@worm-vue3-print/common 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +2 -2
  2. package/dist/browser-bundle.d.ts +1 -1
  3. package/dist/common.js +49 -42
  4. package/dist/core/default-template.d.ts +1 -1
  5. package/dist/core/format.d.ts +1 -1
  6. package/dist/core/h.d.ts +1 -1
  7. package/dist/core/icons.d.ts +1 -1
  8. package/dist/core/store.d.ts +1 -1
  9. package/dist/index.cjs +8 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +390 -383
  12. package/dist/print-designer.d.ts +1 -1
  13. package/dist/shell/binding.d.ts +1 -1
  14. package/dist/shell/canvas.d.ts +1 -1
  15. package/dist/shell/code.d.ts +1 -1
  16. package/dist/shell/color-picker.d.ts +1 -1
  17. package/dist/shell/controls.d.ts +1 -1
  18. package/dist/shell/crop-anchor.d.ts +1 -1
  19. package/dist/shell/elements.d.ts +1 -1
  20. package/dist/shell/expression-editor.d.ts +1 -1
  21. package/dist/shell/flow-list.d.ts +1 -1
  22. package/dist/shell/font-select.d.ts +1 -1
  23. package/dist/shell/format-bar.d.ts +1 -1
  24. package/dist/shell/help-content/changelog.d.ts +1 -1
  25. package/dist/shell/help-content/faq.d.ts +1 -1
  26. package/dist/shell/help-content/features.d.ts +1 -1
  27. package/dist/shell/help-content/getting-started.d.ts +1 -1
  28. package/dist/shell/help-content/index.d.ts +1 -1
  29. package/dist/shell/help-content/shortcuts.d.ts +1 -1
  30. package/dist/shell/help-modal.d.ts +1 -1
  31. package/dist/shell/page-extras.d.ts +1 -1
  32. package/dist/shell/panels.d.ts +1 -1
  33. package/dist/shell/prop-group.d.ts +1 -1
  34. package/dist/shell/property-panel.d.ts +1 -1
  35. package/dist/shell/property-search.d.ts +1 -1
  36. package/dist/shell/ruler.d.ts +1 -1
  37. package/dist/shell/table-props.d.ts +1 -1
  38. package/dist/shell/table.d.ts +1 -1
  39. package/dist/shell/toolbar-overflow.d.ts +1 -1
  40. package/dist/shell/toolbar.d.ts +1 -1
  41. package/dist/shell/watermark.d.ts +1 -1
  42. package/package.json +2 -2
package/dist/common.js CHANGED
@@ -1,5 +1,5 @@
1
- (function(vt){typeof define=="function"&&define.amd?define(vt):vt()})((function(){"use strict";function vt(t){return t/2.83464566929}function vr(t){return t*(25.4/96)}function $t(t){return t*(96/25.4)}const Fs=6,$f=1,Nf=["clip","shrink","autoHeight"];function zs(t){return typeof t=="string"&&Nf.includes(t)?t:void 0}const Lf={text:"clip",longText:"autoHeight",flowList:"clip"};function wr(t,e){return zs(e?.textFit)??Lf[t]??"clip"}function Bs(t){if(t?.keepLineBreaks===!0&&t.wordWrap!==!1)return"pre-wrap"}function Hs(t){return t?.wordWrap===!1?"nowrap":void 0}function ii(t){return zs(t?.textFit)??(t?.wordWrap===!1?"clip":"autoHeight")}function Cn(t){return typeof t!="number"||!Number.isFinite(t)||t<=0?Fs:Math.max(t,$f)}function ai(t){return Math.round(t*100)/100}function Ff(t){return Math.floor(t*100)/100}function zf(t,e,n,r){return`${t}#${e}#${n}:${r}`}function Bf(t){const e=t.indexOf("#");if(e<0)return;const n=t.lastIndexOf("#"),r=t.slice(e+1,n);if(r!=="b"&&r!=="st"&&r!=="sm")return;const[o,i]=t.slice(n+1).split(":").map(Number);if(!(!Number.isFinite(o)||!Number.isFinite(i)))return{elementId:t.slice(0,e),kind:r,rowIndex:o,colIndex:i}}function Us(t,e){return(t||"contain")==="cover"?e:void 0}function si(t,e,n,r=1){const o=Math.max(n?.colspan??1,1);let i=0;for(let c=0;c<o;c++)i+=t[e+c]??0;if(i<=0)return 0;const a=n?.padding??r,l=(vt(n?.borders?.left?.width??0)+vt(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function An(t,e,n,r=1){const o=Math.max(n?.rowspan??1,1);let i=0;for(let c=0;c<o;c++)i+=t[e+c]?.height??8;const a=n?.padding??r,l=(vt(n?.borders?.top?.width??0)+vt(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const li=1,qs=12,Hf=3,Uf=100,qf=0,Wf=50,Ws=25.4/72;function jf(t,e,n,r){return typeof t!="number"||!Number.isFinite(t)?r:Math.min(n,Math.max(e,Math.round(t)))}function ut(t){return jf(t,li,qs,4)}function wt(t){return typeof t!="number"||!Number.isFinite(t)?4:Math.min(Wf,Math.max(qf,t))}function On(t){return typeof t!="number"||!Number.isFinite(t)?8:Math.min(Uf,Math.max(Hf,t))}function Qt(t,e){const n=ut(e),r=Math.min(2,n);return typeof t!="number"||!Number.isFinite(t)?r:Math.min(n,Math.max(1,Math.round(t)))}function Gf(t,e,n){const r=ut(e),o=wt(n),i=t-o*(r-1);return i<=0?0:i/r}function Yf(t,e,n){const r=Math.max(1,Math.floor(n));return t*r+e*(r-1)}function js(t,e){if(!t)return 0;const n=typeof e=="number"&&Number.isFinite(e)&&e>0?e*Ws:12*Ws;let r=0;for(const o of t){if(o===" "){r+=.28;continue}const i=o.codePointAt(0)??0;i>=12288&&i<=12351||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=131072?r+=1:/^[0-9A-Z]$/.test(o)?r+=.6:/^[a-z]$/.test(o)?r+=.5:/^[\u0020-\u007f]$/.test(o)?r+=.4:r+=.75}return r*n}function Vf(t,e){if(!e.autoSpan)return 1;const n=Qt(e.maxSpan,e.columns);if(n<=1||e.colUnitMm<=0)return 1;const r=js(t,e.fontSizePt);for(let o=1;o<=n;o++)if(r<=Yf(e.colUnitMm,e.gapX,o))return o;return n}function Xf(t,e){const n=ut(e.columns),r=wt(e.gapX),o=Gf(e.width,n,r),i=Qt(e.maxSpan,n),a=[];let l=[],c=0;for(const s of t){const d=String(s??""),p=Vf(d,{...e,columns:n,gapX:r,maxSpan:i,colUnitMm:o});l.length>0&&c+p>n&&(a.push({cells:l}),l=[],c=0),l.push({text:d,span:p}),c+=p}return l.length>0&&a.push({cells:l}),a}function xr(t,e){if(typeof t!="string"||!t.includes("{")||!e)return;const n=new Set;for(const r of t.matchAll(/\{([^{}]*)\}/g))for(const o of(r[1]??"").split(/[^A-Za-z0-9_\u4e00-\u9fa5.]/)){const i=o.split(".")[0];i&&!/^\d/.test(i)&&n.add(i)}for(const r of n)if(Array.isArray(e[r]))return r}function Kf(t,e,n){const r=wt(e),o=js("一",n);if(o<=0||t<=0)return li;const i=Math.floor((t+r)/(o+r));return Math.min(qs,Math.max(li,i))}const Gs=t=>`${Math.round(t*1e3)/1e3}mm`;function Zf(t){const e=ut(t.columns),n=wt(t.gapX),r=On(t.rowHeight);return["display:grid",`grid-template-columns:repeat(${e},minmax(0,1fr))`,`column-gap:${Gs(n)}`,`grid-auto-rows:minmax(${Gs(r)},auto)`].join(";")}const In=25.4,Ys=10;function ci(t){return typeof t=="number"&&Number.isFinite(t)?Math.max(0,Math.floor(t)):Ys}const xt=30,Er=10,di=2,Vs=0,Jf=.25,ui=.254;function Qf(t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return null;const e=t/In;for(let n=2;n<=8;n+=.5){const r=Math.max(1,Math.round(Sr(n)*e)),o=r/e;if(o>=ui-1e-9)return{barWidth:n,dotsPerModule:r,moduleWidthMm:o}}return null}function Xs(t,e){const n=Qf(t);if(!n)return"";const r=s=>String(Number(s.toFixed(3))),o=`按 ${t}dpi 推荐条宽倍率 ${n.barWidth}(每模块 ${n.dotsPerModule} 个打印点 = ${r(n.moduleWidthMm)}mm,取达到 ${r(ui)}mm 下限的最小档)`,i=Sr(e??2),a=Math.max(1,Math.round(i*t/In)),l=a/(t/In),c=l>=ui-1e-9?`当前倍率 ${e??2} 折算为 ${a} 点 / ${r(l)}mm,已达标`:`当前倍率 ${e??2} 只有 ${a} 点 / ${r(l)}mm,低于下限`;return`${o};${c}。这里只提示,不会替你改值`}function Pn(t){const e=typeof t=="number"&&Number.isFinite(t)?t:2;return Math.max(1,e/2)}function Sr(t){return Pn(t)*Jf}function eh(t){const{barHeightMm:e,moduleWidthMm:n,boxHeightMm:r,textModules:o}=t,i=typeof e=="number"&&Number.isFinite(e)&&e>0,a=typeof n=="number"&&Number.isFinite(n)&&n>0;if(!i||!a)return xt;const l=Math.max(1,Math.round(e/n));if(!(typeof r=="number"&&Number.isFinite(r)&&r>0))return l;const s=typeof o=="number"&&Number.isFinite(o)&&o>0?o:0,d=Math.floor((r-s*n)/n);return Math.max(1,Math.min(l,d))}function Ks(t,e,n){const r=Math.max(1,Math.round(t*n)),o=Math.floor(e*n);if(o<1)return null;const i=Math.min(r,o);return{dotsPerModule:i,preferredDots:r,moduleWidthMm:i/n}}function th(t){const e=Sr(t.barWidth),n=Math.max(1,Math.ceil(t.unitWidth)),r=t.boxWidthMm>0?t.boxWidthMm/n:Number.POSITIVE_INFINITY,o=t.dpi;if(typeof o=="number"&&Number.isFinite(o)&&o>0){const i=Ks(e,r,o/In);if(i)return i.moduleWidthMm}return Math.min(e,r)}function en(t,e){const n=typeof t=="number"&&t>0?t:Number.POSITIVE_INFINITY,r=typeof e=="number"&&e>0?Math.min(n,e):n;return Number.isFinite(r)?r:0}function nh(t){const e=Math.max(1,Math.ceil(t.unitWidth)),n=Math.max(1,Math.ceil(t.unitHeight)),r=Sr(t.barWidth),o=Math.min(t.boxWidthMm>0?t.boxWidthMm/e:Number.POSITIVE_INFINITY,t.boxHeightMm>0?t.boxHeightMm/n:Number.POSITIVE_INFINITY),i=t.dpi;if(typeof i=="number"&&Number.isFinite(i)&&i>0){const l=Ks(r,o,i/In);if(l)return{moduleWidthMm:l.moduleWidthMm,widthMm:e*l.moduleWidthMm,heightMm:n*l.moduleWidthMm,dotsPerModule:l.dotsPerModule,scaledDown:l.dotsPerModule<l.preferredDots}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:e*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}function pi(t){const e=Pn(t.barWidth),n=c=>nh({unitWidth:c.widthUnits/e,unitHeight:c.heightUnits/e,boxWidthMm:t.boxWidthMm,boxHeightMm:t.boxHeightMm,dpi:t.dpi,barWidth:t.barWidth}),r=t.measure(xt);if(!r)return{barHeightModules:xt,size:null};if(!(typeof t.barHeightMm=="number"&&Number.isFinite(t.barHeightMm)&&t.barHeightMm>0))return{barHeightModules:xt,size:n(r)};const i=Math.max(0,r.heightUnits/e-xt),a=eh({barHeightMm:t.barHeightMm,moduleWidthMm:th({unitWidth:r.widthUnits/e,boxWidthMm:t.boxWidthMm,dpi:t.dpi,barWidth:t.barWidth}),boxHeightMm:t.boxHeightMm,textModules:i});if(a===xt)return{barHeightModules:a,size:n(r)};const l=t.measure(a);return l?{barHeightModules:a,size:n(l)}:{barHeightModules:xt,size:null}}const _r=["top","right","bottom","left"],Zs=new Set(["rect","oval","hline","vline","table"]);function fi(t){return!!t&&!Zs.has(t)}const rh=new Set(["solid","dashed","dotted","double"]);function Js(t,e,n){return typeof t!="number"||!Number.isFinite(t)||t<=0||e==="none"?null:{borderWidth:`${t}pt`,borderStyle:typeof e=="string"&&rh.has(e)?e:"solid",borderColor:n||"#000"}}function Qs(t,e){if(!t||Zs.has(t))return null;const n=Js(e?.borderWidth,e?.borderStyle,e?.borderColor),r={},o=e?.borders;if(o)for(const i of _r){const a=o[i];if(!a)continue;const l=Js(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const oh=/[;"'<>\\(){}\[\]@!#]/,ih=64,Rn=100,el=400;function ah(t){const e=(t??"").trim();return!e||e.length>ih||oh.test(e)?"":e}function tl(t,e){if((t||"contain")!=="cover"||typeof e!="number"||!Number.isFinite(e))return;const n=Math.round(e);if(!(n<=Rn))return Math.min(n,el)}function hi(t,e,n){const r=ah(n),o={};r&&(o.objectPosition=r);const i=tl(t,e);return i!==void 0&&(o.transform=`scale(${Number((i/100).toFixed(2))})`,o.transformOrigin=r||"50% 50%"),o}function Dn(t){return typeof t!="number"||!Number.isFinite(t)?0:(t%360+360)%360}function nl(t,e,n){const r=t.width,o=e,i=Dn(n);let a,l;if(i===0||i===180)a=r,l=o;else if(i===90||i===270)a=o,l=r;else{const c=i*Math.PI/180;a=r*Math.abs(Math.cos(c))+o*Math.abs(Math.sin(c)),l=r*Math.abs(Math.sin(c))+o*Math.abs(Math.cos(c))}return{left:t.left-(a-r)/2,top:t.top-(l-o)/2,width:a,height:l}}const rl=385,ol=new Set(["table","flowList"]);function sh(t){return ol.has(t)}const lh="条码与二维码仅支持 90° 步进;任意角度需 385dpi 以上打印头";function ch(t,e){if(t!=="barcode"&&t!=="qrcode")return!0;const n=e?.printerDpi;return typeof n=="number"&&n>0&&n>=rl}function gi(t,e,n){const r=e?.rotate;if(typeof r!="number"||!Number.isFinite(r))return;const o=Dn(r);if(o!==0&&!ol.has(t)){if(t==="barcode"||t==="qrcode"){if(o===90||o===180||o===270)return o;const i=e?.printerDpi;if(typeof i=="number"&&i>0&&i<rl){const a=Dn(Math.round(o/90)*90);return a===0?void 0:a}}return o}}const Nt={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:216,height:279},Legal:{width:216,height:356},DOT_FULL:{width:241,height:279.4},DOT_HALF:{width:241,height:139.7},DOT_THIRD:{width:241,height:93.1},LABEL_80X60:{width:80,height:60},LABEL_60X40:{width:60,height:40},LABEL_40X30:{width:40,height:30},THERMAL_57:{width:57,height:297},THERMAL_80:{width:80,height:297},THERMAL_110:{width:110,height:297},CUSTOM:{width:210,height:297},CONTINUOUS:{width:80,height:297}},dh=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function tn(t){return dh.has(t)}function Ze(t){const e=tn(t.paperSize),n=t.paperSize==="CUSTOM"||e?{width:t.customWidth??Nt[t.paperSize].width,height:t.customHeight??Nt[t.paperSize].height}:Nt[t.paperSize];return t.orientation==="landscape"&&!e?{width:n.height,height:n.width}:{...n}}function nn(t){if(tn(t.paperSize))return Ze(t);const n=Ze(t);return t.outputRotation===90||t.outputRotation===270?{width:n.height,height:n.width}:n}function mi(t){return tn(t.paperSize)?0:t.outputRotation??0}function tt(t){return tn(t.paperSize)}function Mr(t){return t.options?.pagination??t.pagination}function uh(t){return t.options?.tablePagination??t.tablePagination}const ph=2;function rn(t){return t.type==="table"||t.printElementType?.type==="table"}function fh(t){return t.type||t.printElementType?.type||"text"}function il(t){return gi(fh(t),t.options)}function $n(t,e){const n=e.get(t.id)?.measuredHeight??t.options?.height??0,r=t.options?.top??0,o=il(t);if(o===void 0)return{height:n,shift:0,top:r,rot:void 0};const i=nl({left:t.options?.left??0,top:r,width:t.options?.width??100},n,o);return{height:i.height,shift:r-i.top,top:i.top,rot:o}}function hh(t,e){const n=t.options?.left??0,r=t.options?.tableColWidths??[],o=rn(t)&&r.length>0?r.reduce((c,s)=>c+s,0):t.options?.width??0,i=il(t);if(i===void 0)return{left:n,width:o};const a=e.get(t.id)?.measuredHeight??t.options?.height??0,l=nl({left:n,top:t.options?.top??0,width:o},a,i);return{left:l.left,width:l.width}}function bi(t){const e=t.options??{},n=e.top??0,o=(e.tableRows??[]).reduce((a,l)=>a+(l.height??0),0),i=Math.max(e.height??0,o);return n+i}function al(t){return(e,n)=>{const r=e.options?.top??0,o=n.options?.top??0;if(r!==o)return r-o;const i=e.options?.zIndex??0,a=n.options?.zIndex??0;return i!==a?i-a:(t.get(e.id)??0)-(t.get(n.id)??0)}}function sl(t){const e=t.filter(a=>typeof a.id=="string").map(a=>a),n=new Map;e.forEach((a,l)=>n.set(a.id,l));const r=[...e].sort(al(n)),o=new Set;for(const a of r)rn(a)||a.options?.groupId&&o.add(a.id);const i=new Set;for(const a of ll(r,o).values())for(const l of a)i.add(l);return i}function ll(t,e){const n=new Map;let r=null,o=-1,i=0,a=0;for(const l of t){if(rn(l)){r=l.id,o=bi(l);const p=l.options?.left??0,u=l.options?.tableColWidths??[],f=u.length>0?u.reduce((h,m)=>h+m,0):l.options?.width??0;i=p,a=p+f,n.set(l.id,[]);continue}if(e?.has(l.id)||!r||(l.options?.top??0)<o)continue;const s=l.options?.left??0;s+(l.options?.width??0)<=i||s>=a||n.get(r).push(l.id)}return n}function gh(t,e,n,r){const o=bi(t);let i=o;for(const a of e){const l=n.elements.find(c=>c.id===a);l&&(i=Math.max(i,(l.options?.top??0)+(l.options?.height??0)))}return Math.max(i-o,0)}function mh(t,e){return Math.max(t.options?.height??0,e.get(t.id)?.measuredHeight??0)}function on(t){const e=t.options??{},n=e.left??0;return[n,n+(e.width??100)]}function cl(t,e){return t[0]<e[1]&&e[0]<t[1]}function dl(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function bh(t,e,n){const r=new Map;for(const p of n.values()){if(p.length<2)continue;const u={anchorId:p[0].id,ids:p.map(f=>f.id),forceFirstPage:p.some(f=>Mr(f)?.pageable===!1),band:p.map(on).reduce(dl)};for(const f of p)r.set(f.id,u)}const o=t.filter(p=>!rn(p)&&!p.options?.groupId&&Mr(p)?.pageable!==!1),i=new Map;o.forEach(p=>i.set(p.id,p.id));const a=p=>{let u=p;for(;i.get(u)!==u;)u=i.get(u);let f=p;for(;i.get(f)!==u;){const h=i.get(f);i.set(f,u),f=h}return u},l=(p,u)=>{const f=a(p),h=a(u);f!==h&&i.set(h,f)},c=[];for(const p of o){const u=p.options?.top??0;for(let m=c.length-1;m>=0;m--)c[m].bottom<=u&&c.splice(m,1);const f=u+mh(p,e),h=on(p);for(const m of c)m.bottom>u&&cl(m.x,h)&&l(p.id,m.id);c.push({id:p.id,top:u,bottom:f,x:h})}const s=new Map(o.map(p=>[p.id,p])),d=new Map;for(const p of o){const u=a(p.id),f=d.get(u);f?f.push(p.id):d.set(u,[p.id])}for(const p of d.values()){if(p.length<2)continue;const u={anchorId:p[0],ids:p,forceFirstPage:!1,band:p.map(f=>on(s.get(f))).reduce(dl)};for(const f of p)r.set(f,u)}return r}function yi(t,e){const n=Ze(t),{top:r,bottom:o}=t.margins,i=t.header?.height??0,a=t.footer?.height??0,l=tt(t),c=l?Number.POSITIVE_INFINITY:n.height-r-o-i-a;if(!l&&c<=0)throw new Error(`页面可用高度不足: paper=${n.height}mm, margins=${r+o}mm, header=${i}mm, footer=${a}mm`);const s=new Map;t.elements.forEach((D,L)=>s.set(D.id,L));const d=[...t.elements].sort(al(s)),p=new Set,u=new Map;for(const D of d){if(rn(D))continue;const L=D.options?.groupId;if(!L)continue;p.add(D.id);const W=u.get(L);W?W.push(D):u.set(L,[D])}const f=ll(d,p),h=new Map;for(const[D,L]of f)for(const W of L)h.set(W,D);const m=new Map;for(const D of d)m.set(D.id,D);const b=bh(d,e,u),v=[];let w=[],_=[],T=!1;function z(){return c-ph}function N(D){let L=0;for(const W of _)cl(D,[W.x0,W.x1])&&(L+=W.height);return Math.max(0,L)}function P(D){return z()-N(D)}function k(D,L){_.push({x0:D[0],x1:D[1],height:L})}function S(D,L=on(D)){return T?C(L):D.options?.top??0}function C(D){return Math.max(0,z()-P(D))}let O=!1,R=[];function I(D,L,W){W<=0||R.push(`元素 ${D.id} 旋转 ${L}° 后顶部超出页首 ${Math.round(W*100)/100}mm,打印将被裁切`)}function x(){v.push(O||R.length>0?{pageIndex:v.length,sections:[...w],...O?{overflow:!0}:{},...R.length>0?{warnings:[...R]}:{}}:{pageIndex:v.length,sections:[...w]})}function j(D){D>c&&(O=!0)}function te(D=!1){if(w.length===0){O=O||D;return}x(),w=[],_=[],T=!0,O=!1,R=[]}let fe=0;for(;fe<d.length;){const D=d[fe];if(h.has(D.id)){fe++;continue}const L=b.get(D.id);if(L&&L.anchorId!==D.id){fe++;continue}if(Mr(D)?.pageable===!1||L?.forceFirstPage){if(L){let W=Number.POSITIVE_INFINITY,V;for(const Y of L.ids){const X=m.get(Y);if(!X)continue;const ne=$n(X,e);W=Math.min(W,ne.top),ne.rot!==void 0&&(V={el:X,rot:ne.rot})}V&&I(V.el,V.rot,-W);for(const Y of L.ids)w.push({elementId:Y,type:"element",renderTop:m.get(Y)?.options?.top??0})}else{const W=$n(D,e);W.rot!==void 0&&I(D,W.rot,-W.top),w.push({elementId:D.id,type:"element",renderTop:S(D)})}fe++;continue}rn(D)?fe=ye(D,e,fe):L?fe=Ke(L,fe):fe=de(D,e,d,fe)}return w.length>0&&x(),v.length===0&&v.push({pageIndex:0,sections:[]}),G(),v;function G(){if(l)return;const D=t.margins.left;for(const L of v){const W=[];for(const V of L.sections){if(V.type==="flow-group")continue;const Y=m.get(V.elementId);if(!Y)continue;const{left:X,width:ne}=hh(Y,e),Q=D+X,se=Q+ne-n.width,he=-Q;se>.01?W.push(`元素 ${Y.id} 超出纸面右侧 ${Math.round(se*100)/100}mm,打印将被裁切`):he>.01&&W.push(`元素 ${Y.id} 超出纸面左侧 ${Math.round(he*100)/100}mm,打印将被裁切`)}W.length>0&&(L.warnings=[...L.warnings??[],...W])}}function de(D,L,W,V){const Y=on(D),X=$n(D,L),ne=X.height,Q=()=>{const se=S(D,Y),he=T?se+X.shift:se,_e=he-(D.options?.top??0);j(X.top+_e+X.height),X.rot!==void 0&&!T&&I(D,X.rot,-X.top),w.push({elementId:D.id,type:"element",renderTop:he}),k(Y,ne)};if(ne<=P(Y)){if(Q(),Mr(D)?.keepWithNext&&V+1<W.length){const se=W[V+1],he=$n(se,L).height;if(ne+he>z())return V+1;he>P(Y)&&(w.pop(),_.pop(),te(),Q())}return V+1}return te(),Q(),V+1}function Ke(D,L){const W=D.ids.map(_e=>m.get(_e)).filter(_e=>!!_e);let V=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,X;for(const _e of W){const K=$n(_e,e);V=Math.min(V,K.top),Y=Math.max(Y,K.top+K.height),K.rot!==void 0&&(X={el:_e,rot:K.rot})}const ne=Math.max(Y-V,0),Q=D.band,se=()=>{const _e=T?C(Q)-V:0;j(V+_e+ne),X&&!T&&I(X.el,X.rot,-V);for(const K of W)w.push({elementId:K.id,type:"element",renderTop:(K.options?.top??0)+_e});k(Q,ne)};return ne<=P(Q)?(se(),L+1):(te((T?0:V)+ne>c),se(),L+1)}function ye(D,L,W){const V=D.options??{},Y=V._renderRows??[],X=L.get(D.id)?.measuredRowHeights??[],ne=(V._subtotalTemplates?.length??0)>0,Q=(V._summaryRows?.length??0)>0,se=ne?ul(Y,X,"subtotal"):0,he=Q?ul(Y,X,"summary"):0,_e=pe=>ne&&pe.type==="subtotal"||Q&&pe.type==="summary",K=Y.filter(pe=>!_e(pe)),yt=X.filter((pe,ve)=>!_e(Y[ve]));V._renderRows=K;const ee=Math.min(K.length,yt.length),lt=V._repeatHeaderCount??0,Me=L.get(D.id)?.repeatHeaderHeight??X.slice(0,lt).reduce((pe,ve)=>pe+ve,0),Ae=z(),Ee=on(D);if(Me>Ae)throw new Error(`表格 ${D.id} 的重复表头高度 (${Me.toFixed(1)}mm) 超过页面可用高度 (${Ae.toFixed(1)}mm),请减少重复表头行`);if(ee===0)return w.push({elementId:D.id,type:"table-slice",startRow:0,endRow:0,summary:he>0,renderTop:S(D,Ee)}),k(Ee,he),Fe(D,L,Ee),W+1;const Ot=yt.slice(0,ee).reduce((pe,ve)=>pe+ve,0)+se+he;if(uh(D)?.enabled===!1)return Ot>P(Ee)&&w.length>0&&te(),w.push({elementId:D.id,type:"table-slice",startRow:0,endRow:ee,subtotal:se>0,summary:he>0,renderTop:S(D,Ee)}),k(Ee,Ot),Fe(D,L,Ee),W+1;const It=yh(K,ee);let M=0,J=!0,ue=S(D,Ee),le=0;const ze=()=>P(Ee)-le,Pt=(pe,ve)=>{w.push({elementId:D.id,type:"table-slice",startRow:M,endRow:pe,subtotal:se>0,...!J&&ve?{repeatHeader:!0}:{},renderTop:ue}),k(Ee,le),le=0};for(const pe of It){const ve=yt.slice(pe.start,pe.end).reduce((mr,Rt)=>mr+Rt,0);if(ve+se<=ze()){le+=ve;continue}pe.start>M&&(Pt(pe.start,lt>0),J=!1,M=pe.start),te(),ue=S(D,Ee),le=0,J||(le+=Me),le+=ve}if(M<ee&&Pt(ee,lt>0),he>0)if(he<=ze()){const pe=w.length-1,ve=w[pe];ve&&ve.type==="table-slice"&&ve.elementId===D.id?(w[pe]={...ve,summary:!0},k(Ee,he)):(te(),w.push({elementId:D.id,type:"table-slice",startRow:ee,endRow:ee,summary:!0,renderTop:0}),k(Ee,he))}else te(),w.push({elementId:D.id,type:"table-slice",startRow:ee,endRow:ee,summary:!0,renderTop:0}),k(Ee,he);return Fe(D,L,Ee),W+1}function Fe(D,L,W){const V=f.get(D.id)??[];if(V.length===0)return;const Y=gh(D,V,t),X=D.options??{};if(Y<=P(W)){const ne=w.length-1,Q=w[ne];if(Q&&Q.type==="table-slice"&&Q.elementId===D.id){w[ne]={...Q,type:"flow-group",followElementIds:V,groupTop:Q.renderTop??X.top??0},k(W,Y);return}}te(),w.push({elementId:D.id,type:"flow-group",startRow:0,endRow:0,followElementIds:V,groupTop:0}),k(W,Y)}}function yh(t,e){const n=[];let r=0,o=1;for(let i=0;i<e;i++){for(const a of t[i]?.cells??[])!a.merged&&(a.rowspan??1)>1&&(o=Math.max(o,i+a.rowspan));i+1>=o&&(n.push({start:r,end:i+1}),r=i+1,o=r+1)}return n}function ul(t,e,n){let r=0;for(let o=0;o<t.length;o++)t[o]?.type===n&&(r+=e[o]??0);return r}const Tr=25,pl=5;function vh(t){return Math.max(Tr,t)}function fl(t,e,n=1.1){const r=e>0?t*n:t/n;return vh(Math.round(r))}function wh(t,e,n,r,o=.9){if(n<=0||r<=0)return 100;const i=Math.min(t/n,e/r)*o,a=Math.round(i*100);return Math.max(pl,a)}const xh=2;function hl(t){const e=t.gap??xh,n=[...t.units].sort((i,a)=>i.order-a.order);if(t.available<=0)return{movedIds:[],overflowRemains:!1};if(n.some(i=>i.width<=0))return{movedIds:[],overflowRemains:!1};const r=i=>{const a=n.filter(c=>!i.has(c.id));return t.pinned+a.reduce((c,s)=>c+s.width+e,0)+(i.size>0?t.moreTriggerWidth+e:0)<=t.available};if(r(new Set))return{movedIds:[],overflowRemains:!1};const o=new Set;for(const i of n)if(o.add(i.id),r(o))return{movedIds:[...o],overflowRemains:!1};return{movedIds:[...o],overflowRemains:!0}}function Eh(t){const e=t.gap??4,n=t.boundaryBottom-t.triggerBottom-e,r=t.triggerTop-t.boundaryTop-e;return n>=t.overlayHeight?"down":r>n?"up":"down"}const Sh=["left","top","width","height"];function _h(t){const e={...t.options};for(const n of Sh){const r=e[n];typeof r=="number"&&Number.isFinite(r)&&(e[n]=Mh(vt(r)))}return{...t,options:e}}function Mh(t){return Math.round(t*100)/100}function Th(t){const e={...t};if(delete e.firstPageOverlay,e.unit==="mm")return e;const n=e,r=o=>o?.map(_h)??[];return{...n,unit:"mm",elements:r(n.elements),header:n.header?{...n.header,elements:r(n.header.elements)}:n.header,footer:n.footer?{...n.footer,elements:r(n.footer.elements)}:n.footer}}const vi="标签纸",nt={A4:{width:210,height:297,label:"A4 210×297mm",group:"常用纸张"},A3:{width:297,height:420,label:"A3 297×420mm",group:"常用纸张"},A5:{width:148,height:210,label:"A5 148×210mm",group:"常用纸张"},Letter:{width:216,height:279,label:"Letter 216×279mm",group:"常用纸张"},Legal:{width:216,height:356,label:"Legal 216×356mm",group:"常用纸张"},DOT_FULL:{width:241,height:279.4,label:"全等分 241×279.4mm",group:"针式打印纸"},DOT_HALF:{width:241,height:139.7,label:"二等分 241×139.7mm",group:"针式打印纸"},DOT_THIRD:{width:241,height:93.1,label:"三等分 241×93.1mm",group:"针式打印纸"},LABEL_80X60:{width:80,height:60,label:"80×60mm",group:vi},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:vi},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:vi},THERMAL_57:{width:57,height:297,continuous:!0,label:"57mm",group:"小票纸"},THERMAL_80:{width:80,height:297,continuous:!0,label:"80mm",group:"小票纸"},THERMAL_110:{width:110,height:297,continuous:!0,label:"110mm",group:"小票纸"},CONTINUOUS:{width:80,height:297,continuous:!0,label:"连续纸(自定义宽度)",group:"连续纸"}};function wi(t){return!!t&&nt[t]?.continuous===!0}function Et(t){const e=wi(t.paperSize);let n;if(t.paperSize==="CUSTOM"||e){const r=nt[t.paperSize];n={width:t.customWidth??r?.width??210,height:t.customHeight??r?.height??297}}else{const r=nt[t.paperSize]||nt.A4;n={width:r.width,height:r.height}}return t.orientation==="landscape"&&!e?{width:n.height,height:n.width}:n}function kh(){let t=0;return function(){return t+=1,`cell-${Date.now().toString(36)}-${t}`}}function Ch(){let t=0;return function(){return t+=1,`row-${Date.now().toString(36)}-${t}`}}const Ah=kh(),Oh=Ch(),St={width:.75,style:"solid",color:"#333333"};function xi(t){return JSON.parse(JSON.stringify(t))}function Ei(t){return{id:Ah(),borders:{top:{...St},right:{...St},bottom:{...St},left:{...St}},...t}}function Ih(){const t=[50,50,50],e=(r,o)=>({id:Oh(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:t.map(()=>Ei())}),n=e("header",!0);return n.cells.forEach((r,o)=>{r.formatter=`列${o+1}`,r.align="center",r.fontWeight="bold"}),{rows:[n,e("data"),e("subtotal"),e("summary")],colWidths:t}}function Si(t,e,n){if(!t[e].cells[n].merged)return{r:e,c:n};for(let r=e;r>=0;r--)for(let o=n;o>=0;o--){const i=t[r].cells[o];if(i.merged)continue;const a=i.rowspan??1,l=i.colspan??1;if(r+a-1>=e&&o+l-1>=n)return{r,c:o}}return{r:e,c:n}}function Lt(t,e,n){const r=Si(t,e,n),o=t[r.r].cells[r.c];return{r1:r.r,c1:r.c,r2:r.r+(o.rowspan??1)-1,c2:r.c+(o.colspan??1)-1}}function gl(t,e,n){let r={r1:Math.min(e.r,n.r),c1:Math.min(e.c,n.c),r2:Math.max(e.r,n.r),c2:Math.max(e.c,n.c)};for(;;){let o=!1;for(let i=r.r1;i<=r.r2;i++)for(let a=r.c1;a<=r.c2;a++){const l=Lt(t,i,a),c={r1:Math.min(r.r1,l.r1),c1:Math.min(r.c1,l.c1),r2:Math.max(r.r2,l.r2),c2:Math.max(r.c2,l.c2)};(c.r1!==r.r1||c.c1!==r.c1||c.r2!==r.r2||c.c2!==r.c2)&&(r=c,o=!0)}if(!o)return r}}function ml(t,e){if((e.r2-e.r1+1)*(e.c2-e.c1+1)<2)return"至少选择 2 个单元格";const r=new Set;for(let i=e.r1;i<=e.r2;i++)r.add(t[i].type);if(r.size>1)return"合并区域不能跨越不同类型的行";const o=gl(t,{r:e.r1,c:e.c1},{r:e.r2,c:e.c2});return o.r1!==e.r1||o.c1!==e.c1||o.r2!==e.r2||o.c2!==e.c2?"选区与已有合并区域部分重叠":null}function bl(t,e){const n=t[e.r1].cells[e.c1],r=[];for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const a=t[o].cells[i];a.formatter&&r.push(a.formatter),!(o===e.r1&&i===e.c1)&&(a.merged=!0,a.rowspan=1,a.colspan=1,a.formatter="")}n.rowspan=e.r2-e.r1+1,n.colspan=e.c2-e.c1+1,n.formatter=r.join(" ")}function yl(t,e){for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const o=t[n].cells[r];if(!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1)){const i=Lt(t,n,r),a=o;for(let l=i.r1;l<=i.r2;l++)for(let c=i.c1;c<=i.c2;c++){const s=t[l].cells[c];s.merged=!1,s.rowspan=1,s.colspan=1,Ph(a,s)}o.rowspan=1,o.colspan=1}}}function Ph(t,e){t!==e&&(e.align=t.align,e.valign=t.valign,e.fontSize=t.fontSize,e.fontFamily=t.fontFamily,e.fontWeight=t.fontWeight,e.color=t.color,e.backgroundColor=t.backgroundColor,e.borders=t.borders?xi(t.borders):void 0,e.padding=t.padding,e.wordWrap=t.wordWrap)}function vl(t,e,n){const r=n==="above"?e:e+1,o=t[e],i=o.cells.length,a=o.type==="data"?"header":o.type,l={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:a,height:o.height,...a==="header"?{repeatOnPage:[t[r-1],t[r]].find(c=>c?.type==="header")?.repeatOnPage===!0}:{},cells:Array.from({length:i},()=>Ei())};for(let c=0;c<i;c++)if(r>0&&r<t.length){const s=Lt(t,r-1,c);if(s.r1<r&&s.r2>=r){const d=t[s.r1].cells[s.c1];d.rowspan=(d.rowspan??1)+1,l.cells[c].merged=!0}}t.splice(r,0,l)}function Rh(t,e){if(t.length<=1)return"不能删除最后一行";const n=t[e],r=n.cells.length;for(let o=0;o<r;o++){const i=n.cells[o];if(!i.merged&&(i.rowspan??1)>1){const a=t[e+1].cells[o];Object.assign(a,xi(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=Lt(t,e,o);if(a.r1<e&&a.c1===o){const l=t[a.r1].cells[a.c1];l.rowspan=(l.rowspan??1)-1}}}return t.splice(e,1),null}function wl(t,e,n,r){const o=r==="left"?n:n+1;e.splice(o,0,e[n]);for(const i of t){const a=Ei();if(o>0&&o<i.cells.length){const l=t.indexOf(i),c=Lt(t,l,o-1);if(c.c1<o&&c.c2>=o){const s=t[c.r1].cells[c.c1];l===c.r1&&(s.colspan=(s.colspan??1)+1),a.merged=!0}}i.cells.splice(o,0,a)}}function Dh(t,e,n){if(e.length<=1)return"不能删除最后一列";for(let r=0;r<t.length;r++){const o=t[r].cells[n];if(!o.merged&&(o.colspan??1)>1){const i=t[r].cells[n+1];Object.assign(i,xi(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=Lt(t,r,n);if(i.c1<n&&i.r1===r){const a=t[i.r1].cells[i.c1];a.colspan=(a.colspan??1)-1}}}for(const r of t)r.cells.splice(n,1);return e.splice(n,1),null}function _i(t,e,n){if(n==="data"){const r=t.findIndex((o,i)=>o.type==="data"&&i!==e);if(r>=0)return`数据行已存在(第 ${r+1} 行),全表最多一行`}if(n==="header"){for(let r=0;r<e;r++)if(t[r].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const r=t.findIndex(o=>o.type==="data");if(r<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(e<r)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&t.slice(0,e).some(r=>r.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&t.slice(e+1).some(r=>r.type==="subtotal"))return"汇总行必须位于小计行之后";if(t[e].type==="header"&&n!=="header"){for(let r=e+1;r<t.length;r++)if(t[r].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}if(t[e].type=n,n==="header"){const r=[t[e-1],t[e+1]].find(o=>o?.type==="header");t[e].repeatOnPage=t[e].repeatOnPage!==void 0?t[e].repeatOnPage===!0:r?.repeatOnPage===!0}else delete t[e].repeatOnPage;return null}function $h(t,e){for(const n of t){if(n.type!=="header")break;n.repeatOnPage=e}}function xl(t,e,n,r){for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const a=t[o].cells[i];if(a.merged)continue;if(n==="none"){delete a.borders;continue}const l=Lt(t,o,i),c=l.r1===e.r1,s=l.r2===e.r2,d=l.c1===e.c1,p=l.c2===e.c2,u={...a.borders??{}};n==="all"?(u.top={...r},u.bottom={...r},u.left={...r},u.right={...r}):n==="outer"?(c&&(u.top={...r}),s&&(u.bottom={...r}),d&&(u.left={...r}),p&&(u.right={...r})):n==="inner"&&(c||(u.top={...r}),s||(u.bottom={...r}),d||(u.left={...r}),p||(u.right={...r})),a.borders=u}}const Nh="线型 / 宽度 / 颜色是待应用规格:选中格已有的边框规格一致时会填进这三行;四边不一致的项显示「混合」,一条边都没有时显示「无 / 0」。改完点「全部 / 外侧 / 内部」或勾选上、下、左、右某条边才会写入选中的单元格;「无」是清除边框",Lh="多选时不回显单格边框:线型 / 宽度 / 颜色按当前设置作为批写规格,点「全部 / 外侧 / 内部」或勾选某条边后写入所有选中格;「无」是清除边框",Fh="当前单元格四边边框规格不一致:带「混合」的项不谎报,未改项在点「全部 / 外侧 / 内部」或勾选单边时按缺省档(实线 0.75pt)写入,改任一项即按该值批写";function El(t,e,n){const r={...t.borders??{}};n?r[e]={...n}:delete r[e],t.borders=r.top||r.right||r.bottom||r.left?r:void 0}function kr(t,e){const n=[];for(let r=e.r1;r<=e.r2;r++)for(let o=e.c1;o<=e.c2;o++){const i=t[r]?.cells[o];i&&!i.merged&&n.push(i)}return n}function Mi(t,e){const n=kr(t,e).length;return{mode:n>1?"multi":"single",count:n}}function zh(t,e){const n=kr(t,e);if(!n.length)return null;const r=n[0].cellType??"text";return n.every(o=>(o.cellType??"text")===r)?r:null}function Sl(t,e){const n=[];for(const o of kr(t,e))for(const i of["top","right","bottom","left"]){const a=o.borders?.[i];a&&n.push(a)}const r=o=>{if(!n.length)return;const i=o(n[0]);return n.every(a=>o(a)===i)?i:"mixed"};return{width:r(o=>o.width),style:r(o=>o.style),color:r(o=>o.color)}}const Bh="1px dashed rgba(0,0,0,0.18)";function Cr(t,e={}){return t&&t.style!=="none"?`${t.width}pt ${t.style} ${t.color}`:e.designMode&&e.showGhostBorder!==!1?Bh:"none"}function Nn(t){const e=(t.tableColWidths??[]).reduce((r,o)=>r+o,0),n=(t.tableRows??[]).reduce((r,o)=>r+o.height,0);t.width=Math.round(e*100)/100,t.height=Math.round(n*100)/100}const _l=5;function Hh(t,e,n,r){const o=t.reduce((l,c,s)=>s===e?l:l+c,0),i=r===1/0?1/0:Math.max(_l,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,_l),i)}const Ti=.75,Uh="线型 / 宽度 / 颜色即时生效,这三行显示的就是当前生效规格:已有边框时任改一行都会按新规格铺满四边并清掉单边覆盖;上、下、左、右只给选中的边加框,撤掉一边会把它其余三边落成单边;「无」清除边框,「内部」仅表格单元格可用",Ln=["top","right","bottom","left"];function Ml(t){const e={};for(const n of Ln){const r=t.map(o=>!!o?.[n]);e[n]=r.length>0&&r.every(Boolean)?"on":r.some(Boolean)?"mixed":"off"}return e}const ki=[{value:"none",label:"无"},{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],qh=new Set(["solid","dashed","dotted","double"]),an="none";function Fn(t,e){const n=t.borders?.[e];if(n&&n.style!==an&&typeof n.width=="number"&&Number.isFinite(n.width)&&n.width>0)return!0;const r=t.borderWidth;return t.borderStyle!==an&&typeof r=="number"&&Number.isFinite(r)&&r>0}function Wh(t){const e={};for(const n of Ln)Fn(t,n)&&(e[n]=t.borders?.[n]??{width:t.borderWidth});return e}function jh(t){const e=t.borderWidth;return{width:typeof e=="number"&&Number.isFinite(e)&&e>0?e:Ti,style:t.borderStyle||"solid",color:t.borderColor||"#333333"}}function Tl(t,e,n){if(e!=="inner"){if(t.borders=void 0,e==="none"){t.borderWidth=0;return}t.borderWidth=n.width,t.borderStyle=n.style,t.borderColor=n.color}}function kl(t){return Ln.some(e=>Fn(t,e))}function Ci(t,e){if(!t.length)return;const n=t[0]?.[e];return t.every(r=>r[e]===n)?n:"mixed"}function Gh(t){if(!t)return;const e=typeof t.style=="string"&&qh.has(t.style)?t.style:"solid";return{width:t.width,style:t.style===void 0?void 0:e,color:t.color}}function Yh(t){const e=Ln.map(r=>t.borders?.[r]).filter(r=>typeof r?.width=="number"&&Number.isFinite(r.width)&&r.width>0).map(r=>Gh(r));if(!e.length)return;const n=Ci(e,"style");return{width:Ci(e,"width"),style:n===void 0?"solid":n,color:Ci(e,"color")}}function Cl(t){const e=t.borderWidth,n=typeof e=="number"&&Number.isFinite(e),r=Yh(t),o=n&&e>0;if(r&&!o)return r;const i=o?t.borderStyle||"solid":an;return n?{width:e,style:i,color:t.borderColor}:{width:void 0,style:i,color:void 0}}function Al(t){const e=Cl(t);return{width:typeof e.width=="number"&&e.width>0?e.width:Ti,style:typeof e.style=="string"&&e.style!==an?e.style:"solid",color:typeof e.color=="string"?e.color:"#333333"}}function Vh(t,e){t.borderWidth=e.width,t.borderStyle=e.style,t.borderColor=e.color,t.borders=void 0}function Xh(t,e,n){if(e==="borderStyle"&&n===an){const r=kl(t);t.borderStyle=an,r&&(t.borderWidth=0,t.borders=void 0);return}if(!kl(t)){if(e==="borderStyle"){t.borderStyle=n,t.borderWidth=Ti;return}Object.assign(t,{[e]:n});return}if(e==="borderWidth"&&(typeof n!="number"||!(n>0))){t.borderWidth=typeof n=="number"&&n<0?0:n,t.borders=void 0;return}Vh(t,jh({...t,[e]:n}))}function Ai(t,e,n,r){if(n!==Fn(t,e)){if(!n){const o=t.borderWidth;if(typeof o!="number"||!(o>0)){Ol(t,e,null);return}const i={};for(const a of Ln){if(a===e)continue;const l=t.borders?.[a];i[a]={width:l?.width??o,...l?.style!==void 0?{style:l.style}:t.borderStyle!==void 0?{style:t.borderStyle}:{},...l?.color!==void 0?{color:l.color}:t.borderColor!==void 0?{color:t.borderColor}:{}}}t.borders=i,t.borderWidth=0;return}Ol(t,e,r??Al(t))}}function Ol(t,e,n){const r={...t.borders??{}};n?r[e]={width:n.width,style:n.style,color:n.color}:delete r[e],t.borders=r}const Il=96/25.4,Pl=1,Kh=8,Zh=210;function Oi(t,e){if(!t||typeof t!="object")return;if(Array.isArray(t)){for(const r of t)Oi(r,e);return}const n=t;typeof n.printerDpi=="number"&&n.printerDpi>0&&e.add(n.printerDpi);for(const r of Object.keys(n)){if(r==="printerDpi")continue;const o=n[r];o&&typeof o=="object"&&Oi(o,e)}}function Jh(t){if(!t)return null;const e=new Set;return Oi(t,e),e.size?Math.max(...e):null}function Qh(t){const e=t?.pages?.[0]??t;return e?Et(e).width*Il:Zh*Il}function eg(t,e){return t<=0||e<=0?Pl:Math.min(Kh,Math.max(Pl,Math.floor(t/e)))}function tg(t,e,n){const r=[];return t&&r.push({key:"dots",value:t/96,label:`点阵 ${t}dpi`,tip:`1 屏幕像素 = 1 个打印点(${t}dpi ÷ 96dpi)。条与间隙按纸面逐点显示,不会在屏幕上糊成一片`}),r.push({key:"fit",value:eg(e,n),label:"适配",tip:"按容器宽放大到放得下整页的最大整数倍"},{key:"100",value:1,label:"100%",tip:"按 CSS 真实尺寸显示(1mm = 3.78 屏幕像素),热敏点距在此档不可分辨"},{key:"200",value:2,label:"200%",tip:"整数倍放大,避免非整数缩放带来的半像素边"},{key:"400",value:4,label:"400%",tip:"整数倍放大,避免非整数缩放带来的半像素边"}),r}function Rl(t){return"100"}function ng(t,e){return!t||e==="dots"?"":`条码看不清?切「点阵 ${t}dpi」档(1 屏幕像素 = 1 打印点)`}const Dl="print-preview-zoom-guard";function rg(t,e){if(!t?.documentElement)return;let n=t.getElementById(Dl);n||(n=t.createElement("style"),n.id=Dl,(t.head??t.documentElement).appendChild(n)),n.textContent=`html{zoom:${e}}@media print{html{zoom:1 !important}}`}function og(t,e,n){return t.some(r=>r.key===e)?e:Rl()}function ig(t,e){return t.find(n=>n.key===e)?.value??1}function sn(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ii(t){const e={left:7,top:17.6,width:42.3,height:7.1};switch(t){case"text":return{...e,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...e,width:28.2,height:28.2,fit:"contain"};case"longText":return{...e,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:n,colWidths:r}=Ih(),o=r.reduce((a,l)=>a+l,0),i=n.reduce((a,l)=>a+l.height,0);return{...e,width:o,height:i,tableMode:"dynamic",tableRows:n,tableColWidths:r,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"flowList":return{...e,width:141.1,height:21.2,fontSize:12,formatter:"{name} {spec}",flowColumns:4,flowRowHeight:8,flowGapX:4,flowAutoSpan:!1,flowMaxSpan:2};case"hline":return{...e,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...e,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...e,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...e,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...e,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...e,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...e,width:28.2,height:28.2};default:return e}}function $l(t,e){const n={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},flowList:{title:"流式列表"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:sn(),options:{...Ii(t),...e},printElementType:{type:t,title:n[t]?.title||t}}}const Nl=["text","image","hline","vline","rect","oval","barcode","qrcode"];function ag(t){return Et(t)}function Pi(t){const e=ag(t),n=t.margins,r=t.header.height,o=t.footer.height,i=e.width-n.left-n.right,a=e.height-n.top-n.bottom-r-o,l=(c,s,d,p)=>({left:c,top:s,width:d,height:p});return{header:l(n.left,n.top,i,r),content:l(n.left,n.top+r,i,a),footer:l(n.left,e.height-n.bottom-o,i,o)}}function Ll(t,e,n){const r=Pi(t);return r.footer.height>0&&n>=r.footer.top?"footer":r.header.height>0&&n<r.header.top+r.header.height?"header":"content"}function Ri(t,e){const n=t.options;n.width=Math.min(n.width,e.width),n.height=Math.min(n.height,e.height),n.left=Math.min(Math.max(0,n.left),e.width-n.width),n.top=Math.min(Math.max(0,n.top),e.height-n.height)}function sg(t,e){const n=Pi(e),r=t.zone||"content",o=n[r],i=o.left+t.options.left+t.options.width/2,a=o.top+t.options.top+t.options.height/2;let l=Ll(e,i,a),c=!1;if(l!=="content"&&!Nl.includes(t.printElementType.type)&&(l="content",c=!0),l!==r){const s=n[l];t.options.left=o.left+t.options.left-s.left,t.options.top=o.top+t.options.top-s.top,t.zone=l}return l!=="content"?Ri(t,n[l]):c&&Ri(t,n.content),{rejected:c}}const Di=22,$i=[1,2,5,10,20,50,100,200,500,1e3];function lg(t,e=64){const n=t*3.7795275590551185;for(const r of $i)if(r*n>=e)return r;return $i[$i.length-1]}function cg(t){const e=Math.floor(Math.log10(t)+1e-9),n=t/10**e;return n===5||n===1&&t>=10?t/5:n===2?t/2:null}function dg(t){return Math.round(t*1e3)/1e3}function ug(t,e,n){if(e<t||n<=0)return[];const o=cg(n)??n,i=Math.ceil(t/o-1e-9)*o,a=Math.floor((e-i)/o+1e-9),l=[];for(let c=0;c<=a;c++){const s=dg(i+c*o);Math.abs(s/n-Math.round(s/n))<1e-6?l.push({mm:s,major:!0,label:String(s)}):l.push({mm:s,major:!1})}return l}const Fl=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Ar=[{group:"position-size",groupLabel:"位置与尺寸",items:[{key:"ps-left",keywords:["X","横坐标","left","位置"]},{key:"ps-top",keywords:["Y","纵坐标","top","位置"]},{key:"ps-width",keywords:["W","宽度","width","尺寸"]},{key:"ps-height",keywords:["H","高度","height","尺寸"]}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-family",keywords:["字体","字体名","字体族","fontfamily"]},{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]},{key:"ap-text-fit",keywords:["溢出","溢出显示","截断","自动缩小","自适应行高","textfit","overflow"]},{key:"ap-shrink-min",keywords:["最小字号","缩放下限","shrinkminfontsize"],default:Fs,defaultUnit:"pt"},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{key:"ap-keep-line-breaks",keywords:["保留换行符","换行符","手动换行","保留空格","连续空格","行首空格","keeplinebreaks"]},{key:"ap-long-text-indent",keywords:["首行缩进","缩进","indent","longtextindent","两字符","段首"],tip:"长文本每段首行空出的宽度,单位「字符」:填 2 即缩进两个汉字宽(中文排版惯例),按 em 落纸——字号被「自动缩小」压小时缩进同步变窄。仅长文本元素生效,写在普通文本上不生效"},{key:"ap-img-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover","填充","裁剪","剪裁","锚点"],tip:"图片在元素框内的缩放方式:包含=完整显示、可能留白;剪裁=铺满框并按「裁剪锚点」取一块;拉伸=填满框会变形;原始尺寸与缩小不放大。画布与三条出纸链路同一口径(缺省包含)"},{key:"ap-img-object-position",keywords:["裁剪锚点","剪裁锚点","锚点","objectposition","object-position","对齐点","上移","头顶"],tip:"取位(仅「剪裁」档有这一行):剪裁把图等比铺满元素框,多出来的那一条边按这里选的位置取舍。先选位置档(贴边/居中/贴另一头),再按百分比微调,0 贴左/贴顶,100 挪到另一头,水平与垂直各自独立;缺省取正中间(保住证件照头顶就选顶部)。其余缩放模式图比框小或刚好铺满,没有可裁的边,所以不出本行"},{key:"ap-img-fit-scale",keywords:["放大比例","剪裁放大","放大倍数","取景","裁切范围","fitscale","zoom"],default:Rn,defaultUnit:"%",tip:"剪裁放大:等比铺满之后把画面再推大这么多,两轴才真的各多出一条边可裁——图与框同比例时不放大就什么都裁不掉。100=不放大(缺省),上限 400;超出框的部分由元素框裁掉。锚点选中的那一点既是取位的钉住点、也是放大的中心,两者共用同一个值。仅「剪裁」档生效,其余缩放模式不出本行"},{key:"ap-rotate",keywords:["旋转","角度","rotate","angle","顺时针","逆时针","90度","直角"],tip:"元素绕自身中心旋转的角度(度,0~359):出纸时按旋转后外接盒分页与结算,底部放不下自动移页,超出纸面左右缘或顶部会被裁切并给出纸提示。表格、流式列表与表格下方跟随区的元素不支持旋转(这三类不出本行);条码与二维码的任意角度需 385dpi 以上打印头,低分辨率打印机只按 90° 步进出纸"}]},{group:"flow-list",groupLabel:"流式列表",items:[{key:"fl-columns",keywords:["每行列数","列数","栏数","几列","flowcolumns"],tip:"一行排几个单元,必须由你指定——不随内容自动算列数。填的列数乘单元宽放不下元素框时只给提示、不改你的数,出纸按你填的排"},{key:"fl-row-height",keywords:["行高","每行高度","单元高度","flowrowheight"],tip:"每个单元行的最低高度(毫米),与表格行高同一口径:内容比它高时这一行会撑高,不会裁字"},{key:"fl-gap-x",keywords:["单元间距","横向间距","格间距","列间距","flowgapx"],tip:"相邻单元之间的横向留白(毫米);纵向不留缝,行与行的距离由行高承担"},{key:"fl-auto-span",keywords:["自适应","跨列","内容过长","占两列","自动换行","flowsautspan","flowautospan"],tip:"单元内容比一列还宽时,让它占掉两个或更多列位;当前行剩不够放就把整个单元挪到下一行行首(绝不把词切两半)。默认关——开着时出纸栏数由字号与框宽决定"},{key:"fl-max-span",keywords:["最多跨几列","跨列上限","flowmaxspan"],tip:"跨列的列数上限,最大只能等于「每行列数」:把每行列数改小时,这里会被一并顶回去"}]},{group:"code",groupLabel:"条码设置",items:[{key:"cd-type",keywords:["码制","条码类型","条形码类型","barcodetype","code128","ean13","code39","itf14"]},{key:"cd-dpi",keywords:["打印机分辨率","dpi","打印点","点阵对齐","203","300"]},{key:"cd-bar-width",keywords:["条宽","条粗细","barwidth","模块宽"]},{key:"cd-bar-quiet-zone",keywords:["条码静区","条码白边","条形码留白","条码空白边","barquietzone"],default:Ys,defaultUnit:"模块",tip:"条形码左右两端的空白格数(1 格 = 1 条宽):缺省 10,正是一维码码制要求的下限;数值越小白边越窄、同样的框内条越粗(可放大)。填 0 即不留白边,但静区参与「条→空→条」跳变,紧邻文字或表格线时可能扫不出,需实打验证"},{key:"cd-bar-height",keywords:["条高","条码高度","条区高度","条码多高","barheight"],default:xt,defaultUnit:"模块",tip:"黑白条本体的目标高度(mm,不含下方文字):折算粒度就是每模块物理宽,所以只能精确到它的整数倍。条宽优先——可用框高装不下时期望条高让位,绝不把条宽挤窄(热敏出纸清晰度靠条宽)。与「最大高度」分工不同:那条限的是整图(含文字)的上限"},{key:"cd-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"],default:Er,defaultUnit:"模块"},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],default:Vs,defaultUnit:"模块",tip:"二维码四周留出的空白格数:0 即不留白边、码面等比铺满元素框(此时靠框外的白纸充当静区);数值越大白边越宽、码面在框内越小(缺省 0,需 ISO/IEC 18004 推荐静区时填 4)"},{key:"cd-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover"]},{key:"cd-max-width",keywords:["最大宽度","最大宽","maxwidth"]},{key:"cd-max-height",keywords:["最大高度","最大高","maxheight"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-style",keywords:["线型","边框线型","实线","虚线","点线","双线","borderstyle"]},{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function Oe(t){for(const e of Ar){const n=e.items.find(r=>r.key===t);if(n)return n.tip??""}return""}function pg(t,e){const n=t.trim().toLowerCase();return n?e.some(r=>r.toLowerCase().includes(n)):!0}function fg(t){const e=[],n=new Set;for(const r of Ar){const o=r.items.filter(i=>pg(t,[...i.keywords,r.groupLabel]));if(o.length>0){e.push(r.group);for(const i of o)n.add(i.key)}}return{groups:e,itemKeys:n}}function hg(t){for(const e of Ar)for(const n of e.items)if(n.key===t&&n.default!==void 0)return{value:n.default,unit:n.defaultUnit}}const gg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),mg=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function Ni(t){const e=[];let n=0;const r=t.length;for(;n<r;){const o=t[n];if(/\s/.test(o)){n++;continue}if(/[0-9]/.test(o)||o==="."&&n+1<r&&/[0-9]/.test(t[n+1])){let l=n;for(;l<r&&/[0-9.]/.test(t[l]);)l++;e.push({type:"num",value:t.slice(n,l),position:n}),n=l;continue}if(o==="'"||o==='"'){let l=n+1,c="";for(;l<r&&t[l]!==o;)t[l]==="\\"&&l+1<r?(c+=t[l+1],l+=2):(c+=t[l],l++);if(l>=r)throw new Error("字符串未闭合");e.push({type:"str",value:c,position:n}),n=l+1;continue}if(/[A-Za-z_$]/.test(o)){let l=n;for(;l<r&&/[A-Za-z0-9_$]/.test(t[l]);)l++;const c=t.slice(n,l);if(mg.has(c))throw new Error(`不允许使用关键字: ${c}`);if(gg.has(c))throw new Error(`禁止访问: ${c}`);c==="true"||c==="false"?e.push({type:"bool",value:c,position:n}):e.push({type:"ident",value:c,position:n}),n=l;continue}const i=t.slice(n,n+3);if(i==="==="||i==="!=="){e.push({type:"punc",value:i,position:n}),n+=3;continue}const a=t.slice(n,n+2);if(a==="=>")throw new Error("不允许函数定义");if(["==","!=","<=",">=","&&","||"].includes(a)){e.push({type:"punc",value:a,position:n}),n+=2;continue}if(o==="=")throw new Error("不允许赋值");if(o===";")throw new Error("不允许多条语句");if("+-*/%()[]{},:.?!<>".includes(o)){e.push({type:"punc",value:o,position:n}),n++;continue}throw new Error(`非法字符: ${o}`)}return e}function Li(t){return new bg(t).parse()}class bg{constructor(e){this.pos=0,this.tokens=e}parse(){const e=this.parseTernary();if(this.pos<this.tokens.length)throw new Error(`表达式存在多余内容: ${this.tokens[this.pos].value}`);return e}peek(){return this.tokens[this.pos]}next(){const e=this.tokens[this.pos++];if(!e)throw new Error("表达式意外结束");return e}eatPunc(e){const n=this.peek();return n&&n.type==="punc"&&n.value===e?(this.pos++,!0):!1}expectPunc(e){if(!this.eatPunc(e)){const n=this.peek()?.position??0;throw new Error(`位置 ${n}: 期望 "${e}"`)}}parseTernary(){const e=this.parseLogicalOr();if(this.eatPunc("?")){const n=this.parseTernary();this.expectPunc(":");const r=this.parseTernary();return{type:"ternary",cond:e,consequent:n,alternate:r}}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.eatPunc("||");){const n=this.parseLogicalAnd();e={type:"binary",op:"||",left:e,right:n}}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.eatPunc("&&");){const n=this.parseEquality();e={type:"binary",op:"&&",left:e,right:n}}return e}parseEquality(){let e=this.parseRelational();for(;;){const n=this.peek();if(n?.type==="punc"&&["==","!=","===","!=="].includes(n.value)){this.pos++;const r=this.parseRelational();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseRelational(){let e=this.parseAdditive();for(;;){const n=this.peek();if(n?.type==="punc"&&["<",">","<=",">="].includes(n.value)){this.pos++;const r=this.parseAdditive();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseAdditive(){let e=this.parseMultiplicative();for(;;){const n=this.peek();if(n?.type==="punc"&&(n.value==="+"||n.value==="-")){this.pos++;const r=this.parseMultiplicative();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseMultiplicative(){let e=this.parseUnary();for(;;){const n=this.peek();if(n?.type==="punc"&&["*","/","%"].includes(n.value)){this.pos++;const r=this.parseUnary();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseUnary(){const e=this.peek();if(e?.type==="punc"&&["!","-","+"].includes(e.value)){this.pos++;const n=this.parseUnary();return{type:"unary",op:e.value,arg:n,prefix:!0}}return this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.eatPunc(".")){const n=this.next();if(n.type!=="ident")throw new Error(`位置 ${n.position}: 成员访问需要属性名`);e={type:"member",object:e,property:n.value,computed:!1}}else if(this.eatPunc("[")){const n=this.parseTernary();this.expectPunc("]"),n.type==="str"?e={type:"member",object:e,property:n.value,computed:!1}:e={type:"member",object:e,property:n.name??String(n.value),computed:!0}}else if(this.peek()?.type==="punc"&&this.peek()?.value==="("&&(e.type==="ident"||e.type==="member")){this.pos++;const n=this.parseArgs();e={type:"call",callee:e,args:n}}else return e}parseArgs(){const e=[];if(this.eatPunc(")"))return e;for(;;){if(e.push(this.parseTernary()),this.eatPunc(")"))return e;this.expectPunc(",")}}parsePrimary(){const e=this.next();if(e.type==="num"){const n=Number(e.value);if(isNaN(n))throw new Error(`非法数字: ${e.value}`);return{type:"num",value:n}}if(e.type==="str")return{type:"str",value:e.value};if(e.type==="bool")return{type:"bool",value:e.value==="true"};if(e.type==="ident")return{type:"ident",name:e.value};if(e.value==="("){const n=this.parseTernary();return this.expectPunc(")"),n}if(e.value==="["){const n=[];if(!this.eatPunc("]"))for(;n.push(this.parseTernary()),!this.eatPunc("]");)this.expectPunc(",");return{type:"array",elements:n}}if(e.value==="{"){const n=[];if(!this.eatPunc("}"))for(;;){const r=this.next();if(r.type!=="ident"&&r.type!=="str")throw new Error(`位置 ${r.position}: 对象键必须是标识符或字符串`);if(this.expectPunc(":"),n.push({key:r.value,value:this.parseTernary()}),this.eatPunc("}"))break;this.expectPunc(",")}return{type:"object",properties:n}}throw new Error(`位置 ${e.position}: 意外的符号: ${e.value}`)}}const zl=20,yg=8;function Ue(t,e=0){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"){const n=t.trim();if(n==="")return e;const r=Number(n);return Number.isFinite(r)?r:e}return t==null?e:typeof t=="boolean"?t?1:0:e}function vg(t){if(typeof t=="number")return Number.isFinite(t);if(typeof t=="string"){const e=t.trim();return e!==""&&Number.isFinite(Number(e))}return!1}function ln(t){return!Number.isFinite(t)||Number.isInteger(t)||Math.abs(t)>=1e15?t:Number(t.toPrecision(12))}function cn(t){if(!Number.isFinite(t)||Number.isInteger(t))return 0;const e=String(t);if(e.includes("e")||e.includes("E"))return 0;const n=e.indexOf(".");return n===-1?0:e.length-n-1}function Fi(t,e){if(!Number.isFinite(t))return 0;const n=Math.min(Math.max(e,0),12);if(n===0)return Math.round(t);const r=10**n,o=t*r;return!Number.isFinite(o)||Math.abs(o)>=1e15?ln(t):Math.round(o)/r}function zi(t,e){const n=Ue(t),r=Ue(e),o=n+r;return Fi(o,Math.max(cn(n),cn(r)))}function Bi(t,e){const n=Ue(t),r=Ue(e),o=n-r;return Fi(o,Math.max(cn(n),cn(r)))}function Bl(t,e){const n=Ue(t),r=Ue(e),o=n*r;return Fi(o,cn(n)+cn(r))}function Hl(t,e){const n=Ue(t),r=Ue(e);return r===0?0:ln(n/r)}function wg(t,e){const n=Ue(t),r=Ue(e);return r===0?0:ln(n%r)}function xg(t){if(t==null)return 2;const e=Math.trunc(Ue(t,2));return Number.isFinite(e)?Math.min(Math.max(e,-zl),zl):2}function Or(t,e,n){const r=Ue(t,0),o=xg(e);if(r===0)return 0;if(Math.abs(r)>=1e21)return ln(r);const i=Math.max(o,0)+yg,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return ln(r);const l=a.startsWith("-"),c=a.replace("-","").replace(".","");let s=BigInt(c||"0");l&&(s=-s);const d=10n**BigInt(i-o),p=s<0n?-1n:1n,u=s<0n?-s:s;let f=u/d;const h=u%d,m=2n*h;n==="up"?h!==0n&&(f+=1n):n!=="down"&&m>=d&&(m>d||n==="half-up"||f%2n===1n)&&(f+=1n);const b=p*f;return ln(o>=0?Number(b)/10**o:Number(b)*10**-o)}const Hi={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},Eg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),Sg=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function Ie(t,e,n={}){switch(t.type){case"num":return t.value;case"str":return t.value;case"bool":return t.value;case"ident":return _g(t.name,e);case"binary":return Mg(t,e,n);case"unary":return Tg(t,e,n);case"ternary":return Ie(t.cond,e,n)?Ie(t.consequent,e,n):Ie(t.alternate,e,n);case"member":return Ag(t,e,n);case"call":return Og(t,e,n);case"array":return t.elements.map(r=>Ie(r,e,n));case"object":return Object.fromEntries(t.properties.map(r=>[r.key,Ie(r.value,e,n)]))}}function _g(t,e,n){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(Object.prototype.hasOwnProperty.call(Hi,t))return Hi[t];throw new Error(`未定义的标识符: ${t}`)}function Mg(t,e,n){const r=Ie(t.left,e,n),o=Ie(t.right,e,n);switch(t.op){case"+":return Cg(r,o)?zi(r,o):kg(r,o);case"-":return Bi(r,o);case"*":return Bl(r,o);case"/":return Hl(r,o);case"%":return wg(r,o);case"<":return r<o;case">":return r>o;case"<=":return r<=o;case">=":return r>=o;case"==":return r==o;case"!=":return r!=o;case"===":return r===o;case"!==":return r!==o;case"&&":return r&&o;case"||":return r||o;default:throw new Error(`未知运算符: ${t.op}`)}}function Tg(t,e,n){const r=Ie(t.arg,e,n);switch(t.op){case"-":return Bi(0,r);case"+":return Ue(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${t.op}`)}}function kg(t,e){return`${t==null?"":String(t)}${e==null?"":String(e)}`}function Cg(t,e){const n=Ul(t),r=Ul(e);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function Ul(t){return t==null||t===""?"neutral":vg(t)?"num":"other"}function Ag(t,e,n){const r=Ie(t.object,e,n);if(r==null)throw new Error("无法访问空值的属性");if(Eg.has(t.property))throw new Error(`禁止访问属性: ${t.property}`);return r[t.property]}function Og(t,e,n){if(t.callee.type==="ident"&&Sg.has(t.callee.name)){const o=Hi[t.callee.name],i=t.args.map(a=>Ie(a,e,n));return o(...i)}if(t.callee.type==="member"&&t.callee.object.type==="ident"&&t.callee.object.name==="Math"){const o=Math[t.callee.property];if(typeof o!="function")throw new Error(`Math.${t.callee.property} 不是方法`);const i=t.args.map(a=>Ie(a,e,n));return o(...i)}let r;if(t.callee.type==="ident")r=t.callee.name;else if(t.callee.type==="member")throw new Error("不支持方法调用,请使用顶级函数");if(r&&n[r]){const o=t.args.map(i=>Ie(i,e,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(e,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function Ig(t){const e=[];let n=0;const r=t.length;for(;n<r;){if(t[n]==="{"){let i=1,a=n+1;for(;a<r&&i>0;)t[a]==="{"?i++:t[a]==="}"&&i--,a++;if(i!==0)throw new Error(`位置 ${n}: 花括号未闭合`);const l=t.slice(n+1,a-1);if(l.trim()==="")throw new Error(`位置 ${n}: 空表达式`);const c=Ni(l),s=Li(c);e.push({type:"expr",expression:s}),n=a;continue}let o=n;for(;o<r&&t[o]!=="{";)t[o]==="\\"&&o+1<r&&(t[o+1]==="{"||t[o+1]==="}")?o+=2:o++;e.push({type:"text",value:t.slice(n,o).replace(/\\([{}])/g,"$1")}),n=o}return{type:"template",parts:e}}function Pg(t,e,n={}){let r="";for(const o of t.parts)if(o.type==="text")r+=o.value;else{const i=Ie(o.expression,e,n);r+=String(i??"")}return r}function ql(t,e={}){const n=Ig(t);return r=>Pg(n,r,e)}function zn(t,e){if(t==null||e==null)return;if(typeof t=="object"&&e in t)return t[e];const n=e.split(".");let r=t;for(const o of n){if(r==null)return;r=r[o]}return r}function Wl(t){const e=Number(t);if(isNaN(e))return String(t);const n=e<0?"-":"",r=Math.abs(e),[o,i]=r.toFixed(2).split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n}${a}.${i}`}function jl(t,e){let n;if(t instanceof Date)n=t;else if(typeof t=="number")n=new Date(t);else if(typeof t=="string")n=new Date(t);else return String(t);if(isNaN(n.getTime()))return String(t);const r=o=>String(o).padStart(2,"0");return e.replace("YYYY",String(n.getFullYear())).replace("MM",r(n.getMonth()+1)).replace("DD",r(n.getDate())).replace("HH",r(n.getHours())).replace("mm",r(n.getMinutes())).replace("ss",r(n.getSeconds()))}const Ui=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],Rg=["","拾","佰","仟"],Dg=["","万","亿","万亿","亿亿"];function $g(t){let e="",n=!1;for(let r=3;r>=0;r--){const o=Math.floor(t/10**r)%10;if(o===0){e&&(n=!0);continue}n&&(e+="零",n=!1),e+=Ui[o]+Rg[r]}return e}function Gl(t){const e=Number(t);if(isNaN(e))return String(t);if(e===0)return"零元整";const n=e<0?"负":"",[r,o]=Math.abs(e).toFixed(2).split("."),i=Math.ceil(r.length/4);let a="",l=!1;for(let d=i-1;d>=0;d--){const p=r.length-d*4,u=parseInt(r.slice(Math.max(0,p-4),p),10);if(u===0){a&&(l=!0);continue}a&&(l||u<1e3)&&(a+="零"),l=!1,a+=$g(u)+(Dg[d]??"")}a=`${a||"零"}元`;const c=parseInt(o[0],10),s=parseInt(o[1],10);return c===0&&s===0?a+="整":(c===0?a+="零":a+=Ui[c]+"角",s>0&&(a+=Ui[s]+"分")),n+a}function Yl(t,e,n){return t?e:n}function qi(t,e){return t.reduce((n,r)=>n+(Number(zn(r,e))||0),0)}function Vl(t,e){return t.length===0?0:qi(t,e)/t.length}function Xl(t,e){return t.length}function Kl(t,e){return t.length===0?0:Math.min(...t.map(n=>Number(zn(n,e))||0))}function Zl(t,e){return t.length===0?0:Math.max(...t.map(n=>Number(zn(n,e))||0))}function Jl(...t){return t.reduce((e,n)=>zi(e,n),0)}function Ql(...t){return t.length===0?0:t.slice(1).reduce((e,n)=>Bi(e,n),zi(t[0],0))}function ec(...t){return t.length===0?0:t.reduce((e,n)=>Bl(e,n),1)}function tc(t,e){return Hl(t,e)}function nc(t,e){return Or(t,e,"half-up")}function Ir(t,e){return Or(t,e,"up")}function Pr(t,e){return Or(t,e,"down")}function rc(t,e){return Or(t,e,"half-even")}class Ng{constructor(){this.functions={}}registerFunction(e,n){this.functions[e]=n}evaluate(e,n){const r=Ni(e),o=Li(r);return Ie(o,n,this.functions)}render(e,n){return ql(e,this.functions)(n)}}const Wi=new Ng,Lg={MONEY:Wl,DATE:jl,UPPER:Gl,IF:Yl,CONCAT:(...t)=>t.filter(e=>e!=null).map(String).join(""),IFEMPTY:(t,e)=>t!=null&&t!==""?String(t):e,LEN:t=>String(t).length,ADD:Jl,SUB:Ql,MUL:ec,DIV:tc,ROUND:nc,ROUNDUP:Ir,CEIL:Ir,ROUNDDOWN:Pr,FLOOR:Pr,ROUNDBANK:rc};for(const[t,e]of Object.entries(Lg))Wi.registerFunction(t,e);function Fg(t,e,n){switch(t.toUpperCase()){case"SUM":return qi(n,e);case"AVG":return Vl(n,e);case"COUNT":return Xl(n);case"MIN":return Kl(n,e);case"MAX":return Zl(n,e);default:return 0}}function zg(t,e){return Wi.evaluate(t,e)}function _t(t,e){if(!t)return"";if(!t.includes("{"))return t;const n=Array.isArray(e.rows)?e.rows:[],r=t.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(Fg(c,d,n))}),`{${a}}`});try{return Wi.render(r,e)}catch{return t}}function oc(t,e,n,r){const o={...$r(),...e??{}},i=JSON.parse(JSON.stringify(t));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>ji(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>ji(l,o,n))),i.elements=i.elements.map(l=>ji(l,o,n));const a=r??n;if(a&&i.fonts?.length){const l=a.replace(/\/+$/,"");i.fonts=i.fonts.map(c=>({...c,files:(c.files??[]).map(s=>({...s,url:s.url?.startsWith("/")&&!s.url.startsWith("//")?l+s.url:s.url}))}))}return i}function ji(t,e,n){const r={...t,options:{...t.options}};if(!(r.type==="flowList"||r.printElementType?.type==="flowList")&&typeof r.options.formatter=="string"){const a=r.options.formatter;Hn(a)?r.options.rawFormatter=a:r.options.formatter=_t(a,e)}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let a=r.options.src;a.includes("{")&&(a=_t(a,e)),a&&n&&a.startsWith("/")&&(a=n.replace(/\/+$/,"")+a),r.options.src=a}return(r.type==="table"||r.printElementType?.type==="table")&&Hg(r,e),(r.type==="flowList"||r.printElementType?.type==="flowList")&&Bg(r,e),r}function Bg(t,e){const n=typeof t.options.formatter=="string"?t.options.formatter:"",r={...t.options,dataSource:t.options.dataSource??xr(n,e)},{list:o,key:i}=ic(r,e),a=c=>i?{...e,...c,[i]:c}:{...e,...c},l=o.map(c=>n?Hn(n)?n:_t(n,a(c)):String(c??""));t.options._flowItems=l,t.options._flowRawFormatter=Hn(n)?n:void 0}function ic(t,e){const n=t.dataSource??t.fields?.[0]?.dataSource??t.fields?.[0]?.field;if(n&&Array.isArray(e[n]))return{list:e[n],key:n};for(const[r,o]of Object.entries(e))if(Array.isArray(o))return{list:o,key:r};return{list:[],key:n}}function Hg(t,e){const n=t.options,r=n.tableRows;if(!Array.isArray(r)||r.length===0)return;const o=n.tableMode??"dynamic",{list:i,key:a}=o==="dynamic"?ic(n,e):{list:[],key:void 0},l=h=>a?{...e,...h,[a]:h}:{...e,...h},c=a?i.map(h=>({...h,[a]:h})):i,s=[],d=[],p=[],u=[];let f=-1;for(const h of r){if(o==="dynamic"&&h.type==="data"){for(const m of i){f<0&&(f=s.length);const b=l(m);s.push(Dr(h,v=>Rr(v,b))),d.push(b)}continue}if(o==="dynamic"&&h.type==="subtotal"){const m=Dr(h,b=>Rr(b,{rows:c,...e}),!0);p.push(m),s.push(m);continue}if(o==="dynamic"&&h.type==="summary"){const m=Dr(h,b=>Rr(b,{rows:c,...e}));u.push(m),s.push(m);continue}s.push(Dr(h,m=>Rr(m,e)))}n._renderRows=s,n._repeatHeaderCount=Ug(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=e}function Rr(t,e){const n=t.formatter;return n?Hn(n)?n:_t(n,e):""}function Dr(t,e,n=!1){return{type:t.type,height:t.height??8,cells:t.cells.map(r=>({content:r.merged?"":e(r),...(n||Hn(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,barQuietZone:r.barQuietZone,barHeight:r.barHeight,barWidth:r.barWidth,barFontSize:r.barFontSize,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,fitScale:r.fitScale,maxWidth:r.maxWidth,maxHeight:r.maxHeight,rowspan:r.rowspan??1,colspan:r.colspan??1,merged:r.merged===!0,align:r.align,valign:r.valign,fontSize:r.fontSize,fontFamily:r.fontFamily,fontWeight:r.fontWeight,color:r.color,backgroundColor:r.backgroundColor,borders:r.borders,padding:r.padding,wordWrap:r.wordWrap,textFit:r.textFit,shrinkMinFontSize:r.shrinkMinFontSize}))}}function Ug(t){const e=qg(t);return e===0||!t.slice(0,e).some(r=>r.repeatOnPage===!0)?0:jg(t,e)}function qg(t){let e=0;for(const n of t){if(n?.type!=="header")break;e++}return e}function Wg(t,e){for(let n=0;n<e;n++)for(const r of t[n]?.cells??[])if(!r?.merged&&n+(r?.rowspan??1)>e)return!1;return!0}function jg(t,e){for(let n=e;n>=1;n--)if(Wg(t,n))return n;return 1}const Bn=t=>String(t).padStart(2,"0");function $r(t=new Date,e={}){return{printDate:`${t.getFullYear()}-${Bn(t.getMonth()+1)}-${Bn(t.getDate())}`,printTime:`${Bn(t.getHours())}:${Bn(t.getMinutes())}:${Bn(t.getSeconds())}`,pageIndex:e.pageIndex??1,totalPages:e.totalPages??1}}function Hn(t){return typeof t=="string"&&/\b(pageIndex|totalPages)\b/.test(t)}function Gi(t,e=new Date){const{printDate:n,printTime:r}=$r(e);return t.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function Un(t){const e=[];for(const n of t??[]){const r=n?.family?.trim();if(!r)continue;const o=`"${r.replace(/"/g,"")}"`;for(const i of n.files??[]){const a=i?.url?.trim();if(!a)continue;const l=Number.isFinite(i.weight)?Number(i.weight):400,c=i.style==="italic"?"italic":"normal";e.push(`@font-face{font-family:${o};src:url("${a}")${Gg(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return e.length?`${e.join("")}
2
- `:""}function Gg(t){const e=t.split(/[?#]/)[0].toLowerCase();return e.endsWith(".woff2")?' format("woff2")':e.endsWith(".woff")?' format("woff")':e.endsWith(".ttf")?' format("truetype")':e.endsWith(".otf")?' format("opentype")':""}const Yi=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function Vi(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Xi(t){const e=t?.trim();return e?[e.includes(",")?e:`"${e.replace(/"/g,"")}"`,...Yi].join(", "):Yi.join(", ")}function Ki(t){return t?Xi(t):"inherit"}function Yg(t){const e=[],n=new Set;for(const r of t??[]){const o=r?.family?.trim();if(!o)continue;const i=o.toLowerCase();if(n.has(i))continue;n.add(i);const a=r?.label?.trim();e.push(a?{family:o,label:a}:{family:o})}return e}function ac(t,e){const n=e?.trim().toLowerCase();if(n)return t.find(r=>r.family.trim().toLowerCase()===n)}function sc(t){return t.label?`${t.label}(${t.family})`:t.family}function qn(t){return t.toLowerCase().replace(/\s+/g,"")}function lc(t,e){if(t===e)return 0;if(t.startsWith(e))return 1;if(t.includes(e))return 2;let n=0;for(const r of t)if(r===e[n]&&n++,n===e.length)return 3;return-1}function Vg(t,e){const n=lc(qn(t.family),e);if(!t.label)return n;const r=lc(qn(t.label),e);return n<0?r:r<0?n:Math.min(n,r)}function Xg(t,e){const n=qn(e.trim());return n?t.map((r,o)=>({font:r,index:o,rank:Vg(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...t]}function U(t){return`${t}mm`}function Zi(t,e){const n=nn(t);return e&&e>0&&tt(t)?{width:n.width,height:e}:n}function cc(t,e){const n=Ze(t);return e&&e>0&&tt(t)?{width:n.width,height:e}:n}function dc(){return`
1
+ (function(vt){typeof define=="function"&&define.amd?define(vt):vt()})((function(){"use strict";function vt(t){return t/2.83464566929}function vr(t){return t*(25.4/96)}function $t(t){return t*(96/25.4)}const zs=6,Nf=1,Lf=["clip","shrink","autoHeight"];function Bs(t){return typeof t=="string"&&Lf.includes(t)?t:void 0}const Ff={text:"clip",longText:"autoHeight",flowList:"clip"};function wr(t,e){return Bs(e?.textFit)??Ff[t]??"clip"}function Hs(t){if(t?.keepLineBreaks===!0&&t.wordWrap!==!1)return"pre-wrap"}function Us(t){return t?.wordWrap===!1?"nowrap":void 0}function ii(t){return Bs(t?.textFit)??(t?.wordWrap===!1?"clip":"autoHeight")}function Cn(t){return typeof t!="number"||!Number.isFinite(t)||t<=0?zs:Math.max(t,Nf)}function ai(t){return Math.round(t*100)/100}function zf(t){return Math.floor(t*100)/100}function Bf(t,e,n,r){return`${t}#${e}#${n}:${r}`}function Hf(t){const e=t.indexOf("#");if(e<0)return;const n=t.lastIndexOf("#"),r=t.slice(e+1,n);if(r!=="b"&&r!=="st"&&r!=="sm")return;const[o,i]=t.slice(n+1).split(":").map(Number);if(!(!Number.isFinite(o)||!Number.isFinite(i)))return{elementId:t.slice(0,e),kind:r,rowIndex:o,colIndex:i}}function qs(t,e){return(t||"contain")==="cover"?e:void 0}function si(t,e,n,r=1){const o=Math.max(n?.colspan??1,1);let i=0;for(let c=0;c<o;c++)i+=t[e+c]??0;if(i<=0)return 0;const a=n?.padding??r,l=(vt(n?.borders?.left?.width??0)+vt(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function An(t,e,n,r=1){const o=Math.max(n?.rowspan??1,1);let i=0;for(let c=0;c<o;c++)i+=t[e+c]?.height??8;const a=n?.padding??r,l=(vt(n?.borders?.top?.width??0)+vt(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const li=1,Ws=12,Uf=3,qf=100,Wf=0,jf=50,js=25.4/72;function Gf(t,e,n,r){return typeof t!="number"||!Number.isFinite(t)?r:Math.min(n,Math.max(e,Math.round(t)))}function ut(t){return Gf(t,li,Ws,4)}function wt(t){return typeof t!="number"||!Number.isFinite(t)?4:Math.min(jf,Math.max(Wf,t))}function On(t){return typeof t!="number"||!Number.isFinite(t)?8:Math.min(qf,Math.max(Uf,t))}function Qt(t,e){const n=ut(e),r=Math.min(2,n);return typeof t!="number"||!Number.isFinite(t)?r:Math.min(n,Math.max(1,Math.round(t)))}function Yf(t,e,n){const r=ut(e),o=wt(n),i=t-o*(r-1);return i<=0?0:i/r}function Vf(t,e,n){const r=Math.max(1,Math.floor(n));return t*r+e*(r-1)}function Gs(t,e){if(!t)return 0;const n=typeof e=="number"&&Number.isFinite(e)&&e>0?e*js:12*js;let r=0;for(const o of t){if(o===" "){r+=.28;continue}const i=o.codePointAt(0)??0;i>=12288&&i<=12351||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=131072?r+=1:/^[0-9A-Z]$/.test(o)?r+=.6:/^[a-z]$/.test(o)?r+=.5:/^[\u0020-\u007f]$/.test(o)?r+=.4:r+=.75}return r*n}function Xf(t,e){if(!e.autoSpan)return 1;const n=Qt(e.maxSpan,e.columns);if(n<=1||e.colUnitMm<=0)return 1;const r=Gs(t,e.fontSizePt);for(let o=1;o<=n;o++)if(r<=Vf(e.colUnitMm,e.gapX,o))return o;return n}function Kf(t,e){const n=ut(e.columns),r=wt(e.gapX),o=Yf(e.width,n,r),i=Qt(e.maxSpan,n),a=[];let l=[],c=0;for(const s of t){const d=String(s??""),p=Xf(d,{...e,columns:n,gapX:r,maxSpan:i,colUnitMm:o});l.length>0&&c+p>n&&(a.push({cells:l}),l=[],c=0),l.push({text:d,span:p}),c+=p}return l.length>0&&a.push({cells:l}),a}function xr(t,e){if(typeof t!="string"||!t.includes("{")||!e)return;const n=new Set;for(const r of t.matchAll(/\{([^{}]*)\}/g))for(const o of(r[1]??"").split(/[^A-Za-z0-9_\u4e00-\u9fa5.]/)){const i=o.split(".")[0];i&&!/^\d/.test(i)&&n.add(i)}for(const r of n)if(Array.isArray(e[r]))return r}function Zf(t,e,n){const r=wt(e),o=Gs("一",n);if(o<=0||t<=0)return li;const i=Math.floor((t+r)/(o+r));return Math.min(Ws,Math.max(li,i))}const Ys=t=>`${Math.round(t*1e3)/1e3}mm`;function Jf(t){const e=ut(t.columns),n=wt(t.gapX),r=On(t.rowHeight);return["display:grid",`grid-template-columns:repeat(${e},minmax(0,1fr))`,`column-gap:${Ys(n)}`,`grid-auto-rows:minmax(${Ys(r)},auto)`].join(";")}const In=25.4,Vs=10;function ci(t){return typeof t=="number"&&Number.isFinite(t)?Math.max(0,Math.floor(t)):Vs}const xt=30,Er=10,di=2,Xs=0,Qf=.25,ui=.254;function eh(t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return null;const e=t/In;for(let n=2;n<=8;n+=.5){const r=Math.max(1,Math.round(Sr(n)*e)),o=r/e;if(o>=ui-1e-9)return{barWidth:n,dotsPerModule:r,moduleWidthMm:o}}return null}function Ks(t,e){const n=eh(t);if(!n)return"";const r=s=>String(Number(s.toFixed(3))),o=`按 ${t}dpi 推荐条宽倍率 ${n.barWidth}(每模块 ${n.dotsPerModule} 个打印点 = ${r(n.moduleWidthMm)}mm,取达到 ${r(ui)}mm 下限的最小档)`,i=Sr(e??2),a=Math.max(1,Math.round(i*t/In)),l=a/(t/In),c=l>=ui-1e-9?`当前倍率 ${e??2} 折算为 ${a} 点 / ${r(l)}mm,已达标`:`当前倍率 ${e??2} 只有 ${a} 点 / ${r(l)}mm,低于下限`;return`${o};${c}。这里只提示,不会替你改值`}function Pn(t){const e=typeof t=="number"&&Number.isFinite(t)?t:2;return Math.max(1,e/2)}function Sr(t){return Pn(t)*Qf}function th(t){const{barHeightMm:e,moduleWidthMm:n,boxHeightMm:r,textModules:o}=t,i=typeof e=="number"&&Number.isFinite(e)&&e>0,a=typeof n=="number"&&Number.isFinite(n)&&n>0;if(!i||!a)return xt;const l=Math.max(1,Math.round(e/n));if(!(typeof r=="number"&&Number.isFinite(r)&&r>0))return l;const s=typeof o=="number"&&Number.isFinite(o)&&o>0?o:0,d=Math.floor((r-s*n)/n);return Math.max(1,Math.min(l,d))}function Zs(t,e,n){const r=Math.max(1,Math.round(t*n)),o=Math.floor(e*n);if(o<1)return null;const i=Math.min(r,o);return{dotsPerModule:i,preferredDots:r,moduleWidthMm:i/n}}function nh(t){const e=Sr(t.barWidth),n=Math.max(1,Math.ceil(t.unitWidth)),r=t.boxWidthMm>0?t.boxWidthMm/n:Number.POSITIVE_INFINITY,o=t.dpi;if(typeof o=="number"&&Number.isFinite(o)&&o>0){const i=Zs(e,r,o/In);if(i)return i.moduleWidthMm}return Math.min(e,r)}function en(t,e){const n=typeof t=="number"&&t>0?t:Number.POSITIVE_INFINITY,r=typeof e=="number"&&e>0?Math.min(n,e):n;return Number.isFinite(r)?r:0}function rh(t){const e=Math.max(1,Math.ceil(t.unitWidth)),n=Math.max(1,Math.ceil(t.unitHeight)),r=Sr(t.barWidth),o=Math.min(t.boxWidthMm>0?t.boxWidthMm/e:Number.POSITIVE_INFINITY,t.boxHeightMm>0?t.boxHeightMm/n:Number.POSITIVE_INFINITY),i=t.dpi;if(typeof i=="number"&&Number.isFinite(i)&&i>0){const l=Zs(r,o,i/In);if(l)return{moduleWidthMm:l.moduleWidthMm,widthMm:e*l.moduleWidthMm,heightMm:n*l.moduleWidthMm,dotsPerModule:l.dotsPerModule,scaledDown:l.dotsPerModule<l.preferredDots}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:e*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}function pi(t){const e=Pn(t.barWidth),n=c=>rh({unitWidth:c.widthUnits/e,unitHeight:c.heightUnits/e,boxWidthMm:t.boxWidthMm,boxHeightMm:t.boxHeightMm,dpi:t.dpi,barWidth:t.barWidth}),r=t.measure(xt);if(!r)return{barHeightModules:xt,size:null};if(!(typeof t.barHeightMm=="number"&&Number.isFinite(t.barHeightMm)&&t.barHeightMm>0))return{barHeightModules:xt,size:n(r)};const i=Math.max(0,r.heightUnits/e-xt),a=th({barHeightMm:t.barHeightMm,moduleWidthMm:nh({unitWidth:r.widthUnits/e,boxWidthMm:t.boxWidthMm,dpi:t.dpi,barWidth:t.barWidth}),boxHeightMm:t.boxHeightMm,textModules:i});if(a===xt)return{barHeightModules:a,size:n(r)};const l=t.measure(a);return l?{barHeightModules:a,size:n(l)}:{barHeightModules:xt,size:null}}const _r=["top","right","bottom","left"],Js=new Set(["rect","oval","hline","vline","table"]);function fi(t){return!!t&&!Js.has(t)}const oh=new Set(["solid","dashed","dotted","double"]);function Qs(t,e,n){return typeof t!="number"||!Number.isFinite(t)||t<=0||e==="none"?null:{borderWidth:`${t}pt`,borderStyle:typeof e=="string"&&oh.has(e)?e:"solid",borderColor:n||"#000"}}function el(t,e){if(!t||Js.has(t))return null;const n=Qs(e?.borderWidth,e?.borderStyle,e?.borderColor),r={},o=e?.borders;if(o)for(const i of _r){const a=o[i];if(!a)continue;const l=Qs(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const ih=/[;"'<>\\(){}\[\]@!#]/,ah=64,Rn=100,tl=400;function sh(t){const e=(t??"").trim();return!e||e.length>ah||ih.test(e)?"":e}function nl(t,e){if((t||"contain")!=="cover"||typeof e!="number"||!Number.isFinite(e))return;const n=Math.round(e);if(!(n<=Rn))return Math.min(n,tl)}function hi(t,e,n){const r=sh(n),o={};r&&(o.objectPosition=r);const i=nl(t,e);return i!==void 0&&(o.transform=`scale(${Number((i/100).toFixed(2))})`,o.transformOrigin=r||"50% 50%"),o}function Dn(t){return typeof t!="number"||!Number.isFinite(t)?0:(t%360+360)%360}function rl(t,e,n){const r=t.width,o=e,i=Dn(n);let a,l;if(i===0||i===180)a=r,l=o;else if(i===90||i===270)a=o,l=r;else{const c=i*Math.PI/180;a=r*Math.abs(Math.cos(c))+o*Math.abs(Math.sin(c)),l=r*Math.abs(Math.sin(c))+o*Math.abs(Math.cos(c))}return{left:t.left-(a-r)/2,top:t.top-(l-o)/2,width:a,height:l}}const ol=385,il=new Set(["table","flowList"]);function lh(t){return il.has(t)}const ch="条码与二维码仅支持 90° 步进;任意角度需 385dpi 以上打印头";function dh(t,e){if(t!=="barcode"&&t!=="qrcode")return!0;const n=e?.printerDpi;return typeof n=="number"&&n>0&&n>=ol}function gi(t,e,n){const r=e?.rotate;if(typeof r!="number"||!Number.isFinite(r))return;const o=Dn(r);if(o!==0&&!il.has(t)){if(t==="barcode"||t==="qrcode"){if(o===90||o===180||o===270)return o;const i=e?.printerDpi;if(typeof i=="number"&&i>0&&i<ol){const a=Dn(Math.round(o/90)*90);return a===0?void 0:a}}return o}}const Nt={A4:{width:210,height:297},A3:{width:297,height:420},A5:{width:148,height:210},Letter:{width:216,height:279},Legal:{width:216,height:356},DOT_FULL:{width:241,height:279.4},DOT_HALF:{width:241,height:139.7},DOT_THIRD:{width:241,height:93.1},LABEL_80X60:{width:80,height:60},LABEL_60X40:{width:60,height:40},LABEL_40X30:{width:40,height:30},THERMAL_57:{width:57,height:297},THERMAL_80:{width:80,height:297},THERMAL_110:{width:110,height:297},CUSTOM:{width:210,height:297},CONTINUOUS:{width:80,height:297}},uh=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function tn(t){return uh.has(t)}function Ze(t){const e=tn(t.paperSize),n=t.paperSize==="CUSTOM"||e?{width:t.customWidth??Nt[t.paperSize].width,height:t.customHeight??Nt[t.paperSize].height}:Nt[t.paperSize];return t.orientation==="landscape"&&!e?{width:n.height,height:n.width}:{...n}}function nn(t){if(tn(t.paperSize))return Ze(t);const n=Ze(t);return t.outputRotation===90||t.outputRotation===270?{width:n.height,height:n.width}:n}function mi(t){return tn(t.paperSize)?0:t.outputRotation??0}function tt(t){return tn(t.paperSize)}function Mr(t){return t.options?.pagination??t.pagination}function ph(t){return t.options?.tablePagination??t.tablePagination}const fh=2;function rn(t){return t.type==="table"||t.printElementType?.type==="table"}function hh(t){return t.type||t.printElementType?.type||"text"}function al(t){return gi(hh(t),t.options)}function $n(t,e){const n=e.get(t.id)?.measuredHeight??t.options?.height??0,r=t.options?.top??0,o=al(t);if(o===void 0)return{height:n,shift:0,top:r,rot:void 0};const i=rl({left:t.options?.left??0,top:r,width:t.options?.width??100},n,o);return{height:i.height,shift:r-i.top,top:i.top,rot:o}}function gh(t,e){const n=t.options?.left??0,r=t.options?.tableColWidths??[],o=rn(t)&&r.length>0?r.reduce((c,s)=>c+s,0):t.options?.width??0,i=al(t);if(i===void 0)return{left:n,width:o};const a=e.get(t.id)?.measuredHeight??t.options?.height??0,l=rl({left:n,top:t.options?.top??0,width:o},a,i);return{left:l.left,width:l.width}}function bi(t){const e=t.options??{},n=e.top??0,o=(e.tableRows??[]).reduce((a,l)=>a+(l.height??0),0),i=Math.max(e.height??0,o);return n+i}function sl(t){return(e,n)=>{const r=e.options?.top??0,o=n.options?.top??0;if(r!==o)return r-o;const i=e.options?.zIndex??0,a=n.options?.zIndex??0;return i!==a?i-a:(t.get(e.id)??0)-(t.get(n.id)??0)}}function ll(t){const e=t.filter(a=>typeof a.id=="string").map(a=>a),n=new Map;e.forEach((a,l)=>n.set(a.id,l));const r=[...e].sort(sl(n)),o=new Set;for(const a of r)rn(a)||a.options?.groupId&&o.add(a.id);const i=new Set;for(const a of cl(r,o).values())for(const l of a)i.add(l);return i}function cl(t,e){const n=new Map;let r=null,o=-1,i=0,a=0;for(const l of t){if(rn(l)){r=l.id,o=bi(l);const p=l.options?.left??0,u=l.options?.tableColWidths??[],f=u.length>0?u.reduce((h,m)=>h+m,0):l.options?.width??0;i=p,a=p+f,n.set(l.id,[]);continue}if(e?.has(l.id)||!r||(l.options?.top??0)<o)continue;const s=l.options?.left??0;s+(l.options?.width??0)<=i||s>=a||n.get(r).push(l.id)}return n}function mh(t,e,n,r){const o=bi(t);let i=o;for(const a of e){const l=n.elements.find(c=>c.id===a);l&&(i=Math.max(i,(l.options?.top??0)+(l.options?.height??0)))}return Math.max(i-o,0)}function bh(t,e){return Math.max(t.options?.height??0,e.get(t.id)?.measuredHeight??0)}function on(t){const e=t.options??{},n=e.left??0;return[n,n+(e.width??100)]}function dl(t,e){return t[0]<e[1]&&e[0]<t[1]}function ul(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function yh(t,e,n){const r=new Map;for(const p of n.values()){if(p.length<2)continue;const u={anchorId:p[0].id,ids:p.map(f=>f.id),forceFirstPage:p.some(f=>Mr(f)?.pageable===!1),band:p.map(on).reduce(ul)};for(const f of p)r.set(f.id,u)}const o=t.filter(p=>!rn(p)&&!p.options?.groupId&&Mr(p)?.pageable!==!1),i=new Map;o.forEach(p=>i.set(p.id,p.id));const a=p=>{let u=p;for(;i.get(u)!==u;)u=i.get(u);let f=p;for(;i.get(f)!==u;){const h=i.get(f);i.set(f,u),f=h}return u},l=(p,u)=>{const f=a(p),h=a(u);f!==h&&i.set(h,f)},c=[];for(const p of o){const u=p.options?.top??0;for(let m=c.length-1;m>=0;m--)c[m].bottom<=u&&c.splice(m,1);const f=u+bh(p,e),h=on(p);for(const m of c)m.bottom>u&&dl(m.x,h)&&l(p.id,m.id);c.push({id:p.id,top:u,bottom:f,x:h})}const s=new Map(o.map(p=>[p.id,p])),d=new Map;for(const p of o){const u=a(p.id),f=d.get(u);f?f.push(p.id):d.set(u,[p.id])}for(const p of d.values()){if(p.length<2)continue;const u={anchorId:p[0],ids:p,forceFirstPage:!1,band:p.map(f=>on(s.get(f))).reduce(ul)};for(const f of p)r.set(f,u)}return r}function yi(t,e){const n=Ze(t),{top:r,bottom:o}=t.margins,i=t.header?.height??0,a=t.footer?.height??0,l=tt(t),c=l?Number.POSITIVE_INFINITY:n.height-r-o-i-a;if(!l&&c<=0)throw new Error(`页面可用高度不足: paper=${n.height}mm, margins=${r+o}mm, header=${i}mm, footer=${a}mm`);const s=new Map;t.elements.forEach((D,L)=>s.set(D.id,L));const d=[...t.elements].sort(sl(s)),p=new Set,u=new Map;for(const D of d){if(rn(D))continue;const L=D.options?.groupId;if(!L)continue;p.add(D.id);const W=u.get(L);W?W.push(D):u.set(L,[D])}const f=cl(d,p),h=new Map;for(const[D,L]of f)for(const W of L)h.set(W,D);const m=new Map;for(const D of d)m.set(D.id,D);const b=yh(d,e,u),v=[];let w=[],_=[],T=!1;function z(){return c-fh}function N(D){let L=0;for(const W of _)dl(D,[W.x0,W.x1])&&(L+=W.height);return Math.max(0,L)}function P(D){return z()-N(D)}function k(D,L){_.push({x0:D[0],x1:D[1],height:L})}function S(D,L=on(D)){return T?C(L):D.options?.top??0}function C(D){return Math.max(0,z()-P(D))}let O=!1,R=[];function I(D,L,W){W<=0||R.push(`元素 ${D.id} 旋转 ${L}° 后顶部超出页首 ${Math.round(W*100)/100}mm,打印将被裁切`)}function x(){v.push(O||R.length>0?{pageIndex:v.length,sections:[...w],...O?{overflow:!0}:{},...R.length>0?{warnings:[...R]}:{}}:{pageIndex:v.length,sections:[...w]})}function j(D){D>c&&(O=!0)}function te(D=!1){if(w.length===0){O=O||D;return}x(),w=[],_=[],T=!0,O=!1,R=[]}let fe=0;for(;fe<d.length;){const D=d[fe];if(h.has(D.id)){fe++;continue}const L=b.get(D.id);if(L&&L.anchorId!==D.id){fe++;continue}if(Mr(D)?.pageable===!1||L?.forceFirstPage){if(L){let W=Number.POSITIVE_INFINITY,V;for(const Y of L.ids){const X=m.get(Y);if(!X)continue;const ne=$n(X,e);W=Math.min(W,ne.top),ne.rot!==void 0&&(V={el:X,rot:ne.rot})}V&&I(V.el,V.rot,-W);for(const Y of L.ids)w.push({elementId:Y,type:"element",renderTop:m.get(Y)?.options?.top??0})}else{const W=$n(D,e);W.rot!==void 0&&I(D,W.rot,-W.top),w.push({elementId:D.id,type:"element",renderTop:S(D)})}fe++;continue}rn(D)?fe=ye(D,e,fe):L?fe=Ke(L,fe):fe=de(D,e,d,fe)}return w.length>0&&x(),v.length===0&&v.push({pageIndex:0,sections:[]}),G(),v;function G(){if(l)return;const D=t.margins.left;for(const L of v){const W=[];for(const V of L.sections){if(V.type==="flow-group")continue;const Y=m.get(V.elementId);if(!Y)continue;const{left:X,width:ne}=gh(Y,e),Q=D+X,se=Q+ne-n.width,he=-Q;se>.01?W.push(`元素 ${Y.id} 超出纸面右侧 ${Math.round(se*100)/100}mm,打印将被裁切`):he>.01&&W.push(`元素 ${Y.id} 超出纸面左侧 ${Math.round(he*100)/100}mm,打印将被裁切`)}W.length>0&&(L.warnings=[...L.warnings??[],...W])}}function de(D,L,W,V){const Y=on(D),X=$n(D,L),ne=X.height,Q=()=>{const se=S(D,Y),he=T?se+X.shift:se,_e=he-(D.options?.top??0);j(X.top+_e+X.height),X.rot!==void 0&&!T&&I(D,X.rot,-X.top),w.push({elementId:D.id,type:"element",renderTop:he}),k(Y,ne)};if(ne<=P(Y)){if(Q(),Mr(D)?.keepWithNext&&V+1<W.length){const se=W[V+1],he=$n(se,L).height;if(ne+he>z())return V+1;he>P(Y)&&(w.pop(),_.pop(),te(),Q())}return V+1}return te(),Q(),V+1}function Ke(D,L){const W=D.ids.map(_e=>m.get(_e)).filter(_e=>!!_e);let V=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,X;for(const _e of W){const K=$n(_e,e);V=Math.min(V,K.top),Y=Math.max(Y,K.top+K.height),K.rot!==void 0&&(X={el:_e,rot:K.rot})}const ne=Math.max(Y-V,0),Q=D.band,se=()=>{const _e=T?C(Q)-V:0;j(V+_e+ne),X&&!T&&I(X.el,X.rot,-V);for(const K of W)w.push({elementId:K.id,type:"element",renderTop:(K.options?.top??0)+_e});k(Q,ne)};return ne<=P(Q)?(se(),L+1):(te((T?0:V)+ne>c),se(),L+1)}function ye(D,L,W){const V=D.options??{},Y=V._renderRows??[],X=L.get(D.id)?.measuredRowHeights??[],ne=(V._subtotalTemplates?.length??0)>0,Q=(V._summaryRows?.length??0)>0,se=ne?pl(Y,X,"subtotal"):0,he=Q?pl(Y,X,"summary"):0,_e=pe=>ne&&pe.type==="subtotal"||Q&&pe.type==="summary",K=Y.filter(pe=>!_e(pe)),yt=X.filter((pe,ve)=>!_e(Y[ve]));V._renderRows=K;const ee=Math.min(K.length,yt.length),lt=V._repeatHeaderCount??0,Me=L.get(D.id)?.repeatHeaderHeight??X.slice(0,lt).reduce((pe,ve)=>pe+ve,0),Ae=z(),Ee=on(D);if(Me>Ae)throw new Error(`表格 ${D.id} 的重复表头高度 (${Me.toFixed(1)}mm) 超过页面可用高度 (${Ae.toFixed(1)}mm),请减少重复表头行`);if(ee===0)return w.push({elementId:D.id,type:"table-slice",startRow:0,endRow:0,summary:he>0,renderTop:S(D,Ee)}),k(Ee,he),Fe(D,L,Ee),W+1;const Ot=yt.slice(0,ee).reduce((pe,ve)=>pe+ve,0)+se+he;if(ph(D)?.enabled===!1)return Ot>P(Ee)&&w.length>0&&te(),w.push({elementId:D.id,type:"table-slice",startRow:0,endRow:ee,subtotal:se>0,summary:he>0,renderTop:S(D,Ee)}),k(Ee,Ot),Fe(D,L,Ee),W+1;const It=vh(K,ee);let M=0,J=!0,ue=S(D,Ee),le=0;const ze=()=>P(Ee)-le,Pt=(pe,ve)=>{w.push({elementId:D.id,type:"table-slice",startRow:M,endRow:pe,subtotal:se>0,...!J&&ve?{repeatHeader:!0}:{},renderTop:ue}),k(Ee,le),le=0};for(const pe of It){const ve=yt.slice(pe.start,pe.end).reduce((mr,Rt)=>mr+Rt,0);if(ve+se<=ze()){le+=ve;continue}pe.start>M&&(Pt(pe.start,lt>0),J=!1,M=pe.start),te(),ue=S(D,Ee),le=0,J||(le+=Me),le+=ve}if(M<ee&&Pt(ee,lt>0),he>0)if(he<=ze()){const pe=w.length-1,ve=w[pe];ve&&ve.type==="table-slice"&&ve.elementId===D.id?(w[pe]={...ve,summary:!0},k(Ee,he)):(te(),w.push({elementId:D.id,type:"table-slice",startRow:ee,endRow:ee,summary:!0,renderTop:0}),k(Ee,he))}else te(),w.push({elementId:D.id,type:"table-slice",startRow:ee,endRow:ee,summary:!0,renderTop:0}),k(Ee,he);return Fe(D,L,Ee),W+1}function Fe(D,L,W){const V=f.get(D.id)??[];if(V.length===0)return;const Y=mh(D,V,t),X=D.options??{};if(Y<=P(W)){const ne=w.length-1,Q=w[ne];if(Q&&Q.type==="table-slice"&&Q.elementId===D.id){w[ne]={...Q,type:"flow-group",followElementIds:V,groupTop:Q.renderTop??X.top??0},k(W,Y);return}}te(),w.push({elementId:D.id,type:"flow-group",startRow:0,endRow:0,followElementIds:V,groupTop:0}),k(W,Y)}}function vh(t,e){const n=[];let r=0,o=1;for(let i=0;i<e;i++){for(const a of t[i]?.cells??[])!a.merged&&(a.rowspan??1)>1&&(o=Math.max(o,i+a.rowspan));i+1>=o&&(n.push({start:r,end:i+1}),r=i+1,o=r+1)}return n}function pl(t,e,n){let r=0;for(let o=0;o<t.length;o++)t[o]?.type===n&&(r+=e[o]??0);return r}const Tr=25,fl=5;function wh(t){return Math.max(Tr,t)}function hl(t,e,n=1.1){const r=e>0?t*n:t/n;return wh(Math.round(r))}function xh(t,e,n,r,o=.9){if(n<=0||r<=0)return 100;const i=Math.min(t/n,e/r)*o,a=Math.round(i*100);return Math.max(fl,a)}const Eh=2;function gl(t){const e=t.gap??Eh,n=[...t.units].sort((i,a)=>i.order-a.order);if(t.available<=0)return{movedIds:[],overflowRemains:!1};if(n.some(i=>i.width<=0))return{movedIds:[],overflowRemains:!1};const r=i=>{const a=n.filter(c=>!i.has(c.id));return t.pinned+a.reduce((c,s)=>c+s.width+e,0)+(i.size>0?t.moreTriggerWidth+e:0)<=t.available};if(r(new Set))return{movedIds:[],overflowRemains:!1};const o=new Set;for(const i of n)if(o.add(i.id),r(o))return{movedIds:[...o],overflowRemains:!1};return{movedIds:[...o],overflowRemains:!0}}function Sh(t){const e=t.gap??4,n=t.boundaryBottom-t.triggerBottom-e,r=t.triggerTop-t.boundaryTop-e;return n>=t.overlayHeight?"down":r>n?"up":"down"}const _h=["left","top","width","height"];function Mh(t){const e={...t.options};for(const n of _h){const r=e[n];typeof r=="number"&&Number.isFinite(r)&&(e[n]=Th(vt(r)))}return{...t,options:e}}function Th(t){return Math.round(t*100)/100}function kh(t){const e={...t};if(delete e.firstPageOverlay,e.unit==="mm")return e;const n=e,r=o=>o?.map(Mh)??[];return{...n,unit:"mm",elements:r(n.elements),header:n.header?{...n.header,elements:r(n.header.elements)}:n.header,footer:n.footer?{...n.footer,elements:r(n.footer.elements)}:n.footer}}const vi="标签纸",nt={A4:{width:210,height:297,label:"A4 210×297mm",group:"常用纸张"},A3:{width:297,height:420,label:"A3 297×420mm",group:"常用纸张"},A5:{width:148,height:210,label:"A5 148×210mm",group:"常用纸张"},Letter:{width:216,height:279,label:"Letter 216×279mm",group:"常用纸张"},Legal:{width:216,height:356,label:"Legal 216×356mm",group:"常用纸张"},DOT_FULL:{width:241,height:279.4,label:"全等分 241×279.4mm",group:"针式打印纸"},DOT_HALF:{width:241,height:139.7,label:"二等分 241×139.7mm",group:"针式打印纸"},DOT_THIRD:{width:241,height:93.1,label:"三等分 241×93.1mm",group:"针式打印纸"},LABEL_80X60:{width:80,height:60,label:"80×60mm",group:vi},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:vi},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:vi},THERMAL_57:{width:57,height:297,continuous:!0,label:"57mm",group:"小票纸"},THERMAL_80:{width:80,height:297,continuous:!0,label:"80mm",group:"小票纸"},THERMAL_110:{width:110,height:297,continuous:!0,label:"110mm",group:"小票纸"},CONTINUOUS:{width:80,height:297,continuous:!0,label:"连续纸(自定义宽度)",group:"连续纸"}};function wi(t){return!!t&&nt[t]?.continuous===!0}function Et(t){const e=wi(t.paperSize);let n;if(t.paperSize==="CUSTOM"||e){const r=nt[t.paperSize];n={width:t.customWidth??r?.width??210,height:t.customHeight??r?.height??297}}else{const r=nt[t.paperSize]||nt.A4;n={width:r.width,height:r.height}}return t.orientation==="landscape"&&!e?{width:n.height,height:n.width}:n}function Ch(){let t=0;return function(){return t+=1,`cell-${Date.now().toString(36)}-${t}`}}function Ah(){let t=0;return function(){return t+=1,`row-${Date.now().toString(36)}-${t}`}}const Oh=Ch(),Ih=Ah(),St={width:.75,style:"solid",color:"#333333"};function xi(t){return JSON.parse(JSON.stringify(t))}function Ei(t){return{id:Oh(),borders:{top:{...St},right:{...St},bottom:{...St},left:{...St}},...t}}function Ph(){const t=[50,50,50],e=(r,o)=>({id:Ih(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:t.map(()=>Ei())}),n=e("header",!0);return n.cells.forEach((r,o)=>{r.formatter=`列${o+1}`,r.align="center",r.fontWeight="bold"}),{rows:[n,e("data"),e("subtotal"),e("summary")],colWidths:t}}function Si(t,e,n){if(!t[e].cells[n].merged)return{r:e,c:n};for(let r=e;r>=0;r--)for(let o=n;o>=0;o--){const i=t[r].cells[o];if(i.merged)continue;const a=i.rowspan??1,l=i.colspan??1;if(r+a-1>=e&&o+l-1>=n)return{r,c:o}}return{r:e,c:n}}function Lt(t,e,n){const r=Si(t,e,n),o=t[r.r].cells[r.c];return{r1:r.r,c1:r.c,r2:r.r+(o.rowspan??1)-1,c2:r.c+(o.colspan??1)-1}}function ml(t,e,n){let r={r1:Math.min(e.r,n.r),c1:Math.min(e.c,n.c),r2:Math.max(e.r,n.r),c2:Math.max(e.c,n.c)};for(;;){let o=!1;for(let i=r.r1;i<=r.r2;i++)for(let a=r.c1;a<=r.c2;a++){const l=Lt(t,i,a),c={r1:Math.min(r.r1,l.r1),c1:Math.min(r.c1,l.c1),r2:Math.max(r.r2,l.r2),c2:Math.max(r.c2,l.c2)};(c.r1!==r.r1||c.c1!==r.c1||c.r2!==r.r2||c.c2!==r.c2)&&(r=c,o=!0)}if(!o)return r}}function bl(t,e){if((e.r2-e.r1+1)*(e.c2-e.c1+1)<2)return"至少选择 2 个单元格";const r=new Set;for(let i=e.r1;i<=e.r2;i++)r.add(t[i].type);if(r.size>1)return"合并区域不能跨越不同类型的行";const o=ml(t,{r:e.r1,c:e.c1},{r:e.r2,c:e.c2});return o.r1!==e.r1||o.c1!==e.c1||o.r2!==e.r2||o.c2!==e.c2?"选区与已有合并区域部分重叠":null}function yl(t,e){const n=t[e.r1].cells[e.c1],r=[];for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const a=t[o].cells[i];a.formatter&&r.push(a.formatter),!(o===e.r1&&i===e.c1)&&(a.merged=!0,a.rowspan=1,a.colspan=1,a.formatter="")}n.rowspan=e.r2-e.r1+1,n.colspan=e.c2-e.c1+1,n.formatter=r.join(" ")}function vl(t,e){for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const o=t[n].cells[r];if(!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1)){const i=Lt(t,n,r),a=o;for(let l=i.r1;l<=i.r2;l++)for(let c=i.c1;c<=i.c2;c++){const s=t[l].cells[c];s.merged=!1,s.rowspan=1,s.colspan=1,Rh(a,s)}o.rowspan=1,o.colspan=1}}}function Rh(t,e){t!==e&&(e.align=t.align,e.valign=t.valign,e.fontSize=t.fontSize,e.fontFamily=t.fontFamily,e.fontWeight=t.fontWeight,e.color=t.color,e.backgroundColor=t.backgroundColor,e.borders=t.borders?xi(t.borders):void 0,e.padding=t.padding,e.wordWrap=t.wordWrap)}function wl(t,e,n){const r=n==="above"?e:e+1,o=t[e],i=o.cells.length,a=o.type==="data"?"header":o.type,l={id:`row-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,type:a,height:o.height,...a==="header"?{repeatOnPage:[t[r-1],t[r]].find(c=>c?.type==="header")?.repeatOnPage===!0}:{},cells:Array.from({length:i},()=>Ei())};for(let c=0;c<i;c++)if(r>0&&r<t.length){const s=Lt(t,r-1,c);if(s.r1<r&&s.r2>=r){const d=t[s.r1].cells[s.c1];d.rowspan=(d.rowspan??1)+1,l.cells[c].merged=!0}}t.splice(r,0,l)}function Dh(t,e){if(t.length<=1)return"不能删除最后一行";const n=t[e],r=n.cells.length;for(let o=0;o<r;o++){const i=n.cells[o];if(!i.merged&&(i.rowspan??1)>1){const a=t[e+1].cells[o];Object.assign(a,xi(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=Lt(t,e,o);if(a.r1<e&&a.c1===o){const l=t[a.r1].cells[a.c1];l.rowspan=(l.rowspan??1)-1}}}return t.splice(e,1),null}function xl(t,e,n,r){const o=r==="left"?n:n+1;e.splice(o,0,e[n]);for(const i of t){const a=Ei();if(o>0&&o<i.cells.length){const l=t.indexOf(i),c=Lt(t,l,o-1);if(c.c1<o&&c.c2>=o){const s=t[c.r1].cells[c.c1];l===c.r1&&(s.colspan=(s.colspan??1)+1),a.merged=!0}}i.cells.splice(o,0,a)}}function $h(t,e,n){if(e.length<=1)return"不能删除最后一列";for(let r=0;r<t.length;r++){const o=t[r].cells[n];if(!o.merged&&(o.colspan??1)>1){const i=t[r].cells[n+1];Object.assign(i,xi(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=Lt(t,r,n);if(i.c1<n&&i.r1===r){const a=t[i.r1].cells[i.c1];a.colspan=(a.colspan??1)-1}}}for(const r of t)r.cells.splice(n,1);return e.splice(n,1),null}function _i(t,e,n){if(n==="data"){const r=t.findIndex((o,i)=>o.type==="data"&&i!==e);if(r>=0)return`数据行已存在(第 ${r+1} 行),全表最多一行`}if(n==="header"){for(let r=0;r<e;r++)if(t[r].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const r=t.findIndex(o=>o.type==="data");if(r<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(e<r)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&t.slice(0,e).some(r=>r.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&t.slice(e+1).some(r=>r.type==="subtotal"))return"汇总行必须位于小计行之后";if(t[e].type==="header"&&n!=="header"){for(let r=e+1;r<t.length;r++)if(t[r].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}if(t[e].type=n,n==="header"){const r=[t[e-1],t[e+1]].find(o=>o?.type==="header");t[e].repeatOnPage=t[e].repeatOnPage!==void 0?t[e].repeatOnPage===!0:r?.repeatOnPage===!0}else delete t[e].repeatOnPage;return null}function Nh(t,e){for(const n of t){if(n.type!=="header")break;n.repeatOnPage=e}}function El(t,e,n,r){for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const a=t[o].cells[i];if(a.merged)continue;if(n==="none"){delete a.borders;continue}const l=Lt(t,o,i),c=l.r1===e.r1,s=l.r2===e.r2,d=l.c1===e.c1,p=l.c2===e.c2,u={...a.borders??{}};n==="all"?(u.top={...r},u.bottom={...r},u.left={...r},u.right={...r}):n==="outer"?(c&&(u.top={...r}),s&&(u.bottom={...r}),d&&(u.left={...r}),p&&(u.right={...r})):n==="inner"&&(c||(u.top={...r}),s||(u.bottom={...r}),d||(u.left={...r}),p||(u.right={...r})),a.borders=u}}const Lh="线型 / 宽度 / 颜色是待应用规格:选中格已有的边框规格一致时会填进这三行;四边不一致的项显示「混合」,一条边都没有时显示「无 / 0」。改完点「全部 / 外侧 / 内部」或勾选上、下、左、右某条边才会写入选中的单元格;「无」是清除边框",Fh="多选时不回显单格边框:线型 / 宽度 / 颜色按当前设置作为批写规格,点「全部 / 外侧 / 内部」或勾选某条边后写入所有选中格;「无」是清除边框",zh="当前单元格四边边框规格不一致:带「混合」的项不谎报,未改项在点「全部 / 外侧 / 内部」或勾选单边时按缺省档(实线 0.75pt)写入,改任一项即按该值批写";function Sl(t,e,n){const r={...t.borders??{}};n?r[e]={...n}:delete r[e],t.borders=r.top||r.right||r.bottom||r.left?r:void 0}function kr(t,e){const n=[];for(let r=e.r1;r<=e.r2;r++)for(let o=e.c1;o<=e.c2;o++){const i=t[r]?.cells[o];i&&!i.merged&&n.push(i)}return n}function Mi(t,e){const n=kr(t,e).length;return{mode:n>1?"multi":"single",count:n}}function Bh(t,e){const n=kr(t,e);if(!n.length)return null;const r=n[0].cellType??"text";return n.every(o=>(o.cellType??"text")===r)?r:null}function _l(t,e){const n=[];for(const o of kr(t,e))for(const i of["top","right","bottom","left"]){const a=o.borders?.[i];a&&n.push(a)}const r=o=>{if(!n.length)return;const i=o(n[0]);return n.every(a=>o(a)===i)?i:"mixed"};return{width:r(o=>o.width),style:r(o=>o.style),color:r(o=>o.color)}}const Hh="1px dashed rgba(0,0,0,0.18)";function Cr(t,e={}){return t&&t.style!=="none"?`${t.width}pt ${t.style} ${t.color}`:e.designMode&&e.showGhostBorder!==!1?Hh:"none"}function Nn(t){const e=(t.tableColWidths??[]).reduce((r,o)=>r+o,0),n=(t.tableRows??[]).reduce((r,o)=>r+o.height,0);t.width=Math.round(e*100)/100,t.height=Math.round(n*100)/100}const Ml=5;function Uh(t,e,n,r){const o=t.reduce((l,c,s)=>s===e?l:l+c,0),i=r===1/0?1/0:Math.max(Ml,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,Ml),i)}const Ti=.75,qh="线型 / 宽度 / 颜色即时生效,这三行显示的就是当前生效规格:已有边框时任改一行都会按新规格铺满四边并清掉单边覆盖;上、下、左、右只给选中的边加框,撤掉一边会把它其余三边落成单边;「无」清除边框,「内部」仅表格单元格可用",Ln=["top","right","bottom","left"];function Tl(t){const e={};for(const n of Ln){const r=t.map(o=>!!o?.[n]);e[n]=r.length>0&&r.every(Boolean)?"on":r.some(Boolean)?"mixed":"off"}return e}const ki=[{value:"none",label:"无"},{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],Wh=new Set(["solid","dashed","dotted","double"]),an="none";function Fn(t,e){const n=t.borders?.[e];if(n&&n.style!==an&&typeof n.width=="number"&&Number.isFinite(n.width)&&n.width>0)return!0;const r=t.borderWidth;return t.borderStyle!==an&&typeof r=="number"&&Number.isFinite(r)&&r>0}function jh(t){const e={};for(const n of Ln)Fn(t,n)&&(e[n]=t.borders?.[n]??{width:t.borderWidth});return e}function Gh(t){const e=t.borderWidth;return{width:typeof e=="number"&&Number.isFinite(e)&&e>0?e:Ti,style:t.borderStyle||"solid",color:t.borderColor||"#333333"}}function kl(t,e,n){if(e!=="inner"){if(t.borders=void 0,e==="none"){t.borderWidth=0;return}t.borderWidth=n.width,t.borderStyle=n.style,t.borderColor=n.color}}function Cl(t){return Ln.some(e=>Fn(t,e))}function Ci(t,e){if(!t.length)return;const n=t[0]?.[e];return t.every(r=>r[e]===n)?n:"mixed"}function Yh(t){if(!t)return;const e=typeof t.style=="string"&&Wh.has(t.style)?t.style:"solid";return{width:t.width,style:t.style===void 0?void 0:e,color:t.color}}function Vh(t){const e=Ln.map(r=>t.borders?.[r]).filter(r=>typeof r?.width=="number"&&Number.isFinite(r.width)&&r.width>0).map(r=>Yh(r));if(!e.length)return;const n=Ci(e,"style");return{width:Ci(e,"width"),style:n===void 0?"solid":n,color:Ci(e,"color")}}function Al(t){const e=t.borderWidth,n=typeof e=="number"&&Number.isFinite(e),r=Vh(t),o=n&&e>0;if(r&&!o)return r;const i=o?t.borderStyle||"solid":an;return n?{width:e,style:i,color:t.borderColor}:{width:void 0,style:i,color:void 0}}function Ol(t){const e=Al(t);return{width:typeof e.width=="number"&&e.width>0?e.width:Ti,style:typeof e.style=="string"&&e.style!==an?e.style:"solid",color:typeof e.color=="string"?e.color:"#333333"}}function Xh(t,e){t.borderWidth=e.width,t.borderStyle=e.style,t.borderColor=e.color,t.borders=void 0}function Kh(t,e,n){if(e==="borderStyle"&&n===an){const r=Cl(t);t.borderStyle=an,r&&(t.borderWidth=0,t.borders=void 0);return}if(!Cl(t)){if(e==="borderStyle"){t.borderStyle=n,t.borderWidth=Ti;return}Object.assign(t,{[e]:n});return}if(e==="borderWidth"&&(typeof n!="number"||!(n>0))){t.borderWidth=typeof n=="number"&&n<0?0:n,t.borders=void 0;return}Xh(t,Gh({...t,[e]:n}))}function Ai(t,e,n,r){if(n!==Fn(t,e)){if(!n){const o=t.borderWidth;if(typeof o!="number"||!(o>0)){Il(t,e,null);return}const i={};for(const a of Ln){if(a===e)continue;const l=t.borders?.[a];i[a]={width:l?.width??o,...l?.style!==void 0?{style:l.style}:t.borderStyle!==void 0?{style:t.borderStyle}:{},...l?.color!==void 0?{color:l.color}:t.borderColor!==void 0?{color:t.borderColor}:{}}}t.borders=i,t.borderWidth=0;return}Il(t,e,r??Ol(t))}}function Il(t,e,n){const r={...t.borders??{}};n?r[e]={width:n.width,style:n.style,color:n.color}:delete r[e],t.borders=r}const Pl=96/25.4,Rl=1,Zh=8,Jh=210;function Oi(t,e){if(!t||typeof t!="object")return;if(Array.isArray(t)){for(const r of t)Oi(r,e);return}const n=t;typeof n.printerDpi=="number"&&n.printerDpi>0&&e.add(n.printerDpi);for(const r of Object.keys(n)){if(r==="printerDpi")continue;const o=n[r];o&&typeof o=="object"&&Oi(o,e)}}function Qh(t){if(!t)return null;const e=new Set;return Oi(t,e),e.size?Math.max(...e):null}function eg(t){const e=t?.pages?.[0]??t;return e?Et(e).width*Pl:Jh*Pl}function tg(t,e){return t<=0||e<=0?Rl:Math.min(Zh,Math.max(Rl,Math.floor(t/e)))}function ng(t,e,n){const r=[];return t&&r.push({key:"dots",value:t/96,label:`点阵 ${t}dpi`,tip:`1 屏幕像素 = 1 个打印点(${t}dpi ÷ 96dpi)。条与间隙按纸面逐点显示,不会在屏幕上糊成一片`}),r.push({key:"fit",value:tg(e,n),label:"适配",tip:"按容器宽放大到放得下整页的最大整数倍"},{key:"100",value:1,label:"100%",tip:"按 CSS 真实尺寸显示(1mm = 3.78 屏幕像素),热敏点距在此档不可分辨"},{key:"200",value:2,label:"200%",tip:"整数倍放大,避免非整数缩放带来的半像素边"},{key:"400",value:4,label:"400%",tip:"整数倍放大,避免非整数缩放带来的半像素边"}),r}function Dl(t){return"100"}function rg(t,e){return!t||e==="dots"?"":`条码看不清?切「点阵 ${t}dpi」档(1 屏幕像素 = 1 打印点)`}const $l="print-preview-zoom-guard";function og(t,e){if(!t?.documentElement)return;let n=t.getElementById($l);n||(n=t.createElement("style"),n.id=$l,(t.head??t.documentElement).appendChild(n)),n.textContent=`html{zoom:${e}}@media print{html{zoom:1 !important}}`}function ig(t,e,n){return t.some(r=>r.key===e)?e:Dl()}function ag(t,e){return t.find(n=>n.key===e)?.value??1}function sn(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ii(t){const e={left:7,top:17.6,width:42.3,height:7.1};switch(t){case"text":return{...e,formatter:"文本",fontSize:12,textAlign:"left",height:5.3};case"image":return{...e,width:28.2,height:28.2,fit:"contain"};case"longText":return{...e,width:141.1,height:28.2,fontSize:12,lineHeight:18};case"table":{const{rows:n,colWidths:r}=Ph(),o=r.reduce((a,l)=>a+l,0),i=n.reduce((a,l)=>a+l.height,0);return{...e,width:o,height:i,tableMode:"dynamic",tableRows:n,tableColWidths:r,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}}case"flowList":return{...e,width:141.1,height:21.2,fontSize:12,formatter:"{name} {spec}",flowColumns:4,flowRowHeight:8,flowGapX:4,flowAutoSpan:!1,flowMaxSpan:2};case"hline":return{...e,width:70.6,height:1.8,borderWidth:.75};case"vline":return{...e,width:1.8,height:35.3,borderWidth:.75};case"rect":return{...e,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"oval":return{...e,width:28.2,height:28.2,borderWidth:1,borderColor:"#333"};case"barcode":return{...e,width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678"};case"qrcode":return{...e,width:28.2,height:28.2,title:"二维码",testData:"qrcode"};case"html":return{...e,width:28.2,height:28.2};default:return e}}function Nl(t,e){const n={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},flowList:{title:"流式列表"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:sn(),options:{...Ii(t),...e},printElementType:{type:t,title:n[t]?.title||t}}}const Ll=["text","image","hline","vline","rect","oval","barcode","qrcode"];function sg(t){return Et(t)}function Pi(t){const e=sg(t),n=t.margins,r=t.header.height,o=t.footer.height,i=e.width-n.left-n.right,a=e.height-n.top-n.bottom-r-o,l=(c,s,d,p)=>({left:c,top:s,width:d,height:p});return{header:l(n.left,n.top,i,r),content:l(n.left,n.top+r,i,a),footer:l(n.left,e.height-n.bottom-o,i,o)}}function Fl(t,e,n){const r=Pi(t);return r.footer.height>0&&n>=r.footer.top?"footer":r.header.height>0&&n<r.header.top+r.header.height?"header":"content"}function Ri(t,e){const n=t.options;n.width=Math.min(n.width,e.width),n.height=Math.min(n.height,e.height),n.left=Math.min(Math.max(0,n.left),e.width-n.width),n.top=Math.min(Math.max(0,n.top),e.height-n.height)}function lg(t,e){const n=Pi(e),r=t.zone||"content",o=n[r],i=o.left+t.options.left+t.options.width/2,a=o.top+t.options.top+t.options.height/2;let l=Fl(e,i,a),c=!1;if(l!=="content"&&!Ll.includes(t.printElementType.type)&&(l="content",c=!0),l!==r){const s=n[l];t.options.left=o.left+t.options.left-s.left,t.options.top=o.top+t.options.top-s.top,t.zone=l}return l!=="content"?Ri(t,n[l]):c&&Ri(t,n.content),{rejected:c}}const Di=22,$i=[1,2,5,10,20,50,100,200,500,1e3];function cg(t,e=64){const n=t*3.7795275590551185;for(const r of $i)if(r*n>=e)return r;return $i[$i.length-1]}function dg(t){const e=Math.floor(Math.log10(t)+1e-9),n=t/10**e;return n===5||n===1&&t>=10?t/5:n===2?t/2:null}function ug(t){return Math.round(t*1e3)/1e3}function pg(t,e,n){if(e<t||n<=0)return[];const o=dg(n)??n,i=Math.ceil(t/o-1e-9)*o,a=Math.floor((e-i)/o+1e-9),l=[];for(let c=0;c<=a;c++){const s=ug(i+c*o);Math.abs(s/n-Math.round(s/n))<1e-6?l.push({mm:s,major:!0,label:String(s)}):l.push({mm:s,major:!1})}return l}const zl=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Ar=[{group:"position-size",groupLabel:"位置与尺寸",items:[{key:"ps-left",keywords:["X","横坐标","left","位置"]},{key:"ps-top",keywords:["Y","纵坐标","top","位置"]},{key:"ps-width",keywords:["W","宽度","width","尺寸"]},{key:"ps-height",keywords:["H","高度","height","尺寸"]}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-family",keywords:["字体","字体名","字体族","fontfamily"]},{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]},{key:"ap-text-fit",keywords:["溢出","溢出显示","截断","自动缩小","自适应行高","textfit","overflow"]},{key:"ap-shrink-min",keywords:["最小字号","缩放下限","shrinkminfontsize"],default:zs,defaultUnit:"pt"},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{key:"ap-keep-line-breaks",keywords:["保留换行符","换行符","手动换行","保留空格","连续空格","行首空格","keeplinebreaks"]},{key:"ap-long-text-indent",keywords:["首行缩进","缩进","indent","longtextindent","两字符","段首"],tip:"长文本每段首行空出的宽度,单位「字符」:填 2 即缩进两个汉字宽(中文排版惯例),按 em 落纸——字号被「自动缩小」压小时缩进同步变窄。仅长文本元素生效,写在普通文本上不生效"},{key:"ap-img-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover","填充","裁剪","剪裁","锚点"],tip:"图片在元素框内的缩放方式:包含=完整显示、可能留白;剪裁=铺满框并按「裁剪锚点」取一块;拉伸=填满框会变形;原始尺寸与缩小不放大。画布与三条出纸链路同一口径(缺省包含)"},{key:"ap-img-object-position",keywords:["裁剪锚点","剪裁锚点","锚点","objectposition","object-position","对齐点","上移","头顶"],tip:"取位(仅「剪裁」档有这一行):剪裁把图等比铺满元素框,多出来的那一条边按这里选的位置取舍。先选位置档(贴边/居中/贴另一头),再按百分比微调,0 贴左/贴顶,100 挪到另一头,水平与垂直各自独立;缺省取正中间(保住证件照头顶就选顶部)。其余缩放模式图比框小或刚好铺满,没有可裁的边,所以不出本行"},{key:"ap-img-fit-scale",keywords:["放大比例","剪裁放大","放大倍数","取景","裁切范围","fitscale","zoom"],default:Rn,defaultUnit:"%",tip:"剪裁放大:等比铺满之后把画面再推大这么多,两轴才真的各多出一条边可裁——图与框同比例时不放大就什么都裁不掉。100=不放大(缺省),上限 400;超出框的部分由元素框裁掉。锚点选中的那一点既是取位的钉住点、也是放大的中心,两者共用同一个值。仅「剪裁」档生效,其余缩放模式不出本行"},{key:"ap-rotate",keywords:["旋转","角度","rotate","angle","顺时针","逆时针","90度","直角"],tip:"元素绕自身中心旋转的角度(度,0~359):出纸时按旋转后外接盒分页与结算,底部放不下自动移页,超出纸面左右缘或顶部会被裁切并给出纸提示。表格、流式列表与表格下方跟随区的元素不支持旋转(这三类不出本行);条码与二维码的任意角度需 385dpi 以上打印头,低分辨率打印机只按 90° 步进出纸"}]},{group:"flow-list",groupLabel:"流式列表",items:[{key:"fl-columns",keywords:["每行列数","列数","栏数","几列","flowcolumns"],tip:"一行排几个单元,必须由你指定——不随内容自动算列数。填的列数乘单元宽放不下元素框时只给提示、不改你的数,出纸按你填的排"},{key:"fl-row-height",keywords:["行高","每行高度","单元高度","flowrowheight"],tip:"每个单元行的最低高度(毫米),与表格行高同一口径:内容比它高时这一行会撑高,不会裁字"},{key:"fl-gap-x",keywords:["单元间距","横向间距","格间距","列间距","flowgapx"],tip:"相邻单元之间的横向留白(毫米);纵向不留缝,行与行的距离由行高承担"},{key:"fl-auto-span",keywords:["自适应","跨列","内容过长","占两列","自动换行","flowsautspan","flowautospan"],tip:"单元内容比一列还宽时,让它占掉两个或更多列位;当前行剩不够放就把整个单元挪到下一行行首(绝不把词切两半)。默认关——开着时出纸栏数由字号与框宽决定"},{key:"fl-max-span",keywords:["最多跨几列","跨列上限","flowmaxspan"],tip:"跨列的列数上限,最大只能等于「每行列数」:把每行列数改小时,这里会被一并顶回去"}]},{group:"code",groupLabel:"条码设置",items:[{key:"cd-type",keywords:["码制","条码类型","条形码类型","barcodetype","code128","ean13","code39","itf14"]},{key:"cd-dpi",keywords:["打印机分辨率","dpi","打印点","点阵对齐","203","300"]},{key:"cd-bar-width",keywords:["条宽","条粗细","barwidth","模块宽"]},{key:"cd-bar-quiet-zone",keywords:["条码静区","条码白边","条形码留白","条码空白边","barquietzone"],default:Vs,defaultUnit:"模块",tip:"条形码左右两端的空白格数(1 格 = 1 条宽):缺省 10,正是一维码码制要求的下限;数值越小白边越窄、同样的框内条越粗(可放大)。填 0 即不留白边,但静区参与「条→空→条」跳变,紧邻文字或表格线时可能扫不出,需实打验证"},{key:"cd-bar-height",keywords:["条高","条码高度","条区高度","条码多高","barheight"],default:xt,defaultUnit:"模块",tip:"黑白条本体的目标高度(mm,不含下方文字):折算粒度就是每模块物理宽,所以只能精确到它的整数倍。条宽优先——可用框高装不下时期望条高让位,绝不把条宽挤窄(热敏出纸清晰度靠条宽)。与「最大高度」分工不同:那条限的是整图(含文字)的上限"},{key:"cd-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"],default:Er,defaultUnit:"模块"},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],default:Xs,defaultUnit:"模块",tip:"二维码四周留出的空白格数:0 即不留白边、码面等比铺满元素框(此时靠框外的白纸充当静区);数值越大白边越宽、码面在框内越小(缺省 0,需 ISO/IEC 18004 推荐静区时填 4)"},{key:"cd-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover"]},{key:"cd-max-width",keywords:["最大宽度","最大宽","maxwidth"]},{key:"cd-max-height",keywords:["最大高度","最大高","maxheight"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-style",keywords:["线型","边框线型","实线","虚线","点线","双线","borderstyle"]},{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function Oe(t){for(const e of Ar){const n=e.items.find(r=>r.key===t);if(n)return n.tip??""}return""}function fg(t,e){const n=t.trim().toLowerCase();return n?e.some(r=>r.toLowerCase().includes(n)):!0}function hg(t){const e=[],n=new Set;for(const r of Ar){const o=r.items.filter(i=>fg(t,[...i.keywords,r.groupLabel]));if(o.length>0){e.push(r.group);for(const i of o)n.add(i.key)}}return{groups:e,itemKeys:n}}function gg(t){for(const e of Ar)for(const n of e.items)if(n.key===t&&n.default!==void 0)return{value:n.default,unit:n.defaultUnit}}const mg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),bg=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function Ni(t){const e=[];let n=0;const r=t.length;for(;n<r;){const o=t[n];if(/\s/.test(o)){n++;continue}if(/[0-9]/.test(o)||o==="."&&n+1<r&&/[0-9]/.test(t[n+1])){let l=n;for(;l<r&&/[0-9.]/.test(t[l]);)l++;e.push({type:"num",value:t.slice(n,l),position:n}),n=l;continue}if(o==="'"||o==='"'){let l=n+1,c="";for(;l<r&&t[l]!==o;)t[l]==="\\"&&l+1<r?(c+=t[l+1],l+=2):(c+=t[l],l++);if(l>=r)throw new Error("字符串未闭合");e.push({type:"str",value:c,position:n}),n=l+1;continue}if(/[A-Za-z_$]/.test(o)){let l=n;for(;l<r&&/[A-Za-z0-9_$]/.test(t[l]);)l++;const c=t.slice(n,l);if(bg.has(c))throw new Error(`不允许使用关键字: ${c}`);if(mg.has(c))throw new Error(`禁止访问: ${c}`);c==="true"||c==="false"?e.push({type:"bool",value:c,position:n}):e.push({type:"ident",value:c,position:n}),n=l;continue}const i=t.slice(n,n+3);if(i==="==="||i==="!=="){e.push({type:"punc",value:i,position:n}),n+=3;continue}const a=t.slice(n,n+2);if(a==="=>")throw new Error("不允许函数定义");if(["==","!=","<=",">=","&&","||"].includes(a)){e.push({type:"punc",value:a,position:n}),n+=2;continue}if(o==="=")throw new Error("不允许赋值");if(o===";")throw new Error("不允许多条语句");if("+-*/%()[]{},:.?!<>".includes(o)){e.push({type:"punc",value:o,position:n}),n++;continue}throw new Error(`非法字符: ${o}`)}return e}function Li(t){return new yg(t).parse()}class yg{constructor(e){this.pos=0,this.tokens=e}parse(){const e=this.parseTernary();if(this.pos<this.tokens.length)throw new Error(`表达式存在多余内容: ${this.tokens[this.pos].value}`);return e}peek(){return this.tokens[this.pos]}next(){const e=this.tokens[this.pos++];if(!e)throw new Error("表达式意外结束");return e}eatPunc(e){const n=this.peek();return n&&n.type==="punc"&&n.value===e?(this.pos++,!0):!1}expectPunc(e){if(!this.eatPunc(e)){const n=this.peek()?.position??0;throw new Error(`位置 ${n}: 期望 "${e}"`)}}parseTernary(){const e=this.parseLogicalOr();if(this.eatPunc("?")){const n=this.parseTernary();this.expectPunc(":");const r=this.parseTernary();return{type:"ternary",cond:e,consequent:n,alternate:r}}return e}parseLogicalOr(){let e=this.parseLogicalAnd();for(;this.eatPunc("||");){const n=this.parseLogicalAnd();e={type:"binary",op:"||",left:e,right:n}}return e}parseLogicalAnd(){let e=this.parseEquality();for(;this.eatPunc("&&");){const n=this.parseEquality();e={type:"binary",op:"&&",left:e,right:n}}return e}parseEquality(){let e=this.parseRelational();for(;;){const n=this.peek();if(n?.type==="punc"&&["==","!=","===","!=="].includes(n.value)){this.pos++;const r=this.parseRelational();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseRelational(){let e=this.parseAdditive();for(;;){const n=this.peek();if(n?.type==="punc"&&["<",">","<=",">="].includes(n.value)){this.pos++;const r=this.parseAdditive();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseAdditive(){let e=this.parseMultiplicative();for(;;){const n=this.peek();if(n?.type==="punc"&&(n.value==="+"||n.value==="-")){this.pos++;const r=this.parseMultiplicative();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseMultiplicative(){let e=this.parseUnary();for(;;){const n=this.peek();if(n?.type==="punc"&&["*","/","%"].includes(n.value)){this.pos++;const r=this.parseUnary();e={type:"binary",op:n.value,left:e,right:r}}else return e}}parseUnary(){const e=this.peek();if(e?.type==="punc"&&["!","-","+"].includes(e.value)){this.pos++;const n=this.parseUnary();return{type:"unary",op:e.value,arg:n,prefix:!0}}return this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.eatPunc(".")){const n=this.next();if(n.type!=="ident")throw new Error(`位置 ${n.position}: 成员访问需要属性名`);e={type:"member",object:e,property:n.value,computed:!1}}else if(this.eatPunc("[")){const n=this.parseTernary();this.expectPunc("]"),n.type==="str"?e={type:"member",object:e,property:n.value,computed:!1}:e={type:"member",object:e,property:n.name??String(n.value),computed:!0}}else if(this.peek()?.type==="punc"&&this.peek()?.value==="("&&(e.type==="ident"||e.type==="member")){this.pos++;const n=this.parseArgs();e={type:"call",callee:e,args:n}}else return e}parseArgs(){const e=[];if(this.eatPunc(")"))return e;for(;;){if(e.push(this.parseTernary()),this.eatPunc(")"))return e;this.expectPunc(",")}}parsePrimary(){const e=this.next();if(e.type==="num"){const n=Number(e.value);if(isNaN(n))throw new Error(`非法数字: ${e.value}`);return{type:"num",value:n}}if(e.type==="str")return{type:"str",value:e.value};if(e.type==="bool")return{type:"bool",value:e.value==="true"};if(e.type==="ident")return{type:"ident",name:e.value};if(e.value==="("){const n=this.parseTernary();return this.expectPunc(")"),n}if(e.value==="["){const n=[];if(!this.eatPunc("]"))for(;n.push(this.parseTernary()),!this.eatPunc("]");)this.expectPunc(",");return{type:"array",elements:n}}if(e.value==="{"){const n=[];if(!this.eatPunc("}"))for(;;){const r=this.next();if(r.type!=="ident"&&r.type!=="str")throw new Error(`位置 ${r.position}: 对象键必须是标识符或字符串`);if(this.expectPunc(":"),n.push({key:r.value,value:this.parseTernary()}),this.eatPunc("}"))break;this.expectPunc(",")}return{type:"object",properties:n}}throw new Error(`位置 ${e.position}: 意外的符号: ${e.value}`)}}const Bl=20,vg=8;function Ue(t,e=0){if(typeof t=="number")return Number.isFinite(t)?t:e;if(typeof t=="string"){const n=t.trim();if(n==="")return e;const r=Number(n);return Number.isFinite(r)?r:e}return t==null?e:typeof t=="boolean"?t?1:0:e}function wg(t){if(typeof t=="number")return Number.isFinite(t);if(typeof t=="string"){const e=t.trim();return e!==""&&Number.isFinite(Number(e))}return!1}function ln(t){return!Number.isFinite(t)||Number.isInteger(t)||Math.abs(t)>=1e15?t:Number(t.toPrecision(12))}function cn(t){if(!Number.isFinite(t)||Number.isInteger(t))return 0;const e=String(t);if(e.includes("e")||e.includes("E"))return 0;const n=e.indexOf(".");return n===-1?0:e.length-n-1}function Fi(t,e){if(!Number.isFinite(t))return 0;const n=Math.min(Math.max(e,0),12);if(n===0)return Math.round(t);const r=10**n,o=t*r;return!Number.isFinite(o)||Math.abs(o)>=1e15?ln(t):Math.round(o)/r}function zi(t,e){const n=Ue(t),r=Ue(e),o=n+r;return Fi(o,Math.max(cn(n),cn(r)))}function Bi(t,e){const n=Ue(t),r=Ue(e),o=n-r;return Fi(o,Math.max(cn(n),cn(r)))}function Hl(t,e){const n=Ue(t),r=Ue(e),o=n*r;return Fi(o,cn(n)+cn(r))}function Ul(t,e){const n=Ue(t),r=Ue(e);return r===0?0:ln(n/r)}function xg(t,e){const n=Ue(t),r=Ue(e);return r===0?0:ln(n%r)}function Eg(t){if(t==null)return 2;const e=Math.trunc(Ue(t,2));return Number.isFinite(e)?Math.min(Math.max(e,-Bl),Bl):2}function Or(t,e,n){const r=Ue(t,0),o=Eg(e);if(r===0)return 0;if(Math.abs(r)>=1e21)return ln(r);const i=Math.max(o,0)+vg,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return ln(r);const l=a.startsWith("-"),c=a.replace("-","").replace(".","");let s=BigInt(c||"0");l&&(s=-s);const d=10n**BigInt(i-o),p=s<0n?-1n:1n,u=s<0n?-s:s;let f=u/d;const h=u%d,m=2n*h;n==="up"?h!==0n&&(f+=1n):n!=="down"&&m>=d&&(m>d||n==="half-up"||f%2n===1n)&&(f+=1n);const b=p*f;return ln(o>=0?Number(b)/10**o:Number(b)*10**-o)}const Hi={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},Sg=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),_g=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function Ie(t,e,n={}){switch(t.type){case"num":return t.value;case"str":return t.value;case"bool":return t.value;case"ident":return Mg(t.name,e);case"binary":return Tg(t,e,n);case"unary":return kg(t,e,n);case"ternary":return Ie(t.cond,e,n)?Ie(t.consequent,e,n):Ie(t.alternate,e,n);case"member":return Og(t,e,n);case"call":return Ig(t,e,n);case"array":return t.elements.map(r=>Ie(r,e,n));case"object":return Object.fromEntries(t.properties.map(r=>[r.key,Ie(r.value,e,n)]))}}function Mg(t,e,n){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(Object.prototype.hasOwnProperty.call(Hi,t))return Hi[t];throw new Error(`未定义的标识符: ${t}`)}function Tg(t,e,n){const r=Ie(t.left,e,n),o=Ie(t.right,e,n);switch(t.op){case"+":return Ag(r,o)?zi(r,o):Cg(r,o);case"-":return Bi(r,o);case"*":return Hl(r,o);case"/":return Ul(r,o);case"%":return xg(r,o);case"<":return r<o;case">":return r>o;case"<=":return r<=o;case">=":return r>=o;case"==":return r==o;case"!=":return r!=o;case"===":return r===o;case"!==":return r!==o;case"&&":return r&&o;case"||":return r||o;default:throw new Error(`未知运算符: ${t.op}`)}}function kg(t,e,n){const r=Ie(t.arg,e,n);switch(t.op){case"-":return Bi(0,r);case"+":return Ue(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${t.op}`)}}function Cg(t,e){return`${t==null?"":String(t)}${e==null?"":String(e)}`}function Ag(t,e){const n=ql(t),r=ql(e);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function ql(t){return t==null||t===""?"neutral":wg(t)?"num":"other"}function Og(t,e,n){const r=Ie(t.object,e,n);if(r==null)throw new Error("无法访问空值的属性");if(Sg.has(t.property))throw new Error(`禁止访问属性: ${t.property}`);return r[t.property]}function Ig(t,e,n){if(t.callee.type==="ident"&&_g.has(t.callee.name)){const o=Hi[t.callee.name],i=t.args.map(a=>Ie(a,e,n));return o(...i)}if(t.callee.type==="member"&&t.callee.object.type==="ident"&&t.callee.object.name==="Math"){const o=Math[t.callee.property];if(typeof o!="function")throw new Error(`Math.${t.callee.property} 不是方法`);const i=t.args.map(a=>Ie(a,e,n));return o(...i)}let r;if(t.callee.type==="ident")r=t.callee.name;else if(t.callee.type==="member")throw new Error("不支持方法调用,请使用顶级函数");if(r&&n[r]){const o=t.args.map(i=>Ie(i,e,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(e,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function Pg(t){const e=[];let n=0;const r=t.length;for(;n<r;){if(t[n]==="{"){let i=1,a=n+1;for(;a<r&&i>0;)t[a]==="{"?i++:t[a]==="}"&&i--,a++;if(i!==0)throw new Error(`位置 ${n}: 花括号未闭合`);const l=t.slice(n+1,a-1);if(l.trim()==="")throw new Error(`位置 ${n}: 空表达式`);const c=Ni(l),s=Li(c);e.push({type:"expr",expression:s}),n=a;continue}let o=n;for(;o<r&&t[o]!=="{";)t[o]==="\\"&&o+1<r&&(t[o+1]==="{"||t[o+1]==="}")?o+=2:o++;e.push({type:"text",value:t.slice(n,o).replace(/\\([{}])/g,"$1")}),n=o}return{type:"template",parts:e}}function Rg(t,e,n={}){let r="";for(const o of t.parts)if(o.type==="text")r+=o.value;else{const i=Ie(o.expression,e,n);r+=String(i??"")}return r}function Wl(t,e={}){const n=Pg(t);return r=>Rg(n,r,e)}function zn(t,e){if(t==null||e==null)return;if(typeof t=="object"&&e in t)return t[e];const n=e.split(".");let r=t;for(const o of n){if(r==null)return;r=r[o]}return r}function jl(t){const e=Number(t);if(isNaN(e))return String(t);const n=e<0?"-":"",r=Math.abs(e),[o,i]=r.toFixed(2).split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n}${a}.${i}`}function Gl(t,e){let n;if(t instanceof Date)n=t;else if(typeof t=="number")n=new Date(t);else if(typeof t=="string")n=new Date(t);else return String(t);if(isNaN(n.getTime()))return String(t);const r=o=>String(o).padStart(2,"0");return e.replace("YYYY",String(n.getFullYear())).replace("MM",r(n.getMonth()+1)).replace("DD",r(n.getDate())).replace("HH",r(n.getHours())).replace("mm",r(n.getMinutes())).replace("ss",r(n.getSeconds()))}const Ui=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],Dg=["","拾","佰","仟"],$g=["","万","亿","万亿","亿亿"];function Ng(t){let e="",n=!1;for(let r=3;r>=0;r--){const o=Math.floor(t/10**r)%10;if(o===0){e&&(n=!0);continue}n&&(e+="零",n=!1),e+=Ui[o]+Dg[r]}return e}function Yl(t){const e=Number(t);if(isNaN(e))return String(t);if(e===0)return"零元整";const n=e<0?"负":"",[r,o]=Math.abs(e).toFixed(2).split("."),i=Math.ceil(r.length/4);let a="",l=!1;for(let d=i-1;d>=0;d--){const p=r.length-d*4,u=parseInt(r.slice(Math.max(0,p-4),p),10);if(u===0){a&&(l=!0);continue}a&&(l||u<1e3)&&(a+="零"),l=!1,a+=Ng(u)+($g[d]??"")}a=`${a||"零"}元`;const c=parseInt(o[0],10),s=parseInt(o[1],10);return c===0&&s===0?a+="整":(c===0?a+="零":a+=Ui[c]+"角",s>0&&(a+=Ui[s]+"分")),n+a}function Vl(t,e,n){return t?e:n}function qi(t,e){return t.reduce((n,r)=>n+(Number(zn(r,e))||0),0)}function Xl(t,e){return t.length===0?0:qi(t,e)/t.length}function Kl(t,e){return t.length}function Zl(t,e){return t.length===0?0:Math.min(...t.map(n=>Number(zn(n,e))||0))}function Jl(t,e){return t.length===0?0:Math.max(...t.map(n=>Number(zn(n,e))||0))}function Ql(...t){return t.reduce((e,n)=>zi(e,n),0)}function ec(...t){return t.length===0?0:t.slice(1).reduce((e,n)=>Bi(e,n),zi(t[0],0))}function tc(...t){return t.length===0?0:t.reduce((e,n)=>Hl(e,n),1)}function nc(t,e){return Ul(t,e)}function rc(t,e){return Or(t,e,"half-up")}function Ir(t,e){return Or(t,e,"up")}function Pr(t,e){return Or(t,e,"down")}function oc(t,e){return Or(t,e,"half-even")}class Lg{constructor(){this.functions={}}registerFunction(e,n){this.functions[e]=n}evaluate(e,n){const r=Ni(e),o=Li(r);return Ie(o,n,this.functions)}render(e,n){return Wl(e,this.functions)(n)}}const Wi=new Lg,Fg={MONEY:jl,DATE:Gl,UPPER:Yl,IF:Vl,CONCAT:(...t)=>t.filter(e=>e!=null).map(String).join(""),IFEMPTY:(t,e)=>t!=null&&t!==""?String(t):e,LEN:t=>String(t).length,ADD:Ql,SUB:ec,MUL:tc,DIV:nc,ROUND:rc,ROUNDUP:Ir,CEIL:Ir,ROUNDDOWN:Pr,FLOOR:Pr,ROUNDBANK:oc};for(const[t,e]of Object.entries(Fg))Wi.registerFunction(t,e);function zg(t,e,n){switch(t.toUpperCase()){case"SUM":return qi(n,e);case"AVG":return Xl(n,e);case"COUNT":return Kl(n);case"MIN":return Zl(n,e);case"MAX":return Jl(n,e);default:return 0}}function Bg(t,e){return Wi.evaluate(t,e)}function _t(t,e){if(!t)return"";if(!t.includes("{"))return t;const n=Array.isArray(e.rows)?e.rows:[],r=t.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(zg(c,d,n))}),`{${a}}`});try{return Wi.render(r,e)}catch{return t}}function ic(t,e,n,r){const o={...$r(),...e??{}},i=JSON.parse(JSON.stringify(t));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>ji(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>ji(l,o,n))),i.elements=i.elements.map(l=>ji(l,o,n));const a=r??n;if(a&&i.fonts?.length){const l=a.replace(/\/+$/,"");i.fonts=i.fonts.map(c=>({...c,files:(c.files??[]).map(s=>({...s,url:s.url?.startsWith("/")&&!s.url.startsWith("//")?l+s.url:s.url}))}))}return i}function ji(t,e,n){const r={...t,options:{...t.options}};if(!(r.type==="flowList"||r.printElementType?.type==="flowList")&&typeof r.options.formatter=="string"){const a=r.options.formatter;Hn(a)?r.options.rawFormatter=a:r.options.formatter=_t(a,e)}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let a=r.options.src;a.includes("{")&&(a=_t(a,e)),a&&n&&a.startsWith("/")&&(a=n.replace(/\/+$/,"")+a),r.options.src=a}return(r.type==="table"||r.printElementType?.type==="table")&&Ug(r,e),(r.type==="flowList"||r.printElementType?.type==="flowList")&&Hg(r,e),r}function Hg(t,e){const n=typeof t.options.formatter=="string"?t.options.formatter:"",r={...t.options,dataSource:t.options.dataSource??xr(n,e)},{list:o,key:i}=ac(r,e),a=c=>i?{...e,...c,[i]:c}:{...e,...c},l=o.map(c=>n?Hn(n)?n:_t(n,a(c)):String(c??""));t.options._flowItems=l,t.options._flowRawFormatter=Hn(n)?n:void 0}function ac(t,e){const n=t.dataSource??t.fields?.[0]?.dataSource??t.fields?.[0]?.field;if(n&&Array.isArray(e[n]))return{list:e[n],key:n};for(const[r,o]of Object.entries(e))if(Array.isArray(o))return{list:o,key:r};return{list:[],key:n}}function Ug(t,e){const n=t.options,r=n.tableRows;if(!Array.isArray(r)||r.length===0)return;const o=n.tableMode??"dynamic",{list:i,key:a}=o==="dynamic"?ac(n,e):{list:[],key:void 0},l=h=>a?{...e,...h,[a]:h}:{...e,...h},c=a?i.map(h=>({...h,[a]:h})):i,s=[],d=[],p=[],u=[];let f=-1;for(const h of r){if(o==="dynamic"&&h.type==="data"){for(const m of i){f<0&&(f=s.length);const b=l(m);s.push(Dr(h,v=>Rr(v,b))),d.push(b)}continue}if(o==="dynamic"&&h.type==="subtotal"){const m=Dr(h,b=>Rr(b,{rows:c,...e}),!0);p.push(m),s.push(m);continue}if(o==="dynamic"&&h.type==="summary"){const m=Dr(h,b=>Rr(b,{rows:c,...e}));u.push(m),s.push(m);continue}s.push(Dr(h,m=>Rr(m,e)))}n._renderRows=s,n._repeatHeaderCount=qg(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=e}function Rr(t,e){const n=t.formatter;return n?Hn(n)?n:_t(n,e):""}function Dr(t,e,n=!1){return{type:t.type,height:t.height??8,cells:t.cells.map(r=>({content:r.merged?"":e(r),...(n||Hn(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,barQuietZone:r.barQuietZone,barHeight:r.barHeight,barWidth:r.barWidth,barFontSize:r.barFontSize,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,fitScale:r.fitScale,maxWidth:r.maxWidth,maxHeight:r.maxHeight,rowspan:r.rowspan??1,colspan:r.colspan??1,merged:r.merged===!0,align:r.align,valign:r.valign,fontSize:r.fontSize,fontFamily:r.fontFamily,fontWeight:r.fontWeight,color:r.color,backgroundColor:r.backgroundColor,borders:r.borders,padding:r.padding,wordWrap:r.wordWrap,textFit:r.textFit,shrinkMinFontSize:r.shrinkMinFontSize}))}}function qg(t){const e=Wg(t);return e===0||!t.slice(0,e).some(r=>r.repeatOnPage===!0)?0:Gg(t,e)}function Wg(t){let e=0;for(const n of t){if(n?.type!=="header")break;e++}return e}function jg(t,e){for(let n=0;n<e;n++)for(const r of t[n]?.cells??[])if(!r?.merged&&n+(r?.rowspan??1)>e)return!1;return!0}function Gg(t,e){for(let n=e;n>=1;n--)if(jg(t,n))return n;return 1}const Bn=t=>String(t).padStart(2,"0");function $r(t=new Date,e={}){return{printDate:`${t.getFullYear()}-${Bn(t.getMonth()+1)}-${Bn(t.getDate())}`,printTime:`${Bn(t.getHours())}:${Bn(t.getMinutes())}:${Bn(t.getSeconds())}`,pageIndex:e.pageIndex??1,totalPages:e.totalPages??1}}function Hn(t){return typeof t=="string"&&/\b(pageIndex|totalPages)\b/.test(t)}function Gi(t,e=new Date){const{printDate:n,printTime:r}=$r(e);return t.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function Un(t){const e=[];for(const n of t??[]){const r=n?.family?.trim();if(!r)continue;const o=`"${r.replace(/"/g,"")}"`;for(const i of n.files??[]){const a=i?.url?.trim();if(!a)continue;const l=Number.isFinite(i.weight)?Number(i.weight):400,c=i.style==="italic"?"italic":"normal";e.push(`@font-face{font-family:${o};src:url("${a}")${Yg(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return e.length?`${e.join("")}
2
+ `:""}function Yg(t){const e=t.split(/[?#]/)[0].toLowerCase();return e.endsWith(".woff2")?' format("woff2")':e.endsWith(".woff")?' format("woff")':e.endsWith(".ttf")?' format("truetype")':e.endsWith(".otf")?' format("opentype")':""}const Yi=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function Vi(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Xi(t){const e=t?.trim();return e?[e.includes(",")?e:`"${e.replace(/"/g,"")}"`,...Yi].join(", "):Yi.join(", ")}function Ki(t){return t?Xi(t):"inherit"}function Vg(t){const e=[],n=new Set;for(const r of t??[]){const o=r?.family?.trim();if(!o)continue;const i=o.toLowerCase();if(n.has(i))continue;n.add(i);const a=r?.label?.trim();e.push(a?{family:o,label:a}:{family:o})}return e}function sc(t,e){const n=e?.trim().toLowerCase();if(n)return t.find(r=>r.family.trim().toLowerCase()===n)}function lc(t){return t.label?`${t.label}(${t.family})`:t.family}function qn(t){return t.toLowerCase().replace(/\s+/g,"")}function cc(t,e){if(t===e)return 0;if(t.startsWith(e))return 1;if(t.includes(e))return 2;let n=0;for(const r of t)if(r===e[n]&&n++,n===e.length)return 3;return-1}function Xg(t,e){const n=cc(qn(t.family),e);if(!t.label)return n;const r=cc(qn(t.label),e);return n<0?r:r<0?n:Math.min(n,r)}function Kg(t,e){const n=qn(e.trim());return n?t.map((r,o)=>({font:r,index:o,rank:Xg(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...t]}function U(t){return`${t}mm`}function Zi(t,e){const n=nn(t);return e&&e>0&&tt(t)?{width:n.width,height:e}:n}function dc(t,e){const n=Ze(t);return e&&e>0&&tt(t)?{width:n.width,height:e}:n}function uc(){return`
3
3
  /* ── 全局重置 ── */
4
4
  * { margin: 0; padding: 0; box-sizing: border-box; }
5
5
 
@@ -17,7 +17,7 @@ body { font-family: ${Yi.join(", ")}; }
17
17
  body { background: #fff; }
18
18
  .print-page { margin: 0; box-shadow: none; }
19
19
  }
20
- `}function uc(){return`
20
+ `}function pc(){return`
21
21
  /* ── 水印层:覆盖整页、位于所有内容之下(显式矢量瓦片,禁止用 CSS 平铺背景:
22
22
  Chromium 会把它编译成 PDF 平铺图案,出纸链路的 RIP 会忽略图案矩阵导致水印放大/错位) ── */
23
23
  .watermark-layer {
@@ -35,7 +35,7 @@ body { font-family: ${Yi.join(", ")}; }
35
35
  position: absolute;
36
36
  pointer-events: none;
37
37
  }
38
- `}function pc(){return`
38
+ `}function fc(){return`
39
39
  /* ── 元素通用定位 ── */
40
40
  .print-element {
41
41
  position: absolute;
@@ -71,10 +71,10 @@ body { font-family: ${Yi.join(", ")}; }
71
71
  height: auto;
72
72
  overflow: visible;
73
73
  }
74
- `}function fc(t){return`
74
+ `}function hc(t){return`
75
75
  /* ── 打印纸张:浏览器原生打印按此尺寸分页(Playwright page.pdf 以显式宽高为准,无副作用) ── */
76
76
  @page { size: ${U(t.width)} ${U(t.height)}; margin: 0; }
77
- `}function hc(t,e,n){const r=`
77
+ `}function gc(t,e,n){const r=`
78
78
  /* ── 出纸转子:设计稿整页旋转 ${n}° 填入出纸纸张 ── */
79
79
  .print-page-rotor {
80
80
  position: absolute;
@@ -88,7 +88,7 @@ body { font-family: ${Yi.join(", ")}; }
88
88
  }`;if(n===0)return r.trim();const i={90:`translate(${U(t.height)}, 0mm) rotate(90deg)`,180:`translate(${U(t.width)}, ${U(t.height)}) rotate(180deg)`,270:`translate(0mm, ${U(t.width)}) rotate(270deg)`}[n];return[r.trim(),`.print-page-rotor-${n} {
89
89
  transform: ${i};
90
90
  }`].join(`
91
- `)}function gc(t,e,n,r){const{top:o,right:i,bottom:a,left:l}=t.margins,c=r?"0":`${U(o)} ${U(i)} ${U(a)} ${U(l)}`;return`
91
+ `)}function mc(t,e,n,r){const{top:o,right:i,bottom:a,left:l}=t.margins,c=r?"0":`${U(o)} ${U(i)} ${U(a)} ${U(l)}`;return`
92
92
  /* ── 纸张页面 ── */
93
93
  ${n} {
94
94
  width: ${U(e.width)};
@@ -102,7 +102,7 @@ ${n} {
102
102
  .print-page:last-child {
103
103
  page-break-after: auto;
104
104
  }
105
- `}function mc(t,e,n){const{right:r,left:o}=t.margins,{bottom:i}=t.margins,a=t.header?.height??0,l=t.footer?.height??0,c=e.width-o-r;return`
105
+ `}function bc(t,e,n){const{right:r,left:o}=t.margins,{bottom:i}=t.margins,a=t.header?.height??0,l=t.footer?.height??0,c=e.width-o-r;return`
106
106
  /* ── 页眉 ── */
107
107
  ${n}.page-header {
108
108
  width: ${U(c)};
@@ -128,12 +128,12 @@ ${n}.content-area {
128
128
  position: relative;
129
129
  overflow: visible;
130
130
  }
131
- `}function Kg(){return[dc(),uc(),pc()].join("").trim()}function Zg(t,e){return fc(Zi(t,e)).trim()}function Jg(t,e,n){const r=mi(t),o=r!==0,i=Zi(t,n),a=cc(t,n),l=e?`${e}.print-page`:".print-page",c=e?`${e} `:"";return[gc(t,i,l,o),mc(t,a,c),...o?[hc(a,t.margins,r)]:[]].join("").trim()}function Wn(t,e){const n=mi(t),r=n!==0,o=Zi(t,e),i=cc(t,e);return[fc(o),dc(),gc(t,o,".print-page",r),uc(),mc(t,i,""),pc(),...r?[hc(i,t.margins,n)]:[]].join("").trim()}const Ji=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function Qg(t,e){if(!tt(t))return`${Wn(t)}
131
+ `}function Zg(){return[uc(),pc(),fc()].join("").trim()}function Jg(t,e){return hc(Zi(t,e)).trim()}function Qg(t,e,n){const r=mi(t),o=r!==0,i=Zi(t,n),a=dc(t,n),l=e?`${e}.print-page`:".print-page",c=e?`${e} `:"";return[mc(t,i,l,o),bc(t,a,c),...o?[gc(a,t.margins,r)]:[]].join("").trim()}function Wn(t,e){const n=mi(t),r=n!==0,o=Zi(t,e),i=dc(t,e);return[hc(o),uc(),mc(t,o,".print-page",r),pc(),bc(t,i,""),fc(),...r?[gc(i,t.margins,n)]:[]].join("").trim()}const Ji=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function em(t,e){if(!tt(t))return`${Wn(t)}
132
132
  ${Ji}`;const{bottom:n}=t.margins,r=t.footer?.height??0,o=Ze(t).width,i=Wn(t,e[0]?.heightMm),a=e.map((l,c)=>{const s=l.heightMm,d=[`@page copy${c} { size: ${U(o)} ${s?U(s):"auto"}; margin: 0; }`,`.print-copy-${c} { page: copy${c}; }`];return s&&(d.push(`.print-copy-${c} .print-page { min-height: ${U(s)}; }`),d.push(`.print-copy-${c} .page-footer { top: ${U(s-n-r)}; }`)),d.join(`
133
133
  `)}).join(`
134
134
  `);return`${i}
135
135
  ${a}
136
- ${Ji}`}function em(t){return`
136
+ ${Ji}`}function tm(t){return`
137
137
  /* ── 拼版纸张:@page 尺寸 = 目标纸。服务端/客户端链路以 paperMm 显式定尺寸、不看这里,
138
138
  但浏览器链路只看 @page,故这条是硬需求 ── */
139
139
  @page { size: ${U(t.sheet.width)} ${U(t.sheet.height)}; margin: 0; }
@@ -166,11 +166,11 @@ ${Ji}`}function em(t){return`
166
166
  否则设计器预览错位 3.17mm、与出纸不一致 */
167
167
  .print-tile > .print-page { margin: 0; box-shadow: none; }
168
168
  }
169
- `}function Qi(t,e,n,r,o){const i=["position:absolute",`left:${U(t)}`,`top:${U(e)}`,`width:${U(n)}`];return r!==void 0&&r>0&&i.push(`height:${U(r)}`),o!==void 0&&i.push(`z-index:${o}`),i.join(";")+";"}const bc=25.4/96,ae={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},tm={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function yc(t,e,n){const r=typeof t=="number"&&Number.isFinite(t)?t:e;return Math.max(n,Math.round(r))}function nm(t){return{width:yc(t?.tileWidth,ae.tileWidth,ae.minTileWidth),height:yc(t?.tileHeight,ae.tileHeight,ae.minTileHeight)}}function rm(t){return t?!t.mode||t.mode==="fixed"?!!t.content&&t.content.trim().length>0:!!t.binding&&t.binding.trim().length>0:!1}function om(t,e,n){if(!t)return"";let r="";if(!t.mode||t.mode==="fixed")r=t.content??"";else if(typeof t.binding=="string"&&t.binding.trim()){const o=t.binding.trim(),i=Array.isArray(e)?e[0]??{}:e??{},a={...$r(),...n,...i};let l;if(o.includes("{"))l=_t(o,a);else{try{l=zg(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=zn(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=t.testData??`[${t.binding}]`}return t.timestamp&&r&&(r=`${r} ${im(t.format)}`),r}function jn(t){return String(t).padStart(2,"0")}function im(t){const e=t&&t.trim()?t:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:jn(n.getMonth()+1),DD:jn(n.getDate()),HH:jn(n.getHours()),mm:jn(n.getMinutes()),ss:jn(n.getSeconds())};return e.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function Nr(t){return Math.round(t*1e4)/1e4}function am(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function vc(t,e,n,r){if(!rm(t))return null;const o=om(t,e,r);if(!o)return null;const i=nm(t),a=Nr(i.width*bc),l=Nr(i.height*bc),c={width:Math.max(0,Number.isFinite(n?.width)?n.width:0),height:Math.max(0,Number.isFinite(n?.height)?n.height:0)},s=Math.max(1,Math.ceil(c.width/a)),d=Math.max(1,Math.ceil(c.height/l)),p=[];for(let u=0;u<d;u++)for(let f=0;f<s;f++)p.push({leftMm:Nr(f*a),topMm:Nr(u*l),widthMm:a,heightMm:l});return{text:o,color:t?.color||ae.color,rotate:t?.rotate??ae.rotate,opacity:t?.opacity??ae.opacity,fontSizePx:ae.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function sm(t,e){const n=t.tileWidthPx,r=t.tileHeightPx,o=n/2,i=r/2;return`<svg class="watermark-tile" style="${`left:${e.leftMm}mm;top:${e.topMm}mm;width:${e.widthMm}mm;height:${e.heightMm}mm`}" viewBox="0 0 ${n} ${r}" xmlns="http://www.w3.org/2000/svg"><text x="${o}" y="${i}" font-size="${t.fontSizePx}" fill="${t.color}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${t.rotate},${o},${i})">${am(t.text)}</text></svg>`}function wc(t,e,n,r){const o=vc(t,e,n,r);if(!o)return"";const i=o.tiles.map(a=>sm(o,a)).join(`
169
+ `}function Qi(t,e,n,r,o){const i=["position:absolute",`left:${U(t)}`,`top:${U(e)}`,`width:${U(n)}`];return r!==void 0&&r>0&&i.push(`height:${U(r)}`),o!==void 0&&i.push(`z-index:${o}`),i.join(";")+";"}const yc=25.4/96,ae={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},nm={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function vc(t,e,n){const r=typeof t=="number"&&Number.isFinite(t)?t:e;return Math.max(n,Math.round(r))}function rm(t){return{width:vc(t?.tileWidth,ae.tileWidth,ae.minTileWidth),height:vc(t?.tileHeight,ae.tileHeight,ae.minTileHeight)}}function om(t){return t?!t.mode||t.mode==="fixed"?!!t.content&&t.content.trim().length>0:!!t.binding&&t.binding.trim().length>0:!1}function im(t,e,n){if(!t)return"";let r="";if(!t.mode||t.mode==="fixed")r=t.content??"";else if(typeof t.binding=="string"&&t.binding.trim()){const o=t.binding.trim(),i=Array.isArray(e)?e[0]??{}:e??{},a={...$r(),...n,...i};let l;if(o.includes("{"))l=_t(o,a);else{try{l=Bg(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=zn(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=t.testData??`[${t.binding}]`}return t.timestamp&&r&&(r=`${r} ${am(t.format)}`),r}function jn(t){return String(t).padStart(2,"0")}function am(t){const e=t&&t.trim()?t:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:jn(n.getMonth()+1),DD:jn(n.getDate()),HH:jn(n.getHours()),mm:jn(n.getMinutes()),ss:jn(n.getSeconds())};return e.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function Nr(t){return Math.round(t*1e4)/1e4}function sm(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wc(t,e,n,r){if(!om(t))return null;const o=im(t,e,r);if(!o)return null;const i=rm(t),a=Nr(i.width*yc),l=Nr(i.height*yc),c={width:Math.max(0,Number.isFinite(n?.width)?n.width:0),height:Math.max(0,Number.isFinite(n?.height)?n.height:0)},s=Math.max(1,Math.ceil(c.width/a)),d=Math.max(1,Math.ceil(c.height/l)),p=[];for(let u=0;u<d;u++)for(let f=0;f<s;f++)p.push({leftMm:Nr(f*a),topMm:Nr(u*l),widthMm:a,heightMm:l});return{text:o,color:t?.color||ae.color,rotate:t?.rotate??ae.rotate,opacity:t?.opacity??ae.opacity,fontSizePx:ae.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function lm(t,e){const n=t.tileWidthPx,r=t.tileHeightPx,o=n/2,i=r/2;return`<svg class="watermark-tile" style="${`left:${e.leftMm}mm;top:${e.topMm}mm;width:${e.widthMm}mm;height:${e.heightMm}mm`}" viewBox="0 0 ${n} ${r}" xmlns="http://www.w3.org/2000/svg"><text x="${o}" y="${i}" font-size="${t.fontSizePx}" fill="${t.color}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${t.rotate},${o},${i})">${sm(t.text)}</text></svg>`}function xc(t,e,n,r){const o=wc(t,e,n,r);if(!o)return"";const i=o.tiles.map(a=>lm(o,a)).join(`
170
170
  `);return`
171
171
  <div class="watermark-layer" style="opacity:${o.opacity}">
172
172
  ${i}
173
- </div>`}function ea(t){return{...t.data??{},pageIndex:t.pageIndex,totalPages:t.totalPages}}function lm(t){return Array.isArray(t)?t[0]??{}:t??{}}function Lr(t,e,n,r){const o=Un(t.fonts)+Wn(t,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:e.length,l={codeRenderer:r?.codeRenderer,pageHeightMm:r?.pageHeightMm};return i?cm(t,o,l,n):dm(t,e,o,a,l,n)}function cm(t,e,n,r){const i=aa(t).width-t.margins.left-t.margins.right,a=t.elements.map(s=>Br(s,!0,void 0,void 0,n)).join(`
173
+ </div>`}function ea(t){return{...t.data??{},pageIndex:t.pageIndex,totalPages:t.totalPages}}function cm(t){return Array.isArray(t)?t[0]??{}:t??{}}function Lr(t,e,n,r){const o=Un(t.fonts)+Wn(t,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:e.length,l={codeRenderer:r?.codeRenderer,pageHeightMm:r?.pageHeightMm};return i?dm(t,o,l,n):um(t,e,o,a,l,n)}function dm(t,e,n,r){const i=aa(t).width-t.margins.left-t.margins.right,a=t.elements.map(s=>Br(s,!0,void 0,void 0,n)).join(`
174
174
  `),l=oa(t.header?.elements??[],i,0,0,n);let c=`<!DOCTYPE html>
175
175
  <html lang="zh-CN">
176
176
  <head>
@@ -179,14 +179,14 @@ ${i}
179
179
  </head>
180
180
  <body class="measure-mode">
181
181
  <section class="print-page" data-measure-page="0">
182
- ${wc(t.watermark,r,aa(t))}
182
+ ${xc(t.watermark,r,aa(t))}
183
183
  <div class="page-header">${l}</div>
184
184
  <div class="content-area" style="height:auto;overflow:visible;">
185
185
  ${a}
186
186
  </div>
187
187
  </section>
188
188
  </body>
189
- </html>`;return c=Gi(c),c}function Fr(t,e,n,r,o){const i=o?.pageOffset??0,a=o?.totalPages??e.length,l=e.map(c=>{const s=c.pageIndex+1+i;return um(t,c,s,a,r,n,o?.pageClass)}).join(`
189
+ </html>`;return c=Gi(c),c}function Fr(t,e,n,r,o){const i=o?.pageOffset??0,a=o?.totalPages??e.length,l=e.map(c=>{const s=c.pageIndex+1+i;return pm(t,c,s,a,r,n,o?.pageClass)}).join(`
190
190
  `);return Gi(l)}function zr(t,e,n){const r=`<!DOCTYPE html>
191
191
  <html lang="zh-CN">
192
192
  <head>
@@ -196,32 +196,32 @@ ${i}
196
196
  <body${n?` class="${n}"`:""}>
197
197
  ${e}
198
198
  </body>
199
- </html>`;return Gi(r)}function dm(t,e,n,r,o,i){const a=Fr(t,e,i??{},o);return zr(n,a,tt(t)?"continuous":void 0)}function um(t,e,n,r,o,i,a){const l=aa(t),c={width:l.width,height:o.pageHeightMm&&o.pageHeightMm>0?o.pageHeightMm:l.height},s=l.width-t.margins.left-t.margins.right,d={pageIndex:n,totalPages:r,data:lm(i)},p=pm(t,d),u={...o,pageVars:d},f=oa(p.header?.elements??[],s,n,r,u),h=oa(p.footer?.elements??[],s,n,r,u);let m=e.sections.map(_=>hm(_,p,u)).join(`
199
+ </html>`;return Gi(r)}function um(t,e,n,r,o,i){const a=Fr(t,e,i??{},o);return zr(n,a,tt(t)?"continuous":void 0)}function pm(t,e,n,r,o,i,a){const l=aa(t),c={width:l.width,height:o.pageHeightMm&&o.pageHeightMm>0?o.pageHeightMm:l.height},s=l.width-t.margins.left-t.margins.right,d={pageIndex:n,totalPages:r,data:cm(i)},p=fm(t,d),u={...o,pageVars:d},f=oa(p.header?.elements??[],s,n,r,u),h=oa(p.footer?.elements??[],s,n,r,u);let m=e.sections.map(_=>gm(_,p,u)).join(`
200
200
  `);m=m.replace(/\{pageIndex\}/g,String(n)),m=m.replace(/\{totalPages\}/g,String(r));const b=`
201
- ${wc(t.watermark,i,c,{pageIndex:n,totalPages:r})}
201
+ ${xc(t.watermark,i,c,{pageIndex:n,totalPages:r})}
202
202
  <div class="page-header">${f}</div>
203
203
  <div class="content-area">
204
204
  ${m}
205
205
  </div>
206
206
  <div class="page-footer">${h}</div>`,v=mi(t),w=v!==0?`<div class="print-page-rotor print-page-rotor-${v}">${b}</div>`:b;return`<section class="print-page${a?` ${a}`:""}" data-page="${n}">
207
207
  ${w}
208
- </section>`}function pm(t,e){if(!fm(t))return t;const n=ea(e),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:_t(a,n)}}},o=i=>i&&{...i,elements:(i.elements??[]).map(r)};return{...t,elements:t.elements.map(r),header:o(t.header),footer:o(t.footer)}}function fm(t){return[t.elements,t.header?.elements,t.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function ta(t,e){const n=t.rawFormatter;return typeof n=="string"&&n!==""&&e?.pageVars?_t(n,ea(e.pageVars)):t.content}function hm(t,e,n){const r=ia(e,t.elementId);return r?t.type==="table-slice"?Em(r,t,n):t.type==="flow-group"?Sm(r,t,e,n):Br(r,!1,void 0,t.renderTop,n):`<!-- element not found: ${t.elementId} -->`}const xc={top:"flex-start",middle:"center",bottom:"flex-end"},gm={left:"flex-start",center:"center",right:"flex-end"};function na(t,e){const n=[],r=t._fitFontSize===void 0?t.fontSize:ai(t._fitFontSize);return r&&n.push(`font-size:${r}pt`),t.fontFamily&&n.push(`font-family:${Vi(Xi(t.fontFamily))}`),t.fontWeight&&n.push(`font-weight:${t.fontWeight}`),t.color&&n.push(`color:${t.color}`),t.backgroundColor&&n.push(`background-color:${t.backgroundColor}`),t.lineHeight?n.push(`line-height:${t.lineHeight}pt`):e&&n.push(`line-height:${e}`),t.letterSpacing&&n.push(`letter-spacing:${t.letterSpacing}pt`),t.verticalAlign&&(t.textAlign==="justify"?n.push(`display:flex;flex-direction:column;justify-content:${xc[t.verticalAlign]??"flex-start"}`):(n.push(`display:flex;align-items:${xc[t.verticalAlign]??"flex-start"}`),n.push(`justify-content:${gm[t.textAlign??"left"]??"flex-start"}`))),t.textAlign&&n.push(`text-align:${t.textAlign}`),t.textAlign==="justify"&&n.push("text-align-last:justify"),n.length?n.join(";")+";":""}function mm(t){return t.longTextIndent?`text-indent:${t.longTextIndent}em;`:""}function Ec(t){const e=Bs(t);return e?`white-space:${e};`:""}function Sc(t,e,n){return Object.entries(hi(t,e,n)).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${Vi(o)};`).join("")}function _c(t,e){const n=Hs(e)?"white-space:nowrap;text-overflow:ellipsis;":"";return t==="autoHeight"?`overflow:visible;${n}`:n}function bm(t,e,n,r){if(t!=="shrink")return"";const o=Cn(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${rt(e)}" data-fit-base="${n}" data-fit-min="${o}"`}function Br(t,e,n,r,o){const i=t.options??{},a=i.left??0,l=r??i.top??0,c=i.width??100,s=i.height??void 0,d=t.type||t.printElementType?.type||"text",p=wr(d,i),f=n??Qi(a,l,c,p==="autoHeight"?void 0:s,i.zIndex),h=Qs(d,i);let m=f;if(h?.all&&(m+=`border:${h.all.borderWidth} ${h.all.borderStyle} ${h.all.borderColor};`),h)for(const w of _r){const _=h.edges[w];_&&(m+=`border-${w}:${_.borderWidth} ${_.borderStyle} ${_.borderColor};`)}if(!e&&n===void 0){const w=gi(d,i);w!==void 0&&(m+=`rotate:${w}deg;`)}const b=e?` data-measure-id="${t.id}"`:"",v=bm(p,t.id,i.fontSize??12,i);switch(d){case"table":return xm(t,e,b,o);case"image":return`<div class="print-element" style="${m}"${b}>
209
- <img src="${rt(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${Sc(i.fit,i.fitScale,i.objectPosition)}" />
208
+ </section>`}function fm(t,e){if(!hm(t))return t;const n=ea(e),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:_t(a,n)}}},o=i=>i&&{...i,elements:(i.elements??[]).map(r)};return{...t,elements:t.elements.map(r),header:o(t.header),footer:o(t.footer)}}function hm(t){return[t.elements,t.header?.elements,t.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function ta(t,e){const n=t.rawFormatter;return typeof n=="string"&&n!==""&&e?.pageVars?_t(n,ea(e.pageVars)):t.content}function gm(t,e,n){const r=ia(e,t.elementId);return r?t.type==="table-slice"?Sm(r,t,n):t.type==="flow-group"?_m(r,t,e,n):Br(r,!1,void 0,t.renderTop,n):`<!-- element not found: ${t.elementId} -->`}const Ec={top:"flex-start",middle:"center",bottom:"flex-end"},mm={left:"flex-start",center:"center",right:"flex-end"};function na(t,e){const n=[],r=t._fitFontSize===void 0?t.fontSize:ai(t._fitFontSize);return r&&n.push(`font-size:${r}pt`),t.fontFamily&&n.push(`font-family:${Vi(Xi(t.fontFamily))}`),t.fontWeight&&n.push(`font-weight:${t.fontWeight}`),t.color&&n.push(`color:${t.color}`),t.backgroundColor&&n.push(`background-color:${t.backgroundColor}`),t.lineHeight?n.push(`line-height:${t.lineHeight}pt`):e&&n.push(`line-height:${e}`),t.letterSpacing&&n.push(`letter-spacing:${t.letterSpacing}pt`),t.verticalAlign&&(t.textAlign==="justify"?n.push(`display:flex;flex-direction:column;justify-content:${Ec[t.verticalAlign]??"flex-start"}`):(n.push(`display:flex;align-items:${Ec[t.verticalAlign]??"flex-start"}`),n.push(`justify-content:${mm[t.textAlign??"left"]??"flex-start"}`))),t.textAlign&&n.push(`text-align:${t.textAlign}`),t.textAlign==="justify"&&n.push("text-align-last:justify"),n.length?n.join(";")+";":""}function bm(t){return t.longTextIndent?`text-indent:${t.longTextIndent}em;`:""}function Sc(t){const e=Hs(t);return e?`white-space:${e};`:""}function _c(t,e,n){return Object.entries(hi(t,e,n)).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${Vi(o)};`).join("")}function Mc(t,e){const n=Us(e)?"white-space:nowrap;text-overflow:ellipsis;":"";return t==="autoHeight"?`overflow:visible;${n}`:n}function ym(t,e,n,r){if(t!=="shrink")return"";const o=Cn(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${rt(e)}" data-fit-base="${n}" data-fit-min="${o}"`}function Br(t,e,n,r,o){const i=t.options??{},a=i.left??0,l=r??i.top??0,c=i.width??100,s=i.height??void 0,d=t.type||t.printElementType?.type||"text",p=wr(d,i),f=n??Qi(a,l,c,p==="autoHeight"?void 0:s,i.zIndex),h=el(d,i);let m=f;if(h?.all&&(m+=`border:${h.all.borderWidth} ${h.all.borderStyle} ${h.all.borderColor};`),h)for(const w of _r){const _=h.edges[w];_&&(m+=`border-${w}:${_.borderWidth} ${_.borderStyle} ${_.borderColor};`)}if(!e&&n===void 0){const w=gi(d,i);w!==void 0&&(m+=`rotate:${w}deg;`)}const b=e?` data-measure-id="${t.id}"`:"",v=ym(p,t.id,i.fontSize??12,i);switch(d){case"table":return Em(t,e,b,o);case"image":return`<div class="print-element" style="${m}"${b}>
209
+ <img src="${rt(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${_c(i.fit,i.fitScale,i.objectPosition)}" />
210
210
  </div>`;case"barcode":case"qrcode":{const w=String(i.formatter??i.testData??"").trim();return`<div class="print-element" style="${m}"${b}>
211
- ${Mc(w,d,i,{fallback:`<span>${rt(w)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
212
- </div>`}case"hline":return`<div class="print-element" style="${m};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${b}></div>`;case"vline":return`<div class="print-element" style="${m};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${b}></div>`;case"rect":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${b}></div>`;case"oval":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${b}></div>`;case"longText":return`<div class="print-element" style="${m}${na(i,"1.5")}${mm(i)}${Ec(i)}${_c(p,i)}"${b}${v}>${rt(i.formatter??i.testData??"")}</div>`;case"flowList":{const w=ut(i.flowColumns),_=wt(i.flowGapX),T=On(i.flowRowHeight),z=Qt(i.flowMaxSpan,w),N=Array.isArray(i._flowItems)?i._flowItems:void 0,P=N&&N.length>0?N:String(i.testData??"").split(/\r?\n/).map(C=>C.trim()).filter(Boolean),k={width:c,columns:w,gapX:_,rowHeight:T,maxSpan:z,fontSizePt:i.fontSize??12,autoSpan:i.flowAutoSpan===!0},S=Xf(P,k).flatMap(C=>C.cells).map(C=>`<div class="print-flow-cell"${C.span>1?` style="grid-column:span ${C.span};"`:""}>${rt(C.text)}</div>`).join(`
213
- `);return`<div class="print-element" style="${m}${na(i)}overflow:hidden;${Zf(k)};"${b}${v}>
211
+ ${Tc(w,d,i,{fallback:`<span>${rt(w)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
212
+ </div>`}case"hline":return`<div class="print-element" style="${m};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${b}></div>`;case"vline":return`<div class="print-element" style="${m};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${b}></div>`;case"rect":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${b}></div>`;case"oval":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${b}></div>`;case"longText":return`<div class="print-element" style="${m}${na(i,"1.5")}${bm(i)}${Sc(i)}${Mc(p,i)}"${b}${v}>${rt(i.formatter??i.testData??"")}</div>`;case"flowList":{const w=ut(i.flowColumns),_=wt(i.flowGapX),T=On(i.flowRowHeight),z=Qt(i.flowMaxSpan,w),N=Array.isArray(i._flowItems)?i._flowItems:void 0,P=N&&N.length>0?N:String(i.testData??"").split(/\r?\n/).map(C=>C.trim()).filter(Boolean),k={width:c,columns:w,gapX:_,rowHeight:T,maxSpan:z,fontSizePt:i.fontSize??12,autoSpan:i.flowAutoSpan===!0},S=Kf(P,k).flatMap(C=>C.cells).map(C=>`<div class="print-flow-cell"${C.span>1?` style="grid-column:span ${C.span};"`:""}>${rt(C.text)}</div>`).join(`
213
+ `);return`<div class="print-element" style="${m}${na(i)}overflow:hidden;${Jf(k)};"${b}${v}>
214
214
  ${S}
215
- </div>`}case"html":return`<div class="print-element" style="${m}"${b}>${i.testData??i.title??""}</div>`;default:return`<div class="print-element" style="${m}${na(i)}${Ec(i)}${_c(p,i)}"${b}${v}>${rt(i.formatter??i.testData??"")}</div>`}}function Mc(t,e,n,r){if(!t||!r.codeRenderer)return r.fallback;const{fallback:o,codeRenderer:i,fit:a,maxWidth:l,maxHeight:c}=r,s=e==="barcode";try{const d=i.render(t,e,{barcodeType:n.barcodeType,qrCodeLevel:n.qrCodeLevel!=null?String(n.qrCodeLevel):void 0,qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0,barQuietZone:typeof n.barQuietZone=="number"?n.barQuietZone:void 0,barHeightMm:typeof n.barHeight=="number"?n.barHeight:void 0,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof(n.barFontSize??n.fontSize)=="number"?n.barFontSize??n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?en(r.targetWidthMm,l):void 0,targetHeightMm:s?en(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return ym(d);const p=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,u=[];u.push("width:100%","height:100%","max-width:100%","max-height:100%","display:block","margin:auto"),u.push(`object-fit:${a||"contain"}`),l&&u.push(`max-width:${l}mm`),c&&u.push(`max-height:${c}mm`);const f=u.join(";");return`<img src="${p}" style="${f}" />`}catch{return o}}function ym(t){return`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${t.replace(/<svg\b/,'<svg style="display:block"')}</div>`}function vm(t,e){const n=[],r=t.fittedFontSize??t.fontSize??e.tableDefaultFontSize,o=t.color??e.tableDefaultColor,i=t.padding??e.tableDefaultPadding??1,a=t.fontFamily??e.tableDefaultFontFamily;r&&n.push(`font-size:${r}pt`),a&&n.push(`font-family:${Vi(Xi(a))}`),t.fontWeight&&n.push(`font-weight:${t.fontWeight}`),o&&n.push(`color:${o}`),t.backgroundColor&&n.push(`background-color:${t.backgroundColor}`),n.push(`text-align:${t.align??"left"}`),t.align==="justify"&&n.push("text-align-last:justify"),n.push(`vertical-align:${t.valign??"middle"}`),n.push(`padding:${i}mm`),n.push(t.wordWrap===!1?"white-space:nowrap;overflow:hidden":"white-space:pre-wrap;word-break:normal;overflow-wrap:break-word");const l=t.borders??{};for(const c of["top","right","bottom","left"]){const s=l[c];n.push(s?`border-${c}:${s.width}pt ${s.style} ${s.color}`:`border-${c}:none`)}return n.join(";")}function Ft(t,e,n,r,o,i,a={elementId:"",kind:"b"},l){const c=[],s=r.tableDefaultPadding??1;for(let d=e;d<n;d++){const p=t[d];if(!p)continue;const u=o?` data-row-index="${d}"`:"",f=p.cells.map((h,m)=>({cell:h,ci:m})).filter(({cell:h})=>!h.merged).map(({cell:h,ci:m})=>{const b=l===void 0?h.rowspan??1:Math.max(1,Math.min(h.rowspan??1,l-d)),v=`${b>1?` rowspan="${b}"`:""}${h.colspan>1?` colspan="${h.colspan}"`:""}`,w=m;let _;if(h.cellType==="barcode"||h.cellType==="qrcode"){const T=ta(h,i);_=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${Mc(T,h.cellType,h,{fallback:rt(T),codeRenderer:i?.codeRenderer,fit:h.fit,maxWidth:h.maxWidth,maxHeight:h.maxHeight,printerDpi:h.printerDpi,targetWidthMm:si(r.tableColWidths??[],m,h,s),targetHeightMm:An(t,d,h,s)})}</div>`}else if(h.cellType==="image"){const T=h.fit||"contain",z=h.maxWidth?`max-width:${h.maxWidth}mm;`:"max-width:100%;",N=h.maxHeight?`max-height:${h.maxHeight}mm;`:"max-height:100%;",P=Us(T,An(t,d,h,s)),k=P===void 0?"height:100%":`height:${P}mm`,S=P===void 0?"":"width:100%;height:100%;";_=`<div style="width:100%;${k};display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${rt(ta(h,i))}" style="${S}object-fit:${T};${Sc(T,h.fitScale,h.objectPosition)}${z}${N}display:block;" /></div>`}else _=wm(t,d,w,h,r,a,s,i);return`<td${v} style="${vm(h,r)}">${_}</td>`}).join("");c.push(`<tr${u} style="height:${p.height}mm;">${f}</tr>`)}return c.join(`
216
- `)}function wm(t,e,n,r,o,i,a,l){const c=ii(r),s=rt(ta(r,l));if(c==="autoHeight")return s;const d=An(t,e,r,a),p=r.wordWrap===!1,u=[`max-height:${d}mm`,"overflow:hidden",...p?["white-space:nowrap","text-overflow:ellipsis"]:[]].join(";"),f=c==="shrink"&&i.elementId?` data-fit="shrink" data-fit-key="${rt(zf(i.elementId,i.kind,e,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${Cn(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function ra(t,e){const r=t.options.tableColWidths??[],o=r.map(a=>`<col style="width:${a}mm;">`).join(""),i=r.reduce((a,l)=>a+l,0);return`<table class="print-table" data-element-id="${t.id}" style="border-collapse:collapse;table-layout:fixed;width:${i}mm;">
215
+ </div>`}case"html":return`<div class="print-element" style="${m}"${b}>${i.testData??i.title??""}</div>`;default:return`<div class="print-element" style="${m}${na(i)}${Sc(i)}${Mc(p,i)}"${b}${v}>${rt(i.formatter??i.testData??"")}</div>`}}function Tc(t,e,n,r){if(!t||!r.codeRenderer)return r.fallback;const{fallback:o,codeRenderer:i,fit:a,maxWidth:l,maxHeight:c}=r,s=e==="barcode";try{const d=i.render(t,e,{barcodeType:n.barcodeType,qrCodeLevel:n.qrCodeLevel!=null?String(n.qrCodeLevel):void 0,qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0,barQuietZone:typeof n.barQuietZone=="number"?n.barQuietZone:void 0,barHeightMm:typeof n.barHeight=="number"?n.barHeight:void 0,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof(n.barFontSize??n.fontSize)=="number"?n.barFontSize??n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?en(r.targetWidthMm,l):void 0,targetHeightMm:s?en(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return vm(d);const p=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(d)}`,u=[];u.push("width:100%","height:100%","max-width:100%","max-height:100%","display:block","margin:auto"),u.push(`object-fit:${a||"contain"}`),l&&u.push(`max-width:${l}mm`),c&&u.push(`max-height:${c}mm`);const f=u.join(";");return`<img src="${p}" style="${f}" />`}catch{return o}}function vm(t){return`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${t.replace(/<svg\b/,'<svg style="display:block"')}</div>`}function wm(t,e){const n=[],r=t.fittedFontSize??t.fontSize??e.tableDefaultFontSize,o=t.color??e.tableDefaultColor,i=t.padding??e.tableDefaultPadding??1,a=t.fontFamily??e.tableDefaultFontFamily;r&&n.push(`font-size:${r}pt`),a&&n.push(`font-family:${Vi(Xi(a))}`),t.fontWeight&&n.push(`font-weight:${t.fontWeight}`),o&&n.push(`color:${o}`),t.backgroundColor&&n.push(`background-color:${t.backgroundColor}`),n.push(`text-align:${t.align??"left"}`),t.align==="justify"&&n.push("text-align-last:justify"),n.push(`vertical-align:${t.valign??"middle"}`),n.push(`padding:${i}mm`),n.push(t.wordWrap===!1?"white-space:nowrap;overflow:hidden":"white-space:pre-wrap;word-break:normal;overflow-wrap:break-word");const l=t.borders??{};for(const c of["top","right","bottom","left"]){const s=l[c];n.push(s?`border-${c}:${s.width}pt ${s.style} ${s.color}`:`border-${c}:none`)}return n.join(";")}function Ft(t,e,n,r,o,i,a={elementId:"",kind:"b"},l){const c=[],s=r.tableDefaultPadding??1;for(let d=e;d<n;d++){const p=t[d];if(!p)continue;const u=o?` data-row-index="${d}"`:"",f=p.cells.map((h,m)=>({cell:h,ci:m})).filter(({cell:h})=>!h.merged).map(({cell:h,ci:m})=>{const b=l===void 0?h.rowspan??1:Math.max(1,Math.min(h.rowspan??1,l-d)),v=`${b>1?` rowspan="${b}"`:""}${h.colspan>1?` colspan="${h.colspan}"`:""}`,w=m;let _;if(h.cellType==="barcode"||h.cellType==="qrcode"){const T=ta(h,i);_=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${Tc(T,h.cellType,h,{fallback:rt(T),codeRenderer:i?.codeRenderer,fit:h.fit,maxWidth:h.maxWidth,maxHeight:h.maxHeight,printerDpi:h.printerDpi,targetWidthMm:si(r.tableColWidths??[],m,h,s),targetHeightMm:An(t,d,h,s)})}</div>`}else if(h.cellType==="image"){const T=h.fit||"contain",z=h.maxWidth?`max-width:${h.maxWidth}mm;`:"max-width:100%;",N=h.maxHeight?`max-height:${h.maxHeight}mm;`:"max-height:100%;",P=qs(T,An(t,d,h,s)),k=P===void 0?"height:100%":`height:${P}mm`,S=P===void 0?"":"width:100%;height:100%;";_=`<div style="width:100%;${k};display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${rt(ta(h,i))}" style="${S}object-fit:${T};${_c(T,h.fitScale,h.objectPosition)}${z}${N}display:block;" /></div>`}else _=xm(t,d,w,h,r,a,s,i);return`<td${v} style="${wm(h,r)}">${_}</td>`}).join("");c.push(`<tr${u} style="height:${p.height}mm;">${f}</tr>`)}return c.join(`
216
+ `)}function xm(t,e,n,r,o,i,a,l){const c=ii(r),s=rt(ta(r,l));if(c==="autoHeight")return s;const d=An(t,e,r,a),p=r.wordWrap===!1,u=[`max-height:${d}mm`,"overflow:hidden",...p?["white-space:nowrap","text-overflow:ellipsis"]:[]].join(";"),f=c==="shrink"&&i.elementId?` data-fit="shrink" data-fit-key="${rt(Bf(i.elementId,i.kind,e,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${Cn(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function ra(t,e){const r=t.options.tableColWidths??[],o=r.map(a=>`<col style="width:${a}mm;">`).join(""),i=r.reduce((a,l)=>a+l,0);return`<table class="print-table" data-element-id="${t.id}" style="border-collapse:collapse;table-layout:fixed;width:${i}mm;">
217
217
  <colgroup>${o}</colgroup>
218
218
  <tbody>${e}</tbody>
219
- </table>`}function xm(t,e,n,r){const o=t.options,i=Qi(o.left??0,o.top??0,o.width??100,void 0,o.zIndex),a=o._renderRows??[],l=Ft(a,0,a.length,o,e,r,{elementId:t.id,kind:"b"});return`<div class="print-element" style="${i};overflow:visible;"${n}>
219
+ </table>`}function Em(t,e,n,r){const o=t.options,i=Qi(o.left??0,o.top??0,o.width??100,void 0,o.zIndex),a=o._renderRows??[],l=Ft(a,0,a.length,o,e,r,{elementId:t.id,kind:"b"});return`<div class="print-element" style="${i};overflow:visible;"${n}>
220
220
  ${ra(t,l)}
221
- </div>`}function Em(t,e,n){const r=t.options,o=Qi(r.left??0,e.renderTop??r.top??0,r.width??100,void 0,r.zIndex),i=r._renderRows??[],a=e.startRow??0,l=e.endRow??i.length,c=r._repeatHeaderCount??0,s=e.repeatHeader&&c>0?Ft(i,0,c,r,!1,n,{elementId:t.id,kind:"b"},c):"",d=Ft(i,a,l,r,!1,n,{elementId:t.id,kind:"b"}),p=e.subtotal?Tc(t,e,r,n):"",u=e.summary?kc(t,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
221
+ </div>`}function Sm(t,e,n){const r=t.options,o=Qi(r.left??0,e.renderTop??r.top??0,r.width??100,void 0,r.zIndex),i=r._renderRows??[],a=e.startRow??0,l=e.endRow??i.length,c=r._repeatHeaderCount??0,s=e.repeatHeader&&c>0?Ft(i,0,c,r,!1,n,{elementId:t.id,kind:"b"},c):"",d=Ft(i,a,l,r,!1,n,{elementId:t.id,kind:"b"}),p=e.subtotal?kc(t,e,r,n):"",u=e.summary?Cc(t,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
222
222
  ${ra(t,`${s}
223
223
  ${d}${p}${u}`)}
224
- </div>`}function Tc(t,e,n,r){const o=n._subtotalTemplates??[];if(o.length===0)return"";const i=n._dataRowCtx??[],a=n._dataStartIdx??0,l=n._mainData??{},c=n._renderRows?.length??0,s=e.startRow??0,d=e.endRow??c,p=Math.max(s,a),u=Math.max(d,p),f=u>a?i.slice(Math.max(p-a,0),u-a):[],h=r?.pageVars?ea(r.pageVars):{},m=o.map(b=>({...b,cells:b.cells.map(v=>v.rawFormatter?{...v,content:_t(v.rawFormatter,{rows:f,...l,...h}),rawFormatter:""}:v)}));return Ft(m,0,m.length,n,!1,r,{elementId:t.id,kind:"st"})}function kc(t,e,n){const r=e._summaryRows??[];return r.length===0?"":Ft(r,0,r.length,e,!1,n,{elementId:t.id,kind:"sm"})}function Sm(t,e,n,r){const o=t.options??{},i=o.left??0,a=o.width??100,l=e.groupTop??o.top??0,c=bi(t),s=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",d=`position:absolute;left:${U(i)};top:${U(l)};width:${U(a)};overflow:visible;${s}`,p=e.startRow??0,u=e.endRow??0;let f="";if(u>p||e.subtotal||e.summary){const w=o._renderRows??[],_=o._repeatHeaderCount??0,T=e.repeatHeader&&_>0?Ft(w,0,_,o,!1,r,{elementId:t.id,kind:"b"},_):"",z=Ft(w,p,u,o,!1,r,{elementId:t.id,kind:"b"}),N=e.subtotal?Tc(t,e,o,r):"",P=e.summary?kc(t,o,r):"";f=`<div class="flow-slice" style="position:relative;width:${U(a)};overflow:visible;">
224
+ </div>`}function kc(t,e,n,r){const o=n._subtotalTemplates??[];if(o.length===0)return"";const i=n._dataRowCtx??[],a=n._dataStartIdx??0,l=n._mainData??{},c=n._renderRows?.length??0,s=e.startRow??0,d=e.endRow??c,p=Math.max(s,a),u=Math.max(d,p),f=u>a?i.slice(Math.max(p-a,0),u-a):[],h=r?.pageVars?ea(r.pageVars):{},m=o.map(b=>({...b,cells:b.cells.map(v=>v.rawFormatter?{...v,content:_t(v.rawFormatter,{rows:f,...l,...h}),rawFormatter:""}:v)}));return Ft(m,0,m.length,n,!1,r,{elementId:t.id,kind:"st"})}function Cc(t,e,n){const r=e._summaryRows??[];return r.length===0?"":Ft(r,0,r.length,e,!1,n,{elementId:t.id,kind:"sm"})}function _m(t,e,n,r){const o=t.options??{},i=o.left??0,a=o.width??100,l=e.groupTop??o.top??0,c=bi(t),s=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",d=`position:absolute;left:${U(i)};top:${U(l)};width:${U(a)};overflow:visible;${s}`,p=e.startRow??0,u=e.endRow??0;let f="";if(u>p||e.subtotal||e.summary){const w=o._renderRows??[],_=o._repeatHeaderCount??0,T=e.repeatHeader&&_>0?Ft(w,0,_,o,!1,r,{elementId:t.id,kind:"b"},_):"",z=Ft(w,p,u,o,!1,r,{elementId:t.id,kind:"b"}),N=e.subtotal?kc(t,e,o,r):"",P=e.summary?Cc(t,o,r):"";f=`<div class="flow-slice" style="position:relative;width:${U(a)};overflow:visible;">
225
225
  ${ra(t,`${T}
226
226
  ${z}${N}${P}`)}
227
227
  </div>`}const h=e.followElementIds??[],m=h.reduce((w,_)=>{const T=ia(n,_);return T?Math.max(w,(T.options?.top??0)+(T.options?.height??0)):w},c),b=h.map(w=>{const _=ia(n,w);if(!_)return"";const T=_.options?.top??0,z=_.options?.left??0,N=_.options?.width??a,P=_.options?.height??0,k=_.options?.zIndex,S=_.type||_.printElementType?.type||"text",C=S==="rect"||S==="oval"||S==="image"||S==="vline",O=["position:absolute",`left:${U(z-i)}`,`top:${U(T-c)}`,`width:${U(N)}`,...C&&P>0?[`height:${U(P)}`]:[],...typeof k=="number"?[`z-index:${k}`]:[],"overflow:visible"].join(";")+";";return Br(_,!1,O,void 0,r)}).join(`
@@ -230,34 +230,34 @@ ${b}
230
230
  </div>`:"";return`<div class="flow-group" style="${d}">
231
231
  ${f}
232
232
  ${v}
233
- </div>`}function oa(t,e,n,r,o){return t.map(i=>{let a=_m(i,o);return n!==void 0&&(a=a.replace(/\{pageIndex\}/g,String(n))),r!==void 0&&(a=a.replace(/\{totalPages\}/g,String(r))),a}).join(`
234
- `)}function _m(t,e){return Br(t,!1,void 0,void 0,e)}function ia(t,e){return t.elements.find(n=>n.id===e)}function aa(t){return Ze(t)}function rt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Mm=25.4;function Tm(t,e){const n=t.margins?.bottom??0,r=t.footer?.height??0,o=Math.max(e,0)+r+n;return Math.max(Mm,Math.round(o*100)/100)}const Cc=3.7795275591;function sa(t){return t/Cc}function Hr(t){return Math.round(t*Cc)}class Gn extends Error{constructor(e,n,r){super(n),this.name="PrintFailure",this.code=e,this.cause=r}}function km(t,e,n){if(t instanceof Gn)return t;const r=t instanceof Error?t.message:String(t);return new Gn(e,`${n}:${r}`,t)}async function Ur(t,e,n,r){let o;try{return await Promise.race([t,new Promise((i,a)=>{o=setTimeout(()=>a(new Gn(n,r)),e)})])}finally{o&&clearTimeout(o)}}function qr(t){return typeof t=="number"&&t>0?t:void 0}function Cm(t){return qr(t.paperHeightMm)??qr(t.override?.height)}function Am(t){const e=qr(t.override?.width)??t.paperMm.width,n=qr(t.override?.height);return t.continuous?n?{paperMm:{width:e,height:n},heightSource:"config"}:{paperMm:{width:e,height:t.paperMm.height},heightSource:"derived"}:{paperMm:{width:e,height:n??t.paperMm.height},heightSource:"config"}}function Ac(t){return{width:Hr(t.width),height:Hr(t.height)}}function Oc(t,e){const n=new Map(e.elements.map(o=>[o.id,o])),r=new Map;for(const o of t){const a=n.get(o.id)?.options?._repeatHeaderCount??0,l=o.rowHeightsPx?.map(sa);r.set(o.id,{id:o.id,measuredHeight:sa(o.heightPx),measuredRowHeights:l,repeatHeaderHeight:l&&l.length>0&&a>0?l.slice(0,a).reduce((c,s)=>c+s,0):0})}return r}const Om={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function Ic(t,e){if(!e||e.length===0)return;const n=new Map,r=o=>{for(const i of o??[])n.set(i.id,i)};r(t.elements),r(t.header?.elements),r(t.footer?.elements);for(const o of e){const i=Bf(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=ai(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[Om[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=ai(o.fontSizePt))}}function Pc(t,e,n={}){return JSON.stringify([t,e,n.barcodeType??null,n.qrCodeLevel??null,n.showText??null,n.barWidth??null,n.fontSize??null,n.qrQuietZone??null,n.barQuietZone??null,n.barHeightMm??null])}function Im(t){return{render(e,n,r){const o=t.get(Pc(e,n,r));if(!o)throw new Error(`码值未渲染:${e}`);return o}}}function Pm(t){const e=new Map;return{renderer:{render(n,r,o={}){const i=Pc(n,r,o),a=t?.get(i);if(a)return a;throw e.set(i,{key:i,value:n,cellType:r,opts:o}),new Error("collect")}},takeSpecs(){const n=[...e.values()];return e.clear(),n}}}function Rm(...t){const e=new Map;for(const n of t)for(const[r,o]of n)e.set(r,o);return e}const Dm={waitReady:"window",readMeasurements:"document",readContentBottom:"document",renderCodes:"none",applyTextFit:"document"},$m=3e4,Nm=5e3;function Lm(t,e){return{async withSession(n,r){const o=await t.createDriver(),i=Date.now()+(n.timeoutMs??$m),a=n.readinessMs??Nm,l=()=>Math.max(1,i-Date.now()),c=(f,h,m)=>km(f,h,m);let s=!1;const d=async()=>{if(!s){if(o.requiresExecutor===!1){s=!0;return}throw new Gn("INTERNAL","缺少 core DOM 执行器产物")}},p=async(f,h)=>{await o.open(h),await o.setContent(f),s=!1,await d(),await o.evaluate("waitReady",[a])},u={async renderCodes(f){if(f.length===0)return new Map;const h=l();return Ur((async()=>{try{await d();const m=await o.evaluate("renderCodes",[f]);return new Map(Object.entries(m))}catch(m){throw c(m,"INTERNAL","码值渲染失败")}})(),h,"RENDER_TIMEOUT",`码值渲染超过 ${h}ms`)},async measure(f,h){const m=l();return Ur((async()=>{try{await p(f,h);const b=await o.evaluate("applyTextFit")??[];return{measurements:await o.evaluate("readMeasurements"),fits:b}}catch(b){throw c(b,"MEASURE_FAILED","测量失败")}})(),m,"RENDER_TIMEOUT",`测量超过 ${m}ms`)},async probeContentBottom(f,h){const m=l();return Ur((async()=>{try{return await p(f,h),await o.evaluate("readContentBottom")}catch(b){throw c(b,"MEASURE_FAILED","连续纸探针失败")}})(),m,"RENDER_TIMEOUT",`连续纸探针超过 ${m}ms`)},async toPdf(f,h,m){if(!o.pdf)throw new Gn("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const b=l();return Ur((async()=>{try{return await p(f,m),await o.pdf(f,h)}catch(v){throw c(v,"PDF_FAILED","PDF 生成失败")}})(),b,"RENDER_TIMEOUT",`PDF 生成超过 ${b}ms`)}};try{return await r(u)}finally{try{await o.close()}catch{}}}}}const Rc=500;function Fm(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Dc(t){if(t===void 0)return{mode:"single",data:{}};if(!Array.isArray(t))return{mode:"single",data:t};if(t.length===0)throw new Error("批量打印数据必须是非空对象数组");if(t.length>Rc)throw new Error(`批量打印最多支持 ${Rc} 份,当前 ${t.length} 份`);for(let e=0;e<t.length;e++)if(!Fm(t[e]))throw new Error(`批量打印数据第 ${e+1} 项必须是对象`);return{mode:"batch",dataList:t}}function zm(t){const e=t[0].bound,n=tt(e),r=t.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=Fr(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
233
+ </div>`}function oa(t,e,n,r,o){return t.map(i=>{let a=Mm(i,o);return n!==void 0&&(a=a.replace(/\{pageIndex\}/g,String(n))),r!==void 0&&(a=a.replace(/\{totalPages\}/g,String(r))),a}).join(`
234
+ `)}function Mm(t,e){return Br(t,!1,void 0,void 0,e)}function ia(t,e){return t.elements.find(n=>n.id===e)}function aa(t){return Ze(t)}function rt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Tm=25.4;function km(t,e){const n=t.margins?.bottom??0,r=t.footer?.height??0,o=Math.max(e,0)+r+n;return Math.max(Tm,Math.round(o*100)/100)}const Ac=3.7795275591;function sa(t){return t/Ac}function Hr(t){return Math.round(t*Ac)}class Gn extends Error{constructor(e,n,r){super(n),this.name="PrintFailure",this.code=e,this.cause=r}}function Cm(t,e,n){if(t instanceof Gn)return t;const r=t instanceof Error?t.message:String(t);return new Gn(e,`${n}:${r}`,t)}async function Ur(t,e,n,r){let o;try{return await Promise.race([t,new Promise((i,a)=>{o=setTimeout(()=>a(new Gn(n,r)),e)})])}finally{o&&clearTimeout(o)}}function qr(t){return typeof t=="number"&&t>0?t:void 0}function Am(t){return qr(t.paperHeightMm)??qr(t.override?.height)}function Om(t){const e=qr(t.override?.width)??t.paperMm.width,n=qr(t.override?.height);return t.continuous?n?{paperMm:{width:e,height:n},heightSource:"config"}:{paperMm:{width:e,height:t.paperMm.height},heightSource:"derived"}:{paperMm:{width:e,height:n??t.paperMm.height},heightSource:"config"}}function Oc(t){return{width:Hr(t.width),height:Hr(t.height)}}function Ic(t,e){const n=new Map(e.elements.map(o=>[o.id,o])),r=new Map;for(const o of t){const a=n.get(o.id)?.options?._repeatHeaderCount??0,l=o.rowHeightsPx?.map(sa);r.set(o.id,{id:o.id,measuredHeight:sa(o.heightPx),measuredRowHeights:l,repeatHeaderHeight:l&&l.length>0&&a>0?l.slice(0,a).reduce((c,s)=>c+s,0):0})}return r}const Im={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function Pc(t,e){if(!e||e.length===0)return;const n=new Map,r=o=>{for(const i of o??[])n.set(i.id,i)};r(t.elements),r(t.header?.elements),r(t.footer?.elements);for(const o of e){const i=Hf(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=ai(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[Im[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=ai(o.fontSizePt))}}function Rc(t,e,n={}){return JSON.stringify([t,e,n.barcodeType??null,n.qrCodeLevel??null,n.showText??null,n.barWidth??null,n.fontSize??null,n.qrQuietZone??null,n.barQuietZone??null,n.barHeightMm??null])}function Pm(t){return{render(e,n,r){const o=t.get(Rc(e,n,r));if(!o)throw new Error(`码值未渲染:${e}`);return o}}}function Rm(t){const e=new Map;return{renderer:{render(n,r,o={}){const i=Rc(n,r,o),a=t?.get(i);if(a)return a;throw e.set(i,{key:i,value:n,cellType:r,opts:o}),new Error("collect")}},takeSpecs(){const n=[...e.values()];return e.clear(),n}}}function Dm(...t){const e=new Map;for(const n of t)for(const[r,o]of n)e.set(r,o);return e}const $m={waitReady:"window",readMeasurements:"document",readContentBottom:"document",renderCodes:"none",applyTextFit:"document"},Nm=3e4,Lm=5e3;function Fm(t,e){return{async withSession(n,r){const o=await t.createDriver(),i=Date.now()+(n.timeoutMs??Nm),a=n.readinessMs??Lm,l=()=>Math.max(1,i-Date.now()),c=(f,h,m)=>Cm(f,h,m);let s=!1;const d=async()=>{if(!s){if(o.requiresExecutor===!1){s=!0;return}throw new Gn("INTERNAL","缺少 core DOM 执行器产物")}},p=async(f,h)=>{await o.open(h),await o.setContent(f),s=!1,await d(),await o.evaluate("waitReady",[a])},u={async renderCodes(f){if(f.length===0)return new Map;const h=l();return Ur((async()=>{try{await d();const m=await o.evaluate("renderCodes",[f]);return new Map(Object.entries(m))}catch(m){throw c(m,"INTERNAL","码值渲染失败")}})(),h,"RENDER_TIMEOUT",`码值渲染超过 ${h}ms`)},async measure(f,h){const m=l();return Ur((async()=>{try{await p(f,h);const b=await o.evaluate("applyTextFit")??[];return{measurements:await o.evaluate("readMeasurements"),fits:b}}catch(b){throw c(b,"MEASURE_FAILED","测量失败")}})(),m,"RENDER_TIMEOUT",`测量超过 ${m}ms`)},async probeContentBottom(f,h){const m=l();return Ur((async()=>{try{return await p(f,h),await o.evaluate("readContentBottom")}catch(b){throw c(b,"MEASURE_FAILED","连续纸探针失败")}})(),m,"RENDER_TIMEOUT",`连续纸探针超过 ${m}ms`)},async toPdf(f,h,m){if(!o.pdf)throw new Gn("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const b=l();return Ur((async()=>{try{return await p(f,m),await o.pdf(f,h)}catch(v){throw c(v,"PDF_FAILED","PDF 生成失败")}})(),b,"RENDER_TIMEOUT",`PDF 生成超过 ${b}ms`)}};try{return await r(u)}finally{try{await o.close()}catch{}}}}}const Dc=500;function zm(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function $c(t){if(t===void 0)return{mode:"single",data:{}};if(!Array.isArray(t))return{mode:"single",data:t};if(t.length===0)throw new Error("批量打印数据必须是非空对象数组");if(t.length>Dc)throw new Error(`批量打印最多支持 ${Dc} 份,当前 ${t.length} 份`);for(let e=0;e<t.length;e++)if(!zm(t[e]))throw new Error(`批量打印数据第 ${e+1} 项必须是对象`);return{mode:"batch",dataList:t}}function Bm(t){const e=t[0].bound,n=tt(e),r=t.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=Fr(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
235
235
  ${s}
236
236
  </section>`}).join(`
237
- `),o=n?Qg(e,t.map(a=>({heightMm:a.derivedHeightMm}))):`${Wn(e)}
238
- .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=Un(e.fonts)+o;return{html:zr(i,r,n?"continuous":void 0),pageCount:t.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:t.map(a=>a.paperMm)}}const ot={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class Bm extends Error{constructor(e,n){super(n),this.name="TilingError",this.code=e}}function zt(t){return Math.round(t*10)/10}function $c(t,e){const n=t.outputRotation;return n===90||n===270?`(内容旋转 ${n}°,每格 ${e.width}×${e.height}mm)`:""}function Wr(t){const e=t.tiling;return{...ot,...e,sheetMargin:{...ot.sheetMargin,...e?.sheetMargin??{}}}}function Yn(t,e){const n=Wr(t),r=e?.paperOverride;if(r&&typeof r.width=="number"&&r.width>0&&typeof r.height=="number"&&r.height>0)return{width:r.width,height:r.height};if(n.sheetPaperSize==="CUSTOM")return{width:n.sheetCustomWidth??Nt.A4.width,height:n.sheetCustomHeight??Nt.A4.height};const o=n.sheetPaperSize??"A4",i=Nt[o]??Nt.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function Nc(t,e){return{w:t.width-e.left-e.right,h:t.height-e.top-e.bottom}}function la(t,e,n){return Math.max(0,Math.floor((t+n)/(e+n)))}function Lc(t,e){const n=ca(t,e);if(n.length)throw new Bm(n[0].code,n[0].message);const r=Wr(t),o=Yn(t,e),i=nn(t),a=Nc(o,r.sheetMargin),l=Math.floor((a.h+r.gapY)/(i.height+r.gapY));return{tile:{width:i.width,height:i.height},sheet:o,columns:r.columns,rows:l,perSheet:r.columns*l,maxColumns:la(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function Hm(t,e){const n=e%t.perSheet,r=n%t.columns,o=Math.floor(n/t.columns);return{left:zt(t.margin.left+r*(t.tile.width+t.gapX)),top:zt(t.margin.top+o*(t.tile.height+t.gapY))}}function Fc(t,e){const n=Wr(t),r=Yn(t,e),o=nn(t),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return la(i,o.width,n.gapX)}function ca(t,e){const n=[],r=Wr(t);tt(t)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=tn(o??"");i&&n.push({code:"SHEET_CONTINUOUS",message:"拼版目标纸张不能是连续纸"});const a=r.sheetPaperSize==="CUSTOM"&&!((r.sheetCustomWidth??0)>0&&(r.sheetCustomHeight??0)>0);if(a&&n.push({code:"SHEET_SIZE_INVALID",message:"拼版自定义纸张宽高必须是大于 0 的数值(mm)"}),a||i)return n;const l=Yn(t,e),c=nn(t),s=Nc(l,r.sheetMargin),d=zt(r.sheetMargin.left+r.sheetMargin.right);if(!Number.isInteger(r.columns)||r.columns<1)return n.push({code:"COLUMNS_INVALID",message:"拼版列数必须是大于 0 的整数"}),n;const p=la(s.w,c.width,r.gapX);if(r.columns>p){const u=zt(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+zt(l.width)+"mm − 左右留白 "+d+"mm = "+zt(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"+$c(t,c)})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+zt(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"+$c(t,c)}),n}function Um(t){const e=[],n=new Set;for(const r of t)for(const o of r.warnings??[])n.has(o)||(n.add(o),e.push(o));return e}function qm(t){const e=Array.isArray(t.pages)?t.pages:[t],n=[];for(const r of e)try{n.push(...yi(r,new Map))}catch{}return Um(n)}function Wm(t){const{copies:e,layout:n}=t,r=e[0].bound,o=[];for(let a=0;a<e.length;a+=n.perSheet){const l=e.slice(a,a+n.perSheet).map((c,s)=>{const d=Hm(n,s),p=Fr(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
237
+ `),o=n?em(e,t.map(a=>({heightMm:a.derivedHeightMm}))):`${Wn(e)}
238
+ .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=Un(e.fonts)+o;return{html:zr(i,r,n?"continuous":void 0),pageCount:t.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:t.map(a=>a.paperMm)}}const ot={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class Hm extends Error{constructor(e,n){super(n),this.name="TilingError",this.code=e}}function zt(t){return Math.round(t*10)/10}function Nc(t,e){const n=t.outputRotation;return n===90||n===270?`(内容旋转 ${n}°,每格 ${e.width}×${e.height}mm)`:""}function Wr(t){const e=t.tiling;return{...ot,...e,sheetMargin:{...ot.sheetMargin,...e?.sheetMargin??{}}}}function Yn(t,e){const n=Wr(t),r=e?.paperOverride;if(r&&typeof r.width=="number"&&r.width>0&&typeof r.height=="number"&&r.height>0)return{width:r.width,height:r.height};if(n.sheetPaperSize==="CUSTOM")return{width:n.sheetCustomWidth??Nt.A4.width,height:n.sheetCustomHeight??Nt.A4.height};const o=n.sheetPaperSize??"A4",i=Nt[o]??Nt.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function Lc(t,e){return{w:t.width-e.left-e.right,h:t.height-e.top-e.bottom}}function la(t,e,n){return Math.max(0,Math.floor((t+n)/(e+n)))}function Fc(t,e){const n=ca(t,e);if(n.length)throw new Hm(n[0].code,n[0].message);const r=Wr(t),o=Yn(t,e),i=nn(t),a=Lc(o,r.sheetMargin),l=Math.floor((a.h+r.gapY)/(i.height+r.gapY));return{tile:{width:i.width,height:i.height},sheet:o,columns:r.columns,rows:l,perSheet:r.columns*l,maxColumns:la(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function Um(t,e){const n=e%t.perSheet,r=n%t.columns,o=Math.floor(n/t.columns);return{left:zt(t.margin.left+r*(t.tile.width+t.gapX)),top:zt(t.margin.top+o*(t.tile.height+t.gapY))}}function zc(t,e){const n=Wr(t),r=Yn(t,e),o=nn(t),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return la(i,o.width,n.gapX)}function ca(t,e){const n=[],r=Wr(t);tt(t)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=tn(o??"");i&&n.push({code:"SHEET_CONTINUOUS",message:"拼版目标纸张不能是连续纸"});const a=r.sheetPaperSize==="CUSTOM"&&!((r.sheetCustomWidth??0)>0&&(r.sheetCustomHeight??0)>0);if(a&&n.push({code:"SHEET_SIZE_INVALID",message:"拼版自定义纸张宽高必须是大于 0 的数值(mm)"}),a||i)return n;const l=Yn(t,e),c=nn(t),s=Lc(l,r.sheetMargin),d=zt(r.sheetMargin.left+r.sheetMargin.right);if(!Number.isInteger(r.columns)||r.columns<1)return n.push({code:"COLUMNS_INVALID",message:"拼版列数必须是大于 0 的整数"}),n;const p=la(s.w,c.width,r.gapX);if(r.columns>p){const u=zt(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+zt(l.width)+"mm − 左右留白 "+d+"mm = "+zt(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"+Nc(t,c)})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+zt(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"+Nc(t,c)}),n}function qm(t){const e=[],n=new Set;for(const r of t)for(const o of r.warnings??[])n.has(o)||(n.add(o),e.push(o));return e}function Wm(t){const e=Array.isArray(t.pages)?t.pages:[t],n=[];for(const r of e)try{n.push(...yi(r,new Map))}catch{}return qm(n)}function jm(t){const{copies:e,layout:n}=t,r=e[0].bound,o=[];for(let a=0;a<e.length;a+=n.perSheet){const l=e.slice(a,a+n.perSheet).map((c,s)=>{const d=Um(n,s),p=Fr(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
239
239
  ${p}
240
240
  </div>`}).join(`
241
241
  `);o.push(`<section class="print-sheet">
242
242
  ${l}
243
243
  </section>`)}const i=Un(r.fonts)+Wn(r)+`
244
- `+em(n);return{html:zr(i,o.join(`
245
- `)),sheetCount:o.length,perSheet:n.perSheet}}function da(t,e){return t.name?`第 ${e+1} 页「${t.name}」`:`第 ${e+1} 页`}function ua(t){const e=jm(t)?t.pages:[t];if(e.length===0)throw new Error("多页面模板至少需要一页");if(e.length===1)return e;const n=Ze(e[0]);return e.forEach((r,o)=>{if(tt(r))throw new Error(`多页面模板不支持连续纸(${da(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${da(r,o)})`);const i=Ze(r);if(i.width!==n.width||i.height!==n.height)throw new Error(`多页面模板各页纸张尺寸必须一致(${da(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),e}function jm(t){return Array.isArray(t.pages)}function Gm(t){const e=new Set,n=[];for(const r of t)for(const o of r.fonts??[]){const i=o.family;e.has(i)||(e.add(i),n.push(o))}return n}function Ym(t){if(t.length===0)throw new Error("多页面模板至少需要一份数据");const e=t[0].boundPages,n=Un(Gm(e))+[Zg(e[0]),Kg(),...e.map((l,c)=>Jg(l,`.mt-${c}`)),...t.length>1?[Ji]:[]].join(`
244
+ `+tm(n);return{html:zr(i,o.join(`
245
+ `)),sheetCount:o.length,perSheet:n.perSheet}}function da(t,e){return t.name?`第 ${e+1} 页「${t.name}」`:`第 ${e+1} 页`}function ua(t){const e=Gm(t)?t.pages:[t];if(e.length===0)throw new Error("多页面模板至少需要一页");if(e.length===1)return e;const n=Ze(e[0]);return e.forEach((r,o)=>{if(tt(r))throw new Error(`多页面模板不支持连续纸(${da(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${da(r,o)})`);const i=Ze(r);if(i.width!==n.width||i.height!==n.height)throw new Error(`多页面模板各页纸张尺寸必须一致(${da(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),e}function Gm(t){return Array.isArray(t.pages)}function Ym(t){const e=new Set,n=[];for(const r of t)for(const o of r.fonts??[]){const i=o.family;e.has(i)||(e.add(i),n.push(o))}return n}function Vm(t){if(t.length===0)throw new Error("多页面模板至少需要一份数据");const e=t[0].boundPages,n=Un(Ym(e))+[Jg(e[0]),Zg(),...e.map((l,c)=>Qg(l,`.mt-${c}`)),...t.length>1?[Ji]:[]].join(`
246
246
 
247
247
  `),r=t.map(l=>{const c=l.layoutsPerPage.reduce((u,f)=>u+f.length,0);let s=0;const p=l.layoutsPerPage.map((u,f)=>{const h=Fr(l.boundPages[f],u,l.data,{codeRenderer:l.codeRenderers?.[f]},{pageOffset:s,totalPages:c,pageClass:`mt-${f}`});return s+=u.length,h}).join(`
248
248
  `);return t.length>1?`<section class="print-copy">
249
249
  ${p}
250
250
  </section>`:p}).join(`
251
- `),o=t.reduce((l,c)=>l+c.layoutsPerPage.reduce((s,d)=>s+d.length,0),0),i=[];let a=0;for(const l of t)for(const c of l.layoutsPerPage)for(const s of c)i.push({...s,pageIndex:a++});return{html:zr(n,r),pageCount:o,pageLayouts:i}}async function Vm(t,e){return e.withSession(t,n=>Xm(t,n))}async function Xm(t,e){const n=ua(t.templateJson);if(n.length>1){const c=Dc(t.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await Zm(t,e,s[u]))}catch(f){const h=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${h}`)}const p=Ym(d);return{html:p.html,pageCount:p.pageCount,paperMm:nn(n[0]),continuous:!1,heightSource:"config",pageLayouts:p.pageLayouts,copies:d.length}}const r=n[0]!==t.templateJson?{...t,templateJson:n[0]}:t,o=n[0],i=Dc(r.printData);if(i.mode==="single"){const c=await Bc(r,e,i.data);return o.tiling?.enabled===!0?zc(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):Km(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await Bc(r,e,i.dataList[c]);a.push({bound:s.bound,pageLayouts:s.pageLayouts,data:i.dataList[c],codeRenderer:s.codeRenderer,derivedHeightMm:s.derivedHeightMm,paperMm:s.paperMm,heightSource:s.heightSource})}catch(s){const d=s instanceof Error?s.message:String(s);throw new Error(`第 ${c+1} 份渲染失败:${d}`)}if(o.tiling?.enabled===!0)return zc(r,a);const l=zm(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:tt(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function Km(t){return{html:t.html,pageCount:t.pageCount,paperMm:t.paperMm,continuous:t.continuous,heightSource:t.heightSource,pageLayouts:t.pageLayouts,copies:1}}function zc(t,e){const n=e[0].bound,r=Lc(n,{paperOverride:t.paperOverride});e.forEach((i,a)=>{const l=i.pageLayouts[0]?.overflow===!0;if(i.pageLayouts.length!==1||l){const c=l?"内容超出纸张高度":`渲染出 ${i.pageLayouts.length} 页`;throw new Error(`拼版要求每份标签恰好 1 页,第 ${a+1} 份${c};请缩小内容或调整标签纸张高度`)}});const o=Wm({copies:e.map(i=>({bound:i.bound,pageLayouts:i.pageLayouts,data:i.data,codeRenderer:i.codeRenderer})),layout:r});return{html:o.html,pageCount:o.sheetCount,paperMm:{width:r.sheet.width,height:r.sheet.height},continuous:!1,heightSource:"config",pageLayouts:e.flatMap(i=>i.pageLayouts),copies:e.length}}async function Bc(t,e,n){const r=oc(t.templateJson,n,t.baseUrl,t.fontBaseUrl),o=tt(r),i=Ze(r),a=Ac(i),l=Cm({paperHeightMm:t.paperHeightMm,override:t.paperOverride}),c=await jr({bound:r,job:t,session:e,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await e.measure(c.html,a);Ic(r,s.fits);const d=yi(r,Oc(s.measurements,r)),p=await jr({bound:r,job:t,session:e,data:n,pageLayouts:d,isMeasurementPass:!1,baseMap:c.map});let u=p.html,f;if(o){if(l&&l>0)f=l;else{const w=await e.probeContentBottom(u,a);f=Tm(r,sa(w))}u=Lr(r,d,n,{codeRenderer:p.codeRenderer,pageHeightMm:f})}const h=o&&l?{...t.paperOverride,height:l}:t.paperOverride,m=nn(r),{paperMm:b,heightSource:v}=Am({paperMm:{width:m.width,height:f??m.height},continuous:o,override:h});return{html:u,pageCount:d.length,paperMm:b,continuous:o,heightSource:v,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,derivedHeightMm:f}}async function Zm(t,e,n){const r=ua(t.templateJson),o=Ac(Ze(r[0])),i=[],a=[],l=[];for(const c of r){const s=oc(c,n,t.baseUrl,t.fontBaseUrl),d=await jr({bound:s,job:t,session:e,data:n,pageLayouts:[],isMeasurementPass:!0}),p=await e.measure(d.html,o);Ic(s,p.fits);const u=yi(s,Oc(p.measurements,s)),f=await jr({bound:s,job:t,session:e,data:n,pageLayouts:u,isMeasurementPass:!1,baseMap:d.map});i.push(s),a.push(u),l.push(f.codeRenderer)}return{boundPages:i,layoutsPerPage:a,data:n,codeRenderers:l}}async function jr(t){const e=t.baseMap??new Map;if(t.job.codeRenderer)return{html:Lr(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:t.job.codeRenderer}),codeRenderer:t.job.codeRenderer,map:e};const n=Pm(e),r=Lr(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:n.renderer}),o=n.takeSpecs(),i=o.length>0?await t.session.renderCodes(o):new Map,a=Rm(e,i),l=a.size>0?Im(a):void 0;return o.length===0?{html:r,codeRenderer:l,map:a}:{html:Lr(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:l}),codeRenderer:l,map:a}}class Jm{constructor(e){this.functions={},e?.functions&&(this.functions={...e.functions})}registerFunction(e,n){this.functions[e]=n}evaluate(e,n){const r=Ni(e),o=Li(r);return Ie(o,n,this.functions)}render(e,n){return ql(e,this.functions)(n)}}const Hc=new Jm,Qm={MONEY:Wl,CONCAT:(...t)=>t.filter(e=>e!=null).join(""),IF:Yl,FORMAT:t=>typeof t!="number"?String(t):t.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(t,e,n)=>String(t).slice(e,n?e+n:void 0),LEN:t=>String(t).length,ADD:Jl,SUB:Ql,MUL:ec,DIV:tc,ROUND:nc,ROUNDUP:Ir,CEIL:Ir,ROUNDDOWN:Pr,FLOOR:Pr,ROUNDBANK:rc,NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(t,e)=>t!=null&&t!==""?String(t):e,PAD:(t,e,n)=>String(t).padStart(e,n),REPLACE:(t,e,n)=>String(t).replace(new RegExp(e,"g"),n),JSON:t=>JSON.stringify(t,null,2),DATE:jl,UPPER:Gl};for(const[t,e]of Object.entries(Qm))Hc.registerFunction(t,e);function e0(t,e,n){switch(t.toUpperCase()){case"SUM":return qi(n,e);case"AVG":return Vl(n,e);case"COUNT":return Xl(n);case"MIN":return Kl(n,e);case"MAX":return Zl(n,e);default:return 0}}function dn(t,e){if(!t)return"";if(!t.includes("{"))return t;const n=Array.isArray(e.rows)?e.rows:[];let r=t.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(e0(c,d,n))}),`{${a}}`});try{return Hc.render(r,e)}catch{return t}}const it={supplier:{name:"鑫达五金有限公司",phone:"0571-88776655",address:"杭州市萧山区经济开发区88号"},receiver:{name:"李四",phone:"13912345678",address:"杭州市余杭区文一西路998号"},order:{no:"PO20260801001",date:"2026-08-01",total:69543.75},goods:[{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:100,price:.5,amount:50,remark:"A级"},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:117,price:.75,amount:87.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:134,price:1,amount:134,remark:""},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:151,price:1.25,amount:188.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:168,price:1.5,amount:252,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:185,price:1.75,amount:323.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:202,price:2,amount:404,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:219,price:2.25,amount:492.75,remark:"A级"},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:236,price:2.5,amount:590,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:253,price:2.75,amount:695.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×20",unit:"个",qty:270,price:3,amount:810,remark:""},{name:"不锈钢螺母 M10",spec:"M16×21",unit:"套",qty:287,price:3.25,amount:932.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×22",unit:"盒",qty:304,price:3.5,amount:1064,remark:""},{name:"六角螺栓 M14",spec:"M5×23",unit:"支",qty:321,price:3.75,amount:1203.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×24",unit:"袋",qty:338,price:4,amount:1352,remark:"A级"},{name:"平垫圈 M6",spec:"M4×25",unit:"件",qty:355,price:4.25,amount:1508.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×26",unit:"根",qty:372,price:4.5,amount:1674,remark:""},{name:"双头螺柱 M20",spec:"M8×27",unit:"包",qty:389,price:4.75,amount:1847.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×28",unit:"只",qty:406,price:5,amount:2030,remark:""},{name:"十字盘头钉 M3",spec:"M12×29",unit:"组",qty:423,price:5.25,amount:2220.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×30",unit:"个",qty:440,price:.5,amount:220,remark:""},{name:"不锈钢螺母 M10",spec:"M16×31",unit:"套",qty:457,price:.75,amount:342.75,remark:"A级"},{name:"弹簧垫圈 M12",spec:"M6×32",unit:"盒",qty:474,price:1,amount:474,remark:""},{name:"六角螺栓 M14",spec:"M5×33",unit:"支",qty:491,price:1.25,amount:613.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×34",unit:"袋",qty:508,price:1.5,amount:762,remark:""},{name:"平垫圈 M6",spec:"M4×35",unit:"件",qty:525,price:1.75,amount:918.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×36",unit:"根",qty:542,price:2,amount:1084,remark:""},{name:"双头螺柱 M20",spec:"M8×37",unit:"包",qty:559,price:2.25,amount:1257.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×38",unit:"只",qty:576,price:2.5,amount:1440,remark:"A级"},{name:"十字盘头钉 M3",spec:"M12×39",unit:"组",qty:593,price:2.75,amount:1630.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×40",unit:"个",qty:610,price:3,amount:1830,remark:""},{name:"不锈钢螺母 M10",spec:"M16×41",unit:"套",qty:627,price:3.25,amount:2037.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×42",unit:"盒",qty:644,price:3.5,amount:2254,remark:""},{name:"六角螺栓 M14",spec:"M5×43",unit:"支",qty:661,price:3.75,amount:2478.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×44",unit:"袋",qty:678,price:4,amount:2712,remark:""},{name:"平垫圈 M6",spec:"M4×45",unit:"件",qty:695,price:4.25,amount:2953.75,remark:"A级"},{name:"自攻螺钉 M5",spec:"M3×46",unit:"根",qty:712,price:4.5,amount:3204,remark:""},{name:"双头螺柱 M20",spec:"M8×47",unit:"包",qty:729,price:4.75,amount:3462.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×48",unit:"只",qty:746,price:5,amount:3730,remark:""},{name:"十字盘头钉 M3",spec:"M12×49",unit:"组",qty:763,price:5.25,amount:4005.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:780,price:.5,amount:390,remark:""},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:797,price:.75,amount:597.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:814,price:1,amount:814,remark:"A级"},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:831,price:1.25,amount:1038.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:848,price:1.5,amount:1272,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:865,price:1.75,amount:1513.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:882,price:2,amount:1764,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:899,price:2.25,amount:2022.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:916,price:2.5,amount:2290,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:933,price:2.75,amount:2565.75,remark:"A级"}]},Gr={left:0,center:50,right:100},Yr={top:0,center:50,bottom:100};function un(t){return Number.isFinite(t)?Math.round(Math.min(100,Math.max(0,t))):50}function Uc(t){return Math.round(t*100)/100}function qc(t,e){const n=un(t),r=un(e);if(!(n===50&&r===50))return`${n}% ${r}%`}function t0(t){return/^\d+(?:\.\d+)?%$/.test(t)?parseFloat(t):void 0}function n0(t){const e=(t??"").trim();if(!e)return{kind:"empty"};const n=e.toLowerCase().split(/\s+/);let r,o;for(let i=0;i<n.length;i++){const a=n[i],l=t0(a);if(i===0)if(a in Gr)r=Gr[a];else if(l!==void 0)r=l;else if(a in Yr)o=Yr[a];else return{kind:"custom",raw:t};else if(a in Yr&&o===void 0)o=Yr[a];else if(l!==void 0&&r===void 0)r=l;else if(l!==void 0&&o===void 0)o=l;else if(a in Gr&&r===void 0)r=Gr[a];else return{kind:"custom",raw:t}}return{kind:"axes",x:un(r??50),y:un(o??50)}}const Wc=25.4/96;function jc(t){const{widthMm:e,heightMm:n,naturalWidth:r,naturalHeight:o}=t;if(!r||!o||!e||!n)return null;const i=e/r,a=n/o,l=(tl(t.fit,t.scalePct)??Rn)/100;switch(t.fit||"contain"){case"fill":return{w:e,h:n};case"cover":{const c=Math.max(i,a)*l;return{w:r*c,h:o*c}}case"none":return{w:r*Wc,h:o*Wc};case"scale-down":{const c=Math.min(1,Math.min(i,a));return{w:r*c,h:o*c}}default:{const c=Math.min(i,a);return{w:r*c,h:o*c}}}}function r0(t){const e=jc(t);return e?{x:Uc(Math.abs(t.widthMm-e.w)),y:Uc(Math.abs(t.heightMm-e.h))}:{x:null,y:null}}function o0(t,e,n){const r=jc(t);if(!r)return null;const o=Math.min(1,t.widthMm/r.w),i=Math.min(1,t.heightMm/r.h);return{leftPct:(1-o)*un(e),topPct:(1-i)*un(n),widthPct:o*100,heightPct:i*100}}function Gc(t){const e=String(t??"");return e?e.includes("{")?String(dn(e,it)):e:""}const Yc={vertical:[{value:0,label:"顶部"},{value:50,label:"居中"},{value:100,label:"底部"}],horizontal:[{value:0,label:"左侧"},{value:50,label:"居中"},{value:100,label:"右侧"}]},i0=[{x:0,y:0,label:"左上"},{x:50,y:0,label:"上中"},{x:100,y:0,label:"右上"},{x:0,y:50,label:"左中"},{x:50,y:50,label:"居中"},{x:100,y:50,label:"右中"},{x:0,y:100,label:"左下"},{x:50,y:100,label:"下中"},{x:100,y:100,label:"右下"}],pa=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"剪裁(等比铺满后裁边)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],a0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNNDAgMFYxMjBNODAgMFYxMjBNMCA0MEgxMjBNMCA4MEgxMjAiIHN0cm9rZT0iI2VlZjFmNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMy41IiBmaWxsPSIjOGI5NWE1Ii8+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMjAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iMTAwIiByPSIzLjUiIGZpbGw9IiM4Yjk1YTUiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iMjAiIHI9IjciIGZpbGw9IiNjMDM5MmIiLz48Y2lyY2xlIGN4PSI2MCIgY3k9IjEwMCIgcj0iNyIgZmlsbD0iIzFmNGZhMyIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iNjAiIHI9IjciIGZpbGw9IiMyYzdhNGEiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSI2MCIgcj0iNyIgZmlsbD0iI2UwN2EyMCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjE0IiBmaWxsPSJub25lIiBzdHJva2U9IiMyZjNhNGEiIHN0cm9rZS13aWR0aD0iNCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYiIGZpbGw9IiMyZjNhNGEiLz48L3N2Zz4=",s0="图片还没设置,上面按内置示例图演示取位;换上真图后档位与可挪量按真图重算";function l0(t){const e=String(t??"").trim();return!e||e.includes("{")||e.includes("}")?{src:a0,isSample:!0}:{src:e,isSample:!1}}function Vc(t){return t==="vertical"?"垂直位置 (%)":"水平位置 (%)"}const c0="放大比例 (%)";function d0(t,e=!1){if(e)return"已保留模板里的原值;改动下面任一项就整体替换成新的取位";const{x:n,y:r}=t;return n===null||r===null?"":n>0&&r>0?`水平可挪 ${n}mm、垂直可挪 ${r}mm:0 贴左/贴顶,100 贴右/贴底`:n>0?`水平可挪 ${n}mm;垂直这一轴已贴满,挪不动`:r>0?`垂直可挪 ${r}mm;水平这一轴已贴满,挪不动`:"这个缩放下图与框正好一样大,两轴都没有可挪的余量"}function u0(t,e,n){return[{name:"horizontal",label:Vc("horizontal"),value:e,travelMm:t.x},{name:"vertical",label:Vc("vertical"),value:n,travelMm:t.y}]}function p0(t,e,n){const r=t.x!==null&&t.x>0,o=t.y!==null&&t.y>0;return o&&!r?Yc.vertical.map(i=>({value:`${e},${i.value}`,label:i.label})):r&&!o?Yc.horizontal.map(i=>({value:`${i.value},${n}`,label:i.label})):i0.map(i=>({value:`${i.x},${i.y}`,label:i.label}))}function Xc(t){const e=[...t].sort((a,l)=>(a.sortOrder??0)-(l.sortOrder??0)),n=new Map,r=[];for(const a of e){const l=a.fieldKey.indexOf(".");if(l===-1)continue;const c=a.fieldKey.slice(0,l);let s=n.get(c);s||(s={key:c,label:c,isList:!1,fields:[]},n.set(c,s),r.push(c)),s.fields.push(a)}const o=[],i=[];for(const a of e){if(a.fieldKey.includes("."))continue;const l=n.get(a.fieldKey);l?(l.label=a.fieldLabel,l.isList=a.fieldType==="list"):i.push(a)}i.length&&o.push({key:"",label:"",isList:!1,fields:i});for(const a of r)o.push(n.get(a));return o}function f0(t,e){const n=e.trim().toLowerCase();return n?t.map(r=>({...r,fields:r.fields.filter(o=>o.fieldLabel.toLowerCase().includes(n)||o.fieldKey.toLowerCase().includes(n))})).filter(r=>r.fields.length>0):t}const h0={text:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],longText:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],barcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],qrcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],image:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],table:[],flowList:[{targetPath:"options.formatter",label:"单元模板",dataSource:"main",placeholder:"{drugs.name} {drugs.spec}"}]};function Kc(t,e,n,r){return t==="data"?[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:r,placeholder:"{name}"}]:t==="subtotal"?[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:t==="summary"?[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function g0(t){const e=t.printElementType.type,n=h0[e]??[],r=[];if(e==="table"){const o=t.options.dataSource;for(const[i,a]of(t.options.tableRows??[]).entries())for(const[l,c]of a.cells.entries())c.merged||r.push(...Kc(a.type,i,l,o))}return[...n,...r]}function m0(t){return $l("text",{formatter:`{${t.fieldKey}}`,title:t.fieldLabel})}function Zc(t){let e=it;for(const n of t.split(".")){if(e==null)return;e=Array.isArray(e)?e[0]?.[n]:e[n]}return e}function b0(t,e){const n=e?.[0];return(t??"").replace(/\{([^{}]+)\}/g,(o,i)=>{const a=i.trim(),l=a.includes(".")?Zc(a):n?.[a]??Zc(a);return l==null?"":String(l)}).trim()||"1234567890128"}const Vr={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function Jc(t){return t==="vCenter"?Vr.center:t==="hCenter"?Vr.middle:Vr[t]??Vr.left}function y0(t,e,n,r={}){const o=r.adsorbMin??1,i=r.adsorbLineMin??2,a=r.showAdsorbLine??!0;let l=t.left,c=t.top;const s=[],d={left:t.left,right:t.left+t.width,vCenter:t.left+t.width/2,top:t.top,bottom:t.top+t.height,hCenter:t.top+t.height/2};let p=1/0;for(const f of e){if(f.id===t.id)continue;const h={left:f.left,right:f.left+f.width,vCenter:f.left+f.width/2,top:f.top,bottom:f.top+f.height,hCenter:f.top+f.height/2},m=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],b=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,w]of m){const _=Math.abs(d[v]-h[w]);_<=o&&_<p&&(p=_,l=t.left+(h[w]-d[v]))}for(const[v,w]of b){const _=Math.abs(d[v]-h[w]);_<=o&&_<p&&(p=_,c=t.top+(h[w]-d[v]))}}if(n){const f={left:l,right:l+t.width,vCenter:l+t.width/2,top:c,bottom:c+t.height,hCenter:c+t.height/2},h=["left","vCenter","right"];for(const b of n.vertical)for(const v of h){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,l=t.left+(b-f[v]))}const m=["top","hCenter","bottom"];for(const b of n.horizontal)for(const v of m){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,c=t.top+(b-f[v]))}}const u={left:l,right:l+t.width,vCenter:l+t.width/2,top:c,bottom:c+t.height,hCenter:c+t.height/2};if(a){const f=new Set;for(const h of e){if(h.id===t.id)continue;const m={left:h.left,right:h.left+h.width,vCenter:h.left+h.width/2,top:h.top,bottom:h.top+h.height,hCenter:h.top+h.height/2},b=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,_]of b)if(Math.abs(u[w]-m[_])<=i){const z=`v:${m[_]}`;f.has(z)||(f.add(z),s.push({type:"vertical",position:m[_],id:h.id,color:Jc(w)}))}for(const[w,_]of v)if(Math.abs(u[w]-m[_])<=i){const z=`h:${m[_]}`;f.has(z)||(f.add(z),s.push({type:"horizontal",position:m[_],id:h.id,color:Jc(w)}))}}}if(n){for(const f of n.vertical)s.some(h=>h.type==="vertical"&&h.position===f)||s.push({type:"vertical",position:f});for(const f of n.horizontal)s.some(h=>h.type==="horizontal"&&h.position===f)||s.push({type:"horizontal",position:f})}return{left:l,top:c,lines:s}}function v0(){function t(e,n){if(e.length<2)return;const r={minLeft:Math.min(...e.map(o=>o.options.left)),maxRight:Math.max(...e.map(o=>o.options.left+o.options.width)),minTop:Math.min(...e.map(o=>o.options.top)),maxBottom:Math.max(...e.map(o=>o.options.top+o.options.height))};switch(n){case"left":e.forEach(o=>{o.options.left=r.minLeft});break;case"right":e.forEach(o=>{o.options.left=r.maxRight-o.options.width});break;case"top":e.forEach(o=>{o.options.top=r.minTop});break;case"bottom":e.forEach(o=>{o.options.top=r.maxBottom-o.options.height});break;case"vertical":{const o=r.minLeft+(r.maxRight-r.minLeft)/2;e.forEach(i=>{i.options.left=o-i.options.width/2});break}case"horizontal":{const o=r.minTop+(r.maxBottom-r.minTop)/2;e.forEach(i=>{i.options.top=o-i.options.height/2});break}case"distributeHor":{const o=[...e].sort((c,s)=>c.options.left-s.options.left),i=o.reduce((c,s)=>c+s.options.width,0),a=(r.maxRight-r.minLeft-i)/(o.length-1);let l=r.minLeft;o.forEach(c=>{c.options.left=l,l+=c.options.width+a});break}case"distributeVer":{const o=[...e].sort((c,s)=>c.options.top-s.options.top),i=o.reduce((c,s)=>c+s.options.height,0),a=(r.maxBottom-r.minTop-i)/(o.length-1);let l=r.minTop;o.forEach(c=>{c.options.top=l,l+=c.options.height+a});break}}}return{align:t}}function Qc(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function w0(){function t(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=Qc();return r.map(l=>o.has(l.id)?{...l,options:{...l.options,groupId:a}}:l)}function e(r,o){const i=r.filter(l=>o.has(l.id)),a=new Set(i.map(l=>l.options.groupId).filter(Boolean));return r.map(l=>l.options.groupId&&a.has(l.options.groupId)?{...l,options:{...l.options,groupId:void 0}}:l)}function n(r,o){const i=r.find(l=>l.id===o);if(!i?.options.groupId)return new Set([o]);const a=new Set;for(const l of r)l.options.groupId===i.options.groupId&&a.add(l.id);return a}return{group:t,ungroup:e,getGroupedIds:n}}const x0=["nw","n","ne","e","se","s","sw","w"];function E0(t,e,n,r,o,i){let{left:a,top:l,width:c,height:s}=e;switch(t){case"e":c=Math.max(o,e.width+n);break;case"w":c=Math.max(o,e.width-n),a=e.left+e.width-c;break;case"s":s=Math.max(i,e.height+r);break;case"n":s=Math.max(i,e.height-r),l=e.top+e.height-s;break;case"se":c=Math.max(o,e.width+n),s=Math.max(i,e.height+r);break;case"sw":c=Math.max(o,e.width-n),a=e.left+e.width-c,s=Math.max(i,e.height+r);break;case"ne":c=Math.max(o,e.width+n),s=Math.max(i,e.height-r),l=e.top+e.height-s;break;case"nw":c=Math.max(o,e.width-n),a=e.left+e.width-c,s=Math.max(i,e.height-r),l=e.top+e.height-s;break}return{left:a,top:l,width:c,height:s}}function ed(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xr={},Vn={},Kr={},td;function qe(){if(td)return Kr;td=1,Object.defineProperty(Kr,"__esModule",{value:!0});function t(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}var e=function n(r,o){t(this,n),this.data=r,this.text=o.text||r,this.options=o};return Kr.default=e,Kr}var nd;function S0(){if(nd)return Vn;nd=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.CODE39=void 0;var t=(function(){function m(b,v){for(var w=0;w<v.length;w++){var _=v[w];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,v,w){return v&&m(b.prototype,v),w&&m(b,w),b}})(),e=qe(),n=r(e);function r(m){return m&&m.__esModule?m:{default:m}}function o(m,b){if(!(m instanceof b))throw new TypeError("Cannot call a class as a function")}function i(m,b){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:m}function a(m,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);m.prototype=Object.create(b&&b.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(m,b):m.__proto__=b)}var l=(function(m){a(b,m);function b(v,w){return o(this,b),v=v.toUpperCase(),w.mod43&&(v+=u(h(v))),i(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,v,w))}return t(b,[{key:"encode",value:function(){for(var w=d("*"),_=0;_<this.data.length;_++)w+=d(this.data[_])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),b})(n.default),c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],s=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(m){return p(f(m))}function p(m){return s[m].toString(2)}function u(m){return c[m]}function f(m){return c.indexOf(m)}function h(m){for(var b=0,v=0;v<m.length;v++)b+=f(m[v]);return b=b%43,b}return Vn.CODE39=l,Vn}var Je={},Zr={},Jr={},me={},rd;function Xn(){if(rd)return me;rd=1,Object.defineProperty(me,"__esModule",{value:!0});var t;function e(c,s,d){return s in c?Object.defineProperty(c,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):c[s]=d,c}var n=me.SET_A=0,r=me.SET_B=1,o=me.SET_C=2;me.SHIFT=98;var i=me.START_A=103,a=me.START_B=104,l=me.START_C=105;return me.MODULO=103,me.STOP=106,me.FNC1=207,me.SET_BY_CODE=(t={},e(t,i,n),e(t,a,r),e(t,l,o),t),me.SWAP={101:n,100:r,99:o},me.A_START_CHAR="Ð",me.B_START_CHAR="Ñ",me.C_START_CHAR="Ò",me.A_CHARS="[\0-_È-Ï]",me.B_CHARS="[ -È-Ï]",me.C_CHARS="(Ï*[0-9]{2}Ï*)",me.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],me}var od;function Qr(){if(od)return Jr;od=1,Object.defineProperty(Jr,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=qe(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){i(this,d);var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p.substring(1),u));return f.bytes=p.split("").map(function(h){return h.charCodeAt(0)}),f}return t(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.bytes,f=u.shift()-105,h=r.SET_BY_CODE[f];if(h===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&u.unshift(r.FNC1);var m=d.next(u,1,h);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(f)+m.result+d.getBar((m.checksum+f)%r.MODULO)+d.getBar(r.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var u=this.options.ean128||!1;return typeof u=="string"&&(u=u.toLowerCase()==="true"),u}}],[{key:"getBar",value:function(u){return r.BARS[u]?r.BARS[u].toString():""}},{key:"correctIndex",value:function(u,f){if(f===r.SET_A){var h=u.shift();return h<32?h+64:h-32}else return f===r.SET_B?u.shift()-32:(u.shift()-48)*10+u.shift()-48}},{key:"next",value:function(u,f,h){if(!u.length)return{result:"",checksum:0};var m=void 0,b=void 0;if(u[0]>=200){b=u.shift()-105;var v=r.SWAP[b];v!==void 0?m=d.next(u,f+1,v):((h===r.SET_A||h===r.SET_B)&&b===r.SHIFT&&(u[0]=h===r.SET_A?u[0]>95?u[0]-96:u[0]:u[0]<32?u[0]+96:u[0]),m=d.next(u,f+1,h))}else b=d.correctIndex(u,h),m=d.next(u,f+1,h);var w=d.getBar(b),_=b*f;return{result:w+m.result,checksum:_+m.checksum}}}]),d})(n.default);return Jr.default=c,Jr}var eo={},id;function _0(){if(id)return eo;id=1,Object.defineProperty(eo,"__esModule",{value:!0});var t=Xn(),e=function(l){return l.match(new RegExp("^"+t.A_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+t.B_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+t.C_CHARS+"*"))[0]};function o(a,l){var c=l?t.A_CHARS:t.B_CHARS,s=a.match(new RegExp("^("+c+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(s)return s[1]+"Ì"+i(a.substring(s[1].length));var d=a.match(new RegExp("^"+c+"+"))[0];return d.length===a.length?a:d+String.fromCharCode(l?205:206)+o(a.substring(d.length),!l)}function i(a){var l=r(a),c=l.length;if(c===a.length)return a;a=a.substring(c);var s=e(a)>=n(a);return l+String.fromCharCode(s?206:205)+o(a,s)}return eo.default=function(a){var l=void 0,c=r(a).length;if(c>=2)l=t.C_START_CHAR+i(a);else{var s=e(a)>n(a);l=(s?t.A_START_CHAR:t.B_START_CHAR)+o(a,s)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,p){return"Ë"+p})},eo}var ad;function M0(){if(ad)return Zr;ad=1,Object.defineProperty(Zr,"__esModule",{value:!0});var t=Qr(),e=o(t),n=_0(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){if(i(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(p))var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,r.default)(p),u));else var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u));return a(f)}return d})(e.default);return Zr.default=c,Zr}var to={},sd;function T0(){if(sd)return to;sd=1,Object.defineProperty(to,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Qr(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.A_START_CHAR+p,u))}return t(d,[{key:"valid",value:function(){return new RegExp("^"+r.A_CHARS+"+$").test(this.data)}}]),d})(n.default);return to.default=c,to}var no={},ld;function k0(){if(ld)return no;ld=1,Object.defineProperty(no,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Qr(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.B_START_CHAR+p,u))}return t(d,[{key:"valid",value:function(){return new RegExp("^"+r.B_CHARS+"+$").test(this.data)}}]),d})(n.default);return no.default=c,no}var ro={},cd;function C0(){if(cd)return ro;cd=1,Object.defineProperty(ro,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Qr(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.C_START_CHAR+p,u))}return t(d,[{key:"valid",value:function(){return new RegExp("^"+r.C_CHARS+"+$").test(this.data)}}]),d})(n.default);return ro.default=c,ro}var dd;function A0(){if(dd)return Je;dd=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.CODE128C=Je.CODE128B=Je.CODE128A=Je.CODE128=void 0;var t=M0(),e=c(t),n=T0(),r=c(n),o=k0(),i=c(o),a=C0(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return Je.CODE128=e.default,Je.CODE128A=r.default,Je.CODE128B=i.default,Je.CODE128C=l.default,Je}var Pe={},oo={},pt={},ud;function Kn(){return ud||(ud=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.SIDE_BIN="101",pt.MIDDLE_BIN="01010",pt.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},pt.EAN2_STRUCTURE=["LL","LG","GL","GG"],pt.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],pt.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),pt}var io={},ao={},pd;function Zn(){if(pd)return ao;pd=1,Object.defineProperty(ao,"__esModule",{value:!0});var t=Kn(),e=function(r,o,i){var a=r.split("").map(function(c,s){return t.BINARIES[o[s]]}).map(function(c,s){return c?c[r[s]]:""});if(i){var l=r.length-1;a=a.map(function(c,s){return s<l?c+i:c})}return a.join("")};return ao.default=e,ao}var fd;function hd(){if(fd)return io;fd=1,Object.defineProperty(io,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})(),e=Kn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,h){l(this,u);var m=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h));return m.fontSize=!h.flat&&h.fontSize>h.width*10?h.width*10:h.fontSize,m.guardHeight=h.height+m.fontSize/2+h.textMargin,m}return t(u,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(h,m){return this.text.substr(h,m)}},{key:"leftEncode",value:function(h,m){return(0,r.default)(h,m)}},{key:"rightText",value:function(h,m){return this.text.substr(h,m)}},{key:"rightEncode",value:function(h,m){return(0,r.default)(h,m)}},{key:"encodeGuarded",value:function(){var h={fontSize:this.fontSize},m={height:this.guardHeight};return[{data:e.SIDE_BIN,options:m},{data:this.leftEncode(),text:this.leftText(),options:h},{data:e.MIDDLE_BIN,options:m},{data:this.rightEncode(),text:this.rightText(),options:h},{data:e.SIDE_BIN,options:m}]}},{key:"encodeFlat",value:function(){var h=[e.SIDE_BIN,this.leftEncode(),e.MIDDLE_BIN,this.rightEncode(),e.SIDE_BIN];return{data:h.join(""),text:this.text}}}]),u})(i.default);return io.default=d,io}var gd;function O0(){if(gd)return oo;gd=1,Object.defineProperty(oo,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})(),e=function p(u,f,h){u===null&&(u=Function.prototype);var m=Object.getOwnPropertyDescriptor(u,f);if(m===void 0){var b=Object.getPrototypeOf(u);return b===null?void 0:p(b,f,h)}else{if("value"in m)return m.value;var v=m.get;return v===void 0?void 0:v.call(h)}},n=Kn(),r=hd(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=function(u){var f=u.substr(0,12).split("").map(function(h){return+h}).reduce(function(h,m,b){return b%2?h+m*3:h+m},0);return(10-f%10)%10},d=(function(p){c(u,p);function u(f,h){a(this,u),f.search(/^[0-9]{12}$/)!==-1&&(f+=s(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h));return m.lastChar=h.lastChar,m}return t(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===s(this.data)}},{key:"leftText",value:function(){return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var h=this.data.substr(1,6),m=n.EAN13_STRUCTURE[this.data[0]];return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftEncode",this).call(this,h,m)}},{key:"rightText",value:function(){return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var h=this.data.substr(7,6);return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightEncode",this).call(this,h,"RRRRRR")}},{key:"encodeGuarded",value:function(){var h=e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(h.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(h.push({data:"00"}),h.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),h}}]),u})(o.default);return oo.default=d,oo}var so={},md;function I0(){if(md)return so;md=1,Object.defineProperty(so,"__esModule",{value:!0});var t=(function(){function d(p,u){for(var f=0;f<u.length;f++){var h=u[f];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(p,h.key,h)}}return function(p,u,f){return u&&d(p.prototype,u),f&&d(p,f),p}})(),e=function d(p,u,f){p===null&&(p=Function.prototype);var h=Object.getOwnPropertyDescriptor(p,u);if(h===void 0){var m=Object.getPrototypeOf(p);return m===null?void 0:d(m,u,f)}else{if("value"in h)return h.value;var b=h.get;return b===void 0?void 0:b.call(f)}},n=hd(),r=o(n);function o(d){return d&&d.__esModule?d:{default:d}}function i(d,p){if(!(d instanceof p))throw new TypeError("Cannot call a class as a function")}function a(d,p){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:d}function l(d,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);d.prototype=Object.create(p&&p.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(d,p):d.__proto__=p)}var c=function(p){var u=p.substr(0,7).split("").map(function(f){return+f}).reduce(function(f,h,m){return m%2?f+h:f+h*3},0);return(10-u%10)%10},s=(function(d){l(p,d);function p(u,f){return i(this,p),u.search(/^[0-9]{7}$/)!==-1&&(u+=c(u)),a(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,u,f))}return t(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:"leftText",value:function(){return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var f=this.data.substr(0,4);return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftEncode",this).call(this,f,"LLLL")}},{key:"rightText",value:function(){return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var f=this.data.substr(4,4);return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightEncode",this).call(this,f,"RRRR")}}]),p})(r.default);return so.default=s,so}var lo={},bd;function P0(){if(bd)return lo;bd=1,Object.defineProperty(lo,"__esModule",{value:!0});var t=(function(){function u(f,h){for(var m=0;m<h.length;m++){var b=h[m];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,b.key,b)}}return function(f,h,m){return h&&u(f.prototype,h),m&&u(f,m),f}})(),e=Kn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(u){return u&&u.__esModule?u:{default:u}}function l(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function c(u,f){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f&&(typeof f=="object"||typeof f=="function")?f:u}function s(u,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(u,f):u.__proto__=f)}var d=function(f){var h=f.split("").map(function(m){return+m}).reduce(function(m,b,v){return v%2?m+b*9:m+b*3},0);return h%10},p=(function(u){s(f,u);function f(h,m){return l(this,f),c(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,h,m))}return t(f,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var m=e.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,r.default)(this.data,m,"01"),text:this.text}}}]),f})(i.default);return lo.default=p,lo}var co={},yd;function R0(){if(yd)return co;yd=1,Object.defineProperty(co,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})(),e=Kn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,h){return l(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h))}return t(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var h=e.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,r.default)(this.data,h,"01"),text:this.text}}}]),u})(i.default);return co.default=d,co}var Jn={},vd;function wd(){if(vd)return Jn;vd=1,Object.defineProperty(Jn,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})();Jn.checksum=d;var e=Zn(),n=i(e),r=qe(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=(function(p){c(u,p);function u(f,h){a(this,u),f.search(/^[0-9]{11}$/)!==-1&&(f+=d(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h));return m.displayValue=h.displayValue,h.fontSize>h.width*10?m.fontSize=h.width*10:m.fontSize=h.fontSize,m.guardHeight=h.height+m.fontSize/2+h.textMargin,m}return t(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var h="";return h+="101",h+=(0,n.default)(this.data.substr(0,6),"LLLLLL"),h+="01010",h+=(0,n.default)(this.data.substr(6,6),"RRRRRR"),h+="101",{data:h,text:this.text}}},{key:"guardedEncoding",value:function(){var h=[];return this.displayValue&&h.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),h.push({data:"101"+(0,n.default)(this.data[0],"L"),options:{height:this.guardHeight}}),h.push({data:(0,n.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),h.push({data:"01010",options:{height:this.guardHeight}}),h.push({data:(0,n.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),h.push({data:(0,n.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&h.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),h}}]),u})(o.default);function d(p){var u=0,f;for(f=1;f<11;f+=2)u+=parseInt(p[f]);for(f=0;f<11;f+=2)u+=parseInt(p[f])*3;return(10-u%10)%10}return Jn.default=s,Jn}var uo={},xd;function D0(){if(xd)return uo;xd=1,Object.defineProperty(uo,"__esModule",{value:!0});var t=(function(){function h(m,b){for(var v=0;v<b.length;v++){var w=b[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,w.key,w)}}return function(m,b,v){return b&&h(m.prototype,b),v&&h(m,v),m}})(),e=Zn(),n=a(e),r=qe(),o=a(r),i=wd();function a(h){return h&&h.__esModule?h:{default:h}}function l(h,m){if(!(h instanceof m))throw new TypeError("Cannot call a class as a function")}function c(h,m){if(!h)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:h}function s(h,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);h.prototype=Object.create(m&&m.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(h,m):h.__proto__=m)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],p=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],u=(function(h){s(m,h);function m(b,v){l(this,m);var w=c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,v));if(w.isValid=!1,b.search(/^[0-9]{6}$/)!==-1)w.middleDigits=b,w.upcA=f(b,"0"),w.text=v.text||""+w.upcA[0]+b+w.upcA[w.upcA.length-1],w.isValid=!0;else if(b.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=b.substring(1,b.length-1),w.upcA=f(w.middleDigits,b[0]),w.upcA[w.upcA.length-1]===b[b.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=v.displayValue,v.fontSize>v.width*10?w.fontSize=v.width*10:w.fontSize=v.fontSize,w.guardHeight=v.height+w.fontSize/2+v.textMargin,w}return t(m,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=this.encodeMiddleDigits(),v+="010101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101",options:{height:this.guardHeight}}),v.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),v.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),v}},{key:"encodeMiddleDigits",value:function(){var v=this.upcA[0],w=this.upcA[this.upcA.length-1],_=p[parseInt(w)][parseInt(v)];return(0,n.default)(this.middleDigits,_)}}]),m})(o.default);function f(h,m){for(var b=parseInt(h[h.length-1]),v=d[b],w="",_=0,T=0;T<v.length;T++){var z=v[T];z==="X"?w+=h[_++]:w+=z}return w=""+m+w,""+w+(0,i.checksum)(w)}return uo.default=u,uo}var Ed;function $0(){if(Ed)return Pe;Ed=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.UPCE=Pe.UPC=Pe.EAN2=Pe.EAN5=Pe.EAN8=Pe.EAN13=void 0;var t=O0(),e=u(t),n=I0(),r=u(n),o=P0(),i=u(o),a=R0(),l=u(a),c=wd(),s=u(c),d=D0(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return Pe.EAN13=e.default,Pe.EAN8=r.default,Pe.EAN5=i.default,Pe.EAN2=l.default,Pe.UPC=s.default,Pe.UPCE=p.default,Pe}var Bt={},po={},pn={},Sd;function N0(){return Sd||(Sd=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.START_BIN="1010",pn.END_BIN="11101",pn.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),pn}var _d;function Md(){if(_d)return po;_d=1,Object.defineProperty(po,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=N0(),n=qe(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return t(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var u=this,f=this.data.match(/.{2}/g).map(function(h){return u.encodePair(h)}).join("");return{data:e.START_BIN+f+e.END_BIN,text:this.text}}},{key:"encodePair",value:function(u){var f=e.BINARIES[u[1]];return e.BINARIES[u[0]].split("").map(function(h,m){return(h==="1"?"111":"1")+(f[m]==="1"?"000":"0")}).join("")}}]),d})(r.default);return po.default=c,po}var fo={},Td;function L0(){if(Td)return fo;Td=1,Object.defineProperty(fo,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Md(),n=r(e);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=function(d){var p=d.substr(0,13).split("").map(function(u){return parseInt(u,10)}).reduce(function(u,f,h){return u+f*(3-h%2*2)},0);return Math.ceil(p/10)*10-p},c=(function(s){a(d,s);function d(p,u){return o(this,d),p.search(/^[0-9]{13}$/)!==-1&&(p+=l(p)),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return t(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===l(this.data)}}]),d})(n.default);return fo.default=c,fo}var kd;function F0(){if(kd)return Bt;kd=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.ITF14=Bt.ITF=void 0;var t=Md(),e=o(t),n=L0(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Bt.ITF=e.default,Bt.ITF14=r.default,Bt}var We={},ho={},Cd;function Qn(){if(Cd)return ho;Cd=1,Object.defineProperty(ho,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=qe(),n=r(e);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=(function(s){a(d,s);function d(p,u){return o(this,d),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return t(d,[{key:"encode",value:function(){for(var u="110",f=0;f<this.data.length;f++){var h=parseInt(this.data[f]),m=h.toString(2);m=c(m,4-m.length);for(var b=0;b<m.length;b++)u+=m[b]=="0"?"100":"110"}return u+="1001",{data:u,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(n.default);function c(s,d){for(var p=0;p<d;p++)s="0"+s;return s}return ho.default=l,ho}var go={},er={},Ad;function mo(){if(Ad)return er;Ad=1,Object.defineProperty(er,"__esModule",{value:!0}),er.mod10=t,er.mod11=e;function t(n){for(var r=0,o=0;o<n.length;o++){var i=parseInt(n[o]);(o+n.length)%2===0?r+=i:r+=i*2%10+Math.floor(i*2/10)}return(10-r%10)%10}function e(n){for(var r=0,o=[2,3,4,5,6,7],i=0;i<n.length;i++){var a=parseInt(n[n.length-1-i]);r+=o[i%o.length]*a}return(11-r%11)%11}return er}var Od;function z0(){if(Od)return go;Od=1,Object.defineProperty(go,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod10)(d),p))}return s})(e.default);return go.default=l,go}var bo={},Id;function B0(){if(Id)return bo;Id=1,Object.defineProperty(bo,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod11)(d),p))}return s})(e.default);return bo.default=l,bo}var yo={},Pd;function H0(){if(Pd)return yo;Pd=1,Object.defineProperty(yo,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod10)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(e.default);return yo.default=l,yo}var vo={},Rd;function U0(){if(Rd)return vo;Rd=1,Object.defineProperty(vo,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod11)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(e.default);return vo.default=l,vo}var Dd;function q0(){if(Dd)return We;Dd=1,Object.defineProperty(We,"__esModule",{value:!0}),We.MSI1110=We.MSI1010=We.MSI11=We.MSI10=We.MSI=void 0;var t=Qn(),e=d(t),n=z0(),r=d(n),o=B0(),i=d(o),a=H0(),l=d(a),c=U0(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return We.MSI=e.default,We.MSI10=r.default,We.MSI11=i.default,We.MSI1010=l.default,We.MSI1110=s.default,We}var tr={},$d;function W0(){if($d)return tr;$d=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.pharmacode=void 0;var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=qe(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s);var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p));return u.number=parseInt(d,10),u}return t(s,[{key:"encode",value:function(){for(var p=this.number,u="";!isNaN(p)&&p!=0;)p%2===0?(u="11100"+u,p=(p-2)/2):(u="100"+u,p=(p-1)/2);return u=u.slice(0,-2),{data:u,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),s})(n.default);return tr.pharmacode=l,tr}var nr={},Nd;function j0(){if(Nd)return nr;Nd=1,Object.defineProperty(nr,"__esModule",{value:!0}),nr.codabar=void 0;var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=qe(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d.toUpperCase(),p));return u.text=u.options.text||u.text.replace(/[A-D]/g,""),u}return t(s,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var p=[],u=this.getEncodings(),f=0;f<this.data.length;f++)p.push(u[this.data.charAt(f)]),f!==this.data.length-1&&p.push("0");return{text:this.text,data:p.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),s})(n.default);return nr.codabar=l,nr}var Ht={},wo={},fn={},Ld;function G0(){return Ld||(Ld=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],fn.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],fn.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),fn}var Fd;function zd(){if(Fd)return wo;Fd=1,Object.defineProperty(wo,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=G0(),n=qe(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return t(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.data.split("").flatMap(function(b){return e.MULTI_SYMBOLS[b]||b}),f=u.map(function(b){return d.getEncoding(b)}).join(""),h=d.checksum(u,20),m=d.checksum(u.concat(h),15);return{text:this.text,data:d.getEncoding("ÿ")+f+d.getEncoding(h)+d.getEncoding(m)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(u){return e.BINARIES[d.symbolValue(u)]}},{key:"getSymbol",value:function(u){return e.SYMBOLS[u]}},{key:"symbolValue",value:function(u){return e.SYMBOLS.indexOf(u)}},{key:"checksum",value:function(u,f){var h=u.slice().reverse().reduce(function(m,b,v){var w=v%f+1;return m+d.symbolValue(b)*w},0);return d.getSymbol(h%47)}}]),d})(r.default);return wo.default=c,wo}var xo={},Bd;function Y0(){if(Bd)return xo;Bd=1,Object.defineProperty(xo,"__esModule",{value:!0});var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=zd(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return t(s,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),s})(n.default);return xo.default=l,xo}var Hd;function V0(){if(Hd)return Ht;Hd=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.CODE93FullASCII=Ht.CODE93=void 0;var t=zd(),e=o(t),n=Y0(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Ht.CODE93=e.default,Ht.CODE93FullASCII=r.default,Ht}var rr={},Ud;function X0(){if(Ud)return rr;Ud=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.GenericBarcode=void 0;var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=qe(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return t(s,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),s})(n.default);return rr.GenericBarcode=l,rr}var qd;function K0(){if(qd)return Xr;qd=1,Object.defineProperty(Xr,"__esModule",{value:!0});var t=S0(),e=A0(),n=$0(),r=F0(),o=q0(),i=W0(),a=j0(),l=V0(),c=X0();return Xr.default={CODE39:t.CODE39,CODE128:e.CODE128,CODE128A:e.CODE128A,CODE128B:e.CODE128B,CODE128C:e.CODE128C,EAN13:n.EAN13,EAN8:n.EAN8,EAN5:n.EAN5,EAN2:n.EAN2,UPC:n.UPC,UPCE:n.UPCE,ITF14:r.ITF14,ITF:r.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:i.pharmacode,codabar:a.codabar,CODE93:l.CODE93,CODE93FullASCII:l.CODE93FullASCII,GenericBarcode:c.GenericBarcode},Xr}var Eo={},Wd;function So(){if(Wd)return Eo;Wd=1,Object.defineProperty(Eo,"__esModule",{value:!0});var t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};return Eo.default=function(e,n){return t({},e,n)},Eo}var _o={},jd;function Z0(){if(jd)return _o;jd=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.default=t;function t(e){var n=[];function r(o){if(Array.isArray(o))for(var i=0;i<o.length;i++)r(o[i]);else o.text=o.text||"",o.data=o.data||"",n.push(o)}return r(e),n}return _o}var Mo={},Gd;function J0(){if(Gd)return Mo;Gd=1,Object.defineProperty(Mo,"__esModule",{value:!0}),Mo.default=t;function t(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}return Mo}var To={},ko={},Co={},Yd;function Vd(){if(Yd)return Co;Yd=1,Object.defineProperty(Co,"__esModule",{value:!0}),Co.default=t;function t(e){var n=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var r in n)n.hasOwnProperty(r)&&(r=n[r],typeof e[r]=="string"&&(e[r]=parseInt(e[r],10)));return typeof e.displayValue=="string"&&(e.displayValue=e.displayValue!="false"),e}return Co}var Ao={},Xd;function Kd(){if(Xd)return Ao;Xd=1,Object.defineProperty(Ao,"__esModule",{value:!0});var t={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Ao.default=t,Ao}var Zd;function Q0(){if(Zd)return ko;Zd=1,Object.defineProperty(ko,"__esModule",{value:!0});var t=Vd(),e=o(t),n=Kd(),r=o(n);function o(a){return a&&a.__esModule?a:{default:a}}function i(a){var l={};for(var c in r.default)r.default.hasOwnProperty(c)&&(a.hasAttribute("jsbarcode-"+c.toLowerCase())&&(l[c]=a.getAttribute("jsbarcode-"+c.toLowerCase())),a.hasAttribute("data-"+c.toLowerCase())&&(l[c]=a.getAttribute("data-"+c.toLowerCase())));return l.value=a.getAttribute("jsbarcode-value")||a.getAttribute("data-value"),l=(0,e.default)(l),l}return ko.default=i,ko}var Oo={},Io={},je={},Jd;function Qd(){if(Jd)return je;Jd=1,Object.defineProperty(je,"__esModule",{value:!0}),je.getTotalWidthOfEncodings=je.calculateEncodingAttributes=je.getBarcodePadding=je.getEncodingHeight=je.getMaximumHeightOfEncodings=void 0;var t=So(),e=n(t);function n(s){return s&&s.__esModule?s:{default:s}}function r(s,d){return d.height+(d.displayValue&&s.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(s,d,p){if(p.displayValue&&d<s){if(p.textAlign=="center")return Math.floor((s-d)/2);if(p.textAlign=="left")return 0;if(p.textAlign=="right")return Math.floor(s-d)}return 0}function i(s,d,p){for(var u=0;u<s.length;u++){var f=s[u],h=(0,e.default)(d,f.options),m;h.displayValue?m=c(f.text,h,p):m=0;var b=f.data.length*h.width;f.width=Math.ceil(Math.max(m,b)),f.height=r(f,h),f.barcodePadding=o(m,b,h)}}function a(s){for(var d=0,p=0;p<s.length;p++)d+=s[p].width;return d}function l(s){for(var d=0,p=0;p<s.length;p++)s[p].height>d&&(d=s[p].height);return d}function c(s,d,p){var u;if(p)u=p;else if(typeof document<"u")u=document.createElement("canvas").getContext("2d");else return 0;u.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var f=u.measureText(s);if(!f)return 0;var h=f.width;return h}return je.getMaximumHeightOfEncodings=l,je.getEncodingHeight=r,je.getBarcodePadding=o,je.calculateEncodingAttributes=i,je.getTotalWidthOfEncodings=a,je}var eu;function eb(){if(eu)return Io;eu=1,Object.defineProperty(Io,"__esModule",{value:!0});var t=(function(){function l(c,s){for(var d=0;d<s.length;d++){var p=s[d];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(c,p.key,p)}}return function(c,s,d){return s&&l(c.prototype,s),d&&l(c,d),c}})(),e=So(),n=o(e),r=Qd();function o(l){return l&&l.__esModule?l:{default:l}}function i(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}var a=(function(){function l(c,s,d){i(this,l),this.canvas=c,this.encodings=s,this.options=d}return t(l,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var s=0;s<this.encodings.length;s++){var d=(0,n.default)(this.options,this.encodings[s].options);this.drawCanvasBarcode(d,this.encodings[s]),this.drawCanvasText(d,this.encodings[s]),this.moveCanvasDrawing(this.encodings[s])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var s=this.canvas.getContext("2d");s.save(),(0,r.calculateEncodingAttributes)(this.encodings,this.options,s);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=p,s.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(s.fillStyle=this.options.background,s.fillRect(0,0,this.canvas.width,this.canvas.height)),s.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(s,d){var p=this.canvas.getContext("2d"),u=d.data,f;s.textPosition=="top"?f=s.marginTop+s.fontSize+s.textMargin:f=s.marginTop,p.fillStyle=s.lineColor;for(var h=0;h<u.length;h++){var m=h*s.width+d.barcodePadding;u[h]==="1"?p.fillRect(m,f,s.width,s.height):u[h]&&p.fillRect(m,f,s.width,s.height*u[h])}}},{key:"drawCanvasText",value:function(s,d){var p=this.canvas.getContext("2d"),u=s.fontOptions+" "+s.fontSize+"px "+s.font;if(s.displayValue){var f,h;s.textPosition=="top"?h=s.marginTop+s.fontSize-s.textMargin:h=s.height+s.textMargin+s.marginTop+s.fontSize,p.font=u,s.textAlign=="left"||d.barcodePadding>0?(f=0,p.textAlign="left"):s.textAlign=="right"?(f=d.width-1,p.textAlign="right"):(f=d.width/2,p.textAlign="center"),p.fillText(d.text,f,h)}}},{key:"moveCanvasDrawing",value:function(s){var d=this.canvas.getContext("2d");d.translate(s.width,0)}},{key:"restoreCanvas",value:function(){var s=this.canvas.getContext("2d");s.restore()}}]),l})();return Io.default=a,Io}var Po={},tu;function tb(){if(tu)return Po;tu=1,Object.defineProperty(Po,"__esModule",{value:!0});var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=So(),n=o(e),r=Qd();function o(c){return c&&c.__esModule?c:{default:c}}function i(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}var a="http://www.w3.org/2000/svg",l=(function(){function c(s,d,p){i(this,c),this.svg=s,this.encodings=d,this.options=p,this.document=p.xmlDocument||document}return t(c,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var p=0;p<this.encodings.length;p++){var u=this.encodings[p],f=(0,n.default)(this.options,u.options),h=this.createGroup(d,f.marginTop,this.svg);this.setGroupOptions(h,f),this.drawSvgBarcode(h,f,u),this.drawSVGText(h,f,u),d+=u.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,r.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings),u=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(u,p),this.options.background&&this.drawRect(0,0,u,p,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,p,u){var f=u.data,h;p.textPosition=="top"?h=p.fontSize+p.textMargin:h=0;for(var m=0,b=0,v=0;v<f.length;v++)b=v*p.width+u.barcodePadding,f[v]==="1"?m++:m>0&&(this.drawRect(b-p.width*m,h,p.width*m,p.height,d),m=0);m>0&&this.drawRect(b-p.width*(m-1),h,p.width*m,p.height,d)}},{key:"drawSVGText",value:function(d,p,u){var f=this.document.createElementNS(a,"text");if(p.displayValue){var h,m;f.setAttribute("font-family",p.font),f.setAttribute("font-size",p.fontSize),p.fontOptions.includes("bold")&&f.setAttribute("font-weight","bold"),p.fontOptions.includes("italic")&&f.setAttribute("font-style","italic"),p.textPosition=="top"?m=p.fontSize-p.textMargin:m=p.height+p.textMargin+p.fontSize,p.textAlign=="left"||u.barcodePadding>0?(h=0,f.setAttribute("text-anchor","start")):p.textAlign=="right"?(h=u.width-1,f.setAttribute("text-anchor","end")):(h=u.width/2,f.setAttribute("text-anchor","middle")),f.setAttribute("x",h),f.setAttribute("y",m),f.appendChild(this.document.createTextNode(u.text)),d.appendChild(f)}}},{key:"setSvgAttributes",value:function(d,p){var u=this.svg;u.setAttribute("width",d+"px"),u.setAttribute("height",p+"px"),u.setAttribute("x","0px"),u.setAttribute("y","0px"),u.setAttribute("viewBox","0 0 "+d+" "+p),u.setAttribute("xmlns",a),u.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,p,u){var f=this.document.createElementNS(a,"g");return f.setAttribute("transform","translate("+d+", "+p+")"),u.appendChild(f),f}},{key:"setGroupOptions",value:function(d,p){d.setAttribute("fill",p.lineColor)}},{key:"drawRect",value:function(d,p,u,f,h){var m=this.document.createElementNS(a,"rect");return m.setAttribute("x",d),m.setAttribute("y",p),m.setAttribute("width",u),m.setAttribute("height",f),h.appendChild(m),m}}]),c})();return Po.default=l,Po}var Ro={},nu;function nb(){if(nu)return Ro;nu=1,Object.defineProperty(Ro,"__esModule",{value:!0});var t=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function e(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o,i,a){e(this,r),this.object=o,this.encodings=i,this.options=a}return t(r,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),r})();return Ro.default=n,Ro}var ru;function rb(){if(ru)return Oo;ru=1,Object.defineProperty(Oo,"__esModule",{value:!0});var t=eb(),e=a(t),n=tb(),r=a(n),o=nb(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Oo.default={CanvasRenderer:e.default,SVGRenderer:r.default,ObjectRenderer:i.default},Oo}var hn={},ou;function iu(){if(ou)return hn;ou=1,Object.defineProperty(hn,"__esModule",{value:!0});function t(a,l){if(!(a instanceof l))throw new TypeError("Cannot call a class as a function")}function e(a,l){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l&&(typeof l=="object"||typeof l=="function")?l:a}function n(a,l){if(typeof l!="function"&&l!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof l);a.prototype=Object.create(l&&l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),l&&(Object.setPrototypeOf?Object.setPrototypeOf(a,l):a.__proto__=l)}var r=(function(a){n(l,a);function l(c,s){t(this,l);var d=e(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return d.name="InvalidInputException",d.symbology=c,d.input=s,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return l})(Error),o=(function(a){n(l,a);function l(){t(this,l);var c=e(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="InvalidElementException",c.message="Not supported type to render on",c}return l})(Error),i=(function(a){n(l,a);function l(){t(this,l);var c=e(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="NoElementException",c.message="No element to render on.",c}return l})(Error);return hn.InvalidInputException=r,hn.InvalidElementException=o,hn.NoElementException=i,hn}var au;function ob(){if(au)return To;au=1,Object.defineProperty(To,"__esModule",{value:!0});var t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e=Q0(),n=a(e),r=rb(),o=a(r),i=iu();function a(d){return d&&d.__esModule?d:{default:d}}function l(d){if(typeof d=="string")return c(d);if(Array.isArray(d)){for(var p=[],u=0;u<d.length;u++)p.push(l(d[u]));return p}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return s(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,n.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,n.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":t(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new i.InvalidElementException}}function c(d){var p=document.querySelectorAll(d);if(p.length!==0){for(var u=[],f=0;f<p.length;f++)u.push(l(p[f]));return u}}function s(d){var p=document.createElement("canvas");return{element:p,options:(0,n.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",p.toDataURL())}}}return To.default=l,To}var Do={},su;function ib(){if(su)return Do;su=1,Object.defineProperty(Do,"__esModule",{value:!0});var t=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function e(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o){e(this,r),this.api=o}return t(r,[{key:"handleCatch",value:function(i){if(i.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw i.message;else throw i;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(i){try{var a=i.apply(void 0,arguments);return this.api._options.valid(!0),a}catch(l){return this.handleCatch(l),this.api}}}]),r})();return Do.default=n,Do}var fa,lu;function ab(){if(lu)return fa;lu=1;var t=K0(),e=v(t),n=So(),r=v(n),o=Z0(),i=v(o),a=J0(),l=v(a),c=ob(),s=v(c),d=Vd(),p=v(d),u=ib(),f=v(u),h=iu(),m=Kd(),b=v(m);function v(S){return S&&S.__esModule?S:{default:S}}var w=function(){},_=function(C,O,R){var I=new w;if(typeof C>"u")throw Error("No element to render on was provided.");return I._renderProperties=(0,s.default)(C),I._encodings=[],I._options=b.default,I._errorHandler=new f.default(I),typeof O<"u"&&(R=R||{},R.format||(R.format=P()),I.options(R)[R.format](O,R).render()),I};_.getModule=function(S){return e.default[S]};for(var T in e.default)e.default.hasOwnProperty(T)&&z(e.default,T);function z(S,C){w.prototype[C]=w.prototype[C.toUpperCase()]=w.prototype[C.toLowerCase()]=function(O,R){var I=this;return I._errorHandler.wrapBarcodeCall(function(){R.text=typeof R.text>"u"?void 0:""+R.text;var x=(0,r.default)(I._options,R);x=(0,p.default)(x);var j=S[C],te=N(O,j,x);return I._encodings.push(te),I})}}function N(S,C,O){S=""+S;var R=new C(S,O);if(!R.valid())throw new h.InvalidInputException(R.constructor.name,S);var I=R.encode();I=(0,i.default)(I);for(var x=0;x<I.length;x++)I[x].options=(0,r.default)(O,I[x].options);return I}function P(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}w.prototype.options=function(S){return this._options=(0,r.default)(this._options,S),this},w.prototype.blank=function(S){var C=new Array(S+1).join("0");return this._encodings.push({data:C}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var S;for(var C in this._renderProperties){S=this._renderProperties[C];var O=(0,r.default)(this._options,S.options);O.format=="auto"&&(O.format=P()),this._errorHandler.wrapBarcodeCall(function(){var R=O.value,I=e.default[O.format.toUpperCase()],x=N(R,I,O);k(S,x,O)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new h.NoElementException;if(Array.isArray(this._renderProperties))for(var S=0;S<this._renderProperties.length;S++)k(this._renderProperties[S],this._encodings,this._options);else k(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=b.default;function k(S,C,O){C=(0,i.default)(C);for(var R=0;R<C.length;R++)C[R].options=(0,r.default)(O,C[R].options),(0,l.default)(C[R].options);(0,l.default)(O);var I=S.renderer,x=new I(S.element,C,O);x.render(),S.afterRender&&S.afterRender()}return typeof window<"u"&&(window.JsBarcode=_),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(S,C){var O=[];return jQuery(this).each(function(){O.push(this)}),_(O,S,C)}),fa=_,fa}var sb=ab();const ha=ed(sb);var gn={},ga,cu;function lb(){return cu||(cu=1,ga=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ga}var ma={},Mt={},du;function Ut(){if(du)return Mt;du=1;let t;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Mt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Mt.getSymbolTotalCodewords=function(r){return e[r]},Mt.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},Mt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Mt.isKanjiModeEnabled=function(){return typeof t<"u"},Mt.toSJIS=function(r){return t(r)},Mt}var ba={},uu;function ya(){return uu||(uu=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,o){if(t.isValid(r))return r;try{return e(r)}catch{return o}}})(ba)),ba}var va,pu;function cb(){if(pu)return va;pu=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(e){const n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)===1},put:function(e,n){for(let r=0;r<n;r++)this.putBit((e>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}},va=t,va}var wa,fu;function db(){if(fu)return wa;fu=1;function t(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return t.prototype.set=function(e,n,r,o){const i=e*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,r){this.data[e*this.size+n]^=r},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},wa=t,wa}var xa={},hu;function ub(){return hu||(hu=1,(function(t){const e=Ut().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=e(r),a=i===145?26:Math.ceil((i-13)/(2*o-2))*2,l=[i-7];for(let c=1;c<o-1;c++)l[c]=l[c-1]-a;return l.push(6),l.reverse()},t.getPositions=function(r){const o=[],i=t.getRowColCoords(r),a=i.length;for(let l=0;l<a;l++)for(let c=0;c<a;c++)l===0&&c===0||l===0&&c===a-1||l===a-1&&c===0||o.push([i[l],i[c]]);return o}})(xa)),xa}var Ea={},gu;function pb(){if(gu)return Ea;gu=1;const t=Ut().getSymbolSize,e=7;return Ea.getPositions=function(r){const o=t(r);return[[0,0],[o-e,0],[0,o-e]]},Ea}var Sa={},mu;function fb(){return mu||(mu=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},t.from=function(o){return t.isValid(o)?parseInt(o,10):void 0},t.getPenaltyN1=function(o){const i=o.size;let a=0,l=0,c=0,s=null,d=null;for(let p=0;p<i;p++){l=c=0,s=d=null;for(let u=0;u<i;u++){let f=o.get(p,u);f===s?l++:(l>=5&&(a+=e.N1+(l-5)),s=f,l=1),f=o.get(u,p),f===d?c++:(c>=5&&(a+=e.N1+(c-5)),d=f,c=1)}l>=5&&(a+=e.N1+(l-5)),c>=5&&(a+=e.N1+(c-5))}return a},t.getPenaltyN2=function(o){const i=o.size;let a=0;for(let l=0;l<i-1;l++)for(let c=0;c<i-1;c++){const s=o.get(l,c)+o.get(l,c+1)+o.get(l+1,c)+o.get(l+1,c+1);(s===4||s===0)&&a++}return a*e.N2},t.getPenaltyN3=function(o){const i=o.size;let a=0,l=0,c=0;for(let s=0;s<i;s++){l=c=0;for(let d=0;d<i;d++)l=l<<1&2047|o.get(s,d),d>=10&&(l===1488||l===93)&&a++,c=c<<1&2047|o.get(d,s),d>=10&&(c===1488||c===93)&&a++}return a*e.N3},t.getPenaltyN4=function(o){let i=0;const a=o.data.length;for(let c=0;c<a;c++)i+=o.data[c];return Math.abs(Math.ceil(i*100/a/5)-10)*e.N4};function n(r,o,i){switch(r){case t.Patterns.PATTERN000:return(o+i)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(o+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return o*i%2+o*i%3===0;case t.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case t.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(o,i){const a=i.size;for(let l=0;l<a;l++)for(let c=0;c<a;c++)i.isReserved(c,l)||i.xor(c,l,n(o,c,l))},t.getBestMask=function(o,i){const a=Object.keys(t.Patterns).length;let l=0,c=1/0;for(let s=0;s<a;s++){i(s),t.applyMask(s,o);const d=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(s,o),d<c&&(c=d,l=s)}return l}})(Sa)),Sa}var $o={},bu;function yu(){if(bu)return $o;bu=1;const t=ya(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $o.getBlocksCount=function(o,i){switch(i){case t.L:return e[(o-1)*4+0];case t.M:return e[(o-1)*4+1];case t.Q:return e[(o-1)*4+2];case t.H:return e[(o-1)*4+3];default:return}},$o.getTotalCodewordsCount=function(o,i){switch(i){case t.L:return n[(o-1)*4+0];case t.M:return n[(o-1)*4+1];case t.Q:return n[(o-1)*4+2];case t.H:return n[(o-1)*4+3];default:return}},$o}var _a={},or={},vu;function hb(){if(vu)return or;vu=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)t[o]=r,e[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)t[o]=t[o-255]})(),or.log=function(r){if(r<1)throw new Error("log("+r+")");return e[r]},or.exp=function(r){return t[r]},or.mul=function(r,o){return r===0||o===0?0:t[e[r]+e[o]]},or}var wu;function gb(){return wu||(wu=1,(function(t){const e=hb();t.mul=function(r,o){const i=new Uint8Array(r.length+o.length-1);for(let a=0;a<r.length;a++)for(let l=0;l<o.length;l++)i[a+l]^=e.mul(r[a],o[l]);return i},t.mod=function(r,o){let i=new Uint8Array(r);for(;i.length-o.length>=0;){const a=i[0];for(let c=0;c<o.length;c++)i[c]^=e.mul(o[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},t.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=t.mul(o,new Uint8Array([1,e.exp(i)]));return o}})(_a)),_a}var Ma,xu;function mb(){if(xu)return Ma;xu=1;const t=gb();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(r.length+this.degree);o.set(r);const i=t.mod(o,this.genPoly),a=this.degree-i.length;if(a>0){const l=new Uint8Array(this.degree);return l.set(i,a),l}return i},Ma=e,Ma}var Ta={},ka={},Ca={},Eu;function Su(){return Eu||(Eu=1,Ca.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Ca}var at={},_u;function Mu(){if(_u)return at;_u=1;const t="[0-9]+",e="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
252
- ]))+`;at.KANJI=new RegExp(n,"g"),at.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),at.BYTE=new RegExp(r,"g"),at.NUMERIC=new RegExp(t,"g"),at.ALPHANUMERIC=new RegExp(e,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return at.testKanji=function(c){return o.test(c)},at.testNumeric=function(c){return i.test(c)},at.testAlphanumeric=function(c){return a.test(c)},at}var Tu;function qt(){return Tu||(Tu=1,(function(t){const e=Su(),n=Mu();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!e.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return n.testNumeric(i)?t.NUMERIC:n.testAlphanumeric(i)?t.ALPHANUMERIC:n.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+o)}}t.from=function(i,a){if(t.isValid(i))return i;try{return r(i)}catch{return a}}})(ka)),ka}var ku;function bb(){return ku||(ku=1,(function(t){const e=Ut(),n=yu(),r=ya(),o=qt(),i=Su(),a=7973,l=e.getBCHDigit(a);function c(u,f,h){for(let m=1;m<=40;m++)if(f<=t.getCapacity(m,h,u))return m}function s(u,f){return o.getCharCountIndicator(u,f)+4}function d(u,f){let h=0;return u.forEach(function(m){const b=s(m.mode,f);h+=b+m.getBitsLength()}),h}function p(u,f){for(let h=1;h<=40;h++)if(d(u,h)<=t.getCapacity(h,f,o.MIXED))return h}t.from=function(f,h){return i.isValid(f)?parseInt(f,10):h},t.getCapacity=function(f,h,m){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=o.BYTE);const b=e.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,h),w=(b-v)*8;if(m===o.MIXED)return w;const _=w-s(m,f);switch(m){case o.NUMERIC:return Math.floor(_/10*3);case o.ALPHANUMERIC:return Math.floor(_/11*2);case o.KANJI:return Math.floor(_/13);case o.BYTE:default:return Math.floor(_/8)}},t.getBestVersionForData=function(f,h){let m;const b=r.from(h,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,b);if(f.length===0)return 1;m=f[0]}else m=f;return c(m.mode,m.getLength(),b)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let h=f<<12;for(;e.getBCHDigit(h)-l>=0;)h^=a<<e.getBCHDigit(h)-l;return f<<12|h}})(Ta)),Ta}var Aa={},Cu;function yb(){if(Cu)return Aa;Cu=1;const t=Ut(),e=1335,n=21522,r=t.getBCHDigit(e);return Aa.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;t.getBCHDigit(c)-r>=0;)c^=e<<t.getBCHDigit(c)-r;return(l<<10|c)^n},Aa}var Oa={},Ia,Au;function vb(){if(Au)return Ia;Au=1;const t=qt();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(r){let o,i,a;for(o=0;o+3<=this.data.length;o+=3)i=this.data.substr(o,3),a=parseInt(i,10),r.put(a,10);const l=this.data.length-o;l>0&&(i=this.data.substr(o),a=parseInt(i,10),r.put(a,l*3+1))},Ia=e,Ia}var Pa,Ou;function wb(){if(Ou)return Pa;Ou=1;const t=qt(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=t.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let i;for(i=0;i+2<=this.data.length;i+=2){let a=e.indexOf(this.data[i])*45;a+=e.indexOf(this.data[i+1]),o.put(a,11)}this.data.length%2&&o.put(e.indexOf(this.data[i]),6)},Pa=n,Pa}var Ra,Iu;function xb(){if(Iu)return Ra;Iu=1;const t=qt();function e(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return e.getBitsLength=function(r){return r*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},Ra=e,Ra}var Da,Pu;function Eb(){if(Pu)return Da;Pu=1;const t=qt(),e=Ut();function n(r){this.mode=t.KANJI,this.data=r}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let o;for(o=0;o<this.data.length;o++){let i=e.toSJIS(this.data[o]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
253
- Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Da=n,Da}var $a={exports:{}},Ru;function Sb(){return Ru||(Ru=1,(function(t){var e={single_source_shortest_paths:function(n,r,o){var i={},a={};a[r]=0;var l=e.PriorityQueue.make();l.push(r,0);for(var c,s,d,p,u,f,h,m,b;!l.empty();){c=l.pop(),s=c.value,p=c.cost,u=n[s]||{};for(d in u)u.hasOwnProperty(d)&&(f=u[d],h=p+f,m=a[d],b=typeof a[d]>"u",(b||m>h)&&(a[d]=h,l.push(d,h),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var v=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=e.single_source_shortest_paths(n,r,o);return e.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=e.PriorityQueue,o={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(o[i]=r[i]);return o.queue=[],o.sorter=n.sorter||r.default_sorter,o},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var o={value:n,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})($a)),$a.exports}var Du;function _b(){return Du||(Du=1,(function(t){const e=qt(),n=vb(),r=wb(),o=xb(),i=Eb(),a=Mu(),l=Ut(),c=Sb();function s(v){return unescape(encodeURIComponent(v)).length}function d(v,w,_){const T=[];let z;for(;(z=v.exec(_))!==null;)T.push({data:z[0],index:z.index,mode:w,length:z[0].length});return T}function p(v){const w=d(a.NUMERIC,e.NUMERIC,v),_=d(a.ALPHANUMERIC,e.ALPHANUMERIC,v);let T,z;return l.isKanjiModeEnabled()?(T=d(a.BYTE,e.BYTE,v),z=d(a.KANJI,e.KANJI,v)):(T=d(a.BYTE_KANJI,e.BYTE,v),z=[]),w.concat(_,T,z).sort(function(P,k){return P.index-k.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.length}})}function u(v,w){switch(w){case e.NUMERIC:return n.getBitsLength(v);case e.ALPHANUMERIC:return r.getBitsLength(v);case e.KANJI:return i.getBitsLength(v);case e.BYTE:return o.getBitsLength(v)}}function f(v){return v.reduce(function(w,_){const T=w.length-1>=0?w[w.length-1]:null;return T&&T.mode===_.mode?(w[w.length-1].data+=_.data,w):(w.push(_),w)},[])}function h(v){const w=[];for(let _=0;_<v.length;_++){const T=v[_];switch(T.mode){case e.NUMERIC:w.push([T,{data:T.data,mode:e.ALPHANUMERIC,length:T.length},{data:T.data,mode:e.BYTE,length:T.length}]);break;case e.ALPHANUMERIC:w.push([T,{data:T.data,mode:e.BYTE,length:T.length}]);break;case e.KANJI:w.push([T,{data:T.data,mode:e.BYTE,length:s(T.data)}]);break;case e.BYTE:w.push([{data:T.data,mode:e.BYTE,length:s(T.data)}])}}return w}function m(v,w){const _={},T={start:{}};let z=["start"];for(let N=0;N<v.length;N++){const P=v[N],k=[];for(let S=0;S<P.length;S++){const C=P[S],O=""+N+S;k.push(O),_[O]={node:C,lastCount:0},T[O]={};for(let R=0;R<z.length;R++){const I=z[R];_[I]&&_[I].node.mode===C.mode?(T[I][O]=u(_[I].lastCount+C.length,C.mode)-u(_[I].lastCount,C.mode),_[I].lastCount+=C.length):(_[I]&&(_[I].lastCount=C.length),T[I][O]=u(C.length,C.mode)+4+e.getCharCountIndicator(C.mode,w))}}z=k}for(let N=0;N<z.length;N++)T[z[N]].end=0;return{map:T,table:_}}function b(v,w){let _;const T=e.getBestModeForData(v);if(_=e.from(w,T),_!==e.BYTE&&_.bit<T.bit)throw new Error('"'+v+'" cannot be encoded with mode '+e.toString(_)+`.
254
- Suggested mode is: `+e.toString(T));switch(_===e.KANJI&&!l.isKanjiModeEnabled()&&(_=e.BYTE),_){case e.NUMERIC:return new n(v);case e.ALPHANUMERIC:return new r(v);case e.KANJI:return new i(v);case e.BYTE:return new o(v)}}t.fromArray=function(w){return w.reduce(function(_,T){return typeof T=="string"?_.push(b(T,null)):T.data&&_.push(b(T.data,T.mode)),_},[])},t.fromString=function(w,_){const T=p(w,l.isKanjiModeEnabled()),z=h(T),N=m(z,_),P=c.find_path(N.map,"start","end"),k=[];for(let S=1;S<P.length-1;S++)k.push(N.table[P[S]].node);return t.fromArray(f(k))},t.rawSplit=function(w){return t.fromArray(p(w,l.isKanjiModeEnabled()))}})(Oa)),Oa}var $u;function Mb(){if($u)return ma;$u=1;const t=Ut(),e=ya(),n=cb(),r=db(),o=ub(),i=pb(),a=fb(),l=yu(),c=mb(),s=bb(),d=yb(),p=qt(),u=_b();function f(N,P){const k=N.size,S=i.getPositions(P);for(let C=0;C<S.length;C++){const O=S[C][0],R=S[C][1];for(let I=-1;I<=7;I++)if(!(O+I<=-1||k<=O+I))for(let x=-1;x<=7;x++)R+x<=-1||k<=R+x||(I>=0&&I<=6&&(x===0||x===6)||x>=0&&x<=6&&(I===0||I===6)||I>=2&&I<=4&&x>=2&&x<=4?N.set(O+I,R+x,!0,!0):N.set(O+I,R+x,!1,!0))}}function h(N){const P=N.size;for(let k=8;k<P-8;k++){const S=k%2===0;N.set(k,6,S,!0),N.set(6,k,S,!0)}}function m(N,P){const k=o.getPositions(P);for(let S=0;S<k.length;S++){const C=k[S][0],O=k[S][1];for(let R=-2;R<=2;R++)for(let I=-2;I<=2;I++)R===-2||R===2||I===-2||I===2||R===0&&I===0?N.set(C+R,O+I,!0,!0):N.set(C+R,O+I,!1,!0)}}function b(N,P){const k=N.size,S=s.getEncodedBits(P);let C,O,R;for(let I=0;I<18;I++)C=Math.floor(I/3),O=I%3+k-8-3,R=(S>>I&1)===1,N.set(C,O,R,!0),N.set(O,C,R,!0)}function v(N,P,k){const S=N.size,C=d.getEncodedBits(P,k);let O,R;for(O=0;O<15;O++)R=(C>>O&1)===1,O<6?N.set(O,8,R,!0):O<8?N.set(O+1,8,R,!0):N.set(S-15+O,8,R,!0),O<8?N.set(8,S-O-1,R,!0):O<9?N.set(8,15-O-1+1,R,!0):N.set(8,15-O-1,R,!0);N.set(S-8,8,1,!0)}function w(N,P){const k=N.size;let S=-1,C=k-1,O=7,R=0;for(let I=k-1;I>0;I-=2)for(I===6&&I--;;){for(let x=0;x<2;x++)if(!N.isReserved(C,I-x)){let j=!1;R<P.length&&(j=(P[R]>>>O&1)===1),N.set(C,I-x,j),O--,O===-1&&(R++,O=7)}if(C+=S,C<0||k<=C){C-=S,S=-S;break}}}function _(N,P,k){const S=new n;k.forEach(function(x){S.put(x.mode.bit,4),S.put(x.getLength(),p.getCharCountIndicator(x.mode,N)),x.write(S)});const C=t.getSymbolTotalCodewords(N),O=l.getTotalCodewordsCount(N,P),R=(C-O)*8;for(S.getLengthInBits()+4<=R&&S.put(0,4);S.getLengthInBits()%8!==0;)S.putBit(0);const I=(R-S.getLengthInBits())/8;for(let x=0;x<I;x++)S.put(x%2?17:236,8);return T(S,N,P)}function T(N,P,k){const S=t.getSymbolTotalCodewords(P),C=l.getTotalCodewordsCount(P,k),O=S-C,R=l.getBlocksCount(P,k),I=S%R,x=R-I,j=Math.floor(S/R),te=Math.floor(O/R),fe=te+1,G=j-te,de=new c(G);let Ke=0;const ye=new Array(R),Fe=new Array(R);let D=0;const L=new Uint8Array(N.buffer);for(let ne=0;ne<R;ne++){const Q=ne<x?te:fe;ye[ne]=L.slice(Ke,Ke+Q),Fe[ne]=de.encode(ye[ne]),Ke+=Q,D=Math.max(D,Q)}const W=new Uint8Array(S);let V=0,Y,X;for(Y=0;Y<D;Y++)for(X=0;X<R;X++)Y<ye[X].length&&(W[V++]=ye[X][Y]);for(Y=0;Y<G;Y++)for(X=0;X<R;X++)W[V++]=Fe[X][Y];return W}function z(N,P,k,S){let C;if(Array.isArray(N))C=u.fromArray(N);else if(typeof N=="string"){let j=P;if(!j){const te=u.rawSplit(N);j=s.getBestVersionForData(te,k)}C=u.fromString(N,j||40)}else throw new Error("Invalid data");const O=s.getBestVersionForData(C,k);if(!O)throw new Error("The amount of data is too big to be stored in a QR Code");if(!P)P=O;else if(P<O)throw new Error(`
251
+ `),o=t.reduce((l,c)=>l+c.layoutsPerPage.reduce((s,d)=>s+d.length,0),0),i=[];let a=0;for(const l of t)for(const c of l.layoutsPerPage)for(const s of c)i.push({...s,pageIndex:a++});return{html:zr(n,r),pageCount:o,pageLayouts:i}}async function Xm(t,e){return e.withSession(t,n=>Km(t,n))}async function Km(t,e){const n=ua(t.templateJson);if(n.length>1){const c=$c(t.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await Jm(t,e,s[u]))}catch(f){const h=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${h}`)}const p=Vm(d);return{html:p.html,pageCount:p.pageCount,paperMm:nn(n[0]),continuous:!1,heightSource:"config",pageLayouts:p.pageLayouts,copies:d.length}}const r=n[0]!==t.templateJson?{...t,templateJson:n[0]}:t,o=n[0],i=$c(r.printData);if(i.mode==="single"){const c=await Hc(r,e,i.data);return o.tiling?.enabled===!0?Bc(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):Zm(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await Hc(r,e,i.dataList[c]);a.push({bound:s.bound,pageLayouts:s.pageLayouts,data:i.dataList[c],codeRenderer:s.codeRenderer,derivedHeightMm:s.derivedHeightMm,paperMm:s.paperMm,heightSource:s.heightSource})}catch(s){const d=s instanceof Error?s.message:String(s);throw new Error(`第 ${c+1} 份渲染失败:${d}`)}if(o.tiling?.enabled===!0)return Bc(r,a);const l=Bm(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:tt(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function Zm(t){return{html:t.html,pageCount:t.pageCount,paperMm:t.paperMm,continuous:t.continuous,heightSource:t.heightSource,pageLayouts:t.pageLayouts,copies:1}}function Bc(t,e){const n=e[0].bound,r=Fc(n,{paperOverride:t.paperOverride});e.forEach((i,a)=>{const l=i.pageLayouts[0]?.overflow===!0;if(i.pageLayouts.length!==1||l){const c=l?"内容超出纸张高度":`渲染出 ${i.pageLayouts.length} 页`;throw new Error(`拼版要求每份标签恰好 1 页,第 ${a+1} 份${c};请缩小内容或调整标签纸张高度`)}});const o=jm({copies:e.map(i=>({bound:i.bound,pageLayouts:i.pageLayouts,data:i.data,codeRenderer:i.codeRenderer})),layout:r});return{html:o.html,pageCount:o.sheetCount,paperMm:{width:r.sheet.width,height:r.sheet.height},continuous:!1,heightSource:"config",pageLayouts:e.flatMap(i=>i.pageLayouts),copies:e.length}}async function Hc(t,e,n){const r=ic(t.templateJson,n,t.baseUrl,t.fontBaseUrl),o=tt(r),i=Ze(r),a=Oc(i),l=Am({paperHeightMm:t.paperHeightMm,override:t.paperOverride}),c=await jr({bound:r,job:t,session:e,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await e.measure(c.html,a);Pc(r,s.fits);const d=yi(r,Ic(s.measurements,r)),p=await jr({bound:r,job:t,session:e,data:n,pageLayouts:d,isMeasurementPass:!1,baseMap:c.map});let u=p.html,f;if(o){if(l&&l>0)f=l;else{const w=await e.probeContentBottom(u,a);f=km(r,sa(w))}u=Lr(r,d,n,{codeRenderer:p.codeRenderer,pageHeightMm:f})}const h=o&&l?{...t.paperOverride,height:l}:t.paperOverride,m=nn(r),{paperMm:b,heightSource:v}=Om({paperMm:{width:m.width,height:f??m.height},continuous:o,override:h});return{html:u,pageCount:d.length,paperMm:b,continuous:o,heightSource:v,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,derivedHeightMm:f}}async function Jm(t,e,n){const r=ua(t.templateJson),o=Oc(Ze(r[0])),i=[],a=[],l=[];for(const c of r){const s=ic(c,n,t.baseUrl,t.fontBaseUrl),d=await jr({bound:s,job:t,session:e,data:n,pageLayouts:[],isMeasurementPass:!0}),p=await e.measure(d.html,o);Pc(s,p.fits);const u=yi(s,Ic(p.measurements,s)),f=await jr({bound:s,job:t,session:e,data:n,pageLayouts:u,isMeasurementPass:!1,baseMap:d.map});i.push(s),a.push(u),l.push(f.codeRenderer)}return{boundPages:i,layoutsPerPage:a,data:n,codeRenderers:l}}async function jr(t){const e=t.baseMap??new Map;if(t.job.codeRenderer)return{html:Lr(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:t.job.codeRenderer}),codeRenderer:t.job.codeRenderer,map:e};const n=Rm(e),r=Lr(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:n.renderer}),o=n.takeSpecs(),i=o.length>0?await t.session.renderCodes(o):new Map,a=Dm(e,i),l=a.size>0?Pm(a):void 0;return o.length===0?{html:r,codeRenderer:l,map:a}:{html:Lr(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:l}),codeRenderer:l,map:a}}class Qm{constructor(e){this.functions={},e?.functions&&(this.functions={...e.functions})}registerFunction(e,n){this.functions[e]=n}evaluate(e,n){const r=Ni(e),o=Li(r);return Ie(o,n,this.functions)}render(e,n){return Wl(e,this.functions)(n)}}const Uc=new Qm,e0={MONEY:jl,CONCAT:(...t)=>t.filter(e=>e!=null).join(""),IF:Vl,FORMAT:t=>typeof t!="number"?String(t):t.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(t,e,n)=>String(t).slice(e,n?e+n:void 0),LEN:t=>String(t).length,ADD:Ql,SUB:ec,MUL:tc,DIV:nc,ROUND:rc,ROUNDUP:Ir,CEIL:Ir,ROUNDDOWN:Pr,FLOOR:Pr,ROUNDBANK:oc,NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(t,e)=>t!=null&&t!==""?String(t):e,PAD:(t,e,n)=>String(t).padStart(e,n),REPLACE:(t,e,n)=>String(t).replace(new RegExp(e,"g"),n),JSON:t=>JSON.stringify(t,null,2),DATE:Gl,UPPER:Yl};for(const[t,e]of Object.entries(e0))Uc.registerFunction(t,e);function t0(t,e,n){switch(t.toUpperCase()){case"SUM":return qi(n,e);case"AVG":return Xl(n,e);case"COUNT":return Kl(n);case"MIN":return Zl(n,e);case"MAX":return Jl(n,e);default:return 0}}function dn(t,e){if(!t)return"";if(!t.includes("{"))return t;const n=Array.isArray(e.rows)?e.rows:[];let r=t.replace(/\{([^}]+)\}/g,(o,i)=>{let a=i.trim();return a=a.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(l,c,s)=>{const d=s.trim().replace(/^['"]|['"]$/g,"");return String(t0(c,d,n))}),`{${a}}`});try{return Uc.render(r,e)}catch{return t}}const it={supplier:{name:"鑫达五金有限公司",phone:"0571-88776655",address:"杭州市萧山区经济开发区88号"},receiver:{name:"李四",phone:"13912345678",address:"杭州市余杭区文一西路998号"},order:{no:"PO20260801001",date:"2026-08-01",total:69543.75},goods:[{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:100,price:.5,amount:50,remark:"A级"},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:117,price:.75,amount:87.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:134,price:1,amount:134,remark:""},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:151,price:1.25,amount:188.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:168,price:1.5,amount:252,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:185,price:1.75,amount:323.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:202,price:2,amount:404,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:219,price:2.25,amount:492.75,remark:"A级"},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:236,price:2.5,amount:590,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:253,price:2.75,amount:695.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×20",unit:"个",qty:270,price:3,amount:810,remark:""},{name:"不锈钢螺母 M10",spec:"M16×21",unit:"套",qty:287,price:3.25,amount:932.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×22",unit:"盒",qty:304,price:3.5,amount:1064,remark:""},{name:"六角螺栓 M14",spec:"M5×23",unit:"支",qty:321,price:3.75,amount:1203.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×24",unit:"袋",qty:338,price:4,amount:1352,remark:"A级"},{name:"平垫圈 M6",spec:"M4×25",unit:"件",qty:355,price:4.25,amount:1508.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×26",unit:"根",qty:372,price:4.5,amount:1674,remark:""},{name:"双头螺柱 M20",spec:"M8×27",unit:"包",qty:389,price:4.75,amount:1847.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×28",unit:"只",qty:406,price:5,amount:2030,remark:""},{name:"十字盘头钉 M3",spec:"M12×29",unit:"组",qty:423,price:5.25,amount:2220.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×30",unit:"个",qty:440,price:.5,amount:220,remark:""},{name:"不锈钢螺母 M10",spec:"M16×31",unit:"套",qty:457,price:.75,amount:342.75,remark:"A级"},{name:"弹簧垫圈 M12",spec:"M6×32",unit:"盒",qty:474,price:1,amount:474,remark:""},{name:"六角螺栓 M14",spec:"M5×33",unit:"支",qty:491,price:1.25,amount:613.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×34",unit:"袋",qty:508,price:1.5,amount:762,remark:""},{name:"平垫圈 M6",spec:"M4×35",unit:"件",qty:525,price:1.75,amount:918.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×36",unit:"根",qty:542,price:2,amount:1084,remark:""},{name:"双头螺柱 M20",spec:"M8×37",unit:"包",qty:559,price:2.25,amount:1257.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×38",unit:"只",qty:576,price:2.5,amount:1440,remark:"A级"},{name:"十字盘头钉 M3",spec:"M12×39",unit:"组",qty:593,price:2.75,amount:1630.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×40",unit:"个",qty:610,price:3,amount:1830,remark:""},{name:"不锈钢螺母 M10",spec:"M16×41",unit:"套",qty:627,price:3.25,amount:2037.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×42",unit:"盒",qty:644,price:3.5,amount:2254,remark:""},{name:"六角螺栓 M14",spec:"M5×43",unit:"支",qty:661,price:3.75,amount:2478.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×44",unit:"袋",qty:678,price:4,amount:2712,remark:""},{name:"平垫圈 M6",spec:"M4×45",unit:"件",qty:695,price:4.25,amount:2953.75,remark:"A级"},{name:"自攻螺钉 M5",spec:"M3×46",unit:"根",qty:712,price:4.5,amount:3204,remark:""},{name:"双头螺柱 M20",spec:"M8×47",unit:"包",qty:729,price:4.75,amount:3462.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×48",unit:"只",qty:746,price:5,amount:3730,remark:""},{name:"十字盘头钉 M3",spec:"M12×49",unit:"组",qty:763,price:5.25,amount:4005.75,remark:""},{name:"碳钢螺丝 M8",spec:"M14×10",unit:"个",qty:780,price:.5,amount:390,remark:""},{name:"不锈钢螺母 M10",spec:"M16×11",unit:"套",qty:797,price:.75,amount:597.75,remark:""},{name:"弹簧垫圈 M12",spec:"M6×12",unit:"盒",qty:814,price:1,amount:814,remark:"A级"},{name:"六角螺栓 M14",spec:"M5×13",unit:"支",qty:831,price:1.25,amount:1038.75,remark:""},{name:"内六角螺钉 M16",spec:"M20×14",unit:"袋",qty:848,price:1.5,amount:1272,remark:""},{name:"平垫圈 M6",spec:"M4×15",unit:"件",qty:865,price:1.75,amount:1513.75,remark:""},{name:"自攻螺钉 M5",spec:"M3×16",unit:"根",qty:882,price:2,amount:1764,remark:""},{name:"双头螺柱 M20",spec:"M8×17",unit:"包",qty:899,price:2.25,amount:2022.75,remark:""},{name:"紧定螺钉 M4",spec:"M10×18",unit:"只",qty:916,price:2.5,amount:2290,remark:""},{name:"十字盘头钉 M3",spec:"M12×19",unit:"组",qty:933,price:2.75,amount:2565.75,remark:"A级"}]},Gr={left:0,center:50,right:100},Yr={top:0,center:50,bottom:100};function un(t){return Number.isFinite(t)?Math.round(Math.min(100,Math.max(0,t))):50}function qc(t){return Math.round(t*100)/100}function Wc(t,e){const n=un(t),r=un(e);if(!(n===50&&r===50))return`${n}% ${r}%`}function n0(t){return/^\d+(?:\.\d+)?%$/.test(t)?parseFloat(t):void 0}function r0(t){const e=(t??"").trim();if(!e)return{kind:"empty"};const n=e.toLowerCase().split(/\s+/);let r,o;for(let i=0;i<n.length;i++){const a=n[i],l=n0(a);if(i===0)if(a in Gr)r=Gr[a];else if(l!==void 0)r=l;else if(a in Yr)o=Yr[a];else return{kind:"custom",raw:t};else if(a in Yr&&o===void 0)o=Yr[a];else if(l!==void 0&&r===void 0)r=l;else if(l!==void 0&&o===void 0)o=l;else if(a in Gr&&r===void 0)r=Gr[a];else return{kind:"custom",raw:t}}return{kind:"axes",x:un(r??50),y:un(o??50)}}const jc=25.4/96;function Gc(t){const{widthMm:e,heightMm:n,naturalWidth:r,naturalHeight:o}=t;if(!r||!o||!e||!n)return null;const i=e/r,a=n/o,l=(nl(t.fit,t.scalePct)??Rn)/100;switch(t.fit||"contain"){case"fill":return{w:e,h:n};case"cover":{const c=Math.max(i,a)*l;return{w:r*c,h:o*c}}case"none":return{w:r*jc,h:o*jc};case"scale-down":{const c=Math.min(1,Math.min(i,a));return{w:r*c,h:o*c}}default:{const c=Math.min(i,a);return{w:r*c,h:o*c}}}}function o0(t){const e=Gc(t);return e?{x:qc(Math.abs(t.widthMm-e.w)),y:qc(Math.abs(t.heightMm-e.h))}:{x:null,y:null}}function i0(t,e,n){const r=Gc(t);if(!r)return null;const o=Math.min(1,t.widthMm/r.w),i=Math.min(1,t.heightMm/r.h);return{leftPct:(1-o)*un(e),topPct:(1-i)*un(n),widthPct:o*100,heightPct:i*100}}function Yc(t){const e=String(t??"");return e?e.includes("{")?String(dn(e,it)):e:""}const Vc={vertical:[{value:0,label:"顶部"},{value:50,label:"居中"},{value:100,label:"底部"}],horizontal:[{value:0,label:"左侧"},{value:50,label:"居中"},{value:100,label:"右侧"}]},a0=[{x:0,y:0,label:"左上"},{x:50,y:0,label:"上中"},{x:100,y:0,label:"右上"},{x:0,y:50,label:"左中"},{x:50,y:50,label:"居中"},{x:100,y:50,label:"右中"},{x:0,y:100,label:"左下"},{x:50,y:100,label:"下中"},{x:100,y:100,label:"右下"}],pa=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"剪裁(等比铺满后裁边)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],s0="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNNDAgMFYxMjBNODAgMFYxMjBNMCA0MEgxMjBNMCA4MEgxMjAiIHN0cm9rZT0iI2VlZjFmNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMy41IiBmaWxsPSIjOGI5NWE1Ii8+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMjAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iMTAwIiByPSIzLjUiIGZpbGw9IiM4Yjk1YTUiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iMjAiIHI9IjciIGZpbGw9IiNjMDM5MmIiLz48Y2lyY2xlIGN4PSI2MCIgY3k9IjEwMCIgcj0iNyIgZmlsbD0iIzFmNGZhMyIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iNjAiIHI9IjciIGZpbGw9IiMyYzdhNGEiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSI2MCIgcj0iNyIgZmlsbD0iI2UwN2EyMCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjE0IiBmaWxsPSJub25lIiBzdHJva2U9IiMyZjNhNGEiIHN0cm9rZS13aWR0aD0iNCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYiIGZpbGw9IiMyZjNhNGEiLz48L3N2Zz4=",l0="图片还没设置,上面按内置示例图演示取位;换上真图后档位与可挪量按真图重算";function c0(t){const e=String(t??"").trim();return!e||e.includes("{")||e.includes("}")?{src:s0,isSample:!0}:{src:e,isSample:!1}}function Xc(t){return t==="vertical"?"垂直位置 (%)":"水平位置 (%)"}const d0="放大比例 (%)";function u0(t,e=!1){if(e)return"已保留模板里的原值;改动下面任一项就整体替换成新的取位";const{x:n,y:r}=t;return n===null||r===null?"":n>0&&r>0?`水平可挪 ${n}mm、垂直可挪 ${r}mm:0 贴左/贴顶,100 贴右/贴底`:n>0?`水平可挪 ${n}mm;垂直这一轴已贴满,挪不动`:r>0?`垂直可挪 ${r}mm;水平这一轴已贴满,挪不动`:"这个缩放下图与框正好一样大,两轴都没有可挪的余量"}function p0(t,e,n){return[{name:"horizontal",label:Xc("horizontal"),value:e,travelMm:t.x},{name:"vertical",label:Xc("vertical"),value:n,travelMm:t.y}]}function f0(t,e,n){const r=t.x!==null&&t.x>0,o=t.y!==null&&t.y>0;return o&&!r?Vc.vertical.map(i=>({value:`${e},${i.value}`,label:i.label})):r&&!o?Vc.horizontal.map(i=>({value:`${i.value},${n}`,label:i.label})):a0.map(i=>({value:`${i.x},${i.y}`,label:i.label}))}function Kc(t){const e=[...t].sort((a,l)=>(a.sortOrder??0)-(l.sortOrder??0)),n=new Map,r=[];for(const a of e){const l=a.fieldKey.indexOf(".");if(l===-1)continue;const c=a.fieldKey.slice(0,l);let s=n.get(c);s||(s={key:c,label:c,isList:!1,fields:[]},n.set(c,s),r.push(c)),s.fields.push(a)}const o=[],i=[];for(const a of e){if(a.fieldKey.includes("."))continue;const l=n.get(a.fieldKey);l?(l.label=a.fieldLabel,l.isList=a.fieldType==="list"):i.push(a)}i.length&&o.push({key:"",label:"",isList:!1,fields:i});for(const a of r)o.push(n.get(a));return o}function h0(t,e){const n=e.trim().toLowerCase();return n?t.map(r=>({...r,fields:r.fields.filter(o=>o.fieldLabel.toLowerCase().includes(n)||o.fieldKey.toLowerCase().includes(n))})).filter(r=>r.fields.length>0):t}const g0={text:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],longText:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],barcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],qrcode:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],image:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],table:[],flowList:[{targetPath:"options.formatter",label:"单元模板",dataSource:"main",placeholder:"{drugs.name} {drugs.spec}"}]};function Zc(t,e,n,r){return t==="data"?[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:r,placeholder:"{name}"}]:t==="subtotal"?[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:t==="summary"?[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${e}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function m0(t){const e=t.printElementType.type,n=g0[e]??[],r=[];if(e==="table"){const o=t.options.dataSource;for(const[i,a]of(t.options.tableRows??[]).entries())for(const[l,c]of a.cells.entries())c.merged||r.push(...Zc(a.type,i,l,o))}return[...n,...r]}function b0(t){return Nl("text",{formatter:`{${t.fieldKey}}`,title:t.fieldLabel})}function Jc(t){let e=it;for(const n of t.split(".")){if(e==null)return;e=Array.isArray(e)?e[0]?.[n]:e[n]}return e}function fa(t,e,n="1234567890128"){const r=e?.[0];return(t??"").replace(/\{([^{}]+)\}/g,(i,a)=>{const l=a.trim(),c=l.includes(".")?Jc(l):r?.[l]??Jc(l);return c==null?"":String(c)}).trim()||n}const Vr={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function Qc(t){return t==="vCenter"?Vr.center:t==="hCenter"?Vr.middle:Vr[t]??Vr.left}function y0(t,e,n,r={}){const o=r.adsorbMin??1,i=r.adsorbLineMin??2,a=r.showAdsorbLine??!0;let l=t.left,c=t.top;const s=[],d={left:t.left,right:t.left+t.width,vCenter:t.left+t.width/2,top:t.top,bottom:t.top+t.height,hCenter:t.top+t.height/2};let p=1/0;for(const f of e){if(f.id===t.id)continue;const h={left:f.left,right:f.left+f.width,vCenter:f.left+f.width/2,top:f.top,bottom:f.top+f.height,hCenter:f.top+f.height/2},m=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],b=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,w]of m){const _=Math.abs(d[v]-h[w]);_<=o&&_<p&&(p=_,l=t.left+(h[w]-d[v]))}for(const[v,w]of b){const _=Math.abs(d[v]-h[w]);_<=o&&_<p&&(p=_,c=t.top+(h[w]-d[v]))}}if(n){const f={left:l,right:l+t.width,vCenter:l+t.width/2,top:c,bottom:c+t.height,hCenter:c+t.height/2},h=["left","vCenter","right"];for(const b of n.vertical)for(const v of h){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,l=t.left+(b-f[v]))}const m=["top","hCenter","bottom"];for(const b of n.horizontal)for(const v of m){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,c=t.top+(b-f[v]))}}const u={left:l,right:l+t.width,vCenter:l+t.width/2,top:c,bottom:c+t.height,hCenter:c+t.height/2};if(a){const f=new Set;for(const h of e){if(h.id===t.id)continue;const m={left:h.left,right:h.left+h.width,vCenter:h.left+h.width/2,top:h.top,bottom:h.top+h.height,hCenter:h.top+h.height/2},b=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,_]of b)if(Math.abs(u[w]-m[_])<=i){const z=`v:${m[_]}`;f.has(z)||(f.add(z),s.push({type:"vertical",position:m[_],id:h.id,color:Qc(w)}))}for(const[w,_]of v)if(Math.abs(u[w]-m[_])<=i){const z=`h:${m[_]}`;f.has(z)||(f.add(z),s.push({type:"horizontal",position:m[_],id:h.id,color:Qc(w)}))}}}if(n){for(const f of n.vertical)s.some(h=>h.type==="vertical"&&h.position===f)||s.push({type:"vertical",position:f});for(const f of n.horizontal)s.some(h=>h.type==="horizontal"&&h.position===f)||s.push({type:"horizontal",position:f})}return{left:l,top:c,lines:s}}function v0(){function t(e,n){if(e.length<2)return;const r={minLeft:Math.min(...e.map(o=>o.options.left)),maxRight:Math.max(...e.map(o=>o.options.left+o.options.width)),minTop:Math.min(...e.map(o=>o.options.top)),maxBottom:Math.max(...e.map(o=>o.options.top+o.options.height))};switch(n){case"left":e.forEach(o=>{o.options.left=r.minLeft});break;case"right":e.forEach(o=>{o.options.left=r.maxRight-o.options.width});break;case"top":e.forEach(o=>{o.options.top=r.minTop});break;case"bottom":e.forEach(o=>{o.options.top=r.maxBottom-o.options.height});break;case"vertical":{const o=r.minLeft+(r.maxRight-r.minLeft)/2;e.forEach(i=>{i.options.left=o-i.options.width/2});break}case"horizontal":{const o=r.minTop+(r.maxBottom-r.minTop)/2;e.forEach(i=>{i.options.top=o-i.options.height/2});break}case"distributeHor":{const o=[...e].sort((c,s)=>c.options.left-s.options.left),i=o.reduce((c,s)=>c+s.options.width,0),a=(r.maxRight-r.minLeft-i)/(o.length-1);let l=r.minLeft;o.forEach(c=>{c.options.left=l,l+=c.options.width+a});break}case"distributeVer":{const o=[...e].sort((c,s)=>c.options.top-s.options.top),i=o.reduce((c,s)=>c+s.options.height,0),a=(r.maxBottom-r.minTop-i)/(o.length-1);let l=r.minTop;o.forEach(c=>{c.options.top=l,l+=c.options.height+a});break}}}return{align:t}}function ed(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function w0(){function t(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=ed();return r.map(l=>o.has(l.id)?{...l,options:{...l.options,groupId:a}}:l)}function e(r,o){const i=r.filter(l=>o.has(l.id)),a=new Set(i.map(l=>l.options.groupId).filter(Boolean));return r.map(l=>l.options.groupId&&a.has(l.options.groupId)?{...l,options:{...l.options,groupId:void 0}}:l)}function n(r,o){const i=r.find(l=>l.id===o);if(!i?.options.groupId)return new Set([o]);const a=new Set;for(const l of r)l.options.groupId===i.options.groupId&&a.add(l.id);return a}return{group:t,ungroup:e,getGroupedIds:n}}const x0=["nw","n","ne","e","se","s","sw","w"];function E0(t,e,n,r,o,i){let{left:a,top:l,width:c,height:s}=e;switch(t){case"e":c=Math.max(o,e.width+n);break;case"w":c=Math.max(o,e.width-n),a=e.left+e.width-c;break;case"s":s=Math.max(i,e.height+r);break;case"n":s=Math.max(i,e.height-r),l=e.top+e.height-s;break;case"se":c=Math.max(o,e.width+n),s=Math.max(i,e.height+r);break;case"sw":c=Math.max(o,e.width-n),a=e.left+e.width-c,s=Math.max(i,e.height+r);break;case"ne":c=Math.max(o,e.width+n),s=Math.max(i,e.height-r),l=e.top+e.height-s;break;case"nw":c=Math.max(o,e.width-n),a=e.left+e.width-c,s=Math.max(i,e.height-r),l=e.top+e.height-s;break}return{left:a,top:l,width:c,height:s}}function td(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Xr={},Vn={},Kr={},nd;function qe(){if(nd)return Kr;nd=1,Object.defineProperty(Kr,"__esModule",{value:!0});function t(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}var e=function n(r,o){t(this,n),this.data=r,this.text=o.text||r,this.options=o};return Kr.default=e,Kr}var rd;function S0(){if(rd)return Vn;rd=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.CODE39=void 0;var t=(function(){function m(b,v){for(var w=0;w<v.length;w++){var _=v[w];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(b,_.key,_)}}return function(b,v,w){return v&&m(b.prototype,v),w&&m(b,w),b}})(),e=qe(),n=r(e);function r(m){return m&&m.__esModule?m:{default:m}}function o(m,b){if(!(m instanceof b))throw new TypeError("Cannot call a class as a function")}function i(m,b){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:m}function a(m,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);m.prototype=Object.create(b&&b.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(m,b):m.__proto__=b)}var l=(function(m){a(b,m);function b(v,w){return o(this,b),v=v.toUpperCase(),w.mod43&&(v+=u(h(v))),i(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,v,w))}return t(b,[{key:"encode",value:function(){for(var w=d("*"),_=0;_<this.data.length;_++)w+=d(this.data[_])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),b})(n.default),c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],s=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(m){return p(f(m))}function p(m){return s[m].toString(2)}function u(m){return c[m]}function f(m){return c.indexOf(m)}function h(m){for(var b=0,v=0;v<m.length;v++)b+=f(m[v]);return b=b%43,b}return Vn.CODE39=l,Vn}var Je={},Zr={},Jr={},me={},od;function Xn(){if(od)return me;od=1,Object.defineProperty(me,"__esModule",{value:!0});var t;function e(c,s,d){return s in c?Object.defineProperty(c,s,{value:d,enumerable:!0,configurable:!0,writable:!0}):c[s]=d,c}var n=me.SET_A=0,r=me.SET_B=1,o=me.SET_C=2;me.SHIFT=98;var i=me.START_A=103,a=me.START_B=104,l=me.START_C=105;return me.MODULO=103,me.STOP=106,me.FNC1=207,me.SET_BY_CODE=(t={},e(t,i,n),e(t,a,r),e(t,l,o),t),me.SWAP={101:n,100:r,99:o},me.A_START_CHAR="Ð",me.B_START_CHAR="Ñ",me.C_START_CHAR="Ò",me.A_CHARS="[\0-_È-Ï]",me.B_CHARS="[ -È-Ï]",me.C_CHARS="(Ï*[0-9]{2}Ï*)",me.BARS=[11011001100,11001101100,11001100110,10010011e3,10010001100,10001001100,10011001e3,10011000100,10001100100,11001001e3,11001000100,11000100100,10110011100,10011011100,10011001110,10111001100,10011101100,10011100110,11001110010,11001011100,11001001110,11011100100,11001110100,11101101110,11101001100,11100101100,11100100110,11101100100,11100110100,11100110010,11011011e3,11011000110,11000110110,10100011e3,10001011e3,10001000110,10110001e3,10001101e3,10001100010,11010001e3,11000101e3,11000100010,10110111e3,10110001110,10001101110,10111011e3,10111000110,10001110110,11101110110,11010001110,11000101110,11011101e3,11011100010,11011101110,11101011e3,11101000110,11100010110,11101101e3,11101100010,11100011010,11101111010,11001000010,11110001010,1010011e4,10100001100,1001011e4,10010000110,10000101100,10000100110,1011001e4,10110000100,1001101e4,10011000010,10000110100,10000110010,11000010010,1100101e4,11110111010,11000010100,10001111010,10100111100,10010111100,10010011110,10111100100,10011110100,10011110010,11110100100,11110010100,11110010010,11011011110,11011110110,11110110110,10101111e3,10100011110,10001011110,10111101e3,10111100010,11110101e3,11110100010,10111011110,10111101110,11101011110,11110101110,11010000100,1101001e4,11010011100,1100011101011],me}var id;function Qr(){if(id)return Jr;id=1,Object.defineProperty(Jr,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=qe(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){i(this,d);var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p.substring(1),u));return f.bytes=p.split("").map(function(h){return h.charCodeAt(0)}),f}return t(d,[{key:"valid",value:function(){return/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.bytes,f=u.shift()-105,h=r.SET_BY_CODE[f];if(h===void 0)throw new RangeError("The encoding does not start with a start character.");this.shouldEncodeAsEan128()===!0&&u.unshift(r.FNC1);var m=d.next(u,1,h);return{text:this.text===this.data?this.text.replace(/[^\x20-\x7E]/g,""):this.text,data:d.getBar(f)+m.result+d.getBar((m.checksum+f)%r.MODULO)+d.getBar(r.STOP)}}},{key:"shouldEncodeAsEan128",value:function(){var u=this.options.ean128||!1;return typeof u=="string"&&(u=u.toLowerCase()==="true"),u}}],[{key:"getBar",value:function(u){return r.BARS[u]?r.BARS[u].toString():""}},{key:"correctIndex",value:function(u,f){if(f===r.SET_A){var h=u.shift();return h<32?h+64:h-32}else return f===r.SET_B?u.shift()-32:(u.shift()-48)*10+u.shift()-48}},{key:"next",value:function(u,f,h){if(!u.length)return{result:"",checksum:0};var m=void 0,b=void 0;if(u[0]>=200){b=u.shift()-105;var v=r.SWAP[b];v!==void 0?m=d.next(u,f+1,v):((h===r.SET_A||h===r.SET_B)&&b===r.SHIFT&&(u[0]=h===r.SET_A?u[0]>95?u[0]-96:u[0]:u[0]<32?u[0]+96:u[0]),m=d.next(u,f+1,h))}else b=d.correctIndex(u,h),m=d.next(u,f+1,h);var w=d.getBar(b),_=b*f;return{result:w+m.result,checksum:_+m.checksum}}}]),d})(n.default);return Jr.default=c,Jr}var eo={},ad;function _0(){if(ad)return eo;ad=1,Object.defineProperty(eo,"__esModule",{value:!0});var t=Xn(),e=function(l){return l.match(new RegExp("^"+t.A_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+t.B_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+t.C_CHARS+"*"))[0]};function o(a,l){var c=l?t.A_CHARS:t.B_CHARS,s=a.match(new RegExp("^("+c+"+?)(([0-9]{2}){2,})([^0-9]|$)"));if(s)return s[1]+"Ì"+i(a.substring(s[1].length));var d=a.match(new RegExp("^"+c+"+"))[0];return d.length===a.length?a:d+String.fromCharCode(l?205:206)+o(a.substring(d.length),!l)}function i(a){var l=r(a),c=l.length;if(c===a.length)return a;a=a.substring(c);var s=e(a)>=n(a);return l+String.fromCharCode(s?206:205)+o(a,s)}return eo.default=function(a){var l=void 0,c=r(a).length;if(c>=2)l=t.C_START_CHAR+i(a);else{var s=e(a)>n(a);l=(s?t.A_START_CHAR:t.B_START_CHAR)+o(a,s)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,p){return"Ë"+p})},eo}var sd;function M0(){if(sd)return Zr;sd=1,Object.defineProperty(Zr,"__esModule",{value:!0});var t=Qr(),e=o(t),n=_0(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){if(i(this,d),/^[\x00-\x7F\xC8-\xD3]+$/.test(p))var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,(0,r.default)(p),u));else var f=a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u));return a(f)}return d})(e.default);return Zr.default=c,Zr}var to={},ld;function T0(){if(ld)return to;ld=1,Object.defineProperty(to,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Qr(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.A_START_CHAR+p,u))}return t(d,[{key:"valid",value:function(){return new RegExp("^"+r.A_CHARS+"+$").test(this.data)}}]),d})(n.default);return to.default=c,to}var no={},cd;function k0(){if(cd)return no;cd=1,Object.defineProperty(no,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Qr(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.B_START_CHAR+p,u))}return t(d,[{key:"valid",value:function(){return new RegExp("^"+r.B_CHARS+"+$").test(this.data)}}]),d})(n.default);return no.default=c,no}var ro={},dd;function C0(){if(dd)return ro;dd=1,Object.defineProperty(ro,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Qr(),n=o(e),r=Xn();function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,r.C_START_CHAR+p,u))}return t(d,[{key:"valid",value:function(){return new RegExp("^"+r.C_CHARS+"+$").test(this.data)}}]),d})(n.default);return ro.default=c,ro}var ud;function A0(){if(ud)return Je;ud=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.CODE128C=Je.CODE128B=Je.CODE128A=Je.CODE128=void 0;var t=M0(),e=c(t),n=T0(),r=c(n),o=k0(),i=c(o),a=C0(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return Je.CODE128=e.default,Je.CODE128A=r.default,Je.CODE128B=i.default,Je.CODE128C=l.default,Je}var Pe={},oo={},pt={},pd;function Kn(){return pd||(pd=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.SIDE_BIN="101",pt.MIDDLE_BIN="01010",pt.BINARIES={L:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],G:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"],R:["1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100"],O:["0001101","0011001","0010011","0111101","0100011","0110001","0101111","0111011","0110111","0001011"],E:["0100111","0110011","0011011","0100001","0011101","0111001","0000101","0010001","0001001","0010111"]},pt.EAN2_STRUCTURE=["LL","LG","GL","GG"],pt.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],pt.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),pt}var io={},ao={},fd;function Zn(){if(fd)return ao;fd=1,Object.defineProperty(ao,"__esModule",{value:!0});var t=Kn(),e=function(r,o,i){var a=r.split("").map(function(c,s){return t.BINARIES[o[s]]}).map(function(c,s){return c?c[r[s]]:""});if(i){var l=r.length-1;a=a.map(function(c,s){return s<l?c+i:c})}return a.join("")};return ao.default=e,ao}var hd;function gd(){if(hd)return io;hd=1,Object.defineProperty(io,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})(),e=Kn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,h){l(this,u);var m=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h));return m.fontSize=!h.flat&&h.fontSize>h.width*10?h.width*10:h.fontSize,m.guardHeight=h.height+m.fontSize/2+h.textMargin,m}return t(u,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(h,m){return this.text.substr(h,m)}},{key:"leftEncode",value:function(h,m){return(0,r.default)(h,m)}},{key:"rightText",value:function(h,m){return this.text.substr(h,m)}},{key:"rightEncode",value:function(h,m){return(0,r.default)(h,m)}},{key:"encodeGuarded",value:function(){var h={fontSize:this.fontSize},m={height:this.guardHeight};return[{data:e.SIDE_BIN,options:m},{data:this.leftEncode(),text:this.leftText(),options:h},{data:e.MIDDLE_BIN,options:m},{data:this.rightEncode(),text:this.rightText(),options:h},{data:e.SIDE_BIN,options:m}]}},{key:"encodeFlat",value:function(){var h=[e.SIDE_BIN,this.leftEncode(),e.MIDDLE_BIN,this.rightEncode(),e.SIDE_BIN];return{data:h.join(""),text:this.text}}}]),u})(i.default);return io.default=d,io}var md;function O0(){if(md)return oo;md=1,Object.defineProperty(oo,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})(),e=function p(u,f,h){u===null&&(u=Function.prototype);var m=Object.getOwnPropertyDescriptor(u,f);if(m===void 0){var b=Object.getPrototypeOf(u);return b===null?void 0:p(b,f,h)}else{if("value"in m)return m.value;var v=m.get;return v===void 0?void 0:v.call(h)}},n=Kn(),r=gd(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=function(u){var f=u.substr(0,12).split("").map(function(h){return+h}).reduce(function(h,m,b){return b%2?h+m*3:h+m},0);return(10-f%10)%10},d=(function(p){c(u,p);function u(f,h){a(this,u),f.search(/^[0-9]{12}$/)!==-1&&(f+=s(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h));return m.lastChar=h.lastChar,m}return t(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===s(this.data)}},{key:"leftText",value:function(){return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var h=this.data.substr(1,6),m=n.EAN13_STRUCTURE[this.data[0]];return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftEncode",this).call(this,h,m)}},{key:"rightText",value:function(){return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var h=this.data.substr(7,6);return e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightEncode",this).call(this,h,"RRRRRR")}},{key:"encodeGuarded",value:function(){var h=e(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(h.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(h.push({data:"00"}),h.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),h}}]),u})(o.default);return oo.default=d,oo}var so={},bd;function I0(){if(bd)return so;bd=1,Object.defineProperty(so,"__esModule",{value:!0});var t=(function(){function d(p,u){for(var f=0;f<u.length;f++){var h=u[f];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(p,h.key,h)}}return function(p,u,f){return u&&d(p.prototype,u),f&&d(p,f),p}})(),e=function d(p,u,f){p===null&&(p=Function.prototype);var h=Object.getOwnPropertyDescriptor(p,u);if(h===void 0){var m=Object.getPrototypeOf(p);return m===null?void 0:d(m,u,f)}else{if("value"in h)return h.value;var b=h.get;return b===void 0?void 0:b.call(f)}},n=gd(),r=o(n);function o(d){return d&&d.__esModule?d:{default:d}}function i(d,p){if(!(d instanceof p))throw new TypeError("Cannot call a class as a function")}function a(d,p){if(!d)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p&&(typeof p=="object"||typeof p=="function")?p:d}function l(d,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof p);d.prototype=Object.create(p&&p.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),p&&(Object.setPrototypeOf?Object.setPrototypeOf(d,p):d.__proto__=p)}var c=function(p){var u=p.substr(0,7).split("").map(function(f){return+f}).reduce(function(f,h,m){return m%2?f+h:f+h*3},0);return(10-u%10)%10},s=(function(d){l(p,d);function p(u,f){return i(this,p),u.search(/^[0-9]{7}$/)!==-1&&(u+=c(u)),a(this,(p.__proto__||Object.getPrototypeOf(p)).call(this,u,f))}return t(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:"leftText",value:function(){return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftText",this).call(this,0,4)}},{key:"leftEncode",value:function(){var f=this.data.substr(0,4);return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftEncode",this).call(this,f,"LLLL")}},{key:"rightText",value:function(){return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightText",this).call(this,4,4)}},{key:"rightEncode",value:function(){var f=this.data.substr(4,4);return e(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightEncode",this).call(this,f,"RRRR")}}]),p})(r.default);return so.default=s,so}var lo={},yd;function P0(){if(yd)return lo;yd=1,Object.defineProperty(lo,"__esModule",{value:!0});var t=(function(){function u(f,h){for(var m=0;m<h.length;m++){var b=h[m];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,b.key,b)}}return function(f,h,m){return h&&u(f.prototype,h),m&&u(f,m),f}})(),e=Kn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(u){return u&&u.__esModule?u:{default:u}}function l(u,f){if(!(u instanceof f))throw new TypeError("Cannot call a class as a function")}function c(u,f){if(!u)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return f&&(typeof f=="object"||typeof f=="function")?f:u}function s(u,f){if(typeof f!="function"&&f!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof f);u.prototype=Object.create(f&&f.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),f&&(Object.setPrototypeOf?Object.setPrototypeOf(u,f):u.__proto__=f)}var d=function(f){var h=f.split("").map(function(m){return+m}).reduce(function(m,b,v){return v%2?m+b*9:m+b*3},0);return h%10},p=(function(u){s(f,u);function f(h,m){return l(this,f),c(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,h,m))}return t(f,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var m=e.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,r.default)(this.data,m,"01"),text:this.text}}}]),f})(i.default);return lo.default=p,lo}var co={},vd;function R0(){if(vd)return co;vd=1,Object.defineProperty(co,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})(),e=Kn(),n=Zn(),r=a(n),o=qe(),i=a(o);function a(p){return p&&p.__esModule?p:{default:p}}function l(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function c(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function s(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var d=(function(p){s(u,p);function u(f,h){return l(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h))}return t(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var h=e.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,r.default)(this.data,h,"01"),text:this.text}}}]),u})(i.default);return co.default=d,co}var Jn={},wd;function xd(){if(wd)return Jn;wd=1,Object.defineProperty(Jn,"__esModule",{value:!0});var t=(function(){function p(u,f){for(var h=0;h<f.length;h++){var m=f[h];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,h){return f&&p(u.prototype,f),h&&p(u,h),u}})();Jn.checksum=d;var e=Zn(),n=i(e),r=qe(),o=i(r);function i(p){return p&&p.__esModule?p:{default:p}}function a(p,u){if(!(p instanceof u))throw new TypeError("Cannot call a class as a function")}function l(p,u){if(!p)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return u&&(typeof u=="object"||typeof u=="function")?u:p}function c(p,u){if(typeof u!="function"&&u!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof u);p.prototype=Object.create(u&&u.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),u&&(Object.setPrototypeOf?Object.setPrototypeOf(p,u):p.__proto__=u)}var s=(function(p){c(u,p);function u(f,h){a(this,u),f.search(/^[0-9]{11}$/)!==-1&&(f+=d(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,h));return m.displayValue=h.displayValue,h.fontSize>h.width*10?m.fontSize=h.width*10:m.fontSize=h.fontSize,m.guardHeight=h.height+m.fontSize/2+h.textMargin,m}return t(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{12}$/)!==-1&&this.data[11]==d(this.data)}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var h="";return h+="101",h+=(0,n.default)(this.data.substr(0,6),"LLLLLL"),h+="01010",h+=(0,n.default)(this.data.substr(6,6),"RRRRRR"),h+="101",{data:h,text:this.text}}},{key:"guardedEncoding",value:function(){var h=[];return this.displayValue&&h.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),h.push({data:"101"+(0,n.default)(this.data[0],"L"),options:{height:this.guardHeight}}),h.push({data:(0,n.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),h.push({data:"01010",options:{height:this.guardHeight}}),h.push({data:(0,n.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),h.push({data:(0,n.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&h.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),h}}]),u})(o.default);function d(p){var u=0,f;for(f=1;f<11;f+=2)u+=parseInt(p[f]);for(f=0;f<11;f+=2)u+=parseInt(p[f])*3;return(10-u%10)%10}return Jn.default=s,Jn}var uo={},Ed;function D0(){if(Ed)return uo;Ed=1,Object.defineProperty(uo,"__esModule",{value:!0});var t=(function(){function h(m,b){for(var v=0;v<b.length;v++){var w=b[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,w.key,w)}}return function(m,b,v){return b&&h(m.prototype,b),v&&h(m,v),m}})(),e=Zn(),n=a(e),r=qe(),o=a(r),i=xd();function a(h){return h&&h.__esModule?h:{default:h}}function l(h,m){if(!(h instanceof m))throw new TypeError("Cannot call a class as a function")}function c(h,m){if(!h)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:h}function s(h,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);h.prototype=Object.create(m&&m.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(h,m):h.__proto__=m)}var d=["XX00000XXX","XX10000XXX","XX20000XXX","XXX00000XX","XXXX00000X","XXXXX00005","XXXXX00006","XXXXX00007","XXXXX00008","XXXXX00009"],p=[["EEEOOO","OOOEEE"],["EEOEOO","OOEOEE"],["EEOOEO","OOEEOE"],["EEOOOE","OOEEEO"],["EOEEOO","OEOOEE"],["EOOEEO","OEEOOE"],["EOOOEE","OEEEOO"],["EOEOEO","OEOEOE"],["EOEOOE","OEOEEO"],["EOOEOE","OEEOEO"]],u=(function(h){s(m,h);function m(b,v){l(this,m);var w=c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,v));if(w.isValid=!1,b.search(/^[0-9]{6}$/)!==-1)w.middleDigits=b,w.upcA=f(b,"0"),w.text=v.text||""+w.upcA[0]+b+w.upcA[w.upcA.length-1],w.isValid=!0;else if(b.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=b.substring(1,b.length-1),w.upcA=f(w.middleDigits,b[0]),w.upcA[w.upcA.length-1]===b[b.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=v.displayValue,v.fontSize>v.width*10?w.fontSize=v.width*10:w.fontSize=v.fontSize,w.guardHeight=v.height+w.fontSize/2+v.textMargin,w}return t(m,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=this.encodeMiddleDigits(),v+="010101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101",options:{height:this.guardHeight}}),v.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),v.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),v}},{key:"encodeMiddleDigits",value:function(){var v=this.upcA[0],w=this.upcA[this.upcA.length-1],_=p[parseInt(w)][parseInt(v)];return(0,n.default)(this.middleDigits,_)}}]),m})(o.default);function f(h,m){for(var b=parseInt(h[h.length-1]),v=d[b],w="",_=0,T=0;T<v.length;T++){var z=v[T];z==="X"?w+=h[_++]:w+=z}return w=""+m+w,""+w+(0,i.checksum)(w)}return uo.default=u,uo}var Sd;function $0(){if(Sd)return Pe;Sd=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.UPCE=Pe.UPC=Pe.EAN2=Pe.EAN5=Pe.EAN8=Pe.EAN13=void 0;var t=O0(),e=u(t),n=I0(),r=u(n),o=P0(),i=u(o),a=R0(),l=u(a),c=xd(),s=u(c),d=D0(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return Pe.EAN13=e.default,Pe.EAN8=r.default,Pe.EAN5=i.default,Pe.EAN2=l.default,Pe.UPC=s.default,Pe.UPCE=p.default,Pe}var Bt={},po={},pn={},_d;function N0(){return _d||(_d=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.START_BIN="1010",pn.END_BIN="11101",pn.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),pn}var Md;function Td(){if(Md)return po;Md=1,Object.defineProperty(po,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=N0(),n=qe(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).apply(this,arguments))}return t(d,[{key:"valid",value:function(){return this.data.search(/^([0-9]{2})+$/)!==-1}},{key:"encode",value:function(){var u=this,f=this.data.match(/.{2}/g).map(function(h){return u.encodePair(h)}).join("");return{data:e.START_BIN+f+e.END_BIN,text:this.text}}},{key:"encodePair",value:function(u){var f=e.BINARIES[u[1]];return e.BINARIES[u[0]].split("").map(function(h,m){return(h==="1"?"111":"1")+(f[m]==="1"?"000":"0")}).join("")}}]),d})(r.default);return po.default=c,po}var fo={},kd;function L0(){if(kd)return fo;kd=1,Object.defineProperty(fo,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=Td(),n=r(e);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=function(d){var p=d.substr(0,13).split("").map(function(u){return parseInt(u,10)}).reduce(function(u,f,h){return u+f*(3-h%2*2)},0);return Math.ceil(p/10)*10-p},c=(function(s){a(d,s);function d(p,u){return o(this,d),p.search(/^[0-9]{13}$/)!==-1&&(p+=l(p)),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return t(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===l(this.data)}}]),d})(n.default);return fo.default=c,fo}var Cd;function F0(){if(Cd)return Bt;Cd=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.ITF14=Bt.ITF=void 0;var t=Td(),e=o(t),n=L0(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Bt.ITF=e.default,Bt.ITF14=r.default,Bt}var We={},ho={},Ad;function Qn(){if(Ad)return ho;Ad=1,Object.defineProperty(ho,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=qe(),n=r(e);function r(s){return s&&s.__esModule?s:{default:s}}function o(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function i(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function a(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var l=(function(s){a(d,s);function d(p,u){return o(this,d),i(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return t(d,[{key:"encode",value:function(){for(var u="110",f=0;f<this.data.length;f++){var h=parseInt(this.data[f]),m=h.toString(2);m=c(m,4-m.length);for(var b=0;b<m.length;b++)u+=m[b]=="0"?"100":"110"}return u+="1001",{data:u,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(n.default);function c(s,d){for(var p=0;p<d;p++)s="0"+s;return s}return ho.default=l,ho}var go={},er={},Od;function mo(){if(Od)return er;Od=1,Object.defineProperty(er,"__esModule",{value:!0}),er.mod10=t,er.mod11=e;function t(n){for(var r=0,o=0;o<n.length;o++){var i=parseInt(n[o]);(o+n.length)%2===0?r+=i:r+=i*2%10+Math.floor(i*2/10)}return(10-r%10)%10}function e(n){for(var r=0,o=[2,3,4,5,6,7],i=0;i<n.length;i++){var a=parseInt(n[n.length-1-i]);r+=o[i%o.length]*a}return(11-r%11)%11}return er}var Id;function z0(){if(Id)return go;Id=1,Object.defineProperty(go,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod10)(d),p))}return s})(e.default);return go.default=l,go}var bo={},Pd;function B0(){if(Pd)return bo;Pd=1,Object.defineProperty(bo,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d+(0,n.mod11)(d),p))}return s})(e.default);return bo.default=l,bo}var yo={},Rd;function H0(){if(Rd)return yo;Rd=1,Object.defineProperty(yo,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod10)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(e.default);return yo.default=l,yo}var vo={},Dd;function U0(){if(Dd)return vo;Dd=1,Object.defineProperty(vo,"__esModule",{value:!0});var t=Qn(),e=r(t),n=mo();function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),d+=(0,n.mod11)(d),d+=(0,n.mod10)(d),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return s})(e.default);return vo.default=l,vo}var $d;function q0(){if($d)return We;$d=1,Object.defineProperty(We,"__esModule",{value:!0}),We.MSI1110=We.MSI1010=We.MSI11=We.MSI10=We.MSI=void 0;var t=Qn(),e=d(t),n=z0(),r=d(n),o=B0(),i=d(o),a=H0(),l=d(a),c=U0(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return We.MSI=e.default,We.MSI10=r.default,We.MSI11=i.default,We.MSI1010=l.default,We.MSI1110=s.default,We}var tr={},Nd;function W0(){if(Nd)return tr;Nd=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.pharmacode=void 0;var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=qe(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s);var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p));return u.number=parseInt(d,10),u}return t(s,[{key:"encode",value:function(){for(var p=this.number,u="";!isNaN(p)&&p!=0;)p%2===0?(u="11100"+u,p=(p-2)/2):(u="100"+u,p=(p-1)/2);return u=u.slice(0,-2),{data:u,text:this.text}}},{key:"valid",value:function(){return this.number>=3&&this.number<=131070}}]),s})(n.default);return tr.pharmacode=l,tr}var nr={},Ld;function j0(){if(Ld)return nr;Ld=1,Object.defineProperty(nr,"__esModule",{value:!0}),nr.codabar=void 0;var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=qe(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){o(this,s),d.search(/^[0-9\-\$\:\.\+\/]+$/)===0&&(d="A"+d+"A");var u=i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d.toUpperCase(),p));return u.text=u.options.text||u.text.replace(/[A-D]/g,""),u}return t(s,[{key:"valid",value:function(){return this.data.search(/^[A-D][0-9\-\$\:\.\+\/]+[A-D]$/)!==-1}},{key:"encode",value:function(){for(var p=[],u=this.getEncodings(),f=0;f<this.data.length;f++)p.push(u[this.data.charAt(f)]),f!==this.data.length-1&&p.push("0");return{text:this.text,data:p.join("")}}},{key:"getEncodings",value:function(){return{0:"101010011",1:"101011001",2:"101001011",3:"110010101",4:"101101001",5:"110101001",6:"100101011",7:"100101101",8:"100110101",9:"110100101","-":"101001101",$:"101100101",":":"1101011011","/":"1101101011",".":"1101101101","+":"1011011011",A:"1011001001",B:"1001001011",C:"1010010011",D:"1010011001"}}}]),s})(n.default);return nr.codabar=l,nr}var Ht={},wo={},fn={},Fd;function G0(){return Fd||(Fd=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.SYMBOLS=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],fn.BINARIES=["100010100","101001000","101000100","101000010","100101000","100100100","100100010","101010000","100010010","100001010","110101000","110100100","110100010","110010100","110010010","110001010","101101000","101100100","101100010","100110100","100011010","101011000","101001100","101000110","100101100","100010110","110110100","110110010","110101100","110100110","110010110","110011010","101101100","101100110","100110110","100111010","100101110","111010100","111010010","111001010","101101110","101110110","110101110","100100110","111011010","111010110","100110010","101011110"],fn.MULTI_SYMBOLS={"\0":["(%)","U"],"":["($)","A"],"":["($)","B"],"":["($)","C"],"":["($)","D"],"":["($)","E"],"":["($)","F"],"\x07":["($)","G"],"\b":["($)","H"]," ":["($)","I"],"\n":["($)","J"],"\v":["($)","K"],"\f":["($)","L"],"\r":["($)","M"],"":["($)","N"],"":["($)","O"],"":["($)","P"],"":["($)","Q"],"":["($)","R"],"":["($)","S"],"":["($)","T"],"":["($)","U"],"":["($)","V"],"":["($)","W"],"":["($)","X"],"":["($)","Y"],"":["($)","Z"],"\x1B":["(%)","A"],"":["(%)","B"],"":["(%)","C"],"":["(%)","D"],"":["(%)","E"],"!":["(/)","A"],'"':["(/)","B"],"#":["(/)","C"],"&":["(/)","F"],"'":["(/)","G"],"(":["(/)","H"],")":["(/)","I"],"*":["(/)","J"],",":["(/)","L"],":":["(/)","Z"],";":["(%)","F"],"<":["(%)","G"],"=":["(%)","H"],">":["(%)","I"],"?":["(%)","J"],"@":["(%)","V"],"[":["(%)","K"],"\\":["(%)","L"],"]":["(%)","M"],"^":["(%)","N"],_:["(%)","O"],"`":["(%)","W"],a:["(+)","A"],b:["(+)","B"],c:["(+)","C"],d:["(+)","D"],e:["(+)","E"],f:["(+)","F"],g:["(+)","G"],h:["(+)","H"],i:["(+)","I"],j:["(+)","J"],k:["(+)","K"],l:["(+)","L"],m:["(+)","M"],n:["(+)","N"],o:["(+)","O"],p:["(+)","P"],q:["(+)","Q"],r:["(+)","R"],s:["(+)","S"],t:["(+)","T"],u:["(+)","U"],v:["(+)","V"],w:["(+)","W"],x:["(+)","X"],y:["(+)","Y"],z:["(+)","Z"],"{":["(%)","P"],"|":["(%)","Q"],"}":["(%)","R"],"~":["(%)","S"],"":["(%)","T"]}),fn}var zd;function Bd(){if(zd)return wo;zd=1,Object.defineProperty(wo,"__esModule",{value:!0});var t=(function(){function s(d,p){for(var u=0;u<p.length;u++){var f=p[u];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(d,f.key,f)}}return function(d,p,u){return p&&s(d.prototype,p),u&&s(d,u),d}})(),e=G0(),n=qe(),r=o(n);function o(s){return s&&s.__esModule?s:{default:s}}function i(s,d){if(!(s instanceof d))throw new TypeError("Cannot call a class as a function")}function a(s,d){if(!s)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return d&&(typeof d=="object"||typeof d=="function")?d:s}function l(s,d){if(typeof d!="function"&&d!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof d);s.prototype=Object.create(d&&d.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),d&&(Object.setPrototypeOf?Object.setPrototypeOf(s,d):s.__proto__=d)}var c=(function(s){l(d,s);function d(p,u){return i(this,d),a(this,(d.__proto__||Object.getPrototypeOf(d)).call(this,p,u))}return t(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.data.split("").flatMap(function(b){return e.MULTI_SYMBOLS[b]||b}),f=u.map(function(b){return d.getEncoding(b)}).join(""),h=d.checksum(u,20),m=d.checksum(u.concat(h),15);return{text:this.text,data:d.getEncoding("ÿ")+f+d.getEncoding(h)+d.getEncoding(m)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(u){return e.BINARIES[d.symbolValue(u)]}},{key:"getSymbol",value:function(u){return e.SYMBOLS[u]}},{key:"symbolValue",value:function(u){return e.SYMBOLS.indexOf(u)}},{key:"checksum",value:function(u,f){var h=u.slice().reverse().reduce(function(m,b,v){var w=v%f+1;return m+d.symbolValue(b)*w},0);return d.getSymbol(h%47)}}]),d})(r.default);return wo.default=c,wo}var xo={},Hd;function Y0(){if(Hd)return xo;Hd=1,Object.defineProperty(xo,"__esModule",{value:!0});var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=Bd(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return t(s,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),s})(n.default);return xo.default=l,xo}var Ud;function V0(){if(Ud)return Ht;Ud=1,Object.defineProperty(Ht,"__esModule",{value:!0}),Ht.CODE93FullASCII=Ht.CODE93=void 0;var t=Bd(),e=o(t),n=Y0(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return Ht.CODE93=e.default,Ht.CODE93FullASCII=r.default,Ht}var rr={},qd;function X0(){if(qd)return rr;qd=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.GenericBarcode=void 0;var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=qe(),n=r(e);function r(c){return c&&c.__esModule?c:{default:c}}function o(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}function i(c,s){if(!c)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s&&(typeof s=="object"||typeof s=="function")?s:c}function a(c,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof s);c.prototype=Object.create(s&&s.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),s&&(Object.setPrototypeOf?Object.setPrototypeOf(c,s):c.__proto__=s)}var l=(function(c){a(s,c);function s(d,p){return o(this,s),i(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,d,p))}return t(s,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),s})(n.default);return rr.GenericBarcode=l,rr}var Wd;function K0(){if(Wd)return Xr;Wd=1,Object.defineProperty(Xr,"__esModule",{value:!0});var t=S0(),e=A0(),n=$0(),r=F0(),o=q0(),i=W0(),a=j0(),l=V0(),c=X0();return Xr.default={CODE39:t.CODE39,CODE128:e.CODE128,CODE128A:e.CODE128A,CODE128B:e.CODE128B,CODE128C:e.CODE128C,EAN13:n.EAN13,EAN8:n.EAN8,EAN5:n.EAN5,EAN2:n.EAN2,UPC:n.UPC,UPCE:n.UPCE,ITF14:r.ITF14,ITF:r.ITF,MSI:o.MSI,MSI10:o.MSI10,MSI11:o.MSI11,MSI1010:o.MSI1010,MSI1110:o.MSI1110,pharmacode:i.pharmacode,codabar:a.codabar,CODE93:l.CODE93,CODE93FullASCII:l.CODE93FullASCII,GenericBarcode:c.GenericBarcode},Xr}var Eo={},jd;function So(){if(jd)return Eo;jd=1,Object.defineProperty(Eo,"__esModule",{value:!0});var t=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e};return Eo.default=function(e,n){return t({},e,n)},Eo}var _o={},Gd;function Z0(){if(Gd)return _o;Gd=1,Object.defineProperty(_o,"__esModule",{value:!0}),_o.default=t;function t(e){var n=[];function r(o){if(Array.isArray(o))for(var i=0;i<o.length;i++)r(o[i]);else o.text=o.text||"",o.data=o.data||"",n.push(o)}return r(e),n}return _o}var Mo={},Yd;function J0(){if(Yd)return Mo;Yd=1,Object.defineProperty(Mo,"__esModule",{value:!0}),Mo.default=t;function t(e){return e.marginTop=e.marginTop||e.margin,e.marginBottom=e.marginBottom||e.margin,e.marginRight=e.marginRight||e.margin,e.marginLeft=e.marginLeft||e.margin,e}return Mo}var To={},ko={},Co={},Vd;function Xd(){if(Vd)return Co;Vd=1,Object.defineProperty(Co,"__esModule",{value:!0}),Co.default=t;function t(e){var n=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var r in n)n.hasOwnProperty(r)&&(r=n[r],typeof e[r]=="string"&&(e[r]=parseInt(e[r],10)));return typeof e.displayValue=="string"&&(e.displayValue=e.displayValue!="false"),e}return Co}var Ao={},Kd;function Zd(){if(Kd)return Ao;Kd=1,Object.defineProperty(Ao,"__esModule",{value:!0});var t={width:2,height:100,format:"auto",displayValue:!0,fontOptions:"",font:"monospace",text:void 0,textAlign:"center",textPosition:"bottom",textMargin:2,fontSize:20,background:"#ffffff",lineColor:"#000000",margin:10,marginTop:void 0,marginBottom:void 0,marginLeft:void 0,marginRight:void 0,valid:function(){}};return Ao.default=t,Ao}var Jd;function Q0(){if(Jd)return ko;Jd=1,Object.defineProperty(ko,"__esModule",{value:!0});var t=Xd(),e=o(t),n=Zd(),r=o(n);function o(a){return a&&a.__esModule?a:{default:a}}function i(a){var l={};for(var c in r.default)r.default.hasOwnProperty(c)&&(a.hasAttribute("jsbarcode-"+c.toLowerCase())&&(l[c]=a.getAttribute("jsbarcode-"+c.toLowerCase())),a.hasAttribute("data-"+c.toLowerCase())&&(l[c]=a.getAttribute("data-"+c.toLowerCase())));return l.value=a.getAttribute("jsbarcode-value")||a.getAttribute("data-value"),l=(0,e.default)(l),l}return ko.default=i,ko}var Oo={},Io={},je={},Qd;function eu(){if(Qd)return je;Qd=1,Object.defineProperty(je,"__esModule",{value:!0}),je.getTotalWidthOfEncodings=je.calculateEncodingAttributes=je.getBarcodePadding=je.getEncodingHeight=je.getMaximumHeightOfEncodings=void 0;var t=So(),e=n(t);function n(s){return s&&s.__esModule?s:{default:s}}function r(s,d){return d.height+(d.displayValue&&s.text.length>0?d.fontSize+d.textMargin:0)+d.marginTop+d.marginBottom}function o(s,d,p){if(p.displayValue&&d<s){if(p.textAlign=="center")return Math.floor((s-d)/2);if(p.textAlign=="left")return 0;if(p.textAlign=="right")return Math.floor(s-d)}return 0}function i(s,d,p){for(var u=0;u<s.length;u++){var f=s[u],h=(0,e.default)(d,f.options),m;h.displayValue?m=c(f.text,h,p):m=0;var b=f.data.length*h.width;f.width=Math.ceil(Math.max(m,b)),f.height=r(f,h),f.barcodePadding=o(m,b,h)}}function a(s){for(var d=0,p=0;p<s.length;p++)d+=s[p].width;return d}function l(s){for(var d=0,p=0;p<s.length;p++)s[p].height>d&&(d=s[p].height);return d}function c(s,d,p){var u;if(p)u=p;else if(typeof document<"u")u=document.createElement("canvas").getContext("2d");else return 0;u.font=d.fontOptions+" "+d.fontSize+"px "+d.font;var f=u.measureText(s);if(!f)return 0;var h=f.width;return h}return je.getMaximumHeightOfEncodings=l,je.getEncodingHeight=r,je.getBarcodePadding=o,je.calculateEncodingAttributes=i,je.getTotalWidthOfEncodings=a,je}var tu;function eb(){if(tu)return Io;tu=1,Object.defineProperty(Io,"__esModule",{value:!0});var t=(function(){function l(c,s){for(var d=0;d<s.length;d++){var p=s[d];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(c,p.key,p)}}return function(c,s,d){return s&&l(c.prototype,s),d&&l(c,d),c}})(),e=So(),n=o(e),r=eu();function o(l){return l&&l.__esModule?l:{default:l}}function i(l,c){if(!(l instanceof c))throw new TypeError("Cannot call a class as a function")}var a=(function(){function l(c,s,d){i(this,l),this.canvas=c,this.encodings=s,this.options=d}return t(l,[{key:"render",value:function(){if(!this.canvas.getContext)throw new Error("The browser does not support canvas.");this.prepareCanvas();for(var s=0;s<this.encodings.length;s++){var d=(0,n.default)(this.options,this.encodings[s].options);this.drawCanvasBarcode(d,this.encodings[s]),this.drawCanvasText(d,this.encodings[s]),this.moveCanvasDrawing(this.encodings[s])}this.restoreCanvas()}},{key:"prepareCanvas",value:function(){var s=this.canvas.getContext("2d");s.save(),(0,r.calculateEncodingAttributes)(this.encodings,this.options,s);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings);this.canvas.width=d+this.options.marginLeft+this.options.marginRight,this.canvas.height=p,s.clearRect(0,0,this.canvas.width,this.canvas.height),this.options.background&&(s.fillStyle=this.options.background,s.fillRect(0,0,this.canvas.width,this.canvas.height)),s.translate(this.options.marginLeft,0)}},{key:"drawCanvasBarcode",value:function(s,d){var p=this.canvas.getContext("2d"),u=d.data,f;s.textPosition=="top"?f=s.marginTop+s.fontSize+s.textMargin:f=s.marginTop,p.fillStyle=s.lineColor;for(var h=0;h<u.length;h++){var m=h*s.width+d.barcodePadding;u[h]==="1"?p.fillRect(m,f,s.width,s.height):u[h]&&p.fillRect(m,f,s.width,s.height*u[h])}}},{key:"drawCanvasText",value:function(s,d){var p=this.canvas.getContext("2d"),u=s.fontOptions+" "+s.fontSize+"px "+s.font;if(s.displayValue){var f,h;s.textPosition=="top"?h=s.marginTop+s.fontSize-s.textMargin:h=s.height+s.textMargin+s.marginTop+s.fontSize,p.font=u,s.textAlign=="left"||d.barcodePadding>0?(f=0,p.textAlign="left"):s.textAlign=="right"?(f=d.width-1,p.textAlign="right"):(f=d.width/2,p.textAlign="center"),p.fillText(d.text,f,h)}}},{key:"moveCanvasDrawing",value:function(s){var d=this.canvas.getContext("2d");d.translate(s.width,0)}},{key:"restoreCanvas",value:function(){var s=this.canvas.getContext("2d");s.restore()}}]),l})();return Io.default=a,Io}var Po={},nu;function tb(){if(nu)return Po;nu=1,Object.defineProperty(Po,"__esModule",{value:!0});var t=(function(){function c(s,d){for(var p=0;p<d.length;p++){var u=d[p];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(s,u.key,u)}}return function(s,d,p){return d&&c(s.prototype,d),p&&c(s,p),s}})(),e=So(),n=o(e),r=eu();function o(c){return c&&c.__esModule?c:{default:c}}function i(c,s){if(!(c instanceof s))throw new TypeError("Cannot call a class as a function")}var a="http://www.w3.org/2000/svg",l=(function(){function c(s,d,p){i(this,c),this.svg=s,this.encodings=d,this.options=p,this.document=p.xmlDocument||document}return t(c,[{key:"render",value:function(){var d=this.options.marginLeft;this.prepareSVG();for(var p=0;p<this.encodings.length;p++){var u=this.encodings[p],f=(0,n.default)(this.options,u.options),h=this.createGroup(d,f.marginTop,this.svg);this.setGroupOptions(h,f),this.drawSvgBarcode(h,f,u),this.drawSVGText(h,f,u),d+=u.width}}},{key:"prepareSVG",value:function(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);(0,r.calculateEncodingAttributes)(this.encodings,this.options);var d=(0,r.getTotalWidthOfEncodings)(this.encodings),p=(0,r.getMaximumHeightOfEncodings)(this.encodings),u=d+this.options.marginLeft+this.options.marginRight;this.setSvgAttributes(u,p),this.options.background&&this.drawRect(0,0,u,p,this.svg).setAttribute("fill",this.options.background)}},{key:"drawSvgBarcode",value:function(d,p,u){var f=u.data,h;p.textPosition=="top"?h=p.fontSize+p.textMargin:h=0;for(var m=0,b=0,v=0;v<f.length;v++)b=v*p.width+u.barcodePadding,f[v]==="1"?m++:m>0&&(this.drawRect(b-p.width*m,h,p.width*m,p.height,d),m=0);m>0&&this.drawRect(b-p.width*(m-1),h,p.width*m,p.height,d)}},{key:"drawSVGText",value:function(d,p,u){var f=this.document.createElementNS(a,"text");if(p.displayValue){var h,m;f.setAttribute("font-family",p.font),f.setAttribute("font-size",p.fontSize),p.fontOptions.includes("bold")&&f.setAttribute("font-weight","bold"),p.fontOptions.includes("italic")&&f.setAttribute("font-style","italic"),p.textPosition=="top"?m=p.fontSize-p.textMargin:m=p.height+p.textMargin+p.fontSize,p.textAlign=="left"||u.barcodePadding>0?(h=0,f.setAttribute("text-anchor","start")):p.textAlign=="right"?(h=u.width-1,f.setAttribute("text-anchor","end")):(h=u.width/2,f.setAttribute("text-anchor","middle")),f.setAttribute("x",h),f.setAttribute("y",m),f.appendChild(this.document.createTextNode(u.text)),d.appendChild(f)}}},{key:"setSvgAttributes",value:function(d,p){var u=this.svg;u.setAttribute("width",d+"px"),u.setAttribute("height",p+"px"),u.setAttribute("x","0px"),u.setAttribute("y","0px"),u.setAttribute("viewBox","0 0 "+d+" "+p),u.setAttribute("xmlns",a),u.setAttribute("version","1.1")}},{key:"createGroup",value:function(d,p,u){var f=this.document.createElementNS(a,"g");return f.setAttribute("transform","translate("+d+", "+p+")"),u.appendChild(f),f}},{key:"setGroupOptions",value:function(d,p){d.setAttribute("fill",p.lineColor)}},{key:"drawRect",value:function(d,p,u,f,h){var m=this.document.createElementNS(a,"rect");return m.setAttribute("x",d),m.setAttribute("y",p),m.setAttribute("width",u),m.setAttribute("height",f),h.appendChild(m),m}}]),c})();return Po.default=l,Po}var Ro={},ru;function nb(){if(ru)return Ro;ru=1,Object.defineProperty(Ro,"__esModule",{value:!0});var t=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function e(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o,i,a){e(this,r),this.object=o,this.encodings=i,this.options=a}return t(r,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),r})();return Ro.default=n,Ro}var ou;function rb(){if(ou)return Oo;ou=1,Object.defineProperty(Oo,"__esModule",{value:!0});var t=eb(),e=a(t),n=tb(),r=a(n),o=nb(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Oo.default={CanvasRenderer:e.default,SVGRenderer:r.default,ObjectRenderer:i.default},Oo}var hn={},iu;function au(){if(iu)return hn;iu=1,Object.defineProperty(hn,"__esModule",{value:!0});function t(a,l){if(!(a instanceof l))throw new TypeError("Cannot call a class as a function")}function e(a,l){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l&&(typeof l=="object"||typeof l=="function")?l:a}function n(a,l){if(typeof l!="function"&&l!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof l);a.prototype=Object.create(l&&l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),l&&(Object.setPrototypeOf?Object.setPrototypeOf(a,l):a.__proto__=l)}var r=(function(a){n(l,a);function l(c,s){t(this,l);var d=e(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return d.name="InvalidInputException",d.symbology=c,d.input=s,d.message='"'+d.input+'" is not a valid input for '+d.symbology,d}return l})(Error),o=(function(a){n(l,a);function l(){t(this,l);var c=e(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="InvalidElementException",c.message="Not supported type to render on",c}return l})(Error),i=(function(a){n(l,a);function l(){t(this,l);var c=e(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="NoElementException",c.message="No element to render on.",c}return l})(Error);return hn.InvalidInputException=r,hn.InvalidElementException=o,hn.NoElementException=i,hn}var su;function ob(){if(su)return To;su=1,Object.defineProperty(To,"__esModule",{value:!0});var t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},e=Q0(),n=a(e),r=rb(),o=a(r),i=au();function a(d){return d&&d.__esModule?d:{default:d}}function l(d){if(typeof d=="string")return c(d);if(Array.isArray(d)){for(var p=[],u=0;u<d.length;u++)p.push(l(d[u]));return p}else{if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLImageElement)return s(d);if(d&&d.nodeName&&d.nodeName.toLowerCase()==="svg"||typeof SVGElement<"u"&&d instanceof SVGElement)return{element:d,options:(0,n.default)(d),renderer:o.default.SVGRenderer};if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement)return{element:d,options:(0,n.default)(d),renderer:o.default.CanvasRenderer};if(d&&d.getContext)return{element:d,renderer:o.default.CanvasRenderer};if(d&&(typeof d>"u"?"undefined":t(d))==="object"&&!d.nodeName)return{element:d,renderer:o.default.ObjectRenderer};throw new i.InvalidElementException}}function c(d){var p=document.querySelectorAll(d);if(p.length!==0){for(var u=[],f=0;f<p.length;f++)u.push(l(p[f]));return u}}function s(d){var p=document.createElement("canvas");return{element:p,options:(0,n.default)(d),renderer:o.default.CanvasRenderer,afterRender:function(){d.setAttribute("src",p.toDataURL())}}}return To.default=l,To}var Do={},lu;function ib(){if(lu)return Do;lu=1,Object.defineProperty(Do,"__esModule",{value:!0});var t=(function(){function r(o,i){for(var a=0;a<i.length;a++){var l=i[a];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(o,l.key,l)}}return function(o,i,a){return i&&r(o.prototype,i),a&&r(o,a),o}})();function e(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o){e(this,r),this.api=o}return t(r,[{key:"handleCatch",value:function(i){if(i.name==="InvalidInputException")if(this.api._options.valid!==this.api._defaults.valid)this.api._options.valid(!1);else throw i.message;else throw i;this.api.render=function(){}}},{key:"wrapBarcodeCall",value:function(i){try{var a=i.apply(void 0,arguments);return this.api._options.valid(!0),a}catch(l){return this.handleCatch(l),this.api}}}]),r})();return Do.default=n,Do}var ha,cu;function ab(){if(cu)return ha;cu=1;var t=K0(),e=v(t),n=So(),r=v(n),o=Z0(),i=v(o),a=J0(),l=v(a),c=ob(),s=v(c),d=Xd(),p=v(d),u=ib(),f=v(u),h=au(),m=Zd(),b=v(m);function v(S){return S&&S.__esModule?S:{default:S}}var w=function(){},_=function(C,O,R){var I=new w;if(typeof C>"u")throw Error("No element to render on was provided.");return I._renderProperties=(0,s.default)(C),I._encodings=[],I._options=b.default,I._errorHandler=new f.default(I),typeof O<"u"&&(R=R||{},R.format||(R.format=P()),I.options(R)[R.format](O,R).render()),I};_.getModule=function(S){return e.default[S]};for(var T in e.default)e.default.hasOwnProperty(T)&&z(e.default,T);function z(S,C){w.prototype[C]=w.prototype[C.toUpperCase()]=w.prototype[C.toLowerCase()]=function(O,R){var I=this;return I._errorHandler.wrapBarcodeCall(function(){R.text=typeof R.text>"u"?void 0:""+R.text;var x=(0,r.default)(I._options,R);x=(0,p.default)(x);var j=S[C],te=N(O,j,x);return I._encodings.push(te),I})}}function N(S,C,O){S=""+S;var R=new C(S,O);if(!R.valid())throw new h.InvalidInputException(R.constructor.name,S);var I=R.encode();I=(0,i.default)(I);for(var x=0;x<I.length;x++)I[x].options=(0,r.default)(O,I[x].options);return I}function P(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}w.prototype.options=function(S){return this._options=(0,r.default)(this._options,S),this},w.prototype.blank=function(S){var C=new Array(S+1).join("0");return this._encodings.push({data:C}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var S;for(var C in this._renderProperties){S=this._renderProperties[C];var O=(0,r.default)(this._options,S.options);O.format=="auto"&&(O.format=P()),this._errorHandler.wrapBarcodeCall(function(){var R=O.value,I=e.default[O.format.toUpperCase()],x=N(R,I,O);k(S,x,O)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new h.NoElementException;if(Array.isArray(this._renderProperties))for(var S=0;S<this._renderProperties.length;S++)k(this._renderProperties[S],this._encodings,this._options);else k(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=b.default;function k(S,C,O){C=(0,i.default)(C);for(var R=0;R<C.length;R++)C[R].options=(0,r.default)(O,C[R].options),(0,l.default)(C[R].options);(0,l.default)(O);var I=S.renderer,x=new I(S.element,C,O);x.render(),S.afterRender&&S.afterRender()}return typeof window<"u"&&(window.JsBarcode=_),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(S,C){var O=[];return jQuery(this).each(function(){O.push(this)}),_(O,S,C)}),ha=_,ha}var sb=ab();const ga=td(sb);var gn={},ma,du;function lb(){return du||(du=1,ma=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ma}var ba={},Mt={},uu;function Ut(){if(uu)return Mt;uu=1;let t;const e=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Mt.getSymbolSize=function(r){if(!r)throw new Error('"version" cannot be null or undefined');if(r<1||r>40)throw new Error('"version" should be in range from 1 to 40');return r*4+17},Mt.getSymbolTotalCodewords=function(r){return e[r]},Mt.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},Mt.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},Mt.isKanjiModeEnabled=function(){return typeof t<"u"},Mt.toSJIS=function(r){return t(r)},Mt}var ya={},pu;function va(){return pu||(pu=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,o){if(t.isValid(r))return r;try{return e(r)}catch{return o}}})(ya)),ya}var wa,fu;function cb(){if(fu)return wa;fu=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(e){const n=Math.floor(e/8);return(this.buffer[n]>>>7-e%8&1)===1},put:function(e,n){for(let r=0;r<n;r++)this.putBit((e>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),e&&(this.buffer[n]|=128>>>this.length%8),this.length++}},wa=t,wa}var xa,hu;function db(){if(hu)return xa;hu=1;function t(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return t.prototype.set=function(e,n,r,o){const i=e*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},t.prototype.get=function(e,n){return this.data[e*this.size+n]},t.prototype.xor=function(e,n,r){this.data[e*this.size+n]^=r},t.prototype.isReserved=function(e,n){return this.reservedBit[e*this.size+n]},xa=t,xa}var Ea={},gu;function ub(){return gu||(gu=1,(function(t){const e=Ut().getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=e(r),a=i===145?26:Math.ceil((i-13)/(2*o-2))*2,l=[i-7];for(let c=1;c<o-1;c++)l[c]=l[c-1]-a;return l.push(6),l.reverse()},t.getPositions=function(r){const o=[],i=t.getRowColCoords(r),a=i.length;for(let l=0;l<a;l++)for(let c=0;c<a;c++)l===0&&c===0||l===0&&c===a-1||l===a-1&&c===0||o.push([i[l],i[c]]);return o}})(Ea)),Ea}var Sa={},mu;function pb(){if(mu)return Sa;mu=1;const t=Ut().getSymbolSize,e=7;return Sa.getPositions=function(r){const o=t(r);return[[0,0],[o-e,0],[0,o-e]]},Sa}var _a={},bu;function fb(){return bu||(bu=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},t.from=function(o){return t.isValid(o)?parseInt(o,10):void 0},t.getPenaltyN1=function(o){const i=o.size;let a=0,l=0,c=0,s=null,d=null;for(let p=0;p<i;p++){l=c=0,s=d=null;for(let u=0;u<i;u++){let f=o.get(p,u);f===s?l++:(l>=5&&(a+=e.N1+(l-5)),s=f,l=1),f=o.get(u,p),f===d?c++:(c>=5&&(a+=e.N1+(c-5)),d=f,c=1)}l>=5&&(a+=e.N1+(l-5)),c>=5&&(a+=e.N1+(c-5))}return a},t.getPenaltyN2=function(o){const i=o.size;let a=0;for(let l=0;l<i-1;l++)for(let c=0;c<i-1;c++){const s=o.get(l,c)+o.get(l,c+1)+o.get(l+1,c)+o.get(l+1,c+1);(s===4||s===0)&&a++}return a*e.N2},t.getPenaltyN3=function(o){const i=o.size;let a=0,l=0,c=0;for(let s=0;s<i;s++){l=c=0;for(let d=0;d<i;d++)l=l<<1&2047|o.get(s,d),d>=10&&(l===1488||l===93)&&a++,c=c<<1&2047|o.get(d,s),d>=10&&(c===1488||c===93)&&a++}return a*e.N3},t.getPenaltyN4=function(o){let i=0;const a=o.data.length;for(let c=0;c<a;c++)i+=o.data[c];return Math.abs(Math.ceil(i*100/a/5)-10)*e.N4};function n(r,o,i){switch(r){case t.Patterns.PATTERN000:return(o+i)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return i%3===0;case t.Patterns.PATTERN011:return(o+i)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case t.Patterns.PATTERN101:return o*i%2+o*i%3===0;case t.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case t.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(o,i){const a=i.size;for(let l=0;l<a;l++)for(let c=0;c<a;c++)i.isReserved(c,l)||i.xor(c,l,n(o,c,l))},t.getBestMask=function(o,i){const a=Object.keys(t.Patterns).length;let l=0,c=1/0;for(let s=0;s<a;s++){i(s),t.applyMask(s,o);const d=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(s,o),d<c&&(c=d,l=s)}return l}})(_a)),_a}var $o={},yu;function vu(){if(yu)return $o;yu=1;const t=va(),e=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return $o.getBlocksCount=function(o,i){switch(i){case t.L:return e[(o-1)*4+0];case t.M:return e[(o-1)*4+1];case t.Q:return e[(o-1)*4+2];case t.H:return e[(o-1)*4+3];default:return}},$o.getTotalCodewordsCount=function(o,i){switch(i){case t.L:return n[(o-1)*4+0];case t.M:return n[(o-1)*4+1];case t.Q:return n[(o-1)*4+2];case t.H:return n[(o-1)*4+3];default:return}},$o}var Ma={},or={},wu;function hb(){if(wu)return or;wu=1;const t=new Uint8Array(512),e=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)t[o]=r,e[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)t[o]=t[o-255]})(),or.log=function(r){if(r<1)throw new Error("log("+r+")");return e[r]},or.exp=function(r){return t[r]},or.mul=function(r,o){return r===0||o===0?0:t[e[r]+e[o]]},or}var xu;function gb(){return xu||(xu=1,(function(t){const e=hb();t.mul=function(r,o){const i=new Uint8Array(r.length+o.length-1);for(let a=0;a<r.length;a++)for(let l=0;l<o.length;l++)i[a+l]^=e.mul(r[a],o[l]);return i},t.mod=function(r,o){let i=new Uint8Array(r);for(;i.length-o.length>=0;){const a=i[0];for(let c=0;c<o.length;c++)i[c]^=e.mul(o[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},t.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=t.mul(o,new Uint8Array([1,e.exp(i)]));return o}})(Ma)),Ma}var Ta,Eu;function mb(){if(Eu)return Ta;Eu=1;const t=gb();function e(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return e.prototype.initialize=function(r){this.degree=r,this.genPoly=t.generateECPolynomial(this.degree)},e.prototype.encode=function(r){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(r.length+this.degree);o.set(r);const i=t.mod(o,this.genPoly),a=this.degree-i.length;if(a>0){const l=new Uint8Array(this.degree);return l.set(i,a),l}return i},Ta=e,Ta}var ka={},Ca={},Aa={},Su;function _u(){return Su||(Su=1,Aa.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Aa}var at={},Mu;function Tu(){if(Mu)return at;Mu=1;const t="[0-9]+",e="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const r="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
252
+ ]))+`;at.KANJI=new RegExp(n,"g"),at.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),at.BYTE=new RegExp(r,"g"),at.NUMERIC=new RegExp(t,"g"),at.ALPHANUMERIC=new RegExp(e,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return at.testKanji=function(c){return o.test(c)},at.testNumeric=function(c){return i.test(c)},at.testAlphanumeric=function(c){return a.test(c)},at}var ku;function qt(){return ku||(ku=1,(function(t){const e=_u(),n=Tu();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!e.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},t.getBestModeForData=function(i){return n.testNumeric(i)?t.NUMERIC:n.testAlphanumeric(i)?t.ALPHANUMERIC:n.testKanji(i)?t.KANJI:t.BYTE},t.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},t.isValid=function(i){return i&&i.bit&&i.ccBits};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+o)}}t.from=function(i,a){if(t.isValid(i))return i;try{return r(i)}catch{return a}}})(Ca)),Ca}var Cu;function bb(){return Cu||(Cu=1,(function(t){const e=Ut(),n=vu(),r=va(),o=qt(),i=_u(),a=7973,l=e.getBCHDigit(a);function c(u,f,h){for(let m=1;m<=40;m++)if(f<=t.getCapacity(m,h,u))return m}function s(u,f){return o.getCharCountIndicator(u,f)+4}function d(u,f){let h=0;return u.forEach(function(m){const b=s(m.mode,f);h+=b+m.getBitsLength()}),h}function p(u,f){for(let h=1;h<=40;h++)if(d(u,h)<=t.getCapacity(h,f,o.MIXED))return h}t.from=function(f,h){return i.isValid(f)?parseInt(f,10):h},t.getCapacity=function(f,h,m){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=o.BYTE);const b=e.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,h),w=(b-v)*8;if(m===o.MIXED)return w;const _=w-s(m,f);switch(m){case o.NUMERIC:return Math.floor(_/10*3);case o.ALPHANUMERIC:return Math.floor(_/11*2);case o.KANJI:return Math.floor(_/13);case o.BYTE:default:return Math.floor(_/8)}},t.getBestVersionForData=function(f,h){let m;const b=r.from(h,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,b);if(f.length===0)return 1;m=f[0]}else m=f;return c(m.mode,m.getLength(),b)},t.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let h=f<<12;for(;e.getBCHDigit(h)-l>=0;)h^=a<<e.getBCHDigit(h)-l;return f<<12|h}})(ka)),ka}var Oa={},Au;function yb(){if(Au)return Oa;Au=1;const t=Ut(),e=1335,n=21522,r=t.getBCHDigit(e);return Oa.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;t.getBCHDigit(c)-r>=0;)c^=e<<t.getBCHDigit(c)-r;return(l<<10|c)^n},Oa}var Ia={},Pa,Ou;function vb(){if(Ou)return Pa;Ou=1;const t=qt();function e(n){this.mode=t.NUMERIC,this.data=n.toString()}return e.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(r){let o,i,a;for(o=0;o+3<=this.data.length;o+=3)i=this.data.substr(o,3),a=parseInt(i,10),r.put(a,10);const l=this.data.length-o;l>0&&(i=this.data.substr(o),a=parseInt(i,10),r.put(a,l*3+1))},Pa=e,Pa}var Ra,Iu;function wb(){if(Iu)return Ra;Iu=1;const t=qt(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(r){this.mode=t.ALPHANUMERIC,this.data=r}return n.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let i;for(i=0;i+2<=this.data.length;i+=2){let a=e.indexOf(this.data[i])*45;a+=e.indexOf(this.data[i+1]),o.put(a,11)}this.data.length%2&&o.put(e.indexOf(this.data[i]),6)},Ra=n,Ra}var Da,Pu;function xb(){if(Pu)return Da;Pu=1;const t=qt();function e(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return e.getBitsLength=function(r){return r*8},e.prototype.getLength=function(){return this.data.length},e.prototype.getBitsLength=function(){return e.getBitsLength(this.data.length)},e.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},Da=e,Da}var $a,Ru;function Eb(){if(Ru)return $a;Ru=1;const t=qt(),e=Ut();function n(r){this.mode=t.KANJI,this.data=r}return n.getBitsLength=function(o){return o*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let o;for(o=0;o<this.data.length;o++){let i=e.toSJIS(this.data[o]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
253
+ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},$a=n,$a}var Na={exports:{}},Du;function Sb(){return Du||(Du=1,(function(t){var e={single_source_shortest_paths:function(n,r,o){var i={},a={};a[r]=0;var l=e.PriorityQueue.make();l.push(r,0);for(var c,s,d,p,u,f,h,m,b;!l.empty();){c=l.pop(),s=c.value,p=c.cost,u=n[s]||{};for(d in u)u.hasOwnProperty(d)&&(f=u[d],h=p+f,m=a[d],b=typeof a[d]>"u",(b||m>h)&&(a[d]=h,l.push(d,h),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var v=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=e.single_source_shortest_paths(n,r,o);return e.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=e.PriorityQueue,o={},i;n=n||{};for(i in r)r.hasOwnProperty(i)&&(o[i]=r[i]);return o.queue=[],o.sorter=n.sorter||r.default_sorter,o},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var o={value:n,cost:r};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(Na)),Na.exports}var $u;function _b(){return $u||($u=1,(function(t){const e=qt(),n=vb(),r=wb(),o=xb(),i=Eb(),a=Tu(),l=Ut(),c=Sb();function s(v){return unescape(encodeURIComponent(v)).length}function d(v,w,_){const T=[];let z;for(;(z=v.exec(_))!==null;)T.push({data:z[0],index:z.index,mode:w,length:z[0].length});return T}function p(v){const w=d(a.NUMERIC,e.NUMERIC,v),_=d(a.ALPHANUMERIC,e.ALPHANUMERIC,v);let T,z;return l.isKanjiModeEnabled()?(T=d(a.BYTE,e.BYTE,v),z=d(a.KANJI,e.KANJI,v)):(T=d(a.BYTE_KANJI,e.BYTE,v),z=[]),w.concat(_,T,z).sort(function(P,k){return P.index-k.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.length}})}function u(v,w){switch(w){case e.NUMERIC:return n.getBitsLength(v);case e.ALPHANUMERIC:return r.getBitsLength(v);case e.KANJI:return i.getBitsLength(v);case e.BYTE:return o.getBitsLength(v)}}function f(v){return v.reduce(function(w,_){const T=w.length-1>=0?w[w.length-1]:null;return T&&T.mode===_.mode?(w[w.length-1].data+=_.data,w):(w.push(_),w)},[])}function h(v){const w=[];for(let _=0;_<v.length;_++){const T=v[_];switch(T.mode){case e.NUMERIC:w.push([T,{data:T.data,mode:e.ALPHANUMERIC,length:T.length},{data:T.data,mode:e.BYTE,length:T.length}]);break;case e.ALPHANUMERIC:w.push([T,{data:T.data,mode:e.BYTE,length:T.length}]);break;case e.KANJI:w.push([T,{data:T.data,mode:e.BYTE,length:s(T.data)}]);break;case e.BYTE:w.push([{data:T.data,mode:e.BYTE,length:s(T.data)}])}}return w}function m(v,w){const _={},T={start:{}};let z=["start"];for(let N=0;N<v.length;N++){const P=v[N],k=[];for(let S=0;S<P.length;S++){const C=P[S],O=""+N+S;k.push(O),_[O]={node:C,lastCount:0},T[O]={};for(let R=0;R<z.length;R++){const I=z[R];_[I]&&_[I].node.mode===C.mode?(T[I][O]=u(_[I].lastCount+C.length,C.mode)-u(_[I].lastCount,C.mode),_[I].lastCount+=C.length):(_[I]&&(_[I].lastCount=C.length),T[I][O]=u(C.length,C.mode)+4+e.getCharCountIndicator(C.mode,w))}}z=k}for(let N=0;N<z.length;N++)T[z[N]].end=0;return{map:T,table:_}}function b(v,w){let _;const T=e.getBestModeForData(v);if(_=e.from(w,T),_!==e.BYTE&&_.bit<T.bit)throw new Error('"'+v+'" cannot be encoded with mode '+e.toString(_)+`.
254
+ Suggested mode is: `+e.toString(T));switch(_===e.KANJI&&!l.isKanjiModeEnabled()&&(_=e.BYTE),_){case e.NUMERIC:return new n(v);case e.ALPHANUMERIC:return new r(v);case e.KANJI:return new i(v);case e.BYTE:return new o(v)}}t.fromArray=function(w){return w.reduce(function(_,T){return typeof T=="string"?_.push(b(T,null)):T.data&&_.push(b(T.data,T.mode)),_},[])},t.fromString=function(w,_){const T=p(w,l.isKanjiModeEnabled()),z=h(T),N=m(z,_),P=c.find_path(N.map,"start","end"),k=[];for(let S=1;S<P.length-1;S++)k.push(N.table[P[S]].node);return t.fromArray(f(k))},t.rawSplit=function(w){return t.fromArray(p(w,l.isKanjiModeEnabled()))}})(Ia)),Ia}var Nu;function Mb(){if(Nu)return ba;Nu=1;const t=Ut(),e=va(),n=cb(),r=db(),o=ub(),i=pb(),a=fb(),l=vu(),c=mb(),s=bb(),d=yb(),p=qt(),u=_b();function f(N,P){const k=N.size,S=i.getPositions(P);for(let C=0;C<S.length;C++){const O=S[C][0],R=S[C][1];for(let I=-1;I<=7;I++)if(!(O+I<=-1||k<=O+I))for(let x=-1;x<=7;x++)R+x<=-1||k<=R+x||(I>=0&&I<=6&&(x===0||x===6)||x>=0&&x<=6&&(I===0||I===6)||I>=2&&I<=4&&x>=2&&x<=4?N.set(O+I,R+x,!0,!0):N.set(O+I,R+x,!1,!0))}}function h(N){const P=N.size;for(let k=8;k<P-8;k++){const S=k%2===0;N.set(k,6,S,!0),N.set(6,k,S,!0)}}function m(N,P){const k=o.getPositions(P);for(let S=0;S<k.length;S++){const C=k[S][0],O=k[S][1];for(let R=-2;R<=2;R++)for(let I=-2;I<=2;I++)R===-2||R===2||I===-2||I===2||R===0&&I===0?N.set(C+R,O+I,!0,!0):N.set(C+R,O+I,!1,!0)}}function b(N,P){const k=N.size,S=s.getEncodedBits(P);let C,O,R;for(let I=0;I<18;I++)C=Math.floor(I/3),O=I%3+k-8-3,R=(S>>I&1)===1,N.set(C,O,R,!0),N.set(O,C,R,!0)}function v(N,P,k){const S=N.size,C=d.getEncodedBits(P,k);let O,R;for(O=0;O<15;O++)R=(C>>O&1)===1,O<6?N.set(O,8,R,!0):O<8?N.set(O+1,8,R,!0):N.set(S-15+O,8,R,!0),O<8?N.set(8,S-O-1,R,!0):O<9?N.set(8,15-O-1+1,R,!0):N.set(8,15-O-1,R,!0);N.set(S-8,8,1,!0)}function w(N,P){const k=N.size;let S=-1,C=k-1,O=7,R=0;for(let I=k-1;I>0;I-=2)for(I===6&&I--;;){for(let x=0;x<2;x++)if(!N.isReserved(C,I-x)){let j=!1;R<P.length&&(j=(P[R]>>>O&1)===1),N.set(C,I-x,j),O--,O===-1&&(R++,O=7)}if(C+=S,C<0||k<=C){C-=S,S=-S;break}}}function _(N,P,k){const S=new n;k.forEach(function(x){S.put(x.mode.bit,4),S.put(x.getLength(),p.getCharCountIndicator(x.mode,N)),x.write(S)});const C=t.getSymbolTotalCodewords(N),O=l.getTotalCodewordsCount(N,P),R=(C-O)*8;for(S.getLengthInBits()+4<=R&&S.put(0,4);S.getLengthInBits()%8!==0;)S.putBit(0);const I=(R-S.getLengthInBits())/8;for(let x=0;x<I;x++)S.put(x%2?17:236,8);return T(S,N,P)}function T(N,P,k){const S=t.getSymbolTotalCodewords(P),C=l.getTotalCodewordsCount(P,k),O=S-C,R=l.getBlocksCount(P,k),I=S%R,x=R-I,j=Math.floor(S/R),te=Math.floor(O/R),fe=te+1,G=j-te,de=new c(G);let Ke=0;const ye=new Array(R),Fe=new Array(R);let D=0;const L=new Uint8Array(N.buffer);for(let ne=0;ne<R;ne++){const Q=ne<x?te:fe;ye[ne]=L.slice(Ke,Ke+Q),Fe[ne]=de.encode(ye[ne]),Ke+=Q,D=Math.max(D,Q)}const W=new Uint8Array(S);let V=0,Y,X;for(Y=0;Y<D;Y++)for(X=0;X<R;X++)Y<ye[X].length&&(W[V++]=ye[X][Y]);for(Y=0;Y<G;Y++)for(X=0;X<R;X++)W[V++]=Fe[X][Y];return W}function z(N,P,k,S){let C;if(Array.isArray(N))C=u.fromArray(N);else if(typeof N=="string"){let j=P;if(!j){const te=u.rawSplit(N);j=s.getBestVersionForData(te,k)}C=u.fromString(N,j||40)}else throw new Error("Invalid data");const O=s.getBestVersionForData(C,k);if(!O)throw new Error("The amount of data is too big to be stored in a QR Code");if(!P)P=O;else if(P<O)throw new Error(`
255
255
  The chosen QR Code version cannot contain this amount of data.
256
256
  Minimum version required to store current data is: `+O+`.
257
- `);const R=_(P,k,C),I=t.getSymbolSize(P),x=new r(I);return f(x,P),h(x),m(x,P),v(x,k,0),P>=7&&b(x,P),w(x,R),isNaN(S)&&(S=a.getBestMask(x,v.bind(null,x,k))),a.applyMask(S,x),v(x,k,S),{modules:x,version:P,errorCorrectionLevel:k,maskPattern:S,segments:C}}return ma.create=function(P,k){if(typeof P>"u"||P==="")throw new Error("No input text");let S=e.M,C,O;return typeof k<"u"&&(S=e.from(k.errorCorrectionLevel,e.M),C=s.from(k.version),O=a.from(k.maskPattern),k.toSJISFunc&&t.setToSJISFunction(k.toSJISFunc)),z(P,C,S,O)},ma}var Na={},La={},Nu;function Lu(){return Nu||(Nu=1,(function(t){function e(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:i,scale:i?4:a,margin:o,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},t.getImageWidth=function(r,o){const i=t.getScale(r,o);return Math.floor((r+o.margin*2)*i)},t.qrToImageData=function(r,o,i){const a=o.modules.size,l=o.modules.data,c=t.getScale(a,i),s=Math.floor((a+i.margin*2)*c),d=i.margin*c,p=[i.color.light,i.color.dark];for(let u=0;u<s;u++)for(let f=0;f<s;f++){let h=(u*s+f)*4,m=i.color.light;if(u>=d&&f>=d&&u<s-d&&f<s-d){const b=Math.floor((u-d)/c),v=Math.floor((f-d)/c);m=p[l[b*a+v]?1:0]}r[h++]=m.r,r[h++]=m.g,r[h++]=m.b,r[h]=m.a}}})(La)),La}var Fu;function Tb(){return Fu||(Fu=1,(function(t){const e=Lu();function n(o,i,a){o.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=a,i.width=a,i.style.height=a+"px",i.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(i,a,l){let c=l,s=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(s=r()),c=e.getOptions(c);const d=e.getImageWidth(i.modules.size,c),p=s.getContext("2d"),u=p.createImageData(d,d);return e.qrToImageData(u.data,i,c),n(p,s,d),p.putImageData(u,0,0),s},t.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const s=t.render(i,a,c),d=c.type||"image/png",p=c.rendererOpts||{};return s.toDataURL(d,p.quality)}})(Na)),Na}var Fa={},zu;function kb(){if(zu)return Fa;zu=1;const t=Lu();function e(o,i){const a=o.a/255,l=i+'="'+o.hex+'"';return a<1?l+" "+i+'-opacity="'+a.toFixed(2).slice(1)+'"':l}function n(o,i,a){let l=o+i;return typeof a<"u"&&(l+=" "+a),l}function r(o,i,a){let l="",c=0,s=!1,d=0;for(let p=0;p<o.length;p++){const u=Math.floor(p%i),f=Math.floor(p/i);!u&&!s&&(s=!0),o[p]?(d++,p>0&&u>0&&o[p-1]||(l+=s?n("M",u+a,.5+f+a):n("m",c,0),c=0,s=!1),u+1<i&&o[p+1]||(l+=n("h",d),d=0)):c++}return l}return Fa.render=function(i,a,l){const c=t.getOptions(a),s=i.modules.size,d=i.modules.data,p=s+c.margin*2,u=c.color.light.a?"<path "+e(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",f="<path "+e(c.color.dark,"stroke")+' d="'+r(d,s,c.margin)+'"/>',h='viewBox="0 0 '+p+" "+p+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+h+' shape-rendering="crispEdges">'+u+f+`</svg>
258
- `;return typeof l=="function"&&l(null,b),b},Fa}var Bu;function Cb(){if(Bu)return gn;Bu=1;const t=lb(),e=Mb(),n=Tb(),r=kb();function o(i,a,l,c,s){const d=[].slice.call(arguments,1),p=d.length,u=typeof d[p-1]=="function";if(!u&&!t())throw new Error("Callback required as last argument");if(u){if(p<2)throw new Error("Too few arguments provided");p===2?(s=l,l=a,a=c=void 0):p===3&&(a.getContext&&typeof s>"u"?(s=c,c=void 0):(s=c,c=l,l=a,a=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(l=a,a=c=void 0):p===2&&!a.getContext&&(c=l,l=a,a=void 0),new Promise(function(f,h){try{const m=e.create(l,c);f(i(m,a,c))}catch(m){h(m)}})}try{const f=e.create(l,c);s(null,i(f,a,c))}catch(f){s(f)}}return gn.create=e.create,gn.toCanvas=o.bind(null,n.render),gn.toDataURL=o.bind(null,n.renderToDataURL),gn.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),gn}var Ab=Cb();const Ob=ed(Ab),Hu="http://www.w3.org/2000/svg";function Ib(t){const e=t.getAttribute("viewBox");if(!e)return null;const n=e.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))?null:{width:n[2],height:n[3]}}function Pb(t,e){const n=document.createElementNS(Hu,"svg"),r=Pn(e.barWidth),o=ci(e.barQuietZone),i=l=>{ha(n,t,{format:e.barcodeType||"CODE128",width:r,height:l*r,displayValue:e.showText!==!1,fontSize:(e.fontSize??Er)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:di*r});const c=Ib(n);return c?{widthUnits:c.width,heightUnits:c.height}:null},a=pi({barHeightMm:e.barHeightMm,boxWidthMm:e.targetWidthMm??0,boxHeightMm:e.targetHeightMm??0,dpi:e.printerDpi,barWidth:e.barWidth,measure:i});return a.size&&(n.setAttribute("width",`${a.size.widthMm}mm`),n.setAttribute("height",`${a.size.heightMm}mm`)),n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}function Rb(t){return typeof t=="number"&&Number.isFinite(t)?Math.max(0,Math.floor(t)):Vs}function Db(t,e){const n=(e.qrCodeLevel??"M").toUpperCase(),o=Ob.create(t,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=Rb(e.qrQuietZone)*a,c=i*a+l*2;let s="";for(let d=0;d<i;d++)for(let p=0;p<i;p++)o.get(p,d)&&(s+=`<rect x="${l+p*a}" y="${l+d*a}" width="${a}" height="${a}" fill="#000"/>`);return`<svg xmlns="${Hu}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function Uu(t,e,n={}){if(!t)throw new Error("empty barcode value");return e==="qrcode"?Db(t,n):Pb(t,n)}const za={render(t,e,n={}){return Uu(t,e,n)}},Ba=.5,$b=12;function Ha(t,e){const n=t.getAttribute(e);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function qu(t,e){if(t.scrollWidth>t.clientWidth+Ba)return!0;const n=t.scrollHeight;return e!==void 0?n>e+Ba:n>t.clientHeight+Ba}function Wu(t){if(t.getAttribute("data-fit")!=="shrink")return;const e=Cn(Ha(t,"data-fit-min")),n=Math.max(Ha(t,"data-fit-base")??e,e),r=Ha(t,"data-fit-mm"),o=r!==void 0&&r>0?$t(r):void 0,i=s=>{const d=Ff(s);return t.style.fontSize=`${d}pt`,t.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!qu(t,o)||n<=e)return a;let l=e,c=n;for(let s=0;s<$b;s++){const d=(l+c)/2;i(d),qu(t,o)?c=d:l=d}return i(l)}function Nb(t){const e=[];return t.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=Wu(n),o=n.getAttribute("data-fit-key");r===void 0||!o||e.push({key:o,fontSizePt:r})}),e}const Lb="2",Fb=5e3;async function zb(t,e=Fb){const n=t.document,r=i=>Promise.race([i,new Promise(a=>setTimeout(a,e))]),o=(async()=>{n.readyState!=="complete"&&await r(new Promise(a=>t.addEventListener("load",()=>a(),{once:!0})));const i=n.fonts;i&&(await r(Promise.all(Bb(n).map(a=>i.load(`${a.style} ${a.weight} 16px "${a.family}"`).catch(()=>{})))),i.ready&&await r(i.ready)),await r(Promise.all(Array.from(n.images??[]).map(a=>a.complete?Promise.resolve():new Promise(l=>{a.addEventListener("load",()=>l(),{once:!0}),a.addEventListener("error",()=>l(),{once:!0})}))))})();await r(o)}function Bb(t){const e=[];for(const r of Array.from(t.styleSheets??[])){let o;try{o=r.cssRules}catch{continue}for(const i of Array.from(o??[])){if(i.type!==5)continue;const a=i.style,l=(a.getPropertyValue("font-family")||"").replace(/^["']|["']$/g,"");l&&e.push({family:l,weight:a.getPropertyValue("font-weight")||"400",style:a.getPropertyValue("font-style")||"normal"})}}return e}function Hb(t){const e=[];return t.querySelectorAll("[data-measure-id]").forEach(n=>{const r=n,o=r.getAttribute("data-measure-id");if(!o)return;const i=r.getBoundingClientRect().height,a=r.querySelector("table.print-table");if(!a){e.push({id:o,heightPx:i});return}const l=[];a.querySelectorAll("tbody > tr[data-row-index]").forEach(c=>{l.push(c.getBoundingClientRect().height)}),e.push({id:o,heightPx:i,rowHeightsPx:l})}),e}function Ub(t){const e=t.querySelector(".print-page"),n=t.querySelector(".content-area");if(!e||!n)return 0;const r=e.getBoundingClientRect().top;let o=0;n.querySelectorAll("*").forEach(a=>{const l=a.getBoundingClientRect();l.height>0&&(o=Math.max(o,l.bottom-r))});const i=n.getBoundingClientRect();return i.height>0&&(o=Math.max(o,i.bottom-r)),o}function qb(t){const e={};for(const n of t)try{e[n.key]=Uu(n.value,n.cellType,n.opts)}catch{}return e}const Wb={version:Lb,waitReady:zb,readMeasurements:Hb,readContentBottom:Ub,renderCodes:qb,applyTextFit:Nb};function jb(){return{async createDriver(){const t=document.createElement("iframe");t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-10000px;top:0;border:0;visibility:hidden;pointer-events:none;",document.body.appendChild(t);let e=t.contentDocument??document;return{requiresExecutor:!1,async open(n){t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,e=t.contentDocument??document},async setContent(n){e=t.contentDocument??document,e.open(),e.write(n),e.close()},async injectExecutor(n){},async evaluate(n,r){const o=Wb[n],i=r??[],a=Dm[n];return a==="window"?o(t.contentWindow,...i):a==="document"?o(e,...i):o(...i)},async close(){t.remove()}}}}}function Gb(){return Lm(jb())}async function Yb(t,e,n,r,o){const i=await Vm({templateJson:t,printData:e,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r},Gb());return{html:i.html,pageCount:i.pageCount,pageLayouts:i.pageLayouts,paperMm:i.paperMm,continuous:i.continuous,copies:i.copies,copyPaperMm:i.copyPaperMm}}function g(t,e={},n=[]){return{tag:t,props:e,children:n}}const ju="http://www.w3.org/2000/svg",Vb=new Set(["draggable","contenteditable","spellcheck"]),Xb=new Set(["indeterminate"]);function Kb(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function Re(t,e){if(typeof t=="string"){const a=document.createTextNode(t);return e.appendChild(a),a}if(t instanceof Node)return e.appendChild(t),t;const{tag:n,props:r,children:o}=t,i=Kb(n)?document.createElementNS(ju,n):document.createElement(n);for(const[a,l]of Object.entries(r))if(!(l==null||l===!1))if(a==="class")i.setAttribute("class",String(l));else if(a==="style")typeof l=="string"?i.style.cssText=l:Object.assign(i.style,l);else if(a==="html")i.innerHTML=String(l);else if(a==="text")i.textContent=String(l);else if(a.startsWith("on")&&typeof l=="function")i.addEventListener(a.slice(2).toLowerCase(),l);else if(a==="dataset")for(const[c,s]of Object.entries(l))i.dataset[c]=s;else Xb.has(a)?i[a]=!0:typeof l=="boolean"?l&&i.setAttribute(a,Vb.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)Re(a,i);return e.appendChild(i),i}function Gu(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const Zb=ju;function ir(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const Ua="开启拼版后只能有一个设计页面";function qa(t){const e=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&Nn(i),{id:o.id||sn(),zone:r,options:i,printElementType:{...o.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},guides:[...t.guides??[]],elements:[...e(t.elements??[],"content"),...e(t.header?.elements??[],"header"),...e(t.footer?.elements??[],"footer")]}}function Yu(t){const e=t.elements,n=r=>e.filter(o=>(o.zone||"content")===r).map(o=>({id:o.id,type:o.printElementType.type,options:{...o.options},printElementType:{...o.printElementType}}));return{unit:"mm",...t,header:{...t.header,elements:n("header")},footer:{...t.footer,elements:n("footer")},elements:n("content"),guides:[...t.guides??[]]}}function Vu(t){const e=(r,o)=>{const i=qa(Th(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!t)return[e(ir(),0)];const n=Array.isArray(t.pages)?t.pages:[t];return n.length?n.map(e):[e(ir(),0)]}const mn=t=>JSON.parse(JSON.stringify(t));class Xu{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=v0();group=w0();constructor(e={}){if(this.pages=Vu(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const n=this.pages[0];n.elements=[...n.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const n of[...this.listeners])n()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(Ua);return}this.recordHistory();const e=this.pages[this.activePageIndex]??ir();this.pages.push(qa({...ir(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(r=>r.name));let n=this.pages.length+1;for(;e.has(`页面 ${n}`);)n++;return`页面 ${n}`}duplicatePage(e){if(this.tilingEnabled){window.alert(Ua);return}this.recordHistory();const n=mn(this.pages[e]);n.name=`${n.name??`页面 ${e+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:sn()})),this.pages.splice(e+1,0,n),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,n){this.recordHistory(),this.pages[e].name=n,this.emit()}movePage(e,n){if(n<0||n>=this.pages.length||e===n)return;this.recordHistory();const[r]=this.pages.splice(e,1);this.pages.splice(n,0,r),this.activePageIndex=n,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,n=!1){if(n){const r=new Set(this.selectedIds);r.has(e)?r.delete(e):r.add(e),this.setSelection(r)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,n=!1){if(n){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(n=>n.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,n){const r=this.templateData.guides??[];this.templateData.guides=[...r,{id:sn(),type:e,position:Math.round(n*10)/10}],this.emit()}moveGuide(e,n){const r=this.templateData.guides??[];this.templateData.guides=r.map(o=>o.id===e?{...o,position:Math.round(n*10)/10}:o),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(n=>n.id!==e),this.emit()}addElement(e,n={},r){const o=$l(e,n);return r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}addFieldElement(e,n={},r){const o=m0(e);return Object.assign(o.options,n),r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}placeAtDropPoint(e,n){const r=this.templateData,o=Ll(r,n.x,n.y);if(o!=="content"&&!Nl.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Pi(r)[o];return e.zone=o,e.options.left=n.x-i.left,e.options.top=n.y-i.top,o!=="content"&&Ri(e,i),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,n){const r=this.templateData.elements.find(i=>i.id===e);if(!r)return;const o=this.live.get(e)??r;this.live.set(e,{...o,options:{...o.options,...n}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[n,r]of this.live){const o=e.find(i=>i.id===n);o&&Object.assign(o.options,r.options)}this.live.clear(),this.emit()}dragIds(e){const n=this.templateData.elements.find(r=>r.id===e);return!n||n.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let n=!1;for(const r of this.elements){const o=e.get(r.id);!o||o===this.geoSig(r)||sg(r,this.templateData).rejected&&(n=!0)}n&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,n,r=!0){r&&this.recordHistory();const o=this.templateData.elements.find(i=>i.id===e);o&&(Object.assign(o.options,n),o.printElementType.type==="table"&&Nn(o.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const n=this.templateData.elements,r=n.filter(i=>this.selectedIds.has(i.id)),o=n.filter(i=>!this.selectedIds.has(i.id));if(e==="top")this.templateData.elements=[...o,...r];else if(e==="bottom")this.templateData.elements=[...r,...o];else{const i=n.findIndex(c=>this.selectedIds.has(c.id)),a=e==="up"?i+1:i-1;if(a<0||a>=n.length)return;const l=[...n];[l[i],l[a]]=[l[a],l[i]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(n=>this.selectedIds.has(n.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=mn(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const n=new Map;for(const i of this.clipboard){const a=i.options.groupId;a&&n.set(a,(n.get(a)??0)+1)}const r=new Map;for(const[i,a]of n)r.set(i,a>=2?Qc():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=mn(i);a.id=sn(),a.options.left+=e,a.options.top+=e,a.options.groupId=a.options.groupId?r.get(a.options.groupId):void 0,o.push(a)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,n){const r=this.selectedElements.filter(o=>!o.options.locked);if(r.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const o of r)o.options.left+=e,o.options.top+=n;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();e&&(this.redoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,n=Tr){this.scale=Math.max(n,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(Yu),n=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(n)}loadTemplate(e){this.pages=Vu(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return Et(this.templateData)}}const Wt=Symbol("mixed"),Wa=new Set(["text","longText"]),Jb=["top","right","bottom","left"],Qb={on:!0,off:!1,mixed:Wt};function Ku(t){const e=Ml(t),n={};for(const r of Jb)n[r]=Qb[e[r]];return n}const e1=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class t1{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(n=>n.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!e||!n)return[];const r=[];for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const a=n[o]?.cells[i];a&&!a.merged&&r.push(a)}return r}get textTargets(){return this.selectedElements.filter(e=>Wa.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const n=e[0];return e.every(r=>r===n)?n:Wt}hasToken(e,n){return(e??"").split(/\s+/).includes(n)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const n=e.map(o=>o.fontWeight==="bold"||o.fontWeight==="bolder"),r=e.map(o=>o.textDecoration);return{fontFamily:this.pick(e.map(o=>o.fontFamily)),fontSize:this.pick(e.map(o=>o.fontSize)),color:this.pick(e.map(o=>o.color)),backgroundColor:this.pick(e.map(o=>o.backgroundColor)),textAlign:this.pick(e.map(o=>this.context==="cells"?o.align:o.textAlign)),verticalAlign:this.pick(e.map(o=>this.context==="cells"?o.valign:o.verticalAlign)),bold:n.every(Boolean)?!0:n.some(Boolean)?Wt:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?Wt:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?Wt:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const n=this.targetCells;n.length&&(n.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const n=this.textTargets,r=this.selectedElements,i=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),a="backgroundColor"in e;!(n.length&&i)&&!(r.length&&a)||(n.forEach(l=>{const c=l.options;"fontFamily"in e&&(c.fontFamily=e.fontFamily),"fontSize"in e&&(c.fontSize=e.fontSize),"color"in e&&(c.color=e.color),"textAlign"in e&&(c.textAlign=e.textAlign),"verticalAlign"in e&&(c.verticalAlign=e.verticalAlign)}),a&&r.forEach(l=>{l.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const r=this.values.bold!==!0;this.writeCells(o=>{o.fontWeight=r?"bold":void 0});return}const e=this.values.bold!==!0,n=this.textTargets;n.length&&(n.forEach(r=>{r.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const n=this.textTargets;if(!n.length)return;const r=this.values[e==="underline"?"underline":"strike"]!==!0;n.forEach(o=>{const i=(o.options.textDecoration??"").split(/\s+/).filter(Boolean),a=i.indexOf(e);r&&a<0&&i.push(e),!r&&a>=0&&i.splice(a,1),o.options.textDecoration=i.length?i.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const e=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!e||!n)return;const r=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(r===this.borderDraftKey)return;if(this.borderDraftKey=r,Mi(n,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const o=Sl(n,e);if(o.style===void 0&&o.width===void 0&&o.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:o.style==="mixed",width:o.width==="mixed",color:o.color==="mixed"},this.borderMixed.style?this.borderStyle=null:o.style===void 0?this.borderStyle="solid":o.style==="none"?this.borderStyle=null:this.borderStyle=o.style,this.borderWidth=this.borderMixed.width?void 0:typeof o.width=="number"?o.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof o.color=="string"?o.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const n=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=n,n===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{Tl(o.options,e,n)}),this.commit())}applyCellBorderPreset(e,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||(xl(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},e,n),this.commit())}applyCellBorderEdges(e,n,r){this.writeCells(o=>{for(const i of e)El(o,i,r?n:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?Ku(e.map(n=>n.borders)):null}toggleCellEdge(e,n){const r=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],n,r)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?Ku(e.map(n=>Wh(n.options))):null}toggleElementEdge(e,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[e]!==!0;r.forEach(i=>Ai(i.options,e,o,n)),this.commit()}applyBorderPreset(e){const n=this.borderStyle===null;if(this.context==="cells"){const r=n&&!this.borderMixed.style;this.applyCellBorderPreset(r?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(n||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const n=this.selectedElements;n.length&&(n.forEach(r=>Ai(r.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const n={};for(const r of _r){const o=e[r];o&&(n[r]={...o})}return n}pickPainterSource(e=!1){const n=this.selectedElements[0];if(!n)return!1;const r=n.options,o=n.printElementType.type;return this.painterSnapshot={text:Wa.has(o)?Object.fromEntries(e1.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:fi(o)?{borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:this.clonePainterBorders(r.borders)}:null},this.painterSource=n.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const n=this.painterSnapshot;if(!n||e.options.locked||e.id===this.painterSource)return!1;const r=e.options,o=e.printElementType.type;return n.text&&Wa.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&fi(o)&&(r.borderWidth=n.border.borderWidth,r.borderStyle=n.border.borderStyle,r.borderColor=n.border.borderColor,r.borders=this.clonePainterBorders(n.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let n=!1;e.forEach(r=>{n=this.applyPainter(r)||n}),n&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const n=e.target?.tagName;n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||this.cancelPainter()}}function Zu(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function n1(t){if(Array.isArray(t))return t}function r1(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==e);c=!0);}catch(d){s=!0,o=d}finally{try{if(!c&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}function o1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
259
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function i1(t,e){return n1(t)||r1(t,e)||a1(t,e)||o1()}function a1(t,e){if(t){if(typeof t=="string")return Zu(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Zu(t,e):void 0}}const Ju=Object.entries,Qu=Object.setPrototypeOf,s1=Object.isFrozen,l1=Object.getPrototypeOf,c1=Object.getOwnPropertyDescriptor;let Se=Object.freeze,Te=Object.seal,bn=Object.create,ep=typeof Reflect<"u"&&Reflect,ja=ep.apply,Ga=ep.construct;Se||(Se=function(e){return e}),Te||(Te=function(e){return e}),ja||(ja=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(n,o)}),Ga||(Ga=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new e(...r)});const jt=xe(Array.prototype.forEach),d1=xe(Array.prototype.lastIndexOf),tp=xe(Array.prototype.pop),ar=xe(Array.prototype.push),u1=xe(Array.prototype.splice),yn=Array.isArray,sr=xe(String.prototype.toLowerCase),Ya=xe(String.prototype.toString),np=xe(String.prototype.match),lr=xe(String.prototype.replace),rp=xe(String.prototype.indexOf),p1=xe(String.prototype.trim),f1=xe(Number.prototype.toString),h1=xe(Boolean.prototype.toString),op=typeof BigInt>"u"?null:xe(BigInt.prototype.toString),ip=typeof Symbol>"u"?null:xe(Symbol.prototype.toString),$e=xe(Object.prototype.hasOwnProperty),cr=xe(Object.prototype.toString),ke=xe(RegExp.prototype.test),Gt=g1(TypeError);function xe(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return ja(t,e,r)}}function g1(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Ga(t,n)}}function oe(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:sr;if(Qu&&Qu(t,null),!yn(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){const i=n(o);i!==o&&(s1(e)||(e[r]=i),o=i)}t[o]=!0}return t}function m1(t){for(let e=0;e<t.length;e++)$e(t,e)||(t[e]=null);return t}function Ge(t){const e=bn(null);for(const r of Ju(t)){var n=i1(r,2);const o=n[0],i=n[1];$e(t,o)&&(yn(i)?e[o]=m1(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Ge(i):e[o]=i)}return e}function b1(t){switch(typeof t){case"string":return t;case"number":return f1(t);case"boolean":return h1(t);case"bigint":return op?op(t):"0";case"symbol":return ip?ip(t):"Symbol()";case"undefined":return cr(t);case"function":case"object":{if(t===null)return cr(t);const e=t,n=Qe(e,"toString");if(typeof n=="function"){const r=n(e);return typeof r=="string"?r:cr(r)}return cr(t)}default:return cr(t)}}function Qe(t,e){for(;t!==null;){const r=c1(t,e);if(r){if(r.get)return xe(r.get);if(typeof r.value=="function")return xe(r.value)}t=l1(t)}function n(){return null}return n}function y1(t){try{return ke(t,""),!0}catch{return!1}}const ap=Se(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Va=Se(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Xa=Se(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),v1=Se(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ka=Se(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),w1=Se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),sp=Se(["#text"]),lp=Se(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Za=Se(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),cp=Se(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),No=Se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),x1=Te(/{{[\w\W]*|^[\w\W]*}}/g),E1=Te(/<%[\w\W]*|^[\w\W]*%>/g),S1=Te(/\${[\w\W]*/g),_1=Te(/^data-[\-\w.\u00B7-\uFFFF]+$/),M1=Te(/^aria-[\-\w]+$/),dp=Te(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),T1=Te(/^(?:\w+script|data):/i),k1=Te(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),C1=Te(/^html$/i),A1=Te(/^[a-z][.\w]*(-[.\w]+)+$/i),up=Te(/<[/\w!]/g),pp=Te(/<[/\w]/g),O1=Te(/<\/no(script|embed|frames)/i),I1=Te(/\/>/i),Ye={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},fp=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],P1=Se(oe({},fp)),R1=(function(){const t={};return jt(fp,e=>{t[e]=Te(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),Se(t)})(),D1=function(){return typeof window>"u"?null:window},$1=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},hp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Tt=function(e,n,r,o){return $e(e,n)&&yn(e[n])?oe(o.base?Ge(o.base):{},e[n],o.transform):r},Ja=function(e,n,r){const o=$e(e,n)?e[n]:void 0;return o&&typeof o=="object"?Ge(o):r()};function gp(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:D1();const e=$=>gp($);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ye.document||!t.Element)return e.isSupported=!1,e;let n=t.document;const r=n,o=r.currentScript;t.DocumentFragment;const i=t.HTMLTemplateElement,a=t.Node,l=t.Element,c=t.NodeFilter,s=t.NamedNodeMap;s===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const d=t.DOMParser,p=t.trustedTypes,u=l.prototype,f=Qe(u,"cloneNode"),h=Qe(u,"remove"),m=Qe(u,"nextSibling"),b=Qe(u,"childNodes"),v=Qe(u,"parentNode"),w=Qe(u,"shadowRoot"),_=Qe(u,"attributes"),T=a&&a.prototype?Qe(a.prototype,"nodeType"):null,z=a&&a.prototype?Qe(a.prototype,"nodeName"):null,N=a&&a.prototype?Qe(a.prototype,"ownerDocument"):null,P=function(y){return T?T(y):y.nodeType},k=function(y){return z?z(y):y.nodeName};if(typeof i=="function"){const $=n.createElement("template");$.content&&$.content.ownerDocument&&(n=$.content.ownerDocument)}let S,C="",O,R=!1,I=0;const x=function(){if(I>0)throw Gt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},j=function(y){x(),I++;try{return S.createHTML(y)}finally{I--}},te=function(y){x(),I++;try{return S.createScriptURL(y)}finally{I--}},fe=function(){return R||(O=$1(p,o),R=!0),O},G=n,de=G.implementation,Ke=G.createNodeIterator,ye=G.createDocumentFragment,Fe=G.getElementsByTagName,D=r.importNode;let L=hp();e.isSupported=typeof Ju=="function"&&typeof v=="function"&&de&&de.createHTMLDocument!==void 0;const W=x1,V=E1,Y=S1,X=_1,ne=M1,Q=T1,se=k1,he=A1;let _e=dp,K=null;const yt=oe({},[...ap,...Va,...Xa,...Ka,...sp]);let ee=null;const lt=oe({},[...lp,...Za,...cp,...No]);let Me=Object.seal(bn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Ee=null;const re=Object.seal(bn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ot=!0,It=!0,M=!1,J=!0,ue=!1,le=!0,ze=!1,Pt=!1,pe=null,ve=null,mr=!1,Rt=!1,Xo=!1,Ko=!1,pf=!0,ff=!1;const hf="user-content-";let Cs=!0,As=!1,Sn={},_n=null;const gf=oe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let mf=null;const bf=oe({},["audio","video","img","source","image","track"]);let yf=null;const vf=oe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Zo="http://www.w3.org/1998/Math/MathML",Jo="http://www.w3.org/2000/svg",ct="http://www.w3.org/1999/xhtml";let Mn=ct,Os=!1,Is=null;const Tw=oe({},[Zo,Jo,ct],Ya),wf=Se(["mi","mo","mn","ms","mtext"]);let Ps=oe({},wf);const xf=Se(["annotation-xml"]);let Rs=oe({},xf);const kw=oe({},["title","style","font","a","script"]);let br=null;const Cw=["application/xhtml+xml","text/html"],Aw="text/html";let we=null,Tn=null;const Ow=n.createElement("form"),Ef=function(y){return y instanceof RegExp||y instanceof Function},Ds=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tn&&Tn===y)return;(!y||typeof y!="object")&&(y={}),y=Ge(y),br=Cw.indexOf(y.PARSER_MEDIA_TYPE)===-1?Aw:y.PARSER_MEDIA_TYPE,we=br==="application/xhtml+xml"?Ya:sr,K=Tt(y,"ALLOWED_TAGS",yt,{transform:we}),ee=Tt(y,"ALLOWED_ATTR",lt,{transform:we}),Is=Tt(y,"ALLOWED_NAMESPACES",Tw,{transform:Ya}),yf=Tt(y,"ADD_URI_SAFE_ATTR",vf,{transform:we,base:vf}),mf=Tt(y,"ADD_DATA_URI_TAGS",bf,{transform:we,base:bf}),_n=Tt(y,"FORBID_CONTENTS",gf,{transform:we}),Ae=Tt(y,"FORBID_TAGS",Ge({}),{transform:we}),Ee=Tt(y,"FORBID_ATTR",Ge({}),{transform:we}),Sn=$e(y,"USE_PROFILES")?y.USE_PROFILES&&typeof y.USE_PROFILES=="object"?Ge(y.USE_PROFILES):y.USE_PROFILES:!1,Ot=y.ALLOW_ARIA_ATTR!==!1,It=y.ALLOW_DATA_ATTR!==!1,M=y.ALLOW_UNKNOWN_PROTOCOLS||!1,J=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ue=y.SAFE_FOR_TEMPLATES||!1,le=y.SAFE_FOR_XML!==!1,ze=y.WHOLE_DOCUMENT||!1,Rt=y.RETURN_DOM||!1,Xo=y.RETURN_DOM_FRAGMENT||!1,Ko=y.RETURN_TRUSTED_TYPE||!1,mr=y.FORCE_BODY||!1,pf=y.SANITIZE_DOM!==!1,ff=y.SANITIZE_NAMED_PROPS||!1,Cs=y.KEEP_CONTENT!==!1,As=y.IN_PLACE||!1,_e=y1(y.ALLOWED_URI_REGEXP)?y.ALLOWED_URI_REGEXP:dp,Mn=typeof y.NAMESPACE=="string"?y.NAMESPACE:ct,Ps=Ja(y,"MATHML_TEXT_INTEGRATION_POINTS",()=>oe({},wf)),Rs=Ja(y,"HTML_INTEGRATION_POINTS",()=>oe({},xf));const E=Ja(y,"CUSTOM_ELEMENT_HANDLING",()=>bn(null));if(Me=bn(null),$e(E,"tagNameCheck")&&Ef(E.tagNameCheck)&&(Me.tagNameCheck=E.tagNameCheck),$e(E,"attributeNameCheck")&&Ef(E.attributeNameCheck)&&(Me.attributeNameCheck=E.attributeNameCheck),$e(E,"allowCustomizedBuiltInElements")&&typeof E.allowCustomizedBuiltInElements=="boolean"&&(Me.allowCustomizedBuiltInElements=E.allowCustomizedBuiltInElements),Te(Me),ue&&(It=!1),Xo&&(Rt=!0),Sn&&(K=oe({},sp),ee=bn(null),Sn.html===!0&&(oe(K,ap),oe(ee,lp)),Sn.svg===!0&&(oe(K,Va),oe(ee,Za),oe(ee,No)),Sn.svgFilters===!0&&(oe(K,Xa),oe(ee,Za),oe(ee,No)),Sn.mathMl===!0&&(oe(K,Ka),oe(ee,cp),oe(ee,No))),re.tagCheck=null,re.attributeCheck=null,$e(y,"ADD_TAGS")&&(typeof y.ADD_TAGS=="function"?re.tagCheck=y.ADD_TAGS:yn(y.ADD_TAGS)&&(K===yt&&(K=Ge(K)),oe(K,y.ADD_TAGS,we))),$e(y,"ADD_ATTR")&&(typeof y.ADD_ATTR=="function"?re.attributeCheck=y.ADD_ATTR:yn(y.ADD_ATTR)&&(ee===lt&&(ee=Ge(ee)),oe(ee,y.ADD_ATTR,we))),$e(y,"ADD_FORBID_CONTENTS")&&yn(y.ADD_FORBID_CONTENTS)&&(_n===gf&&(_n=Ge(_n)),oe(_n,y.ADD_FORBID_CONTENTS,we)),Cs&&(K["#text"]=!0),ze&&oe(K,["html","head","body"]),K.table&&(oe(K,["tbody"]),delete Ae.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=S;S=y.TRUSTED_TYPES_POLICY;try{C=j("")}catch(F){throw S=A,F}}else y.TRUSTED_TYPES_POLICY===null?(S=void 0,C=""):(S===void 0&&(S=fe()),S&&typeof C=="string"&&(C=j("")));Se&&Se(y),Tn=y},Sf=oe({},[...Va,...Xa,...v1]),_f=oe({},[...Ka,...w1]),Iw=function(y,E,A){return E.namespaceURI===ct?y==="svg":E.namespaceURI===Zo?y==="svg"&&(A==="annotation-xml"||Ps[A]):!!Sf[y]},Pw=function(y,E,A){return E.namespaceURI===ct?y==="math":E.namespaceURI===Jo?y==="math"&&Rs[A]:!!_f[y]},Rw=function(y,E,A){return E.namespaceURI===Jo&&!Rs[A]||E.namespaceURI===Zo&&!Ps[A]?!1:!_f[y]&&(kw[y]||!Sf[y])},Dw=function(y){let E=v(y);(!E||!E.tagName)&&(E={namespaceURI:Mn,tagName:"template"});const A=sr(y.tagName),F=sr(E.tagName);return Is[y.namespaceURI]?y.namespaceURI===Jo?Iw(A,E,F):y.namespaceURI===Zo?Pw(A,E,F):y.namespaceURI===ct?Rw(A,E,F):!!(br==="application/xhtml+xml"&&Is[y.namespaceURI]):!1},Dt=function(y){ar(e.removed,{element:y});try{v(y).removeChild(y)}catch{if(h(y),!v(y))throw Gt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Mf=function(y,E,A){try{y.removeAttributeNode(E)}catch{try{y.removeAttribute(A)}catch{}}},Qo=function(y){ei(y);const E=b(y);if(E){const F=[];jt(E,B=>{ar(F,B)}),jt(F,B=>{try{h(B)}catch{}})}const A=_(y);if(A)for(let F=A.length-1;F>=0;--F){const B=A[F],q=B&&B.name;typeof q=="string"&&Mf(y,B,q)}},Jt=function(y,E,A){if(!A)try{A=E.getAttributeNode(y)}catch{A=null}ar(e.removed,{attribute:A||null,from:E});try{A?E.removeAttributeNode(A):E.removeAttribute(y)}catch{try{E.removeAttribute(y)}catch{}}if(y==="is")if(Rt||Xo)try{Dt(E)}catch{}else try{E.setAttribute(y,"")}catch{}},$w=function(y){const E=_(y);if(E)for(let A=E.length-1;A>=0;--A){const F=E[A],B=F&&F.name;typeof B!="string"||ee[we(B)]||Mf(y,F,B)}},ei=function(y){const E=[y];for(;E.length>0;){const A=E.pop();P(A)===Ye.element&&$w(A);const B=b(A);if(B)for(let q=B.length-1;q>=0;--q)E.push(B[q])}},Tf=function(y,E){return le?y==="patchsrc"?!0:y==="for"&&E!=="label"&&E!=="output":!1},Nw=function(y){if(!le)return;const E=[y];for(;E.length>0;){const A=E.pop(),F=P(A);if(F===Ye.processingInstruction||F===Ye.comment&&ke(pp,A.data)){try{h(A)}catch{}continue}if(F===Ye.element){const q=A,ce=we(k(A));try{q.hasAttribute&&q.hasAttribute("patchsrc")&&q.removeAttribute("patchsrc"),q.hasAttribute&&q.hasAttribute("for")&&Tf("for",ce)&&q.removeAttribute("for")}catch{}}const B=b(A);if(B)for(let q=B.length-1;q>=0;--q)E.push(B[q])}},kf=function(y){let E=null,A=null;if(mr)y="<remove></remove>"+y;else{const q=np(y,/^[\r\n\t ]+/);A=q&&q[0]}br==="application/xhtml+xml"&&Mn===ct&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const F=S?j(y):y;if(Mn===ct)try{E=new d().parseFromString(F,br)}catch{}if(!E||!E.documentElement){E=de.createDocument(Mn,"template",null);try{E.documentElement.innerHTML=Os?C:F}catch{}}const B=E.body||E.documentElement;return y&&A&&B.insertBefore(n.createTextNode(A),B.childNodes[0]||null),Mn===ct?Fe.call(E,ze?"html":"body")[0]:ze?E.documentElement:B},Cf=function(y){const E=N?N(y):y.ownerDocument;return Ke.call(E||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ti=function(y){return y=lr(y,W," "),y=lr(y,V," "),y=lr(y,Y," "),y},$s=function(y){var E;y.normalize();const A=N?N(y):y.ownerDocument,F=Ke.call(A||y,y,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let B=F.nextNode();for(;B;)B.data=ti(B.data),B=F.nextNode();const q=(E=y.querySelectorAll)===null||E===void 0?void 0:E.call(y,"template");q&&jt(q,ce=>{kn(ce.content)&&$s(ce.content)})},ni=function(y){const E=z?z(y):null;return typeof E!="string"||we(E)!=="form"?!1:typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||y.attributes!==_(y)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function"||y.nodeType!==T(y)||y.childNodes!==b(y)},kn=function(y){if(!T||typeof y!="object"||y===null)return!1;try{return T(y)===Ye.documentFragment}catch{return!1}},yr=function(y){if(!T||typeof y!="object"||y===null)return!1;try{return typeof T(y)=="number"}catch{return!1}};function dt($,y,E){$.length!==0&&jt($,A=>{A.call(e,y,E,Tn)})}const Lw=function(y,E){return!!(le&&y.hasChildNodes()&&!yr(y.firstElementChild)&&ke(up,y.textContent)&&ke(up,y.innerHTML)||le&&y.namespaceURI===ct&&P1[E]&&(yr(y.firstElementChild)||typeof y.textContent=="string"&&ke(R1[E],y.textContent))||y.nodeType===Ye.processingInstruction||le&&y.nodeType===Ye.comment&&ke(pp,y.data))},ri=function(y,E){if(y instanceof RegExp)return ke(y,E);if(y instanceof Function){for(var A=arguments.length,F=new Array(A>2?A-2:0),B=2;B<A;B++)F[B-2]=arguments[B];return!!y(E,...F)}return!1},Fw=function(y,E,A){if(!Ae[E]&&Rf(E)&&ri(Me.tagNameCheck,E))return!1;if(Cs&&!_n[E]){const F=v(y),B=b(y);if(B&&F){const q=B.length;for(let ce=q-1;ce>=0;--ce){const ge=y===A?f(B[ce],!0):B[ce];F.insertBefore(ge,m(y))}}}return Dt(y),!0},Af=function(y,E,A,F){return y.length===0?E:E===A||E===F?Ge(E):E},Of=function(y,E){return y===E||v(y)!==null?!1:(As&&ei(y),!0)},If=function(y,E){if(dt(L.beforeSanitizeElements,y,null),Of(y,E))return!0;if(ni(y))return Dt(y),!0;const A=we(k(y));if(K=Af(L.uponSanitizeElement,K,yt,pe),dt(L.uponSanitizeElement,y,{tagName:A,allowedTags:K}),Of(y,E))return!0;if(Lw(y,A))return Dt(y),!0;if(Ae[A]||!(re.tagCheck instanceof Function&&re.tagCheck(A))&&!K[A]){const B=Fw(y,A,E);return B===!1&&dt(L.afterSanitizeElements,y,null),B}if(P(y)===Ye.element&&!Dw(y)||(A==="noscript"||A==="noembed"||A==="noframes")&&ke(O1,y.innerHTML))return Dt(y),!0;if(ue&&y.nodeType===Ye.text){const B=ti(y.textContent);y.textContent!==B&&(ar(e.removed,{element:y.cloneNode()}),y.textContent=B)}return dt(L.afterSanitizeElements,y,null),!1},Pf=function(y,E,A){if(Ee[E]||Tf(E,y)||pf&&(E==="id"||E==="name")&&(A in n||A in Ow))return!1;const F=ee[E]||re.attributeCheck instanceof Function&&re.attributeCheck(E,y);return It&&ke(X,E)||Ot&&ke(ne,E)?!0:F?yf[E]||ke(_e,lr(A,se,""))||(E==="src"||E==="xlink:href"||E==="href")&&y!=="script"&&rp(A,"data:")===0&&mf[y]||M&&!ke(Q,lr(A,se,""))?!0:!A:Rf(y)&&ri(Me.tagNameCheck,y)&&ri(Me.attributeNameCheck,E,y)||E==="is"&&Me.allowCustomizedBuiltInElements&&ri(Me.tagNameCheck,A)},zw=oe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Rf=function(y){return!zw[sr(y)]&&ke(he,y)},Bw=function(y,E,A,F){if(S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!A)switch(p.getAttributeType(y,E)){case"TrustedHTML":return j(F);case"TrustedScriptURL":return te(F)}return F},Hw=function(y,E,A,F){try{A?y.setAttributeNS(A,E,F):y.setAttribute(E,F),ni(y)?Dt(y):tp(e.removed)}catch{Jt(E,y)}},Df=function(y){dt(L.beforeSanitizeAttributes,y,null);const E=y.attributes;if(!E||ni(y))return;ee=Af(L.uponSanitizeAttribute,ee,lt,ve);const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let F=E.length;const B=we(y.nodeName);for(;F--;){const q=E[F],ce=q.name,ge=q.namespaceURI,Be=q.value,He=we(ce),Ls=Be;let De=ce==="value"?Ls:p1(Ls);if(A.attrName=He,A.attrValue=De,A.keepAttr=!0,A.forceKeepAttr=void 0,dt(L.uponSanitizeAttribute,y,A),De=A.attrValue,ff&&(He==="id"||He==="name")&&rp(De,hf)!==0&&(Jt(ce,y,q),De=hf+De),le&&ke(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){Jt(ce,y,q);continue}if(He==="attributename"&&np(De,"href")){Jt(ce,y,q);continue}if(!A.forceKeepAttr){if(!A.keepAttr){Jt(ce,y,q);continue}if(!J&&ke(I1,De)){Jt(ce,y,q);continue}if(ue&&(De=ti(De)),!Pf(B,He,De)){Jt(ce,y,q);continue}De=Bw(B,He,ge,De),De!==Ls&&Hw(y,ce,ge,De)}}dt(L.afterSanitizeAttributes,y,null)},oi=function(y){let E=null;const A=Cf(y);for(dt(L.beforeSanitizeShadowDOM,y,null);E=A.nextNode();)if(dt(L.uponSanitizeShadowNode,E,null),If(E,y),Df(E),kn(E.content)&&oi(E.content),P(E)===Ye.element){const F=w(E);kn(F)&&(Ns(F),oi(F))}dt(L.afterSanitizeShadowDOM,y,null)},Ns=function(y){const E=[{node:y,shadow:null}];for(;E.length>0;){const A=E.pop();if(A.shadow){oi(A.shadow);continue}const F=A.node,q=P(F)===Ye.element,ce=b(F);if(ce)for(let ge=ce.length-1;ge>=0;--ge)E.push({node:ce[ge],shadow:null});if(q){const ge=z?z(F):null;if(typeof ge=="string"&&we(ge)==="template"){const Be=F.content;kn(Be)&&E.push({node:Be,shadow:null})}}if(q){const ge=w(F);kn(ge)&&E.push({node:null,shadow:ge},{node:ge,shadow:null})}}};return e.sanitize=function($){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,A=null,F=null,B=null;if(Os=!$,Os&&($="<!-->"),typeof $!="string"&&!yr($)&&($=b1($),typeof $!="string"))throw Gt("dirty is not a string, aborting");if(!e.isSupported)return $;Pt?(K=pe,ee=ve):Ds(y),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(K=Ge(K)),L.uponSanitizeAttribute.length>0&&(ee=Ge(ee)),e.removed=[];const q=As&&typeof $!="string"&&yr($);if(q){Nw($);const Be=k($);if(typeof Be=="string"){const He=we(Be);if(!K[He]||Ae[He])throw Qo($),Gt("root node is forbidden and cannot be sanitized in-place")}if(ni($))throw Qo($),Gt("root node is clobbered and cannot be sanitized in-place");try{Ns($)}catch(He){throw Qo($),He}}else if(yr($))E=kf("<!---->"),A=E.ownerDocument.importNode($,!0),A.nodeType===Ye.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?E=A:E.appendChild(A),Ns(A);else{if(!Rt&&!ue&&!ze&&$.indexOf("<")===-1)return S&&Ko?j($):$;if(E=kf($),!E)return Rt?null:Ko?C:""}E&&mr&&Dt(E.firstChild);const ce=q?$:E;try{const Be=Cf(ce);for(;F=Be.nextNode();)If(F,ce),Df(F),kn(F.content)&&oi(F.content)}catch(Be){throw q&&(Qo($),jt(e.removed,He=>{He.element&&ei(He.element)})),Be}if(q)return jt(e.removed,Be=>{Be.element&&ei(Be.element)}),ue&&$s($),$;if(Rt){if(ue&&$s(E),Xo)for(B=ye.call(E.ownerDocument);E.firstChild;)B.appendChild(E.firstChild);else B=E;return(ee.shadowroot||ee.shadowrootmode)&&(B=D.call(r,B,!0)),B}let ge=ze?E.outerHTML:E.innerHTML;return ze&&K["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ke(C1,E.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
260
- `+ge),ue&&(ge=ti(ge)),S&&Ko?j(ge):ge},e.setConfig=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ds($),Pt=!0,pe=K,ve=ee},e.clearConfig=function(){Tn=null,Pt=!1,pe=null,ve=null,S=O,C=""},e.isValidAttribute=function($,y,E){Tn||Ds({});const A=we($),F=we(y);return Pf(A,F,E)},e.addHook=function($,y){typeof y=="function"&&$e(L,$)&&ar(L[$],y)},e.removeHook=function($,y){if($e(L,$)){if(y!==void 0){const E=d1(L[$],y);return E===-1?void 0:u1(L[$],E,1)[0]}return tp(L[$])}},e.removeHooks=function($){$e(L,$)&&(L[$]=[])},e.removeAllHooks=function(){L=hp()},e}var N1=gp();const L1={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function F1(t){const e=t.options;return String(e.testData||e.formatter||e.title||"")||"条码"}function z1(t){return g("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function B1(t){const e=t.options;return g("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[g("svg",{preserveAspectRatio:L1[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function H1(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(n=>!Number.isFinite(n))?null:{width:e[2],height:e[3]}}function U1(t,e){const n=t.options,r=Pn(n.barWidth),o=ci(n.barQuietZone),i=a=>{ha(e,F1(t),{format:String(n.barcodeType||"CODE128"),width:r,height:a*r,displayValue:!n.hideTitle,fontSize:(n.fontSize??Er)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:di*r});const l=H1(e);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const a=pi({barHeightMm:n.barHeight,boxWidthMm:en(n.width,n.maxWidth),boxHeightMm:en(n.height,n.maxHeight),dpi:n.printerDpi,barWidth:n.barWidth,measure:i});e.style.width=a.size?`${a.size.widthMm}mm`:"",e.style.height=a.size?`${a.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function q1(t,e){const n=t.options,r=String(n.testData||n.formatter||n.title||"")||"二维码";e.replaceChildren();try{const o=za.render(r,"qrcode",{qrCodeLevel:String(n.qrCodeLevel??"M"),qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0}),i=document.createElement("img");i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`,i.alt="qrcode",i.style.width="100%",i.style.height="100%",i.style.objectFit=String(n.fit||"contain"),i.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",i.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",e.appendChild(i)}catch{}}function W1(t,e){for(const n of Array.from(t.querySelectorAll("[data-code-kind]"))){const r=n.dataset.codeId,o=e.find(i=>i.id===r);if(o)if(n.dataset.codeKind==="barcode"){const i=n.querySelector("svg");i&&U1(o,i)}else q1(o,n)}}const j1={header:"题",data:"数",subtotal:"小",summary:"汇"},G1=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],Lo=3.7795275591,Y1=.1,Qa=t=>JSON.parse(JSON.stringify(t)),mp=new WeakMap;function ft(t){let e=mp.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},mp.set(t,e)),e}function dr(t,e){return t.templateData.elements.find(n=>n.id===e)??null}function V1(t,e){const n=t.tableSelection;return!n||n.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):n}function bp(t,e,n){const r=dr(t,n.id);if(!r)return null;const o=n.options;return{store:t,fire:e,el:n,real:r,options:o,rows:o.tableRows??[],colWidths:o.tableColWidths??[],isSelected:t.selectedIds.has(n.id),selection:V1(t,n),maxTableWidth:yp(t)}}function yp(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function es(t){return t.options.tableDefaultFontSize??10}function vp(t){return t.options.tableDefaultColor??"#333333"}function X1(t,e){let n=0;for(let r=0;r<e;r++)n+=t.rows[r].height;return n}function K1(t,e){return ft(t.store).layouts.get(t.el.id)?.[e]?.top??X1(t,e)}function Z1(t,e){return ft(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function J1(t){const e=t.options.dataSource;if(e&&Array.isArray(it[e]))return it[e];for(const n of Object.values(it))if(Array.isArray(n))return n}function wp(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function xp(t,e){return wp(e)?b0(e.formatter,J1(t)):e.formatter||""}function Q1(t,e){const n={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:Ki(e.fontFamily??t.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??es(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??vp(t),backgroundColor:e.backgroundColor??"transparent",borderTop:Cr(e.borders?.top,n),borderRight:Cr(e.borders?.right,n),borderBottom:Cr(e.borders?.bottom,n),borderLeft:Cr(e.borders?.left,n),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ey(t,e,n){const r=t.selection;return[!!r&&e>=r.r1&&e<=r.r2&&n>=r.c1&&n<=r.c2?"cell-selected":"",t.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Ep(t){return ii(t)}function ty(t){return Ep(t)!=="autoHeight"}function ny(t,e){return e.fontSize??es(t)}function Fo(t,e,n){return An(t.rows,e,n,t.options.tableDefaultPadding??1)}function ry(t,e,n){return si(t.colWidths,e,n,t.options.tableDefaultPadding??1)}function oy(t,e,n){return{maxHeight:Fo(t,n,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function iy(t,e,n){const r={fitBase:String(ny(t,e)),fitMin:String(Cn(e.shrinkMinFontSize)),fitMm:String(Fo(t,n,e))};return Ep(e)==="shrink"&&(r.fit="shrink"),r}function ay(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(n=>!Number.isFinite(n))?null:{width:e[2],height:e[3]}}const sy={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ly(t,e,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(Zb,"svg");o.appendChild(i);const a=xp(t,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",sy[r.fit||"contain"]??"xMidYMid meet");const l=Pn(r.barWidth),c=ci(r.barQuietZone),s=u=>{ha(i,a,{format:r.barcodeType||"CODE128",width:l,height:u*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??Er)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:di*l});const f=ay(i);return f?{widthUnits:f.width,heightUnits:f.height}:null};let d=null;try{d=pi({barHeightMm:r.barHeight,boxWidthMm:en(ry(t,n,r),r.maxWidth),boxHeightMm:en(Fo(t,e,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:s})}catch{d=null}if(!d){i.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=a||"条码",o.appendChild(u),o}const p=d.size;return p?(i.style.width=`${p.widthMm}mm`,i.style.height=`${p.heightMm}mm`):(i.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",i.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%"),i.setAttribute("shape-rendering","crispEdges"),o}if(i.style.display="none",!a)return o;try{const l=za.render(a,"qrcode",{qrCodeLevel:String(r.qrCodeLevel||"M"),qrQuietZone:typeof r.qrQuietZone=="number"?r.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=r.fit||"contain",r.objectPosition&&(c.style.objectPosition=r.objectPosition),c.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",c.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%",o.appendChild(c)}catch{}return o}function Sp(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function cy(t){const e=t.formatter||"";return e?e.includes("{")?dn(e,it):e:""}function dy(t,e,n){const r=document.createElement("div");r.className="cell-image";const o=Us(n.fit,Fo(t,e,n));o!==void 0&&(r.style.height=`${o}mm`);const i=cy(n);if(!i)return r.appendChild(Sp()),r;const a=document.createElement("img");a.setAttribute("src",i),o!==void 0&&(a.style.width="100%",a.style.height="100%"),a.style.objectFit=n.fit||"contain";for(const[l,c]of Object.entries(hi(n.fit,n.fitScale,n.objectPosition)))a.style[l]=c;return a.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",a.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",a.addEventListener("error",()=>{a.remove(),r.appendChild(Sp())},{once:!0}),r.appendChild(a),r}function uy(t,e,n,r,o){if(wp(o))return ly(t,n,r,o);if(o.cellType==="image")return dy(t,n,o);const i=xp(t,o),a=()=>e.type==="data"?g("span",{class:"data-placeholder",text:i}):i;return ty(o)?g("div",{class:"cell-fit",style:oy(t,o,n),dataset:iy(t,o,n)},[a()]):a()}function zo(t,e,n){const r={elementId:t.el.id,...gl(t.rows,e,n)};t.store.setTableSelection(r),t.fire("table-selection-change",{elementId:t.el.id,selection:r})}function py(t,e,n,r,o){if(o.button!==0||(t.fire("table-cell-mousedown",{elementId:t.el.id,r:e,c:n,cellId:r,event:o}),!t.isSelected))return;o.stopPropagation();const i=ft(t.store);o.shiftKey&&t.selection?zo(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:n}):(i.anchor={r:e,c:n},zo(t,{r:e,c:n},{r:e,c:n})),document.addEventListener("mouseup",()=>{ft(t.store).anchor=null},{once:!0})}function fy(t,e,n){const r=ft(t.store).anchor;r&&zo(t,r,{r:e,c:n})}function _p(t,e){const n=ft(t);n.menu?.visible&&(n.menu.visible=!1,e("table-menu-close",{elementId:n.menuElId}),t.emit(!1))}function hy(t,e,n,r){r.preventDefault(),r.stopPropagation(),t.isSelected||t.store.selectOne(t.el.id);const o=t.selection;o&&e>=o.r1&&e<=o.r2&&n>=o.c1&&n<=o.c2||zo(t,{r:e,c:n},{r:e,c:n});const a=ft(t.store);a.menuElId=t.el.id,a.menu&&(a.menu.x=r.clientX,a.menu.y=r.clientY,a.menu.visible=!0),t.fire("table-cell-contextmenu",{elementId:t.el.id,r:e,c:n,clientX:r.clientX,clientY:r.clientY}),t.store.emit(!1),document.addEventListener("mousedown",()=>_p(t.store,t.fire),{once:!0})}function Mp(t,e,n){const r=t.reduce((o,i)=>o+i,0)+(t[e]??0);return r>n?`插入后表格总宽 ${Math.round(r*10)/10}mm 超过打印范围宽度 ${n}mm,请先缩小列宽`:null}function gy(t,e){const n=t.real.options.tableRows??[],r=t.real.options.tableColWidths??[],o=e(Qa(n),Qa(r));return o?(window.alert(o),!1):(t.store.recordHistory(),e(n,r),t.store.setTableSelection(null),Nn(t.real.options),t.store.emit(),!0)}function ht(t,e,n){_p(t.store,t.fire);const r=t.selection;if(!r)return;let o=null;switch(e){case"insert-row-above":o=i=>(vl(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(vl(i,r.r2,"below"),null);break;case"delete-row":o=i=>Rh(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=Mp(a,r.c1,t.maxTableWidth);return l||(wl(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=Mp(a,r.c2,t.maxTableWidth);return l||(wl(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>Dh(i,a,r.c1);break;case"merge":o=i=>(bl(i,r),null);break;case"split":o=i=>(yl(i,r),null);break;case"set-row-type":o=i=>n?_i(i,r.r1,n):"未指定行类型";break}o&&gy(t,o)&&t.fire(`table-${e}`,{elementId:t.el.id,...n?{type:n}:{}})}function my(t){const e=t.selection;if(!e)return!1;for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const o=t.rows[n]?.cells[r];if(o&&!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1))return!0}return!1}function Tp(t,e){const n=t.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":_i(Qa(t.rows),n.r1,e):"未选择单元格"}function gt(t,e,n={}){return g("div",{class:`menu-item${n.disabled?" disabled":""}${n.active?" active":""}`,title:n.title||"",text:t,onClick:()=>{n.disabled||e()}})}const ts=()=>g("div",{class:"menu-divider"});function by(t,e,n){const r=ft(t);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=dr(t,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=bp(t,e,o);if(!i)return"";const a=i.selection?ml(i.rows,i.selection):"未选择单元格",l=i.selection?i.rows[i.selection.r1]?.type??null:null;return g("div",{class:"table-ctx-menu",style:{left:n.x+"px",top:n.y+"px"},onMousedown:c=>c.stopPropagation()},[gt("在上方插入行",()=>ht(i,"insert-row-above")),gt("在下方插入行",()=>ht(i,"insert-row-below")),gt("删除行",()=>ht(i,"delete-row"),{disabled:i.rows.length<=1}),ts(),gt("在左侧插入列",()=>ht(i,"insert-col-left")),gt("在右侧插入列",()=>ht(i,"insert-col-right")),gt("删除列",()=>ht(i,"delete-col"),{disabled:i.colWidths.length<=1}),ts(),gt("合并单元格",()=>ht(i,"merge"),{disabled:!!a,title:a||""}),gt("拆分单元格",()=>ht(i,"split"),{disabled:!my(i)}),ts(),g("div",{class:"menu-group-title",text:"行类型"}),...G1.map(c=>gt(c.label,()=>ht(i,"set-row-type",c.value),{disabled:!!Tp(i,c.value),title:Tp(i,c.value)||"",active:l===c.value}))])}let Yt=null;function kp(){Yt&&(document.removeEventListener("mousemove",ns),document.removeEventListener("mouseup",rs),Yt.handle.classList.remove("dragging"),Yt=null)}function yy(t,e){const n=t.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(e.scale||100)/100}function vy(t,e,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;kp();const i=t.real.options.tableColWidths??[];Yt={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:n.clientX,startWidth:i[e-1]??0,scale:yy(o,t.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",ns),document.addEventListener("mouseup",rs)}function ns(t){const e=Yt;if(!e)return;const n=dr(e.store,e.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(t.clientX-e.startX)/(e.scale*Lo),i=e.boundary-1;r[i]=Hh(r,i,e.startWidth+o,yp(e.store)),Nn(n.options),r.forEach((a,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${a}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((a,l)=>{a.style.left=`${r.slice(0,l+1).reduce((c,s)=>c+s,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${n.options.width}mm`,e.wrapper.style.height=`${n.options.height}mm`)}function rs(){document.removeEventListener("mousemove",ns),document.removeEventListener("mouseup",rs);const t=Yt;if(!t)return;Yt=null,t.handle.classList.remove("dragging");const e=dr(t.store,t.elId);e&&Nn(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function wy(t,e,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=dr(t,e);if(!i)return;let a=!1;const l=o/Lo;Math.abs(l-(i.options.height??0))>Y1&&(i.options.height=Math.round(l*100)/100,a=!0);const c=r.offsetTop,s=Array.from(r.rows).map(p=>({top:(p.offsetTop-c)/Lo,height:p.offsetHeight/Lo})),d=ft(t);xy(d.layouts.get(e),s)||(d.layouts.set(e,s),a=!0),a&&t.emit(!1)}function xy(t,e){return!t||t.length!==e.length?!1:e.every((n,r)=>{const o=t[r];return Math.round(n.top*10)===Math.round(o.top*10)&&Math.round(n.height*10)===Math.round(o.height*10)})}function Ey(t,e){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&wy(t,e,r)}),n}function Sy(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function _y(t){return Array.from({length:t.colWidths.length},(e,n)=>n+1)}function My(t,e){return t.colWidths.slice(0,e).reduce((n,r)=>n+r,0)}function Ty(t,e,n){const r=bp(e,n,t);if(!r)return g("div",{class:"print-table"});const o=[g("table",{style:{fontSize:`${es(r)}pt`,color:vp(r)}},[g("colgroup",{},r.colWidths.map(i=>g("col",{style:{width:i+"mm"}}))),g("tbody",{},r.rows.map((i,a)=>g("tr",{style:{height:i.height+"mm"}},i.cells.map((l,c)=>l.merged?"":g("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ey(r,a,c),style:Q1(r,l),onMousedown:s=>py(r,a,c,l.id,s),onMouseenter:()=>fy(r,a,c),onContextmenu:s=>hy(r,a,c,s)},[uy(r,i,a,c,l)])).filter(Boolean))))])];return Sy(r)&&o.push(g("div",{class:"col-resize-layer"},_y(r).map(i=>g("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${i}`,style:{left:My(r,i)+"mm"},onMousedown:a=>{a.stopPropagation(),a.preventDefault(),vy(r,i,a)}})))),r.isSelected&&o.push(g("div",{class:"row-badges"},r.rows.map((i,a)=>g("span",{class:"row-badge",style:{top:K1(r,a)+"mm",height:Z1(r,a)+"mm"},text:j1[i.type]})))),o.push(Ey(e,t.id)),g("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:i=>i.preventDefault()},o)}const ky=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function os(t){return Array.isArray(t)&&t.length>0?t:[]}function Cy(t,e){const n=xr(t,e)??(e?Object.keys(e).find(o=>Array.isArray(e[o])):void 0);if(n)return os(e?.[n]);const r=xr(t,it);return r?os(it[r]):[]}function Ay(t,e){const n=t.options,r=typeof n.formatter=="string"?n.formatter:"",o=os(e)[0],i=Cy(r,o);if(i.length===0)return[...ky];if(!r)return i.map(c=>String(c?.name??JSON.stringify(c)));const a=o??{},l=xr(r,a)??Object.keys(a).find(c=>Array.isArray(a[c]));return i.map(c=>{try{return dn(r,{...a,...c,...l?{[l]:c}:{}})}catch{return r}})}function Oy(t,e){const n=t.options,r=ut(n.flowColumns),o=wt(n.flowGapX),i=On(n.flowRowHeight),a={display:"grid",gridTemplateColumns:`repeat(${r},minmax(0,1fr))`,columnGap:`${o}mm`,gridAutoRows:`minmax(${i}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",color:n.color||"#333",boxSizing:"border-box"};return n.fontFamily&&(a.fontFamily=String(n.fontFamily)),n.backgroundColor&&(a.backgroundColor=String(n.backgroundColor)),g("div",{class:"print-flowlist",style:a},Ay(t,e).map(l=>g("div",{class:"print-flow-cell",text:l})))}const Cp={top:"flex-start",middle:"center",bottom:"flex-end"},Iy={left:"flex-start",center:"center",right:"flex-end"};function Py(t,e){const n=t.options,r=Qs(t.printElementType.type,n),o={};if(r?.all&&(o.border=`${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor}`),r)for(const i of _r){const a=r.edges[i];a&&(o[`border${i.charAt(0).toUpperCase()}${i.slice(1)}`]=`${a.borderWidth} ${a.borderStyle} ${a.borderColor}`)}return{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`,zIndex:String(n.zIndex||"auto"),...o,...Ry(t,e)}}function Ry(t,e){if(e?.has(t.id))return{};const n=gi(t.printElementType.type,t.options);return n===void 0?{}:{rotate:`${n}deg`}}function Ap(t){const e=t.options,n=t.printElementType.type==="longText",r=wr(t.printElementType.type,e),o=e.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:e.fontWeight||"normal",fontFamily:Ki(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:n?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:i?"auto":"100%",boxSizing:"border-box",overflow:i?"visible":"hidden",...n?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};Hs(e)&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis");const l=Bs(e);return l&&(a.whiteSpace=l),e.verticalAlign&&(a.display="flex",e.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Cp[e.verticalAlign]??"flex-start"):(a.alignItems=Cp[e.verticalAlign]??"flex-start",a.justifyContent=Iy[e.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function Dy(t){const e=t.options,n=`${e.borderWidth||.75}pt`,r=e.borderStyle||"solid",o=e.borderColor||"#333";return t.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${n} ${r} ${o}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${n} ${r} ${o}`,boxSizing:"border-box"}}function $y(t){const e=t.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:t.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ny(t){const e=t.options;return{objectFit:e.fit||"contain",...hi(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function Op(t){const e=t.options,n={fitBase:String(e.fontSize||12),fitMin:String(Cn(e.shrinkMinFontSize))};return wr(t.printElementType.type,e)==="shrink"&&(n.fit="shrink"),n}function Ly(t,e,n){const r=t.printElementType.type,o=t.options;switch(r){case"text":{const{style:i}=Ap(t);return g("div",{class:"print-text",style:i,dataset:Op(t),text:String(o.testData||o.formatter||"")||"文本"})}case"longText":{const{style:i}=Ap(t);return g("div",{class:"print-longtext",style:i,dataset:Op(t),text:String(o.formatter||"")||"长文本内容"})}case"hline":case"vline":return g("div",{class:"print-line",style:Dy(t)});case"rect":case"oval":return g("div",{class:"print-shape",style:$y(t)});case"image":{const i=String(o.src??""),a=i.includes("{")?dn(i,it):i;return g("div",{class:"print-image"},[a?g("img",{src:a,style:Ny(t)}):g("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return z1(t);case"barcode":return B1(t);case"html":{const i=String(o.formatter??""),a=i?N1.sanitize(dn(i,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return g("div",{class:"print-html",html:a})}case"pageNumber":return g("div",{class:"page-number-element",style:{fontSize:`${o.fontSize||12}pt`,fontWeight:o.fontWeight||"normal",fontFamily:Ki(o.fontFamily),color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:o.title||"{pageIndex}/{totalPages}"});case"table":return n?Ty(t,n.store,n.fire):g("div",{class:"print-table"});case"flowList":return Oy(t);default:return g("div",{text:r})}}function Ip(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function Fy(t,e,n){const r=t.store,o=r.selectedIds.has(e.id),i=r.previewIds.has(e.id),a=e.options,l=e.zone||"content",c=[Ly(e,!0,{store:r,fire:t.fire})];return r.draggingIds.has(e.id)&&c.push(g("div",{class:"drag-preview"})),o&&(c.push(g("div",{class:"resize-handles"},x0.map(s=>g("div",{class:`resize-handle handle-${s}`,dataset:{point:s,elId:e.id},onMousedown:d=>t.fire("resize-start",{event:d,id:e.id,point:s})})))),c.push(g("div",{class:"selected-indicator"},[g("div",{class:"position-label",text:Ip(a)})]))),g("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${l}`,o?"selected":"",i?"previewed":"",r.draggingIds.has(e.id)?"drag-ghost":"","design-mode",a.locked?"locked":"",a.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Py(e,n),dataset:{elId:e.id},onMousedown:s=>t.fire("element-mousedown",{event:s,id:e.id}),onContextmenu:s=>{s.preventDefault(),s.stopPropagation(),t.fire("contextmenu",{event:s,id:e.id})}},c)}function is(t,e){const n=t.margins,r=t.header?.height??10,o=t.footer?.height??10,i=e.width-n.left-n.right;return{header:{left:n.left,top:n.top,width:i,height:r},content:{left:n.left,top:n.top+r,width:i,height:e.height-n.top-n.bottom-r-o},footer:{left:n.left,top:e.height-n.bottom-o,width:i,height:o}}}const zy='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>';function Pp(t,e){return t.type==="vertical"?{left:`${t.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${t.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}}function By(t,e){const n=vc(t.watermark,[],e);return n?g("div",{class:"watermark-layer",style:{opacity:String(n.opacity)}},n.tiles.map(r=>g("svg",{class:"watermark-tile",width:`${r.widthMm}mm`,height:`${r.heightMm}mm`,viewBox:`0 0 ${n.tileWidthPx} ${n.tileHeightPx}`,style:{left:`${r.leftMm}mm`,top:`${r.topMm}mm`}},[g("text",{x:String(n.tileWidthPx/2),y:String(n.tileHeightPx/2),"font-size":String(n.fontSizePx),fill:n.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${n.rotate},${n.tileWidthPx/2},${n.tileHeightPx/2})`,text:n.text})]))):""}function as(t,e,n,r,o,i){const a=t.store,l=[];n!=="content"&&l.push(g("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"}));const c=n==="content"?sl(o):void 0;if(l.push(...o.map(s=>Fy(t,s,c))),n!=="content"){const s=n==="header"?"bottom":"top";l.push(g("div",{class:`zone-resize-handle handle-${s}`,dataset:{zone:n},onMousedown:d=>t.fire("zone-resize",{event:d,zone:n})},[e.zoneResizing===n?g("div",{class:"zone-height-tip",text:`${(n==="header"?a.templateData.header.height:a.templateData.footer.height).toFixed(1)}mm`}):""]))}return g("div",{class:`zone-layer zone-${n} design-mode`,style:{position:"absolute",left:`${r.left}mm`,top:`${r.top}mm`,width:`${r.width}mm`,height:`${r.height}mm`},dataset:{zone:n,paperWidth:String(i.width),paperHeight:String(i.height)}},l.filter(Boolean))}function Hy(t,e){const n=t.store,r=n.templateData,o=Ze(r),i=(n.scale||100)/100,a=is(r,o),l=p=>n.elements.filter(u=>(u.zone||"content")===p),c=g("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${r.margins.top}mm ${r.margins.right}mm ${r.margins.bottom}mm ${r.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${o.height}mm`}},[n.showGrid?g("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(zy)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[By(r,o)]:[],as(t,e,"header",a.header,l("header"),o),as(t,e,"content",a.content,l("content"),o),as(t,e,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>g("div",{class:`adsorb-guide guide-${p.type}`,style:Pp(p,o)})),...(r.guides??[]).map(p=>g("div",{class:`manual-guide guide-${p.type}`,style:{...Pp(p,o),"--guide-hit":`${8/i}px`},dataset:{guideId:String(p.id??"")},onMousedown:u=>t.fire("guide-mousedown",{event:u,id:p.id}),onDblclick:u=>{u.preventDefault(),t.fire("guide-remove",p.id)}}))].filter(Boolean)),s=g("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${o.width}mm`,minHeight:`${o.height}mm`,background:r.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${i})`,transformOrigin:"0 0"}},[...r.designBackground?.src?[g("div",{class:"design-background",style:{width:`${o.width}mm`,height:`${o.height}mm`,left:"0",top:"0",transform:r.designBackground.rotation?`rotate(${r.designBackground.rotation}deg)`:""}},[g("img",{src:r.designBackground.src,draggable:!1,alt:""})])]:[],c]),d=[g("div",{class:"canvas-scroll"},[g("div",{class:"paper-wrapper",style:{width:`${Hr(o.width)*i}px`,height:`${Hr(o.height)*i}px`,position:"relative"}},[s])])];if(n.showRuler&&d.push(g("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[g("div",{class:"ruler-corner"}),g("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:p=>t.fire("ruler-mousedown",{event:p,orientation:"horizontal"})}),g("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:p=>t.fire("ruler-mousedown",{event:p,orientation:"vertical"})})])),e.guidePreview&&d.push(g("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&d.push(g("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const p=e.contextMenu;d.push(g("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[et(t,p,"复制","copy"),et(t,p,"剪切","cut"),et(t,p,"粘贴","paste",!n.hasClipboard),et(t,p,"删除","delete"),g("div",{class:"context-menu-sep"}),et(t,p,"置顶","move-layer",!1,"top"),et(t,p,"上移","move-layer",!1,"up"),et(t,p,"下移","move-layer",!1,"down"),et(t,p,"置底","move-layer",!1,"bottom")]:[et(t,p,"粘贴","paste-at",!n.hasClipboard),et(t,p,"全选","select-all"),et(t,p,"取消选择","clear-selection")]))}return g("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:p=>p.preventDefault(),onDrop:p=>t.fire("drop",p),onMousedown:p=>t.fire("canvas-mousedown",p),onMousemove:p=>t.fire("canvas-mousemove",p),onMouseleave:()=>t.fire("canvas-mouseleave"),onWheel:p=>t.fire("wheel",p),onScroll:p=>t.fire("scroll",p),onContextmenu:p=>{p.preventDefault(),t.fire("canvas-contextmenu",p)}},d.filter(Boolean))}function et(t,e,n,r,o=!1,i){return g("div",{class:`context-menu-item${o?" disabled":""}`,text:n,onClick:()=>{e.visible=!1,o||t.fire(r,i),t.repaint()}})}const Uy={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function Ne(t,e=15,n){const r=Uy[t];return r?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${n?` class="${n}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`:""}let Vt=null;function ss(t){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return null;const n=e[1],r=n.length===3?n.split("").map(o=>o+o).join(""):n;return{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16)}}function ls(t){const e=ss(t);return e?Rp(e):"#000000"}function Rp({r:t,g:e,b:n}){return`#${[t,e,n].map(r=>Math.round(ur(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function qy(t,e,n){const r=t/255,o=e/255,i=n/255,a=Math.max(r,o,i),l=Math.min(r,o,i),c=a-l;let s=0;return c!==0&&(a===r?s=(o-i)/c%6:a===o?s=(i-r)/c+2:s=(r-o)/c+4,s*=60,s<0&&(s+=360)),{h:s,s:a===0?0:c/a,v:a}}function Wy(t,e,n){const r=n*e,o=(t%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[a,l,c]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],s=n-r;return{r:(a+s)*255,g:(l+s)*255,b:(c+s)*255}}function jy(t){return((Number.isFinite(t)?t:0)%360+360)%360}function ur(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function Gy(t){const e=t.title??"颜色选择";return g("button",{type:"button",class:`preset-color-trigger${t.triggerClass?` ${t.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:n=>{const r=n.currentTarget??n.target,o=r.getRootNode();if(!!Vt&&Vt.root===o&&Vt.title===e&&Vt.trigger===r){pr();return}pr(),Yy(r,t)}},[g("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function pr(){const t=Vt;t&&(Vt=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function Yy(t,e){const n=t.getRootNode(),r=n instanceof ShadowRoot?n:document.body,o={root:n,title:e.title??"颜色选择",trigger:t,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&ds(o,e.value)?o.hexText=ls(e.value).toUpperCase():o.hexText=e.value?String(e.value):"",o.panel=Re(Zy(o),r),o.current=o.panel.querySelector(".picker-current"),o.hex=o.panel.querySelector(".picker-hex"),o.area=o.panel.querySelector(".picker-area"),o.handle=o.panel.querySelector(".picker-handle"),o.hueRange=o.panel.querySelector(".picker-hue"),o.clearBtn=o.panel.querySelector(".picker-clear"),o.items=Array.from(o.panel.querySelectorAll(".preset-color-item")).map((i,a)=>({el:i,color:Fl[a]})),Bo(o),Vy(o),Xy(o),Vt=o,t.setAttribute("aria-expanded","true")}function Vy(t){const e=t.trigger.getBoundingClientRect(),n=190,r=t.panel.offsetHeight||216,o=8,i=Math.max(o,Math.min(e.left,window.innerWidth-n-o)),a=e.bottom+6,l=a+r>window.innerHeight-o?Math.max(o,e.top-r-6):a;t.panel.style.left=`${i}px`,t.panel.style.top=`${l}px`}function Xy(t){const e=o=>{const i=Ky(o);i.includes(t.trigger)||i.includes(t.panel)||pr()},n=o=>{o.key==="Escape"&&pr()},r=()=>pr();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),t.root.addEventListener("scroll",r,!0),t.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",n),()=>window.removeEventListener("scroll",r,!0),()=>window.removeEventListener("resize",r),()=>t.root.removeEventListener("scroll",r,!0))}function Ky(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function Zy(t){return g("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[g("div",{class:"picker-preview"},[g("span",{class:"picker-current"}),g("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>Qy(t,e.target.value)})]),g("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>ev(t,e),onKeydown:e=>tv(t,e)},[g("span",{class:"picker-handle"})]),g("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>nv(t,Number(e.target.value)),onChange:()=>us(t)}),g("div",{class:"picker-heading"},[g("span",{text:"常用颜色"}),t.clearable?g("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Ho(t,void 0)},[g("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[g("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),g("div",{class:"preset-color-grid"},Fl.map(e=>g("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>Jy(t,e)})))])}function cs(t){return Rp(Wy(t.hue,t.saturation,t.value_))}function Bo(t){const e=cs(t);t.hex.value!==t.hexText&&(t.hex.value=t.hexText),t.current.className=t.model?"picker-current":"picker-current is-empty",t.model?t.current.style.background=e:t.current.style.removeProperty("background"),t.area.style.setProperty("--picker-hue",`${Math.round(t.hue)}deg`),t.handle.style.left=`${t.saturation*100}%`,t.handle.style.top=`${(1-t.value_)*100}%`,t.handle.style.background=e;const n=String(Math.round(t.hue));t.hueRange.value!==n&&(t.hueRange.value=n),t.clearBtn&&(t.clearBtn.disabled=!t.model);for(const r of t.items)r.el.className=t.model&&r.color.toLowerCase()===t.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ds(t,e){const n=ss(e);if(!n)return!1;const r=qy(n.r,n.g,n.b);return t.hue=r.h,t.saturation=r.s,t.value_=r.v,t.hexText=ls(e).toUpperCase(),!0}function vn(t,e,n,r){t.hue=jy(e),t.saturation=ur(n),t.value_=ur(r),t.hexText=cs(t).toUpperCase(),Bo(t)}function us(t){const e=cs(t);t.model=e,Bo(t),t.onChange(e)}function Ho(t,e){t.model=e,e||(t.hexText=""),Bo(t),t.onChange(e)}function Jy(t,e){ds(t,e),Ho(t,e)}function Qy(t,e){const n=e.trim();if(!n){t.clearable&&Ho(t,void 0);return}ss(n)&&(ds(t,n),Ho(t,ls(n)))}function ev(t,e){t.dragging=!0,Dp(t,e);const n=o=>{t.dragging&&Dp(t,o)},r=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),us(t))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function Dp(t,e){const n=t.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=ur((e.clientX-n.left)/n.width),o=ur(1-(e.clientY-n.top)/n.height);vn(t,t.hue,r,o)}function tv(t,e){const n=e.shiftKey?.1:.02;let r=!0;e.key==="ArrowLeft"?vn(t,t.hue,t.saturation-n,t.value_):e.key==="ArrowRight"?vn(t,t.hue,t.saturation+n,t.value_):e.key==="ArrowUp"?vn(t,t.hue,t.saturation,t.value_+n):e.key==="ArrowDown"?vn(t,t.hue,t.saturation,t.value_-n):r=!1,r&&(e.preventDefault(),us(t))}function nv(t,e){vn(t,e,t.saturation,t.value_)}function be(t,e,n,r){return g("button",{class:`tb-btn tb-icon${r.on?" on":""}${r.danger?" danger":""}`,type:"button",disabled:!!r.disabled,dataset:{tip:r.tip,...r.test?{test:r.test}:{}},onClick:()=>t.fire(n,r.arg),html:Ne(e)})}function Uo(t,e,n,r){const o=t.state.openDd===e,i=()=>{t.state.openDd=o?null:e,t.repaint()};return g("div",{class:"tb-dd"},[g("button",{type:"button",class:`tb-dd-trigger${o?" on":""}`,disabled:!!n.disabled,dataset:{test:n.testId??e,tip:n.tip},onClick:i,html:`${n.icon?Ne(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${Ne("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?g("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function Z(t){const e=t.step??1,n=String(e),r=n.indexOf("."),o=r===-1?0:n.length-r-1,i=p=>Number.isFinite(p)?Number(p.toFixed(o)):0,a=p=>{let u=i(p);return t.min!==void 0&&u<t.min&&(u=t.min),t.max!==void 0&&u>t.max&&(u=t.max),u},l=t.value===void 0||t.value===null||!Number.isFinite(t.value)?void 0:i(t.value),c=l??t.min??0,s=p=>{p!==l&&t.onCommit(p)},d=g("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:t.min,max:t.max,step:e,placeholder:t.placeholder,disabled:!!t.disabled,onChange:p=>{const u=p.target,f=(u.value??"").trim();if(f===""){l!==void 0&&(u.value=String(l));return}const h=Number(f);if(!Number.isFinite(h)){u.value=l===void 0?"":String(l);return}const m=a(h);u.value=String(m),s(m)}});return g("div",{class:"pd-stepper"},[g("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!t.disabled||c<=(t.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>s(a(c-e))}),d,g("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!t.disabled||c>=(t.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>s(a(c+e))})])}function ie(t,e,n,r){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:t}),r??""]),e,n?g("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const ps=t=>g("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function Ve(t,e,n,r){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t"},[t,ps(n)]),r??""]),e])}function Xt(t){const e=t.base?.[t.propKey],n=t.target?.[t.propKey]!==e,r=t.force===!0||n,o=t.tipOverride??(t.tipValue===void 0?"恢复默认值":`恢复默认值(${t.tipValue}${t.tipUnit?" "+t.tipUnit:""})`),i=t.force?`${o}(应用到全部选中格)`:o;return g("button",{type:"button",class:`pd-reset-btn${n&&!t.force?" is-dirty":""}`,"data-tip":i,"aria-label":i,html:Ne("RotateCcw",13),onClick:()=>{r&&(t.write?t.write(e):t.target[t.propKey]=e,t.onReset?.())}})}const st=t=>g("h3",{class:"pd-divider",text:t});function Xe(t,e,n="颜色选择",r){return Gy({value:t,title:n,triggerClass:r,onChange:o=>e(o)})}function kt(t,e,n,r,o=!1){return g("div",{class:`pd-radio-group${o?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(i=>g("label",{class:"pd-radio"},[g("input",{type:"radio",name:t,value:i.value,checked:n===i.value,onChange:()=>r(i.value)}),g("span",{text:i.label})])))}function $p(t,e,n,r={}){const o=document.createElement("select");o.className=r.className??"pd-select",r.width&&(o.style.width=r.width);for(const i of e){const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.disabled&&(a.disabled=!0),o.appendChild(a)}return o.value=t,e.some(i=>i.value===t)||(o.selectedIndex=-1),o.addEventListener("change",()=>n(o.value)),o}function rv(t){const e=window.innerHeight;for(let n=t.parentElement;n&&n!==document.body;n=n.parentElement){const r=getComputedStyle(n).overflowY;if(r==="auto"||r==="scroll"||r==="hidden"||r==="clip"){const o=n.getBoundingClientRect();return{top:Math.max(0,o.top),bottom:Math.min(e,o.bottom)}}}return{top:0,bottom:e}}function qo(t){const e=Yg(t.fonts),n=t.placeholder??"默认",r=`font-select-list-${t.id}`,o=k=>{const S=k?.trim();return S?ac(e,S)?.label??S:""},i=k=>{const S=qn(k);return e.find(O=>O.label&&qn(O.label)===S)?.family??k},a=()=>{const k=t.value?.trim();return k?ac(e,k)?"":k:""},l=k=>{const S=(t.value??"").trim(),C=(I,x,j,te)=>({kind:I,key:x,label:j,value:te,selected:(te??"")===S}),O=k.trim();if(!O){const I=[C("clear","__clear__",n)],x=a();x&&I.push(C("unknown","__unknown__",`${x}(未知)`,x));for(const j of e)I.push(C("font",j.family,sc(j),j.family));return I}const R=Xg(e,O).map(I=>C("font",I.family,sc(I),I.family));if(!R.length){const I=i(O);R.push(C("free","__free__",`使用「${I}」`,I))}return R},c=document.createElement("div");c.className="font-select";const s=document.createElement("input");s.className="pd-input font-select-input",s.type="text",s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-controls",r),s.autocomplete="off",s.placeholder=n,s.disabled=!!t.disabled,s.value=o(t.value);const d=document.createElement("ul");d.id=r,d.className="font-select-list",d.setAttribute("role","listbox");const p=t.state.fontOpen?.id===t.id?t.state.fontOpen:null,u={open:!!p&&!t.disabled,query:p?.query??"",highlighted:p?.highlighted??-1};u.open&&(s.value=u.query);const f=()=>{t.state.fontOpen=u.open?{id:t.id,query:u.query,highlighted:u.highlighted}:null};f();const h=()=>{const k=(t.value??"").trim();return l(u.query).findIndex(S=>(S.value??"")===k)},m=()=>{const k=s.getBoundingClientRect(),S=rv(s);d.classList.toggle("is-up",Eh({triggerTop:k.top,triggerBottom:k.bottom,overlayHeight:d.getBoundingClientRect().height,boundaryTop:S.top,boundaryBottom:S.bottom})==="up")},b=()=>{if(!u.open){d.isConnected&&d.remove(),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant","");return}d.isConnected||c.appendChild(d);const k=l(u.query);d.replaceChildren(...k.map((S,C)=>{const O=document.createElement("li");return O.id=`${r}-${C}`,O.className="font-select-option"+(C===u.highlighted?" is-active":"")+(S.kind==="unknown"||S.kind==="free"?" is-muted":""),O.setAttribute("role","option"),O.setAttribute("aria-selected",String(S.selected)),O.textContent=S.label,O.addEventListener("mousedown",R=>{R.preventDefault(),N(S)}),O})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:""),m()},v=()=>{u.open||t.disabled||(u.open=!0,u.query="",u.highlighted=h(),f(),b())},w=()=>{u.open||v()},_=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),b()},T=k=>{if(!u.open){v();return}const S=l(u.query).length-1;if(S<0)return;u.highlighted=Math.min(Math.max(u.highlighted+k,0),S),f(),b(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},z=()=>{if(!u.open)return;const k=l(u.query)[u.highlighted];if(k){N(k);return}const S=u.query.trim();if(S){const C=i(S);N({value:C})}},N=k=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(k.value),b(),t.onChange(k.value)},P=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(t.value),b())};return s.addEventListener("focus",v),s.addEventListener("click",w),s.addEventListener("input",_),s.addEventListener("blur",P),s.addEventListener("keydown",k=>{const S=k;S.key==="ArrowDown"?(S.preventDefault(),T(1)):S.key==="ArrowUp"?(S.preventDefault(),T(-1)):S.key==="Enter"?(S.preventDefault(),z()):S.key==="Escape"&&(S.preventDefault(),P())}),c.append(s),b(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const ov=[{key:"solid",label:"实线",preview:"1.5px solid currentColor"},{key:"dashed",label:"虚线",preview:"1.5px dashed currentColor"},{key:"dotted",label:"点线",preview:"1.5px dotted currentColor"},{key:"double",label:"双线",preview:"3px double currentColor"}],iv={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function Ct(t,e,n,r,o={}){return g("button",{type:"button",class:`ft-cell-btn${o.on?" on":""}`,dataset:{test:t,tip:e},disabled:!!o.disabled,onClick:r,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${n}</svg>`})}const wn='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',Np='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function av(t){const e=t.format;e.syncBorderDraft();const n=e.values,r=!e.fontEditable,o=r||e.context==="cells",i=e.context==="none",a=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",s=u=>r?`${u}(需选中文本元素)`:u,d=[g("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[g("div",{class:"ft-border-grid"},[Ct("preset-none","无边框",`${wn}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),Ct("preset-all","所有边框",`${Np}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),Ct("preset-outer","外侧边框",Np,()=>e.applyBorderPreset("outer")),Ct("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${wn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!a}),Ct("edge-top","上边框",`${wn}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),Ct("edge-bottom","下边框",`${wn}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),Ct("edge-left","左边框",`${wn}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),Ct("edge-right","右边框",`${wn}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),g("div",{class:"ft-style-row"},ov.map(u=>g("button",{type:"button",class:`ft-style-btn${e.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:e.borderStyle===u.key?`${u.label}(再点一次取消,线型=无)`:u.label},onClick:()=>{e.toggleBorderStyle(u.key),t.repaint()}},[g("span",{class:"ft-style-line",style:{borderTop:u.preview}})]))),g("div",{class:"ft-border-style-row"},[g("span",{class:"ft-edge-label",text:"粗细"}),g("div",{class:"ft-line-width"},[Z({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:u=>{e.setBorderWidth(u),t.repaint()}})])]),g("div",{class:"ft-border-style-row"},[g("span",{class:"ft-edge-label",text:"颜色"}),Xe(e.borderColor,u=>{e.setBorderColor(u),t.repaint()},"边框颜色")]),e.borderMixedAny?g("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],p=[g("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[g("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([u,f,h])=>g("button",{type:"button",class:`ft-cell-btn${n.textAlign===u?" on":""}`,dataset:{test:`align-${u}`,tip:f},disabled:r,onClick:()=>e.applyStyle({textAlign:u}),html:Ne(h)}))),g("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([u,f,h])=>g("button",{type:"button",class:`ft-cell-btn${n.verticalAlign===u?" on":""}`,dataset:{test:`valign-${u}`,tip:f},disabled:r,onClick:()=>e.applyStyle({verticalAlign:u}),html:Ne(h)})))])];return g("div",{class:"format-toolbar"},[g("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[g("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),t.repaint()},onDblclick:()=>{e.pickPainterSource(!0),t.repaint()},html:Ne("Paintbrush")})]),g("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[g("div",{class:"ft-font"},[qo({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===Wt?"混合":"默认",disabled:r,onChange:u=>e.applyStyle({fontFamily:u})})]),g("div",{class:"ft-size",dataset:{test:"font-size"}},[Z({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===Wt?"混合":"默认",onCommit:u=>e.applyStyle({fontSize:u})})])]),g("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([u,f,h,m])=>g("button",{type:"button",class:`ft-btn${n[u]===!0?" on":""}`,dataset:{test:u,tip:s(h)},disabled:u==="bold"?r:o,onClick:m,html:Ne(f)}))]),g("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[g("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[Xe(typeof n.color=="string"?n.color:void 0,u=>e.applyStyle({color:u})),g("span",{class:"ft-glyph",text:"A"})]),g("span",{class:`ft-color-btn${i?" dim":""}`,title:"背景色"},[Xe(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>e.applyStyle({backgroundColor:u})),g("span",{class:"ft-glyph",html:Ne("PaintBucket",14)})])]),g("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[Uo(t,"align",{icon:iv[String(n.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:r?"对齐(需选中文本元素或单元格)":"对齐",disabled:r,testId:"align-dd"},p)]),g("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[Uo(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const sv=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",label:"流式列表",icon:"⊟"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],lv={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function cv(t){const e=t.state;if(e.leftCollapsed)return g("div",{class:"left-panel collapsed"},[g("div",{class:"left-collapsed"},[Lp("»","展开素材台",()=>{e.leftCollapsed=!1,t.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([r,o,i])=>g("button",{type:"button",class:`lc-btn${e.leftTab===r?" on":""}`,title:o,text:i,onClick:()=>{e.leftTab=r,e.leftCollapsed=!1,t.repaint()}}))])]);const n=(r,o)=>g("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===r?"":{display:"none"}},o);return g("div",{class:"left-panel"},[g("div",{class:"left-head"},[g("span",{class:"left-title",text:"素材台"}),Lp("«","收起素材台",()=>{e.leftCollapsed=!0,t.repaint()})]),g("div",{class:"pd-tabs left-tabs"},[g("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([r,o])=>g("button",{type:"button",class:`pd-tab${e.leftTab===r?" active":""}`,text:o,onClick:()=>{e.leftTab=r,t.repaint()}}))]),n("elements",dv()),n("fields",[uv(t)]),n("layers",[pv(t)])])])}function Lp(t,e,n){return g("button",{type:"button",class:"collapse-btn",title:e,text:t,onClick:n})}function dv(){return[g("div",{class:"panel-title",text:"拖拽元素到画布"}),...sv.map(t=>g("div",{class:"material-card",draggable:!0,dataset:{test:`material-${t.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",t.type)},[g("span",{class:"material-icon",text:t.icon}),g("span",{class:"material-label",text:t.label})]))]}function uv(t){const e=t.state,n=Xc(t.store.fields),r=(e.fieldSearch??"").trim().toLowerCase(),o=r?n.map(i=>({...i,fields:i.fields.filter(a=>`${a.fieldLabel}${a.fieldKey}`.toLowerCase().includes(r))})).filter(i=>i.fields.length):n;return g("div",{class:"field-tree-panel"},[g("div",{class:"panel-title",text:"业务字段"}),g("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:i=>{e.fieldSearch=i.target.value},onChange:()=>t.repaint()}),g("div",{class:"tree-container"},o.flatMap(i=>{const a=e.collapsedGroups.has(i.key)&&!r,l=i.key?g("div",{class:`field-group-header${i.isList?" is-list":""}`,onClick:()=>{a?e.collapsedGroups.delete(i.key):e.collapsedGroups.add(i.key),t.repaint()}},[g("span",{class:"expand-icon",text:a?"▶":"▼"}),g("span",{class:"node-icon",text:i.isList?"📋":"📁"}),g("span",{class:"group-label",text:i.label,"data-tip":i.label})]):"",c=a?[]:i.fields.map(s=>g("div",{class:"field-row",draggable:!0,"data-tip":`${s.fieldLabel} (${s.fieldKey})`,style:{paddingLeft:`${i.key?22:8}px`},onDragstart:d=>{d.dataTransfer?.setData("fieldKey",s.fieldKey)}},[g("span",{class:"node-icon",text:"📄"}),g("span",{class:"node-meta"},[g("span",{class:"node-label",text:s.fieldLabel}),g("span",{class:"node-key",text:`(${s.fieldKey})`})])]));return[l,g("div",{},c.filter(Boolean))].filter(Boolean)})),o.length===0?g("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function pv(t){const e=t.store,n=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),r=e.elements.filter(l=>e.selectedIds.has(l.id)),o=r.length>=2,i=r.some(l=>!!l.options.groupId),a=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return g("div",{class:"layer-panel"},[g("div",{class:"panel-title",text:"图层"}),...n.map(l=>g("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[g("span",{class:"layer-icon",text:lv[l.printElementType.type]||"?"}),g("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),a(l)?g("span",{class:"layer-zone",text:a(l)}):"",g("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),n.length?g("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,s])=>g("button",{type:"button",class:"pd-button small",title:c,html:Ne(s,14),onClick:()=>t.fire("move-layer",l)}))]):"",o||i?g("div",{class:"layer-actions"},[o?g("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:Ne("Group",14),onClick:()=>t.fire("group")}):"",i?g("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:Ne("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function fv(t){const e=t.store,n=t.state,r=e.pages.length>1,o=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,i=e.tilingEnabled;return g("div",{class:"page-tabs"},[g("div",{class:"page-tabs-list"},e.pages.map((l,c)=>n.renamingPage===c?g("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:n.renameText??"",onInput:s=>{n.renameText=s.target.value},onBlur:()=>a(),onKeydown:s=>{const d=s;if(d.key==="Enter"){a();return}d.key==="Escape"&&(n.renamingPage=null,t.repaint())}}):g("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{n.renamingPage=c,n.renameText=l.name??"",t.repaint()}}))),g("div",{class:"page-tabs-actions"},[g("button",{type:"button",dataset:{test:"add-page",tip:i?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:i,text:"+",onClick:()=>t.fire("add-page")}),g("button",{type:"button",dataset:{test:"duplicate-page",tip:i?"拼版模板仅允许一个设计页面":`复制当前页「${o}」`},disabled:i,text:"⧉",onClick:()=>t.fire("duplicate-page")}),g("button",{type:"button",dataset:{test:"delete-page",tip:r?`删除当前页「${o}」`:"仅多页面模板可删除页面"},disabled:!r,text:"✕",onClick:()=>t.fire("delete-page")}),g("button",{type:"button",dataset:{test:"move-left",tip:`前移「${o}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>t.fire("move-page",-1)}),g("button",{type:"button",dataset:{test:"move-right",tip:`后移「${o}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>t.fire("move-page",1)})])]);function a(){const l=(n.renameText??"").trim();n.renamingPage!==null&&l&&e.renamePage(n.renamingPage,l),n.renamingPage=null,t.repaint()}}function hv(t){const e=t.store,n=e.templateData,r=Et(n),o=n.orientation==="landscape"?"横向":"纵向",i=nt[n.paperSize]?.label??n.paperSize,a=n.outputRotation,l=`${i} ${o} ${Math.round(r.width)}×${Math.round(r.height)}mm${a?`(旋转${a}°)`:""}`;return g("div",{class:"status-bar"},[g("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),g("span",{class:"status-item",text:`缩放 ${e.scale}%`}),g("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),g("span",{class:`status-dirty${e.dirty?" on":""}`},[g("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),g("span",{class:"status-item status-paper",text:l})])}const gv=Object.keys(nt).filter(t=>t!=="CUSTOM"&&!nt[t]?.continuous);function mv(t){const e=document.createElement("label");e.className="pd-button small upload-label";const n=document.createTextNode("上传背景图"),r=document.createElement("input");r.className="visually-hidden",r.type="file",r.accept="image/*",e.append(n,r);const o=i=>{e.className=`pd-button small upload-label${i?" disabled":""}`,r.disabled=i};return r.addEventListener("change",async()=>{const i=r.files?.[0];if(!i)return;if(!i.type.startsWith("image/")){alert("仅支持上传图片文件"),r.value="";return}const a=t.host.uploadDesignBackground;if(!a){alert("设计背景上传能力未配置"),r.value="";return}o(!0),n.textContent="上传中...";try{const l=await a(i);l?t.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{n.textContent="上传背景图",o(!t.host.uploadDesignBackground),r.value=""}}),t.host.uploadDesignBackground||o(!0),e}function bv(t){const n=t.store.templateData.designBackground,r=n?.rotation??0;return g("div",{class:"design-background-config"},[st("设计背景"),g("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),n?.src?[g("div",{class:"design-background-path",title:n.src,text:n.src}),g("div",{class:"design-background-actions"},[g("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(r+90)%360}°)`,onClick:()=>t.store.updateTemplateData({designBackground:{...n,rotation:(r+90)%360}})}),g("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>t.store.updateTemplateData({designBackground:void 0})})])]:mv(t)].flat())}function yv(t){const e=t.store,n=e.templateData,r=n.tiling,o={...ot,...r??{},enabled:r?.enabled??!1,sheetMargin:{...ot.sheetMargin,...r?.sheetMargin??{}}},i=wi(n.paperSize),a=h=>e.updateTemplateData({tiling:{...o,...h}}),l=h=>Xt({target:o,base:ot,propKey:h,write:()=>a({[h]:ot[h]})}),c=h=>Xt({target:o.sheetMargin,base:ot.sheetMargin,propKey:h,write:()=>s(h,ot.sheetMargin[h])}),s=(h,m)=>a({sheetMargin:{...o.sheetMargin,[h]:m??0}}),d={...n,tiling:o},p=ca(d),u=Math.max(Fc(d),1);let f="";if(!p.length)try{const h=Lc(d),m=Yn(d),b=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",v=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";f=`目标纸 ${b}${v} ${m.width}×${m.height}mm · ${h.columns} 列 × ${h.rows} 行 = 每张 ${h.perSheet} 格 · 每格 ${h.tile.width}×${h.tile.height}mm`}catch{f=""}return g("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[st("拼版打印"),g("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),g("div",{class:"pd-field"},[g("label",{class:"tiling-switch"},[g("input",{type:"checkbox",checked:o.enabled===!0,disabled:i,onChange:h=>{if(!h.target.checked){a({enabled:!1});return}a({...ot,columns:Math.min(ot.columns,Math.max(u,1))})}}),g("span",{text:"启用拼版"})]),i?g("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[ie("目标纸张",g("select",{class:"pd-select",style:{width:"100%"},onChange:h=>{const m=h.target.value;if(m!=="CUSTOM"){a({sheetPaperSize:m});return}const b=Yn(d);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??b.width,sheetCustomHeight:o.sheetCustomHeight??b.height})}},[...gv.map(h=>g("option",{value:h,text:nt[h]?.label??h,selected:(o.sheetPaperSize??"A4")===h})),g("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),o.sheetPaperSize==="CUSTOM"?ie("目标纸宽高 (mm)",g("div",{class:"custom-size-grid"},[Z({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:h=>a({sheetCustomWidth:h})}),g("span",{class:"custom-size-x",text:"×"}),Z({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:h=>a({sheetCustomHeight:h})})])):ie("目标纸方向",kt("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",h=>a({sheetOrientation:h})),void 0,l("sheetOrientation")),st("拼版留白 (mm)"),g("div",{class:"margin-grid"},[ie("上",Z({value:o.sheetMargin.top??0,min:0,max:100,onCommit:h=>s("top",h)}),void 0,c("top")),ie("下",Z({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:h=>s("bottom",h)}),void 0,c("bottom")),ie("左",Z({value:o.sheetMargin.left??0,min:0,max:100,onCommit:h=>s("left",h)}),void 0,c("left")),ie("右",Z({value:o.sheetMargin.right??0,min:0,max:100,onCommit:h=>s("right",h)}),void 0,c("right"))]),st("格间距与列数"),ie("横向间距",Z({value:o.gapX??0,min:0,max:50,onCommit:h=>a({gapX:h??0})}),void 0,l("gapX")),ie("纵向间距",Z({value:o.gapY??0,min:0,max:50,onCommit:h=>a({gapY:h??0})}),void 0,l("gapY")),ie("列数",Z({value:o.columns??1,min:1,max:u,onCommit:h=>a({columns:h||1})})),...p.map(h=>g("p",{class:"pd-hint tiling-error",text:h.message})),!p.length&&f?g("p",{class:"pd-hint tiling-summary",text:f}):""]:""].flat().filter(Boolean))}const vv=new Set(Ar.map(t=>t.group)),wv={"table-settings":"content"},Fp=new Map;function fs(t){const e=t??"";let n=Fp.get(e);if(!n){const{groups:r,itemKeys:o}=fg(e);n={groups:r,keys:o,searching:!!e.trim()},Fp.set(e,n)}return n}function hs(t){const e=wv[t]??t;return vv.has(e)?e:""}function xv(t,e){const n=fs(t.state.propSearch);if(!n.searching)return!0;const r=hs(e);return!r||n.groups.includes(r)}function Ev(t,e){const n=fs(t.state.propSearch);return!n.searching||n.keys.has(e)}function zp(t,e){const n=t.props.style??{};return t.props.style={...n,display:e?"":"none"},t}function H(t,e,n){const r=n.props.dataset??{};return n.props.dataset={...r,propKey:e},zp(n,Ev(t,e))}function Sv(t,e,n){const r=hs(e);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},zp(n,xv(t,e))}function Bp(t,e){const n=fs(e);for(const r of Array.from(t.querySelectorAll("[data-prop-group]"))){const o=hs(r.dataset.propGroup??"");r.style.display=!n.searching||!o||n.groups.includes(o)?"":"none"}for(const r of Array.from(t.querySelectorAll("[data-prop-key]")))r.style.display=!n.searching||n.keys.has(r.dataset.propKey??"")?"":"none"}function _v(t){return g("div",{class:"property-search"},[g("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:t.state.propSearch??"",onInput:e=>{const n=e.target,r=n.value;t.state.propSearch=r,Bp(n.getRootNode(),r)}})])}const Mv={Document:"≡",Brush:"◧",Setting:"⚙"};function Tv(t,e){try{const n=window.localStorage.getItem(`property-group-${t}`);return n===null?e:n==="true"}catch{return e}}function kv(t,e){try{window.localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function Le(t,e,n,r,o,i=!0){const a=Tv(e,i);return Sv(t,e,g("div",{class:`property-group${a?" is-expanded":""}`},[g("div",{class:"group-header",onClick:()=>{kv(e,!a),t.repaint()}},[g("span",{class:"group-icon",text:Mv[r]||"•"}),g("span",{class:"group-title",text:n}),g("span",{class:"expand-icon",text:a?"▾":"▸"})]),g("div",{class:"group-content",style:a?"":{display:"none"}},o.filter(Boolean))]))}function Wo(t){return g("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function Hp(t){return t.split(".").flatMap(e=>{const n=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!n)return[e];const r=n[1],o=[...n[2].matchAll(/\[(\d+)\]/g)].map(i=>Number(i[1]));return[r,...o]})}function Up(t,e){return Hp(e).reduce((o,i)=>o==null?"":o[i],t)??""}function gs(t,e,n,r){const o=Hp(n),i=o.pop(),a=o.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);a[i]=r||void 0,t.recordHistory(),t.emit()}function Cv(t,e){const n=t.store;if(e.printElementType.type==="table"&&n.tableSelection?.elementId===e.id){const{r1:r,c1:o}=n.tableSelection,i=(e.options.tableRows??[])[r];if(i)return Kc(i.type,r,o,e.options.fields?.[0]?.dataSource)}return g0(e)}function Av(t,e){const n=document.createElement("label");n.className="pd-button small upload-label",Re(g("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[g("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),n);const r=document.createTextNode("上传图片"),o=document.createElement("input");o.className="visually-hidden",o.type="file",o.accept="image/*",n.append(r,o);const i=c=>{n.className=`pd-button small upload-label${c?" disabled":""}`,o.disabled=c};o.addEventListener("change",async()=>{const c=o.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),o.value="";return}const s=t.host.uploadImage;if(!s){alert("图片上传能力未配置"),o.value="";return}i(!0),r.textContent="上传中...";try{const d=await s(c);d?gs(t.store,e,"options.src",d):alert("图片上传失败")}catch(d){alert(d instanceof Error?d.message:"图片上传失败")}finally{r.textContent="上传图片",i(!t.host.uploadImage),o.value=""}}),t.host.uploadImage||i(!0);const a=document.createElement("div");a.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",a.append(n,l),a}function Ov(t,e){const n=r=>t.fire("open-expression",{elementId:e.id,targetPath:r.targetPath,value:Up(e,r.targetPath)});return Le(t,"binding","内容","Document",[...Cv(t,e).map(r=>ie(r.label,g("input",{class:"pd-input",type:"text",value:Up(e,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>gs(t.store,e,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),e.printElementType.type==="image"?Av(t,e):""].filter(Boolean))}const fr=new Map;function jo(t){return`${Math.round(t*1e4)/1e4}%`}function qp(t,e){const n=n0(e.value),r=n.kind==="custom",o=n.kind==="axes"?n.x:50,i=n.kind==="axes"?n.y:50,a=l0(e.src),l=fr.get(a.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},s=r0(c),d=o0(c,o,i),p=document.createElement("select");p.className="pd-select",p.style.width="100%";for(const m of p0(s,o,i)){const b=document.createElement("option");b.value=m.value,b.textContent=m.label,p.appendChild(b)}if(r){const m=document.createElement("option");m.value="custom",m.textContent="自定义(保留原值)",p.appendChild(m)}p.value=r?"custom":`${o},${i}`,p.selectedIndex<0&&(p.selectedIndex=r?p.options.length-1:0),p.addEventListener("change",()=>{if(p.value==="custom")return;const[m,b]=p.value.split(",").map(Number);e.onCommit(qc(m,b))});const u=Oe(e.fieldKey),f=[g("div",{class:"pd-field",dataset:{field:e.fieldKey}},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t"},[e.label,ps(u)]),e.resetAnchor??""].filter(Boolean)),p])];f.push(g("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t"},[c0,ps(Oe("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),Z({value:e.scale,min:Rn,max:el,step:5,placeholder:"默认 100",onCommit:m=>e.onScaleCommit(m>Rn?m:void 0)})]));for(const m of u0(s,o,i))f.push(g("div",{class:"pd-field",dataset:{field:e.fieldKey}},[g("span",{class:"pd-label",text:m.label}),Z({value:m.value,min:0,max:100,step:1,onCommit:b=>e.onCommit(qc(m.name==="horizontal"?b:o,m.name==="vertical"?b:i))})]));const h=d0(s,r);return h&&f.push(g("p",{class:"pd-crop-note",text:h})),a.isSample&&f.push(g("p",{class:"pd-crop-note",text:s0})),f.push(g("div",{class:"pd-crop-preview"},[g("img",{class:"pd-crop-thumb",src:a.src,alt:a.isSample?"示例图":"原图",onLoad:m=>{const b=m.target;if(!(b.naturalWidth>0&&b.naturalHeight>0))return;const v=fr.get(a.src);v&&v.width===b.naturalWidth&&v.height===b.naturalHeight||(fr.set(a.src,{width:b.naturalWidth,height:b.naturalHeight}),t.repaint())},onError:()=>{fr.has(a.src)&&(fr.delete(a.src),t.repaint())}}),d?g("div",{class:"pd-crop-win",style:{left:jo(d.leftPct),top:jo(d.topPct),width:jo(d.widthPct),height:jo(d.heightPct)}}):""])),g("div",{class:e.containerClass??"pd-crop-anchor"},f)}const Kt=t=>Number(t??0),ms=t=>t||void 0;function xn(t,e,n,r,o){return g("div",{class:"pd-field"},[g("span",{class:"pd-label",...r?{title:r}:{}},[g("span",{class:"pd-label-t",text:t}),o??""].filter(Boolean)),g("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:i=>n(i.target.checked)})])}function Wp(t,e,n,r,o=!1,i){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:t}),""].filter(Boolean)),g("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:a=>r(a.target.value)},n.map(a=>g("option",{value:a.value,text:a.label,selected:a.value===e})))])}function hr(t,e,n,r,o={}){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:t}),o.reset??""].filter(Boolean)),$p(e,n,r,{className:"pd-select",...o.full?{width:"100%"}:{}})])}const gr=t=>g("p",{class:"pd-hint",text:t}),Iv="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Pv=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Rv=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Dv=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],$v=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Nv={value:"__multi__",label:"多选",disabled:!0};function Lv(t,e){const n=t.store,r=n.tableSelection,o=e.options.tableRows??[],i=r?o[r.r1]:void 0;if(!r||!i)return Le(t,"table-row","行属性","Grid",[]);const a=l=>n.updateElement(e.id,l);return Le(t,"table-row","行属性","Grid",[Wo([Wp("行类型",i.type,Pv,l=>{const c=_i(o,r.r1,l);if(c){window.alert(c);return}a({tableRows:o})},!0),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"行高 (mm)"}),Z({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?xn("表头每页重复",i.repeatOnPage??!1,l=>{$h(o,l),a({tableRows:o})},Iv):""])])}function Fv(t,e){const n=t.store,r=e.options,o=d=>n.updateElement(e.id,d),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(d=>d.fieldType==="list").map(d=>({value:d.fieldKey,label:d.fieldLabel})),c=Ii("table"),s=d=>Xt({target:r,base:c,propKey:d,write:()=>o({[d]:c[d]})});return Le(t,"table-settings","表格设置","Grid",[Wo([Wp("列表数据源字段",r.dataSource??"",l,d=>o({dataSource:d||void 0}),!0),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认字体"}),s("tableDefaultFontFamily")]),qo({id:"table-default-font",state:t.state,fonts:t.host.fonts,value:r.tableDefaultFontFamily,placeholder:"默认",onChange:d=>o({tableDefaultFontFamily:d||void 0})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认字号 (pt)"}),s("tableDefaultFontSize")]),Z({value:Kt(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:d=>o({tableDefaultFontSize:ms(d)})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认文字颜色"}),s("tableDefaultColor")]),Xe(r.tableDefaultColor,d=>o({tableDefaultColor:d}),"默认文字颜色")]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),s("tableDefaultPadding")]),Z({value:Kt(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:d=>o({tableDefaultPadding:ms(d)})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((d,p)=>g("div",{class:"col-width-row"},[g("span",{style:{width:"60px"},text:`列${p+1}`}),Z({value:d,min:5,max:200,onCommit:u=>{const f=i.reduce((h,m,b)=>b===p?h:h+m,0);if(f+u>a){const h=Math.max(5,Math.round((a-f)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${p+1} 已调整为 ${h}mm`),i[p]=h}else i[p]=u;o({tableColWidths:i})}})]))])])])}function zv(t,e){const n=t.store,r=e.options,o=e.printElementType.type==="table",i=l=>n.updateElement(e.id,l),a=[];if(o)a.push(H(t,"pg-enabled",xn("启用分页",r.tablePagination?.enabled??!0,l=>i({tablePagination:{enabled:l}}))));else{const l=r.pagination?.pageable??!0,c=r.pagination?.keepWithNext??!1;a.push(H(t,"pg-pageable",xn("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(H(t,"pg-keep-with-next",xn("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return Le(t,"pagination","分页配置","Document",[Wo(a)],!1)}const bs=new WeakMap,jp=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Bv(t,e){const n=t.store,r=n.tableSelection,o=e.options.tableRows??[];if(!r)return Le(t,"table-cell","单元格","Menu",[]);const i=Si(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return Le(t,"table-cell","单元格","Menu",[]);const l=()=>kr(o,r),c=Mi(o,r),s=c.count,d=c.mode==="multi",p=`${e.id}:${r.r1}:${r.c1}:${r.r2}:${r.c2}`,u=bs.get(n),f=u?.key===p?u:{key:p,border:{},values:{},edges:{}};u?.key!==p&&bs.set(n,f);const h=M=>{bs.set(n,{key:p,border:M.border??f.border,values:M.values??f.values,edges:M.edges??f.edges})},m=(M,J)=>{h({border:{...f.border,[M]:J}}),t.repaint()},b=(M,J)=>{l().forEach(M),d&&J&&h({values:{...f.values,...J}}),n.updateElement(e.id,{tableRows:o})},v=(M,J)=>{b(ue=>{ue[M]=J},{[M]:J})},w=M=>d?f.values[M]:a[M],_=M=>d&&M in f.values,T=d?{width:void 0,style:void 0,color:void 0}:Sl(o,r),z=!d&&l().some(M=>!!M.borders&&!!(M.borders.top||M.borders.right||M.borders.bottom||M.borders.left)),N=!d&&!z,P={width:N?0:typeof T.width=="number"?T.width:St.width,style:N?"none":typeof T.style=="string"&&T.style!=="mixed"?T.style:St.style,color:typeof T.color=="string"&&T.color!=="mixed"?T.color:St.color,...f.border},k="__mixed__",S={style:!d&&T.style==="mixed",width:!d&&T.width==="mixed",color:!d&&T.color==="mixed"},C=S.style&&!("style"in f.border),O=S.width&&!("width"in f.border),R=S.color&&!("color"in f.border),I=C||O||R,x=C?k:P.style,j=O?void 0:P.width,te=R?void 0:P.color,fe=M=>{const J={style:M};M!=="none"&&j===0?J.width=St.width:M==="none"&&!z&&(J.width=0),h({border:{...f.border,...J}}),t.repaint()},G=()=>({...P}),de=d?jp.reduce((M,J)=>(M[J.value]=f.edges[J.value]?"on":"off",M),{}):Ml(l().map(M=>M.borders)),Ke=d?"cellType"in f.values?f.values.cellType??"text":zh(o,r):a.cellType??"text",ye=Ke==="barcode",Fe=Ke==="qrcode",D=Ke==="image",L=Ke==="text",W=ye&&!!w("printerDpi"),V=Xs(w("printerDpi"),w("barWidth")),Y=d?f.values.textFit:ii(a),X=d?"cellType"in f.values?f.values.cellType??"text":"":a.cellType||"text",ne=M=>d?[Nv,...M]:M,Q=M=>d?"多选":M,se=(M,J)=>d?f.values[M]:J,he=d?w("barcodeType")??"__multi__":a.barcodeType||"CODE128",_e=d?_("printerDpi")?w("printerDpi")?String(w("printerDpi")):"":"__multi__":a.printerDpi?String(a.printerDpi):"",K=d?w("qrCodeLevel")??"__multi__":a.qrCodeLevel||"M",yt=d?w("fit")??"__multi__":a.fit||"contain",ee=Y??"__multi__",lt=ml(o,r);let Me=!1;for(let M=r.r1;M<=r.r2&&!Me;M++)for(let J=r.c1;J<=r.c2&&!Me;J++){const ue=o[M]?.cells[J];ue&&!ue.merged&&((ue.rowspan??1)>1||(ue.colspan??1)>1)&&(Me=!0)}const Ae=(M,J,ue,le={},ze)=>g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:M}),ze??""].filter(Boolean)),Z({value:J,...le,onCommit:Pt=>v(ue,ms(Pt))})]),Ee="恢复默认值(跟随表格默认)",re=M=>Xt({target:a,base:{},propKey:M,tipOverride:Ee,force:d,write:()=>v(M,void 0)}),Ot=e.options.tableDefaultPadding??1,It={width:si(e.options.tableColWidths??[],i.c,a,Ot),height:An(o,i.r,a,Ot)};return Le(t,"table-cell","单元格","Menu",[Wo([d?gr(`已选 ${s} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"单元格类型"}),kt("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],X,M=>{const J=M==="text"?void 0:M,ue={cellType:M};M!=="barcode"&&Object.assign(ue,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),M!=="qrcode"&&Object.assign(ue,{qrCodeLevel:void 0,qrQuietZone:void 0}),b(le=>{le.cellType=J,M!=="barcode"&&(le.barcodeType=void 0,le.showBarcodeText=void 0,le.printerDpi=void 0,le.barQuietZone=void 0,le.barHeight=void 0),M!=="qrcode"&&(le.qrCodeLevel=void 0,le.qrQuietZone=void 0)},ue)})]),ye?hr("码制",he,ne(Rv),M=>{M!=="__multi__"&&v("barcodeType",M||void 0)}):"",ye?xn("显示文本",d?f.values.showBarcodeText===!0:a.showBarcodeText!==!1,M=>v("showBarcodeText",M),void 0,re("showBarcodeText")):"",ye?Ae("条宽(倍率)",se("barWidth",a.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:Q("")},re("barWidth")):"",ye?gr((W?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(V?`。${V}`:"")):"",ye?Ve("静区 (模块)",Z({value:se("barQuietZone",a.barQuietZone),min:0,max:20,placeholder:Q("默认 10"),onCommit:M=>v("barQuietZone",M)}),Oe("cd-bar-quiet-zone"),re("barQuietZone")):"",ye?Ve("条高 (mm)",Z({value:se("barHeight",a.barHeight),min:1,max:100,placeholder:Q("默认 30 模块"),onCommit:M=>v("barHeight",M??void 0)}),Oe("cd-bar-height"),re("barHeight")):"",ye?Ae("文本字号(相对条高,条高为 30)",se("barFontSize",a.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:Q("默认 10")},re("barFontSize")):"",ye?hr("打印机分辨率",_e,ne([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),M=>{if(M==="__multi__")return;const J=Number(M);v("printerDpi",J>0?J:void 0)},{reset:re("printerDpi")}):"",ye?gr("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",Fe?hr("纠错级别",K,ne(Dv),M=>{M!=="__multi__"&&v("qrCodeLevel",M||void 0)},{reset:re("qrCodeLevel")}):"",Fe?Ve("静区 (模块)",Z({value:se("qrQuietZone",a.qrQuietZone),min:0,max:8,placeholder:Q("默认 0"),onCommit:M=>v("qrQuietZone",M)}),Oe("cd-quiet-zone"),re("qrQuietZone")):"",ye?gr("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",Fe||D?hr("缩放模式",yt,ne(pa),M=>{M!=="__multi__"&&v("fit",M)},{reset:re("fit")}):"",D&&!d&&a.fit==="cover"?qp(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Gc(a.formatter),fit:a.fit,containerClass:"pd-cell-anchor",widthMm:It.width,heightMm:It.height,scale:a.fitScale,value:a.objectPosition,onCommit:M=>v("objectPosition",M),onScaleCommit:M=>v("fitScale",M),resetAnchor:re("objectPosition"),resetScale:re("fitScale")}):"",ye||Fe||D?Ae("最大宽度 (mm)",se("maxWidth",Kt(a.maxWidth)),"maxWidth",{min:0,max:200,placeholder:Q("默认")},re("maxWidth")):"",ye||Fe||D?Ae("最大高度 (mm)",se("maxHeight",Kt(a.maxHeight)),"maxHeight",{min:0,max:200,placeholder:Q("默认")},re("maxHeight")):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"内容"}),g("input",{class:"pd-input",type:"text",value:d?w("formatter")??"":a.formatter||"",placeholder:d?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:M=>v("formatter",M.target.value||void 0),onDblclick:()=>t.fire("table-cell-dblclick",{elementId:e.id,r:i.r,c:i.c,cellId:a.id})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"水平对齐"}),re("align")]),kt("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],d?f.values.align??"":a.align||"left",M=>v("align",M))]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"垂直对齐"}),re("valign")]),kt("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],d?f.values.valign??"":a.valign||"top",M=>v("valign",M))]),g("div",{class:"cell-style-grid"},[g("div",{class:"pd-field cell-font-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"字体"}),re("fontFamily")]),qo({id:"cell-font",state:t.state,fonts:t.host.fonts,value:d?w("fontFamily"):a.fontFamily,placeholder:Q("继承默认"),onChange:M=>v("fontFamily",M)})]),Ae("字号 (pt)",se("fontSize",Kt(a.fontSize)),"fontSize",{min:0,max:72,placeholder:Q("默认")},re("fontSize")),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"加粗"}),re("fontWeight")]),g("input",{class:"pd-switch",type:"checkbox",checked:d?f.values.fontWeight==="bold":a.fontWeight==="bold",onChange:M=>v("fontWeight",M.target.checked?"bold":void 0)})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"文字颜色"}),re("color")]),Xe(d?w("color"):a.color,M=>v("color",M),"文字颜色")]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"背景色"}),re("backgroundColor")]),Xe(d?w("backgroundColor"):a.backgroundColor,M=>v("backgroundColor",M),"背景颜色")])]),st("边框"),g("div",{class:"border-style-row"},[$p(x,[...C?[{value:k,label:"混合",disabled:!0}]:[],...ki],M=>{M!==k&&fe(M)},{width:"90px"}),g("div",{style:{width:"112px",flexShrink:"0"}},[Z({value:j,min:.25,max:5,step:.25,placeholder:d?"多选":O?"混合":void 0,onCommit:M=>m("width",M)})]),Xe(te,M=>m("color",M),"边框颜色")]),g("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([M,J])=>g("button",{type:"button",class:"pd-button small",text:J,onClick:()=>{xl(o,r,P.style==="none"?"none":M,G()),n.updateElement(e.id,{tableRows:o})}}))),g("div",{class:"pd-checkbox-group"},jp.map(M=>g("label",{class:"pd-checkbox"},[g("input",{type:"checkbox",value:M.value,checked:de[M.value]==="on",indeterminate:de[M.value]==="mixed",onChange:J=>{const le=J.target.checked&&P.style!=="none";d&&h({edges:{...f.edges,[M.value]:le}}),b(ze=>{El(ze,M.value,le?G():null)})}}),g("span",{text:M.label})]))),gr(d?Lh:I?Fh:Nh),Ae("内边距 (mm)",se("padding",Kt(a.padding)),"padding",{min:0,max:10,step:.5,placeholder:Q("默认")},re("padding")),xn("自动换行",d?f.values.wordWrap===!0:a.wordWrap??!0,M=>v("wordWrap",M),void 0,re("wordWrap")),L?hr("文字溢出",ee,ne($v),M=>{M!=="__multi__"&&v("textFit",M)},{full:!0,reset:re("textFit")}):"",L&&Y==="shrink"?Ae("最小字号 (pt)",se("shrinkMinFontSize",Kt(a.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:Q("默认 6")},re("shrinkMinFontSize")):"",g("div",{class:"merge-btns"},[g("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!lt,title:lt||"",onClick:()=>{bl(o,r),n.updateElement(e.id,{tableRows:o})}}),g("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Me,onClick:()=>{yl(o,r),n.updateElement(e.id,{tableRows:o})}})])])])}const ys=tm;function vs(t){const e=t.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function Hv(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function Uv(t){const e=t.store.templateData.watermark,n=Hv(e),r=e?.mode==="binding"||n!==""&&vs(n),o=(()=>{const s=e?.tileWidth??ae.tileWidth,d=e?.tileHeight??ae.tileHeight;for(const[p,u]of Object.entries(ys))if(u.width===s&&u.height===d)return p;return"custom"})(),i=s=>{const d={testData:e?.testData??"",rotate:e?.rotate??ae.rotate,color:e?.color||ae.color,opacity:e?.opacity??ae.opacity,tileWidth:e?.tileWidth??ae.tileWidth,tileHeight:e?.tileHeight??ae.tileHeight,timestamp:e?.timestamp,format:e?.format};t.store.updateTemplateData({watermark:{...d,...s}})},a=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n}),l={rotate:e?.rotate??ae.rotate,color:e?.color||ae.color,opacity:e?.opacity??ae.opacity,tileWidth:e?.tileWidth??ae.tileWidth,tileHeight:e?.tileHeight??ae.tileHeight},c=s=>Xt({target:l,base:ae,propKey:s,write:()=>i({[s]:ae[s]})});return g("div",{class:"watermark-config"},[st("水印"),g("form",{class:"pd-form",onSubmit:s=>s.preventDefault()},[g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"水印表达式"}),g("input",{class:"pd-input",type:"text",value:n,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:s=>{const d=s.target.value;i(vs(d)?{mode:"binding",binding:d,content:""}:{mode:"fixed",content:d,binding:""})},onDblclick:a}),g("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?ie("测试值",g("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:s=>i({testData:s.target.value})})):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),g("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??ae.rotate),onChange:s=>i({rotate:Number(s.target.value)})}),g("span",{class:"pd-hint",text:`${e?.rotate??ae.rotate}°`})]),ie("颜色",Xe(e?.color||ae.color,s=>i({color:s}),"水印颜色"),void 0,c("color")),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),g("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??ae.opacity),onChange:s=>i({opacity:Number(s.target.value)})}),g("span",{class:"pd-hint",text:(e?.opacity??ae.opacity).toFixed(2)})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"密度"}),g("select",{class:"pd-select",style:{width:"100%"},onChange:s=>{const d=s.target.value,p=ys[d];p&&i({tileWidth:p.width,tileHeight:p.height})}},[...Object.entries(ys).map(([s,d])=>g("option",{value:s,text:`${d.label}(${d.width}×${d.height})`,selected:o===s})),g("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),g("input",{type:"number",class:"pd-input",min:ae.minTileWidth,step:10,value:String(e?.tileWidth??ae.tileWidth),onChange:s=>i({tileWidth:Number(s.target.value)})})]):"",o==="custom"?g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),g("input",{type:"number",class:"pd-input",min:ae.minTileHeight,step:10,value:String(e?.tileHeight??ae.tileHeight),onChange:s=>i({tileHeight:Number(s.target.value)})})]):""].filter(Boolean))])}function Ce(t,e,n,r,o={},i){return ie(e,Z({value:n,...o,onCommit:r}),void 0,i)}function At(t,e,n,r,o,i,a){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>o(l.value));for(const c of r){const s=document.createElement("option");s.value=c.value,s.textContent=c.label,l.appendChild(s)}return l.value=n,r.some(c=>c.value===n)||(l.selectedIndex=-1),i?Ve(e,l,i,a):ie(e,l,void 0,a)}function En(t,e,n,r,o){return ie(e,g("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:i=>r(i.target.checked)}),void 0,o)}const qv=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],Wv=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function jv(t,e){const n=t.store,r=e.options,o=e.printElementType.type,i=x=>n.updateElement(e.id,x),a=o==="text"||o==="longText",l=o==="barcode"||o==="qrcode",c=o==="table",s=c&&n.tableSelection?.elementId===e.id,d=s&&Mi(e.options.tableRows??[],n.tableSelection).mode==="multi",p=[];s||p.push(Le(t,"position-size","位置与尺寸","Location",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[g("div",{class:"position-grid"},[H(t,"ps-left",Ce(t,"X",r.left,x=>i({left:x}),{min:0})),H(t,"ps-top",Ce(t,"Y",r.top,x=>i({top:x}),{min:0})),H(t,"ps-width",Ce(t,"W",r.width,x=>i({width:x}),{min:4})),H(t,"ps-height",Ce(t,"H",r.height,x=>i({height:x}),{min:4}))])])]));const u=Ii(o),f=(x,j)=>{const te=hg(j);return Xt({target:r,base:u,propKey:x,tipValue:te?.value,tipUnit:te?.unit,write:()=>i({[x]:u[x]})})},h=typeof r.rotate=="number"&&Number.isFinite(r.rotate)&&r.rotate!==0?Dn(r.rotate):void 0,m=x=>i({rotate:x===void 0||x===0?void 0:Dn(x)}),b=ch(o,r),v=sh(o)||sl(n.elements).has(e.id),w=v?"":H(t,"ap-rotate",Ve("旋转 (°)",g("div",{class:"pd-rotate-row"},[g("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>m((h??0)-90)}),g("div",{class:"pd-rotate-stepper"},[Z({value:h,min:0,max:359,placeholder:"0",disabled:!b,onCommit:x=>m(x)})]),g("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>m((h??0)+90)})]),Oe("ap-rotate"),f("rotate","ap-rotate"))),_=v||b?"":g("p",{class:"pd-hint pd-rotate-note",text:lh});if(p.push(Le(t,"appearance","外观","Brush",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},a?[H(t,"ap-font-family",ie("字体",qo({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:x=>i({fontFamily:x})}),void 0,f("fontFamily","ap-font-family"))),H(t,"ap-font-size",Ce(t,"字体大小",r.fontSize,x=>i({fontSize:x}),{min:8,max:72},f("fontSize","ap-font-size"))),H(t,"ap-font-weight",At(t,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],x=>i({fontWeight:x}),void 0,f("fontWeight","ap-font-weight"))),H(t,"ap-align",ie("对齐",kt("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",x=>i({textAlign:x})),void 0,f("textAlign","ap-align"))),H(t,"ap-vertical-align",ie("垂直对齐",kt("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",x=>i({verticalAlign:x})),void 0,f("verticalAlign","ap-vertical-align"))),g("div",{class:"color-row"},[H(t,"ap-color",ie("颜色",Xe(r.color,x=>i({color:x}),"字体颜色"),void 0,f("color","ap-color"))),H(t,"ap-bg-color",ie("背景色",Xe(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","ap-bg-color")))]),H(t,"ap-line-height",Ce(t,"行高",r.lineHeight,x=>i({lineHeight:x||void 0}),{min:0,max:100},f("lineHeight","ap-line-height"))),H(t,"ap-letter-spacing",Ce(t,"字间距",r.letterSpacing,x=>i({letterSpacing:x||void 0}),{min:0,max:20,step:.5},f("letterSpacing","ap-letter-spacing"))),H(t,"ap-text-fit",At(t,"文字溢出",wr(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],x=>i({textFit:x}),void 0,f("textFit","ap-text-fit"))),r.textFit==="shrink"?H(t,"ap-shrink-min",ie("最小字号 (pt)",Z({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:x=>i({shrinkMinFontSize:x||void 0})}),void 0,f("shrinkMinFontSize","ap-shrink-min"))):"",o==="longText"?H(t,"ap-long-text-indent",Ve("首行缩进 (字符)",Z({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:x=>i({longTextIndent:x||void 0})}),Oe("ap-long-text-indent"),f("longTextIndent","ap-long-text-indent"))):"",H(t,"ap-word-wrap",En(t,"自动换行",r.wordWrap!==!1,x=>i({wordWrap:x?void 0:!1}),f("wordWrap","ap-word-wrap"))),H(t,"ap-keep-line-breaks",En(t,"保留换行符",r.keepLineBreaks===!0,x=>i({keepLineBreaks:x?!0:void 0}),f("keepLineBreaks","ap-keep-line-breaks"))),w,_]:[o==="image"?H(t,"ap-img-fit",At(t,"缩放模式",String(r.fit??"contain"),pa,x=>i({fit:x}),Oe("ap-img-fit"),f("fit","ap-img-fit"))):"",o==="image"&&r.fit==="cover"?H(t,"ap-img-object-position",qp(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Gc(r.src),widthMm:Number(r.width)||0,heightMm:Number(r.height)||0,fit:r.fit,scale:r.fitScale,value:r.objectPosition===void 0?void 0:String(r.objectPosition),onCommit:x=>i({objectPosition:x}),onScaleCommit:x=>i({fitScale:x}),resetAnchor:f("objectPosition","ap-img-object-position"),resetScale:f("fitScale","ap-img-fit-scale")})):"",w,_,o==="flowList"?g("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const x=o==="barcode",j=String(r.barcodeType||"CODE128").toUpperCase(),te=r.printerDpi?String(r.printerDpi):"",fe=Xs(r.printerDpi,r.barWidth);p.push(Le(t,"code","条码设置","Postcard",[g("form",{class:"pd-form",onSubmit:G=>G.preventDefault()},[x?[H(t,"cd-type",At(t,"码制",j,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],G=>i({barcodeType:G==="CODE128"?void 0:G}))),H(t,"cd-dpi",At(t,"打印机分辨率",te,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],G=>i({printerDpi:Number(G)>0?Number(G):void 0}),void 0,f("printerDpi","cd-dpi"))),H(t,"cd-dpi",g("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),H(t,"cd-bar-width",Ce(t,"条宽(倍率)",r.barWidth??2,G=>i({barWidth:G}),{min:2,max:8,step:.5},f("barWidth","cd-bar-width"))),H(t,"cd-bar-width",g("p",{class:"pd-hint",text:(te?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(fe?`。${fe}`:"")})),H(t,"cd-bar-quiet-zone",Ve("静区 (模块)",Z({value:r.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:G=>i({barQuietZone:G})}),Oe("cd-bar-quiet-zone"),f("barQuietZone","cd-bar-quiet-zone"))),H(t,"cd-bar-height",Ve("条高 (mm)",Z({value:r.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:G=>i({barHeight:G??void 0})}),Oe("cd-bar-height"),f("barHeight","cd-bar-height"))),H(t,"cd-show-text",En(t,"显示文本",r.hideTitle!==!0,G=>i({hideTitle:G?void 0:!0}),f("hideTitle","cd-show-text"))),H(t,"cd-font-size",ie("文本字号(相对条高,条高为 30)",Z({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:G=>i({fontSize:G||void 0})}),void 0,f("fontSize","cd-font-size")))]:[H(t,"cd-ec-level",At(t,"纠错级别",String(r.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],G=>i({qrCodeLevel:G}),void 0,f("qrCodeLevel","cd-ec-level"))),H(t,"cd-quiet-zone",Ve("静区 (模块)",Z({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:G=>i({qrQuietZone:G})}),Oe("cd-quiet-zone"),f("qrQuietZone","cd-quiet-zone")))],st("自定义设置"),x?g("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",x?"":H(t,"cd-fit",At(t,"缩放模式",String(r.fit||"contain"),pa,G=>i({fit:G||void 0}),void 0,f("fit","cd-fit"))),H(t,"cd-max-width",ie("最大宽度 (mm)",Z({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxWidth:G||void 0})}),void 0,f("maxWidth","cd-max-width"))),H(t,"cd-max-height",ie("最大高度 (mm)",Z({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxHeight:G||void 0})}),void 0,f("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(d||p.push(Ov(t,e)),s&&(p.push(Lv(t,e)),p.push(Bv(t,e))),c&&p.push(Fv(t,e)),o==="flowList"){const x=ut(r.flowColumns),j=On(r.flowRowHeight),te=wt(r.flowGapX),fe=Qt(r.flowMaxSpan,x),G=Kf(r.width??0,te,r.fontSize??12);p.push(Le(t,"flowList","流式列表","Grid3x3",[g("form",{class:"pd-form",onSubmit:de=>de.preventDefault()},[H(t,"fl-columns",Ve("每行列数",Z({value:x,min:1,max:12,onCommit:de=>i({flowColumns:ut(de),flowMaxSpan:Qt(r.flowMaxSpan,ut(de))})}),Oe("fl-columns"))),H(t,"fl-row-height",Ve("行高 (mm)",Z({value:j,min:3,max:100,step:.5,onCommit:de=>i({flowRowHeight:On(de)})}),Oe("fl-row-height"))),H(t,"fl-gap-x",Ve("单元横向间距 (mm)",Z({value:te,min:0,max:50,step:.5,onCommit:de=>i({flowGapX:wt(de)})}),Oe("fl-gap-x"))),H(t,"fl-auto-span",En(t,"内容过长时跨列",r.flowAutoSpan===!0,de=>{i(de?{flowAutoSpan:de,flowMaxSpan:fe}:{flowAutoSpan:de})})),r.flowAutoSpan===!0?H(t,"fl-max-span",Ve("最多跨几列",Z({value:fe,min:1,max:x,onCommit:de=>i({flowMaxSpan:Qt(de,x)})}),Oe("fl-max-span"))):"",x>G?g("p",{class:"pd-hint",text:`按当前字号与框宽,${x} 列偏挤(可放约 ${G} 列)。数值保持不变,出纸按 ${x} 列排。`}):""].flat().filter(Boolean))]))}const T=()=>({borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:r.borders}),z=x=>{const j=T();Tl(j,x,Al(j)),i(j)},N=x=>{const j=T();Ai(j,x,!Fn(j,x)),i(j)},P=Cl(r),k=P.style==="mixed",S=typeof P.width=="number"?P.width:void 0,C=k||P.style===void 0?"":P.style,O=typeof P.color=="string"?P.color:void 0,R=(x,j)=>{const te=T();Xh(te,x,j),i(te)},I=k?[{value:"",label:"混合"},...ki]:[...ki];return p.push(Le(t,"border-bg","边框与背景","Picture",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[H(t,"bb-border-style",At(t,"线型",C,I,x=>R("borderStyle",x))),g("div",{class:"border-row"},[H(t,"bb-border-width",Ce(t,"边框宽度",S,x=>R("borderWidth",x),{min:0,max:20,step:.25,placeholder:P.width==="mixed"?"混合":void 0},f("borderWidth","bb-border-width"))),H(t,"bb-border-color",ie("边框颜色",Xe(O,x=>R("borderColor",x),"边框颜色"),void 0,f("borderColor","bb-border-color")))]),...fi(o)?[g("div",{class:"pd-button-group border-presets"},qv.map(x=>g("button",{type:"button",class:"pd-button small",text:x.label,disabled:x.value==="inner",onClick:()=>z(x.value)}))),g("div",{class:"pd-checkbox-group"},Wv.map(x=>g("label",{class:"pd-checkbox"},[g("input",{type:"checkbox",checked:Fn(r,x.value),onChange:()=>N(x.value)}),g("span",{text:x.label})]))),g("p",{class:"pd-hint",text:Uh})]:[],H(t,"bb-bg-color",ie("背景色",Xe(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","bb-bg-color")))])])),p.push(zv(t,e)),p.push(Le(t,"advanced","高级设置","Setting",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[g("div",{class:"advanced-row"},[H(t,"ad-locked",En(t,"锁定",!!r.locked,x=>i({locked:x}),f("locked","ad-locked"))),H(t,"ad-fixed",En(t,"每页重复",!!r.fixed,x=>i({fixed:x}),f("fixed","ad-fixed")))]),H(t,"ad-z-index",Ce(t,"层级",r.zIndex,x=>i({zIndex:x}),{min:0,max:999},f("zIndex","ad-z-index"))),H(t,"ad-delete",g("div",{class:"pd-field"},[g("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>n.deleteSelected()})]))])],!1)),g("div",{class:"property-content"},p)}function Gv(t){const e=t.store,n=e.templateData,r=c=>e.updateTemplateData(c),o=c=>{const s=n.tiling,d=p=>p===90||p===270;if(s?.enabled&&d(c)!==d(n.outputRotation)){const p=Fc({...n,outputRotation:c});r({outputRotation:c,tiling:{...s,columns:Math.max(p,1)}});return}r({outputRotation:c})},i=[];for(const[c,s]of Object.entries(nt)){const d=s.group??"其他";let p=i.find(u=>u.group===d);p||(p={group:d,items:[]},i.push(p)),p.items.push({key:c,label:s.label??c})}const a=!nt[n.paperSize],l=wi(n.paperSize);return g("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[st("纸张设置"),ie("纸张尺寸",g("select",{class:"pd-select",style:{width:"100%"},onChange:c=>r({paperSize:c.target.value})},[...i.map(c=>g("optgroup",{label:c.group},c.items.map(s=>g("option",{value:s.key,text:s.label,selected:n.paperSize===s.key})))),g("option",{value:"CUSTOM",text:"自定义宽高",selected:a})])),l||a?ie(l?"纸宽 (mm)":"自定义宽高 (mm)",g("div",{class:"custom-size-grid"},[Z({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:c=>r({customWidth:c})}),...a?[g("span",{class:"custom-size-x",text:"×"}),Z({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:c=>r({customHeight:c})})]:[]])):"",l?"":ie("纸张方向",kt("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",c=>r({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":ie("内容旋转角度",kt("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),c=>o(Number(c)),!0),n.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),ie("页面背景色",g("div",{class:"page-bg-row"},[Xe(n.pageBackground,c=>r({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,Xt({target:n,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>r({pageBackground:void 0})})),bv(t),e.pages.length>1?"":yv(t),st("页边距 (mm)"),g("div",{class:"margin-grid"},[Ce(t,"上",n.margins.top,c=>r({margins:{...n.margins,top:c}}),{min:0,max:50}),Ce(t,"下",n.margins.bottom,c=>r({margins:{...n.margins,bottom:c}}),{min:0,max:100}),Ce(t,"左",n.margins.left,c=>r({margins:{...n.margins,left:c}}),{min:0,max:50}),Ce(t,"右",n.margins.right,c=>r({margins:{...n.margins,right:c}}),{min:0,max:50})]),st("页眉/页脚高度 (mm)"),Ce(t,"页眉高度",n.header.height??10,c=>r({header:{...n.header,height:c}}),{min:0,max:100,step:.1}),Ce(t,"页脚高度",n.footer.height??10,c=>r({footer:{...n.footer,height:c}}),{min:0,max:100,step:.1}),Uv(t)].filter(Boolean))}function Yv(t){const e=t.store,n=t.state,r=e.selectedElement;if(n.propCollapsed)return g("div",{class:"property-panel collapsed"},[g("div",{class:"prop-collapsed"},[g("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{n.propCollapsed=!1,t.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([i,a,l])=>g("button",{type:"button",class:`pc-btn${n.propTab===i?" on":""}`,title:a,text:l,onClick:()=>{n.propTab=i,n.propCollapsed=!1,t.repaint()}}))])]);const o=r?n.propTab:"page";return g("div",{class:"property-panel"},[g("div",{class:"prop-head"},[g("span",{class:"prop-title",text:"属性台"}),g("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{n.propCollapsed=!0,t.repaint()}})]),g("div",{class:"pd-tabs prop-tabs"},[g("div",{class:"pd-tab-bar",role:"tablist"},[g("button",{type:"button",class:`pd-tab${o==="element"?" active":""}`,text:"元素属性",onClick:()=>{n.propTab="element",t.repaint()}}),g("button",{type:"button",class:`pd-tab${o==="page"?" active":""}`,text:"页面属性",onClick:()=>{n.propTab="page",t.repaint()}})]),g("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="element"?"":{display:"none"}},r?[_v(t),jv(t,r)]:[g("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),g("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="page"?"":{display:"none"}},[Gv(t)])])])}const ws=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Gp={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},Vv=[{name:"SUM",label:"求和",template:"SUM()"},{name:"AVG",label:"平均值",template:"AVG()"},{name:"COUNT",label:"计数",template:"COUNT()"},{name:"MIN",label:"最小值",template:"MIN()"},{name:"MAX",label:"最大值",template:"MAX()"}],Xv=[{name:"ADD",label:"相加",template:"ADD()"},{name:"SUB",label:"相减",template:"SUB()"},{name:"MUL",label:"相乘",template:"MUL()"},{name:"DIV",label:"相除",template:"DIV()"},{name:"ROUND",label:"四舍五入",template:"ROUND()"},{name:"ROUNDUP",label:"进一法",template:"ROUNDUP()"},{name:"ROUNDDOWN",label:"去尾法",template:"ROUNDDOWN()"},{name:"ROUNDBANK",label:"四舍六入五成双",template:"ROUNDBANK()"}],Kv=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],Zv=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],Jv=[{title:"聚合函数",items:Vv},{title:"数值运算",items:Xv},{title:"格式化函数",items:Kv}],Qv="(输入表达式后预览)",ew="(无法计算)",xs="(表达式错误)";function Yp(t,e){if(!t.trim())return Qv;try{const n={...it,...e??{},...$r()},r=dn(t,n);return r==null?ew:String(r)}catch{return xs}}function Vp(t,e){const n=e.trim().toLowerCase();return n?t.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):t}function tw(t,e){const n=t.substring(0,e),r=n.lastIndexOf("{"),o=r!==-1&&!n.slice(r+1).includes("}"),i=n.lastIndexOf("("),a=i!==-1&&!n.slice(i+1).includes(")");return{insideBlock:o,insideParens:a}}function nw(t,e){const n=/^\{\s*([^{}]+?)\s*\}$/.exec(t.trim());if(!n)return null;const r=n[1]??"";return e.find(o=>o.fieldKey===r)??null}function Es(t,e){return g("div",{class:"ee-field-info"},[g("span",{class:"ee-item-label",text:t}),g("span",{class:"ee-item-key",text:e})])}function Zt(t){return t.currentTarget.getRootNode()}function Go(t,e,n){const r=[];return n.forEach((o,i)=>{r.push(o),i<n.length-1&&r.push(g("br"))}),g("div",{class:`ee-help-card ${t}`},[g("div",{class:"ee-help-card-title",text:e}),g("div",{class:"ee-help-card-content"},r)])}function rw(){return g("div",{class:"ee-help-section"},[g("div",{class:"ee-help-title",text:"帮助信息"}),g("div",{class:"ee-help-grid"},[Go("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Go("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Go("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Go("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function ow(t,e){const n={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},r=(h,m)=>h.querySelector(m),o=h=>{const m=r(h,".ee-preview");if(!m)return;const b=Yp(n.expression,t.demoData);m.textContent=b,m.classList.toggle("ee-preview-error",b===xs)},i=()=>{if(n.activeTab==="variable")return Vp(Zv,n.searchText).map(b=>g("div",{class:"ee-list-item",onDblclick:v=>{const{insideParens:w}=l(v);c(Zt(v),w?b.template.replace(/^\{|\}$/g,""):b.template)}},[Es(b.label,b.template)]));if(n.activeTab==="function")return Jv.map(b=>g("div",{class:"ee-func-group"},[g("div",{class:"ee-func-group-title",text:b.title}),...Vp(b.items,n.searchText).map(v=>g("div",{class:"ee-list-item",onDblclick:w=>{const{insideBlock:_}=l(w),T=_?v.template:`{${v.template}}`;c(Zt(w),T,T.indexOf("(")+1)}},[Es(v.label,`${v.name}()`)]))]));const h=f0(Xc(t.fields??[]),n.searchText);if(!h.length)return[g("p",{class:"pd-empty",text:"暂无字段"})];const m=[];for(const b of h){b.key&&m.push(g("div",{class:`ee-field-group${b.isList?" is-list":""}`},[g("span",{class:"ee-field-group-icon",text:b.isList?"📋":"📁"}),g("span",{text:b.label})]));for(const v of b.fields)m.push(g("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:b.key?"22px":"10px"},onDblclick:w=>{const{insideParens:_}=l(w);c(Zt(w),_?v.fieldKey:`{${v.fieldKey}}`)}},[Es(v.fieldLabel,v.fieldKey)]))}return m},a=h=>{Array.from(h.querySelectorAll(".ee-nav-tab")).forEach((_,T)=>_.classList.toggle("active",ws[T]?.key===n.activeTab));const b=r(h,".ee-content-search .pd-input");if(b){const _=Gp[n.activeTab];b.placeholder!==_&&(b.placeholder=_),b.value!==n.searchText&&(b.value=n.searchText)}const v=r(h,".ee-textarea");v&&v.value!==n.expression&&(v.value=n.expression);const w=r(h,".ee-content-list");if(w){Gu(w);for(const _ of i())Re(_,w)}o(h)},l=h=>{const b=r(Zt(h),".ee-textarea")?.selectionStart??n.expression.length;return tw(n.expression,b)},c=(h,m,b=m.length)=>{const v=r(h,".ee-textarea");if(!v){n.expression+=m,o(h);return}const w=v.selectionStart??n.expression.length,_=v.selectionEnd??w;n.expression=n.expression.substring(0,w)+m+n.expression.substring(_);const T=w+b;v.value=n.expression,v.focus(),v.selectionStart=v.selectionEnd=T,o(h)},s=()=>{const h=n.expression;if(n.binding===void 0){t.onApply({formatter:h}),t.onClose();return}const m=nw(h,t.fields??[]);t.onApply(m?{formatter:h,binding:m.fieldKey,title:m.fieldLabel}:{formatter:h}),t.onClose()},d=g("div",{class:"ee-nav"},[g("div",{class:"ee-nav-title",text:"类型"}),g("div",{class:"ee-nav-tabs"},ws.map((h,m)=>g("div",{class:`ee-nav-tab${n.activeTab===h.key?" active":""}`,text:h.text,onClick:b=>{n.activeTab=ws[m].key,a(Zt(b))}})))]),p=g("div",{class:"ee-content"},[g("div",{class:"ee-content-search"},[g("input",{class:"pd-input",placeholder:Gp[n.activeTab],onInput:h=>{n.searchText=h.target.value,a(Zt(h))}})]),g("div",{class:"ee-content-list"},i())]),u=Yp(n.expression,t.demoData),f=g("div",{class:"ee-editor"},[g("div",{class:"ee-editor-section"},[g("div",{class:"ee-editor-title",text:"表达式编辑"}),g("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:n.expression,onInput:h=>{n.expression=h.target.value,o(Zt(h))}})]),g("div",{class:"ee-editor-section"},[g("div",{class:"ee-editor-title",text:"预览结果"}),g("div",{class:`ee-preview${u===xs?" ee-preview-error":""}`,text:u})]),rw()]);return g("div",{class:"pd-dialog-overlay",onKeydown:h=>{h.key==="Escape"&&t.onClose()}},[g("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[g("header",{class:"pd-dialog-header"},[g("strong",{id:"expression-editor-title",text:"编辑表达式"}),g("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>t.onClose()})]),g("div",{class:"expression-editor"},[d,p,f]),g("footer",{class:"pd-dialog-footer"},[g("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>t.onClose()}),g("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>s()})])])])}const Yo=[{id:"getting-started",title:"快速入门",content:`
257
+ `);const R=_(P,k,C),I=t.getSymbolSize(P),x=new r(I);return f(x,P),h(x),m(x,P),v(x,k,0),P>=7&&b(x,P),w(x,R),isNaN(S)&&(S=a.getBestMask(x,v.bind(null,x,k))),a.applyMask(S,x),v(x,k,S),{modules:x,version:P,errorCorrectionLevel:k,maskPattern:S,segments:C}}return ba.create=function(P,k){if(typeof P>"u"||P==="")throw new Error("No input text");let S=e.M,C,O;return typeof k<"u"&&(S=e.from(k.errorCorrectionLevel,e.M),C=s.from(k.version),O=a.from(k.maskPattern),k.toSJISFunc&&t.setToSJISFunction(k.toSJISFunc)),z(P,C,S,O)},ba}var La={},Fa={},Lu;function Fu(){return Lu||(Lu=1,(function(t){function e(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(i){return[i,i]}))),r.length===6&&r.push("F","F");const o=parseInt(r.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const o=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,i=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:i,scale:i?4:a,margin:o,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},t.getImageWidth=function(r,o){const i=t.getScale(r,o);return Math.floor((r+o.margin*2)*i)},t.qrToImageData=function(r,o,i){const a=o.modules.size,l=o.modules.data,c=t.getScale(a,i),s=Math.floor((a+i.margin*2)*c),d=i.margin*c,p=[i.color.light,i.color.dark];for(let u=0;u<s;u++)for(let f=0;f<s;f++){let h=(u*s+f)*4,m=i.color.light;if(u>=d&&f>=d&&u<s-d&&f<s-d){const b=Math.floor((u-d)/c),v=Math.floor((f-d)/c);m=p[l[b*a+v]?1:0]}r[h++]=m.r,r[h++]=m.g,r[h++]=m.b,r[h]=m.a}}})(Fa)),Fa}var zu;function Tb(){return zu||(zu=1,(function(t){const e=Fu();function n(o,i,a){o.clearRect(0,0,i.width,i.height),i.style||(i.style={}),i.height=a,i.width=a,i.style.height=a+"px",i.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(i,a,l){let c=l,s=a;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),a||(s=r()),c=e.getOptions(c);const d=e.getImageWidth(i.modules.size,c),p=s.getContext("2d"),u=p.createImageData(d,d);return e.qrToImageData(u.data,i,c),n(p,s,d),p.putImageData(u,0,0),s},t.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const s=t.render(i,a,c),d=c.type||"image/png",p=c.rendererOpts||{};return s.toDataURL(d,p.quality)}})(La)),La}var za={},Bu;function kb(){if(Bu)return za;Bu=1;const t=Fu();function e(o,i){const a=o.a/255,l=i+'="'+o.hex+'"';return a<1?l+" "+i+'-opacity="'+a.toFixed(2).slice(1)+'"':l}function n(o,i,a){let l=o+i;return typeof a<"u"&&(l+=" "+a),l}function r(o,i,a){let l="",c=0,s=!1,d=0;for(let p=0;p<o.length;p++){const u=Math.floor(p%i),f=Math.floor(p/i);!u&&!s&&(s=!0),o[p]?(d++,p>0&&u>0&&o[p-1]||(l+=s?n("M",u+a,.5+f+a):n("m",c,0),c=0,s=!1),u+1<i&&o[p+1]||(l+=n("h",d),d=0)):c++}return l}return za.render=function(i,a,l){const c=t.getOptions(a),s=i.modules.size,d=i.modules.data,p=s+c.margin*2,u=c.color.light.a?"<path "+e(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",f="<path "+e(c.color.dark,"stroke")+' d="'+r(d,s,c.margin)+'"/>',h='viewBox="0 0 '+p+" "+p+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+h+' shape-rendering="crispEdges">'+u+f+`</svg>
258
+ `;return typeof l=="function"&&l(null,b),b},za}var Hu;function Cb(){if(Hu)return gn;Hu=1;const t=lb(),e=Mb(),n=Tb(),r=kb();function o(i,a,l,c,s){const d=[].slice.call(arguments,1),p=d.length,u=typeof d[p-1]=="function";if(!u&&!t())throw new Error("Callback required as last argument");if(u){if(p<2)throw new Error("Too few arguments provided");p===2?(s=l,l=a,a=c=void 0):p===3&&(a.getContext&&typeof s>"u"?(s=c,c=void 0):(s=c,c=l,l=a,a=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(l=a,a=c=void 0):p===2&&!a.getContext&&(c=l,l=a,a=void 0),new Promise(function(f,h){try{const m=e.create(l,c);f(i(m,a,c))}catch(m){h(m)}})}try{const f=e.create(l,c);s(null,i(f,a,c))}catch(f){s(f)}}return gn.create=e.create,gn.toCanvas=o.bind(null,n.render),gn.toDataURL=o.bind(null,n.renderToDataURL),gn.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),gn}var Ab=Cb();const Ob=td(Ab),Uu="http://www.w3.org/2000/svg";function Ib(t){const e=t.getAttribute("viewBox");if(!e)return null;const n=e.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))?null:{width:n[2],height:n[3]}}function Pb(t,e){const n=document.createElementNS(Uu,"svg"),r=Pn(e.barWidth),o=ci(e.barQuietZone),i=l=>{ga(n,t,{format:e.barcodeType||"CODE128",width:r,height:l*r,displayValue:e.showText!==!1,fontSize:(e.fontSize??Er)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:di*r});const c=Ib(n);return c?{widthUnits:c.width,heightUnits:c.height}:null},a=pi({barHeightMm:e.barHeightMm,boxWidthMm:e.targetWidthMm??0,boxHeightMm:e.targetHeightMm??0,dpi:e.printerDpi,barWidth:e.barWidth,measure:i});return a.size&&(n.setAttribute("width",`${a.size.widthMm}mm`),n.setAttribute("height",`${a.size.heightMm}mm`)),n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}function Rb(t){return typeof t=="number"&&Number.isFinite(t)?Math.max(0,Math.floor(t)):Xs}function Db(t,e){const n=(e.qrCodeLevel??"M").toUpperCase(),o=Ob.create(t,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=Rb(e.qrQuietZone)*a,c=i*a+l*2;let s="";for(let d=0;d<i;d++)for(let p=0;p<i;p++)o.get(p,d)&&(s+=`<rect x="${l+p*a}" y="${l+d*a}" width="${a}" height="${a}" fill="#000"/>`);return`<svg xmlns="${Uu}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function qu(t,e,n={}){if(!t)throw new Error("empty barcode value");return e==="qrcode"?Db(t,n):Pb(t,n)}const Ba={render(t,e,n={}){return qu(t,e,n)}},Ha=.5,$b=12;function Ua(t,e){const n=t.getAttribute(e);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function Wu(t,e){if(t.scrollWidth>t.clientWidth+Ha)return!0;const n=t.scrollHeight;return e!==void 0?n>e+Ha:n>t.clientHeight+Ha}function ju(t){if(t.getAttribute("data-fit")!=="shrink")return;const e=Cn(Ua(t,"data-fit-min")),n=Math.max(Ua(t,"data-fit-base")??e,e),r=Ua(t,"data-fit-mm"),o=r!==void 0&&r>0?$t(r):void 0,i=s=>{const d=zf(s);return t.style.fontSize=`${d}pt`,t.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!Wu(t,o)||n<=e)return a;let l=e,c=n;for(let s=0;s<$b;s++){const d=(l+c)/2;i(d),Wu(t,o)?c=d:l=d}return i(l)}function Nb(t){const e=[];return t.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=ju(n),o=n.getAttribute("data-fit-key");r===void 0||!o||e.push({key:o,fontSizePt:r})}),e}const Lb="2",Fb=5e3;async function zb(t,e=Fb){const n=t.document,r=i=>Promise.race([i,new Promise(a=>setTimeout(a,e))]),o=(async()=>{n.readyState!=="complete"&&await r(new Promise(a=>t.addEventListener("load",()=>a(),{once:!0})));const i=n.fonts;i&&(await r(Promise.all(Bb(n).map(a=>i.load(`${a.style} ${a.weight} 16px "${a.family}"`).catch(()=>{})))),i.ready&&await r(i.ready)),await r(Promise.all(Array.from(n.images??[]).map(a=>a.complete?Promise.resolve():new Promise(l=>{a.addEventListener("load",()=>l(),{once:!0}),a.addEventListener("error",()=>l(),{once:!0})}))))})();await r(o)}function Bb(t){const e=[];for(const r of Array.from(t.styleSheets??[])){let o;try{o=r.cssRules}catch{continue}for(const i of Array.from(o??[])){if(i.type!==5)continue;const a=i.style,l=(a.getPropertyValue("font-family")||"").replace(/^["']|["']$/g,"");l&&e.push({family:l,weight:a.getPropertyValue("font-weight")||"400",style:a.getPropertyValue("font-style")||"normal"})}}return e}function Hb(t){const e=[];return t.querySelectorAll("[data-measure-id]").forEach(n=>{const r=n,o=r.getAttribute("data-measure-id");if(!o)return;const i=r.getBoundingClientRect().height,a=r.querySelector("table.print-table");if(!a){e.push({id:o,heightPx:i});return}const l=[];a.querySelectorAll("tbody > tr[data-row-index]").forEach(c=>{l.push(c.getBoundingClientRect().height)}),e.push({id:o,heightPx:i,rowHeightsPx:l})}),e}function Ub(t){const e=t.querySelector(".print-page"),n=t.querySelector(".content-area");if(!e||!n)return 0;const r=e.getBoundingClientRect().top;let o=0;n.querySelectorAll("*").forEach(a=>{const l=a.getBoundingClientRect();l.height>0&&(o=Math.max(o,l.bottom-r))});const i=n.getBoundingClientRect();return i.height>0&&(o=Math.max(o,i.bottom-r)),o}function qb(t){const e={};for(const n of t)try{e[n.key]=qu(n.value,n.cellType,n.opts)}catch{}return e}const Wb={version:Lb,waitReady:zb,readMeasurements:Hb,readContentBottom:Ub,renderCodes:qb,applyTextFit:Nb};function jb(){return{async createDriver(){const t=document.createElement("iframe");t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;left:-10000px;top:0;border:0;visibility:hidden;pointer-events:none;",document.body.appendChild(t);let e=t.contentDocument??document;return{requiresExecutor:!1,async open(n){t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,e=t.contentDocument??document},async setContent(n){e=t.contentDocument??document,e.open(),e.write(n),e.close()},async injectExecutor(n){},async evaluate(n,r){const o=Wb[n],i=r??[],a=$m[n];return a==="window"?o(t.contentWindow,...i):a==="document"?o(e,...i):o(...i)},async close(){t.remove()}}}}}function Gb(){return Fm(jb())}async function Yb(t,e,n,r,o){const i=await Xm({templateJson:t,printData:e,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r},Gb());return{html:i.html,pageCount:i.pageCount,pageLayouts:i.pageLayouts,paperMm:i.paperMm,continuous:i.continuous,copies:i.copies,copyPaperMm:i.copyPaperMm}}function g(t,e={},n=[]){return{tag:t,props:e,children:n}}const Gu="http://www.w3.org/2000/svg",Vb=new Set(["draggable","contenteditable","spellcheck"]),Xb=new Set(["indeterminate"]);function Kb(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function Re(t,e){if(typeof t=="string"){const a=document.createTextNode(t);return e.appendChild(a),a}if(t instanceof Node)return e.appendChild(t),t;const{tag:n,props:r,children:o}=t,i=Kb(n)?document.createElementNS(Gu,n):document.createElement(n);for(const[a,l]of Object.entries(r))if(!(l==null||l===!1))if(a==="class")i.setAttribute("class",String(l));else if(a==="style")typeof l=="string"?i.style.cssText=l:Object.assign(i.style,l);else if(a==="html")i.innerHTML=String(l);else if(a==="text")i.textContent=String(l);else if(a.startsWith("on")&&typeof l=="function")i.addEventListener(a.slice(2).toLowerCase(),l);else if(a==="dataset")for(const[c,s]of Object.entries(l))i.dataset[c]=s;else Xb.has(a)?i[a]=!0:typeof l=="boolean"?l&&i.setAttribute(a,Vb.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)Re(a,i);return e.appendChild(i),i}function Yu(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const Zb=Gu;function ir(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const qa="开启拼版后只能有一个设计页面";function Wa(t){const e=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&Nn(i),{id:o.id||sn(),zone:r,options:i,printElementType:{...o.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},guides:[...t.guides??[]],elements:[...e(t.elements??[],"content"),...e(t.header?.elements??[],"header"),...e(t.footer?.elements??[],"footer")]}}function Vu(t){const e=t.elements,n=r=>e.filter(o=>(o.zone||"content")===r).map(o=>({id:o.id,type:o.printElementType.type,options:{...o.options},printElementType:{...o.printElementType}}));return{unit:"mm",...t,header:{...t.header,elements:n("header")},footer:{...t.footer,elements:n("footer")},elements:n("content"),guides:[...t.guides??[]]}}function Xu(t){const e=(r,o)=>{const i=Wa(kh(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!t)return[e(ir(),0)];const n=Array.isArray(t.pages)?t.pages:[t];return n.length?n.map(e):[e(ir(),0)]}const mn=t=>JSON.parse(JSON.stringify(t));class Ku{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=v0();group=w0();constructor(e={}){if(this.pages=Xu(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const n=this.pages[0];n.elements=[...n.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const n of[...this.listeners])n()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(qa);return}this.recordHistory();const e=this.pages[this.activePageIndex]??ir();this.pages.push(Wa({...ir(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(r=>r.name));let n=this.pages.length+1;for(;e.has(`页面 ${n}`);)n++;return`页面 ${n}`}duplicatePage(e){if(this.tilingEnabled){window.alert(qa);return}this.recordHistory();const n=mn(this.pages[e]);n.name=`${n.name??`页面 ${e+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:sn()})),this.pages.splice(e+1,0,n),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,n){this.recordHistory(),this.pages[e].name=n,this.emit()}movePage(e,n){if(n<0||n>=this.pages.length||e===n)return;this.recordHistory();const[r]=this.pages.splice(e,1);this.pages.splice(n,0,r),this.activePageIndex=n,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,n=!1){if(n){const r=new Set(this.selectedIds);r.has(e)?r.delete(e):r.add(e),this.setSelection(r)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,n=!1){if(n){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(n=>n.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,n){const r=this.templateData.guides??[];this.templateData.guides=[...r,{id:sn(),type:e,position:Math.round(n*10)/10}],this.emit()}moveGuide(e,n){const r=this.templateData.guides??[];this.templateData.guides=r.map(o=>o.id===e?{...o,position:Math.round(n*10)/10}:o),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(n=>n.id!==e),this.emit()}addElement(e,n={},r){const o=Nl(e,n);return r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}addFieldElement(e,n={},r){const o=b0(e);return Object.assign(o.options,n),r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}placeAtDropPoint(e,n){const r=this.templateData,o=Fl(r,n.x,n.y);if(o!=="content"&&!Ll.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Pi(r)[o];return e.zone=o,e.options.left=n.x-i.left,e.options.top=n.y-i.top,o!=="content"&&Ri(e,i),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,n){const r=this.templateData.elements.find(i=>i.id===e);if(!r)return;const o=this.live.get(e)??r;this.live.set(e,{...o,options:{...o.options,...n}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[n,r]of this.live){const o=e.find(i=>i.id===n);o&&Object.assign(o.options,r.options)}this.live.clear(),this.emit()}dragIds(e){const n=this.templateData.elements.find(r=>r.id===e);return!n||n.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let n=!1;for(const r of this.elements){const o=e.get(r.id);!o||o===this.geoSig(r)||lg(r,this.templateData).rejected&&(n=!0)}n&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,n,r=!0){r&&this.recordHistory();const o=this.templateData.elements.find(i=>i.id===e);o&&(Object.assign(o.options,n),o.printElementType.type==="table"&&Nn(o.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const n=this.templateData.elements,r=n.filter(i=>this.selectedIds.has(i.id)),o=n.filter(i=>!this.selectedIds.has(i.id));if(e==="top")this.templateData.elements=[...o,...r];else if(e==="bottom")this.templateData.elements=[...r,...o];else{const i=n.findIndex(c=>this.selectedIds.has(c.id)),a=e==="up"?i+1:i-1;if(a<0||a>=n.length)return;const l=[...n];[l[i],l[a]]=[l[a],l[i]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(n=>this.selectedIds.has(n.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=mn(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const n=new Map;for(const i of this.clipboard){const a=i.options.groupId;a&&n.set(a,(n.get(a)??0)+1)}const r=new Map;for(const[i,a]of n)r.set(i,a>=2?ed():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=mn(i);a.id=sn(),a.options.left+=e,a.options.top+=e,a.options.groupId=a.options.groupId?r.get(a.options.groupId):void 0,o.push(a)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,n){const r=this.selectedElements.filter(o=>!o.options.locked);if(r.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const o of r)o.options.left+=e,o.options.top+=n;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();e&&(this.redoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:mn(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,n=Tr){this.scale=Math.max(n,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(Vu),n=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(n)}loadTemplate(e){this.pages=Xu(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return Et(this.templateData)}}const Wt=Symbol("mixed"),ja=new Set(["text","longText"]),Jb=["top","right","bottom","left"],Qb={on:!0,off:!1,mixed:Wt};function Zu(t){const e=Tl(t),n={};for(const r of Jb)n[r]=Qb[e[r]];return n}const e1=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class t1{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(n=>n.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!e||!n)return[];const r=[];for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const a=n[o]?.cells[i];a&&!a.merged&&r.push(a)}return r}get textTargets(){return this.selectedElements.filter(e=>ja.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const n=e[0];return e.every(r=>r===n)?n:Wt}hasToken(e,n){return(e??"").split(/\s+/).includes(n)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const n=e.map(o=>o.fontWeight==="bold"||o.fontWeight==="bolder"),r=e.map(o=>o.textDecoration);return{fontFamily:this.pick(e.map(o=>o.fontFamily)),fontSize:this.pick(e.map(o=>o.fontSize)),color:this.pick(e.map(o=>o.color)),backgroundColor:this.pick(e.map(o=>o.backgroundColor)),textAlign:this.pick(e.map(o=>this.context==="cells"?o.align:o.textAlign)),verticalAlign:this.pick(e.map(o=>this.context==="cells"?o.valign:o.verticalAlign)),bold:n.every(Boolean)?!0:n.some(Boolean)?Wt:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?Wt:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?Wt:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const n=this.targetCells;n.length&&(n.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const n=this.textTargets,r=this.selectedElements,i=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),a="backgroundColor"in e;!(n.length&&i)&&!(r.length&&a)||(n.forEach(l=>{const c=l.options;"fontFamily"in e&&(c.fontFamily=e.fontFamily),"fontSize"in e&&(c.fontSize=e.fontSize),"color"in e&&(c.color=e.color),"textAlign"in e&&(c.textAlign=e.textAlign),"verticalAlign"in e&&(c.verticalAlign=e.verticalAlign)}),a&&r.forEach(l=>{l.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const r=this.values.bold!==!0;this.writeCells(o=>{o.fontWeight=r?"bold":void 0});return}const e=this.values.bold!==!0,n=this.textTargets;n.length&&(n.forEach(r=>{r.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const n=this.textTargets;if(!n.length)return;const r=this.values[e==="underline"?"underline":"strike"]!==!0;n.forEach(o=>{const i=(o.options.textDecoration??"").split(/\s+/).filter(Boolean),a=i.indexOf(e);r&&a<0&&i.push(e),!r&&a>=0&&i.splice(a,1),o.options.textDecoration=i.length?i.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const e=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!e||!n)return;const r=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(r===this.borderDraftKey)return;if(this.borderDraftKey=r,Mi(n,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const o=_l(n,e);if(o.style===void 0&&o.width===void 0&&o.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:o.style==="mixed",width:o.width==="mixed",color:o.color==="mixed"},this.borderMixed.style?this.borderStyle=null:o.style===void 0?this.borderStyle="solid":o.style==="none"?this.borderStyle=null:this.borderStyle=o.style,this.borderWidth=this.borderMixed.width?void 0:typeof o.width=="number"?o.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof o.color=="string"?o.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const n=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=n,n===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{kl(o.options,e,n)}),this.commit())}applyCellBorderPreset(e,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||(El(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},e,n),this.commit())}applyCellBorderEdges(e,n,r){this.writeCells(o=>{for(const i of e)Sl(o,i,r?n:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?Zu(e.map(n=>n.borders)):null}toggleCellEdge(e,n){const r=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],n,r)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?Zu(e.map(n=>jh(n.options))):null}toggleElementEdge(e,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[e]!==!0;r.forEach(i=>Ai(i.options,e,o,n)),this.commit()}applyBorderPreset(e){const n=this.borderStyle===null;if(this.context==="cells"){const r=n&&!this.borderMixed.style;this.applyCellBorderPreset(r?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(n||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const n=this.selectedElements;n.length&&(n.forEach(r=>Ai(r.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const n={};for(const r of _r){const o=e[r];o&&(n[r]={...o})}return n}pickPainterSource(e=!1){const n=this.selectedElements[0];if(!n)return!1;const r=n.options,o=n.printElementType.type;return this.painterSnapshot={text:ja.has(o)?Object.fromEntries(e1.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:fi(o)?{borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:this.clonePainterBorders(r.borders)}:null},this.painterSource=n.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const n=this.painterSnapshot;if(!n||e.options.locked||e.id===this.painterSource)return!1;const r=e.options,o=e.printElementType.type;return n.text&&ja.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&fi(o)&&(r.borderWidth=n.border.borderWidth,r.borderStyle=n.border.borderStyle,r.borderColor=n.border.borderColor,r.borders=this.clonePainterBorders(n.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let n=!1;e.forEach(r=>{n=this.applyPainter(r)||n}),n&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const n=e.target?.tagName;n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||this.cancelPainter()}}function Ju(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function n1(t){if(Array.isArray(t))return t}function r1(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,e!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==e);c=!0);}catch(d){s=!0,o=d}finally{try{if(!c&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return l}}function o1(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
259
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function i1(t,e){return n1(t)||r1(t,e)||a1(t,e)||o1()}function a1(t,e){if(t){if(typeof t=="string")return Ju(t,e);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ju(t,e):void 0}}const Qu=Object.entries,ep=Object.setPrototypeOf,s1=Object.isFrozen,l1=Object.getPrototypeOf,c1=Object.getOwnPropertyDescriptor;let Se=Object.freeze,Te=Object.seal,bn=Object.create,tp=typeof Reflect<"u"&&Reflect,Ga=tp.apply,Ya=tp.construct;Se||(Se=function(e){return e}),Te||(Te=function(e){return e}),Ga||(Ga=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(n,o)}),Ya||(Ya=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new e(...r)});const jt=xe(Array.prototype.forEach),d1=xe(Array.prototype.lastIndexOf),np=xe(Array.prototype.pop),ar=xe(Array.prototype.push),u1=xe(Array.prototype.splice),yn=Array.isArray,sr=xe(String.prototype.toLowerCase),Va=xe(String.prototype.toString),rp=xe(String.prototype.match),lr=xe(String.prototype.replace),op=xe(String.prototype.indexOf),p1=xe(String.prototype.trim),f1=xe(Number.prototype.toString),h1=xe(Boolean.prototype.toString),ip=typeof BigInt>"u"?null:xe(BigInt.prototype.toString),ap=typeof Symbol>"u"?null:xe(Symbol.prototype.toString),$e=xe(Object.prototype.hasOwnProperty),cr=xe(Object.prototype.toString),ke=xe(RegExp.prototype.test),Gt=g1(TypeError);function xe(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Ga(t,e,r)}}function g1(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Ya(t,n)}}function oe(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:sr;if(ep&&ep(t,null),!yn(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){const i=n(o);i!==o&&(s1(e)||(e[r]=i),o=i)}t[o]=!0}return t}function m1(t){for(let e=0;e<t.length;e++)$e(t,e)||(t[e]=null);return t}function Ge(t){const e=bn(null);for(const r of Qu(t)){var n=i1(r,2);const o=n[0],i=n[1];$e(t,o)&&(yn(i)?e[o]=m1(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Ge(i):e[o]=i)}return e}function b1(t){switch(typeof t){case"string":return t;case"number":return f1(t);case"boolean":return h1(t);case"bigint":return ip?ip(t):"0";case"symbol":return ap?ap(t):"Symbol()";case"undefined":return cr(t);case"function":case"object":{if(t===null)return cr(t);const e=t,n=Qe(e,"toString");if(typeof n=="function"){const r=n(e);return typeof r=="string"?r:cr(r)}return cr(t)}default:return cr(t)}}function Qe(t,e){for(;t!==null;){const r=c1(t,e);if(r){if(r.get)return xe(r.get);if(typeof r.value=="function")return xe(r.value)}t=l1(t)}function n(){return null}return n}function y1(t){try{return ke(t,""),!0}catch{return!1}}const sp=Se(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Xa=Se(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ka=Se(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),v1=Se(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Za=Se(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),w1=Se(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lp=Se(["#text"]),cp=Se(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ja=Se(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),dp=Se(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),No=Se(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),x1=Te(/{{[\w\W]*|^[\w\W]*}}/g),E1=Te(/<%[\w\W]*|^[\w\W]*%>/g),S1=Te(/\${[\w\W]*/g),_1=Te(/^data-[\-\w.\u00B7-\uFFFF]+$/),M1=Te(/^aria-[\-\w]+$/),up=Te(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),T1=Te(/^(?:\w+script|data):/i),k1=Te(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),C1=Te(/^html$/i),A1=Te(/^[a-z][.\w]*(-[.\w]+)+$/i),pp=Te(/<[/\w!]/g),fp=Te(/<[/\w]/g),O1=Te(/<\/no(script|embed|frames)/i),I1=Te(/\/>/i),Ye={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},hp=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],P1=Se(oe({},hp)),R1=(function(){const t={};return jt(hp,e=>{t[e]=Te(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),Se(t)})(),D1=function(){return typeof window>"u"?null:window},$1=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const i="dompurify"+(r?"#"+r:"");try{return e.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},gp=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Tt=function(e,n,r,o){return $e(e,n)&&yn(e[n])?oe(o.base?Ge(o.base):{},e[n],o.transform):r},Qa=function(e,n,r){const o=$e(e,n)?e[n]:void 0;return o&&typeof o=="object"?Ge(o):r()};function mp(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:D1();const e=$=>mp($);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ye.document||!t.Element)return e.isSupported=!1,e;let n=t.document;const r=n,o=r.currentScript;t.DocumentFragment;const i=t.HTMLTemplateElement,a=t.Node,l=t.Element,c=t.NodeFilter,s=t.NamedNodeMap;s===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const d=t.DOMParser,p=t.trustedTypes,u=l.prototype,f=Qe(u,"cloneNode"),h=Qe(u,"remove"),m=Qe(u,"nextSibling"),b=Qe(u,"childNodes"),v=Qe(u,"parentNode"),w=Qe(u,"shadowRoot"),_=Qe(u,"attributes"),T=a&&a.prototype?Qe(a.prototype,"nodeType"):null,z=a&&a.prototype?Qe(a.prototype,"nodeName"):null,N=a&&a.prototype?Qe(a.prototype,"ownerDocument"):null,P=function(y){return T?T(y):y.nodeType},k=function(y){return z?z(y):y.nodeName};if(typeof i=="function"){const $=n.createElement("template");$.content&&$.content.ownerDocument&&(n=$.content.ownerDocument)}let S,C="",O,R=!1,I=0;const x=function(){if(I>0)throw Gt('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},j=function(y){x(),I++;try{return S.createHTML(y)}finally{I--}},te=function(y){x(),I++;try{return S.createScriptURL(y)}finally{I--}},fe=function(){return R||(O=$1(p,o),R=!0),O},G=n,de=G.implementation,Ke=G.createNodeIterator,ye=G.createDocumentFragment,Fe=G.getElementsByTagName,D=r.importNode;let L=gp();e.isSupported=typeof Qu=="function"&&typeof v=="function"&&de&&de.createHTMLDocument!==void 0;const W=x1,V=E1,Y=S1,X=_1,ne=M1,Q=T1,se=k1,he=A1;let _e=up,K=null;const yt=oe({},[...sp,...Xa,...Ka,...Za,...lp]);let ee=null;const lt=oe({},[...cp,...Ja,...dp,...No]);let Me=Object.seal(bn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Ee=null;const re=Object.seal(bn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ot=!0,It=!0,M=!1,J=!0,ue=!1,le=!0,ze=!1,Pt=!1,pe=null,ve=null,mr=!1,Rt=!1,Xo=!1,Ko=!1,ff=!0,hf=!1;const gf="user-content-";let As=!0,Os=!1,Sn={},_n=null;const mf=oe({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let bf=null;const yf=oe({},["audio","video","img","source","image","track"]);let vf=null;const wf=oe({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Zo="http://www.w3.org/1998/Math/MathML",Jo="http://www.w3.org/2000/svg",ct="http://www.w3.org/1999/xhtml";let Mn=ct,Is=!1,Ps=null;const Tw=oe({},[Zo,Jo,ct],Va),xf=Se(["mi","mo","mn","ms","mtext"]);let Rs=oe({},xf);const Ef=Se(["annotation-xml"]);let Ds=oe({},Ef);const kw=oe({},["title","style","font","a","script"]);let br=null;const Cw=["application/xhtml+xml","text/html"],Aw="text/html";let we=null,Tn=null;const Ow=n.createElement("form"),Sf=function(y){return y instanceof RegExp||y instanceof Function},$s=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Tn&&Tn===y)return;(!y||typeof y!="object")&&(y={}),y=Ge(y),br=Cw.indexOf(y.PARSER_MEDIA_TYPE)===-1?Aw:y.PARSER_MEDIA_TYPE,we=br==="application/xhtml+xml"?Va:sr,K=Tt(y,"ALLOWED_TAGS",yt,{transform:we}),ee=Tt(y,"ALLOWED_ATTR",lt,{transform:we}),Ps=Tt(y,"ALLOWED_NAMESPACES",Tw,{transform:Va}),vf=Tt(y,"ADD_URI_SAFE_ATTR",wf,{transform:we,base:wf}),bf=Tt(y,"ADD_DATA_URI_TAGS",yf,{transform:we,base:yf}),_n=Tt(y,"FORBID_CONTENTS",mf,{transform:we}),Ae=Tt(y,"FORBID_TAGS",Ge({}),{transform:we}),Ee=Tt(y,"FORBID_ATTR",Ge({}),{transform:we}),Sn=$e(y,"USE_PROFILES")?y.USE_PROFILES&&typeof y.USE_PROFILES=="object"?Ge(y.USE_PROFILES):y.USE_PROFILES:!1,Ot=y.ALLOW_ARIA_ATTR!==!1,It=y.ALLOW_DATA_ATTR!==!1,M=y.ALLOW_UNKNOWN_PROTOCOLS||!1,J=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ue=y.SAFE_FOR_TEMPLATES||!1,le=y.SAFE_FOR_XML!==!1,ze=y.WHOLE_DOCUMENT||!1,Rt=y.RETURN_DOM||!1,Xo=y.RETURN_DOM_FRAGMENT||!1,Ko=y.RETURN_TRUSTED_TYPE||!1,mr=y.FORCE_BODY||!1,ff=y.SANITIZE_DOM!==!1,hf=y.SANITIZE_NAMED_PROPS||!1,As=y.KEEP_CONTENT!==!1,Os=y.IN_PLACE||!1,_e=y1(y.ALLOWED_URI_REGEXP)?y.ALLOWED_URI_REGEXP:up,Mn=typeof y.NAMESPACE=="string"?y.NAMESPACE:ct,Rs=Qa(y,"MATHML_TEXT_INTEGRATION_POINTS",()=>oe({},xf)),Ds=Qa(y,"HTML_INTEGRATION_POINTS",()=>oe({},Ef));const E=Qa(y,"CUSTOM_ELEMENT_HANDLING",()=>bn(null));if(Me=bn(null),$e(E,"tagNameCheck")&&Sf(E.tagNameCheck)&&(Me.tagNameCheck=E.tagNameCheck),$e(E,"attributeNameCheck")&&Sf(E.attributeNameCheck)&&(Me.attributeNameCheck=E.attributeNameCheck),$e(E,"allowCustomizedBuiltInElements")&&typeof E.allowCustomizedBuiltInElements=="boolean"&&(Me.allowCustomizedBuiltInElements=E.allowCustomizedBuiltInElements),Te(Me),ue&&(It=!1),Xo&&(Rt=!0),Sn&&(K=oe({},lp),ee=bn(null),Sn.html===!0&&(oe(K,sp),oe(ee,cp)),Sn.svg===!0&&(oe(K,Xa),oe(ee,Ja),oe(ee,No)),Sn.svgFilters===!0&&(oe(K,Ka),oe(ee,Ja),oe(ee,No)),Sn.mathMl===!0&&(oe(K,Za),oe(ee,dp),oe(ee,No))),re.tagCheck=null,re.attributeCheck=null,$e(y,"ADD_TAGS")&&(typeof y.ADD_TAGS=="function"?re.tagCheck=y.ADD_TAGS:yn(y.ADD_TAGS)&&(K===yt&&(K=Ge(K)),oe(K,y.ADD_TAGS,we))),$e(y,"ADD_ATTR")&&(typeof y.ADD_ATTR=="function"?re.attributeCheck=y.ADD_ATTR:yn(y.ADD_ATTR)&&(ee===lt&&(ee=Ge(ee)),oe(ee,y.ADD_ATTR,we))),$e(y,"ADD_FORBID_CONTENTS")&&yn(y.ADD_FORBID_CONTENTS)&&(_n===mf&&(_n=Ge(_n)),oe(_n,y.ADD_FORBID_CONTENTS,we)),As&&(K["#text"]=!0),ze&&oe(K,["html","head","body"]),K.table&&(oe(K,["tbody"]),delete Ae.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Gt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=S;S=y.TRUSTED_TYPES_POLICY;try{C=j("")}catch(F){throw S=A,F}}else y.TRUSTED_TYPES_POLICY===null?(S=void 0,C=""):(S===void 0&&(S=fe()),S&&typeof C=="string"&&(C=j("")));Se&&Se(y),Tn=y},_f=oe({},[...Xa,...Ka,...v1]),Mf=oe({},[...Za,...w1]),Iw=function(y,E,A){return E.namespaceURI===ct?y==="svg":E.namespaceURI===Zo?y==="svg"&&(A==="annotation-xml"||Rs[A]):!!_f[y]},Pw=function(y,E,A){return E.namespaceURI===ct?y==="math":E.namespaceURI===Jo?y==="math"&&Ds[A]:!!Mf[y]},Rw=function(y,E,A){return E.namespaceURI===Jo&&!Ds[A]||E.namespaceURI===Zo&&!Rs[A]?!1:!Mf[y]&&(kw[y]||!_f[y])},Dw=function(y){let E=v(y);(!E||!E.tagName)&&(E={namespaceURI:Mn,tagName:"template"});const A=sr(y.tagName),F=sr(E.tagName);return Ps[y.namespaceURI]?y.namespaceURI===Jo?Iw(A,E,F):y.namespaceURI===Zo?Pw(A,E,F):y.namespaceURI===ct?Rw(A,E,F):!!(br==="application/xhtml+xml"&&Ps[y.namespaceURI]):!1},Dt=function(y){ar(e.removed,{element:y});try{v(y).removeChild(y)}catch{if(h(y),!v(y))throw Gt("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Tf=function(y,E,A){try{y.removeAttributeNode(E)}catch{try{y.removeAttribute(A)}catch{}}},Qo=function(y){ei(y);const E=b(y);if(E){const F=[];jt(E,B=>{ar(F,B)}),jt(F,B=>{try{h(B)}catch{}})}const A=_(y);if(A)for(let F=A.length-1;F>=0;--F){const B=A[F],q=B&&B.name;typeof q=="string"&&Tf(y,B,q)}},Jt=function(y,E,A){if(!A)try{A=E.getAttributeNode(y)}catch{A=null}ar(e.removed,{attribute:A||null,from:E});try{A?E.removeAttributeNode(A):E.removeAttribute(y)}catch{try{E.removeAttribute(y)}catch{}}if(y==="is")if(Rt||Xo)try{Dt(E)}catch{}else try{E.setAttribute(y,"")}catch{}},$w=function(y){const E=_(y);if(E)for(let A=E.length-1;A>=0;--A){const F=E[A],B=F&&F.name;typeof B!="string"||ee[we(B)]||Tf(y,F,B)}},ei=function(y){const E=[y];for(;E.length>0;){const A=E.pop();P(A)===Ye.element&&$w(A);const B=b(A);if(B)for(let q=B.length-1;q>=0;--q)E.push(B[q])}},kf=function(y,E){return le?y==="patchsrc"?!0:y==="for"&&E!=="label"&&E!=="output":!1},Nw=function(y){if(!le)return;const E=[y];for(;E.length>0;){const A=E.pop(),F=P(A);if(F===Ye.processingInstruction||F===Ye.comment&&ke(fp,A.data)){try{h(A)}catch{}continue}if(F===Ye.element){const q=A,ce=we(k(A));try{q.hasAttribute&&q.hasAttribute("patchsrc")&&q.removeAttribute("patchsrc"),q.hasAttribute&&q.hasAttribute("for")&&kf("for",ce)&&q.removeAttribute("for")}catch{}}const B=b(A);if(B)for(let q=B.length-1;q>=0;--q)E.push(B[q])}},Cf=function(y){let E=null,A=null;if(mr)y="<remove></remove>"+y;else{const q=rp(y,/^[\r\n\t ]+/);A=q&&q[0]}br==="application/xhtml+xml"&&Mn===ct&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const F=S?j(y):y;if(Mn===ct)try{E=new d().parseFromString(F,br)}catch{}if(!E||!E.documentElement){E=de.createDocument(Mn,"template",null);try{E.documentElement.innerHTML=Is?C:F}catch{}}const B=E.body||E.documentElement;return y&&A&&B.insertBefore(n.createTextNode(A),B.childNodes[0]||null),Mn===ct?Fe.call(E,ze?"html":"body")[0]:ze?E.documentElement:B},Af=function(y){const E=N?N(y):y.ownerDocument;return Ke.call(E||y,y,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ti=function(y){return y=lr(y,W," "),y=lr(y,V," "),y=lr(y,Y," "),y},Ns=function(y){var E;y.normalize();const A=N?N(y):y.ownerDocument,F=Ke.call(A||y,y,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let B=F.nextNode();for(;B;)B.data=ti(B.data),B=F.nextNode();const q=(E=y.querySelectorAll)===null||E===void 0?void 0:E.call(y,"template");q&&jt(q,ce=>{kn(ce.content)&&Ns(ce.content)})},ni=function(y){const E=z?z(y):null;return typeof E!="string"||we(E)!=="form"?!1:typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||y.attributes!==_(y)||typeof y.removeAttribute!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function"||y.nodeType!==T(y)||y.childNodes!==b(y)},kn=function(y){if(!T||typeof y!="object"||y===null)return!1;try{return T(y)===Ye.documentFragment}catch{return!1}},yr=function(y){if(!T||typeof y!="object"||y===null)return!1;try{return typeof T(y)=="number"}catch{return!1}};function dt($,y,E){$.length!==0&&jt($,A=>{A.call(e,y,E,Tn)})}const Lw=function(y,E){return!!(le&&y.hasChildNodes()&&!yr(y.firstElementChild)&&ke(pp,y.textContent)&&ke(pp,y.innerHTML)||le&&y.namespaceURI===ct&&P1[E]&&(yr(y.firstElementChild)||typeof y.textContent=="string"&&ke(R1[E],y.textContent))||y.nodeType===Ye.processingInstruction||le&&y.nodeType===Ye.comment&&ke(fp,y.data))},ri=function(y,E){if(y instanceof RegExp)return ke(y,E);if(y instanceof Function){for(var A=arguments.length,F=new Array(A>2?A-2:0),B=2;B<A;B++)F[B-2]=arguments[B];return!!y(E,...F)}return!1},Fw=function(y,E,A){if(!Ae[E]&&Df(E)&&ri(Me.tagNameCheck,E))return!1;if(As&&!_n[E]){const F=v(y),B=b(y);if(B&&F){const q=B.length;for(let ce=q-1;ce>=0;--ce){const ge=y===A?f(B[ce],!0):B[ce];F.insertBefore(ge,m(y))}}}return Dt(y),!0},Of=function(y,E,A,F){return y.length===0?E:E===A||E===F?Ge(E):E},If=function(y,E){return y===E||v(y)!==null?!1:(Os&&ei(y),!0)},Pf=function(y,E){if(dt(L.beforeSanitizeElements,y,null),If(y,E))return!0;if(ni(y))return Dt(y),!0;const A=we(k(y));if(K=Of(L.uponSanitizeElement,K,yt,pe),dt(L.uponSanitizeElement,y,{tagName:A,allowedTags:K}),If(y,E))return!0;if(Lw(y,A))return Dt(y),!0;if(Ae[A]||!(re.tagCheck instanceof Function&&re.tagCheck(A))&&!K[A]){const B=Fw(y,A,E);return B===!1&&dt(L.afterSanitizeElements,y,null),B}if(P(y)===Ye.element&&!Dw(y)||(A==="noscript"||A==="noembed"||A==="noframes")&&ke(O1,y.innerHTML))return Dt(y),!0;if(ue&&y.nodeType===Ye.text){const B=ti(y.textContent);y.textContent!==B&&(ar(e.removed,{element:y.cloneNode()}),y.textContent=B)}return dt(L.afterSanitizeElements,y,null),!1},Rf=function(y,E,A){if(Ee[E]||kf(E,y)||ff&&(E==="id"||E==="name")&&(A in n||A in Ow))return!1;const F=ee[E]||re.attributeCheck instanceof Function&&re.attributeCheck(E,y);return It&&ke(X,E)||Ot&&ke(ne,E)?!0:F?vf[E]||ke(_e,lr(A,se,""))||(E==="src"||E==="xlink:href"||E==="href")&&y!=="script"&&op(A,"data:")===0&&bf[y]||M&&!ke(Q,lr(A,se,""))?!0:!A:Df(y)&&ri(Me.tagNameCheck,y)&&ri(Me.attributeNameCheck,E,y)||E==="is"&&Me.allowCustomizedBuiltInElements&&ri(Me.tagNameCheck,A)},zw=oe({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Df=function(y){return!zw[sr(y)]&&ke(he,y)},Bw=function(y,E,A,F){if(S&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!A)switch(p.getAttributeType(y,E)){case"TrustedHTML":return j(F);case"TrustedScriptURL":return te(F)}return F},Hw=function(y,E,A,F){try{A?y.setAttributeNS(A,E,F):y.setAttribute(E,F),ni(y)?Dt(y):np(e.removed)}catch{Jt(E,y)}},$f=function(y){dt(L.beforeSanitizeAttributes,y,null);const E=y.attributes;if(!E||ni(y))return;ee=Of(L.uponSanitizeAttribute,ee,lt,ve);const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:ee,forceKeepAttr:void 0};let F=E.length;const B=we(y.nodeName);for(;F--;){const q=E[F],ce=q.name,ge=q.namespaceURI,Be=q.value,He=we(ce),Fs=Be;let De=ce==="value"?Fs:p1(Fs);if(A.attrName=He,A.attrValue=De,A.keepAttr=!0,A.forceKeepAttr=void 0,dt(L.uponSanitizeAttribute,y,A),De=A.attrValue,hf&&(He==="id"||He==="name")&&op(De,gf)!==0&&(Jt(ce,y,q),De=gf+De),le&&ke(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,De)){Jt(ce,y,q);continue}if(He==="attributename"&&rp(De,"href")){Jt(ce,y,q);continue}if(!A.forceKeepAttr){if(!A.keepAttr){Jt(ce,y,q);continue}if(!J&&ke(I1,De)){Jt(ce,y,q);continue}if(ue&&(De=ti(De)),!Rf(B,He,De)){Jt(ce,y,q);continue}De=Bw(B,He,ge,De),De!==Fs&&Hw(y,ce,ge,De)}}dt(L.afterSanitizeAttributes,y,null)},oi=function(y){let E=null;const A=Af(y);for(dt(L.beforeSanitizeShadowDOM,y,null);E=A.nextNode();)if(dt(L.uponSanitizeShadowNode,E,null),Pf(E,y),$f(E),kn(E.content)&&oi(E.content),P(E)===Ye.element){const F=w(E);kn(F)&&(Ls(F),oi(F))}dt(L.afterSanitizeShadowDOM,y,null)},Ls=function(y){const E=[{node:y,shadow:null}];for(;E.length>0;){const A=E.pop();if(A.shadow){oi(A.shadow);continue}const F=A.node,q=P(F)===Ye.element,ce=b(F);if(ce)for(let ge=ce.length-1;ge>=0;--ge)E.push({node:ce[ge],shadow:null});if(q){const ge=z?z(F):null;if(typeof ge=="string"&&we(ge)==="template"){const Be=F.content;kn(Be)&&E.push({node:Be,shadow:null})}}if(q){const ge=w(F);kn(ge)&&E.push({node:null,shadow:ge},{node:ge,shadow:null})}}};return e.sanitize=function($){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,A=null,F=null,B=null;if(Is=!$,Is&&($="<!-->"),typeof $!="string"&&!yr($)&&($=b1($),typeof $!="string"))throw Gt("dirty is not a string, aborting");if(!e.isSupported)return $;Pt?(K=pe,ee=ve):$s(y),(L.uponSanitizeElement.length>0||L.uponSanitizeAttribute.length>0)&&(K=Ge(K)),L.uponSanitizeAttribute.length>0&&(ee=Ge(ee)),e.removed=[];const q=Os&&typeof $!="string"&&yr($);if(q){Nw($);const Be=k($);if(typeof Be=="string"){const He=we(Be);if(!K[He]||Ae[He])throw Qo($),Gt("root node is forbidden and cannot be sanitized in-place")}if(ni($))throw Qo($),Gt("root node is clobbered and cannot be sanitized in-place");try{Ls($)}catch(He){throw Qo($),He}}else if(yr($))E=Cf("<!---->"),A=E.ownerDocument.importNode($,!0),A.nodeType===Ye.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?E=A:E.appendChild(A),Ls(A);else{if(!Rt&&!ue&&!ze&&$.indexOf("<")===-1)return S&&Ko?j($):$;if(E=Cf($),!E)return Rt?null:Ko?C:""}E&&mr&&Dt(E.firstChild);const ce=q?$:E;try{const Be=Af(ce);for(;F=Be.nextNode();)Pf(F,ce),$f(F),kn(F.content)&&oi(F.content)}catch(Be){throw q&&(Qo($),jt(e.removed,He=>{He.element&&ei(He.element)})),Be}if(q)return jt(e.removed,Be=>{Be.element&&ei(Be.element)}),ue&&Ns($),$;if(Rt){if(ue&&Ns(E),Xo)for(B=ye.call(E.ownerDocument);E.firstChild;)B.appendChild(E.firstChild);else B=E;return(ee.shadowroot||ee.shadowrootmode)&&(B=D.call(r,B,!0)),B}let ge=ze?E.outerHTML:E.innerHTML;return ze&&K["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&ke(C1,E.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
260
+ `+ge),ue&&(ge=ti(ge)),S&&Ko?j(ge):ge},e.setConfig=function(){let $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};$s($),Pt=!0,pe=K,ve=ee},e.clearConfig=function(){Tn=null,Pt=!1,pe=null,ve=null,S=O,C=""},e.isValidAttribute=function($,y,E){Tn||$s({});const A=we($),F=we(y);return Rf(A,F,E)},e.addHook=function($,y){typeof y=="function"&&$e(L,$)&&ar(L[$],y)},e.removeHook=function($,y){if($e(L,$)){if(y!==void 0){const E=d1(L[$],y);return E===-1?void 0:u1(L[$],E,1)[0]}return np(L[$])}},e.removeHooks=function($){$e(L,$)&&(L[$]=[])},e.removeAllHooks=function(){L=gp()},e}var N1=mp();const L1={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function F1(t){const e=t.options;return fa(e.formatter,void 0,String(e.testData||e.title||""))||"条码"}function z1(t){return g("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function B1(t){const e=t.options;return g("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[g("svg",{preserveAspectRatio:L1[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function H1(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(n=>!Number.isFinite(n))?null:{width:e[2],height:e[3]}}function U1(t,e){const n=t.options,r=Pn(n.barWidth),o=ci(n.barQuietZone),i=a=>{ga(e,F1(t),{format:String(n.barcodeType||"CODE128"),width:r,height:a*r,displayValue:!n.hideTitle,fontSize:(n.fontSize??Er)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:di*r});const l=H1(e);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const a=pi({barHeightMm:n.barHeight,boxWidthMm:en(n.width,n.maxWidth),boxHeightMm:en(n.height,n.maxHeight),dpi:n.printerDpi,barWidth:n.barWidth,measure:i});e.style.width=a.size?`${a.size.widthMm}mm`:"",e.style.height=a.size?`${a.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function q1(t,e){const n=t.options,r=fa(n.formatter,void 0,String(n.testData||n.title||""))||"二维码";e.replaceChildren();try{const o=Ba.render(r,"qrcode",{qrCodeLevel:String(n.qrCodeLevel??"M"),qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0}),i=document.createElement("img");i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(o)}`,i.alt="qrcode",i.style.width="100%",i.style.height="100%",i.style.objectFit=String(n.fit||"contain"),i.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",i.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",e.appendChild(i)}catch{}}function W1(t,e){for(const n of Array.from(t.querySelectorAll("[data-code-kind]"))){const r=n.dataset.codeId,o=e.find(i=>i.id===r);if(o)if(n.dataset.codeKind==="barcode"){const i=n.querySelector("svg");i&&U1(o,i)}else q1(o,n)}}const j1={header:"题",data:"数",subtotal:"小",summary:"汇"},G1=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],Lo=3.7795275591,Y1=.1,es=t=>JSON.parse(JSON.stringify(t)),bp=new WeakMap;function ft(t){let e=bp.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},bp.set(t,e)),e}function dr(t,e){return t.templateData.elements.find(n=>n.id===e)??null}function V1(t,e){const n=t.tableSelection;return!n||n.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):n}function yp(t,e,n){const r=dr(t,n.id);if(!r)return null;const o=n.options;return{store:t,fire:e,el:n,real:r,options:o,rows:o.tableRows??[],colWidths:o.tableColWidths??[],isSelected:t.selectedIds.has(n.id),selection:V1(t,n),maxTableWidth:vp(t)}}function vp(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function ts(t){return t.options.tableDefaultFontSize??10}function wp(t){return t.options.tableDefaultColor??"#333333"}function X1(t,e){let n=0;for(let r=0;r<e;r++)n+=t.rows[r].height;return n}function K1(t,e){return ft(t.store).layouts.get(t.el.id)?.[e]?.top??X1(t,e)}function Z1(t,e){return ft(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function J1(t){const e=t.options.dataSource;if(e&&Array.isArray(it[e]))return it[e];for(const n of Object.values(it))if(Array.isArray(n))return n}function xp(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function Ep(t,e){return xp(e)?fa(e.formatter,J1(t)):e.formatter||""}function Q1(t,e){const n={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:Ki(e.fontFamily??t.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??ts(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??wp(t),backgroundColor:e.backgroundColor??"transparent",borderTop:Cr(e.borders?.top,n),borderRight:Cr(e.borders?.right,n),borderBottom:Cr(e.borders?.bottom,n),borderLeft:Cr(e.borders?.left,n),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ey(t,e,n){const r=t.selection;return[!!r&&e>=r.r1&&e<=r.r2&&n>=r.c1&&n<=r.c2?"cell-selected":"",t.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Sp(t){return ii(t)}function ty(t){return Sp(t)!=="autoHeight"}function ny(t,e){return e.fontSize??ts(t)}function Fo(t,e,n){return An(t.rows,e,n,t.options.tableDefaultPadding??1)}function ry(t,e,n){return si(t.colWidths,e,n,t.options.tableDefaultPadding??1)}function oy(t,e,n){return{maxHeight:Fo(t,n,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function iy(t,e,n){const r={fitBase:String(ny(t,e)),fitMin:String(Cn(e.shrinkMinFontSize)),fitMm:String(Fo(t,n,e))};return Sp(e)==="shrink"&&(r.fit="shrink"),r}function ay(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(n=>!Number.isFinite(n))?null:{width:e[2],height:e[3]}}const sy={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ly(t,e,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(Zb,"svg");o.appendChild(i);const a=Ep(t,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",sy[r.fit||"contain"]??"xMidYMid meet");const l=Pn(r.barWidth),c=ci(r.barQuietZone),s=u=>{ga(i,a,{format:r.barcodeType||"CODE128",width:l,height:u*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??Er)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:di*l});const f=ay(i);return f?{widthUnits:f.width,heightUnits:f.height}:null};let d=null;try{d=pi({barHeightMm:r.barHeight,boxWidthMm:en(ry(t,n,r),r.maxWidth),boxHeightMm:en(Fo(t,e,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:s})}catch{d=null}if(!d){i.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=a||"条码",o.appendChild(u),o}const p=d.size;return p?(i.style.width=`${p.widthMm}mm`,i.style.height=`${p.heightMm}mm`):(i.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",i.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%"),i.setAttribute("shape-rendering","crispEdges"),o}if(i.style.display="none",!a)return o;try{const l=Ba.render(a,"qrcode",{qrCodeLevel:String(r.qrCodeLevel||"M"),qrQuietZone:typeof r.qrQuietZone=="number"?r.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=r.fit||"contain",r.objectPosition&&(c.style.objectPosition=r.objectPosition),c.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",c.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%",o.appendChild(c)}catch{}return o}function _p(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function cy(t){const e=t.formatter||"";return e?e.includes("{")?dn(e,it):e:""}function dy(t,e,n){const r=document.createElement("div");r.className="cell-image";const o=qs(n.fit,Fo(t,e,n));o!==void 0&&(r.style.height=`${o}mm`);const i=cy(n);if(!i)return r.appendChild(_p()),r;const a=document.createElement("img");a.setAttribute("src",i),o!==void 0&&(a.style.width="100%",a.style.height="100%"),a.style.objectFit=n.fit||"contain";for(const[l,c]of Object.entries(hi(n.fit,n.fitScale,n.objectPosition)))a.style[l]=c;return a.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",a.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",a.addEventListener("error",()=>{a.remove(),r.appendChild(_p())},{once:!0}),r.appendChild(a),r}function uy(t,e,n,r,o){if(xp(o))return ly(t,n,r,o);if(o.cellType==="image")return dy(t,n,o);const i=Ep(t,o),a=()=>e.type==="data"?g("span",{class:"data-placeholder",text:i}):i;return ty(o)?g("div",{class:"cell-fit",style:oy(t,o,n),dataset:iy(t,o,n)},[a()]):a()}function zo(t,e,n){const r={elementId:t.el.id,...ml(t.rows,e,n)};t.store.setTableSelection(r),t.fire("table-selection-change",{elementId:t.el.id,selection:r})}function py(t,e,n,r,o){if(o.button!==0||(t.fire("table-cell-mousedown",{elementId:t.el.id,r:e,c:n,cellId:r,event:o}),!t.isSelected))return;o.stopPropagation();const i=ft(t.store);o.shiftKey&&t.selection?zo(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:n}):(i.anchor={r:e,c:n},zo(t,{r:e,c:n},{r:e,c:n})),document.addEventListener("mouseup",()=>{ft(t.store).anchor=null},{once:!0})}function fy(t,e,n){const r=ft(t.store).anchor;r&&zo(t,r,{r:e,c:n})}function Mp(t,e){const n=ft(t);n.menu?.visible&&(n.menu.visible=!1,e("table-menu-close",{elementId:n.menuElId}),t.emit(!1))}function hy(t,e,n,r){r.preventDefault(),r.stopPropagation(),t.isSelected||t.store.selectOne(t.el.id);const o=t.selection;o&&e>=o.r1&&e<=o.r2&&n>=o.c1&&n<=o.c2||zo(t,{r:e,c:n},{r:e,c:n});const a=ft(t.store);a.menuElId=t.el.id,a.menu&&(a.menu.x=r.clientX,a.menu.y=r.clientY,a.menu.visible=!0),t.fire("table-cell-contextmenu",{elementId:t.el.id,r:e,c:n,clientX:r.clientX,clientY:r.clientY}),t.store.emit(!1),document.addEventListener("mousedown",()=>Mp(t.store,t.fire),{once:!0})}function Tp(t,e,n){const r=t.reduce((o,i)=>o+i,0)+(t[e]??0);return r>n?`插入后表格总宽 ${Math.round(r*10)/10}mm 超过打印范围宽度 ${n}mm,请先缩小列宽`:null}function gy(t,e){const n=t.real.options.tableRows??[],r=t.real.options.tableColWidths??[],o=e(es(n),es(r));return o?(window.alert(o),!1):(t.store.recordHistory(),e(n,r),t.store.setTableSelection(null),Nn(t.real.options),t.store.emit(),!0)}function ht(t,e,n){Mp(t.store,t.fire);const r=t.selection;if(!r)return;let o=null;switch(e){case"insert-row-above":o=i=>(wl(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(wl(i,r.r2,"below"),null);break;case"delete-row":o=i=>Dh(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=Tp(a,r.c1,t.maxTableWidth);return l||(xl(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=Tp(a,r.c2,t.maxTableWidth);return l||(xl(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>$h(i,a,r.c1);break;case"merge":o=i=>(yl(i,r),null);break;case"split":o=i=>(vl(i,r),null);break;case"set-row-type":o=i=>n?_i(i,r.r1,n):"未指定行类型";break}o&&gy(t,o)&&t.fire(`table-${e}`,{elementId:t.el.id,...n?{type:n}:{}})}function my(t){const e=t.selection;if(!e)return!1;for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const o=t.rows[n]?.cells[r];if(o&&!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1))return!0}return!1}function kp(t,e){const n=t.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":_i(es(t.rows),n.r1,e):"未选择单元格"}function gt(t,e,n={}){return g("div",{class:`menu-item${n.disabled?" disabled":""}${n.active?" active":""}`,title:n.title||"",text:t,onClick:()=>{n.disabled||e()}})}const ns=()=>g("div",{class:"menu-divider"});function by(t,e,n){const r=ft(t);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=dr(t,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=yp(t,e,o);if(!i)return"";const a=i.selection?bl(i.rows,i.selection):"未选择单元格",l=i.selection?i.rows[i.selection.r1]?.type??null:null;return g("div",{class:"table-ctx-menu",style:{left:n.x+"px",top:n.y+"px"},onMousedown:c=>c.stopPropagation()},[gt("在上方插入行",()=>ht(i,"insert-row-above")),gt("在下方插入行",()=>ht(i,"insert-row-below")),gt("删除行",()=>ht(i,"delete-row"),{disabled:i.rows.length<=1}),ns(),gt("在左侧插入列",()=>ht(i,"insert-col-left")),gt("在右侧插入列",()=>ht(i,"insert-col-right")),gt("删除列",()=>ht(i,"delete-col"),{disabled:i.colWidths.length<=1}),ns(),gt("合并单元格",()=>ht(i,"merge"),{disabled:!!a,title:a||""}),gt("拆分单元格",()=>ht(i,"split"),{disabled:!my(i)}),ns(),g("div",{class:"menu-group-title",text:"行类型"}),...G1.map(c=>gt(c.label,()=>ht(i,"set-row-type",c.value),{disabled:!!kp(i,c.value),title:kp(i,c.value)||"",active:l===c.value}))])}let Yt=null;function Cp(){Yt&&(document.removeEventListener("mousemove",rs),document.removeEventListener("mouseup",os),Yt.handle.classList.remove("dragging"),Yt=null)}function yy(t,e){const n=t.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(e.scale||100)/100}function vy(t,e,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;Cp();const i=t.real.options.tableColWidths??[];Yt={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:n.clientX,startWidth:i[e-1]??0,scale:yy(o,t.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",rs),document.addEventListener("mouseup",os)}function rs(t){const e=Yt;if(!e)return;const n=dr(e.store,e.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(t.clientX-e.startX)/(e.scale*Lo),i=e.boundary-1;r[i]=Uh(r,i,e.startWidth+o,vp(e.store)),Nn(n.options),r.forEach((a,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${a}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((a,l)=>{a.style.left=`${r.slice(0,l+1).reduce((c,s)=>c+s,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${n.options.width}mm`,e.wrapper.style.height=`${n.options.height}mm`)}function os(){document.removeEventListener("mousemove",rs),document.removeEventListener("mouseup",os);const t=Yt;if(!t)return;Yt=null,t.handle.classList.remove("dragging");const e=dr(t.store,t.elId);e&&Nn(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function wy(t,e,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=dr(t,e);if(!i)return;let a=!1;const l=o/Lo;Math.abs(l-(i.options.height??0))>Y1&&(i.options.height=Math.round(l*100)/100,a=!0);const c=r.offsetTop,s=Array.from(r.rows).map(p=>({top:(p.offsetTop-c)/Lo,height:p.offsetHeight/Lo})),d=ft(t);xy(d.layouts.get(e),s)||(d.layouts.set(e,s),a=!0),a&&t.emit(!1)}function xy(t,e){return!t||t.length!==e.length?!1:e.every((n,r)=>{const o=t[r];return Math.round(n.top*10)===Math.round(o.top*10)&&Math.round(n.height*10)===Math.round(o.height*10)})}function Ey(t,e){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&wy(t,e,r)}),n}function Sy(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function _y(t){return Array.from({length:t.colWidths.length},(e,n)=>n+1)}function My(t,e){return t.colWidths.slice(0,e).reduce((n,r)=>n+r,0)}function Ty(t,e,n){const r=yp(e,n,t);if(!r)return g("div",{class:"print-table"});const o=[g("table",{style:{fontSize:`${ts(r)}pt`,color:wp(r)}},[g("colgroup",{},r.colWidths.map(i=>g("col",{style:{width:i+"mm"}}))),g("tbody",{},r.rows.map((i,a)=>g("tr",{style:{height:i.height+"mm"}},i.cells.map((l,c)=>l.merged?"":g("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ey(r,a,c),style:Q1(r,l),onMousedown:s=>py(r,a,c,l.id,s),onMouseenter:()=>fy(r,a,c),onContextmenu:s=>hy(r,a,c,s)},[uy(r,i,a,c,l)])).filter(Boolean))))])];return Sy(r)&&o.push(g("div",{class:"col-resize-layer"},_y(r).map(i=>g("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${i}`,style:{left:My(r,i)+"mm"},onMousedown:a=>{a.stopPropagation(),a.preventDefault(),vy(r,i,a)}})))),r.isSelected&&o.push(g("div",{class:"row-badges"},r.rows.map((i,a)=>g("span",{class:"row-badge",style:{top:K1(r,a)+"mm",height:Z1(r,a)+"mm"},text:j1[i.type]})))),o.push(Ey(e,t.id)),g("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:i=>i.preventDefault()},o)}const ky=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function is(t){return Array.isArray(t)&&t.length>0?t:[]}function Cy(t,e){const n=xr(t,e)??(e?Object.keys(e).find(o=>Array.isArray(e[o])):void 0);if(n)return is(e?.[n]);const r=xr(t,it);return r?is(it[r]):[]}function Ay(t,e){const n=t.options,r=typeof n.formatter=="string"?n.formatter:"",o=is(e)[0],i=Cy(r,o);if(i.length===0)return[...ky];if(!r)return i.map(c=>String(c?.name??JSON.stringify(c)));const a=o??{},l=xr(r,a)??Object.keys(a).find(c=>Array.isArray(a[c]));return i.map(c=>{try{return dn(r,{...a,...c,...l?{[l]:c}:{}})}catch{return r}})}function Oy(t,e){const n=t.options,r=ut(n.flowColumns),o=wt(n.flowGapX),i=On(n.flowRowHeight),a={display:"grid",gridTemplateColumns:`repeat(${r},minmax(0,1fr))`,columnGap:`${o}mm`,gridAutoRows:`minmax(${i}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",color:n.color||"#333",boxSizing:"border-box"};return n.fontFamily&&(a.fontFamily=String(n.fontFamily)),n.backgroundColor&&(a.backgroundColor=String(n.backgroundColor)),g("div",{class:"print-flowlist",style:a},Ay(t,e).map(l=>g("div",{class:"print-flow-cell",text:l})))}const Ap={top:"flex-start",middle:"center",bottom:"flex-end"},Iy={left:"flex-start",center:"center",right:"flex-end"};function Py(t,e){const n=t.options,r=el(t.printElementType.type,n),o={};if(r?.all&&(o.border=`${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor}`),r)for(const i of _r){const a=r.edges[i];a&&(o[`border${i.charAt(0).toUpperCase()}${i.slice(1)}`]=`${a.borderWidth} ${a.borderStyle} ${a.borderColor}`)}return{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`,zIndex:String(n.zIndex||"auto"),...o,...Ry(t,e)}}function Ry(t,e){if(e?.has(t.id))return{};const n=gi(t.printElementType.type,t.options);return n===void 0?{}:{rotate:`${n}deg`}}function Op(t){const e=t.options,n=t.printElementType.type==="longText",r=wr(t.printElementType.type,e),o=e.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:e.fontWeight||"normal",fontFamily:Ki(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:n?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:i?"auto":"100%",boxSizing:"border-box",overflow:i?"visible":"hidden",...n?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};Us(e)&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis");const l=Hs(e);return l&&(a.whiteSpace=l),e.verticalAlign&&(a.display="flex",e.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Ap[e.verticalAlign]??"flex-start"):(a.alignItems=Ap[e.verticalAlign]??"flex-start",a.justifyContent=Iy[e.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function Dy(t){const e=t.options,n=`${e.borderWidth||.75}pt`,r=e.borderStyle||"solid",o=e.borderColor||"#333";return t.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${n} ${r} ${o}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${n} ${r} ${o}`,boxSizing:"border-box"}}function $y(t){const e=t.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:t.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ny(t){const e=t.options;return{objectFit:e.fit||"contain",...hi(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function Ip(t){const e=t.options,n={fitBase:String(e.fontSize||12),fitMin:String(Cn(e.shrinkMinFontSize))};return wr(t.printElementType.type,e)==="shrink"&&(n.fit="shrink"),n}function Ly(t,e,n){const r=t.printElementType.type,o=t.options;switch(r){case"text":{const{style:i}=Op(t);return g("div",{class:"print-text",style:i,dataset:Ip(t),text:String(o.testData||o.formatter||"")||"文本"})}case"longText":{const{style:i}=Op(t);return g("div",{class:"print-longtext",style:i,dataset:Ip(t),text:String(o.formatter||"")||"长文本内容"})}case"hline":case"vline":return g("div",{class:"print-line",style:Dy(t)});case"rect":case"oval":return g("div",{class:"print-shape",style:$y(t)});case"image":{const i=String(o.src??""),a=i.includes("{")?dn(i,it):i;return g("div",{class:"print-image"},[a?g("img",{src:a,style:Ny(t)}):g("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return z1(t);case"barcode":return B1(t);case"html":{const i=String(o.formatter??""),a=i?N1.sanitize(dn(i,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return g("div",{class:"print-html",html:a})}case"pageNumber":return g("div",{class:"page-number-element",style:{fontSize:`${o.fontSize||12}pt`,fontWeight:o.fontWeight||"normal",fontFamily:Ki(o.fontFamily),color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:o.title||"{pageIndex}/{totalPages}"});case"table":return n?Ty(t,n.store,n.fire):g("div",{class:"print-table"});case"flowList":return Oy(t);default:return g("div",{text:r})}}function Pp(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function Fy(t,e,n){const r=t.store,o=r.selectedIds.has(e.id),i=r.previewIds.has(e.id),a=e.options,l=e.zone||"content",c=[Ly(e,!0,{store:r,fire:t.fire})];return r.draggingIds.has(e.id)&&c.push(g("div",{class:"drag-preview"})),o&&(c.push(g("div",{class:"resize-handles"},x0.map(s=>g("div",{class:`resize-handle handle-${s}`,dataset:{point:s,elId:e.id},onMousedown:d=>t.fire("resize-start",{event:d,id:e.id,point:s})})))),c.push(g("div",{class:"selected-indicator"},[g("div",{class:"position-label",text:Pp(a)})]))),g("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${l}`,o?"selected":"",i?"previewed":"",r.draggingIds.has(e.id)?"drag-ghost":"","design-mode",a.locked?"locked":"",a.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Py(e,n),dataset:{elId:e.id},onMousedown:s=>t.fire("element-mousedown",{event:s,id:e.id}),onContextmenu:s=>{s.preventDefault(),s.stopPropagation(),t.fire("contextmenu",{event:s,id:e.id})}},c)}function as(t,e){const n=t.margins,r=t.header?.height??10,o=t.footer?.height??10,i=e.width-n.left-n.right;return{header:{left:n.left,top:n.top,width:i,height:r},content:{left:n.left,top:n.top+r,width:i,height:e.height-n.top-n.bottom-r-o},footer:{left:n.left,top:e.height-n.bottom-o,width:i,height:o}}}const zy='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>';function Rp(t,e){return t.type==="vertical"?{left:`${t.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${t.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}}function By(t,e){const n=wc(t.watermark,[],e);return n?g("div",{class:"watermark-layer",style:{opacity:String(n.opacity)}},n.tiles.map(r=>g("svg",{class:"watermark-tile",width:`${r.widthMm}mm`,height:`${r.heightMm}mm`,viewBox:`0 0 ${n.tileWidthPx} ${n.tileHeightPx}`,style:{left:`${r.leftMm}mm`,top:`${r.topMm}mm`}},[g("text",{x:String(n.tileWidthPx/2),y:String(n.tileHeightPx/2),"font-size":String(n.fontSizePx),fill:n.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${n.rotate},${n.tileWidthPx/2},${n.tileHeightPx/2})`,text:n.text})]))):""}function ss(t,e,n,r,o,i){const a=t.store,l=[];n!=="content"&&l.push(g("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"}));const c=n==="content"?ll(o):void 0;if(l.push(...o.map(s=>Fy(t,s,c))),n!=="content"){const s=n==="header"?"bottom":"top";l.push(g("div",{class:`zone-resize-handle handle-${s}`,dataset:{zone:n},onMousedown:d=>t.fire("zone-resize",{event:d,zone:n})},[e.zoneResizing===n?g("div",{class:"zone-height-tip",text:`${(n==="header"?a.templateData.header.height:a.templateData.footer.height).toFixed(1)}mm`}):""]))}return g("div",{class:`zone-layer zone-${n} design-mode`,style:{position:"absolute",left:`${r.left}mm`,top:`${r.top}mm`,width:`${r.width}mm`,height:`${r.height}mm`},dataset:{zone:n,paperWidth:String(i.width),paperHeight:String(i.height)}},l.filter(Boolean))}function Hy(t,e){const n=t.store,r=n.templateData,o=Ze(r),i=(n.scale||100)/100,a=as(r,o),l=p=>n.elements.filter(u=>(u.zone||"content")===p),c=g("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${r.margins.top}mm ${r.margins.right}mm ${r.margins.bottom}mm ${r.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${o.height}mm`}},[n.showGrid?g("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(zy)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[By(r,o)]:[],ss(t,e,"header",a.header,l("header"),o),ss(t,e,"content",a.content,l("content"),o),ss(t,e,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>g("div",{class:`adsorb-guide guide-${p.type}`,style:Rp(p,o)})),...(r.guides??[]).map(p=>g("div",{class:`manual-guide guide-${p.type}`,style:{...Rp(p,o),"--guide-hit":`${8/i}px`},dataset:{guideId:String(p.id??"")},onMousedown:u=>t.fire("guide-mousedown",{event:u,id:p.id}),onDblclick:u=>{u.preventDefault(),t.fire("guide-remove",p.id)}}))].filter(Boolean)),s=g("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${o.width}mm`,minHeight:`${o.height}mm`,background:r.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${i})`,transformOrigin:"0 0"}},[...r.designBackground?.src?[g("div",{class:"design-background",style:{width:`${o.width}mm`,height:`${o.height}mm`,left:"0",top:"0",transform:r.designBackground.rotation?`rotate(${r.designBackground.rotation}deg)`:""}},[g("img",{src:r.designBackground.src,draggable:!1,alt:""})])]:[],c]),d=[g("div",{class:"canvas-scroll"},[g("div",{class:"paper-wrapper",style:{width:`${Hr(o.width)*i}px`,height:`${Hr(o.height)*i}px`,position:"relative"}},[s])])];if(n.showRuler&&d.push(g("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[g("div",{class:"ruler-corner"}),g("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:p=>t.fire("ruler-mousedown",{event:p,orientation:"horizontal"})}),g("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:p=>t.fire("ruler-mousedown",{event:p,orientation:"vertical"})})])),e.guidePreview&&d.push(g("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&d.push(g("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const p=e.contextMenu;d.push(g("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[et(t,p,"复制","copy"),et(t,p,"剪切","cut"),et(t,p,"粘贴","paste",!n.hasClipboard),et(t,p,"删除","delete"),g("div",{class:"context-menu-sep"}),et(t,p,"置顶","move-layer",!1,"top"),et(t,p,"上移","move-layer",!1,"up"),et(t,p,"下移","move-layer",!1,"down"),et(t,p,"置底","move-layer",!1,"bottom")]:[et(t,p,"粘贴","paste-at",!n.hasClipboard),et(t,p,"全选","select-all"),et(t,p,"取消选择","clear-selection")]))}return g("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:p=>p.preventDefault(),onDrop:p=>t.fire("drop",p),onMousedown:p=>t.fire("canvas-mousedown",p),onMousemove:p=>t.fire("canvas-mousemove",p),onMouseleave:()=>t.fire("canvas-mouseleave"),onWheel:p=>t.fire("wheel",p),onScroll:p=>t.fire("scroll",p),onContextmenu:p=>{p.preventDefault(),t.fire("canvas-contextmenu",p)}},d.filter(Boolean))}function et(t,e,n,r,o=!1,i){return g("div",{class:`context-menu-item${o?" disabled":""}`,text:n,onClick:()=>{e.visible=!1,o||t.fire(r,i),t.repaint()}})}const Uy={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function Ne(t,e=15,n){const r=Uy[t];return r?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${n?` class="${n}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`:""}let Vt=null;function ls(t){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return null;const n=e[1],r=n.length===3?n.split("").map(o=>o+o).join(""):n;return{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16)}}function cs(t){const e=ls(t);return e?Dp(e):"#000000"}function Dp({r:t,g:e,b:n}){return`#${[t,e,n].map(r=>Math.round(ur(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function qy(t,e,n){const r=t/255,o=e/255,i=n/255,a=Math.max(r,o,i),l=Math.min(r,o,i),c=a-l;let s=0;return c!==0&&(a===r?s=(o-i)/c%6:a===o?s=(i-r)/c+2:s=(r-o)/c+4,s*=60,s<0&&(s+=360)),{h:s,s:a===0?0:c/a,v:a}}function Wy(t,e,n){const r=n*e,o=(t%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),[a,l,c]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i],s=n-r;return{r:(a+s)*255,g:(l+s)*255,b:(c+s)*255}}function jy(t){return((Number.isFinite(t)?t:0)%360+360)%360}function ur(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function Gy(t){const e=t.title??"颜色选择";return g("button",{type:"button",class:`preset-color-trigger${t.triggerClass?` ${t.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:n=>{const r=n.currentTarget??n.target,o=r.getRootNode();if(!!Vt&&Vt.root===o&&Vt.title===e&&Vt.trigger===r){pr();return}pr(),Yy(r,t)}},[g("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function pr(){const t=Vt;t&&(Vt=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function Yy(t,e){const n=t.getRootNode(),r=n instanceof ShadowRoot?n:document.body,o={root:n,title:e.title??"颜色选择",trigger:t,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&us(o,e.value)?o.hexText=cs(e.value).toUpperCase():o.hexText=e.value?String(e.value):"",o.panel=Re(Zy(o),r),o.current=o.panel.querySelector(".picker-current"),o.hex=o.panel.querySelector(".picker-hex"),o.area=o.panel.querySelector(".picker-area"),o.handle=o.panel.querySelector(".picker-handle"),o.hueRange=o.panel.querySelector(".picker-hue"),o.clearBtn=o.panel.querySelector(".picker-clear"),o.items=Array.from(o.panel.querySelectorAll(".preset-color-item")).map((i,a)=>({el:i,color:zl[a]})),Bo(o),Vy(o),Xy(o),Vt=o,t.setAttribute("aria-expanded","true")}function Vy(t){const e=t.trigger.getBoundingClientRect(),n=190,r=t.panel.offsetHeight||216,o=8,i=Math.max(o,Math.min(e.left,window.innerWidth-n-o)),a=e.bottom+6,l=a+r>window.innerHeight-o?Math.max(o,e.top-r-6):a;t.panel.style.left=`${i}px`,t.panel.style.top=`${l}px`}function Xy(t){const e=o=>{const i=Ky(o);i.includes(t.trigger)||i.includes(t.panel)||pr()},n=o=>{o.key==="Escape"&&pr()},r=()=>pr();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),t.root.addEventListener("scroll",r,!0),t.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",n),()=>window.removeEventListener("scroll",r,!0),()=>window.removeEventListener("resize",r),()=>t.root.removeEventListener("scroll",r,!0))}function Ky(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function Zy(t){return g("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[g("div",{class:"picker-preview"},[g("span",{class:"picker-current"}),g("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>Qy(t,e.target.value)})]),g("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>ev(t,e),onKeydown:e=>tv(t,e)},[g("span",{class:"picker-handle"})]),g("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>nv(t,Number(e.target.value)),onChange:()=>ps(t)}),g("div",{class:"picker-heading"},[g("span",{text:"常用颜色"}),t.clearable?g("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Ho(t,void 0)},[g("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[g("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),g("div",{class:"preset-color-grid"},zl.map(e=>g("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>Jy(t,e)})))])}function ds(t){return Dp(Wy(t.hue,t.saturation,t.value_))}function Bo(t){const e=ds(t);t.hex.value!==t.hexText&&(t.hex.value=t.hexText),t.current.className=t.model?"picker-current":"picker-current is-empty",t.model?t.current.style.background=e:t.current.style.removeProperty("background"),t.area.style.setProperty("--picker-hue",`${Math.round(t.hue)}deg`),t.handle.style.left=`${t.saturation*100}%`,t.handle.style.top=`${(1-t.value_)*100}%`,t.handle.style.background=e;const n=String(Math.round(t.hue));t.hueRange.value!==n&&(t.hueRange.value=n),t.clearBtn&&(t.clearBtn.disabled=!t.model);for(const r of t.items)r.el.className=t.model&&r.color.toLowerCase()===t.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function us(t,e){const n=ls(e);if(!n)return!1;const r=qy(n.r,n.g,n.b);return t.hue=r.h,t.saturation=r.s,t.value_=r.v,t.hexText=cs(e).toUpperCase(),!0}function vn(t,e,n,r){t.hue=jy(e),t.saturation=ur(n),t.value_=ur(r),t.hexText=ds(t).toUpperCase(),Bo(t)}function ps(t){const e=ds(t);t.model=e,Bo(t),t.onChange(e)}function Ho(t,e){t.model=e,e||(t.hexText=""),Bo(t),t.onChange(e)}function Jy(t,e){us(t,e),Ho(t,e)}function Qy(t,e){const n=e.trim();if(!n){t.clearable&&Ho(t,void 0);return}ls(n)&&(us(t,n),Ho(t,cs(n)))}function ev(t,e){t.dragging=!0,$p(t,e);const n=o=>{t.dragging&&$p(t,o)},r=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),ps(t))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function $p(t,e){const n=t.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=ur((e.clientX-n.left)/n.width),o=ur(1-(e.clientY-n.top)/n.height);vn(t,t.hue,r,o)}function tv(t,e){const n=e.shiftKey?.1:.02;let r=!0;e.key==="ArrowLeft"?vn(t,t.hue,t.saturation-n,t.value_):e.key==="ArrowRight"?vn(t,t.hue,t.saturation+n,t.value_):e.key==="ArrowUp"?vn(t,t.hue,t.saturation,t.value_+n):e.key==="ArrowDown"?vn(t,t.hue,t.saturation,t.value_-n):r=!1,r&&(e.preventDefault(),ps(t))}function nv(t,e){vn(t,e,t.saturation,t.value_)}function be(t,e,n,r){return g("button",{class:`tb-btn tb-icon${r.on?" on":""}${r.danger?" danger":""}`,type:"button",disabled:!!r.disabled,dataset:{tip:r.tip,...r.test?{test:r.test}:{}},onClick:()=>t.fire(n,r.arg),html:Ne(e)})}function Uo(t,e,n,r){const o=t.state.openDd===e,i=()=>{t.state.openDd=o?null:e,t.repaint()};return g("div",{class:"tb-dd"},[g("button",{type:"button",class:`tb-dd-trigger${o?" on":""}`,disabled:!!n.disabled,dataset:{test:n.testId??e,tip:n.tip},onClick:i,html:`${n.icon?Ne(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${Ne("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?g("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function Z(t){const e=t.step??1,n=String(e),r=n.indexOf("."),o=r===-1?0:n.length-r-1,i=p=>Number.isFinite(p)?Number(p.toFixed(o)):0,a=p=>{let u=i(p);return t.min!==void 0&&u<t.min&&(u=t.min),t.max!==void 0&&u>t.max&&(u=t.max),u},l=t.value===void 0||t.value===null||!Number.isFinite(t.value)?void 0:i(t.value),c=l??t.min??0,s=p=>{p!==l&&t.onCommit(p)},d=g("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:t.min,max:t.max,step:e,placeholder:t.placeholder,disabled:!!t.disabled,onChange:p=>{const u=p.target,f=(u.value??"").trim();if(f===""){l!==void 0&&(u.value=String(l));return}const h=Number(f);if(!Number.isFinite(h)){u.value=l===void 0?"":String(l);return}const m=a(h);u.value=String(m),s(m)}});return g("div",{class:"pd-stepper"},[g("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!t.disabled||c<=(t.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>s(a(c-e))}),d,g("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!t.disabled||c>=(t.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>s(a(c+e))})])}function ie(t,e,n,r){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:t}),r??""]),e,n?g("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const fs=t=>g("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function Ve(t,e,n,r){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t"},[t,fs(n)]),r??""]),e])}function Xt(t){const e=t.base?.[t.propKey],n=t.target?.[t.propKey]!==e,r=t.force===!0||n,o=t.tipOverride??(t.tipValue===void 0?"恢复默认值":`恢复默认值(${t.tipValue}${t.tipUnit?" "+t.tipUnit:""})`),i=t.force?`${o}(应用到全部选中格)`:o;return g("button",{type:"button",class:`pd-reset-btn${n&&!t.force?" is-dirty":""}`,"data-tip":i,"aria-label":i,html:Ne("RotateCcw",13),onClick:()=>{r&&(t.write?t.write(e):t.target[t.propKey]=e,t.onReset?.())}})}const st=t=>g("h3",{class:"pd-divider",text:t});function Xe(t,e,n="颜色选择",r){return Gy({value:t,title:n,triggerClass:r,onChange:o=>e(o)})}function kt(t,e,n,r,o=!1){return g("div",{class:`pd-radio-group${o?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(i=>g("label",{class:"pd-radio"},[g("input",{type:"radio",name:t,value:i.value,checked:n===i.value,onChange:()=>r(i.value)}),g("span",{text:i.label})])))}function Np(t,e,n,r={}){const o=document.createElement("select");o.className=r.className??"pd-select",r.width&&(o.style.width=r.width);for(const i of e){const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.disabled&&(a.disabled=!0),o.appendChild(a)}return o.value=t,e.some(i=>i.value===t)||(o.selectedIndex=-1),o.addEventListener("change",()=>n(o.value)),o}function rv(t){const e=window.innerHeight;for(let n=t.parentElement;n&&n!==document.body;n=n.parentElement){const r=getComputedStyle(n).overflowY;if(r==="auto"||r==="scroll"||r==="hidden"||r==="clip"){const o=n.getBoundingClientRect();return{top:Math.max(0,o.top),bottom:Math.min(e,o.bottom)}}}return{top:0,bottom:e}}function qo(t){const e=Vg(t.fonts),n=t.placeholder??"默认",r=`font-select-list-${t.id}`,o=k=>{const S=k?.trim();return S?sc(e,S)?.label??S:""},i=k=>{const S=qn(k);return e.find(O=>O.label&&qn(O.label)===S)?.family??k},a=()=>{const k=t.value?.trim();return k?sc(e,k)?"":k:""},l=k=>{const S=(t.value??"").trim(),C=(I,x,j,te)=>({kind:I,key:x,label:j,value:te,selected:(te??"")===S}),O=k.trim();if(!O){const I=[C("clear","__clear__",n)],x=a();x&&I.push(C("unknown","__unknown__",`${x}(未知)`,x));for(const j of e)I.push(C("font",j.family,lc(j),j.family));return I}const R=Kg(e,O).map(I=>C("font",I.family,lc(I),I.family));if(!R.length){const I=i(O);R.push(C("free","__free__",`使用「${I}」`,I))}return R},c=document.createElement("div");c.className="font-select";const s=document.createElement("input");s.className="pd-input font-select-input",s.type="text",s.setAttribute("role","combobox"),s.setAttribute("aria-autocomplete","list"),s.setAttribute("aria-controls",r),s.autocomplete="off",s.placeholder=n,s.disabled=!!t.disabled,s.value=o(t.value);const d=document.createElement("ul");d.id=r,d.className="font-select-list",d.setAttribute("role","listbox");const p=t.state.fontOpen?.id===t.id?t.state.fontOpen:null,u={open:!!p&&!t.disabled,query:p?.query??"",highlighted:p?.highlighted??-1};u.open&&(s.value=u.query);const f=()=>{t.state.fontOpen=u.open?{id:t.id,query:u.query,highlighted:u.highlighted}:null};f();const h=()=>{const k=(t.value??"").trim();return l(u.query).findIndex(S=>(S.value??"")===k)},m=()=>{const k=s.getBoundingClientRect(),S=rv(s);d.classList.toggle("is-up",Sh({triggerTop:k.top,triggerBottom:k.bottom,overlayHeight:d.getBoundingClientRect().height,boundaryTop:S.top,boundaryBottom:S.bottom})==="up")},b=()=>{if(!u.open){d.isConnected&&d.remove(),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant","");return}d.isConnected||c.appendChild(d);const k=l(u.query);d.replaceChildren(...k.map((S,C)=>{const O=document.createElement("li");return O.id=`${r}-${C}`,O.className="font-select-option"+(C===u.highlighted?" is-active":"")+(S.kind==="unknown"||S.kind==="free"?" is-muted":""),O.setAttribute("role","option"),O.setAttribute("aria-selected",String(S.selected)),O.textContent=S.label,O.addEventListener("mousedown",R=>{R.preventDefault(),N(S)}),O})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:""),m()},v=()=>{u.open||t.disabled||(u.open=!0,u.query="",u.highlighted=h(),f(),b())},w=()=>{u.open||v()},_=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),b()},T=k=>{if(!u.open){v();return}const S=l(u.query).length-1;if(S<0)return;u.highlighted=Math.min(Math.max(u.highlighted+k,0),S),f(),b(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},z=()=>{if(!u.open)return;const k=l(u.query)[u.highlighted];if(k){N(k);return}const S=u.query.trim();if(S){const C=i(S);N({value:C})}},N=k=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(k.value),b(),t.onChange(k.value)},P=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(t.value),b())};return s.addEventListener("focus",v),s.addEventListener("click",w),s.addEventListener("input",_),s.addEventListener("blur",P),s.addEventListener("keydown",k=>{const S=k;S.key==="ArrowDown"?(S.preventDefault(),T(1)):S.key==="ArrowUp"?(S.preventDefault(),T(-1)):S.key==="Enter"?(S.preventDefault(),z()):S.key==="Escape"&&(S.preventDefault(),P())}),c.append(s),b(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const ov=[{key:"solid",label:"实线",preview:"1.5px solid currentColor"},{key:"dashed",label:"虚线",preview:"1.5px dashed currentColor"},{key:"dotted",label:"点线",preview:"1.5px dotted currentColor"},{key:"double",label:"双线",preview:"3px double currentColor"}],iv={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function Ct(t,e,n,r,o={}){return g("button",{type:"button",class:`ft-cell-btn${o.on?" on":""}`,dataset:{test:t,tip:e},disabled:!!o.disabled,onClick:r,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${n}</svg>`})}const wn='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',Lp='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function av(t){const e=t.format;e.syncBorderDraft();const n=e.values,r=!e.fontEditable,o=r||e.context==="cells",i=e.context==="none",a=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",s=u=>r?`${u}(需选中文本元素)`:u,d=[g("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[g("div",{class:"ft-border-grid"},[Ct("preset-none","无边框",`${wn}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),Ct("preset-all","所有边框",`${Lp}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),Ct("preset-outer","外侧边框",Lp,()=>e.applyBorderPreset("outer")),Ct("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${wn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!a}),Ct("edge-top","上边框",`${wn}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),Ct("edge-bottom","下边框",`${wn}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),Ct("edge-left","左边框",`${wn}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),Ct("edge-right","右边框",`${wn}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),g("div",{class:"ft-style-row"},ov.map(u=>g("button",{type:"button",class:`ft-style-btn${e.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:e.borderStyle===u.key?`${u.label}(再点一次取消,线型=无)`:u.label},onClick:()=>{e.toggleBorderStyle(u.key),t.repaint()}},[g("span",{class:"ft-style-line",style:{borderTop:u.preview}})]))),g("div",{class:"ft-border-style-row"},[g("span",{class:"ft-edge-label",text:"粗细"}),g("div",{class:"ft-line-width"},[Z({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:u=>{e.setBorderWidth(u),t.repaint()}})])]),g("div",{class:"ft-border-style-row"},[g("span",{class:"ft-edge-label",text:"颜色"}),Xe(e.borderColor,u=>{e.setBorderColor(u),t.repaint()},"边框颜色")]),e.borderMixedAny?g("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],p=[g("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[g("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([u,f,h])=>g("button",{type:"button",class:`ft-cell-btn${n.textAlign===u?" on":""}`,dataset:{test:`align-${u}`,tip:f},disabled:r,onClick:()=>e.applyStyle({textAlign:u}),html:Ne(h)}))),g("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([u,f,h])=>g("button",{type:"button",class:`ft-cell-btn${n.verticalAlign===u?" on":""}`,dataset:{test:`valign-${u}`,tip:f},disabled:r,onClick:()=>e.applyStyle({verticalAlign:u}),html:Ne(h)})))])];return g("div",{class:"format-toolbar"},[g("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[g("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),t.repaint()},onDblclick:()=>{e.pickPainterSource(!0),t.repaint()},html:Ne("Paintbrush")})]),g("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[g("div",{class:"ft-font"},[qo({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===Wt?"混合":"默认",disabled:r,onChange:u=>e.applyStyle({fontFamily:u})})]),g("div",{class:"ft-size",dataset:{test:"font-size"}},[Z({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===Wt?"混合":"默认",onCommit:u=>e.applyStyle({fontSize:u})})])]),g("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([u,f,h,m])=>g("button",{type:"button",class:`ft-btn${n[u]===!0?" on":""}`,dataset:{test:u,tip:s(h)},disabled:u==="bold"?r:o,onClick:m,html:Ne(f)}))]),g("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[g("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[Xe(typeof n.color=="string"?n.color:void 0,u=>e.applyStyle({color:u})),g("span",{class:"ft-glyph",text:"A"})]),g("span",{class:`ft-color-btn${i?" dim":""}`,title:"背景色"},[Xe(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>e.applyStyle({backgroundColor:u})),g("span",{class:"ft-glyph",html:Ne("PaintBucket",14)})])]),g("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[Uo(t,"align",{icon:iv[String(n.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:r?"对齐(需选中文本元素或单元格)":"对齐",disabled:r,testId:"align-dd"},p)]),g("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[Uo(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const sv=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",label:"流式列表",icon:"⊟"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],lv={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function cv(t){const e=t.state;if(e.leftCollapsed)return g("div",{class:"left-panel collapsed"},[g("div",{class:"left-collapsed"},[Fp("»","展开素材台",()=>{e.leftCollapsed=!1,t.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([r,o,i])=>g("button",{type:"button",class:`lc-btn${e.leftTab===r?" on":""}`,title:o,text:i,onClick:()=>{e.leftTab=r,e.leftCollapsed=!1,t.repaint()}}))])]);const n=(r,o)=>g("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===r?"":{display:"none"}},o);return g("div",{class:"left-panel"},[g("div",{class:"left-head"},[g("span",{class:"left-title",text:"素材台"}),Fp("«","收起素材台",()=>{e.leftCollapsed=!0,t.repaint()})]),g("div",{class:"pd-tabs left-tabs"},[g("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([r,o])=>g("button",{type:"button",class:`pd-tab${e.leftTab===r?" active":""}`,text:o,onClick:()=>{e.leftTab=r,t.repaint()}}))]),n("elements",dv()),n("fields",[uv(t)]),n("layers",[pv(t)])])])}function Fp(t,e,n){return g("button",{type:"button",class:"collapse-btn",title:e,text:t,onClick:n})}function dv(){return[g("div",{class:"panel-title",text:"拖拽元素到画布"}),...sv.map(t=>g("div",{class:"material-card",draggable:!0,dataset:{test:`material-${t.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",t.type)},[g("span",{class:"material-icon",text:t.icon}),g("span",{class:"material-label",text:t.label})]))]}function uv(t){const e=t.state,n=Kc(t.store.fields),r=(e.fieldSearch??"").trim().toLowerCase(),o=r?n.map(i=>({...i,fields:i.fields.filter(a=>`${a.fieldLabel}${a.fieldKey}`.toLowerCase().includes(r))})).filter(i=>i.fields.length):n;return g("div",{class:"field-tree-panel"},[g("div",{class:"panel-title",text:"业务字段"}),g("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:i=>{e.fieldSearch=i.target.value},onChange:()=>t.repaint()}),g("div",{class:"tree-container"},o.flatMap(i=>{const a=e.collapsedGroups.has(i.key)&&!r,l=i.key?g("div",{class:`field-group-header${i.isList?" is-list":""}`,onClick:()=>{a?e.collapsedGroups.delete(i.key):e.collapsedGroups.add(i.key),t.repaint()}},[g("span",{class:"expand-icon",text:a?"▶":"▼"}),g("span",{class:"node-icon",text:i.isList?"📋":"📁"}),g("span",{class:"group-label",text:i.label,"data-tip":i.label})]):"",c=a?[]:i.fields.map(s=>g("div",{class:"field-row",draggable:!0,"data-tip":`${s.fieldLabel} (${s.fieldKey})`,style:{paddingLeft:`${i.key?22:8}px`},onDragstart:d=>{d.dataTransfer?.setData("fieldKey",s.fieldKey)}},[g("span",{class:"node-icon",text:"📄"}),g("span",{class:"node-meta"},[g("span",{class:"node-label",text:s.fieldLabel}),g("span",{class:"node-key",text:`(${s.fieldKey})`})])]));return[l,g("div",{},c.filter(Boolean))].filter(Boolean)})),o.length===0?g("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function pv(t){const e=t.store,n=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),r=e.elements.filter(l=>e.selectedIds.has(l.id)),o=r.length>=2,i=r.some(l=>!!l.options.groupId),a=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return g("div",{class:"layer-panel"},[g("div",{class:"panel-title",text:"图层"}),...n.map(l=>g("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[g("span",{class:"layer-icon",text:lv[l.printElementType.type]||"?"}),g("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),a(l)?g("span",{class:"layer-zone",text:a(l)}):"",g("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),n.length?g("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,s])=>g("button",{type:"button",class:"pd-button small",title:c,html:Ne(s,14),onClick:()=>t.fire("move-layer",l)}))]):"",o||i?g("div",{class:"layer-actions"},[o?g("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:Ne("Group",14),onClick:()=>t.fire("group")}):"",i?g("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:Ne("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function fv(t){const e=t.store,n=t.state,r=e.pages.length>1,o=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,i=e.tilingEnabled;return g("div",{class:"page-tabs"},[g("div",{class:"page-tabs-list"},e.pages.map((l,c)=>n.renamingPage===c?g("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:n.renameText??"",onInput:s=>{n.renameText=s.target.value},onBlur:()=>a(),onKeydown:s=>{const d=s;if(d.key==="Enter"){a();return}d.key==="Escape"&&(n.renamingPage=null,t.repaint())}}):g("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{n.renamingPage=c,n.renameText=l.name??"",t.repaint()}}))),g("div",{class:"page-tabs-actions"},[g("button",{type:"button",dataset:{test:"add-page",tip:i?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:i,text:"+",onClick:()=>t.fire("add-page")}),g("button",{type:"button",dataset:{test:"duplicate-page",tip:i?"拼版模板仅允许一个设计页面":`复制当前页「${o}」`},disabled:i,text:"⧉",onClick:()=>t.fire("duplicate-page")}),g("button",{type:"button",dataset:{test:"delete-page",tip:r?`删除当前页「${o}」`:"仅多页面模板可删除页面"},disabled:!r,text:"✕",onClick:()=>t.fire("delete-page")}),g("button",{type:"button",dataset:{test:"move-left",tip:`前移「${o}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>t.fire("move-page",-1)}),g("button",{type:"button",dataset:{test:"move-right",tip:`后移「${o}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>t.fire("move-page",1)})])]);function a(){const l=(n.renameText??"").trim();n.renamingPage!==null&&l&&e.renamePage(n.renamingPage,l),n.renamingPage=null,t.repaint()}}function hv(t){const e=t.store,n=e.templateData,r=Et(n),o=n.orientation==="landscape"?"横向":"纵向",i=nt[n.paperSize]?.label??n.paperSize,a=n.outputRotation,l=`${i} ${o} ${Math.round(r.width)}×${Math.round(r.height)}mm${a?`(旋转${a}°)`:""}`;return g("div",{class:"status-bar"},[g("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),g("span",{class:"status-item",text:`缩放 ${e.scale}%`}),g("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),g("span",{class:`status-dirty${e.dirty?" on":""}`},[g("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),g("span",{class:"status-item status-paper",text:l})])}const gv=Object.keys(nt).filter(t=>t!=="CUSTOM"&&!nt[t]?.continuous);function mv(t){const e=document.createElement("label");e.className="pd-button small upload-label";const n=document.createTextNode("上传背景图"),r=document.createElement("input");r.className="visually-hidden",r.type="file",r.accept="image/*",e.append(n,r);const o=i=>{e.className=`pd-button small upload-label${i?" disabled":""}`,r.disabled=i};return r.addEventListener("change",async()=>{const i=r.files?.[0];if(!i)return;if(!i.type.startsWith("image/")){alert("仅支持上传图片文件"),r.value="";return}const a=t.host.uploadDesignBackground;if(!a){alert("设计背景上传能力未配置"),r.value="";return}o(!0),n.textContent="上传中...";try{const l=await a(i);l?t.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{n.textContent="上传背景图",o(!t.host.uploadDesignBackground),r.value=""}}),t.host.uploadDesignBackground||o(!0),e}function bv(t){const n=t.store.templateData.designBackground,r=n?.rotation??0;return g("div",{class:"design-background-config"},[st("设计背景"),g("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),n?.src?[g("div",{class:"design-background-path",title:n.src,text:n.src}),g("div",{class:"design-background-actions"},[g("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(r+90)%360}°)`,onClick:()=>t.store.updateTemplateData({designBackground:{...n,rotation:(r+90)%360}})}),g("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>t.store.updateTemplateData({designBackground:void 0})})])]:mv(t)].flat())}function yv(t){const e=t.store,n=e.templateData,r=n.tiling,o={...ot,...r??{},enabled:r?.enabled??!1,sheetMargin:{...ot.sheetMargin,...r?.sheetMargin??{}}},i=wi(n.paperSize),a=h=>e.updateTemplateData({tiling:{...o,...h}}),l=h=>Xt({target:o,base:ot,propKey:h,write:()=>a({[h]:ot[h]})}),c=h=>Xt({target:o.sheetMargin,base:ot.sheetMargin,propKey:h,write:()=>s(h,ot.sheetMargin[h])}),s=(h,m)=>a({sheetMargin:{...o.sheetMargin,[h]:m??0}}),d={...n,tiling:o},p=ca(d),u=Math.max(zc(d),1);let f="";if(!p.length)try{const h=Fc(d),m=Yn(d),b=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",v=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";f=`目标纸 ${b}${v} ${m.width}×${m.height}mm · ${h.columns} 列 × ${h.rows} 行 = 每张 ${h.perSheet} 格 · 每格 ${h.tile.width}×${h.tile.height}mm`}catch{f=""}return g("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[st("拼版打印"),g("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),g("div",{class:"pd-field"},[g("label",{class:"tiling-switch"},[g("input",{type:"checkbox",checked:o.enabled===!0,disabled:i,onChange:h=>{if(!h.target.checked){a({enabled:!1});return}a({...ot,columns:Math.min(ot.columns,Math.max(u,1))})}}),g("span",{text:"启用拼版"})]),i?g("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[ie("目标纸张",g("select",{class:"pd-select",style:{width:"100%"},onChange:h=>{const m=h.target.value;if(m!=="CUSTOM"){a({sheetPaperSize:m});return}const b=Yn(d);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??b.width,sheetCustomHeight:o.sheetCustomHeight??b.height})}},[...gv.map(h=>g("option",{value:h,text:nt[h]?.label??h,selected:(o.sheetPaperSize??"A4")===h})),g("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),o.sheetPaperSize==="CUSTOM"?ie("目标纸宽高 (mm)",g("div",{class:"custom-size-grid"},[Z({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:h=>a({sheetCustomWidth:h})}),g("span",{class:"custom-size-x",text:"×"}),Z({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:h=>a({sheetCustomHeight:h})})])):ie("目标纸方向",kt("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",h=>a({sheetOrientation:h})),void 0,l("sheetOrientation")),st("拼版留白 (mm)"),g("div",{class:"margin-grid"},[ie("上",Z({value:o.sheetMargin.top??0,min:0,max:100,onCommit:h=>s("top",h)}),void 0,c("top")),ie("下",Z({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:h=>s("bottom",h)}),void 0,c("bottom")),ie("左",Z({value:o.sheetMargin.left??0,min:0,max:100,onCommit:h=>s("left",h)}),void 0,c("left")),ie("右",Z({value:o.sheetMargin.right??0,min:0,max:100,onCommit:h=>s("right",h)}),void 0,c("right"))]),st("格间距与列数"),ie("横向间距",Z({value:o.gapX??0,min:0,max:50,onCommit:h=>a({gapX:h??0})}),void 0,l("gapX")),ie("纵向间距",Z({value:o.gapY??0,min:0,max:50,onCommit:h=>a({gapY:h??0})}),void 0,l("gapY")),ie("列数",Z({value:o.columns??1,min:1,max:u,onCommit:h=>a({columns:h||1})})),...p.map(h=>g("p",{class:"pd-hint tiling-error",text:h.message})),!p.length&&f?g("p",{class:"pd-hint tiling-summary",text:f}):""]:""].flat().filter(Boolean))}const vv=new Set(Ar.map(t=>t.group)),wv={"table-settings":"content"},zp=new Map;function hs(t){const e=t??"";let n=zp.get(e);if(!n){const{groups:r,itemKeys:o}=hg(e);n={groups:r,keys:o,searching:!!e.trim()},zp.set(e,n)}return n}function gs(t){const e=wv[t]??t;return vv.has(e)?e:""}function xv(t,e){const n=hs(t.state.propSearch);if(!n.searching)return!0;const r=gs(e);return!r||n.groups.includes(r)}function Ev(t,e){const n=hs(t.state.propSearch);return!n.searching||n.keys.has(e)}function Bp(t,e){const n=t.props.style??{};return t.props.style={...n,display:e?"":"none"},t}function H(t,e,n){const r=n.props.dataset??{};return n.props.dataset={...r,propKey:e},Bp(n,Ev(t,e))}function Sv(t,e,n){const r=gs(e);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},Bp(n,xv(t,e))}function Hp(t,e){const n=hs(e);for(const r of Array.from(t.querySelectorAll("[data-prop-group]"))){const o=gs(r.dataset.propGroup??"");r.style.display=!n.searching||!o||n.groups.includes(o)?"":"none"}for(const r of Array.from(t.querySelectorAll("[data-prop-key]")))r.style.display=!n.searching||n.keys.has(r.dataset.propKey??"")?"":"none"}function _v(t){return g("div",{class:"property-search"},[g("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:t.state.propSearch??"",onInput:e=>{const n=e.target,r=n.value;t.state.propSearch=r,Hp(n.getRootNode(),r)}})])}const Mv={Document:"≡",Brush:"◧",Setting:"⚙"};function Tv(t,e){try{const n=window.localStorage.getItem(`property-group-${t}`);return n===null?e:n==="true"}catch{return e}}function kv(t,e){try{window.localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function Le(t,e,n,r,o,i=!0){const a=Tv(e,i);return Sv(t,e,g("div",{class:`property-group${a?" is-expanded":""}`},[g("div",{class:"group-header",onClick:()=>{kv(e,!a),t.repaint()}},[g("span",{class:"group-icon",text:Mv[r]||"•"}),g("span",{class:"group-title",text:n}),g("span",{class:"expand-icon",text:a?"▾":"▸"})]),g("div",{class:"group-content",style:a?"":{display:"none"}},o.filter(Boolean))]))}function Wo(t){return g("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function Up(t){return t.split(".").flatMap(e=>{const n=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!n)return[e];const r=n[1],o=[...n[2].matchAll(/\[(\d+)\]/g)].map(i=>Number(i[1]));return[r,...o]})}function qp(t,e){return Up(e).reduce((o,i)=>o==null?"":o[i],t)??""}function ms(t,e,n,r){const o=Up(n),i=o.pop(),a=o.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);a[i]=r||void 0,t.recordHistory(),t.emit()}function Cv(t,e){const n=t.store;if(e.printElementType.type==="table"&&n.tableSelection?.elementId===e.id){const{r1:r,c1:o}=n.tableSelection,i=(e.options.tableRows??[])[r];if(i)return Zc(i.type,r,o,e.options.fields?.[0]?.dataSource)}return m0(e)}function Av(t,e){const n=document.createElement("label");n.className="pd-button small upload-label",Re(g("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[g("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),n);const r=document.createTextNode("上传图片"),o=document.createElement("input");o.className="visually-hidden",o.type="file",o.accept="image/*",n.append(r,o);const i=c=>{n.className=`pd-button small upload-label${c?" disabled":""}`,o.disabled=c};o.addEventListener("change",async()=>{const c=o.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),o.value="";return}const s=t.host.uploadImage;if(!s){alert("图片上传能力未配置"),o.value="";return}i(!0),r.textContent="上传中...";try{const d=await s(c);d?ms(t.store,e,"options.src",d):alert("图片上传失败")}catch(d){alert(d instanceof Error?d.message:"图片上传失败")}finally{r.textContent="上传图片",i(!t.host.uploadImage),o.value=""}}),t.host.uploadImage||i(!0);const a=document.createElement("div");a.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",a.append(n,l),a}function Ov(t,e){const n=r=>t.fire("open-expression",{elementId:e.id,targetPath:r.targetPath,value:qp(e,r.targetPath)});return Le(t,"binding","内容","Document",[...Cv(t,e).map(r=>ie(r.label,g("input",{class:"pd-input",type:"text",value:qp(e,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>ms(t.store,e,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),e.printElementType.type==="image"?Av(t,e):""].filter(Boolean))}const fr=new Map;function jo(t){return`${Math.round(t*1e4)/1e4}%`}function Wp(t,e){const n=r0(e.value),r=n.kind==="custom",o=n.kind==="axes"?n.x:50,i=n.kind==="axes"?n.y:50,a=c0(e.src),l=fr.get(a.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},s=o0(c),d=i0(c,o,i),p=document.createElement("select");p.className="pd-select",p.style.width="100%";for(const m of f0(s,o,i)){const b=document.createElement("option");b.value=m.value,b.textContent=m.label,p.appendChild(b)}if(r){const m=document.createElement("option");m.value="custom",m.textContent="自定义(保留原值)",p.appendChild(m)}p.value=r?"custom":`${o},${i}`,p.selectedIndex<0&&(p.selectedIndex=r?p.options.length-1:0),p.addEventListener("change",()=>{if(p.value==="custom")return;const[m,b]=p.value.split(",").map(Number);e.onCommit(Wc(m,b))});const u=Oe(e.fieldKey),f=[g("div",{class:"pd-field",dataset:{field:e.fieldKey}},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t"},[e.label,fs(u)]),e.resetAnchor??""].filter(Boolean)),p])];f.push(g("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t"},[d0,fs(Oe("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),Z({value:e.scale,min:Rn,max:tl,step:5,placeholder:"默认 100",onCommit:m=>e.onScaleCommit(m>Rn?m:void 0)})]));for(const m of p0(s,o,i))f.push(g("div",{class:"pd-field",dataset:{field:e.fieldKey}},[g("span",{class:"pd-label",text:m.label}),Z({value:m.value,min:0,max:100,step:1,onCommit:b=>e.onCommit(Wc(m.name==="horizontal"?b:o,m.name==="vertical"?b:i))})]));const h=u0(s,r);return h&&f.push(g("p",{class:"pd-crop-note",text:h})),a.isSample&&f.push(g("p",{class:"pd-crop-note",text:l0})),f.push(g("div",{class:"pd-crop-preview"},[g("img",{class:"pd-crop-thumb",src:a.src,alt:a.isSample?"示例图":"原图",onLoad:m=>{const b=m.target;if(!(b.naturalWidth>0&&b.naturalHeight>0))return;const v=fr.get(a.src);v&&v.width===b.naturalWidth&&v.height===b.naturalHeight||(fr.set(a.src,{width:b.naturalWidth,height:b.naturalHeight}),t.repaint())},onError:()=>{fr.has(a.src)&&(fr.delete(a.src),t.repaint())}}),d?g("div",{class:"pd-crop-win",style:{left:jo(d.leftPct),top:jo(d.topPct),width:jo(d.widthPct),height:jo(d.heightPct)}}):""])),g("div",{class:e.containerClass??"pd-crop-anchor"},f)}const Kt=t=>Number(t??0),bs=t=>t||void 0;function xn(t,e,n,r,o){return g("div",{class:"pd-field"},[g("span",{class:"pd-label",...r?{title:r}:{}},[g("span",{class:"pd-label-t",text:t}),o??""].filter(Boolean)),g("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:i=>n(i.target.checked)})])}function jp(t,e,n,r,o=!1,i){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:t}),""].filter(Boolean)),g("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:a=>r(a.target.value)},n.map(a=>g("option",{value:a.value,text:a.label,selected:a.value===e})))])}function hr(t,e,n,r,o={}){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:t}),o.reset??""].filter(Boolean)),Np(e,n,r,{className:"pd-select",...o.full?{width:"100%"}:{}})])}const gr=t=>g("p",{class:"pd-hint",text:t}),Iv="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Pv=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Rv=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Dv=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],$v=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Nv={value:"__multi__",label:"多选",disabled:!0};function Lv(t,e){const n=t.store,r=n.tableSelection,o=e.options.tableRows??[],i=r?o[r.r1]:void 0;if(!r||!i)return Le(t,"table-row","行属性","Grid",[]);const a=l=>n.updateElement(e.id,l);return Le(t,"table-row","行属性","Grid",[Wo([jp("行类型",i.type,Pv,l=>{const c=_i(o,r.r1,l);if(c){window.alert(c);return}a({tableRows:o})},!0),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"行高 (mm)"}),Z({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?xn("表头每页重复",i.repeatOnPage??!1,l=>{Nh(o,l),a({tableRows:o})},Iv):""])])}function Fv(t,e){const n=t.store,r=e.options,o=d=>n.updateElement(e.id,d),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(d=>d.fieldType==="list").map(d=>({value:d.fieldKey,label:d.fieldLabel})),c=Ii("table"),s=d=>Xt({target:r,base:c,propKey:d,write:()=>o({[d]:c[d]})});return Le(t,"table-settings","表格设置","Grid",[Wo([jp("列表数据源字段",r.dataSource??"",l,d=>o({dataSource:d||void 0}),!0),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认字体"}),s("tableDefaultFontFamily")]),qo({id:"table-default-font",state:t.state,fonts:t.host.fonts,value:r.tableDefaultFontFamily,placeholder:"默认",onChange:d=>o({tableDefaultFontFamily:d||void 0})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认字号 (pt)"}),s("tableDefaultFontSize")]),Z({value:Kt(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:d=>o({tableDefaultFontSize:bs(d)})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认文字颜色"}),s("tableDefaultColor")]),Xe(r.tableDefaultColor,d=>o({tableDefaultColor:d}),"默认文字颜色")]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),s("tableDefaultPadding")]),Z({value:Kt(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:d=>o({tableDefaultPadding:bs(d)})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((d,p)=>g("div",{class:"col-width-row"},[g("span",{style:{width:"60px"},text:`列${p+1}`}),Z({value:d,min:5,max:200,onCommit:u=>{const f=i.reduce((h,m,b)=>b===p?h:h+m,0);if(f+u>a){const h=Math.max(5,Math.round((a-f)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${p+1} 已调整为 ${h}mm`),i[p]=h}else i[p]=u;o({tableColWidths:i})}})]))])])])}function zv(t,e){const n=t.store,r=e.options,o=e.printElementType.type==="table",i=l=>n.updateElement(e.id,l),a=[];if(o)a.push(H(t,"pg-enabled",xn("启用分页",r.tablePagination?.enabled??!0,l=>i({tablePagination:{enabled:l}}))));else{const l=r.pagination?.pageable??!0,c=r.pagination?.keepWithNext??!1;a.push(H(t,"pg-pageable",xn("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(H(t,"pg-keep-with-next",xn("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return Le(t,"pagination","分页配置","Document",[Wo(a)],!1)}const ys=new WeakMap,Gp=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Bv(t,e){const n=t.store,r=n.tableSelection,o=e.options.tableRows??[];if(!r)return Le(t,"table-cell","单元格","Menu",[]);const i=Si(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return Le(t,"table-cell","单元格","Menu",[]);const l=()=>kr(o,r),c=Mi(o,r),s=c.count,d=c.mode==="multi",p=`${e.id}:${r.r1}:${r.c1}:${r.r2}:${r.c2}`,u=ys.get(n),f=u?.key===p?u:{key:p,border:{},values:{},edges:{}};u?.key!==p&&ys.set(n,f);const h=M=>{ys.set(n,{key:p,border:M.border??f.border,values:M.values??f.values,edges:M.edges??f.edges})},m=(M,J)=>{h({border:{...f.border,[M]:J}}),t.repaint()},b=(M,J)=>{l().forEach(M),d&&J&&h({values:{...f.values,...J}}),n.updateElement(e.id,{tableRows:o})},v=(M,J)=>{b(ue=>{ue[M]=J},{[M]:J})},w=M=>d?f.values[M]:a[M],_=M=>d&&M in f.values,T=d?{width:void 0,style:void 0,color:void 0}:_l(o,r),z=!d&&l().some(M=>!!M.borders&&!!(M.borders.top||M.borders.right||M.borders.bottom||M.borders.left)),N=!d&&!z,P={width:N?0:typeof T.width=="number"?T.width:St.width,style:N?"none":typeof T.style=="string"&&T.style!=="mixed"?T.style:St.style,color:typeof T.color=="string"&&T.color!=="mixed"?T.color:St.color,...f.border},k="__mixed__",S={style:!d&&T.style==="mixed",width:!d&&T.width==="mixed",color:!d&&T.color==="mixed"},C=S.style&&!("style"in f.border),O=S.width&&!("width"in f.border),R=S.color&&!("color"in f.border),I=C||O||R,x=C?k:P.style,j=O?void 0:P.width,te=R?void 0:P.color,fe=M=>{const J={style:M};M!=="none"&&j===0?J.width=St.width:M==="none"&&!z&&(J.width=0),h({border:{...f.border,...J}}),t.repaint()},G=()=>({...P}),de=d?Gp.reduce((M,J)=>(M[J.value]=f.edges[J.value]?"on":"off",M),{}):Tl(l().map(M=>M.borders)),Ke=d?"cellType"in f.values?f.values.cellType??"text":Bh(o,r):a.cellType??"text",ye=Ke==="barcode",Fe=Ke==="qrcode",D=Ke==="image",L=Ke==="text",W=ye&&!!w("printerDpi"),V=Ks(w("printerDpi"),w("barWidth")),Y=d?f.values.textFit:ii(a),X=d?"cellType"in f.values?f.values.cellType??"text":"":a.cellType||"text",ne=M=>d?[Nv,...M]:M,Q=M=>d?"多选":M,se=(M,J)=>d?f.values[M]:J,he=d?w("barcodeType")??"__multi__":a.barcodeType||"CODE128",_e=d?_("printerDpi")?w("printerDpi")?String(w("printerDpi")):"":"__multi__":a.printerDpi?String(a.printerDpi):"",K=d?w("qrCodeLevel")??"__multi__":a.qrCodeLevel||"M",yt=d?w("fit")??"__multi__":a.fit||"contain",ee=Y??"__multi__",lt=bl(o,r);let Me=!1;for(let M=r.r1;M<=r.r2&&!Me;M++)for(let J=r.c1;J<=r.c2&&!Me;J++){const ue=o[M]?.cells[J];ue&&!ue.merged&&((ue.rowspan??1)>1||(ue.colspan??1)>1)&&(Me=!0)}const Ae=(M,J,ue,le={},ze)=>g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:M}),ze??""].filter(Boolean)),Z({value:J,...le,onCommit:Pt=>v(ue,bs(Pt))})]),Ee="恢复默认值(跟随表格默认)",re=M=>Xt({target:a,base:{},propKey:M,tipOverride:Ee,force:d,write:()=>v(M,void 0)}),Ot=e.options.tableDefaultPadding??1,It={width:si(e.options.tableColWidths??[],i.c,a,Ot),height:An(o,i.r,a,Ot)};return Le(t,"table-cell","单元格","Menu",[Wo([d?gr(`已选 ${s} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"单元格类型"}),kt("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],X,M=>{const J=M==="text"?void 0:M,ue={cellType:M};M!=="barcode"&&Object.assign(ue,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),M!=="qrcode"&&Object.assign(ue,{qrCodeLevel:void 0,qrQuietZone:void 0}),b(le=>{le.cellType=J,M!=="barcode"&&(le.barcodeType=void 0,le.showBarcodeText=void 0,le.printerDpi=void 0,le.barQuietZone=void 0,le.barHeight=void 0),M!=="qrcode"&&(le.qrCodeLevel=void 0,le.qrQuietZone=void 0)},ue)})]),ye?hr("码制",he,ne(Rv),M=>{M!=="__multi__"&&v("barcodeType",M||void 0)}):"",ye?xn("显示文本",d?f.values.showBarcodeText===!0:a.showBarcodeText!==!1,M=>v("showBarcodeText",M),void 0,re("showBarcodeText")):"",ye?Ae("条宽(倍率)",se("barWidth",a.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:Q("")},re("barWidth")):"",ye?gr((W?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(V?`。${V}`:"")):"",ye?Ve("静区 (模块)",Z({value:se("barQuietZone",a.barQuietZone),min:0,max:20,placeholder:Q("默认 10"),onCommit:M=>v("barQuietZone",M)}),Oe("cd-bar-quiet-zone"),re("barQuietZone")):"",ye?Ve("条高 (mm)",Z({value:se("barHeight",a.barHeight),min:1,max:100,placeholder:Q("默认 30 模块"),onCommit:M=>v("barHeight",M??void 0)}),Oe("cd-bar-height"),re("barHeight")):"",ye?Ae("文本字号(相对条高,条高为 30)",se("barFontSize",a.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:Q("默认 10")},re("barFontSize")):"",ye?hr("打印机分辨率",_e,ne([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),M=>{if(M==="__multi__")return;const J=Number(M);v("printerDpi",J>0?J:void 0)},{reset:re("printerDpi")}):"",ye?gr("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",Fe?hr("纠错级别",K,ne(Dv),M=>{M!=="__multi__"&&v("qrCodeLevel",M||void 0)},{reset:re("qrCodeLevel")}):"",Fe?Ve("静区 (模块)",Z({value:se("qrQuietZone",a.qrQuietZone),min:0,max:8,placeholder:Q("默认 0"),onCommit:M=>v("qrQuietZone",M)}),Oe("cd-quiet-zone"),re("qrQuietZone")):"",ye?gr("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",Fe||D?hr("缩放模式",yt,ne(pa),M=>{M!=="__multi__"&&v("fit",M)},{reset:re("fit")}):"",D&&!d&&a.fit==="cover"?Wp(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Yc(a.formatter),fit:a.fit,containerClass:"pd-cell-anchor",widthMm:It.width,heightMm:It.height,scale:a.fitScale,value:a.objectPosition,onCommit:M=>v("objectPosition",M),onScaleCommit:M=>v("fitScale",M),resetAnchor:re("objectPosition"),resetScale:re("fitScale")}):"",ye||Fe||D?Ae("最大宽度 (mm)",se("maxWidth",Kt(a.maxWidth)),"maxWidth",{min:0,max:200,placeholder:Q("默认")},re("maxWidth")):"",ye||Fe||D?Ae("最大高度 (mm)",se("maxHeight",Kt(a.maxHeight)),"maxHeight",{min:0,max:200,placeholder:Q("默认")},re("maxHeight")):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"内容"}),g("input",{class:"pd-input",type:"text",value:d?w("formatter")??"":a.formatter||"",placeholder:d?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:M=>v("formatter",M.target.value||void 0),onDblclick:()=>t.fire("table-cell-dblclick",{elementId:e.id,r:i.r,c:i.c,cellId:a.id})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"水平对齐"}),re("align")]),kt("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],d?f.values.align??"":a.align||"left",M=>v("align",M))]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"垂直对齐"}),re("valign")]),kt("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],d?f.values.valign??"":a.valign||"top",M=>v("valign",M))]),g("div",{class:"cell-style-grid"},[g("div",{class:"pd-field cell-font-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"字体"}),re("fontFamily")]),qo({id:"cell-font",state:t.state,fonts:t.host.fonts,value:d?w("fontFamily"):a.fontFamily,placeholder:Q("继承默认"),onChange:M=>v("fontFamily",M)})]),Ae("字号 (pt)",se("fontSize",Kt(a.fontSize)),"fontSize",{min:0,max:72,placeholder:Q("默认")},re("fontSize")),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"加粗"}),re("fontWeight")]),g("input",{class:"pd-switch",type:"checkbox",checked:d?f.values.fontWeight==="bold":a.fontWeight==="bold",onChange:M=>v("fontWeight",M.target.checked?"bold":void 0)})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"文字颜色"}),re("color")]),Xe(d?w("color"):a.color,M=>v("color",M),"文字颜色")]),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"背景色"}),re("backgroundColor")]),Xe(d?w("backgroundColor"):a.backgroundColor,M=>v("backgroundColor",M),"背景颜色")])]),st("边框"),g("div",{class:"border-style-row"},[Np(x,[...C?[{value:k,label:"混合",disabled:!0}]:[],...ki],M=>{M!==k&&fe(M)},{width:"90px"}),g("div",{style:{width:"112px",flexShrink:"0"}},[Z({value:j,min:.25,max:5,step:.25,placeholder:d?"多选":O?"混合":void 0,onCommit:M=>m("width",M)})]),Xe(te,M=>m("color",M),"边框颜色")]),g("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([M,J])=>g("button",{type:"button",class:"pd-button small",text:J,onClick:()=>{El(o,r,P.style==="none"?"none":M,G()),n.updateElement(e.id,{tableRows:o})}}))),g("div",{class:"pd-checkbox-group"},Gp.map(M=>g("label",{class:"pd-checkbox"},[g("input",{type:"checkbox",value:M.value,checked:de[M.value]==="on",indeterminate:de[M.value]==="mixed",onChange:J=>{const le=J.target.checked&&P.style!=="none";d&&h({edges:{...f.edges,[M.value]:le}}),b(ze=>{Sl(ze,M.value,le?G():null)})}}),g("span",{text:M.label})]))),gr(d?Fh:I?zh:Lh),Ae("内边距 (mm)",se("padding",Kt(a.padding)),"padding",{min:0,max:10,step:.5,placeholder:Q("默认")},re("padding")),xn("自动换行",d?f.values.wordWrap===!0:a.wordWrap??!0,M=>v("wordWrap",M),void 0,re("wordWrap")),L?hr("文字溢出",ee,ne($v),M=>{M!=="__multi__"&&v("textFit",M)},{full:!0,reset:re("textFit")}):"",L&&Y==="shrink"?Ae("最小字号 (pt)",se("shrinkMinFontSize",Kt(a.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:Q("默认 6")},re("shrinkMinFontSize")):"",g("div",{class:"merge-btns"},[g("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!lt,title:lt||"",onClick:()=>{yl(o,r),n.updateElement(e.id,{tableRows:o})}}),g("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Me,onClick:()=>{vl(o,r),n.updateElement(e.id,{tableRows:o})}})])])])}const vs=nm;function ws(t){const e=t.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function Hv(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function Uv(t){const e=t.store.templateData.watermark,n=Hv(e),r=e?.mode==="binding"||n!==""&&ws(n),o=(()=>{const s=e?.tileWidth??ae.tileWidth,d=e?.tileHeight??ae.tileHeight;for(const[p,u]of Object.entries(vs))if(u.width===s&&u.height===d)return p;return"custom"})(),i=s=>{const d={testData:e?.testData??"",rotate:e?.rotate??ae.rotate,color:e?.color||ae.color,opacity:e?.opacity??ae.opacity,tileWidth:e?.tileWidth??ae.tileWidth,tileHeight:e?.tileHeight??ae.tileHeight,timestamp:e?.timestamp,format:e?.format};t.store.updateTemplateData({watermark:{...d,...s}})},a=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n}),l={rotate:e?.rotate??ae.rotate,color:e?.color||ae.color,opacity:e?.opacity??ae.opacity,tileWidth:e?.tileWidth??ae.tileWidth,tileHeight:e?.tileHeight??ae.tileHeight},c=s=>Xt({target:l,base:ae,propKey:s,write:()=>i({[s]:ae[s]})});return g("div",{class:"watermark-config"},[st("水印"),g("form",{class:"pd-form",onSubmit:s=>s.preventDefault()},[g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"水印表达式"}),g("input",{class:"pd-input",type:"text",value:n,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:s=>{const d=s.target.value;i(ws(d)?{mode:"binding",binding:d,content:""}:{mode:"fixed",content:d,binding:""})},onDblclick:a}),g("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?ie("测试值",g("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:s=>i({testData:s.target.value})})):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),g("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??ae.rotate),onChange:s=>i({rotate:Number(s.target.value)})}),g("span",{class:"pd-hint",text:`${e?.rotate??ae.rotate}°`})]),ie("颜色",Xe(e?.color||ae.color,s=>i({color:s}),"水印颜色"),void 0,c("color")),g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),g("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??ae.opacity),onChange:s=>i({opacity:Number(s.target.value)})}),g("span",{class:"pd-hint",text:(e?.opacity??ae.opacity).toFixed(2)})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"密度"}),g("select",{class:"pd-select",style:{width:"100%"},onChange:s=>{const d=s.target.value,p=vs[d];p&&i({tileWidth:p.width,tileHeight:p.height})}},[...Object.entries(vs).map(([s,d])=>g("option",{value:s,text:`${d.label}(${d.width}×${d.height})`,selected:o===s})),g("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),g("input",{type:"number",class:"pd-input",min:ae.minTileWidth,step:10,value:String(e?.tileWidth??ae.tileWidth),onChange:s=>i({tileWidth:Number(s.target.value)})})]):"",o==="custom"?g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[g("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),g("input",{type:"number",class:"pd-input",min:ae.minTileHeight,step:10,value:String(e?.tileHeight??ae.tileHeight),onChange:s=>i({tileHeight:Number(s.target.value)})})]):""].filter(Boolean))])}function Ce(t,e,n,r,o={},i){return ie(e,Z({value:n,...o,onCommit:r}),void 0,i)}function At(t,e,n,r,o,i,a){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>o(l.value));for(const c of r){const s=document.createElement("option");s.value=c.value,s.textContent=c.label,l.appendChild(s)}return l.value=n,r.some(c=>c.value===n)||(l.selectedIndex=-1),i?Ve(e,l,i,a):ie(e,l,void 0,a)}function En(t,e,n,r,o){return ie(e,g("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:i=>r(i.target.checked)}),void 0,o)}const qv=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],Wv=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function jv(t,e){const n=t.store,r=e.options,o=e.printElementType.type,i=x=>n.updateElement(e.id,x),a=o==="text"||o==="longText",l=o==="barcode"||o==="qrcode",c=o==="table",s=c&&n.tableSelection?.elementId===e.id,d=s&&Mi(e.options.tableRows??[],n.tableSelection).mode==="multi",p=[];s||p.push(Le(t,"position-size","位置与尺寸","Location",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[g("div",{class:"position-grid"},[H(t,"ps-left",Ce(t,"X",r.left,x=>i({left:x}),{min:0})),H(t,"ps-top",Ce(t,"Y",r.top,x=>i({top:x}),{min:0})),H(t,"ps-width",Ce(t,"W",r.width,x=>i({width:x}),{min:4})),H(t,"ps-height",Ce(t,"H",r.height,x=>i({height:x}),{min:4}))])])]));const u=Ii(o),f=(x,j)=>{const te=gg(j);return Xt({target:r,base:u,propKey:x,tipValue:te?.value,tipUnit:te?.unit,write:()=>i({[x]:u[x]})})},h=typeof r.rotate=="number"&&Number.isFinite(r.rotate)&&r.rotate!==0?Dn(r.rotate):void 0,m=x=>i({rotate:x===void 0||x===0?void 0:Dn(x)}),b=dh(o,r),v=lh(o)||ll(n.elements).has(e.id),w=v?"":H(t,"ap-rotate",Ve("旋转 (°)",g("div",{class:"pd-rotate-row"},[g("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>m((h??0)-90)}),g("div",{class:"pd-rotate-stepper"},[Z({value:h,min:0,max:359,placeholder:"0",disabled:!b,onCommit:x=>m(x)})]),g("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>m((h??0)+90)})]),Oe("ap-rotate"),f("rotate","ap-rotate"))),_=v||b?"":g("p",{class:"pd-hint pd-rotate-note",text:ch});if(p.push(Le(t,"appearance","外观","Brush",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},a?[H(t,"ap-font-family",ie("字体",qo({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:x=>i({fontFamily:x})}),void 0,f("fontFamily","ap-font-family"))),H(t,"ap-font-size",Ce(t,"字体大小",r.fontSize,x=>i({fontSize:x}),{min:8,max:72},f("fontSize","ap-font-size"))),H(t,"ap-font-weight",At(t,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],x=>i({fontWeight:x}),void 0,f("fontWeight","ap-font-weight"))),H(t,"ap-align",ie("对齐",kt("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",x=>i({textAlign:x})),void 0,f("textAlign","ap-align"))),H(t,"ap-vertical-align",ie("垂直对齐",kt("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",x=>i({verticalAlign:x})),void 0,f("verticalAlign","ap-vertical-align"))),g("div",{class:"color-row"},[H(t,"ap-color",ie("颜色",Xe(r.color,x=>i({color:x}),"字体颜色"),void 0,f("color","ap-color"))),H(t,"ap-bg-color",ie("背景色",Xe(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","ap-bg-color")))]),H(t,"ap-line-height",Ce(t,"行高",r.lineHeight,x=>i({lineHeight:x||void 0}),{min:0,max:100},f("lineHeight","ap-line-height"))),H(t,"ap-letter-spacing",Ce(t,"字间距",r.letterSpacing,x=>i({letterSpacing:x||void 0}),{min:0,max:20,step:.5},f("letterSpacing","ap-letter-spacing"))),H(t,"ap-text-fit",At(t,"文字溢出",wr(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],x=>i({textFit:x}),void 0,f("textFit","ap-text-fit"))),r.textFit==="shrink"?H(t,"ap-shrink-min",ie("最小字号 (pt)",Z({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:x=>i({shrinkMinFontSize:x||void 0})}),void 0,f("shrinkMinFontSize","ap-shrink-min"))):"",o==="longText"?H(t,"ap-long-text-indent",Ve("首行缩进 (字符)",Z({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:x=>i({longTextIndent:x||void 0})}),Oe("ap-long-text-indent"),f("longTextIndent","ap-long-text-indent"))):"",H(t,"ap-word-wrap",En(t,"自动换行",r.wordWrap!==!1,x=>i({wordWrap:x?void 0:!1}),f("wordWrap","ap-word-wrap"))),H(t,"ap-keep-line-breaks",En(t,"保留换行符",r.keepLineBreaks===!0,x=>i({keepLineBreaks:x?!0:void 0}),f("keepLineBreaks","ap-keep-line-breaks"))),w,_]:[o==="image"?H(t,"ap-img-fit",At(t,"缩放模式",String(r.fit??"contain"),pa,x=>i({fit:x}),Oe("ap-img-fit"),f("fit","ap-img-fit"))):"",o==="image"&&r.fit==="cover"?H(t,"ap-img-object-position",Wp(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Yc(r.src),widthMm:Number(r.width)||0,heightMm:Number(r.height)||0,fit:r.fit,scale:r.fitScale,value:r.objectPosition===void 0?void 0:String(r.objectPosition),onCommit:x=>i({objectPosition:x}),onScaleCommit:x=>i({fitScale:x}),resetAnchor:f("objectPosition","ap-img-object-position"),resetScale:f("fitScale","ap-img-fit-scale")})):"",w,_,o==="flowList"?g("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const x=o==="barcode",j=String(r.barcodeType||"CODE128").toUpperCase(),te=r.printerDpi?String(r.printerDpi):"",fe=Ks(r.printerDpi,r.barWidth);p.push(Le(t,"code","条码设置","Postcard",[g("form",{class:"pd-form",onSubmit:G=>G.preventDefault()},[x?[H(t,"cd-type",At(t,"码制",j,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],G=>i({barcodeType:G==="CODE128"?void 0:G}))),H(t,"cd-dpi",At(t,"打印机分辨率",te,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],G=>i({printerDpi:Number(G)>0?Number(G):void 0}),void 0,f("printerDpi","cd-dpi"))),H(t,"cd-dpi",g("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),H(t,"cd-bar-width",Ce(t,"条宽(倍率)",r.barWidth??2,G=>i({barWidth:G}),{min:2,max:8,step:.5},f("barWidth","cd-bar-width"))),H(t,"cd-bar-width",g("p",{class:"pd-hint",text:(te?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(fe?`。${fe}`:"")})),H(t,"cd-bar-quiet-zone",Ve("静区 (模块)",Z({value:r.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:G=>i({barQuietZone:G})}),Oe("cd-bar-quiet-zone"),f("barQuietZone","cd-bar-quiet-zone"))),H(t,"cd-bar-height",Ve("条高 (mm)",Z({value:r.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:G=>i({barHeight:G??void 0})}),Oe("cd-bar-height"),f("barHeight","cd-bar-height"))),H(t,"cd-show-text",En(t,"显示文本",r.hideTitle!==!0,G=>i({hideTitle:G?void 0:!0}),f("hideTitle","cd-show-text"))),H(t,"cd-font-size",ie("文本字号(相对条高,条高为 30)",Z({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:G=>i({fontSize:G||void 0})}),void 0,f("fontSize","cd-font-size")))]:[H(t,"cd-ec-level",At(t,"纠错级别",String(r.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],G=>i({qrCodeLevel:G}),void 0,f("qrCodeLevel","cd-ec-level"))),H(t,"cd-quiet-zone",Ve("静区 (模块)",Z({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:G=>i({qrQuietZone:G})}),Oe("cd-quiet-zone"),f("qrQuietZone","cd-quiet-zone")))],st("自定义设置"),x?g("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",x?"":H(t,"cd-fit",At(t,"缩放模式",String(r.fit||"contain"),pa,G=>i({fit:G||void 0}),void 0,f("fit","cd-fit"))),H(t,"cd-max-width",ie("最大宽度 (mm)",Z({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxWidth:G||void 0})}),void 0,f("maxWidth","cd-max-width"))),H(t,"cd-max-height",ie("最大高度 (mm)",Z({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:G=>i({maxHeight:G||void 0})}),void 0,f("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(d||p.push(Ov(t,e)),s&&(p.push(Lv(t,e)),p.push(Bv(t,e))),c&&p.push(Fv(t,e)),o==="flowList"){const x=ut(r.flowColumns),j=On(r.flowRowHeight),te=wt(r.flowGapX),fe=Qt(r.flowMaxSpan,x),G=Zf(r.width??0,te,r.fontSize??12);p.push(Le(t,"flowList","流式列表","Grid3x3",[g("form",{class:"pd-form",onSubmit:de=>de.preventDefault()},[H(t,"fl-columns",Ve("每行列数",Z({value:x,min:1,max:12,onCommit:de=>i({flowColumns:ut(de),flowMaxSpan:Qt(r.flowMaxSpan,ut(de))})}),Oe("fl-columns"))),H(t,"fl-row-height",Ve("行高 (mm)",Z({value:j,min:3,max:100,step:.5,onCommit:de=>i({flowRowHeight:On(de)})}),Oe("fl-row-height"))),H(t,"fl-gap-x",Ve("单元横向间距 (mm)",Z({value:te,min:0,max:50,step:.5,onCommit:de=>i({flowGapX:wt(de)})}),Oe("fl-gap-x"))),H(t,"fl-auto-span",En(t,"内容过长时跨列",r.flowAutoSpan===!0,de=>{i(de?{flowAutoSpan:de,flowMaxSpan:fe}:{flowAutoSpan:de})})),r.flowAutoSpan===!0?H(t,"fl-max-span",Ve("最多跨几列",Z({value:fe,min:1,max:x,onCommit:de=>i({flowMaxSpan:Qt(de,x)})}),Oe("fl-max-span"))):"",x>G?g("p",{class:"pd-hint",text:`按当前字号与框宽,${x} 列偏挤(可放约 ${G} 列)。数值保持不变,出纸按 ${x} 列排。`}):""].flat().filter(Boolean))]))}const T=()=>({borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:r.borders}),z=x=>{const j=T();kl(j,x,Ol(j)),i(j)},N=x=>{const j=T();Ai(j,x,!Fn(j,x)),i(j)},P=Al(r),k=P.style==="mixed",S=typeof P.width=="number"?P.width:void 0,C=k||P.style===void 0?"":P.style,O=typeof P.color=="string"?P.color:void 0,R=(x,j)=>{const te=T();Kh(te,x,j),i(te)},I=k?[{value:"",label:"混合"},...ki]:[...ki];return p.push(Le(t,"border-bg","边框与背景","Picture",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[H(t,"bb-border-style",At(t,"线型",C,I,x=>R("borderStyle",x))),g("div",{class:"border-row"},[H(t,"bb-border-width",Ce(t,"边框宽度",S,x=>R("borderWidth",x),{min:0,max:20,step:.25,placeholder:P.width==="mixed"?"混合":void 0},f("borderWidth","bb-border-width"))),H(t,"bb-border-color",ie("边框颜色",Xe(O,x=>R("borderColor",x),"边框颜色"),void 0,f("borderColor","bb-border-color")))]),...fi(o)?[g("div",{class:"pd-button-group border-presets"},qv.map(x=>g("button",{type:"button",class:"pd-button small",text:x.label,disabled:x.value==="inner",onClick:()=>z(x.value)}))),g("div",{class:"pd-checkbox-group"},Wv.map(x=>g("label",{class:"pd-checkbox"},[g("input",{type:"checkbox",checked:Fn(r,x.value),onChange:()=>N(x.value)}),g("span",{text:x.label})]))),g("p",{class:"pd-hint",text:qh})]:[],H(t,"bb-bg-color",ie("背景色",Xe(r.backgroundColor,x=>i({backgroundColor:x}),"背景颜色"),void 0,f("backgroundColor","bb-bg-color")))])])),p.push(zv(t,e)),p.push(Le(t,"advanced","高级设置","Setting",[g("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[g("div",{class:"advanced-row"},[H(t,"ad-locked",En(t,"锁定",!!r.locked,x=>i({locked:x}),f("locked","ad-locked"))),H(t,"ad-fixed",En(t,"每页重复",!!r.fixed,x=>i({fixed:x}),f("fixed","ad-fixed")))]),H(t,"ad-z-index",Ce(t,"层级",r.zIndex,x=>i({zIndex:x}),{min:0,max:999},f("zIndex","ad-z-index"))),H(t,"ad-delete",g("div",{class:"pd-field"},[g("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>n.deleteSelected()})]))])],!1)),g("div",{class:"property-content"},p)}function Gv(t){const e=t.store,n=e.templateData,r=c=>e.updateTemplateData(c),o=c=>{const s=n.tiling,d=p=>p===90||p===270;if(s?.enabled&&d(c)!==d(n.outputRotation)){const p=zc({...n,outputRotation:c});r({outputRotation:c,tiling:{...s,columns:Math.max(p,1)}});return}r({outputRotation:c})},i=[];for(const[c,s]of Object.entries(nt)){const d=s.group??"其他";let p=i.find(u=>u.group===d);p||(p={group:d,items:[]},i.push(p)),p.items.push({key:c,label:s.label??c})}const a=!nt[n.paperSize],l=wi(n.paperSize);return g("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[st("纸张设置"),ie("纸张尺寸",g("select",{class:"pd-select",style:{width:"100%"},onChange:c=>r({paperSize:c.target.value})},[...i.map(c=>g("optgroup",{label:c.group},c.items.map(s=>g("option",{value:s.key,text:s.label,selected:n.paperSize===s.key})))),g("option",{value:"CUSTOM",text:"自定义宽高",selected:a})])),l||a?ie(l?"纸宽 (mm)":"自定义宽高 (mm)",g("div",{class:"custom-size-grid"},[Z({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:c=>r({customWidth:c})}),...a?[g("span",{class:"custom-size-x",text:"×"}),Z({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:c=>r({customHeight:c})})]:[]])):"",l?"":ie("纸张方向",kt("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",c=>r({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":ie("内容旋转角度",kt("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),c=>o(Number(c)),!0),n.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),ie("页面背景色",g("div",{class:"page-bg-row"},[Xe(n.pageBackground,c=>r({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,Xt({target:n,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>r({pageBackground:void 0})})),bv(t),e.pages.length>1?"":yv(t),st("页边距 (mm)"),g("div",{class:"margin-grid"},[Ce(t,"上",n.margins.top,c=>r({margins:{...n.margins,top:c}}),{min:0,max:50}),Ce(t,"下",n.margins.bottom,c=>r({margins:{...n.margins,bottom:c}}),{min:0,max:100}),Ce(t,"左",n.margins.left,c=>r({margins:{...n.margins,left:c}}),{min:0,max:50}),Ce(t,"右",n.margins.right,c=>r({margins:{...n.margins,right:c}}),{min:0,max:50})]),st("页眉/页脚高度 (mm)"),Ce(t,"页眉高度",n.header.height??10,c=>r({header:{...n.header,height:c}}),{min:0,max:100,step:.1}),Ce(t,"页脚高度",n.footer.height??10,c=>r({footer:{...n.footer,height:c}}),{min:0,max:100,step:.1}),Uv(t)].filter(Boolean))}function Yv(t){const e=t.store,n=t.state,r=e.selectedElement;if(n.propCollapsed)return g("div",{class:"property-panel collapsed"},[g("div",{class:"prop-collapsed"},[g("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{n.propCollapsed=!1,t.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([i,a,l])=>g("button",{type:"button",class:`pc-btn${n.propTab===i?" on":""}`,title:a,text:l,onClick:()=>{n.propTab=i,n.propCollapsed=!1,t.repaint()}}))])]);const o=r?n.propTab:"page";return g("div",{class:"property-panel"},[g("div",{class:"prop-head"},[g("span",{class:"prop-title",text:"属性台"}),g("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{n.propCollapsed=!0,t.repaint()}})]),g("div",{class:"pd-tabs prop-tabs"},[g("div",{class:"pd-tab-bar",role:"tablist"},[g("button",{type:"button",class:`pd-tab${o==="element"?" active":""}`,text:"元素属性",onClick:()=>{n.propTab="element",t.repaint()}}),g("button",{type:"button",class:`pd-tab${o==="page"?" active":""}`,text:"页面属性",onClick:()=>{n.propTab="page",t.repaint()}})]),g("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="element"?"":{display:"none"}},r?[_v(t),jv(t,r)]:[g("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),g("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="page"?"":{display:"none"}},[Gv(t)])])])}const xs=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Yp={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},Vv=[{name:"SUM",label:"求和",template:"SUM()"},{name:"AVG",label:"平均值",template:"AVG()"},{name:"COUNT",label:"计数",template:"COUNT()"},{name:"MIN",label:"最小值",template:"MIN()"},{name:"MAX",label:"最大值",template:"MAX()"}],Xv=[{name:"ADD",label:"相加",template:"ADD()"},{name:"SUB",label:"相减",template:"SUB()"},{name:"MUL",label:"相乘",template:"MUL()"},{name:"DIV",label:"相除",template:"DIV()"},{name:"ROUND",label:"四舍五入",template:"ROUND()"},{name:"ROUNDUP",label:"进一法",template:"ROUNDUP()"},{name:"ROUNDDOWN",label:"去尾法",template:"ROUNDDOWN()"},{name:"ROUNDBANK",label:"四舍六入五成双",template:"ROUNDBANK()"}],Kv=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],Zv=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],Jv=[{title:"聚合函数",items:Vv},{title:"数值运算",items:Xv},{title:"格式化函数",items:Kv}],Qv="(输入表达式后预览)",ew="(无法计算)",Es="(表达式错误)";function Vp(t,e){if(!t.trim())return Qv;try{const n={...it,...e??{},...$r()},r=dn(t,n);return r==null?ew:String(r)}catch{return Es}}function Xp(t,e){const n=e.trim().toLowerCase();return n?t.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):t}function tw(t,e){const n=t.substring(0,e),r=n.lastIndexOf("{"),o=r!==-1&&!n.slice(r+1).includes("}"),i=n.lastIndexOf("("),a=i!==-1&&!n.slice(i+1).includes(")");return{insideBlock:o,insideParens:a}}function nw(t,e){const n=/^\{\s*([^{}]+?)\s*\}$/.exec(t.trim());if(!n)return null;const r=n[1]??"";return e.find(o=>o.fieldKey===r)??null}function Ss(t,e){return g("div",{class:"ee-field-info"},[g("span",{class:"ee-item-label",text:t}),g("span",{class:"ee-item-key",text:e})])}function Zt(t){return t.currentTarget.getRootNode()}function Go(t,e,n){const r=[];return n.forEach((o,i)=>{r.push(o),i<n.length-1&&r.push(g("br"))}),g("div",{class:`ee-help-card ${t}`},[g("div",{class:"ee-help-card-title",text:e}),g("div",{class:"ee-help-card-content"},r)])}function rw(){return g("div",{class:"ee-help-section"},[g("div",{class:"ee-help-title",text:"帮助信息"}),g("div",{class:"ee-help-grid"},[Go("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Go("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Go("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Go("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function ow(t,e){const n={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},r=(h,m)=>h.querySelector(m),o=h=>{const m=r(h,".ee-preview");if(!m)return;const b=Vp(n.expression,t.demoData);m.textContent=b,m.classList.toggle("ee-preview-error",b===Es)},i=()=>{if(n.activeTab==="variable")return Xp(Zv,n.searchText).map(b=>g("div",{class:"ee-list-item",onDblclick:v=>{const{insideParens:w}=l(v);c(Zt(v),w?b.template.replace(/^\{|\}$/g,""):b.template)}},[Ss(b.label,b.template)]));if(n.activeTab==="function")return Jv.map(b=>g("div",{class:"ee-func-group"},[g("div",{class:"ee-func-group-title",text:b.title}),...Xp(b.items,n.searchText).map(v=>g("div",{class:"ee-list-item",onDblclick:w=>{const{insideBlock:_}=l(w),T=_?v.template:`{${v.template}}`;c(Zt(w),T,T.indexOf("(")+1)}},[Ss(v.label,`${v.name}()`)]))]));const h=h0(Kc(t.fields??[]),n.searchText);if(!h.length)return[g("p",{class:"pd-empty",text:"暂无字段"})];const m=[];for(const b of h){b.key&&m.push(g("div",{class:`ee-field-group${b.isList?" is-list":""}`},[g("span",{class:"ee-field-group-icon",text:b.isList?"📋":"📁"}),g("span",{text:b.label})]));for(const v of b.fields)m.push(g("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:b.key?"22px":"10px"},onDblclick:w=>{const{insideParens:_}=l(w);c(Zt(w),_?v.fieldKey:`{${v.fieldKey}}`)}},[Ss(v.fieldLabel,v.fieldKey)]))}return m},a=h=>{Array.from(h.querySelectorAll(".ee-nav-tab")).forEach((_,T)=>_.classList.toggle("active",xs[T]?.key===n.activeTab));const b=r(h,".ee-content-search .pd-input");if(b){const _=Yp[n.activeTab];b.placeholder!==_&&(b.placeholder=_),b.value!==n.searchText&&(b.value=n.searchText)}const v=r(h,".ee-textarea");v&&v.value!==n.expression&&(v.value=n.expression);const w=r(h,".ee-content-list");if(w){Yu(w);for(const _ of i())Re(_,w)}o(h)},l=h=>{const b=r(Zt(h),".ee-textarea")?.selectionStart??n.expression.length;return tw(n.expression,b)},c=(h,m,b=m.length)=>{const v=r(h,".ee-textarea");if(!v){n.expression+=m,o(h);return}const w=v.selectionStart??n.expression.length,_=v.selectionEnd??w;n.expression=n.expression.substring(0,w)+m+n.expression.substring(_);const T=w+b;v.value=n.expression,v.focus(),v.selectionStart=v.selectionEnd=T,o(h)},s=()=>{const h=n.expression;if(n.binding===void 0){t.onApply({formatter:h}),t.onClose();return}const m=nw(h,t.fields??[]);t.onApply(m?{formatter:h,binding:m.fieldKey,title:m.fieldLabel}:{formatter:h}),t.onClose()},d=g("div",{class:"ee-nav"},[g("div",{class:"ee-nav-title",text:"类型"}),g("div",{class:"ee-nav-tabs"},xs.map((h,m)=>g("div",{class:`ee-nav-tab${n.activeTab===h.key?" active":""}`,text:h.text,onClick:b=>{n.activeTab=xs[m].key,a(Zt(b))}})))]),p=g("div",{class:"ee-content"},[g("div",{class:"ee-content-search"},[g("input",{class:"pd-input",placeholder:Yp[n.activeTab],onInput:h=>{n.searchText=h.target.value,a(Zt(h))}})]),g("div",{class:"ee-content-list"},i())]),u=Vp(n.expression,t.demoData),f=g("div",{class:"ee-editor"},[g("div",{class:"ee-editor-section"},[g("div",{class:"ee-editor-title",text:"表达式编辑"}),g("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:n.expression,onInput:h=>{n.expression=h.target.value,o(Zt(h))}})]),g("div",{class:"ee-editor-section"},[g("div",{class:"ee-editor-title",text:"预览结果"}),g("div",{class:`ee-preview${u===Es?" ee-preview-error":""}`,text:u})]),rw()]);return g("div",{class:"pd-dialog-overlay",onKeydown:h=>{h.key==="Escape"&&t.onClose()}},[g("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[g("header",{class:"pd-dialog-header"},[g("strong",{id:"expression-editor-title",text:"编辑表达式"}),g("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>t.onClose()})]),g("div",{class:"expression-editor"},[d,p,f]),g("footer",{class:"pd-dialog-footer"},[g("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>t.onClose()}),g("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>s()})])])])}const Yo=[{id:"getting-started",title:"快速入门",content:`
261
261
  <h2>界面布局</h2>
262
262
  <p>打印模板设计器采用三栏布局:</p>
263
263
  <ul>
@@ -673,6 +673,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
673
673
  <p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
674
674
  </blockquote>
675
675
  `},{id:"changelog",title:"更新记录",content:`
676
+ <h2>V1.4.1<small>(2026-10-28)</small></h2>
677
+
678
+ <h3>修复</h3>
679
+ <ul>
680
+ <li><strong>条码 / 二维码设计态不再被示例码值遮住</strong>:新增条码/二维码时自带的示例码值此前排在「内容」之前,作者填了 {字段} 内容后画布仍然一直显示示例码。现在先按内容里的 {字段} 用示例数据求值(与表格单元格同口径),取不到值才显示预制示例码。只影响设计器里的展示,出纸不变。</li>
681
+ </ul>
682
+
676
683
  <h2>V1.4.0<small>(2026-10-28)</small></h2>
677
684
 
678
685
  <h3>新增</h3>
@@ -1012,6 +1019,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1012
1019
  <blockquote>
1013
1020
  <p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
1014
1021
  </blockquote>
1015
- `}],Xp="worm-print-help-tab",iw="getting-started";function Kp(t){return Yo.some(e=>e.id===t)?String(t):""}function aw(t){let e=null;try{e=window.localStorage.getItem(Xp)}catch{e=null}return Kp(e)||Kp(t)||iw}function sw(t){const e=aw(t.initialTab),n=(r,o)=>{const i=r.currentTarget,a=i.closest(".help-modal");if(!a)return;for(const c of Array.from(a.querySelectorAll(".help-tab")))c.classList.toggle("active",c===i);const l=a.querySelector(".help-content");l&&(l.innerHTML=Yo.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(Xp,o)}catch{}};return g("div",{class:"help-modal-overlay",tabindex:"-1",onClick:r=>{r.target===r.currentTarget&&t.onClose()},onKeydown:r=>{r.key==="Escape"&&t.onClose()}},[g("div",{class:"help-modal"},[g("div",{class:"help-modal-header"},[g("div",{class:"help-modal-title-wrap"},[g("h2",{class:"help-modal-title",text:"帮助文档"}),g("span",{class:"help-modal-project",text:"worm-vue3-print"})]),g("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>t.onClose()})]),g("div",{class:"help-modal-body"},[g("div",{class:"help-modal-sidebar"},Yo.map(r=>g("button",{type:"button",class:`help-tab${r.id===e?" active":""}`,text:r.title,onClick:o=>n(o,r.id)}))),g("div",{class:"help-modal-content"},[g("div",{class:"help-content",html:Yo.find(r=>r.id===e)?.content??""})])])])])}function lw(t,e){const n=Re(sw(e),t),r=o=>{o.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const cw=2,dw=74,Ss=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function uw(t){const e=!!t.state.openMore,n=Ss.slice().sort((r,o)=>r.order-o.order).map(r=>g("div",{class:"tb-more-item",dataset:{unit:r.id},style:{display:"none"}},[g("div",{class:"tb-menu-label",text:r.label}),g("div",{class:"tb-more-slot",id:`tb-more-slot-${r.id}`,dataset:{unit:r.id}})]));return g("div",{class:"tb-group tb-more-group",style:{display:"none"}},[g("div",{class:"tb-dd"},[g("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{t.state.openMore=!e,t.repaint()},html:`${Ne("Ellipsis",15)}<span class="tb-btn-text">更多</span>${Ne("ChevronDown",12,"tb-dd-arrow")}`}),g("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[g("div",{class:"tb-menu tb-more-menu"},n)])])])}const Zp=new WeakMap;function Jp(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(e),r=Number.parseFloat(n.gap)||cw,o=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=new Map;for(const m of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const b=m.parentElement;b&&!b.classList.contains("tb-more-slot")&&Zp.set(m,{parent:b,next:m.nextSibling}),a.set(m.dataset.unit,m)}for(const m of a.values()){const b=Zp.get(m);!b||m.parentElement===b.parent||(b.next?.parentElement===b.parent?b.parent.insertBefore(m,b.next):b.parent.appendChild(m))}let l=0;for(const m of Array.from(e.children)){if(m.classList.contains("tb-spacer")||m.classList.contains("tb-more-group"))continue;const b=Math.max(m.offsetWidth,m.scrollWidth);b<=0||(l+=b+r)}const c=new Map;for(const[m,b]of a){const v=b.offsetWidth;v>0&&c.set(m,v)}const s=Ss.map(m=>({id:m.id,order:m.order,width:c.get(m.id)??0})),d=s.reduce((m,b)=>m-b.width-r,l),p=e.clientWidth-o-i,{movedIds:u,overflowRemains:f}=hl({available:p,pinned:d,moreTriggerWidth:dw,gap:r,units:s});for(const m of Ss){const b=e.querySelector(`.tb-more-item[data-unit="${m.id}"]`),v=e.querySelector(`#tb-more-slot-${m.id}`),w=a.get(m.id);if(!b||!v||!w)continue;const _=u.includes(m.id);_&&w.parentElement!==v&&v.appendChild(w),b.style.display=_?"":"none"}const h=e.querySelector(".tb-more-group");return h&&(h.style.display=u.length>0?"":"none"),e.classList.toggle("is-tight",f),{movedIds:u,overflowRemains:f}}function pw(t,e){const n=t.store,r=n.selectedIds.size>0,o=n.selectedIds.size>1,i=n.selectedElement,a=!r,l=t.isEdit?"编辑模板":"新建模板",c=[g("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[g("div",{class:"tb-menu-label",text:"对齐 / 分布"}),g("div",{class:"tb-menu-grid"},[be(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),be(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),be(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),be(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),be(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),be(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),be(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),be(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),g("div",{class:"tb-menu-label",text:"层级"}),g("div",{class:"tb-menu-grid"},[be(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),be(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),be(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),be(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),g("div",{class:"tb-menu-label",text:"组合"}),g("div",{class:"tb-menu-grid"},[be(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),be(t,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!i?.options?.groupId})])])],s=[g("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[d("标尺",n.showRuler,"toggle-ruler","显示/隐藏标尺"),d("网格",n.showGrid,"toggle-grid","显示/隐藏网格背景"),d("虚框",n.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),d("吸附",n.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function d(p,u,f,h){return g("button",{type:"button",class:`tb-btn tb-menu-row${u?" on":""}`,dataset:{tip:h},onClick:()=>t.fire(f)},[g("span",{class:"dot"}),p])}return g("div",{class:"designer-toolbar"},[g("div",{class:"tb-group tb-brand"},[g("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),g("div",{class:"tb-title"},[g("span",{class:"tb-title-name",text:l}),g("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),g("div",{class:"tb-group"},[be(t,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),be(t,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),e,g("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[Uo(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),Uo(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),g("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[be(t,"Maximize","fit-window",{tip:"适应窗口"}),be(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),g("span",{class:"tb-zoom",text:`${n.scale}%`}),be(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),g("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[be(t,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),be(t,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),be(t,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),uw(t),g("div",{class:"tb-spacer"}),t.showHelp?g("div",{class:"tb-group"},[g("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>t.fire("help")},[g("span",{class:"help-icon",text:"?"})])]):"",g("div",{class:"tb-group"},[g("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>t.fire("preview")}),g("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>t.fire("save")})])].filter(Boolean))}function _s(t,e,n){for(const r of e){const o=t.getPropertyValue(r).trim();if(o)return o}return n}function fw(t,e){const n=e.orientation==="horizontal",r=e.geom,o=n?r.viewW:r.viewH;t.style.width=`${n?o:Di}px`,t.style.height=`${n?Di:o}px`;const i=t.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=Di;t.width=(n?l:c)*a,t.height=(n?c:l)*a,i.setTransform(a,0,0,a,0,0);const s=getComputedStyle(t),d=_s(s,["--pd-ruler-bg"],"#F8F9FC"),p=_s(s,["--pd-ruler"],"#9AA1AF"),u=_s(s,["--pd-ruler-cursor","--pd-accent"],"#165DFF");i.fillStyle=d,i.fillRect(0,0,n?l:c,n?c:l);const f=e.scale>0?e.scale:r.paperScale>0?r.paperScale:1,h=$t(1)*f;if(h<=0)return;const m={ctx:i,horizontal:n,viewportPx:o,thickness:c,originPx:n?r.originX:r.originY,pxPerMM:h,paperLengthMM:e.paperLengthMM},b=-m.originPx/h,v=(l-m.originPx)/h,w=lg(f),_=ug(b,v,w);ef(m,_,p,!0),ef(m,_,p,!1),tf(m,0,u),tf(m,e.paperLengthMM,u);const T=e.cursorPx??null;if(T!==null&&T>=0&&T<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const z=Math.round(T)+.5;i.moveTo(z,0),i.lineTo(z,c)}else{const z=Math.round(T)+.5;i.moveTo(0,z),i.lineTo(c,z)}i.stroke()}}function Qp(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function ef(t,e,n,r){const{ctx:o,horizontal:i,paperLengthMM:a}=t;o.strokeStyle=n,o.fillStyle=n,o.globalAlpha=r?.32:1,o.lineWidth=1,o.font="9px ui-monospace, Menlo, monospace",o.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>a)!==r)continue;const s=Qp(t,l.mm),d=l.major?8:4;o.beginPath(),i?(o.moveTo(s,0),o.lineTo(s,d)):(o.moveTo(0,s),o.lineTo(d,s)),o.stroke(),l.major&&l.label&&(i?o.fillText(l.label,s+2,11):(o.save(),o.translate(11,s+2),o.rotate(-Math.PI/2),o.fillText(l.label,0,0),o.restore()))}o.globalAlpha=1}function tf(t,e,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=t,l=Qp(t,e);l<=0||l>=a||(r.strokeStyle=n,r.globalAlpha=.55,r.lineWidth=1,r.beginPath(),o?(r.moveTo(l,0),r.lineTo(l,i)):(r.moveTo(0,l),r.lineTo(i,l)),r.stroke(),r.globalAlpha=1)}const hw=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Vo=20,gw=".page-tabs, .field-tree-panel",mw=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),bw={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},nf="print-studio:left",rf="print-studio:right";function of(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function af(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}class mt extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=hw,this.root.appendChild(e),Re(g("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(e){this.applyTemplate(e)}get template(){return this.store?.getTemplateJson()}set fields(e){this.store.fields=(typeof e=="string"?JSON.parse(e):e)??[],this.repaint()}set isEdit(e){this.setAttribute("is-edit",String(e)),this.repaint()}set showHelp(e){this.setAttribute("show-help",String(e)),e||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(e,n,r){if(!r)return;if(e==="name"){this.repaint();return}let o;try{o=JSON.parse(r)}catch{return}e==="template"?this.applyTemplate(o):e==="fields"?(this.store.fields=o,this.repaint()):e==="fonts"&&Array.isArray(o)&&(this.fonts=o)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},n=this.getAttribute("template");if(n)try{e.initialTemplate=JSON.parse(n)}catch{}const r=this.getAttribute("fields");if(r)try{e.initialFields=JSON.parse(r)}catch{}this.store=new Xu(e),this.format=new t1(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=of(nf),this.state.propCollapsed=of(rf),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const e=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;e!==this.chromeKey&&(this.chromeKey=e,af(nf,this.state.leftCollapsed),af(rf,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,mt.active===this&&(mt.active=null),kp(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=Un(this._fonts);if(!e){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=e,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=e}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),n=this.fonts;if(!n?.length)return e;if(Array.isArray(e.pages)){const r=e;return{...r,pages:r.pages.map(o=>({...o,fonts:[...n]}))}}return{...e,fonts:[...n]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const n=this.getGeometryWarnings();n.length&&window.alert(`出纸提示(不影响保存):
1022
+ `}],Kp="worm-print-help-tab",iw="getting-started";function Zp(t){return Yo.some(e=>e.id===t)?String(t):""}function aw(t){let e=null;try{e=window.localStorage.getItem(Kp)}catch{e=null}return Zp(e)||Zp(t)||iw}function sw(t){const e=aw(t.initialTab),n=(r,o)=>{const i=r.currentTarget,a=i.closest(".help-modal");if(!a)return;for(const c of Array.from(a.querySelectorAll(".help-tab")))c.classList.toggle("active",c===i);const l=a.querySelector(".help-content");l&&(l.innerHTML=Yo.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(Kp,o)}catch{}};return g("div",{class:"help-modal-overlay",tabindex:"-1",onClick:r=>{r.target===r.currentTarget&&t.onClose()},onKeydown:r=>{r.key==="Escape"&&t.onClose()}},[g("div",{class:"help-modal"},[g("div",{class:"help-modal-header"},[g("div",{class:"help-modal-title-wrap"},[g("h2",{class:"help-modal-title",text:"帮助文档"}),g("span",{class:"help-modal-project",text:"worm-vue3-print"})]),g("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>t.onClose()})]),g("div",{class:"help-modal-body"},[g("div",{class:"help-modal-sidebar"},Yo.map(r=>g("button",{type:"button",class:`help-tab${r.id===e?" active":""}`,text:r.title,onClick:o=>n(o,r.id)}))),g("div",{class:"help-modal-content"},[g("div",{class:"help-content",html:Yo.find(r=>r.id===e)?.content??""})])])])])}function lw(t,e){const n=Re(sw(e),t),r=o=>{o.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const cw=2,dw=74,_s=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function uw(t){const e=!!t.state.openMore,n=_s.slice().sort((r,o)=>r.order-o.order).map(r=>g("div",{class:"tb-more-item",dataset:{unit:r.id},style:{display:"none"}},[g("div",{class:"tb-menu-label",text:r.label}),g("div",{class:"tb-more-slot",id:`tb-more-slot-${r.id}`,dataset:{unit:r.id}})]));return g("div",{class:"tb-group tb-more-group",style:{display:"none"}},[g("div",{class:"tb-dd"},[g("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{t.state.openMore=!e,t.repaint()},html:`${Ne("Ellipsis",15)}<span class="tb-btn-text">更多</span>${Ne("ChevronDown",12,"tb-dd-arrow")}`}),g("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[g("div",{class:"tb-menu tb-more-menu"},n)])])])}const Jp=new WeakMap;function Qp(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(e),r=Number.parseFloat(n.gap)||cw,o=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=new Map;for(const m of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const b=m.parentElement;b&&!b.classList.contains("tb-more-slot")&&Jp.set(m,{parent:b,next:m.nextSibling}),a.set(m.dataset.unit,m)}for(const m of a.values()){const b=Jp.get(m);!b||m.parentElement===b.parent||(b.next?.parentElement===b.parent?b.parent.insertBefore(m,b.next):b.parent.appendChild(m))}let l=0;for(const m of Array.from(e.children)){if(m.classList.contains("tb-spacer")||m.classList.contains("tb-more-group"))continue;const b=Math.max(m.offsetWidth,m.scrollWidth);b<=0||(l+=b+r)}const c=new Map;for(const[m,b]of a){const v=b.offsetWidth;v>0&&c.set(m,v)}const s=_s.map(m=>({id:m.id,order:m.order,width:c.get(m.id)??0})),d=s.reduce((m,b)=>m-b.width-r,l),p=e.clientWidth-o-i,{movedIds:u,overflowRemains:f}=gl({available:p,pinned:d,moreTriggerWidth:dw,gap:r,units:s});for(const m of _s){const b=e.querySelector(`.tb-more-item[data-unit="${m.id}"]`),v=e.querySelector(`#tb-more-slot-${m.id}`),w=a.get(m.id);if(!b||!v||!w)continue;const _=u.includes(m.id);_&&w.parentElement!==v&&v.appendChild(w),b.style.display=_?"":"none"}const h=e.querySelector(".tb-more-group");return h&&(h.style.display=u.length>0?"":"none"),e.classList.toggle("is-tight",f),{movedIds:u,overflowRemains:f}}function pw(t,e){const n=t.store,r=n.selectedIds.size>0,o=n.selectedIds.size>1,i=n.selectedElement,a=!r,l=t.isEdit?"编辑模板":"新建模板",c=[g("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[g("div",{class:"tb-menu-label",text:"对齐 / 分布"}),g("div",{class:"tb-menu-grid"},[be(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),be(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),be(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),be(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),be(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),be(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),be(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),be(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),g("div",{class:"tb-menu-label",text:"层级"}),g("div",{class:"tb-menu-grid"},[be(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),be(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),be(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),be(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),g("div",{class:"tb-menu-label",text:"组合"}),g("div",{class:"tb-menu-grid"},[be(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),be(t,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!i?.options?.groupId})])])],s=[g("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[d("标尺",n.showRuler,"toggle-ruler","显示/隐藏标尺"),d("网格",n.showGrid,"toggle-grid","显示/隐藏网格背景"),d("虚框",n.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),d("吸附",n.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function d(p,u,f,h){return g("button",{type:"button",class:`tb-btn tb-menu-row${u?" on":""}`,dataset:{tip:h},onClick:()=>t.fire(f)},[g("span",{class:"dot"}),p])}return g("div",{class:"designer-toolbar"},[g("div",{class:"tb-group tb-brand"},[g("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),g("div",{class:"tb-title"},[g("span",{class:"tb-title-name",text:l}),g("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),g("div",{class:"tb-group"},[be(t,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),be(t,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),e,g("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[Uo(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),Uo(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),g("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[be(t,"Maximize","fit-window",{tip:"适应窗口"}),be(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),g("span",{class:"tb-zoom",text:`${n.scale}%`}),be(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),g("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[be(t,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),be(t,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),be(t,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),uw(t),g("div",{class:"tb-spacer"}),t.showHelp?g("div",{class:"tb-group"},[g("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>t.fire("help")},[g("span",{class:"help-icon",text:"?"})])]):"",g("div",{class:"tb-group"},[g("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>t.fire("preview")}),g("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>t.fire("save")})])].filter(Boolean))}function Ms(t,e,n){for(const r of e){const o=t.getPropertyValue(r).trim();if(o)return o}return n}function fw(t,e){const n=e.orientation==="horizontal",r=e.geom,o=n?r.viewW:r.viewH;t.style.width=`${n?o:Di}px`,t.style.height=`${n?Di:o}px`;const i=t.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=Di;t.width=(n?l:c)*a,t.height=(n?c:l)*a,i.setTransform(a,0,0,a,0,0);const s=getComputedStyle(t),d=Ms(s,["--pd-ruler-bg"],"#F8F9FC"),p=Ms(s,["--pd-ruler"],"#9AA1AF"),u=Ms(s,["--pd-ruler-cursor","--pd-accent"],"#165DFF");i.fillStyle=d,i.fillRect(0,0,n?l:c,n?c:l);const f=e.scale>0?e.scale:r.paperScale>0?r.paperScale:1,h=$t(1)*f;if(h<=0)return;const m={ctx:i,horizontal:n,viewportPx:o,thickness:c,originPx:n?r.originX:r.originY,pxPerMM:h,paperLengthMM:e.paperLengthMM},b=-m.originPx/h,v=(l-m.originPx)/h,w=cg(f),_=pg(b,v,w);tf(m,_,p,!0),tf(m,_,p,!1),nf(m,0,u),nf(m,e.paperLengthMM,u);const T=e.cursorPx??null;if(T!==null&&T>=0&&T<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const z=Math.round(T)+.5;i.moveTo(z,0),i.lineTo(z,c)}else{const z=Math.round(T)+.5;i.moveTo(0,z),i.lineTo(c,z)}i.stroke()}}function ef(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function tf(t,e,n,r){const{ctx:o,horizontal:i,paperLengthMM:a}=t;o.strokeStyle=n,o.fillStyle=n,o.globalAlpha=r?.32:1,o.lineWidth=1,o.font="9px ui-monospace, Menlo, monospace",o.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>a)!==r)continue;const s=ef(t,l.mm),d=l.major?8:4;o.beginPath(),i?(o.moveTo(s,0),o.lineTo(s,d)):(o.moveTo(0,s),o.lineTo(d,s)),o.stroke(),l.major&&l.label&&(i?o.fillText(l.label,s+2,11):(o.save(),o.translate(11,s+2),o.rotate(-Math.PI/2),o.fillText(l.label,0,0),o.restore()))}o.globalAlpha=1}function nf(t,e,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=t,l=ef(t,e);l<=0||l>=a||(r.strokeStyle=n,r.globalAlpha=.55,r.lineWidth=1,r.beginPath(),o?(r.moveTo(l,0),r.lineTo(l,i)):(r.moveTo(0,l),r.lineTo(i,l)),r.stroke(),r.globalAlpha=1)}const hw=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Vo=20,gw=".page-tabs, .field-tree-panel",mw=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),bw={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},rf="print-studio:left",of="print-studio:right";function af(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function sf(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}class mt extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=hw,this.root.appendChild(e),Re(g("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(e){this.applyTemplate(e)}get template(){return this.store?.getTemplateJson()}set fields(e){this.store.fields=(typeof e=="string"?JSON.parse(e):e)??[],this.repaint()}set isEdit(e){this.setAttribute("is-edit",String(e)),this.repaint()}set showHelp(e){this.setAttribute("show-help",String(e)),e||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(e,n,r){if(!r)return;if(e==="name"){this.repaint();return}let o;try{o=JSON.parse(r)}catch{return}e==="template"?this.applyTemplate(o):e==="fields"?(this.store.fields=o,this.repaint()):e==="fonts"&&Array.isArray(o)&&(this.fonts=o)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},n=this.getAttribute("template");if(n)try{e.initialTemplate=JSON.parse(n)}catch{}const r=this.getAttribute("fields");if(r)try{e.initialFields=JSON.parse(r)}catch{}this.store=new Ku(e),this.format=new t1(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=af(rf),this.state.propCollapsed=af(of),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const e=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;e!==this.chromeKey&&(this.chromeKey=e,sf(rf,this.state.leftCollapsed),sf(of,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,mt.active===this&&(mt.active=null),Cp(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=Un(this._fonts);if(!e){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=e,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=e}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),n=this.fonts;if(!n?.length)return e;if(Array.isArray(e.pages)){const r=e;return{...r,pages:r.pages.map(o=>({...o,fonts:[...n]}))}}return{...e,fonts:[...n]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const n=this.getGeometryWarnings();n.length&&window.alert(`出纸提示(不影响保存):
1016
1023
  ${n.join(`
1017
- `)}`);const r=this.templateJsonWithFonts();if(Array.isArray(r.pages))try{ua(r)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const o=JSON.stringify(r);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:o,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?ca(e):[]}getGeometryWarnings(){return qm(this.store.templateData)}applyTemplate(e){if(!e)return;const n=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(n):this.setAttribute("template",JSON.stringify(n))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(r=>r.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(r=>r.remove());const n=this.exprTarget;Re(ow({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:r=>this.applyExpression(n,r)},n),this.root),this.exprMountedFor=n}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const e=this.helpVisible&&this.getAttribute("show-help")!=="false";if(e&&!this.unmountHelp)this.unmountHelp=lw(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const n=this.unmountHelp;this.unmountHelp=null,n()}}applyExpression(e,n){const r=n.formatter??"",o=e.targetPath;if(o.startsWith("options.")){if(o.includes("[")){const a=this.store.elements.find(l=>l.id===e.elementId);a&&gs(this.store,a,o,r);return}const i={[o.slice(8)]:r||void 0};n.title!==void 0&&(i.title=n.title),this.store.updateElement(e.elementId,i);return}if(o==="watermark.content"){const i={...this.store.templateData.watermark};vs(r)?Object.assign(i,{mode:"binding",binding:r,content:""}):Object.assign(i,{mode:"fixed",content:r,binding:""}),this.store.updateTemplateData({watermark:i})}}dblEditElement(e){const n=this.store.elements.find(o=>o.id===e);if(!n||(this.store.selectOne(e),this.state.propTab="element",n.options.locked))return;const r=bw[n.printElementType.type];r&&this.openExpression({elementId:n.id,targetPath:`options.${r}`,value:String(n.options[r]??"")})}dblEditCell(e){const n=this.store.elements.find(l=>l.id===e.elementId);if(!n||(this.store.selectOne(n.id),this.state.propTab="element",n.options.locked))return;const r=n.options.tableRows??[],o=Si(r,e.r,e.c),a=r[o.r]?.cells[o.c];a&&this.openExpression({elementId:n.id,targetPath:`options.tableRows[${o.r}].cells[${o.c}].formatter`,value:a.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(e,n)=>this.fire(e,n),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const e=[...this.store.selectedIds].join(",");e!==this.lastSelKey&&(this.lastSelKey=e,this.state.propTab=e?"element":"page");const n=this.root.querySelector(".designer-container");n.classList.toggle("format-painting",this.format.painterActive),Gu(n);const r=this.ctx;Re(pw(r,av(r)),n),Re(fv(r),n),Re(g("div",{class:"designer-body"},[cv(r),Hy(r,this.canvasUi()),Yv(r)]),n),Re(hv(r),n),Jp(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>Jp(n)),this.toolbarRo.observe(n));const o=by(this.store,(i,a)=>this.fire(i,a),this.tableMenu);o&&Re(o,n),W1(this.root,this.store.elements),Bp(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Wu(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const n=e.getAttribute("data-fit-base");n?e.style.fontSize=`${n}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),n=this.root.querySelector(".hiprint-printPaper");if(!e||!n)return;const r=e.getBoundingClientRect(),o=n.getBoundingClientRect(),i=(this.store.scale||100)/100,a=o.width/$t(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-Vo+this.scrollPos.x,originY:o.top-r.top-Vo+this.scrollPos.y,viewW:e.clientWidth-Vo,viewH:e.clientHeight-Vo},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,n=Et(e),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";fw(o,{orientation:i,geom:this.geom,scale:r,paperLengthMM:i==="horizontal"?n.width:n.height})}}patchElementDom(){for(const r of this.store.elements){const o=this.root.querySelector(`[data-el-id="${CSS.escape(r.id)}"]`);o&&(o.style.left=`${r.options.left}mm`,o.style.top=`${r.options.top}mm`,o.style.width=`${r.options.width}mm`,o.style.height=`${r.options.height}mm`)}const e=this.root.querySelector(".position-label"),n=this.store.selectedElement;e&&n&&!this.drag&&(e.textContent=Ip(n.options))}fire(e,n){const r=this.store;switch(e){case"undo":r.undo();break;case"redo":r.redo();break;case"align":r.alignSelected(n);break;case"move-layer":r.moveLayer(n);break;case"group":r.groupSelected();break;case"ungroup":r.ungroupSelected();break;case"copy":r.copy();break;case"cut":r.cutSelected();break;case"paste":r.paste();break;case"paste-at":r.paste();break;case"delete":r.deleteSelected();break;case"delete-page":r.deletePage(r.activePageIndex);break;case"add-page":r.addPage();break;case"duplicate-page":r.duplicatePage(r.activePageIndex);break;case"move-page":r.movePage(r.activePageIndex,r.activePageIndex+n);break;case"select-all":r.selectAll();break;case"clear-selection":r.clearSelection();break;case"toggle-ruler":r.showRuler=!r.showRuler,this.repaint();break;case"toggle-grid":r.showGrid=!r.showGrid,this.repaint();break;case"toggle-snap":r.snapToGrid=!r.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":r.showTableGhostBorder=!r.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(n>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":r.removeGuide(n);break;case"resize-start":this.beginResize(n);break;case"element-mousedown":{const o=n;o.event.button===0&&this.isDoubleTap(`el:${o.id}`,o.event)&&this.fire("element-dblclick",{event:o.event,id:o.id}),this.beginDrag(o);break}case"table-cell-mousedown":{const o=n;this.isDoubleTap(`cell:${o.elementId}:${o.r}:${o.c}`,o.event)&&(this.taps.delete(`el:${o.elementId}`),this.fire("table-cell-dblclick",{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId}));break}case"zone-resize":this.beginZoneResize(n);break;case"guide-mousedown":this.beginGuideDrag(n);break;case"ruler-mousedown":this.beginRulerGuide(n);break;case"canvas-mousedown":this.onCanvasMouseDown(n);break;case"canvas-mousemove":this.onCanvasMouseMove(n);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(n);break;case"contextmenu":this.onElementContextMenu(n);break;case"element-dblclick":{const{id:o}=n;this.dblEditElement(o),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:o,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const o=n;this.dblEditCell(o),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(n);break;case"drop":this.onDrop(n);break;case"wheel":this.onWheel(n);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const n=e.dataTransfer,r=n?.getData("elementType"),o=n?.getData("fieldKey"),i=this.pointToPaperMm(e);if(!i)return;const a={x:i.left,y:i.top};if(r)this.store.addElement(r,{},a);else if(o){const l=this.store.fields.find(c=>c.fieldKey===o);l&&this.store.addFieldElement(l,{},a)}}pointToPaperMm(e){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const r=n.getBoundingClientRect(),o=(this.store.scale||100)/100,i=vr((e.clientX-r.left)/o),a=vr((e.clientY-r.top)/o);return i<0||a<0?null:{left:i,top:a}}onCanvasMouseDown(e){const n=e.target;(n===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(o=>n.classList.contains(o)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const n=this.pointToPaperMm(e),r=this.root.querySelector("[data-coord]");if(r){if(!n){r.style.display="none";return}r.style.display="",r.textContent=`x:${(n.left-this.store.templateData.margins.left).toFixed(1)} y:${(n.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,n){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=n,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const r=this.root.querySelector(".context-menu");if(!r)return;const o=r.getBoundingClientRect();this.menu.flipX=o.right>window.innerWidth?window.innerWidth-o.right-8:0,this.menu.flipY=o.bottom>window.innerHeight?window.innerHeight-o.bottom-8:0,this.paint()})}startMarquee(e){const n={x:e.clientX,y:e.clientY},r=i=>{this.marquee={visible:!0,x:Math.min(n.x,i.clientX),y:Math.min(n.y,i.clientY),w:Math.abs(i.clientX-n.x),h:Math.abs(i.clientY-n.y)},this.paint()},o=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const i={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},i.w>2&&i.h>2){const a=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const s=c.getBoundingClientRect();return s.left<i.x+i.w&&s.right>i.x&&s.top<i.y+i.h&&s.bottom>i.y});this.store.select(new Set(a.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}taps=new Map;isDoubleTap(e,n){const r=this.taps.get(e);return this.taps.set(e,{t:n.timeStamp,x:n.clientX,y:n.clientY}),!r||n.timeStamp-r.t>=500||Math.abs(n.clientX-r.x)>6||Math.abs(n.clientY-r.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const n=e.event;if(n.button!==0)return;const r=this.store;n.stopPropagation();const o=r.elements.find(l=>l.id===e.id);if(!o||(r.selectElement(o.id,n.ctrlKey||n.metaKey),o.options.locked))return;const i=n.altKey?[o.id]:r.dragIds(o.id),a=new Map;for(const l of i){const c=r.elements.find(s=>s.id===l);c&&a.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:i,primary:o.id,altKey:n.altKey,movedPositions:new Map,startX:n.clientX,startY:n.clientY,origin:a,zone:o.zone||"content",moved:!1},r.draggingIds=new Set(i),r.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const n of Array.from(this.root.querySelectorAll(".print-element"))){const r=e.has(n.dataset.elId??"");n.classList.toggle("drag-ghost",r);const o=n.querySelector(":scope > .drag-preview");r&&!o?Re(g("div",{class:"drag-preview"}),n):!r&&o&&o.remove()}}finishAltClone(e){const n=this.store;n.adsorbGuides=[];const r=n.elements.find(a=>a.id===e.primary),o=e.movedPositions.get(e.primary);if(n.discardLive(),!r||!o)return;const i=JSON.parse(JSON.stringify(r));i.id=sn(),i.options.left=o.left,i.options.top=o.top,i.options.groupId=void 0,n.cloneElement(i)}flashSnapIndicator(e,n){const r=this.root.querySelector(".hiprint-printPaper-content");r&&(r.querySelector(".snap-indicator")?.remove(),Re(g("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${n}mm`}}),r),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{r.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const n=e.event;n.stopPropagation();const r=this.store.elements.find(o=>o.id===e.id);!r||r.options.locked||(this.resize={id:e.id,point:e.point,startX:n.clientX,startY:n.clientY,origin:{left:r.options.left,top:r.options.top,width:r.options.width,height:r.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const n=e.event.clientY,r=this.store.templateData,o=e.zone==="header"?r.header.height:r.footer.height,i=(this.store.scale||100)/100,a=c=>{const s=vr((c.clientY-n)/i),d=Math.max(0,Math.round((o+(e.zone==="header"?s:-s))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...r.header,height:d}}):this.store.updateTemplateData({footer:{...r.footer,height:d}}),this.paint()},l=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",l)}beginGuideDrag(e){const n=(this.store.templateData.guides??[]).find(d=>d.id===e.id);if(!n)return;const r=Et(this.store.templateData),o=n.type==="vertical"?r.width:r.height,i=e.event.clientX,a=e.event.clientY,l=(this.store.scale||100)/100,c=d=>{const p=vr((n.type==="vertical"?d.clientX-i:d.clientY-a)/l);this.store.moveGuide(n.id,Math.min(o,Math.max(0,n.position+p))),this.paint()},s=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",s),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",s)}beginRulerGuide(e){const n=e.orientation==="horizontal"?"vertical":"horizontal",r=i=>{this.guidePreview={type:n,position:n==="vertical"?i.clientX:i.clientY},this.paint()},o=i=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const a=this.rulerPointToMM(i,n);this.guidePreview=null,a!==null?this.store.addGuide(n,a):this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}rulerPointToMM(e,n){const r=this.root.querySelector(".hiprint-printPaper");if(!r)return null;const o=r.getBoundingClientRect(),i=$t(1)*(this.geom.paperScale||1),a=n==="vertical"?(e.clientX-o.left)/i:(e.clientY-o.top)/i,l=Et(this.store.templateData),c=n==="vertical"?l.width:l.height;return a<0||a>c?null:a}applyZoom(e,n,r,o){const i=this.root.querySelector(".canvas-area");if(!i)return;const a=Math.round(this.store.scale),l=Math.max(o,Math.round(e));if(l===a)return;const c=getComputedStyle(i),s=parseFloat(c.paddingLeft)||0,d=parseFloat(c.paddingTop)||0,p=i.scrollLeft+n-s,u=i.scrollTop+r-d,f=l/a;this.store.setScale(l,o),i.scrollLeft=p*f-n+s,i.scrollTop=u*f-r+d}zoomByStep(e){const n=this.root.querySelector(".canvas-area");n&&this.applyZoom(fl(this.store.scale,e),n.clientWidth/2,n.clientHeight/2,Tr)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const n=getComputedStyle(e),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),o=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),i=Et(this.store.templateData),a=wh(e.clientWidth-r,e.clientHeight-o,$t(i.width),$t(i.height));this.applyZoom(a,e.clientWidth/2,e.clientHeight/2,pl)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=this.root.querySelector(".canvas-area");if(!n)return;const r=Math.round(this.store.scale),o=fl(r,e.deltaY>0?-1:1);if(o===r)return;const i=n.getBoundingClientRect();this.applyZoom(o,e.clientX-i.left,e.clientY-i.top,Tr)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const n=this.store;if(!n)return;const o=((n.scale||100)/100||1)*$t(1),i=(a,l)=>({dx:a/o,dy:l/o});if(this.drag){const{dx:a,dy:l}=i(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(a)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=n.elements.find(h=>h.id===this.drag.primary),s=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+a,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let d=null;if(s&&n.snapToGrid!==!1){const h=n.elements.filter(v=>!this.drag.ids.includes(v.id)&&(v.zone||"content")===this.drag.zone).map(v=>({id:v.id,left:v.options.left,top:v.options.top,width:v.options.width,height:v.options.height})),m=is(n.templateData,n.paperSize)[this.drag.zone],b=y0(s,h,this.manualGuides());d={left:b.left,top:b.top},n.adsorbGuides=(b.lines??[]).filter(v=>v.position>=0&&v.position<=(v.type==="vertical"?m.width:m.height)),(d.left!==s.left||d.top!==s.top)&&this.flashSnapIndicator(d.left+s.width/2,d.top+s.height/2)}else n.adsorbGuides=[];const p=c?this.drag.origin.get(c.id):void 0,u=d&&p?d.left-p.left:a,f=d&&p?d.top-p.top:l;for(const h of this.drag.ids){const m=this.drag.origin.get(h);if(!m)continue;const b={left:m.left+u,top:m.top+f};this.drag.movedPositions.set(h,b),n.livePatch(h,b)}this.patchElementDom(),n.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:a,dy:l}=i(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=E0(this.resize.point,this.resize.origin,a,l,3.5,3.5);n.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const e=!!this.drag,n=this.drag;if(n?.moved&&n.altKey){this.finishAltClone(n),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),e&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",e=>{const n=e.composedPath(),r=n.some(i=>i.classList?.contains("tb-dd"));this.state.openDd&&!r&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!r&&(this.state.openMore=!1,this.repaint());const o=n.some(i=>i.classList?.contains("context-menu"));this.menu.visible&&!o&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const r=e.target?.closest?.("[data-tip]");!r||!r.closest(gw)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(r),300))}),this.root.addEventListener("mouseout",e=>{const n=e,r=n.target?.closest?.("[data-tip]");r&&n.relatedTarget?.closest?.("[data-tip]")!==r&&this.hideHoverTip()})}showHoverTip(e){const n=e.dataset.tip;if(!n)return;this.hideHoverTip();const r=e.getBoundingClientRect(),o=r.left+r.width/2;this.hoverTipEl=Re(g("div",{class:"pd-hover-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root);const i=this.hoverTipEl.offsetWidth/2;if(!i)return;const a=i+8,l=Math.max(window.innerWidth-i-8,a);this.hoverTipEl.style.left=`${Math.min(Math.max(o,a),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const e=[],n=[];for(const r of this.store.templateData.guides??[])r.type==="vertical"?e.push(r.position):n.push(r.position);return{vertical:e,horizontal:n}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const r of Array.from(e.querySelectorAll(".adsorb-guide")))r.remove();const n=this.store.paperSize;is(this.store.templateData,n);for(const r of this.store.adsorbGuides){const o=document.createElement("div");o.className=`adsorb-guide guide-${r.type}`,r.type==="vertical"?o.style.cssText=`left:${r.position}mm;top:0;height:${n.height}mm;border-left-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`:o.style.cssText=`top:${r.position}mm;left:0;width:${n.width}mm;border-top-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(o)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{mt.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),mt.active||(mt.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null)}onGlobalKeydown(e){const n=this.store;if(!n||mt.active!==this)return;const o=e.composedPath()[0]?.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const a=e.shiftKey?10:e.ctrlKey?.5:1,l=e.key==="ArrowLeft"?-a:e.key==="ArrowRight"?a:0,c=e.key==="ArrowUp"?-a:e.key==="ArrowDown"?a:0;n.moveSelected(l,c);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),n.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const i=e.key.toLowerCase();mw.has(i)&&(e.preventDefault(),i==="z"?e.shiftKey?n.redo():n.undo():i==="y"?n.redo():i==="a"?n.selectAll():i==="c"?n.copy():i==="x"?n.cutSelected():i==="v"?n.paste():i==="d"?n.duplicateSelected():i==="g"?e.shiftKey?n.ungroupSelected():n.groupSelected():i==="1"?n.resetZoom():i==="l"?n.alignSelected("left"):i==="r"?n.alignSelected("right"):i==="e"?n.alignSelected("vertical"):i==="t"?n.alignSelected("top"):i==="b"?n.alignSelected("bottom"):i==="0"&&this.fire("fit-window"))}}function sf(t="print-designer"){return customElements.get(t)||customElements.define(t,mt),t}function yw(){return sf()}const vw=Object.freeze(Object.defineProperty({__proto__:null,DesignerStore:Xu,PrintDesignerElement:mt,TILING_SINGLE_PAGE_TIP:Ua,createDefaultTemplate:ir,definePrintDesigner:sf,registerAll:yw,serializePage:Yu,toRuntimePool:qa},Symbol.toStringTag,{value:"Module"})),ww=17521,xw=20,Ms={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml"};let Ts=0;function Ew(){return Ts=(Ts+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${Ts.toString(36)}`}function lf(t,e){const n={id:Ew(),type:t,payload:e};return JSON.stringify(n)}function cf(t){let e;try{e=JSON.parse(t)}catch{return{malformed:!0}}if(typeof e!="object"||e===null)return{malformed:!0};const n=e;if(typeof n.id!="string"||typeof n.ok!="boolean")return{malformed:!0};if(n.ok)return{id:n.id,ok:!0,payload:n.payload??{}};const r=n.error;return!r||typeof r.code!="string"||typeof r.message!="string"?{malformed:!0}:{id:n.id,ok:!1,error:{code:r.code,message:r.message}}}class bt extends Error{constructor(e,n){super(n),this.name="WormPrintError",this.code=e}}class df extends Error{constructor(e){super(e),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class Sw{constructor(e={}){this.ws=null,this.status_="disconnected",this.hello=null,this.pendings=new Map,this.statusCbs=new Set,this.manualClose=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.opts=e,this.ctor=e.WebSocketCtor??WebSocket,this.defaultTimeout=e.timeoutMs??15e3}get status(){return this.status_}onStatus(e){return this.statusCbs.add(e),()=>this.statusCbs.delete(e)}setToken(e){this.opts={...this.opts,token:e}}async connect(e){if(this.status_==="connected"&&this.hello)return this.hello;this.setStatus("connecting");const n=this.opts.ports??Array.from({length:xw},(r,o)=>ww+o);for(const r of n){if(e?.aborted)throw new bt("CLIENT_NOT_RUNNING","连接已取消");try{return this.hello=await this.tryPort(r,e),this.manualClose=!1,this.reconnectAttempts=0,this.setStatus("connected"),this.hello}catch(o){if(o instanceof df)throw this.setStatus("disconnected"),new bt("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new bt("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(e,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new bt("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=lf(e,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new bt("CLIENT_TIMEOUT",`请求 ${e} 超时未响应`))},r??this.defaultTimeout);this.pendings.set(i.id,{resolve:a,reject:l,timer:c}),this.ws.send(o)})}close(){this.manualClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ws?.close(),this.failAllPendings(new bt("CLIENT_NOT_RUNNING","连接已关闭")),this.setStatus("disconnected")}buildUrl(e){const n=new URL(`ws://127.0.0.1:${e}`);return this.opts.token&&n.searchParams.set("token",this.opts.token),n.toString().replace(/\/$/,"")}tryPort(e,n){return new Promise((r,o)=>{const i=new this.ctor(this.buildUrl(e));this.ws=i;let a=!1;const l=()=>{a||(a=!0,o(new Error("aborted")))};n?.addEventListener("abort",l,{once:!0}),i.onopen=()=>{i.send(lf("hello",{}))},i.onmessage=c=>{const s=cf(String(c.data));if(!("malformed"in s))if(s.ok&&_w(s.payload)){if(a)return;a=!0,this.bindLifecycle(i),r(s.payload)}else if(!s.ok&&s.error.code==="UNAUTHORIZED"){if(a)return;a=!0,o(new df(s.error.message))}else a||(a=!0,o(new Error("握手失败")))},i.onerror=()=>{a||(a=!0,o(new Error("连接错误")))},i.onclose=()=>{a||(a=!0,o(new Error("连接关闭")))}})}bindLifecycle(e){e.onmessage=n=>{const r=cf(String(n.data));if("malformed"in r)return;const o=this.pendings.get(r.id);o&&(this.pendings.delete(r.id),clearTimeout(o.timer),r.ok?o.resolve(r.payload):o.reject(new bt(r.error.code,r.error.message)))},e.onclose=()=>{this.failAllPendings(new bt("CLIENT_NOT_RUNNING","与客户端的连接中断")),this.hello=null,this.ws=null,this.manualClose||this.scheduleReconnect()},e.onerror=()=>{}}scheduleReconnect(){this.setStatus("connecting");const e=Math.min(1e3*2**this.reconnectAttempts++,1e4);this.reconnectTimer=setTimeout(()=>{this.connect().catch(()=>this.scheduleReconnect())},e)}failAllPendings(e){for(const[,n]of this.pendings)clearTimeout(n.timer),n.reject(e);this.pendings.clear()}setStatus(e){if(this.status_!==e){this.status_=e;for(const n of this.statusCbs)n(e)}}}function _w(t){return typeof t=="object"&&t!==null&&t.app==="worm-print-client"}const uf="worm-print-client:token";class ks{constructor(e={}){const r={token:e.token??ks.loadStoredToken()??void 0,timeoutMs:e.timeoutMs,WebSocketCtor:e.WebSocketCtor};this.transport=new Sw(r)}get status(){return this.transport.status}connect(e){return this.transport.connect(e)}onStatusChange(e){return this.transport.onStatus(e)}async listPrinters(){return(await this.transport.request(Ms.PRINTERS_LIST,{})).printers}print(e,n,r={},o){const{baseUrl:i,fontBaseUrl:a,timeoutMs:l,...c}=r,s={templateJson:e,printData:n,baseUrl:i,fontBaseUrl:a,print:c};return typeof o=="string"&&o.trim().length>0&&(s.templateName=o),this.transport.request(Ms.PRINT_SUBMIT,s,l)}printHtml(e,n={},r){const{timeoutMs:o,...i}=n,a={html:e.html,paperMm:e.paperMm,continuous:e.continuous,pageCount:e.pageCount,print:i};return typeof r=="string"&&r.trim().length>0&&(a.templateName=r),this.transport.request(Ms.PRINT_SUBMIT_HTML,a,o)}pair(e){localStorage.setItem(uf,e),this.transport.setToken(e)}static loadStoredToken(){try{return localStorage.getItem(uf)}catch{return null}}close(){this.transport.close()}}const Mw={...vw,renderHtmlPages:Yb,browserCodeRenderer:za,PrintClient:ks,WormPrintError:bt,getPaperDimensions:Ze,isContinuousPaperSize:tn,getByPath:zn,resolvePrinterDpi:Jh,paperWidthPx:Qh,zoomPresets:tg,defaultZoomKey:Rl,resolveZoomKey:og,zoomValueOf:ig,viewZoomHint:ng,applyPreviewViewZoom:rg,resolveToolbarOverflow:hl};globalThis.WormPrintCommon??=Mw}));
1024
+ `)}`);const r=this.templateJsonWithFonts();if(Array.isArray(r.pages))try{ua(r)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const o=JSON.stringify(r);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:o,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?ca(e):[]}getGeometryWarnings(){return Wm(this.store.templateData)}applyTemplate(e){if(!e)return;const n=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(n):this.setAttribute("template",JSON.stringify(n))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(r=>r.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(r=>r.remove());const n=this.exprTarget;Re(ow({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:r=>this.applyExpression(n,r)},n),this.root),this.exprMountedFor=n}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const e=this.helpVisible&&this.getAttribute("show-help")!=="false";if(e&&!this.unmountHelp)this.unmountHelp=lw(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const n=this.unmountHelp;this.unmountHelp=null,n()}}applyExpression(e,n){const r=n.formatter??"",o=e.targetPath;if(o.startsWith("options.")){if(o.includes("[")){const a=this.store.elements.find(l=>l.id===e.elementId);a&&ms(this.store,a,o,r);return}const i={[o.slice(8)]:r||void 0};n.title!==void 0&&(i.title=n.title),this.store.updateElement(e.elementId,i);return}if(o==="watermark.content"){const i={...this.store.templateData.watermark};ws(r)?Object.assign(i,{mode:"binding",binding:r,content:""}):Object.assign(i,{mode:"fixed",content:r,binding:""}),this.store.updateTemplateData({watermark:i})}}dblEditElement(e){const n=this.store.elements.find(o=>o.id===e);if(!n||(this.store.selectOne(e),this.state.propTab="element",n.options.locked))return;const r=bw[n.printElementType.type];r&&this.openExpression({elementId:n.id,targetPath:`options.${r}`,value:String(n.options[r]??"")})}dblEditCell(e){const n=this.store.elements.find(l=>l.id===e.elementId);if(!n||(this.store.selectOne(n.id),this.state.propTab="element",n.options.locked))return;const r=n.options.tableRows??[],o=Si(r,e.r,e.c),a=r[o.r]?.cells[o.c];a&&this.openExpression({elementId:n.id,targetPath:`options.tableRows[${o.r}].cells[${o.c}].formatter`,value:a.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(e,n)=>this.fire(e,n),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const e=[...this.store.selectedIds].join(",");e!==this.lastSelKey&&(this.lastSelKey=e,this.state.propTab=e?"element":"page");const n=this.root.querySelector(".designer-container");n.classList.toggle("format-painting",this.format.painterActive),Yu(n);const r=this.ctx;Re(pw(r,av(r)),n),Re(fv(r),n),Re(g("div",{class:"designer-body"},[cv(r),Hy(r,this.canvasUi()),Yv(r)]),n),Re(hv(r),n),Qp(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>Qp(n)),this.toolbarRo.observe(n));const o=by(this.store,(i,a)=>this.fire(i,a),this.tableMenu);o&&Re(o,n),W1(this.root,this.store.elements),Hp(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))ju(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const n=e.getAttribute("data-fit-base");n?e.style.fontSize=`${n}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),n=this.root.querySelector(".hiprint-printPaper");if(!e||!n)return;const r=e.getBoundingClientRect(),o=n.getBoundingClientRect(),i=(this.store.scale||100)/100,a=o.width/$t(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-Vo+this.scrollPos.x,originY:o.top-r.top-Vo+this.scrollPos.y,viewW:e.clientWidth-Vo,viewH:e.clientHeight-Vo},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,n=Et(e),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";fw(o,{orientation:i,geom:this.geom,scale:r,paperLengthMM:i==="horizontal"?n.width:n.height})}}patchElementDom(){for(const r of this.store.elements){const o=this.root.querySelector(`[data-el-id="${CSS.escape(r.id)}"]`);o&&(o.style.left=`${r.options.left}mm`,o.style.top=`${r.options.top}mm`,o.style.width=`${r.options.width}mm`,o.style.height=`${r.options.height}mm`)}const e=this.root.querySelector(".position-label"),n=this.store.selectedElement;e&&n&&!this.drag&&(e.textContent=Pp(n.options))}fire(e,n){const r=this.store;switch(e){case"undo":r.undo();break;case"redo":r.redo();break;case"align":r.alignSelected(n);break;case"move-layer":r.moveLayer(n);break;case"group":r.groupSelected();break;case"ungroup":r.ungroupSelected();break;case"copy":r.copy();break;case"cut":r.cutSelected();break;case"paste":r.paste();break;case"paste-at":r.paste();break;case"delete":r.deleteSelected();break;case"delete-page":r.deletePage(r.activePageIndex);break;case"add-page":r.addPage();break;case"duplicate-page":r.duplicatePage(r.activePageIndex);break;case"move-page":r.movePage(r.activePageIndex,r.activePageIndex+n);break;case"select-all":r.selectAll();break;case"clear-selection":r.clearSelection();break;case"toggle-ruler":r.showRuler=!r.showRuler,this.repaint();break;case"toggle-grid":r.showGrid=!r.showGrid,this.repaint();break;case"toggle-snap":r.snapToGrid=!r.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":r.showTableGhostBorder=!r.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(n>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":r.removeGuide(n);break;case"resize-start":this.beginResize(n);break;case"element-mousedown":{const o=n;o.event.button===0&&this.isDoubleTap(`el:${o.id}`,o.event)&&this.fire("element-dblclick",{event:o.event,id:o.id}),this.beginDrag(o);break}case"table-cell-mousedown":{const o=n;this.isDoubleTap(`cell:${o.elementId}:${o.r}:${o.c}`,o.event)&&(this.taps.delete(`el:${o.elementId}`),this.fire("table-cell-dblclick",{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId}));break}case"zone-resize":this.beginZoneResize(n);break;case"guide-mousedown":this.beginGuideDrag(n);break;case"ruler-mousedown":this.beginRulerGuide(n);break;case"canvas-mousedown":this.onCanvasMouseDown(n);break;case"canvas-mousemove":this.onCanvasMouseMove(n);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(n);break;case"contextmenu":this.onElementContextMenu(n);break;case"element-dblclick":{const{id:o}=n;this.dblEditElement(o),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:o,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const o=n;this.dblEditCell(o),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:o.elementId,r:o.r,c:o.c,cellId:o.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(n);break;case"drop":this.onDrop(n);break;case"wheel":this.onWheel(n);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const n=e.dataTransfer,r=n?.getData("elementType"),o=n?.getData("fieldKey"),i=this.pointToPaperMm(e);if(!i)return;const a={x:i.left,y:i.top};if(r)this.store.addElement(r,{},a);else if(o){const l=this.store.fields.find(c=>c.fieldKey===o);l&&this.store.addFieldElement(l,{},a)}}pointToPaperMm(e){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const r=n.getBoundingClientRect(),o=(this.store.scale||100)/100,i=vr((e.clientX-r.left)/o),a=vr((e.clientY-r.top)/o);return i<0||a<0?null:{left:i,top:a}}onCanvasMouseDown(e){const n=e.target;(n===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(o=>n.classList.contains(o)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const n=this.pointToPaperMm(e),r=this.root.querySelector("[data-coord]");if(r){if(!n){r.style.display="none";return}r.style.display="",r.textContent=`x:${(n.left-this.store.templateData.margins.left).toFixed(1)} y:${(n.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,n){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=n,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const r=this.root.querySelector(".context-menu");if(!r)return;const o=r.getBoundingClientRect();this.menu.flipX=o.right>window.innerWidth?window.innerWidth-o.right-8:0,this.menu.flipY=o.bottom>window.innerHeight?window.innerHeight-o.bottom-8:0,this.paint()})}startMarquee(e){const n={x:e.clientX,y:e.clientY},r=i=>{this.marquee={visible:!0,x:Math.min(n.x,i.clientX),y:Math.min(n.y,i.clientY),w:Math.abs(i.clientX-n.x),h:Math.abs(i.clientY-n.y)},this.paint()},o=()=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const i={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},i.w>2&&i.h>2){const a=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const s=c.getBoundingClientRect();return s.left<i.x+i.w&&s.right>i.x&&s.top<i.y+i.h&&s.bottom>i.y});this.store.select(new Set(a.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}taps=new Map;isDoubleTap(e,n){const r=this.taps.get(e);return this.taps.set(e,{t:n.timeStamp,x:n.clientX,y:n.clientY}),!r||n.timeStamp-r.t>=500||Math.abs(n.clientX-r.x)>6||Math.abs(n.clientY-r.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const n=e.event;if(n.button!==0)return;const r=this.store;n.stopPropagation();const o=r.elements.find(l=>l.id===e.id);if(!o||(r.selectElement(o.id,n.ctrlKey||n.metaKey),o.options.locked))return;const i=n.altKey?[o.id]:r.dragIds(o.id),a=new Map;for(const l of i){const c=r.elements.find(s=>s.id===l);c&&a.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:i,primary:o.id,altKey:n.altKey,movedPositions:new Map,startX:n.clientX,startY:n.clientY,origin:a,zone:o.zone||"content",moved:!1},r.draggingIds=new Set(i),r.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const n of Array.from(this.root.querySelectorAll(".print-element"))){const r=e.has(n.dataset.elId??"");n.classList.toggle("drag-ghost",r);const o=n.querySelector(":scope > .drag-preview");r&&!o?Re(g("div",{class:"drag-preview"}),n):!r&&o&&o.remove()}}finishAltClone(e){const n=this.store;n.adsorbGuides=[];const r=n.elements.find(a=>a.id===e.primary),o=e.movedPositions.get(e.primary);if(n.discardLive(),!r||!o)return;const i=JSON.parse(JSON.stringify(r));i.id=sn(),i.options.left=o.left,i.options.top=o.top,i.options.groupId=void 0,n.cloneElement(i)}flashSnapIndicator(e,n){const r=this.root.querySelector(".hiprint-printPaper-content");r&&(r.querySelector(".snap-indicator")?.remove(),Re(g("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${n}mm`}}),r),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{r.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const n=e.event;n.stopPropagation();const r=this.store.elements.find(o=>o.id===e.id);!r||r.options.locked||(this.resize={id:e.id,point:e.point,startX:n.clientX,startY:n.clientY,origin:{left:r.options.left,top:r.options.top,width:r.options.width,height:r.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const n=e.event.clientY,r=this.store.templateData,o=e.zone==="header"?r.header.height:r.footer.height,i=(this.store.scale||100)/100,a=c=>{const s=vr((c.clientY-n)/i),d=Math.max(0,Math.round((o+(e.zone==="header"?s:-s))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...r.header,height:d}}):this.store.updateTemplateData({footer:{...r.footer,height:d}}),this.paint()},l=()=>{window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",a),window.addEventListener("mouseup",l)}beginGuideDrag(e){const n=(this.store.templateData.guides??[]).find(d=>d.id===e.id);if(!n)return;const r=Et(this.store.templateData),o=n.type==="vertical"?r.width:r.height,i=e.event.clientX,a=e.event.clientY,l=(this.store.scale||100)/100,c=d=>{const p=vr((n.type==="vertical"?d.clientX-i:d.clientY-a)/l);this.store.moveGuide(n.id,Math.min(o,Math.max(0,n.position+p))),this.paint()},s=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",s),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",s)}beginRulerGuide(e){const n=e.orientation==="horizontal"?"vertical":"horizontal",r=i=>{this.guidePreview={type:n,position:n==="vertical"?i.clientX:i.clientY},this.paint()},o=i=>{window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",o);const a=this.rulerPointToMM(i,n);this.guidePreview=null,a!==null?this.store.addGuide(n,a):this.repaint()};window.addEventListener("mousemove",r),window.addEventListener("mouseup",o)}rulerPointToMM(e,n){const r=this.root.querySelector(".hiprint-printPaper");if(!r)return null;const o=r.getBoundingClientRect(),i=$t(1)*(this.geom.paperScale||1),a=n==="vertical"?(e.clientX-o.left)/i:(e.clientY-o.top)/i,l=Et(this.store.templateData),c=n==="vertical"?l.width:l.height;return a<0||a>c?null:a}applyZoom(e,n,r,o){const i=this.root.querySelector(".canvas-area");if(!i)return;const a=Math.round(this.store.scale),l=Math.max(o,Math.round(e));if(l===a)return;const c=getComputedStyle(i),s=parseFloat(c.paddingLeft)||0,d=parseFloat(c.paddingTop)||0,p=i.scrollLeft+n-s,u=i.scrollTop+r-d,f=l/a;this.store.setScale(l,o),i.scrollLeft=p*f-n+s,i.scrollTop=u*f-r+d}zoomByStep(e){const n=this.root.querySelector(".canvas-area");n&&this.applyZoom(hl(this.store.scale,e),n.clientWidth/2,n.clientHeight/2,Tr)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const n=getComputedStyle(e),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),o=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),i=Et(this.store.templateData),a=xh(e.clientWidth-r,e.clientHeight-o,$t(i.width),$t(i.height));this.applyZoom(a,e.clientWidth/2,e.clientHeight/2,fl)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=this.root.querySelector(".canvas-area");if(!n)return;const r=Math.round(this.store.scale),o=hl(r,e.deltaY>0?-1:1);if(o===r)return;const i=n.getBoundingClientRect();this.applyZoom(o,e.clientX-i.left,e.clientY-i.top,Tr)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const n=this.store;if(!n)return;const o=((n.scale||100)/100||1)*$t(1),i=(a,l)=>({dx:a/o,dy:l/o});if(this.drag){const{dx:a,dy:l}=i(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(a)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=n.elements.find(h=>h.id===this.drag.primary),s=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+a,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let d=null;if(s&&n.snapToGrid!==!1){const h=n.elements.filter(v=>!this.drag.ids.includes(v.id)&&(v.zone||"content")===this.drag.zone).map(v=>({id:v.id,left:v.options.left,top:v.options.top,width:v.options.width,height:v.options.height})),m=as(n.templateData,n.paperSize)[this.drag.zone],b=y0(s,h,this.manualGuides());d={left:b.left,top:b.top},n.adsorbGuides=(b.lines??[]).filter(v=>v.position>=0&&v.position<=(v.type==="vertical"?m.width:m.height)),(d.left!==s.left||d.top!==s.top)&&this.flashSnapIndicator(d.left+s.width/2,d.top+s.height/2)}else n.adsorbGuides=[];const p=c?this.drag.origin.get(c.id):void 0,u=d&&p?d.left-p.left:a,f=d&&p?d.top-p.top:l;for(const h of this.drag.ids){const m=this.drag.origin.get(h);if(!m)continue;const b={left:m.left+u,top:m.top+f};this.drag.movedPositions.set(h,b),n.livePatch(h,b)}this.patchElementDom(),n.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:a,dy:l}=i(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=E0(this.resize.point,this.resize.origin,a,l,3.5,3.5);n.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const e=!!this.drag,n=this.drag;if(n?.moved&&n.altKey){this.finishAltClone(n),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),e&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",e=>{const n=e.composedPath(),r=n.some(i=>i.classList?.contains("tb-dd"));this.state.openDd&&!r&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!r&&(this.state.openMore=!1,this.repaint());const o=n.some(i=>i.classList?.contains("context-menu"));this.menu.visible&&!o&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const r=e.target?.closest?.("[data-tip]");!r||!r.closest(gw)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(r),300))}),this.root.addEventListener("mouseout",e=>{const n=e,r=n.target?.closest?.("[data-tip]");r&&n.relatedTarget?.closest?.("[data-tip]")!==r&&this.hideHoverTip()})}showHoverTip(e){const n=e.dataset.tip;if(!n)return;this.hideHoverTip();const r=e.getBoundingClientRect(),o=r.left+r.width/2;this.hoverTipEl=Re(g("div",{class:"pd-hover-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root);const i=this.hoverTipEl.offsetWidth/2;if(!i)return;const a=i+8,l=Math.max(window.innerWidth-i-8,a);this.hoverTipEl.style.left=`${Math.min(Math.max(o,a),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const e=[],n=[];for(const r of this.store.templateData.guides??[])r.type==="vertical"?e.push(r.position):n.push(r.position);return{vertical:e,horizontal:n}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const r of Array.from(e.querySelectorAll(".adsorb-guide")))r.remove();const n=this.store.paperSize;as(this.store.templateData,n);for(const r of this.store.adsorbGuides){const o=document.createElement("div");o.className=`adsorb-guide guide-${r.type}`,r.type==="vertical"?o.style.cssText=`left:${r.position}mm;top:0;height:${n.height}mm;border-left-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`:o.style.cssText=`top:${r.position}mm;left:0;width:${n.width}mm;border-top-color:${r.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(o)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{mt.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),mt.active||(mt.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null)}onGlobalKeydown(e){const n=this.store;if(!n||mt.active!==this)return;const o=e.composedPath()[0]?.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const a=e.shiftKey?10:e.ctrlKey?.5:1,l=e.key==="ArrowLeft"?-a:e.key==="ArrowRight"?a:0,c=e.key==="ArrowUp"?-a:e.key==="ArrowDown"?a:0;n.moveSelected(l,c);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),n.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const i=e.key.toLowerCase();mw.has(i)&&(e.preventDefault(),i==="z"?e.shiftKey?n.redo():n.undo():i==="y"?n.redo():i==="a"?n.selectAll():i==="c"?n.copy():i==="x"?n.cutSelected():i==="v"?n.paste():i==="d"?n.duplicateSelected():i==="g"?e.shiftKey?n.ungroupSelected():n.groupSelected():i==="1"?n.resetZoom():i==="l"?n.alignSelected("left"):i==="r"?n.alignSelected("right"):i==="e"?n.alignSelected("vertical"):i==="t"?n.alignSelected("top"):i==="b"?n.alignSelected("bottom"):i==="0"&&this.fire("fit-window"))}}function lf(t="print-designer"){return customElements.get(t)||customElements.define(t,mt),t}function yw(){return lf()}const vw=Object.freeze(Object.defineProperty({__proto__:null,DesignerStore:Ku,PrintDesignerElement:mt,TILING_SINGLE_PAGE_TIP:qa,createDefaultTemplate:ir,definePrintDesigner:lf,registerAll:yw,serializePage:Vu,toRuntimePool:Wa},Symbol.toStringTag,{value:"Module"})),ww=17521,xw=20,Ts={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml"};let ks=0;function Ew(){return ks=(ks+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${ks.toString(36)}`}function cf(t,e){const n={id:Ew(),type:t,payload:e};return JSON.stringify(n)}function df(t){let e;try{e=JSON.parse(t)}catch{return{malformed:!0}}if(typeof e!="object"||e===null)return{malformed:!0};const n=e;if(typeof n.id!="string"||typeof n.ok!="boolean")return{malformed:!0};if(n.ok)return{id:n.id,ok:!0,payload:n.payload??{}};const r=n.error;return!r||typeof r.code!="string"||typeof r.message!="string"?{malformed:!0}:{id:n.id,ok:!1,error:{code:r.code,message:r.message}}}class bt extends Error{constructor(e,n){super(n),this.name="WormPrintError",this.code=e}}class uf extends Error{constructor(e){super(e),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class Sw{constructor(e={}){this.ws=null,this.status_="disconnected",this.hello=null,this.pendings=new Map,this.statusCbs=new Set,this.manualClose=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.opts=e,this.ctor=e.WebSocketCtor??WebSocket,this.defaultTimeout=e.timeoutMs??15e3}get status(){return this.status_}onStatus(e){return this.statusCbs.add(e),()=>this.statusCbs.delete(e)}setToken(e){this.opts={...this.opts,token:e}}async connect(e){if(this.status_==="connected"&&this.hello)return this.hello;this.setStatus("connecting");const n=this.opts.ports??Array.from({length:xw},(r,o)=>ww+o);for(const r of n){if(e?.aborted)throw new bt("CLIENT_NOT_RUNNING","连接已取消");try{return this.hello=await this.tryPort(r,e),this.manualClose=!1,this.reconnectAttempts=0,this.setStatus("connected"),this.hello}catch(o){if(o instanceof uf)throw this.setStatus("disconnected"),new bt("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new bt("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(e,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new bt("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=cf(e,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new bt("CLIENT_TIMEOUT",`请求 ${e} 超时未响应`))},r??this.defaultTimeout);this.pendings.set(i.id,{resolve:a,reject:l,timer:c}),this.ws.send(o)})}close(){this.manualClose=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.ws?.close(),this.failAllPendings(new bt("CLIENT_NOT_RUNNING","连接已关闭")),this.setStatus("disconnected")}buildUrl(e){const n=new URL(`ws://127.0.0.1:${e}`);return this.opts.token&&n.searchParams.set("token",this.opts.token),n.toString().replace(/\/$/,"")}tryPort(e,n){return new Promise((r,o)=>{const i=new this.ctor(this.buildUrl(e));this.ws=i;let a=!1;const l=()=>{a||(a=!0,o(new Error("aborted")))};n?.addEventListener("abort",l,{once:!0}),i.onopen=()=>{i.send(cf("hello",{}))},i.onmessage=c=>{const s=df(String(c.data));if(!("malformed"in s))if(s.ok&&_w(s.payload)){if(a)return;a=!0,this.bindLifecycle(i),r(s.payload)}else if(!s.ok&&s.error.code==="UNAUTHORIZED"){if(a)return;a=!0,o(new uf(s.error.message))}else a||(a=!0,o(new Error("握手失败")))},i.onerror=()=>{a||(a=!0,o(new Error("连接错误")))},i.onclose=()=>{a||(a=!0,o(new Error("连接关闭")))}})}bindLifecycle(e){e.onmessage=n=>{const r=df(String(n.data));if("malformed"in r)return;const o=this.pendings.get(r.id);o&&(this.pendings.delete(r.id),clearTimeout(o.timer),r.ok?o.resolve(r.payload):o.reject(new bt(r.error.code,r.error.message)))},e.onclose=()=>{this.failAllPendings(new bt("CLIENT_NOT_RUNNING","与客户端的连接中断")),this.hello=null,this.ws=null,this.manualClose||this.scheduleReconnect()},e.onerror=()=>{}}scheduleReconnect(){this.setStatus("connecting");const e=Math.min(1e3*2**this.reconnectAttempts++,1e4);this.reconnectTimer=setTimeout(()=>{this.connect().catch(()=>this.scheduleReconnect())},e)}failAllPendings(e){for(const[,n]of this.pendings)clearTimeout(n.timer),n.reject(e);this.pendings.clear()}setStatus(e){if(this.status_!==e){this.status_=e;for(const n of this.statusCbs)n(e)}}}function _w(t){return typeof t=="object"&&t!==null&&t.app==="worm-print-client"}const pf="worm-print-client:token";class Cs{constructor(e={}){const r={token:e.token??Cs.loadStoredToken()??void 0,timeoutMs:e.timeoutMs,WebSocketCtor:e.WebSocketCtor};this.transport=new Sw(r)}get status(){return this.transport.status}connect(e){return this.transport.connect(e)}onStatusChange(e){return this.transport.onStatus(e)}async listPrinters(){return(await this.transport.request(Ts.PRINTERS_LIST,{})).printers}print(e,n,r={},o){const{baseUrl:i,fontBaseUrl:a,timeoutMs:l,...c}=r,s={templateJson:e,printData:n,baseUrl:i,fontBaseUrl:a,print:c};return typeof o=="string"&&o.trim().length>0&&(s.templateName=o),this.transport.request(Ts.PRINT_SUBMIT,s,l)}printHtml(e,n={},r){const{timeoutMs:o,...i}=n,a={html:e.html,paperMm:e.paperMm,continuous:e.continuous,pageCount:e.pageCount,print:i};return typeof r=="string"&&r.trim().length>0&&(a.templateName=r),this.transport.request(Ts.PRINT_SUBMIT_HTML,a,o)}pair(e){localStorage.setItem(pf,e),this.transport.setToken(e)}static loadStoredToken(){try{return localStorage.getItem(pf)}catch{return null}}close(){this.transport.close()}}const Mw={...vw,renderHtmlPages:Yb,browserCodeRenderer:Ba,PrintClient:Cs,WormPrintError:bt,getPaperDimensions:Ze,isContinuousPaperSize:tn,getByPath:zn,resolvePrinterDpi:Qh,paperWidthPx:eg,zoomPresets:ng,defaultZoomKey:Dl,resolveZoomKey:ig,zoomValueOf:ag,viewZoomHint:rg,applyPreviewViewZoom:og,resolveToolbarOverflow:gl};globalThis.WormPrintCommon??=Mw}));