@worm-vue3-print/common 0.0.0-stage → 1.3.7-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -2
  3. package/dist/browser-bundle.d.ts +12 -0
  4. package/dist/common.css +462 -0
  5. package/dist/common.js +910 -0
  6. package/dist/core/default-template.d.ts +9 -0
  7. package/dist/core/font-catalog.d.ts +30 -0
  8. package/dist/core/format.d.ts +102 -0
  9. package/dist/core/h.d.ts +22 -0
  10. package/dist/core/icons.d.ts +10 -0
  11. package/dist/core/store.d.ts +163 -0
  12. package/dist/index.cjs +657 -0
  13. package/dist/index.d.ts +13 -0
  14. package/dist/index.js +7058 -0
  15. package/dist/print-designer.d.ts +182 -0
  16. package/dist/shell/binding.d.ts +21 -0
  17. package/dist/shell/canvas.d.ts +59 -0
  18. package/dist/shell/code.d.ts +11 -0
  19. package/dist/shell/color-picker.d.ts +44 -0
  20. package/dist/shell/controls.d.ts +101 -0
  21. package/dist/shell/elements.d.ts +27 -0
  22. package/dist/shell/expression-editor.d.ts +33 -0
  23. package/dist/shell/font-select.d.ts +24 -0
  24. package/dist/shell/format-bar.d.ts +15 -0
  25. package/dist/shell/help-content/changelog.d.ts +12 -0
  26. package/dist/shell/help-content/faq.d.ts +12 -0
  27. package/dist/shell/help-content/features.d.ts +12 -0
  28. package/dist/shell/help-content/getting-started.d.ts +12 -0
  29. package/dist/shell/help-content/index.d.ts +13 -0
  30. package/dist/shell/help-content/shortcuts.d.ts +12 -0
  31. package/dist/shell/help-modal.d.ts +19 -0
  32. package/dist/shell/page-extras.d.ts +10 -0
  33. package/dist/shell/panels.d.ts +17 -0
  34. package/dist/shell/prop-group.d.ts +11 -0
  35. package/dist/shell/property-panel.d.ts +14 -0
  36. package/dist/shell/property-search.d.ts +32 -0
  37. package/dist/shell/ruler.d.ts +29 -0
  38. package/dist/shell/table-props.d.ts +17 -0
  39. package/dist/shell/table.d.ts +22 -0
  40. package/dist/shell/toolbar-overflow.d.ts +28 -0
  41. package/dist/shell/toolbar.d.ts +8 -0
  42. package/dist/shell/watermark.d.ts +10 -0
  43. package/package.json +57 -4
package/dist/common.js ADDED
@@ -0,0 +1,910 @@
1
+ (function(rt){typeof define=="function"&&define.amd?define(rt):rt()})((function(){"use strict";function rt(t){return t/2.83464566929}function Un(t){return t*(25.4/96)}function ut(t){return t*(96/25.4)}const rp=6,op=1,ip=["clip","shrink","autoHeight"];function Ya(t){return typeof t=="string"&&ip.includes(t)?t:void 0}const ap={text:"clip",longText:"autoHeight"};function qn(t,e){return Ya(e?.textFit)??ap[t]??"clip"}function Mo(t){return Ya(t?.textFit)??(t?.wordWrap===!1?"clip":"autoHeight")}function ln(t){return typeof t!="number"||!Number.isFinite(t)||t<=0?rp:Math.max(t,op)}function Co(t){return Math.round(t*100)/100}function sp(t){return Math.floor(t*100)/100}function lp(t,e,n,r){return`${t}#${e}#${n}:${r}`}function cp(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 Xa(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=(rt(n?.borders?.left?.width??0)+rt(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function Ao(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=(rt(n?.borders?.top?.width??0)+rt(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const dp=25.4,Dt=10,Oo=30,Po=10,Ro=2,up=.25;function Wn(t){const e=typeof t=="number"&&Number.isFinite(t)?t:2;return Math.max(1,e/2)}function pp(t){return Wn(t)*up}function $t(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 Io(t){const e=Math.max(1,Math.ceil(t.unitWidth)),n=Math.max(1,Math.ceil(t.unitHeight)),r=pp(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=i/dp,c=Math.max(1,Math.round(r*l)),s=Math.floor(o*l);if(s>=1){const d=Math.min(c,s),p=d/l;return{moduleWidthMm:p,widthMm:e*p,heightMm:n*p,dotsPerModule:d,scaledDown:d<c}}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:e*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}const jn=["top","right","bottom","left"],Ka=new Set(["rect","oval","hline","vline","table"]);function Ja(t){return!!t&&!Ka.has(t)}const fp=new Set(["solid","dashed","dotted","double"]);function Za(t,e,n){return typeof t!="number"||!Number.isFinite(t)||t<=0?null:{borderWidth:`${t}pt`,borderStyle:typeof e=="string"&&fp.has(e)?e:"solid",borderColor:n||"#000"}}function Qa(t,e){if(!t||Ka.has(t))return null;const n=Za(e?.borderWidth,e?.borderStyle,e?.borderColor),r={},o=e?.borders;if(o)for(const i of jn){const a=o[i];if(!a)continue;const l=Za(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const Gn=25,es=5;function hp(t){return Math.max(Gn,t)}function ts(t,e,n=1.1){const r=e>0?t*n:t/n;return hp(Math.round(r))}function gp(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(es,a)}const mp=2;function bp(t){const e=t.gap??mp,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}}const vp=["left","top","width","height"];function yp(t){const e={...t.options};for(const n of vp){const r=e[n];typeof r=="number"&&Number.isFinite(r)&&(e[n]=xp(rt(r)))}return{...t,options:e}}function xp(t){return Math.round(t*100)/100}function wp(t){const e={...t};if(delete e.firstPageOverlay,e.unit==="mm")return e;const n=e,r=o=>o?.map(yp)??[];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 Do="标签纸",Ue={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:Do},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:Do},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:Do},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 $o(t){return!!t&&Ue[t]?.continuous===!0}function pt(t){const e=$o(t.paperSize);let n;if(t.paperSize==="CUSTOM"||e){const r=Ue[t.paperSize];n={width:t.customWidth??r?.width??210,height:t.customHeight??r?.height??297}}else{const r=Ue[t.paperSize]||Ue.A4;n={width:r.width,height:r.height}}return t.orientation==="landscape"&&!e?{width:n.height,height:n.width}:n}function Ep(){let t=0;return function(){return t+=1,`cell-${Date.now().toString(36)}-${t}`}}function Sp(){let t=0;return function(){return t+=1,`row-${Date.now().toString(36)}-${t}`}}const _p=Ep(),Tp=Sp(),Vn={width:.75,style:"solid",color:"#333333"};function Lo(t){return JSON.parse(JSON.stringify(t))}function No(t){return{id:_p(),borders:{top:{...Vn},right:{...Vn},bottom:{...Vn},left:{...Vn}},...t}}function kp(){const t=[50,50,50],e=(r,o)=>({id:Tp(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:t.map(()=>No())}),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 Fo(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 ft(t,e,n){const r=Fo(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 ns(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=ft(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 rs(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=ns(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 os(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 is(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=ft(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,Mp(a,s)}o.rowspan=1,o.colspan=1}}}function Mp(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?Lo(t.borders):void 0,e.padding=t.padding,e.wordWrap=t.wordWrap)}function as(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},()=>No())};for(let c=0;c<i;c++)if(r>0&&r<t.length){const s=ft(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 Cp(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,Lo(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=ft(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 ss(t,e,n,r){const o=r==="left"?n:n+1;e.splice(o,0,e[n]);for(const i of t){const a=No();if(o>0&&o<i.cells.length){const l=t.indexOf(i),c=ft(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 Ap(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,Lo(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=ft(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 zo(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 Op(t,e){for(const n of t){if(n.type!=="header")break;n.repeatOnPage=e}}function ls(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=ft(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 Pp="1px dashed rgba(0,0,0,0.18)";function Yn(t,e={}){return t&&t.style!=="none"?`${t.width}pt ${t.style} ${t.color}`:e.designMode&&e.showGhostBorder!==!1?Pp:"none"}function cn(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 cs=5;function Rp(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(cs,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,cs),i)}function Lt(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ip(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}=kp(),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"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 ds(t,e){const n={text:{title:"文本"},image:{title:"图片"},longText:{title:"长文"},table:{title:"表格"},hline:{title:"横线"},vline:{title:"竖线"},rect:{title:"矩形"},oval:{title:"椭圆"},barcode:{title:"条形码"},qrcode:{title:"二维码"},html:{title:"HTML"},pageNumber:{title:"页码"}};return{id:Lt(),options:{...Ip(t),...e},printElementType:{type:t,title:n[t]?.title||t}}}const us=["text","image","hline","vline","rect","oval","barcode","qrcode"];function Dp(t){return pt(t)}function Bo(t){const e=Dp(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 ps(t,e,n){const r=Bo(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 Ho(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 $p(t,e){const n=Bo(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=ps(e,i,a),c=!1;if(l!=="content"&&!us.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"?Ho(t,n[l]):c&&Ho(t,n.content),{rejected:c}}const Uo=22,qo=[1,2,5,10,20,50,100,200,500,1e3];function Lp(t,e=64){const n=t*3.7795275590551185;for(const r of qo)if(r*n>=e)return r;return qo[qo.length-1]}function Np(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 Fp(t){return Math.round(t*1e3)/1e3}function zp(t,e,n){if(e<t||n<=0)return[];const o=Np(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=Fp(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 fs=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Wo=[{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"]},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{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:"裁剪时保留框内的哪一部分,CSS object-position 值原样生效(如 center 20% 让画面上移、保住证件照头顶);只在发生裁切时可见,缺省按 50% 50% 居中。含分号、引号、url() 的值会被整条丢弃"}]},{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-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"]},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],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-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 Nt(t){for(const e of Wo){const n=e.items.find(r=>r.key===t);if(n)return n.tip??""}return""}function Bp(t,e){const n=t.trim().toLowerCase();return n?e.some(r=>r.toLowerCase().includes(n)):!0}function Hp(t){const e=[],n=new Set;for(const r of Wo){const o=r.items.filter(i=>Bp(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 hs(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 Up(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 qp={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:[]};function gs(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 Wp(t){const e=t.printElementType.type,n=qp[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(...gs(a.type,i,l,o))}return[...n,...r]}const ht={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级"}]},jp=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),Gp=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function jo(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(Gp.has(c))throw new Error(`不允许使用关键字: ${c}`);if(jp.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 Go(t){return new Vp(t).parse()}class Vp{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 ms=20,Yp=8;function Ce(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 Xp(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 Ft(t){return!Number.isFinite(t)||Number.isInteger(t)||Math.abs(t)>=1e15?t:Number(t.toPrecision(12))}function zt(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 Vo(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?Ft(t):Math.round(o)/r}function Yo(t,e){const n=Ce(t),r=Ce(e),o=n+r;return Vo(o,Math.max(zt(n),zt(r)))}function Xo(t,e){const n=Ce(t),r=Ce(e),o=n-r;return Vo(o,Math.max(zt(n),zt(r)))}function bs(t,e){const n=Ce(t),r=Ce(e),o=n*r;return Vo(o,zt(n)+zt(r))}function vs(t,e){const n=Ce(t),r=Ce(e);return r===0?0:Ft(n/r)}function Kp(t,e){const n=Ce(t),r=Ce(e);return r===0?0:Ft(n%r)}function Jp(t){if(t==null)return 2;const e=Math.trunc(Ce(t,2));return Number.isFinite(e)?Math.min(Math.max(e,-ms),ms):2}function Xn(t,e,n){const r=Ce(t,0),o=Jp(e);if(r===0)return 0;if(Math.abs(r)>=1e21)return Ft(r);const i=Math.max(o,0)+Yp,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return Ft(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 v=p*f;return Ft(o>=0?Number(v)/10**o:Number(v)*10**-o)}const Ko={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},Zp=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),Qp=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function be(t,e,n={}){switch(t.type){case"num":return t.value;case"str":return t.value;case"bool":return t.value;case"ident":return ef(t.name,e);case"binary":return tf(t,e,n);case"unary":return nf(t,e,n);case"ternary":return be(t.cond,e,n)?be(t.consequent,e,n):be(t.alternate,e,n);case"member":return af(t,e,n);case"call":return sf(t,e,n);case"array":return t.elements.map(r=>be(r,e,n));case"object":return Object.fromEntries(t.properties.map(r=>[r.key,be(r.value,e,n)]))}}function ef(t,e,n){if(Object.prototype.hasOwnProperty.call(e,t))return e[t];if(Object.prototype.hasOwnProperty.call(Ko,t))return Ko[t];throw new Error(`未定义的标识符: ${t}`)}function tf(t,e,n){const r=be(t.left,e,n),o=be(t.right,e,n);switch(t.op){case"+":return of(r,o)?Yo(r,o):rf(r,o);case"-":return Xo(r,o);case"*":return bs(r,o);case"/":return vs(r,o);case"%":return Kp(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 nf(t,e,n){const r=be(t.arg,e,n);switch(t.op){case"-":return Xo(0,r);case"+":return Ce(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${t.op}`)}}function rf(t,e){return`${t==null?"":String(t)}${e==null?"":String(e)}`}function of(t,e){const n=ys(t),r=ys(e);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function ys(t){return t==null||t===""?"neutral":Xp(t)?"num":"other"}function af(t,e,n){const r=be(t.object,e,n);if(r==null)throw new Error("无法访问空值的属性");if(Zp.has(t.property))throw new Error(`禁止访问属性: ${t.property}`);return r[t.property]}function sf(t,e,n){if(t.callee.type==="ident"&&Qp.has(t.callee.name)){const o=Ko[t.callee.name],i=t.args.map(a=>be(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=>be(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=>be(i,e,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(e,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function lf(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=jo(l),s=Go(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 cf(t,e,n={}){let r="";for(const o of t.parts)if(o.type==="text")r+=o.value;else{const i=be(o.expression,e,n);r+=String(i??"")}return r}function xs(t,e={}){const n=lf(t);return r=>cf(n,r,e)}function dn(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 ws(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 Es(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()))}function Ss(t){const e=Number(t);if(isNaN(e))return String(t);if(e===0)return"零元整";const n=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],r=["","拾","佰","仟"],o=["","万","亿"],i=e<0?"负":"",a=Math.abs(e),[l,c]=a.toFixed(2).split("."),s=parseInt(l,10);let d="";if(s>0){const f=l.split("").reverse();let h=0,m=0,v=!1;for(let x=0;x<f.length;x++){const w=parseInt(f[x],10),y=r[h%4],S=o[Math.floor(h/4)];w===0?m!==0&&(v=!0):(v&&(d="零"+d,v=!1),d=n[w]+y+d,m=w),h%4===3&&h>0&&(d=S+d),h++}d+="元"}const p=parseInt(c[0],10),u=parseInt(c[1],10);return p===0&&u===0?d+="整":(p>0&&(d+=n[p]+"角"),u>0&&(d+=n[u]+"分")),i+d}function _s(t,e,n){return t?e:n}function Jo(t,e){return t.reduce((n,r)=>n+(Number(dn(r,e))||0),0)}function Ts(t,e){return t.length===0?0:Jo(t,e)/t.length}function ks(t,e){return t.length}function Ms(t,e){return t.length===0?0:Math.min(...t.map(n=>Number(dn(n,e))||0))}function Cs(t,e){return t.length===0?0:Math.max(...t.map(n=>Number(dn(n,e))||0))}function As(...t){return t.reduce((e,n)=>Yo(e,n),0)}function Os(...t){return t.length===0?0:t.slice(1).reduce((e,n)=>Xo(e,n),Yo(t[0],0))}function Ps(...t){return t.length===0?0:t.reduce((e,n)=>bs(e,n),1)}function Rs(t,e){return vs(t,e)}function Is(t,e){return Xn(t,e,"half-up")}function Kn(t,e){return Xn(t,e,"up")}function Jn(t,e){return Xn(t,e,"down")}function Ds(t,e){return Xn(t,e,"half-even")}class df{constructor(){this.functions={}}registerFunction(e,n){this.functions[e]=n}evaluate(e,n){const r=jo(e),o=Go(r);return be(o,n,this.functions)}render(e,n){return xs(e,this.functions)(n)}}const Zo=new df,uf={MONEY:ws,DATE:Es,UPPER:Ss,IF:_s,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:As,SUB:Os,MUL:Ps,DIV:Rs,ROUND:Is,ROUNDUP:Kn,CEIL:Kn,ROUNDDOWN:Jn,FLOOR:Jn,ROUNDBANK:Ds};for(const[t,e]of Object.entries(uf))Zo.registerFunction(t,e);function pf(t,e,n){switch(t.toUpperCase()){case"SUM":return Jo(n,e);case"AVG":return Ts(n,e);case"COUNT":return ks(n);case"MIN":return Ms(n,e);case"MAX":return Cs(n,e);default:return 0}}function ff(t,e){return Zo.evaluate(t,e)}function gt(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(pf(c,d,n))}),`{${a}}`});try{return Zo.render(r,e)}catch{return t}}function $s(t,e,n,r){const o={...er(),...e??{}},i=JSON.parse(JSON.stringify(t));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>Qo(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>Qo(l,o,n))),i.elements=i.elements.map(l=>Qo(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 Qo(t,e,n){const r={...t,options:{...t.options}};if(typeof r.options.formatter=="string"){const i=r.options.formatter;ei(i)?r.options.rawFormatter=i:r.options.formatter=gt(i,e)}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let i=r.options.src;i.includes("{")&&(i=gt(i,e)),i&&n&&i.startsWith("/")&&(i=n.replace(/\/+$/,"")+i),r.options.src=i}return(r.type==="table"||r.printElementType?.type==="table")&&gf(r,e),r}function hf(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 gf(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"?hf(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 v=l(m);s.push(Qn(h,x=>Zn(x,v))),d.push(v)}continue}if(o==="dynamic"&&h.type==="subtotal"){const m=Qn(h,v=>Zn(v,{rows:c,...e}),!0);p.push(m),s.push(m);continue}if(o==="dynamic"&&h.type==="summary"){const m=Qn(h,v=>Zn(v,{rows:c,...e}));u.push(m),s.push(m);continue}s.push(Qn(h,m=>Zn(m,e)))}n._renderRows=s,n._repeatHeaderCount=mf(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=e}function Zn(t,e){const n=t.formatter;return n?ei(n)?n:gt(n,e):""}function Qn(t,e,n=!1){return{type:t.type,height:t.height??8,cells:t.cells.map(r=>({content:r.merged?"":e(r),...(n||ei(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,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 mf(t){const e=bf(t);return e===0||!t.slice(0,e).some(r=>r.repeatOnPage===!0)?0:yf(t,e)}function bf(t){let e=0;for(const n of t){if(n?.type!=="header")break;e++}return e}function vf(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 yf(t,e){for(let n=e;n>=1;n--)if(vf(t,n))return n;return 1}const un=t=>String(t).padStart(2,"0");function er(t=new Date,e={}){return{printDate:`${t.getFullYear()}-${un(t.getMonth()+1)}-${un(t.getDate())}`,printTime:`${un(t.getHours())}:${un(t.getMinutes())}:${un(t.getSeconds())}`,pageIndex:e.pageIndex??1,totalPages:e.totalPages??1}}function ei(t){return typeof t=="string"&&/\b(pageIndex|totalPages)\b/.test(t)}function ti(t,e=new Date){const{printDate:n,printTime:r}=er(e);return t.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function pn(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}")${xf(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return e.length?`${e.join("")}
2
+ `:""}function xf(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 ni=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function ri(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Ls(t){const e=t?.trim();return e?[e.includes(",")?e:`"${e.replace(/"/g,"")}"`,...ni].join(", "):ni.join(", ")}const mt={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}},wf=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function Bt(t){return wf.has(t)}function ve(t){const e=Bt(t.paperSize),n=t.paperSize==="CUSTOM"||e?{width:t.customWidth??mt[t.paperSize].width,height:t.customHeight??mt[t.paperSize].height}:mt[t.paperSize];return t.orientation==="landscape"&&!e?{width:n.height,height:n.width}:{...n}}function oi(t){if(Bt(t.paperSize)||t.tiling?.enabled===!0)return ve(t);const n=ve(t);return t.outputRotation===90||t.outputRotation===270?{width:n.height,height:n.width}:n}function ii(t){return Bt(t.paperSize)||t.tiling?.enabled===!0?0:t.outputRotation??0}function qe(t){return Bt(t.paperSize)}function z(t){return`${t}mm`}function ai(t,e){const n=oi(t);return e&&e>0&&qe(t)?{width:n.width,height:e}:n}function Ns(t,e){const n=ve(t);return e&&e>0&&qe(t)?{width:n.width,height:e}:n}function Fs(){return`
3
+ /* ── 全局重置 ── */
4
+ * { margin: 0; padding: 0; box-sizing: border-box; }
5
+
6
+ /* 打印必须保留元素背景色(Chromium 默认剔除背景,需显式声明) */
7
+ * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
8
+
9
+ body { font-family: ${ni.join(", ")}; }
10
+
11
+ /* ── 屏幕预览:灰底 + 纸张阴影/页间距;打印时去除 ── */
12
+ @media screen {
13
+ body { background: #e9ebee; }
14
+ .print-page { margin: 12px auto; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18); }
15
+ }
16
+ @media print {
17
+ body { background: #fff; }
18
+ .print-page { margin: 0; box-shadow: none; }
19
+ }
20
+ `}function zs(){return`
21
+ /* ── 水印层:覆盖整页、位于所有内容之下(显式矢量瓦片,禁止用 CSS 平铺背景:
22
+ Chromium 会把它编译成 PDF 平铺图案,出纸链路的 RIP 会忽略图案矩阵导致水印放大/错位) ── */
23
+ .watermark-layer {
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ width: 100%;
28
+ height: 100%;
29
+ z-index: 0;
30
+ pointer-events: none;
31
+ overflow: hidden;
32
+ }
33
+ /* 单块水印瓦片:位置/尺寸由 core 的瓦片网格给出(mm) */
34
+ .watermark-tile {
35
+ position: absolute;
36
+ pointer-events: none;
37
+ }
38
+ `}function Bs(){return`
39
+ /* ── 元素通用定位 ── */
40
+ .print-element {
41
+ position: absolute;
42
+ overflow: hidden;
43
+ }
44
+
45
+ /* ── 表格样式 ── */
46
+ .print-table {
47
+ width: 100%;
48
+ border-collapse: collapse;
49
+ table-layout: fixed;
50
+ }
51
+ .print-table th,
52
+ .print-table td {
53
+ border: 1px solid #ccc;
54
+ padding: 2mm 3mm;
55
+ word-break: break-all;
56
+ overflow: hidden;
57
+ }
58
+ .print-table thead th {
59
+ background-color: #f5f5f5;
60
+ font-weight: bold;
61
+ }
62
+
63
+ /* ── 测量模式 ── */
64
+ .measure-mode .print-page {
65
+ height: auto;
66
+ min-height: auto;
67
+ overflow: visible;
68
+ }
69
+ .measure-mode .content-area {
70
+ height: auto;
71
+ overflow: visible;
72
+ }
73
+ `}function Hs(t){return`
74
+ /* ── 打印纸张:浏览器原生打印按此尺寸分页(Playwright page.pdf 以显式宽高为准,无副作用) ── */
75
+ @page { size: ${z(t.width)} ${z(t.height)}; margin: 0; }
76
+ `}function Us(t,e,n){const r=`
77
+ /* ── 出纸转子:设计稿整页旋转 ${n}° 填入出纸纸张 ── */
78
+ .print-page-rotor {
79
+ position: absolute;
80
+ top: 0;
81
+ left: 0;
82
+ width: ${z(t.width)};
83
+ height: ${z(t.height)};
84
+ padding: ${z(e.top)} ${z(e.right)} ${z(e.bottom)} ${z(e.left)};
85
+ box-sizing: border-box;
86
+ transform-origin: 0 0;
87
+ }`;if(n===0)return r.trim();const i={90:`translate(${z(t.height)}, 0mm) rotate(90deg)`,180:`translate(${z(t.width)}, ${z(t.height)}) rotate(180deg)`,270:`translate(0mm, ${z(t.width)}) rotate(270deg)`}[n];return[r.trim(),`.print-page-rotor-${n} {
88
+ transform: ${i};
89
+ }`].join(`
90
+ `)}function qs(t,e,n,r){const{top:o,right:i,bottom:a,left:l}=t.margins,c=r?"0":`${z(o)} ${z(i)} ${z(a)} ${z(l)}`;return`
91
+ /* ── 纸张页面 ── */
92
+ ${n} {
93
+ width: ${z(e.width)};
94
+ min-height: ${z(e.height)};
95
+ background: ${t.pageBackground??"#fff"};
96
+ padding: ${c};
97
+ position: relative;
98
+ page-break-after: always;
99
+ overflow: hidden;
100
+ }
101
+ .print-page:last-child {
102
+ page-break-after: auto;
103
+ }
104
+ `}function Ws(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
+ /* ── 页眉 ── */
106
+ ${n}.page-header {
107
+ width: ${z(c)};
108
+ height: ${z(a)};
109
+ position: relative;
110
+ }
111
+
112
+ /* ── 页脚:绝对定位固定在页面底部(内容不足时不随文档流上浮) ──
113
+ 用显式 top 定位到「纸高 - 下边距 - 页脚高」,保证下边距生效、
114
+ 与设计器 CanvasPaper 的三区几何一致。
115
+ 绝对定位的包含块是 padding box 外缘(= 纸面),left 须显式补左边距。 */
116
+ ${n}.page-footer {
117
+ width: ${z(c)};
118
+ height: ${z(l)};
119
+ position: absolute;
120
+ top: ${z(e.height-i-l)};
121
+ left: ${z(o)};
122
+ }
123
+
124
+ /* ── 内容区 ── */
125
+ ${n}.content-area {
126
+ width: ${z(c)};
127
+ position: relative;
128
+ overflow: visible;
129
+ }
130
+ `}function Ef(){return[Fs(),zs(),Bs()].join("").trim()}function Sf(t,e){return Hs(ai(t,e)).trim()}function _f(t,e,n){const r=ii(t),o=r!==0,i=ai(t,n),a=Ns(t,n),l=e?`${e}.print-page`:".print-page",c=e?`${e} `:"";return[qs(t,i,l,o),Ws(t,a,c),...o?[Us(a,t.margins,r)]:[]].join("").trim()}function fn(t,e){const n=ii(t),r=n!==0,o=ai(t,e),i=Ns(t,e);return[Hs(o),Fs(),qs(t,o,".print-page",r),zs(),Ws(t,i,""),Bs(),...r?[Us(i,t.margins,n)]:[]].join("").trim()}const si=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function Tf(t,e){if(!qe(t))return`${fn(t)}
131
+ ${si}`;const{bottom:n}=t.margins,r=t.footer?.height??0,o=ve(t).width,i=fn(t,e[0]?.heightMm),a=e.map((l,c)=>{const s=l.heightMm,d=[`@page copy${c} { size: ${z(o)} ${s?z(s):"auto"}; margin: 0; }`,`.print-copy-${c} { page: copy${c}; }`];return s&&(d.push(`.print-copy-${c} .print-page { min-height: ${z(s)}; }`),d.push(`.print-copy-${c} .page-footer { top: ${z(s-n-r)}; }`)),d.join(`
132
+ `)}).join(`
133
+ `);return`${i}
134
+ ${a}
135
+ ${si}`}function kf(t){return`
136
+ /* ── 拼版纸张:@page 尺寸 = 目标纸。服务端/客户端链路以 paperMm 显式定尺寸、不看这里,
137
+ 但浏览器链路只看 @page,故这条是硬需求 ── */
138
+ @page { size: ${z(t.sheet.width)} ${z(t.sheet.height)}; margin: 0; }
139
+
140
+ /* ── 一张目标纸 ── */
141
+ .print-sheet {
142
+ width: ${z(t.sheet.width)};
143
+ height: ${z(t.sheet.height)};
144
+ position: relative;
145
+ overflow: hidden;
146
+ break-after: page;
147
+ page-break-after: always;
148
+ }
149
+ .print-sheet:last-child { break-after: auto; page-break-after: auto; }
150
+
151
+ /* ── 一格:绝对定位,位置由 tilePosition() 以行内 style 给出 ── */
152
+ .print-tile {
153
+ position: absolute;
154
+ width: ${z(t.tile.width)};
155
+ height: ${z(t.tile.height)};
156
+ overflow: hidden;
157
+ }
158
+ /* 防御性声明:绝对定位 + overflow:hidden 容器内的后代不产生分页点,当前布局下无实际作用;
159
+ 若将来改用 flex/grid 布局,格内整页会重新参与分页,故保留 */
160
+ .print-tile > .print-page { break-after: auto; page-break-after: auto; }
161
+
162
+ @media screen {
163
+ .print-sheet { margin: 12px auto; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18); }
164
+ /* 必需:抵消标签 CSS 的 @media screen{.print-page{margin:12px auto}},
165
+ 否则设计器预览错位 3.17mm、与出纸不一致 */
166
+ .print-tile > .print-page { margin: 0; box-shadow: none; }
167
+ }
168
+ `}function li(t,e,n,r,o){const i=["position:absolute",`left:${z(t)}`,`top:${z(e)}`,`width:${z(n)}`];return r!==void 0&&r>0&&i.push(`height:${z(r)}`),o!==void 0&&i.push(`z-index:${o}`),i.join(";")+";"}const js=25.4/96,Q={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},Mf={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function Gs(t,e,n){const r=typeof t=="number"&&Number.isFinite(t)?t:e;return Math.max(n,Math.round(r))}function Cf(t){return{width:Gs(t?.tileWidth,Q.tileWidth,Q.minTileWidth),height:Gs(t?.tileHeight,Q.tileHeight,Q.minTileHeight)}}function Af(t){return t?!t.mode||t.mode==="fixed"?!!t.content&&t.content.trim().length>0:!!t.binding&&t.binding.trim().length>0:!1}function Of(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={...er(),...n,...i};let l;if(o.includes("{"))l=gt(o,a);else{try{l=ff(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=dn(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=t.testData??`[${t.binding}]`}return t.timestamp&&r&&(r=`${r} ${Pf(t.format)}`),r}function hn(t){return String(t).padStart(2,"0")}function Pf(t){const e=t&&t.trim()?t:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:hn(n.getMonth()+1),DD:hn(n.getDate()),HH:hn(n.getHours()),mm:hn(n.getMinutes()),ss:hn(n.getSeconds())};return e.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function tr(t){return Math.round(t*1e4)/1e4}function Rf(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vs(t,e,n,r){if(!Af(t))return null;const o=Of(t,e,r);if(!o)return null;const i=Cf(t),a=tr(i.width*js),l=tr(i.height*js),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:tr(f*a),topMm:tr(u*l),widthMm:a,heightMm:l});return{text:o,color:t?.color||Q.color,rotate:t?.rotate??Q.rotate,opacity:t?.opacity??Q.opacity,fontSizePx:Q.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function If(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})">${Rf(t.text)}</text></svg>`}function Ys(t,e,n,r){const o=Vs(t,e,n,r);if(!o)return"";const i=o.tiles.map(a=>If(o,a)).join(`
169
+ `);return`
170
+ <div class="watermark-layer" style="opacity:${o.opacity}">
171
+ ${i}
172
+ </div>`}function nr(t){return t.options?.pagination??t.pagination}function Df(t){return t.options?.tablePagination??t.tablePagination}const rr=2;function or(t){return t.type==="table"||t.printElementType?.type==="table"}function ci(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 $f(t,e){const n=new Map;let r=null,o=-1;for(const i of t){if(or(i)){r=i.id,o=ci(i),n.set(i.id,[]);continue}if(e?.has(i.id))continue;const a=i.options?.top??0;r&&a>=o&&n.get(r).push(i.id)}return n}function Lf(t,e,n,r){const o=ci(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 Xs(t,e){return Math.max(t.options?.height??0,e.get(t.id)?.measuredHeight??0)}function Nf(t,e,n){const r=new Map;for(const d of n.values()){if(d.length<2)continue;const p={anchorId:d[0].id,ids:d.map(u=>u.id),forceFirstPage:d.some(u=>nr(u)?.pageable===!1)};for(const u of d)r.set(u.id,p)}const o=t.filter(d=>!or(d)&&!d.options?.groupId&&nr(d)?.pageable!==!1),i=new Map;o.forEach(d=>i.set(d.id,d.id));const a=d=>{let p=d;for(;i.get(p)!==p;)p=i.get(p);let u=d;for(;i.get(u)!==p;){const f=i.get(u);i.set(u,p),u=f}return p},l=(d,p)=>{const u=a(d),f=a(p);u!==f&&i.set(f,u)},c=[];for(const d of o){const p=d.options?.top??0;for(let f=c.length-1;f>=0;f--)c[f].bottom<=p&&c.splice(f,1);const u=p+Xs(d,e);for(const f of c)f.bottom>p&&l(d.id,f.id);c.push({id:d.id,top:p,bottom:u})}const s=new Map;for(const d of o){const p=a(d.id),u=s.get(p);u?u.push(d.id):s.set(p,[d.id])}for(const d of s.values()){if(d.length<2)continue;const p={anchorId:d[0],ids:d,forceFirstPage:!1};for(const u of d)r.set(u,p)}return r}function Ks(t,e){const n=ve(t),{top:r,bottom:o}=t.margins,i=t.header?.height??0,a=t.footer?.height??0,l=qe(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(($,U)=>s.set($.id,U));const d=[...t.elements].sort(($,U)=>{const V=$.options?.top??0,G=U.options?.top??0;if(V!==G)return V-G;const Y=$.options?.zIndex??0,ae=U.options?.zIndex??0;return Y!==ae?Y-ae:(s.get($.id)??0)-(s.get(U.id)??0)}),p=new Set,u=new Map;for(const $ of d){if(or($))continue;const U=$.options?.groupId;if(!U)continue;p.add($.id);const V=u.get(U);V?V.push($):u.set(U,[$])}const f=$f(d,p),h=new Map;for(const[$,U]of f)for(const V of U)h.set(V,$);const m=new Map;for(const $ of d)m.set($.id,$);const v=Nf(d,e,u),x=[];let w=[],y=c-rr,S=!1;function D($){return S?R():$.options?.top??0}function R(){return Math.max(0,A()-y)}function A(){return c-rr}let k=!1;function _(){x.push(k?{pageIndex:x.length,sections:[...w],overflow:!0}:{pageIndex:x.length,sections:[...w]})}function M($){$>c&&(k=!0)}function O($=!1){if(w.length===0){k=k||$;return}_(),w=[],y=c-rr,S=!0,k=!1}let C=0;for(;C<d.length;){const $=d[C];if(h.has($.id)){C++;continue}const U=v.get($.id);if(U&&U.anchorId!==$.id){C++;continue}if(nr($)?.pageable===!1||U?.forceFirstPage){if(U)for(const V of U.ids)w.push({elementId:V,type:"element",renderTop:m.get(V)?.options?.top??0});else w.push({elementId:$.id,type:"element",renderTop:D($)});C++;continue}or($)?C=ie($,e,C):U?C=N(U,C):C=I($,e,d,C)}return w.length>0&&_(),x.length===0&&x.push({pageIndex:0,sections:[]}),x;function I($,U,V,G){const Y=U.get($.id)?.measuredHeight??$.options?.height??0;if(Y<=y){const pe=S?R():$.options?.top??0;if(M(pe+Y),w.push({elementId:$.id,type:"element",renderTop:D($)}),y-=Y,nr($)?.keepWithNext&&G+1<V.length){const W=V[G+1],ee=U.get(W.id)?.measuredHeight??W.options?.height??0;if(Y+ee>A())return G+1;ee>y&&(w.pop(),O(),w.push({elementId:$.id,type:"element",renderTop:D($)}),y-=Y)}return G+1}return O(),(S?R():$.options?.top??0)+Y>c&&(k=!0),w.push({elementId:$.id,type:"element",renderTop:D($)}),y-=Y,G+1}function N($,U){const V=$.ids.map(ee=>m.get(ee)).filter(ee=>!!ee);let G=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY;for(const ee of V){const de=ee.options?.top??0;G=Math.min(G,de),Y=Math.max(Y,de+Xs(ee,e))}const ae=Math.max(Y-G,0),pe=()=>{const ee=S?R()-G:0;M(G+ee+ae);for(const de of V)w.push({elementId:de.id,type:"element",renderTop:(de.options?.top??0)+ee});y-=ae};return ae<=y?(pe(),U+1):(O((S?0:G)+ae>c),pe(),U+1)}function ie($,U,V){const G=$.options??{},Y=G._renderRows??[],ae=U.get($.id)?.measuredRowHeights??[],pe=(G._subtotalTemplates?.length??0)>0,W=(G._summaryRows?.length??0)>0,ee=pe?Js(Y,ae,"subtotal"):0,de=W?Js(Y,ae,"summary"):0,Te=se=>pe&&se.type==="subtotal"||W&&se.type==="summary",we=Y.filter(se=>!Te(se)),Fe=ae.filter((se,te)=>!Te(Y[te]));G._renderRows=we;const me=Math.min(we.length,Fe.length),Qt=G._repeatHeaderCount??0,Nn=U.get($.id)?.repeatHeaderHeight??ae.slice(0,Qt).reduce((se,te)=>se+te,0),Fn=c-rr;if(Nn>Fn)throw new Error(`表格 ${$.id} 的重复表头高度 (${Nn.toFixed(1)}mm) 超过页面可用高度 (${Fn.toFixed(1)}mm),请减少重复表头行`);if(me===0)return w.push({elementId:$.id,type:"table-slice",startRow:0,endRow:0,summary:de>0,renderTop:D($)}),y-=de,Ne($),V+1;const en=Fe.slice(0,me).reduce((se,te)=>se+te,0)+ee+de;if(Df($)?.enabled===!1)return en>y&&w.length>0&&O(),w.push({elementId:$.id,type:"table-slice",startRow:0,endRow:me,subtotal:ee>0,summary:de>0,renderTop:D($)}),y-=en,Ne($),V+1;const K=Ff(we,me);let tt=0,Ee=!0,nt=D($);for(const se of K){const te=Fe.slice(se.start,se.end).reduce((ho,zn)=>ho+zn,0);if(te+ee<=y){y-=te;continue}se.start>tt&&(w.push({elementId:$.id,type:"table-slice",startRow:tt,endRow:se.start,subtotal:ee>0,...!Ee&&Qt>0?{repeatHeader:!0}:{},renderTop:nt}),Ee=!1,tt=se.start),O(),nt=D($),Ee||(y-=Nn),y-=te}if(tt<me&&w.push({elementId:$.id,type:"table-slice",startRow:tt,endRow:me,subtotal:ee>0,...!Ee&&Qt>0?{repeatHeader:!0}:{},renderTop:nt}),de>0)if(de<=y){const se=w.length-1,te=w[se];te&&te.type==="table-slice"&&te.elementId===$.id?(w[se]={...te,summary:!0},y-=de):(O(),w.push({elementId:$.id,type:"table-slice",startRow:me,endRow:me,summary:!0,renderTop:0}),y-=de)}else O(),w.push({elementId:$.id,type:"table-slice",startRow:me,endRow:me,summary:!0,renderTop:0}),y-=de;return Ne($),V+1}function Ne($,U){const V=f.get($.id)??[];if(V.length===0)return;const G=Lf($,V,t),Y=$.options??{};if(G<=y){const ae=w.length-1,pe=w[ae];if(pe&&pe.type==="table-slice"&&pe.elementId===$.id){w[ae]={...pe,type:"flow-group",followElementIds:V,groupTop:pe.renderTop??Y.top??0},y-=G;return}}O(),w.push({elementId:$.id,type:"flow-group",startRow:0,endRow:0,followElementIds:V,groupTop:0}),y-=G}}function Ff(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 Js(t,e,n){let r=0;for(let o=0;o<t.length;o++)t[o]?.type===n&&(r+=e[o]??0);return r}function di(t){return{...t.data??{},pageIndex:t.pageIndex,totalPages:t.totalPages}}function zf(t){return Array.isArray(t)?t[0]??{}:t??{}}function ir(t,e,n,r){const o=pn(t.fonts)+fn(t,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:e.length,l={codeRenderer:r?.codeRenderer,pageHeightMm:r?.pageHeightMm};return i?Bf(t,o,l,n):Hf(t,e,o,a,l,n)}function Bf(t,e,n,r){const i=gi(t).width-t.margins.left-t.margins.right,a=t.elements.map(s=>lr(s,!0,void 0,void 0,n)).join(`
173
+ `),l=fi(t.header?.elements??[],i,0,0,n);let c=`<!DOCTYPE html>
174
+ <html lang="zh-CN">
175
+ <head>
176
+ <meta charset="UTF-8">
177
+ <style>${e}</style>
178
+ </head>
179
+ <body class="measure-mode">
180
+ <section class="print-page" data-measure-page="0">
181
+ ${Ys(t.watermark,r,gi(t))}
182
+ <div class="page-header">${l}</div>
183
+ <div class="content-area" style="height:auto;overflow:visible;">
184
+ ${a}
185
+ </div>
186
+ </section>
187
+ </body>
188
+ </html>`;return c=ti(c),c}function ar(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 Uf(t,c,s,a,r,n,o?.pageClass)}).join(`
189
+ `);return ti(l)}function sr(t,e,n){const r=`<!DOCTYPE html>
190
+ <html lang="zh-CN">
191
+ <head>
192
+ <meta charset="UTF-8">
193
+ <style>${t}</style>
194
+ </head>
195
+ <body${n?` class="${n}"`:""}>
196
+ ${e}
197
+ </body>
198
+ </html>`;return ti(r)}function Hf(t,e,n,r,o,i){const a=ar(t,e,i??{},o);return sr(n,a,qe(t)?"continuous":void 0)}function Uf(t,e,n,r,o,i,a){const l=gi(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:zf(i)},p=qf(t,d),u={...o,pageVars:d},f=fi(p.header?.elements??[],s,n,r,u),h=fi(p.footer?.elements??[],s,n,r,u);let m=e.sections.map(y=>jf(y,p,u)).join(`
199
+ `);m=m.replace(/\{pageIndex\}/g,String(n)),m=m.replace(/\{totalPages\}/g,String(r));const v=`
200
+ ${Ys(t.watermark,i,c,{pageIndex:n,totalPages:r})}
201
+ <div class="page-header">${f}</div>
202
+ <div class="content-area">
203
+ ${m}
204
+ </div>
205
+ <div class="page-footer">${h}</div>`,x=ii(t),w=x!==0?`<div class="print-page-rotor print-page-rotor-${x}">${v}</div>`:v;return`<section class="print-page${a?` ${a}`:""}" data-page="${n}">
206
+ ${w}
207
+ </section>`}function qf(t,e){if(!Wf(t))return t;const n=di(e),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:gt(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 Wf(t){return[t.elements,t.header?.elements,t.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function ui(t,e){const n=t.rawFormatter;return typeof n=="string"&&n!==""&&e?.pageVars?gt(n,di(e.pageVars)):t.content}function jf(t,e,n){const r=hi(e,t.elementId);return r?t.type==="table-slice"?eh(r,t,n):t.type==="flow-group"?th(r,t,e,n):lr(r,!1,void 0,t.renderTop,n):`<!-- element not found: ${t.elementId} -->`}const Zs={top:"flex-start",middle:"center",bottom:"flex-end"},Gf={left:"flex-start",center:"center",right:"flex-end"};function Qs(t){const e=[],n=t._fitFontSize===void 0?t.fontSize:Co(t._fitFontSize);return n&&e.push(`font-size:${n}pt`),t.fontFamily&&e.push(`font-family:${ri(Ls(t.fontFamily))}`),t.fontWeight&&e.push(`font-weight:${t.fontWeight}`),t.color&&e.push(`color:${t.color}`),t.backgroundColor&&e.push(`background-color:${t.backgroundColor}`),t.lineHeight&&e.push(`line-height:${t.lineHeight}pt`),t.letterSpacing&&e.push(`letter-spacing:${t.letterSpacing}pt`),t.verticalAlign&&(t.textAlign==="justify"?e.push(`display:flex;flex-direction:column;justify-content:${Zs[t.verticalAlign]??"flex-start"}`):(e.push(`display:flex;align-items:${Zs[t.verticalAlign]??"flex-start"}`),e.push(`justify-content:${Gf[t.textAlign??"left"]??"flex-start"}`))),t.textAlign&&e.push(`text-align:${t.textAlign}`),t.textAlign==="justify"&&e.push("text-align-last:justify"),e.length?e.join(";")+";":""}function Vf(t){return t.longTextIndent?`text-indent:${t.longTextIndent}em;`:""}const Yf=/[;"'<>\\(){}\[\]@!#]/;function el(t){const e=(t??"").trim();return!e||e.length>64||Yf.test(e)?"":`object-position:${ri(e)};`}function tl(t,e){return t==="autoHeight"?"overflow:visible;":e.wordWrap===!1?"white-space:nowrap;text-overflow:ellipsis;":""}function Xf(t,e,n,r){if(t!=="shrink")return"";const o=ln(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${Ye(e)}" data-fit-base="${n}" data-fit-min="${o}"`}function lr(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=qn(d,i),f=n??li(a,l,c,p==="autoHeight"?void 0:s,i.zIndex),h=Qa(d,i);let m=f;if(h?.all&&(m+=`border:${h.all.borderWidth} ${h.all.borderStyle} ${h.all.borderColor};`),h)for(const w of jn){const y=h.edges[w];y&&(m+=`border-${w}:${y.borderWidth} ${y.borderStyle} ${y.borderColor};`)}const v=e?` data-measure-id="${t.id}"`:"",x=Xf(p,t.id,i.fontSize??12,i);switch(d){case"table":return Qf(t,e,v,o);case"image":return`<div class="print-element" style="${m}"${v}>
208
+ <img src="${Ye(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${el(i.objectPosition)}" />
209
+ </div>`;case"barcode":case"qrcode":{const w=String(i.formatter??i.testData??"").trim();return`<div class="print-element" style="${m}"${v}>
210
+ ${nl(w,d,i,{fallback:`<span>${Ye(w)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
211
+ </div>`}case"hline":return`<div class="print-element" style="${m};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${v}></div>`;case"vline":return`<div class="print-element" style="${m};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${v}></div>`;case"rect":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${v}></div>`;case"oval":return`<div class="print-element" style="${m};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${v}></div>`;case"longText":return`<div class="print-element" style="${m}${Qs(i)}${Vf(i)}${tl(p,i)}"${v}${x}>${Ye(i.formatter??i.testData??"")}</div>`;case"html":return`<div class="print-element" style="${m}"${v}>${i.testData??i.title??""}</div>`;default:return`<div class="print-element" style="${m}${Qs(i)}${tl(p,i)}"${v}${x}>${Ye(i.formatter??i.testData??"")}</div>`}}function nl(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,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof n.fontSize=="number"?n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?$t(r.targetWidthMm,l):void 0,targetHeightMm:s?$t(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return Kf(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 Kf(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 Jf(t,e){const n=[],r=t.fittedFontSize??t.fontSize??e.tableDefaultFontSize,o=t.color??e.tableDefaultColor,i=t.padding??e.tableDefaultPadding??1;r&&n.push(`font-size:${r}pt`),t.fontFamily&&n.push(`font-family:${ri(Ls(t.fontFamily))}`),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":"word-break:break-all");const a=t.borders??{};for(const l of["top","right","bottom","left"]){const c=a[l];n.push(c?`border-${l}:${c.width}pt ${c.style} ${c.color}`:`border-${l}:none`)}return n.join(";")}function bt(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 v=l===void 0?h.rowspan??1:Math.max(1,Math.min(h.rowspan??1,l-d)),x=`${v>1?` rowspan="${v}"`:""}${h.colspan>1?` colspan="${h.colspan}"`:""}`,w=m;let y;if(h.cellType==="barcode"||h.cellType==="qrcode"){const S=ui(h,i);y=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${nl(S,h.cellType,h,{fallback:Ye(S),codeRenderer:i?.codeRenderer,fit:h.fit,maxWidth:h.maxWidth,maxHeight:h.maxHeight,printerDpi:h.printerDpi,targetWidthMm:Xa(r.tableColWidths??[],m,h,s),targetHeightMm:Ao(t,d,h,s)})}</div>`}else if(h.cellType==="image"){const S=h.fit||"contain",D=h.maxWidth?`max-width:${h.maxWidth}mm;`:"max-width:100%;",R=h.maxHeight?`max-height:${h.maxHeight}mm;`:"max-height:100%;";y=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${Ye(ui(h,i))}" style="object-fit:${S};${el(h.objectPosition)}${D}${R}display:block;" /></div>`}else y=Zf(t,d,w,h,r,a,s,i);return`<td${x} style="${Jf(h,r)}">${y}</td>`}).join("");c.push(`<tr${u} style="height:${p.height}mm;">${f}</tr>`)}return c.join(`
212
+ `)}function Zf(t,e,n,r,o,i,a,l){const c=Mo(r),s=Ye(ui(r,l));if(c==="autoHeight")return s;const d=Ao(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="${Ye(lp(i.elementId,i.kind,e,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${ln(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function pi(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;">
213
+ <colgroup>${o}</colgroup>
214
+ <tbody>${e}</tbody>
215
+ </table>`}function Qf(t,e,n,r){const o=t.options,i=li(o.left??0,o.top??0,o.width??100,void 0,o.zIndex),a=o._renderRows??[],l=bt(a,0,a.length,o,e,r,{elementId:t.id,kind:"b"});return`<div class="print-element" style="${i};overflow:visible;"${n}>
216
+ ${pi(t,l)}
217
+ </div>`}function eh(t,e,n){const r=t.options,o=li(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?bt(i,0,c,r,!1,n,{elementId:t.id,kind:"b"},c):"",d=bt(i,a,l,r,!1,n,{elementId:t.id,kind:"b"}),p=e.subtotal?rl(t,e,r,n):"",u=e.summary?ol(t,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
218
+ ${pi(t,`${s}
219
+ ${d}${p}${u}`)}
220
+ </div>`}function rl(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?di(r.pageVars):{},m=o.map(v=>({...v,cells:v.cells.map(x=>x.rawFormatter?{...x,content:gt(x.rawFormatter,{rows:f,...l,...h}),rawFormatter:""}:x)}));return bt(m,0,m.length,n,!1,r,{elementId:t.id,kind:"st"})}function ol(t,e,n){const r=e._summaryRows??[];return r.length===0?"":bt(r,0,r.length,e,!1,n,{elementId:t.id,kind:"sm"})}function th(t,e,n,r){const o=t.options??{},i=o.left??0,a=o.width??100,l=e.groupTop??o.top??0,c=ci(t),s=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",d=`position:absolute;left:${z(i)};top:${z(l)};width:${z(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??[],y=o._repeatHeaderCount??0,S=e.repeatHeader&&y>0?bt(w,0,y,o,!1,r,{elementId:t.id,kind:"b"},y):"",D=bt(w,p,u,o,!1,r,{elementId:t.id,kind:"b"}),R=e.subtotal?rl(t,e,o,r):"",A=e.summary?ol(t,o,r):"";f=`<div class="flow-slice" style="position:relative;width:${z(a)};overflow:visible;">
221
+ ${pi(t,`${S}
222
+ ${D}${R}${A}`)}
223
+ </div>`}const h=e.followElementIds??[],m=h.reduce((w,y)=>{const S=hi(n,y);return S?Math.max(w,(S.options?.top??0)+(S.options?.height??0)):w},c),v=h.map(w=>{const y=hi(n,w);if(!y)return"";const S=y.options?.top??0,D=y.options?.left??0,R=y.options?.width??a,A=y.options?.height??0,k=y.options?.zIndex,_=y.type||y.printElementType?.type||"text",M=_==="rect"||_==="oval"||_==="image",O=["position:absolute",`left:${z(D-i)}`,`top:${z(S-c)}`,`width:${z(R)}`,...M&&A>0?[`height:${z(A)}`]:[],...typeof k=="number"?[`z-index:${k}`]:[],"overflow:visible"].join(";")+";";return lr(y,!1,O,void 0,r)}).join(`
224
+ `),x=h.length>0?`<div class="flow-follow" style="position:relative;width:${z(a)};height:${z(Math.max(m-c,0))};overflow:visible;">
225
+ ${v}
226
+ </div>`:"";return`<div class="flow-group" style="${d}">
227
+ ${f}
228
+ ${x}
229
+ </div>`}function fi(t,e,n,r,o){return t.map(i=>{let a=nh(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(`
230
+ `)}function nh(t,e){return lr(t,!1,void 0,void 0,e)}function hi(t,e){return t.elements.find(n=>n.id===e)}function gi(t){return ve(t)}function Ye(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const rh=25.4;function oh(t,e){const n=t.margins?.bottom??0,r=t.footer?.height??0,o=Math.max(e,0)+r+n;return Math.max(rh,Math.round(o*100)/100)}const il=3.7795275591;function mi(t){return t/il}function cr(t){return Math.round(t*il)}class gn extends Error{constructor(e,n,r){super(n),this.name="PrintFailure",this.code=e,this.cause=r}}function ih(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 dr(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 ur(t){return typeof t=="number"&&t>0?t:void 0}function ah(t){return ur(t.paperHeightMm)??ur(t.override?.height)}function sh(t){const e=ur(t.override?.width)??t.paperMm.width,n=ur(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 al(t){return{width:cr(t.width),height:cr(t.height)}}function sl(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(mi);r.set(o.id,{id:o.id,measuredHeight:mi(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 lh={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function ll(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=cp(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=Co(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[lh[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=Co(o.fontSizePt))}}function cl(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])}function ch(t){return{render(e,n,r){const o=t.get(cl(e,n,r));if(!o)throw new Error(`码值未渲染:${e}`);return o}}}function dh(t){const e=new Map;return{renderer:{render(n,r,o={}){const i=cl(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 uh(...t){const e=new Map;for(const n of t)for(const[r,o]of n)e.set(r,o);return e}const ph={waitReady:"window",readMeasurements:"document",readContentBottom:"document",renderCodes:"none",applyTextFit:"document"},fh=3e4,hh=5e3;function gh(t,e){return{async withSession(n,r){const o=await t.createDriver(),i=Date.now()+(n.timeoutMs??fh),a=n.readinessMs??hh,l=()=>Math.max(1,i-Date.now()),c=(f,h,m)=>ih(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 dr((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 dr((async()=>{try{await p(f,h);const v=await o.evaluate("applyTextFit")??[];return{measurements:await o.evaluate("readMeasurements"),fits:v}}catch(v){throw c(v,"MEASURE_FAILED","测量失败")}})(),m,"RENDER_TIMEOUT",`测量超过 ${m}ms`)},async probeContentBottom(f,h){const m=l();return dr((async()=>{try{return await p(f,h),await o.evaluate("readContentBottom")}catch(v){throw c(v,"MEASURE_FAILED","连续纸探针失败")}})(),m,"RENDER_TIMEOUT",`连续纸探针超过 ${m}ms`)},async toPdf(f,h,m){if(!o.pdf)throw new gn("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const v=l();return dr((async()=>{try{return await p(f,m),await o.pdf(f,h)}catch(x){throw c(x,"PDF_FAILED","PDF 生成失败")}})(),v,"RENDER_TIMEOUT",`PDF 生成超过 ${v}ms`)}};try{return await r(u)}finally{try{await o.close()}catch{}}}}}const dl=500;function mh(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ul(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>dl)throw new Error(`批量打印最多支持 ${dl} 份,当前 ${t.length} 份`);for(let e=0;e<t.length;e++)if(!mh(t[e]))throw new Error(`批量打印数据第 ${e+1} 项必须是对象`);return{mode:"batch",dataList:t}}function bh(t){const e=t[0].bound,n=qe(e),r=t.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=ar(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
231
+ ${s}
232
+ </section>`}).join(`
233
+ `),o=n?Tf(e,t.map(a=>({heightMm:a.derivedHeightMm}))):`${fn(e)}
234
+ .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=pn(e.fonts)+o;return{html:sr(i,r,n?"continuous":void 0),pageCount:t.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:t.map(a=>a.paperMm)}}const Ht={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class vh extends Error{constructor(e,n){super(n),this.name="TilingError",this.code=e}}function vt(t){return Math.round(t*10)/10}function pr(t){const e=t.tiling;return{...Ht,...e,sheetMargin:{...Ht.sheetMargin,...e?.sheetMargin??{}}}}function mn(t,e){const n=pr(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??mt.A4.width,height:n.sheetCustomHeight??mt.A4.height};const o=n.sheetPaperSize??"A4",i=mt[o]??mt.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function pl(t,e){return{w:t.width-e.left-e.right,h:t.height-e.top-e.bottom}}function bi(t,e,n){return Math.max(0,Math.floor((t+n)/(e+n)))}function fl(t,e){const n=vi(t,e);if(n.length)throw new vh(n[0].code,n[0].message);const r=pr(t),o=mn(t,e),i=ve(t),a=pl(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:bi(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function yh(t,e){const n=e%t.perSheet,r=n%t.columns,o=Math.floor(n/t.columns);return{left:vt(t.margin.left+r*(t.tile.width+t.gapX)),top:vt(t.margin.top+o*(t.tile.height+t.gapY))}}function xh(t,e){const n=pr(t),r=mn(t,e),o=ve(t),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return bi(i,o.width,n.gapX)}function vi(t,e){const n=[],r=pr(t);qe(t)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=Bt(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=mn(t,e),c=ve(t),s=pl(l,r.sheetMargin),d=vt(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=bi(s.w,c.width,r.gapX);if(r.columns>p){const u=vt(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+vt(l.width)+"mm − 左右留白 "+d+"mm = "+vt(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+vt(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"}),n}function wh(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=yh(n,s),p=ar(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
235
+ ${p}
236
+ </div>`}).join(`
237
+ `);o.push(`<section class="print-sheet">
238
+ ${l}
239
+ </section>`)}const i=pn(r.fonts)+fn(r)+`
240
+ `+kf(n);return{html:sr(i,o.join(`
241
+ `)),sheetCount:o.length,perSheet:n.perSheet}}function yi(t,e){return t.name?`第 ${e+1} 页「${t.name}」`:`第 ${e+1} 页`}function xi(t){const e=Eh(t)?t.pages:[t];if(e.length===0)throw new Error("多页面模板至少需要一页");if(e.length===1)return e;const n=ve(e[0]);return e.forEach((r,o)=>{if(qe(r))throw new Error(`多页面模板不支持连续纸(${yi(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${yi(r,o)})`);const i=ve(r);if(i.width!==n.width||i.height!==n.height)throw new Error(`多页面模板各页纸张尺寸必须一致(${yi(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),e}function Eh(t){return Array.isArray(t.pages)}function Sh(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 _h(t){if(t.length===0)throw new Error("多页面模板至少需要一份数据");const e=t[0].boundPages,n=pn(Sh(e))+[Sf(e[0]),Ef(),...e.map((l,c)=>_f(l,`.mt-${c}`)),...t.length>1?[si]:[]].join(`
242
+
243
+ `),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=ar(l.boundPages[f],u,l.data,{codeRenderer:l.codeRenderers?.[f]},{pageOffset:s,totalPages:c,pageClass:`mt-${f}`});return s+=u.length,h}).join(`
244
+ `);return t.length>1?`<section class="print-copy">
245
+ ${p}
246
+ </section>`:p}).join(`
247
+ `),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:sr(n,r),pageCount:o,pageLayouts:i}}async function Th(t,e){return e.withSession(t,n=>kh(t,n))}async function kh(t,e){const n=xi(t.templateJson);if(n.length>1){const c=ul(t.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await Ch(t,e,s[u]))}catch(f){const h=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${h}`)}const p=_h(d);return{html:p.html,pageCount:p.pageCount,paperMm:oi(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=ul(r.printData);if(i.mode==="single"){const c=await gl(r,e,i.data);return o.tiling?.enabled===!0?hl(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):Mh(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await gl(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 hl(r,a);const l=bh(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:qe(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function Mh(t){return{html:t.html,pageCount:t.pageCount,paperMm:t.paperMm,continuous:t.continuous,heightSource:t.heightSource,pageLayouts:t.pageLayouts,copies:1}}function hl(t,e){const n=e[0].bound,r=fl(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=wh({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 gl(t,e,n){const r=$s(t.templateJson,n,t.baseUrl,t.fontBaseUrl),o=qe(r),i=ve(r),a=al(i),l=ah({paperHeightMm:t.paperHeightMm,override:t.paperOverride}),c=await fr({bound:r,job:t,session:e,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await e.measure(c.html,a);ll(r,s.fits);const d=Ks(r,sl(s.measurements,r)),p=await fr({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=oh(r,mi(w))}u=ir(r,d,n,{codeRenderer:p.codeRenderer,pageHeightMm:f})}const h=o&&l?{...t.paperOverride,height:l}:t.paperOverride,m=oi(r),{paperMm:v,heightSource:x}=sh({paperMm:{width:m.width,height:f??m.height},continuous:o,override:h});return{html:u,pageCount:d.length,paperMm:v,continuous:o,heightSource:x,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,derivedHeightMm:f}}async function Ch(t,e,n){const r=xi(t.templateJson),o=al(ve(r[0])),i=[],a=[],l=[];for(const c of r){const s=$s(c,n,t.baseUrl,t.fontBaseUrl),d=await fr({bound:s,job:t,session:e,data:n,pageLayouts:[],isMeasurementPass:!0}),p=await e.measure(d.html,o);ll(s,p.fits);const u=Ks(s,sl(p.measurements,s)),f=await fr({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 fr(t){const e=t.baseMap??new Map;if(t.job.codeRenderer)return{html:ir(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:t.job.codeRenderer}),codeRenderer:t.job.codeRenderer,map:e};const n=dh(e),r=ir(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=uh(e,i),l=a.size>0?ch(a):void 0;return o.length===0?{html:r,codeRenderer:l,map:a}:{html:ir(t.bound,t.pageLayouts,t.data,{isMeasurementPass:t.isMeasurementPass,codeRenderer:l}),codeRenderer:l,map:a}}class Ah{constructor(e){this.functions={},e?.functions&&(this.functions={...e.functions})}registerFunction(e,n){this.functions[e]=n}evaluate(e,n){const r=jo(e),o=Go(r);return be(o,n,this.functions)}render(e,n){return xs(e,this.functions)(n)}}const ml=new Ah,Oh={MONEY:ws,CONCAT:(...t)=>t.filter(e=>e!=null).join(""),IF:_s,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:As,SUB:Os,MUL:Ps,DIV:Rs,ROUND:Is,ROUNDUP:Kn,CEIL:Kn,ROUNDDOWN:Jn,FLOOR:Jn,ROUNDBANK:Ds,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:Es,UPPER:Ss};for(const[t,e]of Object.entries(Oh))ml.registerFunction(t,e);function Ph(t,e,n){switch(t.toUpperCase()){case"SUM":return Jo(n,e);case"AVG":return Ts(n,e);case"COUNT":return ks(n);case"MIN":return Ms(n,e);case"MAX":return Cs(n,e);default:return 0}}function hr(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(Ph(c,d,n))}),`{${a}}`});try{return ml.render(r,e)}catch{return t}}function Rh(t){return ds("text",{formatter:`{${t.fieldKey}}`,title:t.fieldLabel})}function bl(t){let e=ht;for(const n of t.split(".")){if(e==null)return;e=Array.isArray(e)?e[0]?.[n]:e[n]}return e}function Ih(t,e){const n=e?.[0];return(t??"").replace(/\{([^{}]+)\}/g,(o,i)=>{const a=i.trim(),l=a.includes(".")?bl(a):n?.[a]??bl(a);return l==null?"":String(l)}).trim()||"1234567890128"}const gr={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function vl(t){return t==="vCenter"?gr.center:t==="hCenter"?gr.middle:gr[t]??gr.left}function Dh(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"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[x,w]of m){const y=Math.abs(d[x]-h[w]);y<=o&&y<p&&(p=y,l=t.left+(h[w]-d[x]))}for(const[x,w]of v){const y=Math.abs(d[x]-h[w]);y<=o&&y<p&&(p=y,c=t.top+(h[w]-d[x]))}}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 v of n.vertical)for(const x of h){const w=Math.abs(f[x]-v);w<=o&&w<p&&(p=w,l=t.left+(v-f[x]))}const m=["top","hCenter","bottom"];for(const v of n.horizontal)for(const x of m){const w=Math.abs(f[x]-v);w<=o&&w<p&&(p=w,c=t.top+(v-f[x]))}}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},v=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],x=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,y]of v)if(Math.abs(u[w]-m[y])<=i){const D=`v:${m[y]}`;f.has(D)||(f.add(D),s.push({type:"vertical",position:m[y],id:h.id,color:vl(w)}))}for(const[w,y]of x)if(Math.abs(u[w]-m[y])<=i){const D=`h:${m[y]}`;f.has(D)||(f.add(D),s.push({type:"horizontal",position:m[y],id:h.id,color:vl(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 $h(){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 yl(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function Lh(){function t(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=yl();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 Nh=["nw","n","ne","e","se","s","sw","w"];function Fh(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 xl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mr={},bn={},br={},wl;function Ae(){if(wl)return br;wl=1,Object.defineProperty(br,"__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 br.default=e,br}var El;function zh(){if(El)return bn;El=1,Object.defineProperty(bn,"__esModule",{value:!0}),bn.CODE39=void 0;var t=(function(){function m(v,x){for(var w=0;w<x.length;w++){var y=x[w];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(v,y.key,y)}}return function(v,x,w){return x&&m(v.prototype,x),w&&m(v,w),v}})(),e=Ae(),n=r(e);function r(m){return m&&m.__esModule?m:{default:m}}function o(m,v){if(!(m instanceof v))throw new TypeError("Cannot call a class as a function")}function i(m,v){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v&&(typeof v=="object"||typeof v=="function")?v:m}function a(m,v){if(typeof v!="function"&&v!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof v);m.prototype=Object.create(v&&v.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),v&&(Object.setPrototypeOf?Object.setPrototypeOf(m,v):m.__proto__=v)}var l=(function(m){a(v,m);function v(x,w){return o(this,v),x=x.toUpperCase(),w.mod43&&(x+=u(h(x))),i(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,x,w))}return t(v,[{key:"encode",value:function(){for(var w=d("*"),y=0;y<this.data.length;y++)w+=d(this.data[y])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),v})(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 v=0,x=0;x<m.length;x++)v+=f(m[x]);return v=v%43,v}return bn.CODE39=l,bn}var ze={},vr={},yr={},re={},Sl;function vn(){if(Sl)return re;Sl=1,Object.defineProperty(re,"__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=re.SET_A=0,r=re.SET_B=1,o=re.SET_C=2;re.SHIFT=98;var i=re.START_A=103,a=re.START_B=104,l=re.START_C=105;return re.MODULO=103,re.STOP=106,re.FNC1=207,re.SET_BY_CODE=(t={},e(t,i,n),e(t,a,r),e(t,l,o),t),re.SWAP={101:n,100:r,99:o},re.A_START_CHAR="Ð",re.B_START_CHAR="Ñ",re.C_START_CHAR="Ò",re.A_CHARS="[\0-_È-Ï]",re.B_CHARS="[ -È-Ï]",re.C_CHARS="(Ï*[0-9]{2}Ï*)",re.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],re}var _l;function xr(){if(_l)return yr;_l=1,Object.defineProperty(yr,"__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=Ae(),n=o(e),r=vn();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,v=void 0;if(u[0]>=200){v=u.shift()-105;var x=r.SWAP[v];x!==void 0?m=d.next(u,f+1,x):((h===r.SET_A||h===r.SET_B)&&v===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 v=d.correctIndex(u,h),m=d.next(u,f+1,h);var w=d.getBar(v),y=v*f;return{result:w+m.result,checksum:y+m.checksum}}}]),d})(n.default);return yr.default=c,yr}var wr={},Tl;function Bh(){if(Tl)return wr;Tl=1,Object.defineProperty(wr,"__esModule",{value:!0});var t=vn(),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 wr.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})},wr}var kl;function Hh(){if(kl)return vr;kl=1,Object.defineProperty(vr,"__esModule",{value:!0});var t=xr(),e=o(t),n=Bh(),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 vr.default=c,vr}var Er={},Ml;function Uh(){if(Ml)return Er;Ml=1,Object.defineProperty(Er,"__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=xr(),n=o(e),r=vn();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 Er.default=c,Er}var Sr={},Cl;function qh(){if(Cl)return Sr;Cl=1,Object.defineProperty(Sr,"__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=xr(),n=o(e),r=vn();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 Sr.default=c,Sr}var _r={},Al;function Wh(){if(Al)return _r;Al=1,Object.defineProperty(_r,"__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=xr(),n=o(e),r=vn();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 _r.default=c,_r}var Ol;function jh(){if(Ol)return ze;Ol=1,Object.defineProperty(ze,"__esModule",{value:!0}),ze.CODE128C=ze.CODE128B=ze.CODE128A=ze.CODE128=void 0;var t=Hh(),e=c(t),n=Uh(),r=c(n),o=qh(),i=c(o),a=Wh(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return ze.CODE128=e.default,ze.CODE128A=r.default,ze.CODE128B=i.default,ze.CODE128C=l.default,ze}var ye={},Tr={},Xe={},Pl;function yn(){return Pl||(Pl=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.SIDE_BIN="101",Xe.MIDDLE_BIN="01010",Xe.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"]},Xe.EAN2_STRUCTURE=["LL","LG","GL","GG"],Xe.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Xe.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Xe}var kr={},Mr={},Rl;function xn(){if(Rl)return Mr;Rl=1,Object.defineProperty(Mr,"__esModule",{value:!0});var t=yn(),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 Mr.default=e,Mr}var Il;function Dl(){if(Il)return kr;Il=1,Object.defineProperty(kr,"__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=yn(),n=xn(),r=a(n),o=Ae(),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 kr.default=d,kr}var $l;function Gh(){if($l)return Tr;$l=1,Object.defineProperty(Tr,"__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 v=Object.getPrototypeOf(u);return v===null?void 0:p(v,f,h)}else{if("value"in m)return m.value;var x=m.get;return x===void 0?void 0:x.call(h)}},n=yn(),r=Dl(),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,v){return v%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 Tr.default=d,Tr}var Cr={},Ll;function Vh(){if(Ll)return Cr;Ll=1,Object.defineProperty(Cr,"__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 v=h.get;return v===void 0?void 0:v.call(f)}},n=Dl(),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 Cr.default=s,Cr}var Ar={},Nl;function Yh(){if(Nl)return Ar;Nl=1,Object.defineProperty(Ar,"__esModule",{value:!0});var t=(function(){function u(f,h){for(var m=0;m<h.length;m++){var v=h[m];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(f,v.key,v)}}return function(f,h,m){return h&&u(f.prototype,h),m&&u(f,m),f}})(),e=yn(),n=xn(),r=a(n),o=Ae(),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,v,x){return x%2?m+v*9:m+v*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 Ar.default=p,Ar}var Or={},Fl;function Xh(){if(Fl)return Or;Fl=1,Object.defineProperty(Or,"__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=yn(),n=xn(),r=a(n),o=Ae(),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 Or.default=d,Or}var wn={},zl;function Bl(){if(zl)return wn;zl=1,Object.defineProperty(wn,"__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}})();wn.checksum=d;var e=xn(),n=i(e),r=Ae(),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 wn.default=s,wn}var Pr={},Hl;function Kh(){if(Hl)return Pr;Hl=1,Object.defineProperty(Pr,"__esModule",{value:!0});var t=(function(){function h(m,v){for(var x=0;x<v.length;x++){var w=v[x];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,w.key,w)}}return function(m,v,x){return v&&h(m.prototype,v),x&&h(m,x),m}})(),e=xn(),n=a(e),r=Ae(),o=a(r),i=Bl();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(v,x){l(this,m);var w=c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,v,x));if(w.isValid=!1,v.search(/^[0-9]{6}$/)!==-1)w.middleDigits=v,w.upcA=f(v,"0"),w.text=x.text||""+w.upcA[0]+v+w.upcA[w.upcA.length-1],w.isValid=!0;else if(v.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=v.substring(1,v.length-1),w.upcA=f(w.middleDigits,v[0]),w.upcA[w.upcA.length-1]===v[v.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=x.displayValue,x.fontSize>x.width*10?w.fontSize=x.width*10:w.fontSize=x.fontSize,w.guardHeight=x.height+w.fontSize/2+x.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 x="";return x+="101",x+=this.encodeMiddleDigits(),x+="010101",{data:x,text:this.text}}},{key:"guardedEncoding",value:function(){var x=[];return this.displayValue&&x.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),x.push({data:"101",options:{height:this.guardHeight}}),x.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),x.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&x.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),x}},{key:"encodeMiddleDigits",value:function(){var x=this.upcA[0],w=this.upcA[this.upcA.length-1],y=p[parseInt(w)][parseInt(x)];return(0,n.default)(this.middleDigits,y)}}]),m})(o.default);function f(h,m){for(var v=parseInt(h[h.length-1]),x=d[v],w="",y=0,S=0;S<x.length;S++){var D=x[S];D==="X"?w+=h[y++]:w+=D}return w=""+m+w,""+w+(0,i.checksum)(w)}return Pr.default=u,Pr}var Ul;function Jh(){if(Ul)return ye;Ul=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.UPCE=ye.UPC=ye.EAN2=ye.EAN5=ye.EAN8=ye.EAN13=void 0;var t=Gh(),e=u(t),n=Vh(),r=u(n),o=Yh(),i=u(o),a=Xh(),l=u(a),c=Bl(),s=u(c),d=Kh(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return ye.EAN13=e.default,ye.EAN8=r.default,ye.EAN5=i.default,ye.EAN2=l.default,ye.UPC=s.default,ye.UPCE=p.default,ye}var yt={},Rr={},Ut={},ql;function Zh(){return ql||(ql=1,Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.START_BIN="1010",Ut.END_BIN="11101",Ut.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Ut}var Wl;function jl(){if(Wl)return Rr;Wl=1,Object.defineProperty(Rr,"__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=Zh(),n=Ae(),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 Rr.default=c,Rr}var Ir={},Gl;function Qh(){if(Gl)return Ir;Gl=1,Object.defineProperty(Ir,"__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=jl(),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 Ir.default=c,Ir}var Vl;function eg(){if(Vl)return yt;Vl=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.ITF14=yt.ITF=void 0;var t=jl(),e=o(t),n=Qh(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return yt.ITF=e.default,yt.ITF14=r.default,yt}var Oe={},Dr={},Yl;function En(){if(Yl)return Dr;Yl=1,Object.defineProperty(Dr,"__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=Ae(),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 v=0;v<m.length;v++)u+=m[v]=="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 Dr.default=l,Dr}var $r={},Sn={},Xl;function Lr(){if(Xl)return Sn;Xl=1,Object.defineProperty(Sn,"__esModule",{value:!0}),Sn.mod10=t,Sn.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 Sn}var Kl;function tg(){if(Kl)return $r;Kl=1,Object.defineProperty($r,"__esModule",{value:!0});var t=En(),e=r(t),n=Lr();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 $r.default=l,$r}var Nr={},Jl;function ng(){if(Jl)return Nr;Jl=1,Object.defineProperty(Nr,"__esModule",{value:!0});var t=En(),e=r(t),n=Lr();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 Nr.default=l,Nr}var Fr={},Zl;function rg(){if(Zl)return Fr;Zl=1,Object.defineProperty(Fr,"__esModule",{value:!0});var t=En(),e=r(t),n=Lr();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 Fr.default=l,Fr}var zr={},Ql;function og(){if(Ql)return zr;Ql=1,Object.defineProperty(zr,"__esModule",{value:!0});var t=En(),e=r(t),n=Lr();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 zr.default=l,zr}var ec;function ig(){if(ec)return Oe;ec=1,Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.MSI1110=Oe.MSI1010=Oe.MSI11=Oe.MSI10=Oe.MSI=void 0;var t=En(),e=d(t),n=tg(),r=d(n),o=ng(),i=d(o),a=rg(),l=d(a),c=og(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return Oe.MSI=e.default,Oe.MSI10=r.default,Oe.MSI11=i.default,Oe.MSI1010=l.default,Oe.MSI1110=s.default,Oe}var _n={},tc;function ag(){if(tc)return _n;tc=1,Object.defineProperty(_n,"__esModule",{value:!0}),_n.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=Ae(),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 _n.pharmacode=l,_n}var Tn={},nc;function sg(){if(nc)return Tn;nc=1,Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.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=Ae(),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 Tn.codabar=l,Tn}var xt={},Br={},qt={},rc;function lg(){return rc||(rc=1,Object.defineProperty(qt,"__esModule",{value:!0}),qt.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","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],qt.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"],qt.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"]}),qt}var oc;function ic(){if(oc)return Br;oc=1,Object.defineProperty(Br,"__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=lg(),n=Ae(),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(v){return e.MULTI_SYMBOLS[v]||v}),f=u.map(function(v){return d.getEncoding(v)}).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,v,x){var w=x%f+1;return m+d.symbolValue(v)*w},0);return d.getSymbol(h%47)}}]),d})(r.default);return Br.default=c,Br}var Hr={},ac;function cg(){if(ac)return Hr;ac=1,Object.defineProperty(Hr,"__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=ic(),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 Hr.default=l,Hr}var sc;function dg(){if(sc)return xt;sc=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.CODE93FullASCII=xt.CODE93=void 0;var t=ic(),e=o(t),n=cg(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return xt.CODE93=e.default,xt.CODE93FullASCII=r.default,xt}var kn={},lc;function ug(){if(lc)return kn;lc=1,Object.defineProperty(kn,"__esModule",{value:!0}),kn.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=Ae(),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 kn.GenericBarcode=l,kn}var cc;function pg(){if(cc)return mr;cc=1,Object.defineProperty(mr,"__esModule",{value:!0});var t=zh(),e=jh(),n=Jh(),r=eg(),o=ig(),i=ag(),a=sg(),l=dg(),c=ug();return mr.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},mr}var Ur={},dc;function qr(){if(dc)return Ur;dc=1,Object.defineProperty(Ur,"__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 Ur.default=function(e,n){return t({},e,n)},Ur}var Wr={},uc;function fg(){if(uc)return Wr;uc=1,Object.defineProperty(Wr,"__esModule",{value:!0}),Wr.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 Wr}var jr={},pc;function hg(){if(pc)return jr;pc=1,Object.defineProperty(jr,"__esModule",{value:!0}),jr.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 jr}var Gr={},Vr={},Yr={},fc;function hc(){if(fc)return Yr;fc=1,Object.defineProperty(Yr,"__esModule",{value:!0}),Yr.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 Yr}var Xr={},gc;function mc(){if(gc)return Xr;gc=1,Object.defineProperty(Xr,"__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 Xr.default=t,Xr}var bc;function gg(){if(bc)return Vr;bc=1,Object.defineProperty(Vr,"__esModule",{value:!0});var t=hc(),e=o(t),n=mc(),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 Vr.default=i,Vr}var Kr={},Jr={},Pe={},vc;function yc(){if(vc)return Pe;vc=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.getTotalWidthOfEncodings=Pe.calculateEncodingAttributes=Pe.getBarcodePadding=Pe.getEncodingHeight=Pe.getMaximumHeightOfEncodings=void 0;var t=qr(),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 v=f.data.length*h.width;f.width=Math.ceil(Math.max(m,v)),f.height=r(f,h),f.barcodePadding=o(m,v,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 Pe.getMaximumHeightOfEncodings=l,Pe.getEncodingHeight=r,Pe.getBarcodePadding=o,Pe.calculateEncodingAttributes=i,Pe.getTotalWidthOfEncodings=a,Pe}var xc;function mg(){if(xc)return Jr;xc=1,Object.defineProperty(Jr,"__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=qr(),n=o(e),r=yc();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 Jr.default=a,Jr}var Zr={},wc;function bg(){if(wc)return Zr;wc=1,Object.defineProperty(Zr,"__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=qr(),n=o(e),r=yc();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,v=0,x=0;x<f.length;x++)v=x*p.width+u.barcodePadding,f[x]==="1"?m++:m>0&&(this.drawRect(v-p.width*m,h,p.width*m,p.height,d),m=0);m>0&&this.drawRect(v-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 Zr.default=l,Zr}var Qr={},Ec;function vg(){if(Ec)return Qr;Ec=1,Object.defineProperty(Qr,"__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 Qr.default=n,Qr}var Sc;function yg(){if(Sc)return Kr;Sc=1,Object.defineProperty(Kr,"__esModule",{value:!0});var t=mg(),e=a(t),n=bg(),r=a(n),o=vg(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Kr.default={CanvasRenderer:e.default,SVGRenderer:r.default,ObjectRenderer:i.default},Kr}var Wt={},_c;function Tc(){if(_c)return Wt;_c=1,Object.defineProperty(Wt,"__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 Wt.InvalidInputException=r,Wt.InvalidElementException=o,Wt.NoElementException=i,Wt}var kc;function xg(){if(kc)return Gr;kc=1,Object.defineProperty(Gr,"__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=gg(),n=a(e),r=yg(),o=a(r),i=Tc();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 Gr.default=l,Gr}var eo={},Mc;function wg(){if(Mc)return eo;Mc=1,Object.defineProperty(eo,"__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 eo.default=n,eo}var wi,Cc;function Eg(){if(Cc)return wi;Cc=1;var t=pg(),e=x(t),n=qr(),r=x(n),o=fg(),i=x(o),a=hg(),l=x(a),c=xg(),s=x(c),d=hc(),p=x(d),u=wg(),f=x(u),h=Tc(),m=mc(),v=x(m);function x(_){return _&&_.__esModule?_:{default:_}}var w=function(){},y=function(M,O,C){var I=new w;if(typeof M>"u")throw Error("No element to render on was provided.");return I._renderProperties=(0,s.default)(M),I._encodings=[],I._options=v.default,I._errorHandler=new f.default(I),typeof O<"u"&&(C=C||{},C.format||(C.format=A()),I.options(C)[C.format](O,C).render()),I};y.getModule=function(_){return e.default[_]};for(var S in e.default)e.default.hasOwnProperty(S)&&D(e.default,S);function D(_,M){w.prototype[M]=w.prototype[M.toUpperCase()]=w.prototype[M.toLowerCase()]=function(O,C){var I=this;return I._errorHandler.wrapBarcodeCall(function(){C.text=typeof C.text>"u"?void 0:""+C.text;var N=(0,r.default)(I._options,C);N=(0,p.default)(N);var ie=_[M],Ne=R(O,ie,N);return I._encodings.push(Ne),I})}}function R(_,M,O){_=""+_;var C=new M(_,O);if(!C.valid())throw new h.InvalidInputException(C.constructor.name,_);var I=C.encode();I=(0,i.default)(I);for(var N=0;N<I.length;N++)I[N].options=(0,r.default)(O,I[N].options);return I}function A(){return e.default.CODE128?"CODE128":Object.keys(e.default)[0]}w.prototype.options=function(_){return this._options=(0,r.default)(this._options,_),this},w.prototype.blank=function(_){var M=new Array(_+1).join("0");return this._encodings.push({data:M}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var _;for(var M in this._renderProperties){_=this._renderProperties[M];var O=(0,r.default)(this._options,_.options);O.format=="auto"&&(O.format=A()),this._errorHandler.wrapBarcodeCall(function(){var C=O.value,I=e.default[O.format.toUpperCase()],N=R(C,I,O);k(_,N,O)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new h.NoElementException;if(Array.isArray(this._renderProperties))for(var _=0;_<this._renderProperties.length;_++)k(this._renderProperties[_],this._encodings,this._options);else k(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=v.default;function k(_,M,O){M=(0,i.default)(M);for(var C=0;C<M.length;C++)M[C].options=(0,r.default)(O,M[C].options),(0,l.default)(M[C].options);(0,l.default)(O);var I=_.renderer,N=new I(_.element,M,O);N.render(),_.afterRender&&_.afterRender()}return typeof window<"u"&&(window.JsBarcode=y),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(_,M){var O=[];return jQuery(this).each(function(){O.push(this)}),y(O,_,M)}),wi=y,wi}var Sg=Eg();const Ei=xl(Sg);var jt={},Si,Ac;function _g(){return Ac||(Ac=1,Si=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Si}var _i={},ot={},Oc;function wt(){if(Oc)return ot;Oc=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 ot.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},ot.getSymbolTotalCodewords=function(r){return e[r]},ot.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},ot.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');t=r},ot.isKanjiModeEnabled=function(){return typeof t<"u"},ot.toSJIS=function(r){return t(r)},ot}var Ti={},Pc;function ki(){return Pc||(Pc=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}}})(Ti)),Ti}var Mi,Rc;function Tg(){if(Rc)return Mi;Rc=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++}},Mi=t,Mi}var Ci,Ic;function kg(){if(Ic)return Ci;Ic=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]},Ci=t,Ci}var Ai={},Dc;function Mg(){return Dc||(Dc=1,(function(t){const e=wt().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}})(Ai)),Ai}var Oi={},$c;function Cg(){if($c)return Oi;$c=1;const t=wt().getSymbolSize,e=7;return Oi.getPositions=function(r){const o=t(r);return[[0,0],[o-e,0],[0,o-e]]},Oi}var Pi={},Lc;function Ag(){return Lc||(Lc=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}})(Pi)),Pi}var to={},Nc;function Fc(){if(Nc)return to;Nc=1;const t=ki(),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 to.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}},to.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}},to}var Ri={},Mn={},zc;function Og(){if(zc)return Mn;zc=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]})(),Mn.log=function(r){if(r<1)throw new Error("log("+r+")");return e[r]},Mn.exp=function(r){return t[r]},Mn.mul=function(r,o){return r===0||o===0?0:t[e[r]+e[o]]},Mn}var Bc;function Pg(){return Bc||(Bc=1,(function(t){const e=Og();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}})(Ri)),Ri}var Ii,Hc;function Rg(){if(Hc)return Ii;Hc=1;const t=Pg();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},Ii=e,Ii}var Di={},$i={},Li={},Uc;function qc(){return Uc||(Uc=1,Li.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),Li}var We={},Wc;function jc(){if(Wc)return We;Wc=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
248
+ ]))+`;We.KANJI=new RegExp(n,"g"),We.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),We.BYTE=new RegExp(r,"g"),We.NUMERIC=new RegExp(t,"g"),We.ALPHANUMERIC=new RegExp(e,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+t+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return We.testKanji=function(c){return o.test(c)},We.testNumeric=function(c){return i.test(c)},We.testAlphanumeric=function(c){return a.test(c)},We}var Gc;function Et(){return Gc||(Gc=1,(function(t){const e=qc(),n=jc();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}}})($i)),$i}var Vc;function Ig(){return Vc||(Vc=1,(function(t){const e=wt(),n=Fc(),r=ki(),o=Et(),i=qc(),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 v=s(m.mode,f);h+=v+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 v=e.getSymbolTotalCodewords(f),x=n.getTotalCodewordsCount(f,h),w=(v-x)*8;if(m===o.MIXED)return w;const y=w-s(m,f);switch(m){case o.NUMERIC:return Math.floor(y/10*3);case o.ALPHANUMERIC:return Math.floor(y/11*2);case o.KANJI:return Math.floor(y/13);case o.BYTE:default:return Math.floor(y/8)}},t.getBestVersionForData=function(f,h){let m;const v=r.from(h,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,v);if(f.length===0)return 1;m=f[0]}else m=f;return c(m.mode,m.getLength(),v)},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}})(Di)),Di}var Ni={},Yc;function Dg(){if(Yc)return Ni;Yc=1;const t=wt(),e=1335,n=21522,r=t.getBCHDigit(e);return Ni.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},Ni}var Fi={},zi,Xc;function $g(){if(Xc)return zi;Xc=1;const t=Et();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))},zi=e,zi}var Bi,Kc;function Lg(){if(Kc)return Bi;Kc=1;const t=Et(),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)},Bi=n,Bi}var Hi,Jc;function Ng(){if(Jc)return Hi;Jc=1;const t=Et();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)},Hi=e,Hi}var Ui,Zc;function Fg(){if(Zc)return Ui;Zc=1;const t=Et(),e=wt();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]+`
249
+ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ui=n,Ui}var qi={exports:{}},Qc;function zg(){return Qc||(Qc=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,v;!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],v=typeof a[d]>"u",(v||m>h)&&(a[d]=h,l.push(d,h),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var x=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(x)}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})(qi)),qi.exports}var ed;function Bg(){return ed||(ed=1,(function(t){const e=Et(),n=$g(),r=Lg(),o=Ng(),i=Fg(),a=jc(),l=wt(),c=zg();function s(x){return unescape(encodeURIComponent(x)).length}function d(x,w,y){const S=[];let D;for(;(D=x.exec(y))!==null;)S.push({data:D[0],index:D.index,mode:w,length:D[0].length});return S}function p(x){const w=d(a.NUMERIC,e.NUMERIC,x),y=d(a.ALPHANUMERIC,e.ALPHANUMERIC,x);let S,D;return l.isKanjiModeEnabled()?(S=d(a.BYTE,e.BYTE,x),D=d(a.KANJI,e.KANJI,x)):(S=d(a.BYTE_KANJI,e.BYTE,x),D=[]),w.concat(y,S,D).sort(function(A,k){return A.index-k.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function u(x,w){switch(w){case e.NUMERIC:return n.getBitsLength(x);case e.ALPHANUMERIC:return r.getBitsLength(x);case e.KANJI:return i.getBitsLength(x);case e.BYTE:return o.getBitsLength(x)}}function f(x){return x.reduce(function(w,y){const S=w.length-1>=0?w[w.length-1]:null;return S&&S.mode===y.mode?(w[w.length-1].data+=y.data,w):(w.push(y),w)},[])}function h(x){const w=[];for(let y=0;y<x.length;y++){const S=x[y];switch(S.mode){case e.NUMERIC:w.push([S,{data:S.data,mode:e.ALPHANUMERIC,length:S.length},{data:S.data,mode:e.BYTE,length:S.length}]);break;case e.ALPHANUMERIC:w.push([S,{data:S.data,mode:e.BYTE,length:S.length}]);break;case e.KANJI:w.push([S,{data:S.data,mode:e.BYTE,length:s(S.data)}]);break;case e.BYTE:w.push([{data:S.data,mode:e.BYTE,length:s(S.data)}])}}return w}function m(x,w){const y={},S={start:{}};let D=["start"];for(let R=0;R<x.length;R++){const A=x[R],k=[];for(let _=0;_<A.length;_++){const M=A[_],O=""+R+_;k.push(O),y[O]={node:M,lastCount:0},S[O]={};for(let C=0;C<D.length;C++){const I=D[C];y[I]&&y[I].node.mode===M.mode?(S[I][O]=u(y[I].lastCount+M.length,M.mode)-u(y[I].lastCount,M.mode),y[I].lastCount+=M.length):(y[I]&&(y[I].lastCount=M.length),S[I][O]=u(M.length,M.mode)+4+e.getCharCountIndicator(M.mode,w))}}D=k}for(let R=0;R<D.length;R++)S[D[R]].end=0;return{map:S,table:y}}function v(x,w){let y;const S=e.getBestModeForData(x);if(y=e.from(w,S),y!==e.BYTE&&y.bit<S.bit)throw new Error('"'+x+'" cannot be encoded with mode '+e.toString(y)+`.
250
+ Suggested mode is: `+e.toString(S));switch(y===e.KANJI&&!l.isKanjiModeEnabled()&&(y=e.BYTE),y){case e.NUMERIC:return new n(x);case e.ALPHANUMERIC:return new r(x);case e.KANJI:return new i(x);case e.BYTE:return new o(x)}}t.fromArray=function(w){return w.reduce(function(y,S){return typeof S=="string"?y.push(v(S,null)):S.data&&y.push(v(S.data,S.mode)),y},[])},t.fromString=function(w,y){const S=p(w,l.isKanjiModeEnabled()),D=h(S),R=m(D,y),A=c.find_path(R.map,"start","end"),k=[];for(let _=1;_<A.length-1;_++)k.push(R.table[A[_]].node);return t.fromArray(f(k))},t.rawSplit=function(w){return t.fromArray(p(w,l.isKanjiModeEnabled()))}})(Fi)),Fi}var td;function Hg(){if(td)return _i;td=1;const t=wt(),e=ki(),n=Tg(),r=kg(),o=Mg(),i=Cg(),a=Ag(),l=Fc(),c=Rg(),s=Ig(),d=Dg(),p=Et(),u=Bg();function f(R,A){const k=R.size,_=i.getPositions(A);for(let M=0;M<_.length;M++){const O=_[M][0],C=_[M][1];for(let I=-1;I<=7;I++)if(!(O+I<=-1||k<=O+I))for(let N=-1;N<=7;N++)C+N<=-1||k<=C+N||(I>=0&&I<=6&&(N===0||N===6)||N>=0&&N<=6&&(I===0||I===6)||I>=2&&I<=4&&N>=2&&N<=4?R.set(O+I,C+N,!0,!0):R.set(O+I,C+N,!1,!0))}}function h(R){const A=R.size;for(let k=8;k<A-8;k++){const _=k%2===0;R.set(k,6,_,!0),R.set(6,k,_,!0)}}function m(R,A){const k=o.getPositions(A);for(let _=0;_<k.length;_++){const M=k[_][0],O=k[_][1];for(let C=-2;C<=2;C++)for(let I=-2;I<=2;I++)C===-2||C===2||I===-2||I===2||C===0&&I===0?R.set(M+C,O+I,!0,!0):R.set(M+C,O+I,!1,!0)}}function v(R,A){const k=R.size,_=s.getEncodedBits(A);let M,O,C;for(let I=0;I<18;I++)M=Math.floor(I/3),O=I%3+k-8-3,C=(_>>I&1)===1,R.set(M,O,C,!0),R.set(O,M,C,!0)}function x(R,A,k){const _=R.size,M=d.getEncodedBits(A,k);let O,C;for(O=0;O<15;O++)C=(M>>O&1)===1,O<6?R.set(O,8,C,!0):O<8?R.set(O+1,8,C,!0):R.set(_-15+O,8,C,!0),O<8?R.set(8,_-O-1,C,!0):O<9?R.set(8,15-O-1+1,C,!0):R.set(8,15-O-1,C,!0);R.set(_-8,8,1,!0)}function w(R,A){const k=R.size;let _=-1,M=k-1,O=7,C=0;for(let I=k-1;I>0;I-=2)for(I===6&&I--;;){for(let N=0;N<2;N++)if(!R.isReserved(M,I-N)){let ie=!1;C<A.length&&(ie=(A[C]>>>O&1)===1),R.set(M,I-N,ie),O--,O===-1&&(C++,O=7)}if(M+=_,M<0||k<=M){M-=_,_=-_;break}}}function y(R,A,k){const _=new n;k.forEach(function(N){_.put(N.mode.bit,4),_.put(N.getLength(),p.getCharCountIndicator(N.mode,R)),N.write(_)});const M=t.getSymbolTotalCodewords(R),O=l.getTotalCodewordsCount(R,A),C=(M-O)*8;for(_.getLengthInBits()+4<=C&&_.put(0,4);_.getLengthInBits()%8!==0;)_.putBit(0);const I=(C-_.getLengthInBits())/8;for(let N=0;N<I;N++)_.put(N%2?17:236,8);return S(_,R,A)}function S(R,A,k){const _=t.getSymbolTotalCodewords(A),M=l.getTotalCodewordsCount(A,k),O=_-M,C=l.getBlocksCount(A,k),I=_%C,N=C-I,ie=Math.floor(_/C),Ne=Math.floor(O/C),$=Ne+1,U=ie-Ne,V=new c(U);let G=0;const Y=new Array(C),ae=new Array(C);let pe=0;const W=new Uint8Array(R.buffer);for(let Fe=0;Fe<C;Fe++){const me=Fe<N?Ne:$;Y[Fe]=W.slice(G,G+me),ae[Fe]=V.encode(Y[Fe]),G+=me,pe=Math.max(pe,me)}const ee=new Uint8Array(_);let de=0,Te,we;for(Te=0;Te<pe;Te++)for(we=0;we<C;we++)Te<Y[we].length&&(ee[de++]=Y[we][Te]);for(Te=0;Te<U;Te++)for(we=0;we<C;we++)ee[de++]=ae[we][Te];return ee}function D(R,A,k,_){let M;if(Array.isArray(R))M=u.fromArray(R);else if(typeof R=="string"){let ie=A;if(!ie){const Ne=u.rawSplit(R);ie=s.getBestVersionForData(Ne,k)}M=u.fromString(R,ie||40)}else throw new Error("Invalid data");const O=s.getBestVersionForData(M,k);if(!O)throw new Error("The amount of data is too big to be stored in a QR Code");if(!A)A=O;else if(A<O)throw new Error(`
251
+ The chosen QR Code version cannot contain this amount of data.
252
+ Minimum version required to store current data is: `+O+`.
253
+ `);const C=y(A,k,M),I=t.getSymbolSize(A),N=new r(I);return f(N,A),h(N),m(N,A),x(N,k,0),A>=7&&v(N,A),w(N,C),isNaN(_)&&(_=a.getBestMask(N,x.bind(null,N,k))),a.applyMask(_,N),x(N,k,_),{modules:N,version:A,errorCorrectionLevel:k,maskPattern:_,segments:M}}return _i.create=function(A,k){if(typeof A>"u"||A==="")throw new Error("No input text");let _=e.M,M,O;return typeof k<"u"&&(_=e.from(k.errorCorrectionLevel,e.M),M=s.from(k.version),O=a.from(k.maskPattern),k.toSJISFunc&&t.setToSJISFunction(k.toSJISFunc)),D(A,M,_,O)},_i}var Wi={},ji={},nd;function rd(){return nd||(nd=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 v=Math.floor((u-d)/c),x=Math.floor((f-d)/c);m=p[l[v*a+x]?1:0]}r[h++]=m.r,r[h++]=m.g,r[h++]=m.b,r[h]=m.a}}})(ji)),ji}var od;function Ug(){return od||(od=1,(function(t){const e=rd();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)}})(Wi)),Wi}var Gi={},id;function qg(){if(id)return Gi;id=1;const t=rd();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 Gi.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+'"',v='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+h+' shape-rendering="crispEdges">'+u+f+`</svg>
254
+ `;return typeof l=="function"&&l(null,v),v},Gi}var ad;function Wg(){if(ad)return jt;ad=1;const t=_g(),e=Hg(),n=Ug(),r=qg();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 jt.create=e.create,jt.toCanvas=o.bind(null,n.render),jt.toDataURL=o.bind(null,n.renderToDataURL),jt.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),jt}var jg=Wg();const Gg=xl(jg),sd="http://www.w3.org/2000/svg";function Vg(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 Yg(t,e){const n=document.createElementNS(sd,"svg"),r=Wn(e.barWidth);Ei(n,t,{format:e.barcodeType||"CODE128",width:r,height:Oo*r,displayValue:e.showText!==!1,fontSize:(e.fontSize??Po)*r,margin:0,marginLeft:Dt*r,marginRight:Dt*r,marginTop:0,marginBottom:Ro*r});const o=Vg(n);if(o){const i=Io({unitWidth:o.width/r,unitHeight:o.height/r,boxWidthMm:e.targetWidthMm??0,boxHeightMm:e.targetHeightMm??0,dpi:e.printerDpi,barWidth:e.barWidth});n.setAttribute("width",`${i.widthMm}mm`),n.setAttribute("height",`${i.heightMm}mm`)}return n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}const Xg=0;function Kg(t){return typeof t=="number"&&Number.isFinite(t)?Math.max(0,Math.floor(t)):Xg}function Jg(t,e){const n=(e.qrCodeLevel??"M").toUpperCase(),o=Gg.create(t,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=Kg(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="${sd}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function ld(t,e,n={}){if(!t)throw new Error("empty barcode value");return e==="qrcode"?Jg(t,n):Yg(t,n)}const Vi={render(t,e,n={}){return ld(t,e,n)}},Yi=.5,Zg=12;function Xi(t,e){const n=t.getAttribute(e);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function cd(t,e){if(t.scrollWidth>t.clientWidth+Yi)return!0;const n=t.scrollHeight;return e!==void 0?n>e+Yi:n>t.clientHeight+Yi}function dd(t){if(t.getAttribute("data-fit")!=="shrink")return;const e=ln(Xi(t,"data-fit-min")),n=Math.max(Xi(t,"data-fit-base")??e,e),r=Xi(t,"data-fit-mm"),o=r!==void 0&&r>0?ut(r):void 0,i=s=>{const d=sp(s);return t.style.fontSize=`${d}pt`,t.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!cd(t,o)||n<=e)return a;let l=e,c=n;for(let s=0;s<Zg;s++){const d=(l+c)/2;i(d),cd(t,o)?c=d:l=d}return i(l)}function Qg(t){const e=[];return t.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=dd(n),o=n.getAttribute("data-fit-key");r===void 0||!o||e.push({key:o,fontSizePt:r})}),e}const em="2",tm=5e3;async function nm(t,e=tm){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(rm(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 rm(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 om(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 im(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 am(t){const e={};for(const n of t)try{e[n.key]=ld(n.value,n.cellType,n.opts)}catch{}return e}const sm={version:em,waitReady:nm,readMeasurements:om,readContentBottom:im,renderCodes:am,applyTextFit:Qg};function lm(){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=sm[n],i=r??[],a=ph[n];return a==="window"?o(t.contentWindow,...i):a==="document"?o(e,...i):o(...i)},async close(){t.remove()}}}}}function cm(){return gh(lm())}async function dm(t,e,n,r,o){const i=await Th({templateJson:t,printData:e,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r},cm());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 ud="http://www.w3.org/2000/svg",um=new Set(["draggable","contenteditable","spellcheck"]);function pm(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function xe(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=pm(n)?document.createElementNS(ud,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 typeof l=="boolean"?l&&i.setAttribute(a,um.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)xe(a,i);return e.appendChild(i),i}function pd(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const fm=ud;function Cn(){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 Ki="开启拼版后只能有一个设计页面";function Ji(t){const e=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&cn(i),{id:o.id||Lt(),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 fd(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 hd(t){const e=(r,o)=>{const i=Ji(wp(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!t)return[e(Cn(),0)];const n=Array.isArray(t.pages)?t.pages:[t];return n.length?n.map(e):[e(Cn(),0)]}const Gt=t=>JSON.parse(JSON.stringify(t));class gd{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=$h();group=Lh();constructor(e={}){if(this.pages=hd(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(Ki);return}this.recordHistory();const e=this.pages[this.activePageIndex]??Cn();this.pages.push(Ji({...Cn(),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(Ki);return}this.recordHistory();const n=Gt(this.pages[e]);n.name=`${n.name??`页面 ${e+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:Lt()})),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:Lt(),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=ds(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=Rh(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=ps(r,n.x,n.y);if(o!=="content"&&!us.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Bo(r)[o];return e.zone=o,e.options.left=n.x-i.left,e.options.top=n.y-i.top,o!=="content"&&Ho(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)||$p(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"&&cn(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=Gt(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?yl():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=Gt(i);a.id=Lt(),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:Gt(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:Gt(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:Gt(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=Gn){this.scale=Math.max(n,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(fd),n=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(n)}loadTemplate(e){this.pages=hd(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return pt(this.templateData)}}const it=Symbol("mixed"),Zi=new Set(["text","longText"]),md=["top","right","bottom","left"],hm=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class gm{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";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=>Zi.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:it}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)?it:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?it:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?it:!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")}borderSpec(){return{width:this.borderWidth,style:this.borderStyle,color:this.borderColor}}applyElementBorder(e,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{o.options.borders=void 0,e==="none"?o.options.borderWidth=0:(o.options.borderWidth=n.width,o.options.borderStyle=n.style,o.options.borderColor=n.color)}),this.commit())}applyCellBorderPreset(e,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||(ls(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},e,n),this.commit())}applyCellBorderEdges(e,n,r){this.writeCells(o=>{const i={...o.borders??{}};for(const a of e)r?i[a]={...n}:delete i[a];o.borders=i})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;if(!e.length)return null;const n={};for(const r of md){const o=e.map(i=>!!i.borders?.[r]);n[r]=o.every(Boolean)?!0:o.some(Boolean)?it:!1}return n}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;if(!e.length)return null;const n={};for(const r of md){const o=e.map(i=>!!i.options.borders?.[r]);n[r]=o.every(Boolean)?!0:o.some(Boolean)?it:!1}return n}toggleElementEdge(e,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[e]!==!0;r.forEach(i=>{const a={...i.options.borders??{}};o?a[e]={width:n.width,style:n.style,color:n.color}:delete a[e],i.options.borders=a}),this.commit()}applyBorderPreset(e){this.context==="cells"?this.applyCellBorderPreset(e,this.borderSpec()):this.applyElementBorder(e==="none"?"none":"all",this.borderSpec())}applyEdge(e){this.context==="cells"?this.toggleCellEdge(e,this.borderSpec()):this.toggleElementEdge(e,this.borderSpec())}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 jn){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:Zi.has(o)?Object.fromEntries(hm.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:Ja(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&&Zi.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&Ja(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 bd(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 mm(t){if(Array.isArray(t))return t}function bm(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 vm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
255
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ym(t,e){return mm(t)||bm(t,e)||xm(t,e)||vm()}function xm(t,e){if(t){if(typeof t=="string")return bd(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)?bd(t,e):void 0}}const vd=Object.entries,yd=Object.setPrototypeOf,wm=Object.isFrozen,Em=Object.getPrototypeOf,Sm=Object.getOwnPropertyDescriptor;let ue=Object.freeze,fe=Object.seal,Vt=Object.create,xd=typeof Reflect<"u"&&Reflect,Qi=xd.apply,ea=xd.construct;ue||(ue=function(e){return e}),fe||(fe=function(e){return e}),Qi||(Qi=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)}),ea||(ea=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 St=ce(Array.prototype.forEach),_m=ce(Array.prototype.lastIndexOf),wd=ce(Array.prototype.pop),An=ce(Array.prototype.push),Tm=ce(Array.prototype.splice),Yt=Array.isArray,On=ce(String.prototype.toLowerCase),ta=ce(String.prototype.toString),Ed=ce(String.prototype.match),Pn=ce(String.prototype.replace),Sd=ce(String.prototype.indexOf),km=ce(String.prototype.trim),Mm=ce(Number.prototype.toString),Cm=ce(Boolean.prototype.toString),_d=typeof BigInt>"u"?null:ce(BigInt.prototype.toString),Td=typeof Symbol>"u"?null:ce(Symbol.prototype.toString),_e=ce(Object.prototype.hasOwnProperty),Rn=ce(Object.prototype.toString),he=ce(RegExp.prototype.test),_t=Am(TypeError);function ce(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 Qi(t,e,r)}}function Am(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return ea(t,n)}}function q(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:On;if(yd&&yd(t,null),!Yt(e))return t;let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){const i=n(o);i!==o&&(wm(e)||(e[r]=i),o=i)}t[o]=!0}return t}function Om(t){for(let e=0;e<t.length;e++)_e(t,e)||(t[e]=null);return t}function Re(t){const e=Vt(null);for(const r of vd(t)){var n=ym(r,2);const o=n[0],i=n[1];_e(t,o)&&(Yt(i)?e[o]=Om(i):i&&typeof i=="object"&&i.constructor===Object?e[o]=Re(i):e[o]=i)}return e}function Pm(t){switch(typeof t){case"string":return t;case"number":return Mm(t);case"boolean":return Cm(t);case"bigint":return _d?_d(t):"0";case"symbol":return Td?Td(t):"Symbol()";case"undefined":return Rn(t);case"function":case"object":{if(t===null)return Rn(t);const e=t,n=Be(e,"toString");if(typeof n=="function"){const r=n(e);return typeof r=="string"?r:Rn(r)}return Rn(t)}default:return Rn(t)}}function Be(t,e){for(;t!==null;){const r=Sm(t,e);if(r){if(r.get)return ce(r.get);if(typeof r.value=="function")return ce(r.value)}t=Em(t)}function n(){return null}return n}function Rm(t){try{return he(t,""),!0}catch{return!1}}const kd=ue(["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"]),na=ue(["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"]),ra=ue(["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"]),Im=ue(["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"]),oa=ue(["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"]),Dm=ue(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Md=ue(["#text"]),Cd=ue(["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"]),ia=ue(["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"]),Ad=ue(["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=ue(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),$m=fe(/{{[\w\W]*|^[\w\W]*}}/g),Lm=fe(/<%[\w\W]*|^[\w\W]*%>/g),Nm=fe(/\${[\w\W]*/g),Fm=fe(/^data-[\-\w.\u00B7-\uFFFF]+$/),zm=fe(/^aria-[\-\w]+$/),Od=fe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Bm=fe(/^(?:\w+script|data):/i),Hm=fe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Um=fe(/^html$/i),qm=fe(/^[a-z][.\w]*(-[.\w]+)+$/i),Pd=fe(/<[/\w!]/g),Rd=fe(/<[/\w]/g),Wm=fe(/<\/no(script|embed|frames)/i),jm=fe(/\/>/i),Ie={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Id=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Gm=ue(q({},Id)),Vm=(function(){const t={};return St(Id,e=>{t[e]=fe(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),ue(t)})(),Ym=function(){return typeof window>"u"?null:window},Xm=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}},Dd=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},at=function(e,n,r,o){return _e(e,n)&&Yt(e[n])?q(o.base?Re(o.base):{},e[n],o.transform):r},aa=function(e,n,r){const o=_e(e,n)?e[n]:void 0;return o&&typeof o=="object"?Re(o):r()};function $d(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ym();const e=P=>$d(P);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==Ie.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=Be(u,"cloneNode"),h=Be(u,"remove"),m=Be(u,"nextSibling"),v=Be(u,"childNodes"),x=Be(u,"parentNode"),w=Be(u,"shadowRoot"),y=Be(u,"attributes"),S=a&&a.prototype?Be(a.prototype,"nodeType"):null,D=a&&a.prototype?Be(a.prototype,"nodeName"):null,R=a&&a.prototype?Be(a.prototype,"ownerDocument"):null,A=function(b){return S?S(b):b.nodeType},k=function(b){return D?D(b):b.nodeName};if(typeof i=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let _,M="",O,C=!1,I=0;const N=function(){if(I>0)throw _t('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.')},ie=function(b){N(),I++;try{return _.createHTML(b)}finally{I--}},Ne=function(b){N(),I++;try{return _.createScriptURL(b)}finally{I--}},$=function(){return C||(O=Xm(p,o),C=!0),O},U=n,V=U.implementation,G=U.createNodeIterator,Y=U.createDocumentFragment,ae=U.getElementsByTagName,pe=r.importNode;let W=Dd();e.isSupported=typeof vd=="function"&&typeof x=="function"&&V&&V.createHTMLDocument!==void 0;const ee=$m,de=Lm,Te=Nm,we=Fm,Fe=zm,me=Bm,Qt=Hm,Nn=qm;let Fn=Od,Z=null;const en=q({},[...kd,...na,...ra,...oa,...Md]);let K=null;const tt=q({},[...Cd,...ia,...Ad,...no]);let Ee=Object.seal(Vt(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}})),nt=null,se=null;const te=Object.seal(Vt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ho=!0,zn=!0,Ru=!1,Iu=!0,ct=!1,Pt=!0,Rt=!1,La=!1,go=null,mo=null,Na=!1,tn=!1,bo=!1,vo=!1,Du=!0,$u=!1;const Lu="user-content-";let Fa=!0,za=!1,nn={},rn=null;const Nu=q({},["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 Fu=null;const zu=q({},["audio","video","img","source","image","track"]);let Bu=null;const Hu=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),yo="http://www.w3.org/1998/Math/MathML",xo="http://www.w3.org/2000/svg",Ge="http://www.w3.org/1999/xhtml";let on=Ge,Ba=!1,Ha=null;const N1=q({},[yo,xo,Ge],ta),Uu=ue(["mi","mo","mn","ms","mtext"]);let Ua=q({},Uu);const qu=ue(["annotation-xml"]);let qa=q({},qu);const F1=q({},["title","style","font","a","script"]);let Bn=null;const z1=["application/xhtml+xml","text/html"],B1="text/html";let le=null,an=null;const H1=n.createElement("form"),Wu=function(b){return b instanceof RegExp||b instanceof Function},Wa=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(an&&an===b)return;(!b||typeof b!="object")&&(b={}),b=Re(b),Bn=z1.indexOf(b.PARSER_MEDIA_TYPE)===-1?B1:b.PARSER_MEDIA_TYPE,le=Bn==="application/xhtml+xml"?ta:On,Z=at(b,"ALLOWED_TAGS",en,{transform:le}),K=at(b,"ALLOWED_ATTR",tt,{transform:le}),Ha=at(b,"ALLOWED_NAMESPACES",N1,{transform:ta}),Bu=at(b,"ADD_URI_SAFE_ATTR",Hu,{transform:le,base:Hu}),Fu=at(b,"ADD_DATA_URI_TAGS",zu,{transform:le,base:zu}),rn=at(b,"FORBID_CONTENTS",Nu,{transform:le}),nt=at(b,"FORBID_TAGS",Re({}),{transform:le}),se=at(b,"FORBID_ATTR",Re({}),{transform:le}),nn=_e(b,"USE_PROFILES")?b.USE_PROFILES&&typeof b.USE_PROFILES=="object"?Re(b.USE_PROFILES):b.USE_PROFILES:!1,ho=b.ALLOW_ARIA_ATTR!==!1,zn=b.ALLOW_DATA_ATTR!==!1,Ru=b.ALLOW_UNKNOWN_PROTOCOLS||!1,Iu=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ct=b.SAFE_FOR_TEMPLATES||!1,Pt=b.SAFE_FOR_XML!==!1,Rt=b.WHOLE_DOCUMENT||!1,tn=b.RETURN_DOM||!1,bo=b.RETURN_DOM_FRAGMENT||!1,vo=b.RETURN_TRUSTED_TYPE||!1,Na=b.FORCE_BODY||!1,Du=b.SANITIZE_DOM!==!1,$u=b.SANITIZE_NAMED_PROPS||!1,Fa=b.KEEP_CONTENT!==!1,za=b.IN_PLACE||!1,Fn=Rm(b.ALLOWED_URI_REGEXP)?b.ALLOWED_URI_REGEXP:Od,on=typeof b.NAMESPACE=="string"?b.NAMESPACE:Ge,Ua=aa(b,"MATHML_TEXT_INTEGRATION_POINTS",()=>q({},Uu)),qa=aa(b,"HTML_INTEGRATION_POINTS",()=>q({},qu));const E=aa(b,"CUSTOM_ELEMENT_HANDLING",()=>Vt(null));if(Ee=Vt(null),_e(E,"tagNameCheck")&&Wu(E.tagNameCheck)&&(Ee.tagNameCheck=E.tagNameCheck),_e(E,"attributeNameCheck")&&Wu(E.attributeNameCheck)&&(Ee.attributeNameCheck=E.attributeNameCheck),_e(E,"allowCustomizedBuiltInElements")&&typeof E.allowCustomizedBuiltInElements=="boolean"&&(Ee.allowCustomizedBuiltInElements=E.allowCustomizedBuiltInElements),fe(Ee),ct&&(zn=!1),bo&&(tn=!0),nn&&(Z=q({},Md),K=Vt(null),nn.html===!0&&(q(Z,kd),q(K,Cd)),nn.svg===!0&&(q(Z,na),q(K,ia),q(K,no)),nn.svgFilters===!0&&(q(Z,ra),q(K,ia),q(K,no)),nn.mathMl===!0&&(q(Z,oa),q(K,Ad),q(K,no))),te.tagCheck=null,te.attributeCheck=null,_e(b,"ADD_TAGS")&&(typeof b.ADD_TAGS=="function"?te.tagCheck=b.ADD_TAGS:Yt(b.ADD_TAGS)&&(Z===en&&(Z=Re(Z)),q(Z,b.ADD_TAGS,le))),_e(b,"ADD_ATTR")&&(typeof b.ADD_ATTR=="function"?te.attributeCheck=b.ADD_ATTR:Yt(b.ADD_ATTR)&&(K===tt&&(K=Re(K)),q(K,b.ADD_ATTR,le))),_e(b,"ADD_FORBID_CONTENTS")&&Yt(b.ADD_FORBID_CONTENTS)&&(rn===Nu&&(rn=Re(rn)),q(rn,b.ADD_FORBID_CONTENTS,le)),Fa&&(Z["#text"]=!0),Rt&&q(Z,["html","head","body"]),Z.table&&(q(Z,["tbody"]),delete nt.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw _t('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw _t('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const T=_;_=b.TRUSTED_TYPES_POLICY;try{M=ie("")}catch(L){throw _=T,L}}else b.TRUSTED_TYPES_POLICY===null?(_=void 0,M=""):(_===void 0&&(_=$()),_&&typeof M=="string"&&(M=ie("")));ue&&ue(b),an=b},ju=q({},[...na,...ra,...Im]),Gu=q({},[...oa,...Dm]),U1=function(b,E,T){return E.namespaceURI===Ge?b==="svg":E.namespaceURI===yo?b==="svg"&&(T==="annotation-xml"||Ua[T]):!!ju[b]},q1=function(b,E,T){return E.namespaceURI===Ge?b==="math":E.namespaceURI===xo?b==="math"&&qa[T]:!!Gu[b]},W1=function(b,E,T){return E.namespaceURI===xo&&!qa[T]||E.namespaceURI===yo&&!Ua[T]?!1:!Gu[b]&&(F1[b]||!ju[b])},j1=function(b){let E=x(b);(!E||!E.tagName)&&(E={namespaceURI:on,tagName:"template"});const T=On(b.tagName),L=On(E.tagName);return Ha[b.namespaceURI]?b.namespaceURI===xo?U1(T,E,L):b.namespaceURI===yo?q1(T,E,L):b.namespaceURI===Ge?W1(T,E,L):!!(Bn==="application/xhtml+xml"&&Ha[b.namespaceURI]):!1},dt=function(b){An(e.removed,{element:b});try{x(b).removeChild(b)}catch{if(h(b),!x(b))throw _t("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Vu=function(b,E,T){try{b.removeAttributeNode(E)}catch{try{b.removeAttribute(T)}catch{}}},wo=function(b){Eo(b);const E=v(b);if(E){const L=[];St(E,F=>{An(L,F)}),St(L,F=>{try{h(F)}catch{}})}const T=y(b);if(T)for(let L=T.length-1;L>=0;--L){const F=T[L],B=F&&F.name;typeof B=="string"&&Vu(b,F,B)}},It=function(b,E,T){if(!T)try{T=E.getAttributeNode(b)}catch{T=null}An(e.removed,{attribute:T||null,from:E});try{T?E.removeAttributeNode(T):E.removeAttribute(b)}catch{try{E.removeAttribute(b)}catch{}}if(b==="is")if(tn||bo)try{dt(E)}catch{}else try{E.setAttribute(b,"")}catch{}},G1=function(b){const E=y(b);if(E)for(let T=E.length-1;T>=0;--T){const L=E[T],F=L&&L.name;typeof F!="string"||K[le(F)]||Vu(b,L,F)}},Eo=function(b){const E=[b];for(;E.length>0;){const T=E.pop();A(T)===Ie.element&&G1(T);const F=v(T);if(F)for(let B=F.length-1;B>=0;--B)E.push(F[B])}},Yu=function(b,E){return Pt?b==="patchsrc"?!0:b==="for"&&E!=="label"&&E!=="output":!1},V1=function(b){if(!Pt)return;const E=[b];for(;E.length>0;){const T=E.pop(),L=A(T);if(L===Ie.processingInstruction||L===Ie.comment&&he(Rd,T.data)){try{h(T)}catch{}continue}if(L===Ie.element){const B=T,J=le(k(T));try{B.hasAttribute&&B.hasAttribute("patchsrc")&&B.removeAttribute("patchsrc"),B.hasAttribute&&B.hasAttribute("for")&&Yu("for",J)&&B.removeAttribute("for")}catch{}}const F=v(T);if(F)for(let B=F.length-1;B>=0;--B)E.push(F[B])}},Xu=function(b){let E=null,T=null;if(Na)b="<remove></remove>"+b;else{const B=Ed(b,/^[\r\n\t ]+/);T=B&&B[0]}Bn==="application/xhtml+xml"&&on===Ge&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const L=_?ie(b):b;if(on===Ge)try{E=new d().parseFromString(L,Bn)}catch{}if(!E||!E.documentElement){E=V.createDocument(on,"template",null);try{E.documentElement.innerHTML=Ba?M:L}catch{}}const F=E.body||E.documentElement;return b&&T&&F.insertBefore(n.createTextNode(T),F.childNodes[0]||null),on===Ge?ae.call(E,Rt?"html":"body")[0]:Rt?E.documentElement:F},Ku=function(b){const E=R?R(b):b.ownerDocument;return G.call(E||b,b,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},So=function(b){return b=Pn(b,ee," "),b=Pn(b,de," "),b=Pn(b,Te," "),b},ja=function(b){var E;b.normalize();const T=R?R(b):b.ownerDocument,L=G.call(T||b,b,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let F=L.nextNode();for(;F;)F.data=So(F.data),F=L.nextNode();const B=(E=b.querySelectorAll)===null||E===void 0?void 0:E.call(b,"template");B&&St(B,J=>{sn(J.content)&&ja(J.content)})},_o=function(b){const E=D?D(b):null;return typeof E!="string"||le(E)!=="form"?!1:typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||b.attributes!==y(b)||typeof b.removeAttribute!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function"||b.nodeType!==S(b)||b.childNodes!==v(b)},sn=function(b){if(!S||typeof b!="object"||b===null)return!1;try{return S(b)===Ie.documentFragment}catch{return!1}},Hn=function(b){if(!S||typeof b!="object"||b===null)return!1;try{return typeof S(b)=="number"}catch{return!1}};function Ve(P,b,E){P.length!==0&&St(P,T=>{T.call(e,b,E,an)})}const Y1=function(b,E){return!!(Pt&&b.hasChildNodes()&&!Hn(b.firstElementChild)&&he(Pd,b.textContent)&&he(Pd,b.innerHTML)||Pt&&b.namespaceURI===Ge&&Gm[E]&&(Hn(b.firstElementChild)||typeof b.textContent=="string"&&he(Vm[E],b.textContent))||b.nodeType===Ie.processingInstruction||Pt&&b.nodeType===Ie.comment&&he(Rd,b.data))},To=function(b,E){if(b instanceof RegExp)return he(b,E);if(b instanceof Function){for(var T=arguments.length,L=new Array(T>2?T-2:0),F=2;F<T;F++)L[F-2]=arguments[F];return!!b(E,...L)}return!1},X1=function(b,E,T){if(!nt[E]&&tp(E)&&To(Ee.tagNameCheck,E))return!1;if(Fa&&!rn[E]){const L=x(b),F=v(b);if(F&&L){const B=F.length;for(let J=B-1;J>=0;--J){const ne=b===T?f(F[J],!0):F[J];L.insertBefore(ne,m(b))}}}return dt(b),!0},Ju=function(b,E,T,L){return b.length===0?E:E===T||E===L?Re(E):E},Zu=function(b,E){return b===E||x(b)!==null?!1:(za&&Eo(b),!0)},Qu=function(b,E){if(Ve(W.beforeSanitizeElements,b,null),Zu(b,E))return!0;if(_o(b))return dt(b),!0;const T=le(k(b));if(Z=Ju(W.uponSanitizeElement,Z,en,go),Ve(W.uponSanitizeElement,b,{tagName:T,allowedTags:Z}),Zu(b,E))return!0;if(Y1(b,T))return dt(b),!0;if(nt[T]||!(te.tagCheck instanceof Function&&te.tagCheck(T))&&!Z[T]){const F=X1(b,T,E);return F===!1&&Ve(W.afterSanitizeElements,b,null),F}if(A(b)===Ie.element&&!j1(b)||(T==="noscript"||T==="noembed"||T==="noframes")&&he(Wm,b.innerHTML))return dt(b),!0;if(ct&&b.nodeType===Ie.text){const F=So(b.textContent);b.textContent!==F&&(An(e.removed,{element:b.cloneNode()}),b.textContent=F)}return Ve(W.afterSanitizeElements,b,null),!1},ep=function(b,E,T){if(se[E]||Yu(E,b)||Du&&(E==="id"||E==="name")&&(T in n||T in H1))return!1;const L=K[E]||te.attributeCheck instanceof Function&&te.attributeCheck(E,b);return zn&&he(we,E)||ho&&he(Fe,E)?!0:L?Bu[E]||he(Fn,Pn(T,Qt,""))||(E==="src"||E==="xlink:href"||E==="href")&&b!=="script"&&Sd(T,"data:")===0&&Fu[b]||Ru&&!he(me,Pn(T,Qt,""))?!0:!T:tp(b)&&To(Ee.tagNameCheck,b)&&To(Ee.attributeNameCheck,E,b)||E==="is"&&Ee.allowCustomizedBuiltInElements&&To(Ee.tagNameCheck,T)},K1=q({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),tp=function(b){return!K1[On(b)]&&he(Nn,b)},J1=function(b,E,T,L){if(_&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!T)switch(p.getAttributeType(b,E)){case"TrustedHTML":return ie(L);case"TrustedScriptURL":return Ne(L)}return L},Z1=function(b,E,T,L){try{T?b.setAttributeNS(T,E,L):b.setAttribute(E,L),_o(b)?dt(b):wd(e.removed)}catch{It(E,b)}},np=function(b){Ve(W.beforeSanitizeAttributes,b,null);const E=b.attributes;if(!E||_o(b))return;K=Ju(W.uponSanitizeAttribute,K,tt,mo);const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let L=E.length;const F=le(b.nodeName);for(;L--;){const B=E[L],J=B.name,ne=B.namespaceURI,ke=B.value,Me=le(J),Va=ke;let Se=J==="value"?Va:km(Va);if(T.attrName=Me,T.attrValue=Se,T.keepAttr=!0,T.forceKeepAttr=void 0,Ve(W.uponSanitizeAttribute,b,T),Se=T.attrValue,$u&&(Me==="id"||Me==="name")&&Sd(Se,Lu)!==0&&(It(J,b,B),Se=Lu+Se),Pt&&he(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Se)){It(J,b,B);continue}if(Me==="attributename"&&Ed(Se,"href")){It(J,b,B);continue}if(!T.forceKeepAttr){if(!T.keepAttr){It(J,b,B);continue}if(!Iu&&he(jm,Se)){It(J,b,B);continue}if(ct&&(Se=So(Se)),!ep(F,Me,Se)){It(J,b,B);continue}Se=J1(F,Me,ne,Se),Se!==Va&&Z1(b,J,ne,Se)}}Ve(W.afterSanitizeAttributes,b,null)},ko=function(b){let E=null;const T=Ku(b);for(Ve(W.beforeSanitizeShadowDOM,b,null);E=T.nextNode();)if(Ve(W.uponSanitizeShadowNode,E,null),Qu(E,b),np(E),sn(E.content)&&ko(E.content),A(E)===Ie.element){const L=w(E);sn(L)&&(Ga(L),ko(L))}Ve(W.afterSanitizeShadowDOM,b,null)},Ga=function(b){const E=[{node:b,shadow:null}];for(;E.length>0;){const T=E.pop();if(T.shadow){ko(T.shadow);continue}const L=T.node,B=A(L)===Ie.element,J=v(L);if(J)for(let ne=J.length-1;ne>=0;--ne)E.push({node:J[ne],shadow:null});if(B){const ne=D?D(L):null;if(typeof ne=="string"&&le(ne)==="template"){const ke=L.content;sn(ke)&&E.push({node:ke,shadow:null})}}if(B){const ne=w(L);sn(ne)&&E.push({node:null,shadow:ne},{node:ne,shadow:null})}}};return e.sanitize=function(P){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,T=null,L=null,F=null;if(Ba=!P,Ba&&(P="<!-->"),typeof P!="string"&&!Hn(P)&&(P=Pm(P),typeof P!="string"))throw _t("dirty is not a string, aborting");if(!e.isSupported)return P;La?(Z=go,K=mo):Wa(b),(W.uponSanitizeElement.length>0||W.uponSanitizeAttribute.length>0)&&(Z=Re(Z)),W.uponSanitizeAttribute.length>0&&(K=Re(K)),e.removed=[];const B=za&&typeof P!="string"&&Hn(P);if(B){V1(P);const ke=k(P);if(typeof ke=="string"){const Me=le(ke);if(!Z[Me]||nt[Me])throw wo(P),_t("root node is forbidden and cannot be sanitized in-place")}if(_o(P))throw wo(P),_t("root node is clobbered and cannot be sanitized in-place");try{Ga(P)}catch(Me){throw wo(P),Me}}else if(Hn(P))E=Xu("<!---->"),T=E.ownerDocument.importNode(P,!0),T.nodeType===Ie.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?E=T:E.appendChild(T),Ga(T);else{if(!tn&&!ct&&!Rt&&P.indexOf("<")===-1)return _&&vo?ie(P):P;if(E=Xu(P),!E)return tn?null:vo?M:""}E&&Na&&dt(E.firstChild);const J=B?P:E;try{const ke=Ku(J);for(;L=ke.nextNode();)Qu(L,J),np(L),sn(L.content)&&ko(L.content)}catch(ke){throw B&&(wo(P),St(e.removed,Me=>{Me.element&&Eo(Me.element)})),ke}if(B)return St(e.removed,ke=>{ke.element&&Eo(ke.element)}),ct&&ja(P),P;if(tn){if(ct&&ja(E),bo)for(F=Y.call(E.ownerDocument);E.firstChild;)F.appendChild(E.firstChild);else F=E;return(K.shadowroot||K.shadowrootmode)&&(F=pe.call(r,F,!0)),F}let ne=Rt?E.outerHTML:E.innerHTML;return Rt&&Z["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&he(Um,E.ownerDocument.doctype.name)&&(ne="<!DOCTYPE "+E.ownerDocument.doctype.name+`>
256
+ `+ne),ct&&(ne=So(ne)),_&&vo?ie(ne):ne},e.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Wa(P),La=!0,go=Z,mo=K},e.clearConfig=function(){an=null,La=!1,go=null,mo=null,_=O,M=""},e.isValidAttribute=function(P,b,E){an||Wa({});const T=le(P),L=le(b);return ep(T,L,E)},e.addHook=function(P,b){typeof b=="function"&&_e(W,P)&&An(W[P],b)},e.removeHook=function(P,b){if(_e(W,P)){if(b!==void 0){const E=_m(W[P],b);return E===-1?void 0:Tm(W[P],E,1)[0]}return wd(W[P])}},e.removeHooks=function(P){_e(W,P)&&(W[P]=[])},e.removeAllHooks=function(){W=Dd()},e}var Km=$d();const Jm={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Zm(t){const e=t.options;return String(e.testData||e.formatter||e.title||"")||"条码"}function Qm(t){return g("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function e0(t){const e=t.options;return g("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[g("svg",{preserveAspectRatio:Jm[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function t0(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 n0(t,e){const n=t.options,r=Wn(n.barWidth);try{Ei(e,Zm(t),{format:String(n.barcodeType||"CODE128"),width:r,height:Oo*r,displayValue:!n.hideTitle,fontSize:(n.fontSize??Po)*r,margin:0,marginLeft:Dt*r,marginRight:Dt*r,marginTop:0,marginBottom:Ro*r})}catch{e.replaceChildren();return}const o=t0(e),i=o?Io({unitWidth:o.width/r,unitHeight:o.height/r,boxWidthMm:$t(n.width,n.maxWidth),boxHeightMm:$t(n.height,n.maxHeight),dpi:n.printerDpi,barWidth:n.barWidth}):null;e.style.width=i?`${i.widthMm}mm`:"",e.style.height=i?`${i.heightMm}mm`:"",e.setAttribute("shape-rendering","crispEdges")}function r0(t,e){const n=t.options,r=String(n.testData||n.formatter||n.title||"")||"二维码";e.replaceChildren();try{const o=Vi.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 o0(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&&n0(o,i)}else r0(o,n)}}const i0={header:"题",data:"数",subtotal:"小",summary:"汇"},a0=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],ro=3.7795275591,s0=.1,sa=t=>JSON.parse(JSON.stringify(t)),Ld=new WeakMap;function Ke(t){let e=Ld.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Ld.set(t,e)),e}function In(t,e){return t.templateData.elements.find(n=>n.id===e)??null}function l0(t,e){const n=t.tableSelection;return!n||n.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):n}function Nd(t,e,n){const r=In(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:l0(t,n),maxTableWidth:Fd(t)}}function Fd(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function la(t){return t.options.tableDefaultFontSize??10}function zd(t){return t.options.tableDefaultColor??"#333333"}function c0(t,e){let n=0;for(let r=0;r<e;r++)n+=t.rows[r].height;return n}function d0(t,e){return Ke(t.store).layouts.get(t.el.id)?.[e]?.top??c0(t,e)}function u0(t,e){return Ke(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function p0(t){const e=t.options.dataSource;if(e&&Array.isArray(ht[e]))return ht[e];for(const n of Object.values(ht))if(Array.isArray(n))return n}function Bd(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function Hd(t,e){return Bd(e)?Ih(e.formatter,p0(t)):e.formatter||""}function f0(t,e){const n={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:e.fontFamily||"inherit",textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??la(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??zd(t),backgroundColor:e.backgroundColor??"transparent",borderTop:Yn(e.borders?.top,n),borderRight:Yn(e.borders?.right,n),borderBottom:Yn(e.borders?.bottom,n),borderLeft:Yn(e.borders?.left,n),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"normal":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function h0(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 Ud(t){return Mo(t)}function g0(t){return Ud(t)!=="autoHeight"}function m0(t,e){return e.fontSize??la(t)}function ca(t,e,n){return Ao(t.rows,e,n,t.options.tableDefaultPadding??1)}function b0(t,e,n){return Xa(t.colWidths,e,n,t.options.tableDefaultPadding??1)}function v0(t,e,n){return{maxHeight:ca(t,n,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function y0(t,e,n){const r={fitBase:String(m0(t,e)),fitMin:String(ln(e.shrinkMinFontSize)),fitMm:String(ca(t,n,e))};return Ud(e)==="shrink"&&(r.fit="shrink"),r}function x0(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 w0={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function E0(t,e,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(fm,"svg");o.appendChild(i);const a=Hd(t,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",w0[r.fit||"contain"]??"xMidYMid meet");const l=Wn(r.barWidth);let c=!0;try{Ei(i,a,{format:r.barcodeType||"CODE128",width:l,height:Oo*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??Po)*l,margin:0,marginLeft:Dt*l,marginRight:Dt*l,marginTop:0,marginBottom:Ro*l})}catch{c=!1}if(!c){i.style.display="none";const p=document.createElement("span");return p.className="cell-barcode-fallback",p.textContent=a||"条码",o.appendChild(p),o}const s=x0(i),d=s?Io({unitWidth:s.width/l,unitHeight:s.height/l,boxWidthMm:$t(b0(t,n,r),r.maxWidth),boxHeightMm:$t(ca(t,e,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth}):null;return d?(i.style.width=`${d.widthMm}mm`,i.style.height=`${d.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=Vi.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 qd(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function S0(t){const e=t.formatter||"";return e?e.includes("{")?hr(e,ht):e:""}function _0(t){const e=document.createElement("div");e.className="cell-image";const n=S0(t);if(!n)return e.appendChild(qd()),e;const r=document.createElement("img");return r.setAttribute("src",n),r.style.objectFit=t.fit||"contain",t.objectPosition&&(r.style.objectPosition=t.objectPosition),r.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",r.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",r.addEventListener("error",()=>{r.remove(),e.appendChild(qd())},{once:!0}),e.appendChild(r),e}function T0(t,e,n,r,o){if(Bd(o))return E0(t,n,r,o);if(o.cellType==="image")return _0(o);const i=Hd(t,o),a=()=>e.type==="data"?g("span",{class:"data-placeholder",text:i}):i;return g0(o)?g("div",{class:"cell-fit",style:v0(t,o,n),dataset:y0(t,o,n)},[a()]):a()}function oo(t,e,n){const r={elementId:t.el.id,...ns(t.rows,e,n)};t.store.setTableSelection(r),t.fire("table-selection-change",{elementId:t.el.id,selection:r})}function k0(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=Ke(t.store);o.shiftKey&&t.selection?oo(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:n}):(i.anchor={r:e,c:n},oo(t,{r:e,c:n},{r:e,c:n})),document.addEventListener("mouseup",()=>{Ke(t.store).anchor=null},{once:!0})}function M0(t,e,n){const r=Ke(t.store).anchor;r&&oo(t,r,{r:e,c:n})}function Wd(t,e){const n=Ke(t);n.menu?.visible&&(n.menu.visible=!1,e("table-menu-close",{elementId:n.menuElId}),t.emit(!1))}function C0(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||oo(t,{r:e,c:n},{r:e,c:n});const a=Ke(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",()=>Wd(t.store,t.fire),{once:!0})}function jd(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 A0(t,e){const n=t.real.options.tableRows??[],r=t.real.options.tableColWidths??[],o=e(sa(n),sa(r));return o?(window.alert(o),!1):(t.store.recordHistory(),e(n,r),t.store.setTableSelection(null),cn(t.real.options),t.store.emit(),!0)}function Je(t,e,n){Wd(t.store,t.fire);const r=t.selection;if(!r)return;let o=null;switch(e){case"insert-row-above":o=i=>(as(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(as(i,r.r2,"below"),null);break;case"delete-row":o=i=>Cp(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=jd(a,r.c1,t.maxTableWidth);return l||(ss(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=jd(a,r.c2,t.maxTableWidth);return l||(ss(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>Ap(i,a,r.c1);break;case"merge":o=i=>(os(i,r),null);break;case"split":o=i=>(is(i,r),null);break;case"set-row-type":o=i=>n?zo(i,r.r1,n):"未指定行类型";break}o&&A0(t,o)&&t.fire(`table-${e}`,{elementId:t.el.id,...n?{type:n}:{}})}function O0(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 Gd(t,e){const n=t.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":zo(sa(t.rows),n.r1,e):"未选择单元格"}function Ze(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 da=()=>g("div",{class:"menu-divider"});function P0(t,e,n){const r=Ke(t);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=In(t,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=Nd(t,e,o);if(!i)return"";const a=i.selection?rs(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()},[Ze("在上方插入行",()=>Je(i,"insert-row-above")),Ze("在下方插入行",()=>Je(i,"insert-row-below")),Ze("删除行",()=>Je(i,"delete-row"),{disabled:i.rows.length<=1}),da(),Ze("在左侧插入列",()=>Je(i,"insert-col-left")),Ze("在右侧插入列",()=>Je(i,"insert-col-right")),Ze("删除列",()=>Je(i,"delete-col"),{disabled:i.colWidths.length<=1}),da(),Ze("合并单元格",()=>Je(i,"merge"),{disabled:!!a,title:a||""}),Ze("拆分单元格",()=>Je(i,"split"),{disabled:!O0(i)}),da(),g("div",{class:"menu-group-title",text:"行类型"}),...a0.map(c=>Ze(c.label,()=>Je(i,"set-row-type",c.value),{disabled:!!Gd(i,c.value),title:Gd(i,c.value)||"",active:l===c.value}))])}let Tt=null;function Vd(){Tt&&(document.removeEventListener("mousemove",ua),document.removeEventListener("mouseup",pa),Tt.handle.classList.remove("dragging"),Tt=null)}function R0(t,e){const n=t.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(e.scale||100)/100}function I0(t,e,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;Vd();const i=t.real.options.tableColWidths??[];Tt={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:n.clientX,startWidth:i[e-1]??0,scale:R0(o,t.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",ua),document.addEventListener("mouseup",pa)}function ua(t){const e=Tt;if(!e)return;const n=In(e.store,e.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(t.clientX-e.startX)/(e.scale*ro),i=e.boundary-1;r[i]=Rp(r,i,e.startWidth+o,Fd(e.store)),cn(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 pa(){document.removeEventListener("mousemove",ua),document.removeEventListener("mouseup",pa);const t=Tt;if(!t)return;Tt=null,t.handle.classList.remove("dragging");const e=In(t.store,t.elId);e&&cn(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function D0(t,e,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=In(t,e);if(!i)return;let a=!1;const l=o/ro;Math.abs(l-(i.options.height??0))>s0&&(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)/ro,height:p.offsetHeight/ro})),d=Ke(t);$0(d.layouts.get(e),s)||(d.layouts.set(e,s),a=!0),a&&t.emit(!1)}function $0(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 L0(t,e){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&D0(t,e,r)}),n}function N0(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function F0(t){return Array.from({length:t.colWidths.length},(e,n)=>n+1)}function z0(t,e){return t.colWidths.slice(0,e).reduce((n,r)=>n+r,0)}function B0(t,e,n){const r=Nd(e,n,t);if(!r)return g("div",{class:"print-table"});const o=[g("table",{style:{fontSize:`${la(r)}pt`,color:zd(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:h0(r,a,c),style:f0(r,l),onMousedown:s=>k0(r,a,c,l.id,s),onMouseenter:()=>M0(r,a,c),onContextmenu:s=>C0(r,a,c,s)},[T0(r,i,a,c,l)])).filter(Boolean))))])];return N0(r)&&o.push(g("div",{class:"col-resize-layer"},F0(r).map(i=>g("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${i}`,style:{left:z0(r,i)+"mm"},onMousedown:a=>{a.stopPropagation(),a.preventDefault(),I0(r,i,a)}})))),r.isSelected&&o.push(g("div",{class:"row-badges"},r.rows.map((i,a)=>g("span",{class:"row-badge",style:{top:d0(r,a)+"mm",height:u0(r,a)+"mm"},text:i0[i.type]})))),o.push(L0(e,t.id)),g("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:i=>i.preventDefault()},o)}const Yd={top:"flex-start",middle:"center",bottom:"flex-end"},H0={left:"flex-start",center:"center",right:"flex-end"};function U0(t){const e=t.options,n=Qa(t.printElementType.type,e),r={};if(n?.all&&(r.border=`${n.all.borderWidth} ${n.all.borderStyle} ${n.all.borderColor}`),n)for(const o of jn){const i=n.edges[o];i&&(r[`border${o.charAt(0).toUpperCase()}${o.slice(1)}`]=`${i.borderWidth} ${i.borderStyle} ${i.borderColor}`)}return{position:"absolute",left:`${e.left}mm`,top:`${e.top}mm`,width:`${e.width}mm`,height:`${e.height}mm`,zIndex:String(e.zIndex||"auto"),...r}}function Xd(t){const e=t.options,n=t.printElementType.type==="longText",r=qn(t.printElementType.type,e),o=e.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:e.fontWeight||"normal",fontFamily:e.fontFamily||"inherit",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`}};return e.wordWrap===!1&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis"),e.verticalAlign&&(a.display="flex",e.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Yd[e.verticalAlign]??"flex-start"):(a.alignItems=Yd[e.verticalAlign]??"flex-start",a.justifyContent=H0[e.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function q0(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 W0(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 j0(t){const e=t.options;return{objectFit:e.fit||"contain",...e.objectPosition?{objectPosition:e.objectPosition}:{},maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function Kd(t){const e=t.options,n={fitBase:String(e.fontSize||12),fitMin:String(ln(e.shrinkMinFontSize))};return qn(t.printElementType.type,e)==="shrink"&&(n.fit="shrink"),n}function G0(t,e,n){const r=t.printElementType.type,o=t.options;switch(r){case"text":{const{style:i}=Xd(t);return g("div",{class:"print-text",style:i,dataset:Kd(t),text:String(o.testData||o.formatter||"")||"文本"})}case"longText":{const{style:i}=Xd(t);return g("div",{class:"print-longtext",style:i,dataset:Kd(t),text:String(o.formatter||"")||"长文本内容"})}case"hline":case"vline":return g("div",{class:"print-line",style:q0(t)});case"rect":case"oval":return g("div",{class:"print-shape",style:W0(t)});case"image":{const i=String(o.src??""),a=i.includes("{")?hr(i,ht):i;return g("div",{class:"print-image"},[a?g("img",{src:a,style:j0(t)}):g("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return Qm(t);case"barcode":return e0(t);case"html":{const i=String(o.formatter??""),a=i?Km.sanitize(hr(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:o.fontFamily||"inherit",color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:o.title||"{pageIndex}/{totalPages}"});case"table":return n?B0(t,n.store,n.fire):g("div",{class:"print-table"});default:return g("div",{text:r})}}function Jd(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function V0(t,e){const n=t.store,r=n.selectedIds.has(e.id),o=n.previewIds.has(e.id),i=e.options,a=e.zone||"content",l=[G0(e,!0,{store:n,fire:t.fire})];return n.draggingIds.has(e.id)&&l.push(g("div",{class:"drag-preview"})),r&&(l.push(g("div",{class:"resize-handles"},Nh.map(c=>g("div",{class:`resize-handle handle-${c}`,dataset:{point:c,elId:e.id},onMousedown:s=>t.fire("resize-start",{event:s,id:e.id,point:c})})))),l.push(g("div",{class:"selected-indicator"},[g("div",{class:"position-label",text:Jd(i)})]))),g("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${a}`,r?"selected":"",o?"previewed":"",n.draggingIds.has(e.id)?"drag-ghost":"","design-mode",i.locked?"locked":"",i.visible===!1?"hidden":""].filter(Boolean).join(" "),style:U0(e),dataset:{elId:e.id},onMousedown:c=>t.fire("element-mousedown",{event:c,id:e.id}),onContextmenu:c=>{c.preventDefault(),c.stopPropagation(),t.fire("contextmenu",{event:c,id:e.id})}},l)}function fa(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 Y0='<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 Zd(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 X0(t,e){const n=Vs(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 ha(t,e,n,r,o,i){const a=t.store,l=[];if(n!=="content"&&l.push(g("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"})),l.push(...o.map(c=>V0(t,c))),n!=="content"){const c=n==="header"?"bottom":"top";l.push(g("div",{class:`zone-resize-handle handle-${c}`,dataset:{zone:n},onMousedown:s=>t.fire("zone-resize",{event:s,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 K0(t,e){const n=t.store,r=n.templateData,o=ve(r),i=(n.scale||100)/100,a=fa(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(Y0)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[X0(r,o)]:[],ha(t,e,"header",a.header,l("header"),o),ha(t,e,"content",a.content,l("content"),o),ha(t,e,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>g("div",{class:`adsorb-guide guide-${p.type}`,style:Zd(p,o)})),...(r.guides??[]).map(p=>g("div",{class:`manual-guide guide-${p.type}`,style:{...Zd(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:`${cr(o.width)*i}px`,height:`${cr(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?[He(t,p,"复制","copy"),He(t,p,"剪切","cut"),He(t,p,"粘贴","paste",!n.hasClipboard),He(t,p,"删除","delete"),g("div",{class:"context-menu-sep"}),He(t,p,"置顶","move-layer",!1,"top"),He(t,p,"上移","move-layer",!1,"up"),He(t,p,"下移","move-layer",!1,"down"),He(t,p,"置底","move-layer",!1,"bottom")]:[He(t,p,"粘贴","paste-at",!n.hasClipboard),He(t,p,"全选","select-all"),He(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 He(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 J0={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" />',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 De(t,e=15,n){const r=J0[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 kt=null;function ga(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 ma(t){const e=ga(t);return e?Qd(e):"#000000"}function Qd({r:t,g:e,b:n}){return`#${[t,e,n].map(r=>Math.round(Dn(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function Z0(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 Q0(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 eb(t){return((Number.isFinite(t)?t:0)%360+360)%360}function Dn(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function tb(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(!!kt&&kt.root===o&&kt.title===e&&kt.trigger===r){$n();return}$n(),nb(r,t)}},[g("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function $n(){const t=kt;t&&(kt=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function nb(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&&va(o,e.value)?o.hexText=ma(e.value).toUpperCase():o.hexText=e.value?String(e.value):"",o.panel=xe(ab(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:fs[a]})),io(o),rb(o),ob(o),kt=o,t.setAttribute("aria-expanded","true")}function rb(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 ob(t){const e=o=>{const i=ib(o);i.includes(t.trigger)||i.includes(t.panel)||$n()},n=o=>{o.key==="Escape"&&$n()},r=()=>$n();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 ib(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function ab(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=>lb(t,e.target.value)})]),g("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>cb(t,e),onKeydown:e=>db(t,e)},[g("span",{class:"picker-handle"})]),g("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>ub(t,Number(e.target.value)),onChange:()=>ya(t)}),g("div",{class:"picker-heading"},[g("span",{text:"常用颜色"}),t.clearable?g("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>ao(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"},fs.map(e=>g("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>sb(t,e)})))])}function ba(t){return Qd(Q0(t.hue,t.saturation,t.value_))}function io(t){const e=ba(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 va(t,e){const n=ga(e);if(!n)return!1;const r=Z0(n.r,n.g,n.b);return t.hue=r.h,t.saturation=r.s,t.value_=r.v,t.hexText=ma(e).toUpperCase(),!0}function Xt(t,e,n,r){t.hue=eb(e),t.saturation=Dn(n),t.value_=Dn(r),t.hexText=ba(t).toUpperCase(),io(t)}function ya(t){const e=ba(t);t.model=e,io(t),t.onChange(e)}function ao(t,e){t.model=e,e||(t.hexText=""),io(t),t.onChange(e)}function sb(t,e){va(t,e),ao(t,e)}function lb(t,e){const n=e.trim();if(!n){t.clearable&&ao(t,void 0);return}ga(n)&&(va(t,n),ao(t,ma(n)))}function cb(t,e){t.dragging=!0,eu(t,e);const n=o=>{t.dragging&&eu(t,o)},r=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),ya(t))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function eu(t,e){const n=t.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=Dn((e.clientX-n.left)/n.width),o=Dn(1-(e.clientY-n.top)/n.height);Xt(t,t.hue,r,o)}function db(t,e){const n=e.shiftKey?.1:.02;let r=!0;e.key==="ArrowLeft"?Xt(t,t.hue,t.saturation-n,t.value_):e.key==="ArrowRight"?Xt(t,t.hue,t.saturation+n,t.value_):e.key==="ArrowUp"?Xt(t,t.hue,t.saturation,t.value_+n):e.key==="ArrowDown"?Xt(t,t.hue,t.saturation,t.value_-n):r=!1,r&&(e.preventDefault(),ya(t))}function ub(t,e){Xt(t,e,t.saturation,t.value_)}function oe(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:De(e)})}function so(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?De(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${De("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?g("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function X(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 j(t,e,n){return g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:t}),e,n?g("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const pb=t=>g("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function Kt(t,e,n){return g("div",{class:"pd-field"},[g("span",{class:"pd-label"},[t,pb(n)]),e])}const je=t=>g("h3",{class:"pd-divider",text:t});function $e(t,e,n="颜色选择",r){return tb({value:t,title:n,triggerClass:r,onChange:o=>e(o)})}function st(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 fb(t){const e=[],n=new Set;for(const r of t??[]){const i=(typeof r=="string"?{family:r}:r)?.family?.trim();if(!i)continue;const a=i.toLowerCase();if(n.has(a))continue;n.add(a);const l=typeof r=="string"?void 0:r?.label?.trim();e.push(l?{family:i,label:l}:{family:i})}return e}function tu(t,e){const n=e?.trim().toLowerCase();if(n)return t.find(r=>r.family.trim().toLowerCase()===n)}function nu(t){return t.label?`${t.label}(${t.family})`:t.family}function Ln(t){return t.toLowerCase().replace(/\s+/g,"")}function ru(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 hb(t,e){const n=ru(Ln(t.family),e);if(!t.label)return n;const r=ru(Ln(t.label),e);return n<0?r:r<0?n:Math.min(n,r)}function gb(t,e){const n=Ln(e.trim());return n?t.map((r,o)=>({font:r,index:o,rank:hb(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...t]}function xa(t){const e=fb(t.fonts),n=t.placeholder??"默认",r=`font-select-list-${t.id}`,o=A=>{const k=A?.trim();return k?tu(e,k)?.label??k:""},i=A=>{const k=Ln(A);return e.find(M=>M.label&&Ln(M.label)===k)?.family??A},a=()=>{const A=t.value?.trim();return A?tu(e,A)?"":A:""},l=A=>{const k=(t.value??"").trim(),_=(C,I,N,ie)=>({kind:C,key:I,label:N,value:ie,selected:(ie??"")===k}),M=A.trim();if(!M){const C=[_("clear","__clear__",n)],I=a();I&&C.push(_("unknown","__unknown__",`${I}(未知)`,I));for(const N of e)C.push(_("font",N.family,nu(N),N.family));return C}const O=gb(e,M).map(C=>_("font",C.family,nu(C),C.family));if(!O.length){const C=i(M);O.push(_("free","__free__",`使用「${C}」`,C))}return O},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 A=(t.value??"").trim();return l(u.query).findIndex(k=>(k.value??"")===A)},m=()=>{if(!u.open){d.isConnected&&d.remove(),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant","");return}d.isConnected||c.appendChild(d);const A=l(u.query);d.replaceChildren(...A.map((k,_)=>{const M=document.createElement("li");return M.id=`${r}-${_}`,M.className="font-select-option"+(_===u.highlighted?" is-active":"")+(k.kind==="unknown"||k.kind==="free"?" is-muted":""),M.setAttribute("role","option"),M.setAttribute("aria-selected",String(k.selected)),M.textContent=k.label,M.addEventListener("mousedown",O=>{O.preventDefault(),D(k)}),M})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:"")},v=()=>{u.open||t.disabled||(u.open=!0,u.query="",u.highlighted=h(),f(),m())},x=()=>{u.open||v()},w=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),m()},y=A=>{if(!u.open){v();return}const k=l(u.query).length-1;if(k<0)return;u.highlighted=Math.min(Math.max(u.highlighted+A,0),k),f(),m(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},S=()=>{if(!u.open)return;const A=l(u.query)[u.highlighted];if(A){D(A);return}const k=u.query.trim();if(k){const _=i(k);D({value:_})}},D=A=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(A.value),m(),t.onChange(A.value)},R=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(t.value),m())};return s.addEventListener("focus",v),s.addEventListener("click",x),s.addEventListener("input",w),s.addEventListener("blur",R),s.addEventListener("keydown",A=>{const k=A;k.key==="ArrowDown"?(k.preventDefault(),y(1)):k.key==="ArrowUp"?(k.preventDefault(),y(-1)):k.key==="Enter"?(k.preventDefault(),S()):k.key==="Escape"&&(k.preventDefault(),R())}),c.append(s),m(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const mb=[{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"}],bb={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function lt(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 Jt='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',ou='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function vb(t){const e=t.format,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"},[lt("preset-none","无边框",`${Jt}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),lt("preset-all","所有边框",`${ou}<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")),lt("preset-outer","外侧边框",ou,()=>e.applyBorderPreset("outer")),lt("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${Jt}<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}),lt("edge-top","上边框",`${Jt}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),lt("edge-bottom","下边框",`${Jt}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),lt("edge-left","左边框",`${Jt}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),lt("edge-right","右边框",`${Jt}<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"},mb.map(u=>g("button",{type:"button",class:`ft-style-btn${e.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:u.label},onClick:()=>{e.borderStyle=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"},[X({value:e.borderWidth,min:.25,max:5,step:.25,onCommit:u=>{e.borderWidth=u,t.repaint()}})])]),g("div",{class:"ft-border-style-row"},[g("span",{class:"ft-edge-label",text:"颜色"}),$e(e.borderColor,u=>{e.borderColor=u,t.repaint()},"边框颜色")])])],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:De(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:De(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:De("Paintbrush")})]),g("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[g("div",{class:"ft-font"},[xa({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===it?"混合":"默认",disabled:r,onChange:u=>e.applyStyle({fontFamily:u})})]),g("div",{class:"ft-size",dataset:{test:"font-size"}},[X({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===it?"混合":"默认",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:De(f)}))]),g("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[g("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[$e(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:"背景色"},[$e(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>e.applyStyle({backgroundColor:u})),g("span",{class:"ft-glyph",html:De("PaintBucket",14)})])]),g("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[so(t,"align",{icon:bb[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"}},[so(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const yb=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",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:"<>"}],xb={text:"T",longText:"¶",table:"⊞",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function wb(t){const e=t.state;if(e.leftCollapsed)return g("div",{class:"left-panel collapsed"},[g("div",{class:"left-collapsed"},[iu("»","展开素材台",()=>{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:"素材台"}),iu("«","收起素材台",()=>{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",Eb()),n("fields",[Sb(t)]),n("layers",[_b(t)])])])}function iu(t,e,n){return g("button",{type:"button",class:"collapse-btn",title:e,text:t,onClick:n})}function Eb(){return[g("div",{class:"panel-title",text:"拖拽元素到画布"}),...yb.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 Sb(t){const e=t.state,n=hs(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})]):"",c=a?[]:i.fields.map(s=>g("div",{class:"field-row",draggable:!0,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-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 _b(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:xb[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:De(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:De("Group",14),onClick:()=>t.fire("group")}):"",i?g("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:De("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function Tb(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 kb(t){const e=t.store,n=e.templateData,r=pt(n),o=n.orientation==="landscape"?"横向":"纵向",i=Ue[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 Mb=Object.keys(Ue).filter(t=>t!=="CUSTOM"&&!Ue[t]?.continuous);function Cb(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 Ab(t){const n=t.store.templateData.designBackground,r=n?.rotation??0;return g("div",{class:"design-background-config"},[je("设计背景"),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})})])]:Cb(t)].flat())}function Ob(t){const e=t.store,n=e.templateData,r=n.tiling,o={...Ht,...r??{},enabled:r?.enabled??!1,sheetMargin:{...Ht.sheetMargin,...r?.sheetMargin??{}}},i=$o(n.paperSize),a=u=>e.updateTemplateData({tiling:{...o,...u}}),l=(u,f)=>a({sheetMargin:{...o.sheetMargin,[u]:f??0}}),c={...n,tiling:o},s=vi(c),d=Math.max(xh(c),1);let p="";if(!s.length)try{const u=fl(c),f=mn(c),h=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",m=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";p=`目标纸 ${h}${m} ${f.width}×${f.height}mm · ${u.columns} 列 × ${u.rows} 行 = 每张 ${u.perSheet} 格`}catch{p=""}return g("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[je("拼版打印"),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:u=>{if(!u.target.checked){a({enabled:!1});return}a({...Ht,columns:Math.min(Ht.columns,Math.max(d,1))})}}),g("span",{text:"启用拼版"})]),i?g("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[j("目标纸张",g("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const f=u.target.value;if(f!=="CUSTOM"){a({sheetPaperSize:f});return}const h=mn(c);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??h.width,sheetCustomHeight:o.sheetCustomHeight??h.height})}},[...Mb.map(u=>g("option",{value:u,text:Ue[u]?.label??u,selected:(o.sheetPaperSize??"A4")===u})),g("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})])),o.sheetPaperSize==="CUSTOM"?j("目标纸宽高 (mm)",g("div",{class:"custom-size-grid"},[X({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:u=>a({sheetCustomWidth:u})}),g("span",{class:"custom-size-x",text:"×"}),X({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:u=>a({sheetCustomHeight:u})})])):j("目标纸方向",st("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",u=>a({sheetOrientation:u}))),je("拼版留白 (mm)"),g("div",{class:"margin-grid"},[j("上",X({value:o.sheetMargin.top??0,min:0,max:100,onCommit:u=>l("top",u)})),j("下",X({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:u=>l("bottom",u)})),j("左",X({value:o.sheetMargin.left??0,min:0,max:100,onCommit:u=>l("left",u)})),j("右",X({value:o.sheetMargin.right??0,min:0,max:100,onCommit:u=>l("right",u)}))]),je("格间距与列数"),j("横向间距",X({value:o.gapX??0,min:0,max:50,onCommit:u=>a({gapX:u??0})})),j("纵向间距",X({value:o.gapY??0,min:0,max:50,onCommit:u=>a({gapY:u??0})})),j("列数",X({value:o.columns??1,min:1,max:d,onCommit:u=>a({columns:u||1})})),...s.map(u=>g("p",{class:"pd-hint tiling-error",text:u.message})),!s.length&&p?g("p",{class:"pd-hint tiling-summary",text:p}):""]:""].flat().filter(Boolean))}const Pb=new Set(Wo.map(t=>t.group)),Rb={"table-settings":"content"},au=new Map;function wa(t){const e=t??"";let n=au.get(e);if(!n){const{groups:r,itemKeys:o}=Hp(e);n={groups:r,keys:o,searching:!!e.trim()},au.set(e,n)}return n}function Ea(t){const e=Rb[t]??t;return Pb.has(e)?e:""}function Ib(t,e){const n=wa(t.state.propSearch);if(!n.searching)return!0;const r=Ea(e);return!r||n.groups.includes(r)}function Db(t,e){const n=wa(t.state.propSearch);return!n.searching||n.keys.has(e)}function su(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},su(n,Db(t,e))}function $b(t,e,n){const r=Ea(e);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},su(n,Ib(t,e))}function lu(t,e){const n=wa(e);for(const r of Array.from(t.querySelectorAll("[data-prop-group]"))){const o=Ea(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 Lb(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,lu(n.getRootNode(),r)}})])}const Nb={Document:"≡",Brush:"◧",Setting:"⚙"};function Fb(t,e){try{const n=localStorage.getItem(`property-group-${t}`);return n===null?e:n==="true"}catch{return e}}function zb(t,e){try{localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function Le(t,e,n,r,o,i=!0){const a=Fb(e,i);return $b(t,e,g("div",{class:`property-group${a?" is-expanded":""}`},[g("div",{class:"group-header",onClick:()=>{zb(e,!a),t.repaint()}},[g("span",{class:"group-icon",text:Nb[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 lo(t){return g("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function cu(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 du(t,e){return cu(e).reduce((o,i)=>o==null?"":o[i],t)??""}function Sa(t,e,n,r){const o=cu(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 Bb(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 gs(i.type,r,o,e.options.fields?.[0]?.dataSource)}return Wp(e)}function Hb(t,e){const n=document.createElement("label");n.className="pd-button small upload-label",xe(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?Sa(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 Ub(t,e){const n=r=>t.fire("open-expression",{elementId:e.id,targetPath:r.targetPath,value:du(e,r.targetPath)});return Le(t,"binding","内容","Document",[...Bb(t,e).map(r=>j(r.label,g("input",{class:"pd-input",type:"text",value:du(e,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>Sa(t.store,e,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),e.printElementType.type==="image"?Hb(t,e):""].filter(Boolean))}const Mt=t=>Number(t??0),_a=t=>t||void 0;function Zt(t,e,n,r){return g("div",{class:"pd-field"},[g("span",{class:"pd-label",...r?{title:r}:{},text:t}),g("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:o=>n(o.target.checked)})])}function Ct(t,e,n,r,o=!1){return g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:t}),g("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:i=>r(i.target.value)},n.map(i=>g("option",{value:i.value,text:i.label,selected:i.value===e})))])}const Ta=t=>g("p",{class:"pd-hint",text:t}),qb="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Wb=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],jb=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Gb=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Vb=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"覆盖(保持比例)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],Yb=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}];function Xb(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",[lo([Ct("行类型",i.type,Wb,l=>{const c=zo(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)"}),X({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?Zt("表头每页重复",i.repeatOnPage??!1,l=>{Op(o,l),a({tableRows:o})},qb):""])])}function Kb(t,e){const n=t.store,r=e.options,o=c=>n.updateElement(e.id,c),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(c=>c.fieldType==="list").map(c=>({value:c.fieldKey,label:c.fieldLabel}));return Le(t,"table-settings","表格设置","Grid",[lo([Ct("列表数据源字段",r.dataSource??"",l,c=>o({dataSource:c||void 0}),!0),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"默认字号 (pt)"}),X({value:Mt(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:c=>o({tableDefaultFontSize:_a(c)})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"默认文字颜色"}),$e(r.tableDefaultColor,c=>o({tableDefaultColor:c}),"默认文字颜色")]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"默认内边距 (mm)"}),X({value:Mt(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:c=>o({tableDefaultPadding:_a(c)})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((c,s)=>g("div",{class:"col-width-row"},[g("span",{style:{width:"60px"},text:`列${s+1}`}),X({value:c,min:5,max:200,onCommit:d=>{const p=i.reduce((u,f,h)=>h===s?u:u+f,0);if(p+d>a){const u=Math.max(5,Math.round((a-p)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${s+1} 已调整为 ${u}mm`),i[s]=u}else i[s]=d;o({tableColWidths:i})}})]))])])])}function Jb(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",Zt("启用分页",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",Zt("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(H(t,"pg-keep-with-next",Zt("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return Le(t,"pagination","分页配置","Document",[lo(a)],!1)}const uu=new WeakMap;function Zb(t){let e=uu.get(t);return e||(e={style:"solid",width:.75,color:"#333333",edges:[]},uu.set(t,e)),e}const Qb=[{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],pu=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function e1(t,e){const n=t.store,r=n.tableSelection,o=e.options.tableRows??[];if(!r)return Le(t,"table-cell","单元格","Menu",[]);const i=Fo(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return Le(t,"table-cell","单元格","Menu",[]);const l=Zb(n),c=y=>{for(let S=r.r1;S<=r.r2;S++)for(let D=r.c1;D<=r.c2;D++){const R=o[S]?.cells[D];R&&!R.merged&&y(R)}n.updateElement(e.id,{tableRows:o})},s=()=>({width:l.width,style:l.style,color:l.color}),d=a.cellType==="barcode",p=a.cellType==="qrcode",u=a.cellType==="image",f=!d&&!p&&!u,h=d&&!!a.printerDpi,m=Mo(a),v=rs(o,r);let x=!1;for(let y=r.r1;y<=r.r2&&!x;y++)for(let S=r.c1;S<=r.c2&&!x;S++){const D=o[y]?.cells[S];D&&!D.merged&&((D.rowspan??1)>1||(D.colspan??1)>1)&&(x=!0)}const w=(y,S,D,R={})=>g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:y}),X({value:S,...R,onCommit:A=>c(k=>D(k,_a(A)))})]);return Le(t,"table-cell","单元格","Menu",[lo([g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"单元格类型"}),st("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],a.cellType||"text",y=>{c(S=>{S.cellType=y==="text"?void 0:y,y!=="barcode"&&(S.barcodeType=void 0,S.showBarcodeText=void 0,S.printerDpi=void 0),y!=="qrcode"&&(S.qrCodeLevel=void 0,S.qrQuietZone=void 0)})})]),d?Ct("码制",a.barcodeType||"CODE128",jb,y=>c(S=>{S.barcodeType=y||void 0})):"",d?Zt("显示文本",a.showBarcodeText!==!1,y=>c(S=>{S.showBarcodeText=y})):"",d?w("条宽(倍率)",a.barWidth??2,(y,S)=>{y.barWidth=S},{min:2,max:4,step:.5}):"",d?Ta(h?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定"):"",d?w("文本字号(相对条高,条高为 30)",a.barFontSize??10,(y,S)=>{y.barFontSize=S},{min:5,max:24,placeholder:"默认 10"}):"",d?Ct("打印机分辨率",a.printerDpi?String(a.printerDpi):"",[{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)"}],y=>{const S=Number(y);c(D=>{D.printerDpi=S>0?S:void 0})}):"",d?Ta("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",p?Ct("纠错级别",a.qrCodeLevel||"M",Gb,y=>c(S=>{S.qrCodeLevel=y||void 0})):"",p?Kt("静区 (模块)",X({value:a.qrQuietZone??0,min:0,max:8,placeholder:"默认 0",onCommit:y=>c(S=>{S.qrQuietZone=y})}),Nt("cd-quiet-zone")):"",d?Ta("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限"):"",p||u?Ct("缩放模式",a.fit||"contain",Vb,y=>c(S=>{S.fit=y})):"",u?Kt("裁剪锚点",g("input",{class:"pd-input",type:"text",value:String(a.objectPosition??""),placeholder:"缺省居中,如 center 20%",onBlur:y=>c(S=>{S.objectPosition=(y.target.value||"").trim()||void 0})}),Nt("ap-img-object-position")):"",d||p||u?w("最大宽度 (mm)",Mt(a.maxWidth),(y,S)=>{y.maxWidth=S},{min:0,max:200,placeholder:"默认"}):"",d||p||u?w("最大高度 (mm)",Mt(a.maxHeight),(y,S)=>{y.maxHeight=S},{min:0,max:200,placeholder:"默认"}):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"内容"}),g("input",{class:"pd-input",type:"text",value:a.formatter||"",placeholder:"输入内容,支持 {字段} 表达式",onChange:y=>c(S=>{S.formatter=y.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",text:"水平对齐"}),st("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],a.align||"left",y=>c(S=>{S.align=y}))]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"垂直对齐"}),st("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],a.valign||"top",y=>c(S=>{S.valign=y}))]),g("div",{class:"cell-style-grid"},[g("div",{class:"pd-field cell-font-field"},[g("span",{class:"pd-label",text:"字体"}),xa({id:"cell-font",state:t.state,fonts:t.host.fonts,value:a.fontFamily,placeholder:"继承默认",onChange:y=>c(S=>{S.fontFamily=y})})]),w("字号 (pt)",Mt(a.fontSize),(y,S)=>{y.fontSize=S},{min:0,max:72,placeholder:"默认"}),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"加粗"}),g("input",{class:"pd-switch",type:"checkbox",checked:a.fontWeight==="bold",onChange:y=>c(S=>{S.fontWeight=y.target.checked?"bold":void 0})})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"文字颜色"}),$e(a.color,y=>c(S=>{S.color=y}),"文字颜色")]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"背景色"}),$e(a.backgroundColor,y=>c(S=>{S.backgroundColor=y}),"背景颜色")])]),je("边框"),g("div",{class:"border-style-row"},[g("select",{class:"pd-select",style:{width:"90px"},onChange:y=>{l.style=y.target.value,t.repaint()}},Qb.map(y=>g("option",{value:y.value,text:y.label,selected:y.value===l.style}))),g("div",{style:{width:"112px",flexShrink:"0"}},[X({value:l.width,min:.25,max:5,step:.25,onCommit:y=>{l.width=y,t.repaint()}})]),$e(l.color,y=>{l.color=y,t.repaint()},"边框颜色")]),g("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([y,S])=>g("button",{type:"button",class:"pd-button small",text:S,onClick:()=>{ls(o,r,y,s()),n.updateElement(e.id,{tableRows:o})}}))),g("div",{class:"pd-checkbox-group"},pu.map(y=>g("label",{class:"pd-checkbox"},[g("input",{type:"checkbox",value:y.value,checked:l.edges.includes(y.value),onChange:S=>{const D=S.target,R=new Set(l.edges);D.checked?R.add(D.value):R.delete(D.value),l.edges=[...R];const A=s();c(k=>{const _={...k.borders??{}};for(const M of pu)R.has(M.value)?_[M.value]={...A}:delete _[M.value];k.borders=_})}}),g("span",{text:y.label})]))),w("内边距 (mm)",Mt(a.padding),(y,S)=>{y.padding=S},{min:0,max:10,step:.5,placeholder:"默认"}),Zt("自动换行",a.wordWrap??!0,y=>c(S=>{S.wordWrap=y})),f?Ct("文字溢出",m,Yb,y=>c(S=>{S.textFit=y}),!0):"",f&&m==="shrink"?w("最小字号 (pt)",Mt(a.shrinkMinFontSize),(y,S)=>{y.shrinkMinFontSize=S},{min:0,max:72,step:.5,placeholder:"默认 6"}):"",g("div",{class:"merge-btns"},[g("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!v,title:v||"",onClick:()=>{os(o,r),n.updateElement(e.id,{tableRows:o})}}),g("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!x,onClick:()=>{is(o,r),n.updateElement(e.id,{tableRows:o})}})])])])}const ka=Mf;function Ma(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 t1(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function n1(t){const e=t.store.templateData.watermark,n=t1(e),r=e?.mode==="binding"||n!==""&&Ma(n),o=(()=>{const l=e?.tileWidth??Q.tileWidth,c=e?.tileHeight??Q.tileHeight;for(const[s,d]of Object.entries(ka))if(d.width===l&&d.height===c)return s;return"custom"})(),i=l=>{const c={testData:e?.testData??"",rotate:e?.rotate??Q.rotate,color:e?.color||Q.color,opacity:e?.opacity??Q.opacity,tileWidth:e?.tileWidth??Q.tileWidth,tileHeight:e?.tileHeight??Q.tileHeight,timestamp:e?.timestamp,format:e?.format};t.store.updateTemplateData({watermark:{...c,...l}})},a=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n});return g("div",{class:"watermark-config"},[je("水印"),g("form",{class:"pd-form",onSubmit:l=>l.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:l=>{const c=l.target.value;i(Ma(c)?{mode:"binding",binding:c,content:""}:{mode:"fixed",content:c,binding:""})},onDblclick:a}),g("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?j("测试值",g("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:l=>i({testData:l.target.value})})):"",g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"旋转角度"}),g("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??Q.rotate),onChange:l=>i({rotate:Number(l.target.value)})}),g("span",{class:"pd-hint",text:`${e?.rotate??Q.rotate}°`})]),j("颜色",$e(e?.color||Q.color,l=>i({color:l}),"水印颜色")),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"透明度"}),g("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??Q.opacity),onChange:l=>i({opacity:Number(l.target.value)})}),g("span",{class:"pd-hint",text:(e?.opacity??Q.opacity).toFixed(2)})]),g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"密度"}),g("select",{class:"pd-select",style:{width:"100%"},onChange:l=>{const c=l.target.value,s=ka[c];s&&i({tileWidth:s.width,tileHeight:s.height})}},[...Object.entries(ka).map(([l,c])=>g("option",{value:l,text:`${c.label}(${c.width}×${c.height})`,selected:o===l})),g("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"瓦片宽"}),g("input",{type:"number",class:"pd-input",min:Q.minTileWidth,step:10,value:String(e?.tileWidth??Q.tileWidth),onChange:l=>i({tileWidth:Number(l.target.value)})})]):"",o==="custom"?g("div",{class:"pd-field"},[g("span",{class:"pd-label",text:"瓦片高"}),g("input",{type:"number",class:"pd-input",min:Q.minTileHeight,step:10,value:String(e?.tileHeight??Q.tileHeight),onChange:l=>i({tileHeight:Number(l.target.value)})})]):""].filter(Boolean))])}function ge(t,e,n,r,o={}){return j(e,X({value:n,...o,onCommit:r}))}function At(t,e,n,r,o,i){const a=document.createElement("select");a.className="pd-select",a.addEventListener("change",()=>o(a.value));for(const l of r){const c=document.createElement("option");c.value=l.value,c.textContent=l.label,a.appendChild(c)}return a.value=n,r.some(l=>l.value===n)||(a.selectedIndex=-1),i?Kt(e,a,i):j(e,a)}function co(t,e,n,r){return j(e,g("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:o=>r(o.target.checked)}))}function r1(t,e){const n=t.store,r=e.options,o=e.printElementType.type,i=p=>n.updateElement(e.id,p),a=o==="text"||o==="longText",l=o==="barcode"||o==="qrcode",c=o==="table",s=c&&n.tableSelection?.elementId===e.id,d=[];if(s||d.push(Le(t,"position-size","位置与尺寸","Location",[g("form",{class:"pd-form",onSubmit:p=>p.preventDefault()},[g("div",{class:"position-grid"},[H(t,"ps-left",ge(t,"X",r.left,p=>i({left:p}),{min:0})),H(t,"ps-top",ge(t,"Y",r.top,p=>i({top:p}),{min:0})),H(t,"ps-width",ge(t,"W",r.width,p=>i({width:p}),{min:4})),H(t,"ps-height",ge(t,"H",r.height,p=>i({height:p}),{min:4}))])])])),d.push(Le(t,"appearance","外观","Brush",[g("form",{class:"pd-form",onSubmit:p=>p.preventDefault()},a?[H(t,"ap-font-family",j("字体",xa({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:p=>i({fontFamily:p})}))),H(t,"ap-font-size",ge(t,"字体大小",r.fontSize,p=>i({fontSize:p}),{min:8,max:72})),H(t,"ap-font-weight",At(t,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],p=>i({fontWeight:p}))),H(t,"ap-align",j("对齐",st("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",p=>i({textAlign:p})))),H(t,"ap-vertical-align",j("垂直对齐",st("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",p=>i({verticalAlign:p})))),g("div",{class:"color-row"},[H(t,"ap-color",j("颜色",$e(r.color,p=>i({color:p}),"字体颜色"))),H(t,"ap-bg-color",j("背景色",$e(r.backgroundColor,p=>i({backgroundColor:p}),"背景颜色")))]),H(t,"ap-line-height",ge(t,"行高",r.lineHeight,p=>i({lineHeight:p||void 0}),{min:0,max:100})),H(t,"ap-letter-spacing",ge(t,"字间距",r.letterSpacing,p=>i({letterSpacing:p||void 0}),{min:0,max:20,step:.5})),H(t,"ap-text-fit",At(t,"文字溢出",qn(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],p=>i({textFit:p}))),r.textFit==="shrink"?H(t,"ap-shrink-min",j("最小字号 (pt)",X({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:p=>i({shrinkMinFontSize:p||void 0})}))):"",o==="longText"?H(t,"ap-long-text-indent",Kt("首行缩进 (字符)",X({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:p=>i({longTextIndent:p||void 0})}),Nt("ap-long-text-indent"))):"",H(t,"ap-word-wrap",co(t,"自动换行",r.wordWrap!==!1,p=>i({wordWrap:p?void 0:!1})))]:[o==="image"?H(t,"ap-img-fit",At(t,"缩放模式",String(r.fit??"contain"),[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"覆盖(保持比例)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],p=>i({fit:p}),Nt("ap-img-fit"))):"",o==="image"?H(t,"ap-img-object-position",Kt("裁剪锚点",g("input",{class:"pd-input",type:"text",value:String(r.objectPosition??""),placeholder:"缺省居中,如 center 20%",onBlur:p=>i({objectPosition:(p.target.value||"").trim()||void 0})}),Nt("ap-img-object-position"))):"",!c&&o!=="image"?g("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const p=o==="barcode",u=String(r.barcodeType||"CODE128").toUpperCase(),f=r.printerDpi?String(r.printerDpi):"";d.push(Le(t,"code","条码设置","Postcard",[g("form",{class:"pd-form",onSubmit:h=>h.preventDefault()},[p?[H(t,"cd-type",At(t,"码制",u,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],h=>i({barcodeType:h==="CODE128"?void 0:h}))),H(t,"cd-dpi",At(t,"打印机分辨率",f,[{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)"}],h=>i({printerDpi:Number(h)>0?Number(h):void 0}))),H(t,"cd-dpi",g("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),H(t,"cd-bar-width",ge(t,"条宽(倍率)",r.barWidth??2,h=>i({barWidth:h}),{min:2,max:4,step:.5})),H(t,"cd-bar-width",g("p",{class:"pd-hint",text:f?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定"})),H(t,"cd-show-text",co(t,"显示文本",r.hideTitle!==!0,h=>i({hideTitle:h?void 0:!0}))),H(t,"cd-font-size",j("文本字号(相对条高,条高为 30)",X({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:h=>i({fontSize:h||void 0})})))]:[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(最高)"}],h=>i({qrCodeLevel:h}))),H(t,"cd-quiet-zone",Kt("静区 (模块)",X({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:h=>i({qrQuietZone:h})}),Nt("cd-quiet-zone")))],je("自定义设置"),p?g("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限"}):"",p?"":H(t,"cd-fit",At(t,"缩放模式",String(r.fit||"contain"),[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"覆盖(保持比例)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],h=>i({fit:h||void 0}))),H(t,"cd-max-width",j("最大宽度 (mm)",X({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:h=>i({maxWidth:h||void 0})}))),H(t,"cd-max-height",j("最大高度 (mm)",X({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:h=>i({maxHeight:h||void 0})})))].flat().filter(Boolean))]))}return d.push(Ub(t,e)),s&&(d.push(Xb(t,e)),d.push(e1(t,e))),c&&d.push(Kb(t,e)),d.push(Le(t,"border-bg","边框与背景","Picture",[g("form",{class:"pd-form",onSubmit:p=>p.preventDefault()},[g("div",{class:"border-row"},[H(t,"bb-border-width",ge(t,"边框宽度",r.borderWidth,p=>i({borderWidth:p}),{min:0,max:20,step:.25})),H(t,"bb-border-color",j("边框颜色",$e(r.borderColor,p=>i({borderColor:p}),"边框颜色")))]),H(t,"bb-bg-color",j("背景色",$e(r.backgroundColor,p=>i({backgroundColor:p}),"背景颜色")))])])),d.push(Jb(t,e)),d.push(Le(t,"advanced","高级设置","Setting",[g("form",{class:"pd-form",onSubmit:p=>p.preventDefault()},[g("div",{class:"advanced-row"},[H(t,"ad-locked",co(t,"锁定",!!r.locked,p=>i({locked:p}))),H(t,"ad-fixed",co(t,"每页重复",!!r.fixed,p=>i({fixed:p})))]),H(t,"ad-z-index",ge(t,"层级",r.zIndex,p=>i({zIndex:p}),{min:0,max:999})),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"},d)}function o1(t){const e=t.store,n=e.templateData,r=l=>e.updateTemplateData(l),o=[];for(const[l,c]of Object.entries(Ue)){const s=c.group??"其他";let d=o.find(p=>p.group===s);d||(d={group:s,items:[]},o.push(d)),d.items.push({key:l,label:c.label??l})}const i=!Ue[n.paperSize],a=$o(n.paperSize);return g("form",{class:"pd-form",onSubmit:l=>l.preventDefault()},[je("纸张设置"),j("纸张尺寸",g("select",{class:"pd-select",style:{width:"100%"},onChange:l=>r({paperSize:l.target.value})},[...o.map(l=>g("optgroup",{label:l.group},l.items.map(c=>g("option",{value:c.key,text:c.label,selected:n.paperSize===c.key})))),g("option",{value:"CUSTOM",text:"自定义宽高",selected:i})])),a||i?j(a?"纸宽 (mm)":"自定义宽高 (mm)",g("div",{class:"custom-size-grid"},[X({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:l=>r({customWidth:l})}),...i?[g("span",{class:"custom-size-x",text:"×"}),X({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:l=>r({customHeight:l})})]:[]])):"",a?"":j("纸张方向",st("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",l=>r({orientation:l})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),!a&&!n.tiling?.enabled?j("内容旋转角度",st("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),l=>r({outputRotation:Number(l)}),!0),"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"):"",j("页面背景色",g("div",{class:"page-bg-row"},[$e(n.pageBackground,l=>r({pageBackground:l}),"页面背景色","page-bg-picker"),g("button",{type:"button",class:"pd-reset",title:"恢复为默认白色",text:"默认",onClick:()=>r({pageBackground:void 0})})])),Ab(t),e.pages.length>1?"":Ob(t),je("页边距 (mm)"),g("div",{class:"margin-grid"},[ge(t,"上",n.margins.top,l=>r({margins:{...n.margins,top:l}}),{min:0,max:50}),ge(t,"下",n.margins.bottom,l=>r({margins:{...n.margins,bottom:l}}),{min:0,max:100}),ge(t,"左",n.margins.left,l=>r({margins:{...n.margins,left:l}}),{min:0,max:50}),ge(t,"右",n.margins.right,l=>r({margins:{...n.margins,right:l}}),{min:0,max:50})]),je("页眉/页脚高度 (mm)"),ge(t,"页眉高度",n.header.height??10,l=>r({header:{...n.header,height:l}}),{min:0,max:100,step:.1}),ge(t,"页脚高度",n.footer.height??10,l=>r({footer:{...n.footer,height:l}}),{min:0,max:100,step:.1}),n1(t)].filter(Boolean))}function i1(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?[Lb(t),r1(t,r)]:[g("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),g("div",{class:"pd-tab-pane",role:"tabpanel",style:o==="page"?"":{display:"none"}},[o1(t)])])])}const Ca=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],fu={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},a1=[{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()"}],s1=[{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()"}],l1=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],c1=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],d1=[{title:"聚合函数",items:a1},{title:"数值运算",items:s1},{title:"格式化函数",items:l1}],u1="(输入表达式后预览)",p1="(无法计算)",Aa="(表达式错误)";function hu(t,e){if(!t.trim())return u1;try{const n={...ht,...e??{},...er()},r=hr(t,n);return r==null?p1:String(r)}catch{return Aa}}function gu(t,e){const n=e.trim().toLowerCase();return n?t.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):t}function f1(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 h1(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 Oa(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 Ot(t){return t.currentTarget.getRootNode()}function uo(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 g1(){return g("div",{class:"ee-help-section"},[g("div",{class:"ee-help-title",text:"帮助信息"}),g("div",{class:"ee-help-grid"},[uo("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),uo("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),uo("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),uo("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function m1(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 v=hu(n.expression,t.demoData);m.textContent=v,m.classList.toggle("ee-preview-error",v===Aa)},i=()=>{if(n.activeTab==="variable")return gu(c1,n.searchText).map(v=>g("div",{class:"ee-list-item",onDblclick:x=>{const{insideParens:w}=l(x);c(Ot(x),w?v.template.replace(/^\{|\}$/g,""):v.template)}},[Oa(v.label,v.template)]));if(n.activeTab==="function")return d1.map(v=>g("div",{class:"ee-func-group"},[g("div",{class:"ee-func-group-title",text:v.title}),...gu(v.items,n.searchText).map(x=>g("div",{class:"ee-list-item",onDblclick:w=>{const{insideBlock:y}=l(w),S=y?x.template:`{${x.template}}`;c(Ot(w),S,S.indexOf("(")+1)}},[Oa(x.label,`${x.name}()`)]))]));const h=Up(hs(t.fields??[]),n.searchText);if(!h.length)return[g("p",{class:"pd-empty",text:"暂无字段"})];const m=[];for(const v of h){v.key&&m.push(g("div",{class:`ee-field-group${v.isList?" is-list":""}`},[g("span",{class:"ee-field-group-icon",text:v.isList?"📋":"📁"}),g("span",{text:v.label})]));for(const x of v.fields)m.push(g("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:v.key?"22px":"10px"},onDblclick:w=>{const{insideParens:y}=l(w);c(Ot(w),y?x.fieldKey:`{${x.fieldKey}}`)}},[Oa(x.fieldLabel,x.fieldKey)]))}return m},a=h=>{Array.from(h.querySelectorAll(".ee-nav-tab")).forEach((y,S)=>y.classList.toggle("active",Ca[S]?.key===n.activeTab));const v=r(h,".ee-content-search .pd-input");if(v){const y=fu[n.activeTab];v.placeholder!==y&&(v.placeholder=y),v.value!==n.searchText&&(v.value=n.searchText)}const x=r(h,".ee-textarea");x&&x.value!==n.expression&&(x.value=n.expression);const w=r(h,".ee-content-list");if(w){pd(w);for(const y of i())xe(y,w)}o(h)},l=h=>{const v=r(Ot(h),".ee-textarea")?.selectionStart??n.expression.length;return f1(n.expression,v)},c=(h,m,v=m.length)=>{const x=r(h,".ee-textarea");if(!x){n.expression+=m,o(h);return}const w=x.selectionStart??n.expression.length,y=x.selectionEnd??w;n.expression=n.expression.substring(0,w)+m+n.expression.substring(y);const S=w+v;x.value=n.expression,x.focus(),x.selectionStart=x.selectionEnd=S,o(h)},s=()=>{const h=n.expression;if(n.binding===void 0){t.onApply({formatter:h}),t.onClose();return}const m=h1(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"},Ca.map((h,m)=>g("div",{class:`ee-nav-tab${n.activeTab===h.key?" active":""}`,text:h.text,onClick:v=>{n.activeTab=Ca[m].key,a(Ot(v))}})))]),p=g("div",{class:"ee-content"},[g("div",{class:"ee-content-search"},[g("input",{class:"pd-input",placeholder:fu[n.activeTab],onInput:h=>{n.searchText=h.target.value,a(Ot(h))}})]),g("div",{class:"ee-content-list"},i())]),u=hu(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(Ot(h))}})]),g("div",{class:"ee-editor-section"},[g("div",{class:"ee-editor-title",text:"预览结果"}),g("div",{class:`ee-preview${u===Aa?" ee-preview-error":""}`,text:u})]),g1()]);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 po=[{id:"getting-started",title:"快速入门",content:`
257
+ <h2>界面布局</h2>
258
+ <p>打印模板设计器采用三栏布局:</p>
259
+ <ul>
260
+ <li><strong>左侧面板</strong>:字段树和图层管理,用于查看和管理画布上的元素</li>
261
+ <li><strong>中间画布</strong>:设计区域,支持标尺、参考线、网格显示</li>
262
+ <li><strong>右侧面板</strong>:属性设置和模板配置</li>
263
+ <li><strong>顶部工具栏</strong>:常用操作按钮</li>
264
+ <li><strong>底部状态栏</strong>:显示坐标、缩放比例、元素数量</li>
265
+ </ul>
266
+
267
+ <h2>添加第一个元素</h2>
268
+ <ol>
269
+ <li>从左侧面板选择元素类型(文本、图片、条码等)</li>
270
+ <li>拖拽到画布上松开</li>
271
+ <li>选中元素后,通过拖拽调整位置</li>
272
+ <li>拖拽元素边角手柄调整大小</li>
273
+ </ol>
274
+
275
+ <h2>数据绑定基础</h2>
276
+ <p>使用花括号 <code>{field.path}</code> 语法绑定数据字段:</p>
277
+ <pre><code>供应商:{supplier.name}
278
+ 日期:{order.date}
279
+ 金额:{MONEY(order.total)}
280
+ 合计:{ROUND(qty * price, 2)}</code></pre>
281
+ <p>花括号内可直接写四则运算(<code>{qty * price}</code>),也可用 <code>ADD</code> / <code>SUB</code> / <code>MUL</code> / <code>DIV</code> 函数;
282
+ 需要保留几位小数时用 <code>ROUND</code>(四舍五入)、<code>ROUNDUP</code>(进一)、<code>ROUNDDOWN</code>(去尾)或 <code>ROUNDBANK</code>(四舍六入五成双)。</p>
283
+ <p>双击元素可打开表达式编辑器配置绑定。</p>
284
+
285
+ <h2>保存与预览</h2>
286
+ <ul>
287
+ <li>点击工具栏"保存"按钮,模板以 JSON 格式导出</li>
288
+ <li>点击"预览"按钮查看打印效果</li>
289
+ <li>模板数据包含页面设置、元素定义、样式配置</li>
290
+ </ul>
291
+
292
+ <h2>关于项目</h2>
293
+ <p><strong>项目名称:</strong>worm-vue3-print</p>
294
+ <p><strong>仓库地址:</strong><a href="https://gitee.com/liulong_oschina/worm-vue3-print" target="_blank" rel="noopener noreferrer">https://gitee.com/liulong_oschina/worm-vue3-print</a></p>
295
+ <p>基于 Vue 3 的可视化打印模板设计器,支持拖拽式模板编辑、表达式数据绑定和浏览器端打印预览。</p>
296
+ `},{id:"features",title:"功能说明",content:`
297
+ <h2>元素类型</h2>
298
+ <table>
299
+ <thead>
300
+ <tr><th>类型</th><th>说明</th></tr>
301
+ </thead>
302
+ <tbody>
303
+ <tr><td>文本</td><td>静态或动态文本,支持表达式绑定</td></tr>
304
+ <tr><td>长文本</td><td>多行文本,支持自动换行</td></tr>
305
+ <tr><td>数据表格</td><td>动态行列,支持分页、表头重复、序号/小计/汇总</td></tr>
306
+ <tr><td>条形码</td><td>支持 code128 等多种码制</td></tr>
307
+ <tr><td>二维码</td><td>支持 L/M/Q/H 纠错级别;「静区 (模块)」控制四周白边(0~8,默认 0=码面等比铺满元素框),需 ISO 推荐静区时填 4</td></tr>
308
+ <tr><td>图片</td><td>静态或动态图片</td></tr>
309
+ <tr><td>线条</td><td>水平线或垂直线</td></tr>
310
+ <tr><td>形状</td><td>矩形、椭圆,支持边框和背景色</td></tr>
311
+ <tr><td>HTML</td><td>自定义 HTML 内容</td></tr>
312
+ <tr><td>页码</td><td>自动页码显示</td></tr>
313
+ </tbody>
314
+ </table>
315
+
316
+ <h2>表达式编辑器</h2>
317
+ <h3>基础语法</h3>
318
+ <p>使用花括号 <code>{}</code> 包裹表达式,花括号外为字面文本。</p>
319
+
320
+ <h3>内置函数</h3>
321
+ <table>
322
+ <thead>
323
+ <tr><th>函数</th><th>说明</th><th>示例</th></tr>
324
+ </thead>
325
+ <tbody>
326
+ <tr><td><code>MONEY(value)</code></td><td>金额格式化(千分位+两位小数)</td><td><code>{MONEY(order.total)}</code> -> "69,543.75"</td></tr>
327
+ <tr><td><code>DATE(value, format)</code></td><td>日期格式化</td><td><code>{DATE(order.date, 'YYYY-MM-DD')}</code></td></tr>
328
+ <tr><td><code>UPPER(value)</code></td><td>数字转大写金额</td><td><code>{UPPER(order.total)}</code> -> "陆万玖仟伍佰肆拾叁元柒角伍分"</td></tr>
329
+ <tr><td><code>IF(cond, true, false)</code></td><td>条件判断</td><td><code>{IF(qty > 100, '大量', '少量')}</code></td></tr>
330
+ <tr><td><code>CONCAT(str1, str2, ...)</code></td><td>字符串拼接</td><td><code>{CONCAT(name, '-', spec)}</code></td></tr>
331
+ <tr><td><code>IFEMPTY(value, default)</code></td><td>空值默认</td><td><code>{IFEMPTY(remark, '无')}</code></td></tr>
332
+ <tr><td><code>ROUND(num, decimals)</code></td><td>四舍五入(位数缺省 2)</td><td><code>{ROUND(price, 2)}</code></td></tr>
333
+ <tr><td><code>ROUNDUP(n, d)</code> / <code>CEIL(n, d)</code></td><td>进一法(远离零)</td><td><code>{ROUNDUP(price, 2)}</code></td></tr>
334
+ <tr><td><code>ROUNDDOWN(n, d)</code> / <code>FLOOR(n, d)</code></td><td>去尾法(朝零)</td><td><code>{ROUNDDOWN(price, 2)}</code></td></tr>
335
+ <tr><td><code>ROUNDBANK(n, d)</code></td><td>四舍六入五成双(GB/T 8170)</td><td><code>{ROUNDBANK(price, 2)}</code></td></tr>
336
+ <tr><td><code>ADD(a, b, ...)</code></td><td>相加(变参)</td><td><code>{ADD(qty, 1)}</code></td></tr>
337
+ <tr><td><code>SUB(a, b, ...)</code></td><td>相减</td><td><code>{SUB(total, discount)}</code></td></tr>
338
+ <tr><td><code>MUL(a, b, ...)</code></td><td>相乘(变参)</td><td><code>{MUL(qty, price)}</code></td></tr>
339
+ <tr><td><code>DIV(a, b)</code></td><td>相除(除数为 0 返回 0)</td><td><code>{DIV(total, qty)}</code></td></tr>
340
+ <tr><td><code>NOW()</code></td><td>当前日期</td><td><code>{NOW()}</code></td></tr>
341
+ <tr><td><code>SUBSTR(str, start, len)</code></td><td>子字符串</td><td><code>{SUBSTR(name, 0, 3)}</code></td></tr>
342
+ <tr><td><code>LEN(str)</code></td><td>字符串长度</td><td><code>{LEN(name)}</code></td></tr>
343
+ <tr><td><code>PAD(value, len, char)</code></td><td>左侧补位</td><td><code>{PAD(qty, 5, '0')}</code></td></tr>
344
+ </tbody>
345
+ </table>
346
+
347
+ <h3>聚合函数(表格小计/汇总行使用)</h3>
348
+ <table>
349
+ <thead>
350
+ <tr><th>函数</th><th>说明</th></tr>
351
+ </thead>
352
+ <tbody>
353
+ <tr><td><code>SUM(field)</code></td><td>求和</td></tr>
354
+ <tr><td><code>AVG(field)</code></td><td>平均值</td></tr>
355
+ <tr><td><code>COUNT(field)</code></td><td>计数</td></tr>
356
+ <tr><td><code>MIN(field)</code></td><td>最小值</td></tr>
357
+ <tr><td><code>MAX(field)</code></td><td>最大值</td></tr>
358
+ </tbody>
359
+ </table>
360
+
361
+ <h3>系统变量</h3>
362
+ <table>
363
+ <thead>
364
+ <tr><th>变量</th><th>说明</th></tr>
365
+ </thead>
366
+ <tbody>
367
+ <tr><td><code>pageIndex</code></td><td>当前页码</td></tr>
368
+ <tr><td><code>totalPages</code></td><td>总页数</td></tr>
369
+ <tr><td><code>printDate</code></td><td>打印日期 (YYYY-MM-DD)</td></tr>
370
+ <tr><td><code>printTime</code></td><td>打印时间戳</td></tr>
371
+ </tbody>
372
+ </table>
373
+
374
+ <h2>数据表格配置</h2>
375
+ <h3>行类型</h3>
376
+ <ul>
377
+ <li><strong>标题行 (header)</strong>:可设置每页重复显示</li>
378
+ <li><strong>数据行 (data)</strong>:绑定列表数据源迭代显示</li>
379
+ <li><strong>小计行 (subtotal)</strong>:当前页末尾显示汇总</li>
380
+ <li><strong>汇总行 (summary)</strong>:仅最后一页显示</li>
381
+ </ul>
382
+
383
+ <h3>表格操作</h3>
384
+ <ul>
385
+ <li>在单元格上右键即可打开表格菜单(无需先选中表格,右键时会自动选中该表格),支持插入/删除行和列、合并/拆分单元格、切换行类型</li>
386
+ <li>拖选多个单元格后可合并;合并后在任一成员单元格上右键可拆分</li>
387
+ <li>支持单元格合并/拆分</li>
388
+ <li>支持边框预设:全部/外边框/内边框/无</li>
389
+ <li>无边框表格设计态显示虚拟虚线</li>
390
+ <li><strong>调整列宽</strong>:需要先在左侧面板的图层中选中对应的表格元素,然后才能在画布上拖动列宽分隔线</li>
391
+ <li><strong>调整表格属性</strong>:必须确保当前没有任何单元格被选中。如有选中的单元格,先点击画布空白区域取消选中,再在图层中选择表格元素</li>
392
+ <li><strong>单元格图片处理</strong>:若单元格中图片无法缩小,请将图片处理方式设置为"缩小保持比例"</li>
393
+ </ul>
394
+
395
+ <h2>格式工具栏与格式刷</h2>
396
+ <h3>格式工具栏</h3>
397
+ <ul>
398
+ <li>位于顶部工具栏,选中元素或表格单元格后可用;不适用的按钮置灰,悬停可见原因</li>
399
+ <li>可设置:字体、字号、加粗 / 下划线 / 删除线、文字颜色、背景颜色、水平与垂直对齐、边框</li>
400
+ <li>多选时样式不一致的项目显示「混合」,重新设置后统一为所选值</li>
401
+ <li>边框面板提供「所有 / 外侧 / 内部 / 无」预设与上、下、左、右逐边开关,可指定线型、线宽、颜色;「内部」仅表格单元格可用</li>
402
+ <li>矩形、椭圆、线条本身用边框绘制,表格走单元格边框,因此不提供元素级边框</li>
403
+ </ul>
404
+ <h3>格式刷</h3>
405
+ <ul>
406
+ <li>先选中<strong>单个</strong>元素作为格式来源,点击格式刷(双击为连续刷)</li>
407
+ <li>再点选或框选目标元素即完成刷取;单击模式刷一次后自动退出</li>
408
+ <li>按 <code>Esc</code>、取消选中或再次点击格式刷按钮均可退出待刷态</li>
409
+ <li>按目标类型自动过滤:字体等文本样式只刷给文本 / 长文本,边框只刷给支持元素级边框的类型,背景颜色对所有元素生效</li>
410
+ <li>锁定元素不会被刷;源元素自身不会被改写</li>
411
+ </ul>
412
+
413
+ <h2>对齐与吸附</h2>
414
+ <h3>自动对齐</h3>
415
+ <p>拖拽元素时自动显示对齐引导线:</p>
416
+ <ul>
417
+ <li>蓝色:左/顶对齐</li>
418
+ <li>绿色:居中对齐</li>
419
+ <li>橙色:右/底对齐</li>
420
+ </ul>
421
+
422
+ <h3>网格吸附</h3>
423
+ <p>开启吸附功能后,元素自动吸附到网格点。</p>
424
+
425
+ <h3>手动参考线</h3>
426
+ <p>通过标尺区域拖拽添加参考线,参考线参与吸附检测。</p>
427
+
428
+ <h2>图层管理</h2>
429
+ <ul>
430
+ <li>调整元素显示顺序(置顶/置底/上移/下移)</li>
431
+ <li>显示/隐藏元素</li>
432
+ <li>锁定/解锁元素(锁定后不可编辑)</li>
433
+ </ul>
434
+
435
+ <h3>组合</h3>
436
+ <p>选中多个元素后(Ctrl/⌘+点击或空白处框选),可通过工具栏按钮、图层面板按钮或 <code>Ctrl + G</code> 将它们组合为一组;取消组合用 <code>Ctrl + Shift + G</code>。组合后:</p>
437
+ <ul>
438
+ <li>点击任一成员即选中整组,拖动任一成员整组跟动</li>
439
+ <li><strong>打印时整组强制在同一页</strong>,不会跨页拆分</li>
440
+ </ul>
441
+ <p><strong>注意:</strong>组内元素的总高度不能超过纸张内容区,否则整组移到新页后,超出部分仍会被裁掉。组太高时请拆分为多个小组或取消组合。</p>
442
+
443
+ <h3>右键菜单</h3>
444
+ <ul>
445
+ <li><strong>在元素上右键</strong>:复制 / 剪切 / 粘贴 / 删除 / 置顶 / 上移 / 下移 / 置底。右键的元素若不在当前选中范围内,会自动改为只选中它,菜单动作即作用于该元素;若它已属于当前多选,则不打断多选</li>
446
+ <li><strong>在空白处右键</strong>:粘贴 / 全选 / 取消选择</li>
447
+ <li>粘贴项在没有可粘贴内容时置灰</li>
448
+ </ul>
449
+
450
+ <h2>三区布局</h2>
451
+ <p>页面分为三个区域:</p>
452
+ <ul>
453
+ <li><strong>页眉 (header)</strong>:顶部区域</li>
454
+ <li><strong>内容区 (content)</strong>:主体区域</li>
455
+ <li><strong>页脚 (footer)</strong>:底部区域</li>
456
+ </ul>
457
+ <p>页眉/页脚支持的元素类型:文本、图片、线条、形状、条形码、二维码</p>
458
+
459
+ <h2>水印配置</h2>
460
+ <ul>
461
+ <li>水印内容用统一的「水印表达式」输入:直接输入文字即为静态水印;写成 <code>{order.no}</code>、<code>CONCAT(...)</code> 等即按表达式解析</li>
462
+ <li>点击「编辑表达式」(或双击输入框)打开表达式弹框,可直接选择业务字段与系统变量:打印日期 <code>{printDate}</code>、打印时间 <code>{printTime}</code>、当前页码 <code>{pageIndex}</code>、总页数 <code>{totalPages}</code>;表达式取不到值时回退到测试值</li>
463
+ <li>可设置旋转角度(-90°~90°)、颜色与透明度</li>
464
+ <li>支持调节水印密度(密/中/疏/自定义瓦片尺寸),以及设置水印颜色</li>
465
+ <li>水印在画布、浏览器预览、服务端 PDF、静默打印四端渲染一致</li>
466
+ </ul>
467
+ `},{id:"shortcuts",title:"快捷键",content:`
468
+ <h2>常用操作</h2>
469
+ <table>
470
+ <thead>
471
+ <tr><th>快捷键</th><th>功能</th></tr>
472
+ </thead>
473
+ <tbody>
474
+ <tr><td><code>Ctrl + C</code></td><td>复制选中元素</td></tr>
475
+ <tr><td><code>Ctrl + V</code></td><td>粘贴元素(偏移 10mm)</td></tr>
476
+ <tr><td><code>Ctrl + D</code></td><td>原地复制(偏移 5mm, 5mm)</td></tr>
477
+ <tr><td><code>Ctrl + A</code></td><td>全选元素</td></tr>
478
+ <tr><td><code>Ctrl / ⌘ + 点击</code></td><td>在画布或图层面板中逐个加选/取消选择元素</td></tr>
479
+ <tr><td><code>空白处拖拽框选</code></td><td>左上→右下为相交命中;右下→左上为完全包围才命中</td></tr>
480
+ <tr><td><code>Delete / Backspace</code></td><td>删除选中元素</td></tr>
481
+ <tr><td><code>Ctrl + Z</code></td><td>撤销</td></tr>
482
+ <tr><td><code>Ctrl + Shift + Z</code> / <code>Ctrl + Y</code></td><td>重做</td></tr>
483
+ </tbody>
484
+ </table>
485
+
486
+ <h2>元素移动</h2>
487
+ <table>
488
+ <thead>
489
+ <tr><th>快捷键</th><th>功能</th></tr>
490
+ </thead>
491
+ <tbody>
492
+ <tr><td><code>方向键</code></td><td>移动 1mm</td></tr>
493
+ <tr><td><code>Shift + 方向键</code></td><td>移动 10mm</td></tr>
494
+ <tr><td><code>Ctrl + 方向键</code></td><td>移动 0.5mm</td></tr>
495
+ </tbody>
496
+ </table>
497
+
498
+ <h2>缩放控制</h2>
499
+ <table>
500
+ <thead>
501
+ <tr><th>快捷键</th><th>功能</th></tr>
502
+ </thead>
503
+ <tbody>
504
+ <tr><td><code>Ctrl + 1</code></td><td>重置缩放至 100%</td></tr>
505
+ <tr><td><code>Ctrl + 0</code></td><td>适应窗口</td></tr>
506
+ </tbody>
507
+ </table>
508
+
509
+ <h2>对齐操作(多选时)</h2>
510
+ <table>
511
+ <thead>
512
+ <tr><th>快捷键</th><th>功能</th></tr>
513
+ </thead>
514
+ <tbody>
515
+ <tr><td><code>Ctrl + L</code></td><td>左对齐</td></tr>
516
+ <tr><td><code>Ctrl + R</code></td><td>右对齐</td></tr>
517
+ <tr><td><code>Ctrl + E</code></td><td>水平居中</td></tr>
518
+ <tr><td><code>Ctrl + T</code></td><td>顶对齐</td></tr>
519
+ <tr><td><code>Ctrl + B</code></td><td>底对齐</td></tr>
520
+ </tbody>
521
+ </table>
522
+
523
+ <h2>组合操作</h2>
524
+ <table>
525
+ <thead>
526
+ <tr><th>快捷键</th><th>功能</th></tr>
527
+ </thead>
528
+ <tbody>
529
+ <tr><td><code>Ctrl + G</code></td><td>组合选中元素(打印时整组强制同页)</td></tr>
530
+ <tr><td><code>Ctrl + Shift + G</code></td><td>取消组合</td></tr>
531
+ </tbody>
532
+ </table>
533
+
534
+ <blockquote>
535
+ <p><strong>注意</strong>:当焦点在输入框、文本框、下拉框内时,快捷键不生效。</p>
536
+ </blockquote>
537
+ `},{id:"faq",title:"常见问题",content:`
538
+ <h2>如何调整纸张大小?</h2>
539
+ <ol>
540
+ <li>在右侧面板选择"页面设置"</li>
541
+ <li>选择预设纸张:常用纸张(A4、A3、A5、Letter、Legal)、针式打印纸(全等分 / 二等分 / 三等分)、标签纸(80×60、60×40、40×30)、小票纸(57 / 80 / 110mm)</li>
542
+ <li>或选择"自定义"输入宽度和高度(mm);"连续纸"可自定义纸宽,出纸高度按内容自动推导</li>
543
+ <li>设置方向:纵向(portrait)或横向(landscape);切换即交换纸张长宽,设计稿内容随之铺在该尺寸上。连续纸与小票纸固定纵向</li>
544
+ <li>内容旋转角度:0° / 90° / 180° / 270°,整页内容旋转对应角度出纸。90° / 270° 时纸张长宽互换以贴合旋转后的内容,设计稿内容保持原方向、不变形不裁切;0° 为不旋转(默认)。连续纸与小票纸固定纵向、无旋转概念</li>
545
+ </ol>
546
+
547
+ <h2>如何处理分页?</h2>
548
+ <p>数据表格支持自动分页:</p>
549
+ <ol>
550
+ <li>在表格属性中设置"每页显示行数"</li>
551
+ <li>启用"表头重复"确保跨页时显示标题行</li>
552
+ <li>添加小计行显示每页小计</li>
553
+ <li>添加汇总行显示整表合计</li>
554
+ <li>文本、图片等非表格元素按位置整体移页,不会拆开;已组合的元素整组强制同页,组过高会被裁切(见"如何组合多个元素")</li>
555
+ </ol>
556
+
557
+ <h2>如何导入外部数据?</h2>
558
+ <p>通过组件 props 传入数据:</p>
559
+ <ul>
560
+ <li><code>fields</code>:字段定义数组,用于字段树显示</li>
561
+ <li><code>initialTemplate</code>:初始模板数据</li>
562
+ </ul>
563
+ <p>模板加载 / 重置(如「加载默认布局」)由宿主实现:把新的模板数据赋给 <code>initialTemplate</code> 即可重载画布。</p>
564
+
565
+ <h2>如何使用表达式绑定字段?</h2>
566
+ <ol>
567
+ <li>双击元素打开表达式编辑器</li>
568
+ <li>使用 <code>{field.path}</code> 语法绑定字段</li>
569
+ <li>使用内置函数格式化数据(如 <code>{MONEY(price)}</code>)</li>
570
+ <li>点击确认保存</li>
571
+ </ol>
572
+
573
+ <h2>如何调整元素层级?</h2>
574
+ <ol>
575
+ <li>选中一个或多个元素</li>
576
+ <li>点击工具栏的层级按钮(带上下箭头图标):
577
+ <ul>
578
+ <li>置顶(箭头到顶线)</li>
579
+ <li>上移一层(向上箭头)</li>
580
+ <li>下移一层(向下箭头)</li>
581
+ <li>置底(箭头到底线)</li>
582
+ </ul>
583
+ </li>
584
+ </ol>
585
+ <p>或使用快捷键在图层面板中调整。</p>
586
+
587
+ <h2>如何选择多个元素?</h2>
588
+ <ol>
589
+ <li>按住 Ctrl(Mac 为 ⌘)在画布或左侧图层面板中逐个点击元素,逐个加入/移出选择</li>
590
+ <li>在画布<strong>空白区域</strong>按下并拖动进行框选(起点落在元素上时会变为选中或拖动该元素,不会启动框选):
591
+ <ul>
592
+ <li>从左上向右下拖动:与选框<strong>相交</strong>的元素即被选中</li>
593
+ <li>从右下向左上拖动:仅<strong>完全包围</strong>的元素被选中</li>
594
+ </ul>
595
+ </li>
596
+ <li>按 <code>Ctrl + A</code> 全选当前页元素</li>
597
+ </ol>
598
+
599
+ <h2>如何组合多个元素?</h2>
600
+ <ol>
601
+ <li>按住 Ctrl(Mac 为 ⌘)逐个点击,或用空白处框选选中多个元素</li>
602
+ <li>点击工具栏"组合"按钮、图层面板底部的组合按钮,或按 <code>Ctrl + G</code></li>
603
+ <li>组合后点击任一成员可选中整组;拖动任一成员整组跟动;打印时整组强制同页</li>
604
+ <li>取消组合:选中组内任一成员后点击"取消组合"(工具栏或图层面板),或按 <code>Ctrl + Shift + G</code></li>
605
+ </ol>
606
+ <p><strong>注意:</strong>组合元素会强制打印在同一页,引擎不会为它跨页拆分。组合前请确认组内元素的总高度(从最高点到最低点)不超过纸张内容区,否则整组虽会移到新的一页,超出页面的部分仍会被裁掉。组太高时请拆分为多个小组,或取消组合。</p>
607
+
608
+ <h2>如何使用参考线?</h2>
609
+ <ol>
610
+ <li>在标尺区域拖拽添加参考线</li>
611
+ <li>参考线自动参与吸附检测</li>
612
+ <li>拖拽参考线可调整位置</li>
613
+ <li>双击参考线可删除</li>
614
+ </ol>
615
+
616
+ <h2>如何预览打印效果?</h2>
617
+ <ol>
618
+ <li>点击工具栏"预览"按钮</li>
619
+ <li>预览使用同构渲染管线,确保与实际打印一致</li>
620
+ </ol>
621
+
622
+ <h2>模板数据格式是什么?</h2>
623
+ <p>模板以 JSON 格式存储,包含:</p>
624
+ <ul>
625
+ <li><code>paperSize</code>:纸张大小</li>
626
+ <li><code>orientation</code>:方向</li>
627
+ <li><code>margins</code>:页边距</li>
628
+ <li><code>header</code>:页眉配置</li>
629
+ <li><code>footer</code>:页脚配置</li>
630
+ <li><code>elements</code>:元素数组</li>
631
+ <li><code>watermark</code>:水印配置</li>
632
+ </ul>
633
+
634
+ <h2>如何调整表格列宽?</h2>
635
+ <ol>
636
+ <li>在左侧面板的图层列表中,点击选中对应的表格元素</li>
637
+ <li>此时画布上的表格会显示列宽分隔线</li>
638
+ <li>拖动列宽分隔线即可调整列宽</li>
639
+ </ol>
640
+ <blockquote>
641
+ <p><strong>注意</strong>:必须先选中表格元素,才能激活列宽拖动功能。</p>
642
+ </blockquote>
643
+
644
+ <h2>如何调整表格属性?</h2>
645
+ <ol>
646
+ <li>确保当前没有任何单元格被选中(如有选中,点击画布空白区域取消选中)</li>
647
+ <li>在左侧面板的图层列表中,点击选中对应的表格元素</li>
648
+ <li>右侧面板会显示表格属性设置</li>
649
+ </ol>
650
+ <blockquote>
651
+ <p><strong>注意</strong>:如果存在选中的单元格,右侧面板将显示单元格属性而非表格属性。</p>
652
+ </blockquote>
653
+
654
+ <h2>为什么部分页面有水印、部分页面没有?</h2>
655
+ <ol>
656
+ <li>水印是<strong>按模板</strong>独立设置的,每一个设计的模板都需要单独配置自己的水印信息,不会自动继承其他模板。</li>
657
+ <li>如果出现部分页面存在水印、部分页面没有水印的情况,说明该页面所在的模板没有为自身设置水印。</li>
658
+ <li>为模板添加水印:进入该模板专属页面,在右侧的"页面属性"中找到"水印"配置项进行设计即可。</li>
659
+ </ol>
660
+ <blockquote>
661
+ <p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
662
+ </blockquote>
663
+ `},{id:"changelog",title:"更新记录",content:`
664
+ <h2>V1.3.7<small>(2026-10-19)</small></h2>
665
+
666
+ <h3>新增</h3>
667
+ <ul>
668
+ <li><strong>两端对齐</strong>:文本元素和表格单元格都能选「两端」,一行字会均匀铺开、左右两头都贴齐边界(含最后一行)。想撑满列宽的表头、签字栏不必再手动加空格。</li>
669
+ <li><strong>长文本首行缩进</strong>:按「字符」填写,2 就是常规的「缩进两个字符」,字号变小时缩进也跟着变窄。</li>
670
+ <li><strong>图片缩放模式与裁剪锚点</strong>:可拉伸铺满或等比裁切,并指定保住哪一侧(证件照保住头顶);表格里的图片单元格同样能设锚点。</li>
671
+ <li><strong>二维码静区(模块)</strong>:可填 0~8 控制码面四周留白,0 即码面等比铺满元素框;需要扫码合规白边时填 4。</li>
672
+ <li><strong>工具栏自适应收纳</strong>:窗口变窄放不下时按钮组自动收进「更多」下拉,分组标题与图标形态都保留,不再出现按钮文字竖排压住画布。</li>
673
+ </ul>
674
+
675
+ <h3>修复</h3>
676
+ <ul>
677
+ <li><strong>二维码不再小一圈</strong>:此前二维码按固定尺寸出图,元素框一旦偏大就明显填不满,缩放框体也没用(24mm 框看不出来,60mm 框只画约三分之二)。现在等比铺满元素框与单元格,反复改框大小也不会重画发虚。</li>
678
+ <li><strong>图片缩放模式出纸时生效</strong>:以前只有画布按所选模式显示,预览、导出 PDF 与桌面客户端出纸都被固定成「完整显示」,现在四条链路一致。</li>
679
+ <li><strong>桌面客户端出纸更准</strong>:改走与浏览器打印同一条通路,纸张按设计器算出的实际毫米下发(60×40 / 80×60 / 100×80 mm 实测落盘尺寸精确一致、内容正立),Windows 不再需要额外安装外部打印工具。</li>
680
+ <li><strong>属性台控件跟随主题</strong>:输入框、下拉、弹层、右键菜单与滚动条统一接入主题变量,浅色外观逐像素不变,换深色不再出现白色死角;说明气泡在部分宿主下被拉成超宽长条,已修正。</li>
681
+ </ul>
682
+
683
+ <h3>注意</h3>
684
+ <ul>
685
+ <li><strong>二维码留白变少</strong>:静区缺省由固定 4 模块改为 0,既有模板的码面占框比例会变大(铺满元素框)。要保留原来的白边,请把「静区 (模块)」填成 4。</li>
686
+ <li><strong>桌面客户端设置项调整</strong>:「出纸方式」配置项已取消,出纸固定走新通路;Windows / Linux 不再显示顶部应用菜单(文本框里的复制粘贴快捷键不受影响)。</li>
687
+ </ul>
688
+
689
+ <h2>V1.3.6<small>(2026-10-16)</small></h2>
690
+
691
+ <h3>修复</h3>
692
+ <ul>
693
+ <li><strong>桌面客户端打印标签不再被转 90°</strong>:宽大于高的标签(如 100×75 mm)经桌面客户端静默打印时,纸上内容会被整体旋转 90°(导出的 PDF 本身是正的)。Windows 上出纸交给 SumatraPDF,它默认会给「宽 &gt; 高」的页面加 90°,现已按页面自身长宽比显式声明方向;macOS / Linux 上此前的纸张声明因出纸参数漏传从未真正下发,现已一并修复,横向单据(横向 A4、宽幅自定义纸)在 macOS 与 Linux 上也都不再被打印系统转 90°。</li>
694
+ </ul>
695
+
696
+ <h2>V1.3.5<small>(2026-10-05)</small></h2>
697
+
698
+ <h3>移除</h3>
699
+ <ul>
700
+ <li><strong>「首页专属」按钮与首页叠加区</strong>:不再提供只在首页出现的额外叠加区域。此前在该区域放过内容的模板,叠加内容不再输出,首页可用高度相应增大,请按新口径复核版式。</li>
701
+ <li><strong>「叠层对比」按钮</strong>:画布上的渲染截图叠层比对已下线,改用「预览」核对出纸效果。</li>
702
+ </ul>
703
+
704
+ <h3>修复</h3>
705
+ <ul>
706
+ <li><strong>右键菜单终于能用了</strong>:此前在画布上右键能弹出菜单,但菜单里的每一项(复制、粘贴、删除、置顶 / 上移 / 下移 / 置底等)点了都没有反应。现在每一项都会正常执行。</li>
707
+ <li><strong>表格右键不再要求先选中</strong>:直接在表格单元格上按右键就能打开表格菜单,不用再先点一下表格。</li>
708
+ <li><strong>右键会自动选中目标</strong>:在没有选中任何东西时右键某个元素,会先把该元素选中再弹菜单,复制、删除这类操作不会再「静默无效」。已经框选好的多个元素不受影响。</li>
709
+ </ul>
710
+
711
+ <h3>改进</h3>
712
+ <ul>
713
+ <li><strong>安装体积更小</strong>:安装包补上了许可证与作者信息,代码文件带版权说明,并且不再附带可阅读的原始代码,包体积约缩小三分之二。</li>
714
+ </ul>
715
+
716
+ <h2>V1.3.4<small>(2026-09-27)</small></h2>
717
+
718
+ <h3>修复</h3>
719
+ <ul>
720
+ <li><strong>页脚打印位置与设计台一致</strong>:此前页脚内容打印或导出 PDF 时会整体左移一个「左边距」的宽度(设计台上看着正常)。现在浏览器打印、服务端 PDF、桌面客户端静默打印三条出纸方式都与设计台所见一致,纸张旋转出纸与连续纸同样生效。</li>
721
+ </ul>
722
+
723
+ <h3>注意</h3>
724
+ <ul>
725
+ <li>如果此前为补偿这个偏移、手动把页脚元素的「左位置」调大过,升级后会变成双重偏移,请在设计台上把它调回想要的位置。</li>
726
+ </ul>
727
+
728
+ <h2>V1.3.3<small>(2026-09-27)</small></h2>
729
+
730
+ <h3>新增</h3>
731
+ <ul>
732
+ <li><strong>格式工具栏</strong>:顶部工具栏新增常用排版控件——字体、字号、加粗 / 下划线 / 删除线、文字颜色、背景颜色、对齐方式、边框。选中多个元素或多个单元格后可一次性批量设置;样式不一致时显示「混合」,用法与 Word 一致。</li>
733
+ <li><strong>边框可以只加某几条边</strong>:边框面板提供「所有 / 外侧 / 内部 / 无」预设和上、下、左、右单独开关,并可指定线型、线宽与颜色。文本、长文本、图片、条码、二维码、HTML、页码等元素现在也能加边框(矩形、椭圆、线条、表格仍按各自原有方式绘制)。</li>
734
+ <li><strong>格式刷</strong>:选中一个元素后点格式刷,再点选或框选目标即可把格式刷过去。单击刷一次后自动退出,双击可连续刷,按 <code>Esc</code> 或点空白处取消;鼠标变成「复制」样式即表示正在待刷。</li>
735
+ </ul>
736
+
737
+ <h3>改进</h3>
738
+ <ul>
739
+ <li><strong>工具栏不再跳动</strong>:排版控件收进顶部一行,次要分组改为下拉;用不上的按钮改为置灰,悬停可以看到具体原因。</li>
740
+ </ul>
741
+
742
+ <h3>注意</h3>
743
+ <ul>
744
+ <li>以前给文本、图片等元素设置过边框但看不见效果的老模板,升级后边框会真的显示出来(画布与打印一致)。如不需要,把边框宽度改成 0 或选「无」即可。</li>
745
+ </ul>
746
+
747
+ <h2>V1.3.2<small>(2026-09-26)</small></h2>
748
+
749
+ <h3>修复</h3>
750
+ <ul>
751
+ <li><strong>表格下方间距不再变大</strong>:放在表格下方的元素(合计行、签名栏等),此前打印到纸上时间距会被莫名拉大(设计台上看着正常)。现在以设计台上看到的表格底部为准,出纸与所见一致。</li>
752
+ <li><strong>翻页后不再互相叠压</strong>:表格断页续到新一页后,页尾的组合元素此前会和续排内容叠在一起。现在换页后各元素从上到下顺排,组合依然整组同页、放不下就整组移到下一页。</li>
753
+ </ul>
754
+
755
+ <h3>改进</h3>
756
+ <ul>
757
+ <li><strong>组合与多选更好用</strong>:画布和图层面板都支持 Ctrl/⌘ 点击加选;只要选中内容里有组成员,「取消组合」就会出现;组合/取消组合可在工具栏、图层面板底部按钮或 <code>Ctrl+G</code> / <code>Ctrl+Shift+G</code> 完成。帮助文档补充了框选规则与组合说明。</li>
758
+ <li><strong>图标焕新</strong>:工具栏与图层面板图标统一为新风格,全部带悬停提示;组合/取消组合使用专属图标。</li>
759
+ </ul>
760
+
761
+ <h2>V1.3.1<small>(2026-09-21)</small></h2>
762
+
763
+ <h3>新增</h3>
764
+ <ul>
765
+ <li><strong>数值运算与修约</strong>:表达式新增四则函数 <code>ADD</code> / <code>SUB</code> / <code>MUL</code> / <code>DIV</code>,以及修约函数 <code>ROUND</code>(四舍五入)、<code>ROUNDUP</code>(进一)、<code>ROUNDDOWN</code>(去尾)、<code>ROUNDBANK</code>(四舍六入五成双)。位数可省略(默认两位),写负数则修约到整十/整百。表达式编辑器「函数」页新增「数值运算」分组,双击即可插入。</li>
766
+ <li><strong>四则运算更准</strong>:直接写 <code>{qty * price}</code> 时,数字字符串按数值参与运算、不再出现 <code>0.30000000000000004</code> 这类浮点尾巴、除以 0 不再印出 <code>Infinity</code>。</li>
767
+ <li><strong>在线示例更好上手</strong>:示例库新增「综合示例模板」(多级表头 + 表格内图片 / 条形码 / 二维码混排),进入页面即自动载入;新增「自定义字段与数据」弹窗,可直接在页面上增删字段、编辑多份打印数据。在线预览已支持静态托管,可直接打开网页体验。</li>
768
+ </ul>
769
+
770
+ <h3>变更</h3>
771
+ <ul>
772
+ <li><strong>静默打印 SDK 并入 core</strong>:原 <code>@worm-vue3-print/client</code> 不再单独安装,改为从 <code>@worm-vue3-print/core/client</code> 导入;<code>PrintClient</code> 等能力保持不变,core 也不会因此增加依赖。</li>
773
+ </ul>
774
+
775
+ <h3>修复</h3>
776
+ <ul>
777
+ <li><code>ROUND(1.005, 2)</code> 此前得到 <code>1</code>(应为 <code>1.01</code>)、<code>ROUND(2.675, 2)</code> 得到 <code>2.67</code>(应为 <code>2.68</code>)——改为按十进制精确修约。</li>
778
+ <li>页码、打印日期此前只能在花括号里单独使用(<code>{pageIndex}</code>),一旦参与运算或函数(<code>{pageIndex + 1}</code>、<code>{ADD(pageIndex,1)}</code>、<code>{DATE(printDate,'YYYY')}</code>)就会被原样印出。现在这些写法都会按所在页真实求值,页眉/页脚、表格单元格同样生效。</li>
779
+ <li><strong>多级表头跨页不再丢层级</strong>:表头有好几层时,翻页后第二层往下曾经整段消失(只重复了最上面一行)。现在「表头每页重复」按整个表头区生效——表头里任意一层勾了,每一页都会完整印出全部层级;新增表头行也会自动跟随同一设置,不用担心漏勾。</li>
780
+ </ul>
781
+
782
+ <h2>V1.3.0<small>(2026-09-20)</small></h2>
783
+
784
+ <h3>新增</h3>
785
+ <ul>
786
+ <li><strong>多页面模板</strong>:一份文书可以由版式不同的多个页面按固定顺序组成(如「封面 + 正文 + 条款」),各页绑定同一份数据,下一次出纸就是完整的一份文档。顶部页面栏支持新增、复制、删除、前移/后移、双击重命名与点击切换;删到只剩一页时自动回到单页模式。</li>
787
+ <li><strong>内容旋转角度</strong>:页面属性新增「内容旋转角度」(0° / 90° / 180° / 270°),支持横版设计、竖版出纸——内容整体旋转填满出纸版面,不缩放也不裁切。</li>
788
+ <li><strong>设计背景(套打底图)</strong>:页面属性支持上传、90° 步进旋转与移除底图,照着现成单据排版更省力。底图只在设计画布显示,预览与打印都不会输出。</li>
789
+ </ul>
790
+
791
+ <h3>变更</h3>
792
+ <ul>
793
+ <li><strong>条码尺寸</strong>:条形码(元素与表格单元格)不再拉伸填满元素框,改为按「条宽 → 打印机分辨率 → 等比缩小」结算:默认条宽下每模块 0.25mm,装得下就按原尺寸落纸;设置了「打印机分辨率」(203/300/600)时吸附到整数打印点;宽度不足时整体等比缩小。要更大的条码请调大「条宽」,需要上限请用「最大宽高」——条形码不再提供「缩放模式」。<strong>同一份旧模板的条码会变小</strong>,这是让出纸条宽保持稳定所必需的。</li>
794
+ <li><strong>文字溢出</strong>:文本元素与表格单元格支持「截断 / 自动缩小 / 自适应行高」三种显示形式(属性面板「文字溢出」),缺省值与原有行为一致,存量模板不受影响。</li>
795
+ <li><strong>标签纸</strong>:纸张切到标签纸(80×60 / 60×40 / 40×30mm)时默认取消页边距与页眉页脚,整张纸都给内容区;只在切换纸型时套用一次,之后仍可自行改回,存量模板不会被改写。</li>
796
+ <li><strong>多页面约束</strong>:纸张设置对所有页生效,页边距、页眉页脚、首页叠加、水印与内容元素则按页各自独立;多页模式下隐藏拼版配置、禁用连续纸。</li>
797
+ </ul>
798
+
799
+ <h3>修复</h3>
800
+ <ul>
801
+ <li>多页面模板页面重排后页签名漂移、删除页面后再新增出现重名。</li>
802
+ <li>条形码经热敏打印机出纸条宽忽宽忽窄、边缘发灰;条宽倍率在不同模式下视觉不一致。</li>
803
+ <li>元素堆叠与显式组合在分页时被拆散;单击组合内的任一成员改为选中整组。</li>
804
+ <li>水印经真实打印机出纸被放大约 3 倍、位置偏移、平铺错乱(改为逐块矢量瓦片渲染)。</li>
805
+ <li>小纸张模板(如 80×60mm 自定义纸)输出多出一张空白首页。</li>
806
+ </ul>
807
+
808
+ <h2>V1.2.2<small>(2026-09-11)</small></h2>
809
+
810
+ <h3>变更</h3>
811
+ <ul>
812
+ <li><code>@worm-vue3-print/core</code> 新增子路径 <code>/designer</code>:框架无关的设计器内核,包含完整模板模型类型、通用工具(元素工厂、表格矩阵、单位换算、模板迁移、标尺等)与纯交互逻辑(对齐、分组、键盘、缩放、吸附计算),不依赖 Vue/React。</li>
813
+ <li><code>@worm-vue3-print/core</code> 新增子路径 <code>/browser</code>:浏览器侧渲染适配器(<code>renderHtmlPages</code> 两遍分页渲染、条形码/二维码渲染器)。</li>
814
+ <li>设计器模型、工具与纯逻辑下沉至 core 子路径,canvas 仅保留 Vue 适配层;公共 API 保持不变,core 主入口仍为零运行时依赖,为后续多框架适配打下基础。</li>
815
+ </ul>
816
+
817
+ <h3>修复</h3>
818
+ <ul>
819
+ <li>修复工具栏放大/缩小按钮直接线性改缩放比例、未做滚动锚点校正导致画面漂移的问题;按钮缩放改为与 Ctrl+滚轮一致的乘性步进,并以视口中心为锚点(与「适应窗口」同一缩放管线)。</li>
820
+ </ul>
821
+
822
+ <h2>V1.2.1<small>(2026-09-11)</small></h2>
823
+
824
+ <h3>变更</h3>
825
+ <ul>
826
+ <li>工具栏编辑区/层级区/视图区图标按钮统一使用 data-tip 自定义悬浮提示,补齐「网格」「吸附」缺失提示;提升提示层级,不再被画布顶部标尺遮挡。</li>
827
+ <li>优化「适应窗口」:以视口中心为锚点一步缩放到位(与 Ctrl+滚轮同一缩放换算管线),缩放平滑过渡;允许低于交互缩放下限(最小可至 5%),超大纸张也能整版容纳,纸张在画布视口内水平垂直居中。</li>
828
+ <li>新增 <code>showHelp</code> 配置:控制帮助入口(帮助按钮与帮助弹框)显示,默认开启,传入 <code>false</code> 即可隐藏。</li>
829
+ </ul>
830
+
831
+ <h3>修复</h3>
832
+ <ul>
833
+ <li>工具栏悬浮提示气泡被画布顶部固定标尺遮挡无法显示。</li>
834
+ <li>「适应窗口」后超大纸张仍残留滚动条、纸张未在画布视口居中(垂直偏上)。</li>
835
+ </ul>
836
+
837
+ <h3>文档</h3>
838
+ <ul>
839
+ <li>新增打印设计工作台布局线框图文档(<code>docs/中文/打印设计工作台-布局线框图.md</code>),标注各区域名称、功能与对应组件文件。</li>
840
+ </ul>
841
+
842
+ <h2>V1.2.0<small>(2026-09-10)</small></h2>
843
+
844
+ <h3>新增</h3>
845
+ <ul>
846
+ <li>帮助文档模态框(HelpModal):内置功能介绍、快捷键一览、常见问题与更新记录,按 Esc 或点击遮罩关闭。</li>
847
+ <li>标尺参考线增强:支持从标尺拖拽添加参考线、双击编辑、删除,参考线对齐吸附实时显示。</li>
848
+ <li>表格列宽拖拽新增末列右边界手柄:可直接拖拽末列右边界调整末列宽,受打印范围宽度与最小列宽 5mm 钳制。</li>
849
+ </ul>
850
+
851
+ <h3>变更</h3>
852
+ <ul>
853
+ <li>优化缩放逻辑:取消放大上限,支持滚轮乘性步进缩放,修复缩放锚点漂移问题。</li>
854
+ <li>移除设计态元素左上角的 fx 绑定标签提示,简化元素视觉呈现。</li>
855
+ </ul>
856
+
857
+ <h3>文档</h3>
858
+ <ul>
859
+ <li>仓库根目录新增 <code>AGENTS.md</code>:AI 代理行为规范,明确代理在本仓库工作时的语言、专家态度、协作约定等强制要求。</li>
860
+ <li>新增 <code>worm-vue3-print</code> 集成支持 skill:包含安装指南、集成 API、故障排查等参考文档。</li>
861
+ </ul>
862
+
863
+ <h3>修复</h3>
864
+ <ul>
865
+ <li>表格列宽拖拽存在的多个缺陷:
866
+ <ul>
867
+ <li>内部列边界向左拖时左列宽度不变,导致边界线不跟随光标。</li>
868
+ <li>px → mm 单位换算缺失,拖拽距离存在约 3.78 倍偏差。</li>
869
+ <li><code>table-layout: fixed</code> 下拖拽过程中表格 CSS <code>width(100%)</code> 与列宽和失配,导致浏览器按比例拉伸列,使边界线与右侧内容偏离光标。</li>
870
+ <li>删除 <code>onColResizeStart</code> 中残留的 <code>document.title</code> 调试代码。</li>
871
+ </ul>
872
+ </li>
873
+ </ul>
874
+
875
+ <h2>V1.1.0<small>(2026-09-06)</small></h2>
876
+
877
+ <h3>新增</h3>
878
+ <ul>
879
+ <li>表格元素支持列宽拖拽:设计态选中表格后,在列边界悬停并拖动即可调整该列宽(左侧列),实时更新画布与元素尺寸;受打印范围宽度与最小列宽 5mm 钳制,拖拽结束后计入一次撤销历史。属性面板的列宽数值输入保留作为精确输入兜底。</li>
880
+ <li>表格单元格支持图片类型:单元格可切换为图片类型,设计态支持选择图片与设置 fit/maxWidth/maxHeight,预览与打印输出完整渲染。</li>
881
+ <li>条形码与二维码单元格支持 fit/maxWidth/maxHeight 属性。</li>
882
+ <li>属性面板位置尺寸改用 StepperInput 控件:支持按钮微调数值;StepperInput 支持可选值列表和小数步进。</li>
883
+ <li>新增统一颜色选择器并重构属性面板字段分组。</li>
884
+ <li>支持页面(纸张)背景色 <code>pageBackground</code>,预览与打印/PDF 输出一致。</li>
885
+ <li>支持 canvas 库模式构建与 npm 发布。</li>
886
+ </ul>
887
+
888
+ <h3>修复</h3>
889
+ <ul>
890
+ <li>打印/导出 PDF 保留元素背景色(<code>print-color-adjust: exact</code>)。</li>
891
+ <li>打印预览保留元素重叠,表格下方跟随元素按设计坐标绝对定位并透传层级 z-index。</li>
892
+ <li>打印页眉页脚区域贴页面底部,修复页边距失效。</li>
893
+ <li>条形码渲染缺少 <code>object-fit: contain</code>。</li>
894
+ <li>修复 canvas 测试在 vitest v4 + happy-dom 环境下 <code>localStorage</code> 未定义的问题,补充 mock 以兼容测试环境。</li>
895
+ </ul>
896
+
897
+ <h2>V1.0.0<small>(2026-09-02)</small></h2>
898
+
899
+ <h3>新增</h3>
900
+ <ul>
901
+ <li>首次开源发布。</li>
902
+ <li><code>@worm-vue3-print/core</code>:模板表达式引擎与同构渲染管线(HTML 生成 / 分页 / 数据绑定)。</li>
903
+ <li><code>@worm-vue3-print/canvas</code>:Vue 3 可视化打印模板设计器画布。</li>
904
+ <li>渲染微服务拆分为独立仓库 <code>worm-vue3-print-render</code>(仅 Docker 部署,不上 npm)。</li>
905
+ </ul>
906
+
907
+ <blockquote>
908
+ <p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
909
+ </blockquote>
910
+ `}],mu="worm-print-help-tab",b1="getting-started";function bu(t){return po.some(e=>e.id===t)?String(t):""}function v1(t){let e=null;try{e=window.localStorage.getItem(mu)}catch{e=null}return bu(e)||bu(t)||b1}function y1(t){const e=v1(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=po.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(mu,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"},po.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:po.find(r=>r.id===e)?.content??""})])])])])}function x1(t,e){const n=xe(y1(e),t),r=o=>{o.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const w1=2,E1=74,Pa=[{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 S1(t){const e=!!t.state.openMore,n=Pa.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:`${De("Ellipsis",15)}<span class="tb-btn-text">更多</span>${De("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 vu=new WeakMap;function yu(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(e),r=Number.parseFloat(n.gap)||w1,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 v=m.parentElement;v&&!v.classList.contains("tb-more-slot")&&vu.set(m,{parent:v,next:m.nextSibling}),a.set(m.dataset.unit,m)}for(const m of a.values()){const v=vu.get(m);!v||m.parentElement===v.parent||(v.next?.parentElement===v.parent?v.parent.insertBefore(m,v.next):v.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 v=Math.max(m.offsetWidth,m.scrollWidth);v<=0||(l+=v+r)}const c=new Map;for(const[m,v]of a){const x=v.offsetWidth;x>0&&c.set(m,x)}const s=Pa.map(m=>({id:m.id,order:m.order,width:c.get(m.id)??0})),d=s.reduce((m,v)=>m-v.width-r,l),p=e.clientWidth-o-i,{movedIds:u,overflowRemains:f}=bp({available:p,pinned:d,moreTriggerWidth:E1,gap:r,units:s});for(const m of Pa){const v=e.querySelector(`.tb-more-item[data-unit="${m.id}"]`),x=e.querySelector(`#tb-more-slot-${m.id}`),w=a.get(m.id);if(!v||!x||!w)continue;const y=u.includes(m.id);y&&w.parentElement!==x&&x.appendChild(w),v.style.display=y?"":"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 _1(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"},[oe(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),oe(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),oe(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),oe(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),oe(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),oe(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),oe(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),oe(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),g("div",{class:"tb-menu-label",text:"层级"}),g("div",{class:"tb-menu-grid"},[oe(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),oe(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),oe(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),oe(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),g("div",{class:"tb-menu-label",text:"组合"}),g("div",{class:"tb-menu-grid"},[oe(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),oe(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"},[oe(t,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),oe(t,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),e,g("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[so(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),so(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),g("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[oe(t,"Maximize","fit-window",{tip:"适应窗口"}),oe(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),g("span",{class:"tb-zoom",text:`${n.scale}%`}),oe(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),g("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[oe(t,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),oe(t,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),oe(t,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),S1(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 Ra(t,e,n){for(const r of e){const o=t.getPropertyValue(r).trim();if(o)return o}return n}function T1(t,e){const n=e.orientation==="horizontal",r=e.geom,o=n?r.viewW:r.viewH;t.style.width=`${n?o:Uo}px`,t.style.height=`${n?Uo:o}px`;const i=t.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=Uo;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=Ra(s,["--pd-ruler-bg"],"#F8F9FC"),p=Ra(s,["--pd-ruler"],"#9AA1AF"),u=Ra(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=ut(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},v=-m.originPx/h,x=(l-m.originPx)/h,w=Lp(f),y=zp(v,x,w);wu(m,y,p,!0),wu(m,y,p,!1),Eu(m,0,u),Eu(m,e.paperLengthMM,u);const S=e.cursorPx??null;if(S!==null&&S>=0&&S<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const D=Math.round(S)+.5;i.moveTo(D,0),i.lineTo(D,c)}else{const D=Math.round(S)+.5;i.moveTo(0,D),i.lineTo(c,D)}i.stroke()}}function xu(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function wu(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=xu(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 Eu(t,e,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=t,l=xu(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 k1=':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}.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-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-input{width:100%}.font-select-list{margin-top:4px;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);list-style:none}.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-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{font-size:11px;color:var(--pd-text-muted, #909399);flex-shrink:0}.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:break-all}.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-4682b43a .3s ease-out}@keyframes snap-pulse-4682b43a{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}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width: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}.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}.pd-reset{height:26px;padding:0 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;flex-shrink:0;transition:all .14s ease}.pd-reset:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.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}.page-tabs-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;white-space:nowrap;pointer-events:none}.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}.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}',fo=20,M1=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),C1={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},Su="print-studio:left",_u="print-studio:right";function Tu(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function ku(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}class Qe 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;pageTipEl=null;pageTipTimer=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=k1,this.root.appendChild(e),xe(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 gd(e),this.format=new gm(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=Tu(Su),this.state.propCollapsed=Tu(_u),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,ku(Su,this.state.leftCollapsed),ku(_u,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,Qe.active===this&&(Qe.active=null),Vd(),this.unmountHelp?.(),this.unmountHelp=null,this.hidePageTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=pn(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.templateJsonWithFonts();if(Array.isArray(n.pages))try{xi(n)}catch(o){window.alert(o instanceof Error?o.message:String(o));return}const r=JSON.stringify(n);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:r,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?vi(e):[]}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;xe(m1({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=x1(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&&Sa(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};Ma(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=C1[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=Fo(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),pd(n);const r=this.ctx;xe(_1(r,vb(r)),n),xe(Tb(r),n),xe(g("div",{class:"designer-body"},[wb(r),K0(r,this.canvasUi()),i1(r)]),n),xe(kb(r),n),yu(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>yu(n)),this.toolbarRo.observe(n));const o=P0(this.store,(i,a)=>this.fire(i,a),this.tableMenu);o&&xe(o,n),o0(this.root,this.store.elements),lu(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))dd(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/ut(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-fo+this.scrollPos.x,originY:o.top-r.top-fo+this.scrollPos.y,viewW:e.clientWidth-fo,viewH:e.clientHeight-fo},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=pt(e),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";T1(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=Jd(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=Un((e.clientX-r.left)/o),a=Un((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?xe(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=Lt(),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(),xe(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=Un((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=pt(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=Un((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=ut(1)*(this.geom.paperScale||1),a=n==="vertical"?(e.clientX-o.left)/i:(e.clientY-o.top)/i,l=pt(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(ts(this.store.scale,e),n.clientWidth/2,n.clientHeight/2,Gn)}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=pt(this.store.templateData),a=gp(e.clientWidth-r,e.clientHeight-o,ut(i.width),ut(i.height));this.applyZoom(a,e.clientWidth/2,e.clientHeight/2,es)}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=ts(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,Gn)}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)*ut(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(x=>!this.drag.ids.includes(x.id)&&(x.zone||"content")===this.drag.zone).map(x=>({id:x.id,left:x.options.left,top:x.options.top,width:x.options.width,height:x.options.height})),m=fa(n.templateData,n.paperSize)[this.drag.zone],v=Dh(s,h,this.manualGuides());d={left:v.left,top:v.top},n.adsorbGuides=(v.lines??[]).filter(x=>x.position>=0&&x.position<=(x.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 v={left:m.left+u,top:m.top+f};this.drag.movedPositions.set(h,v),n.livePatch(h,v)}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=Fh(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(".page-tabs")||(this.pageTipTimer&&clearTimeout(this.pageTipTimer),this.pageTipTimer=setTimeout(()=>this.showPageTip(r),300))}),this.root.addEventListener("mouseout",e=>{const n=e,r=n.target?.closest?.("[data-tip]");r&&n.relatedTarget?.closest?.("[data-tip]")!==r&&this.hidePageTip()})}showPageTip(e){const n=e.dataset.tip;if(!n)return;this.hidePageTip();const r=e.getBoundingClientRect(),o=Math.min(Math.max(r.left+r.width/2,80),window.innerWidth-80);this.pageTipEl=xe(g("div",{class:"page-tabs-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root)}hidePageTip(){this.pageTipTimer&&(clearTimeout(this.pageTipTimer),this.pageTipTimer=null),this.pageTipEl?.remove(),this.pageTipEl=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;fa(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=()=>{Qe.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),Qe.active||(Qe.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||Qe.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();M1.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 Mu(t="print-designer"){return customElements.get(t)||customElements.define(t,Qe),t}function A1(){return Mu()}const O1=Object.freeze(Object.defineProperty({__proto__:null,DesignerStore:gd,PrintDesignerElement:Qe,TILING_SINGLE_PAGE_TIP:Ki,createDefaultTemplate:Cn,definePrintDesigner:Mu,registerAll:A1,serializePage:fd,toRuntimePool:Ji},Symbol.toStringTag,{value:"Module"})),P1=17521,R1=20,Ia={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml"};let Da=0;function I1(){return Da=(Da+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${Da.toString(36)}`}function Cu(t,e){const n={id:I1(),type:t,payload:e};return JSON.stringify(n)}function Au(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 et extends Error{constructor(e,n){super(n),this.name="WormPrintError",this.code=e}}class Ou extends Error{constructor(e){super(e),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class D1{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:R1},(r,o)=>P1+o);for(const r of n){if(e?.aborted)throw new et("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 Ou)throw this.setStatus("disconnected"),new et("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new et("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(e,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new et("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=Cu(e,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new et("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 et("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(Cu("hello",{}))},i.onmessage=c=>{const s=Au(String(c.data));if(!("malformed"in s))if(s.ok&&$1(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 Ou(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=Au(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 et(r.error.code,r.error.message)))},e.onclose=()=>{this.failAllPendings(new et("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 $1(t){return typeof t=="object"&&t!==null&&t.app==="worm-print-client"}const Pu="worm-print-client:token";class $a{constructor(e={}){const r={token:e.token??$a.loadStoredToken()??void 0,timeoutMs:e.timeoutMs,WebSocketCtor:e.WebSocketCtor};this.transport=new D1(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(Ia.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(Ia.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(Ia.PRINT_SUBMIT_HTML,a,o)}pair(e){localStorage.setItem(Pu,e),this.transport.setToken(e)}static loadStoredToken(){try{return localStorage.getItem(Pu)}catch{return null}}close(){this.transport.close()}}const L1={...O1,renderHtmlPages:dm,browserCodeRenderer:Vi,PrintClient:$a,WormPrintError:et,getPaperDimensions:ve,isContinuousPaperSize:Bt,getByPath:dn};globalThis.WormPrintCommon??=L1}));