@worm-print-platform/canvas 1.5.3 → 1.6.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 (55) hide show
  1. package/README.md +9 -3
  2. package/dist/browser-bundle.d.ts +1 -1
  3. package/dist/canvas.css +1 -1
  4. package/dist/canvas.js +75 -63
  5. package/dist/core/default-template.d.ts +1 -1
  6. package/dist/core/element-definitions.d.ts +1 -1
  7. package/dist/core/format.d.ts +1 -1
  8. package/dist/core/h.d.ts +3 -17
  9. package/dist/core/icons.d.ts +1 -1
  10. package/dist/core/plugin.d.ts +1 -1
  11. package/dist/core/store.d.ts +1 -1
  12. package/dist/host-contract.d.ts +9 -3
  13. package/dist/index.cjs +22 -10
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +1712 -1666
  16. package/dist/print-designer.d.ts +7 -3
  17. package/dist/shell/binding.d.ts +2 -2
  18. package/dist/shell/canvas.d.ts +2 -2
  19. package/dist/shell/code.d.ts +3 -3
  20. package/dist/shell/color-picker.d.ts +3 -39
  21. package/dist/shell/controls.d.ts +14 -11
  22. package/dist/shell/crop-anchor.d.ts +2 -2
  23. package/dist/shell/elements.d.ts +2 -2
  24. package/dist/shell/expression-editor.d.ts +3 -28
  25. package/dist/shell/flow-list.d.ts +2 -2
  26. package/dist/shell/font-select.d.ts +1 -1
  27. package/dist/shell/format-bar.d.ts +2 -2
  28. package/dist/shell/help-content/advanced-settings.d.ts +1 -1
  29. package/dist/shell/help-content/changelog.d.ts +1 -1
  30. package/dist/shell/help-content/faq.d.ts +1 -1
  31. package/dist/shell/help-content/features.d.ts +1 -1
  32. package/dist/shell/help-content/getting-started.d.ts +1 -1
  33. package/dist/shell/help-content/index.d.ts +1 -1
  34. package/dist/shell/help-content/shortcuts.d.ts +1 -1
  35. package/dist/shell/help-modal.d.ts +1 -1
  36. package/dist/shell/page-extras.d.ts +1 -1
  37. package/dist/shell/panels.d.ts +4 -4
  38. package/dist/shell/plugin-ui.d.ts +1 -1
  39. package/dist/shell/prop-group.d.ts +1 -1
  40. package/dist/shell/property-panel.d.ts +1 -1
  41. package/dist/shell/property-search.d.ts +1 -1
  42. package/dist/shell/ruler.d.ts +1 -1
  43. package/dist/shell/table-props.d.ts +1 -1
  44. package/dist/shell/table.d.ts +1 -1
  45. package/dist/shell/toolbar-overflow.d.ts +2 -2
  46. package/dist/shell/toolbar.d.ts +2 -2
  47. package/dist/shell/watermark.d.ts +1 -1
  48. package/dist/theme-tokens.d.ts +1 -1
  49. package/dist/version.d.ts +2 -2
  50. package/dist/vue3/PrintDesigner.d.ts +1 -1
  51. package/dist/vue3/PrintHtmlPreview.d.ts +1 -1
  52. package/dist/vue3/index.d.ts +1 -1
  53. package/dist/vue3/previewStyle.d.ts +1 -1
  54. package/dist/vue3/toolbarOverflow.d.ts +1 -1
  55. package/package.json +3 -3
package/dist/canvas.js CHANGED
@@ -1,12 +1,12 @@
1
- (function(so){typeof define=="function"&&define.amd?define(so):so()})((function(){"use strict";function so(){let e=0;return function(){return e+=1,`cell-${Date.now().toString(36)}-${e}`}}function Cg(){let e=0;return function(){return e+=1,`row-${Date.now().toString(36)}-${e}`}}const Ag=so(),Og=Cg(),Kt={width:.75,style:"solid",color:"#333333"};function ea(e){return JSON.parse(JSON.stringify(e))}function ta(e){return{id:Ag(),borders:{top:{...Kt},right:{...Kt},bottom:{...Kt},left:{...Kt}},...e}}function Ig(){const e=[50,50,50],t=(r,o)=>({id:Og(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:e.map(()=>ta())}),n=t("header",!0);return n.cells.forEach((r,o)=>{r.formatter=`列${o+1}`,r.align="center",r.fontWeight="bold"}),{rows:[n,t("data"),t("subtotal"),t("summary")],colWidths:e}}function ar(e,t,n){if(!e[t].cells[n].merged)return{r:t,c:n};for(let r=t;r>=0;r--)for(let o=n;o>=0;o--){const i=e[r].cells[o];if(i.merged)continue;const a=i.rowspan??1,l=i.colspan??1;if(r+a-1>=t&&o+l-1>=n)return{r,c:o}}return{r:t,c:n}}function cn(e,t,n){const r=ar(e,t,n),o=e[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 ec(e,t,n){let r={r1:Math.min(t.r,n.r),c1:Math.min(t.c,n.c),r2:Math.max(t.r,n.r),c2:Math.max(t.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=cn(e,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 tc(e,t){if((t.r2-t.r1+1)*(t.c2-t.c1+1)<2)return"至少选择 2 个单元格";const r=new Set;for(let i=t.r1;i<=t.r2;i++)r.add(e[i].type);if(r.size>1)return"合并区域不能跨越不同类型的行";if(t.r2>t.r1&&r.has("data"))return"数据行将按列表展开,纵向合并请使用单元格属性「按值合并」";const o=ec(e,{r:t.r1,c:t.c1},{r:t.r2,c:t.c2});return o.r1!==t.r1||o.c1!==t.c1||o.r2!==t.r2||o.c2!==t.c2?"选区与已有合并区域部分重叠":null}function nc(e,t){const n=e[t.r1].cells[t.c1],r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];a.formatter&&r.push(a.formatter),!(o===t.r1&&i===t.c1)&&(a.merged=!0,a.rowspan=1,a.colspan=1,a.formatter="")}n.rowspan=t.r2-t.r1+1,n.colspan=t.c2-t.c1+1,n.formatter=r.join(" ")}function rc(e,t){for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e[n].cells[r];if(!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1)){const i=cn(e,n,r),a=o;for(let l=i.r1;l<=i.r2;l++)for(let c=i.c1;c<=i.c2;c++){const s=e[l].cells[c];s.merged=!1,s.rowspan=1,s.colspan=1,Pg(a,s)}o.rowspan=1,o.colspan=1}}}function Pg(e,t){e!==t&&(t.align=e.align,t.valign=e.valign,t.fontSize=e.fontSize,t.fontFamily=e.fontFamily,t.fontWeight=e.fontWeight,t.color=e.color,t.backgroundColor=e.backgroundColor,t.borders=e.borders?ea(e.borders):void 0,t.padding=e.padding,t.wordWrap=e.wordWrap)}function oc(e,t,n){const r=n==="above"?t:t+1,o=e[t],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:[e[r-1],e[r]].find(c=>c?.type==="header")?.repeatOnPage===!0}:{},cells:Array.from({length:i},()=>ta())};for(let c=0;c<i;c++)if(r>0&&r<e.length){const s=cn(e,r-1,c);if(s.r1<r&&s.r2>=r){const d=e[s.r1].cells[s.c1];d.rowspan=(d.rowspan??1)+1,l.cells[c].merged=!0}}e.splice(r,0,l)}function Rg(e,t){if(e.length<=1)return"不能删除最后一行";const n=e[t],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=e[t+1].cells[o];Object.assign(a,ea(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=cn(e,t,o);if(a.r1<t&&a.c1===o){const l=e[a.r1].cells[a.c1];l.rowspan=(l.rowspan??1)-1}}}return e.splice(t,1),null}function ic(e,t,n,r){const o=r==="left"?n:n+1;t.splice(o,0,t[n]);for(const i of e){const a=ta();if(o>0&&o<i.cells.length){const l=e.indexOf(i),c=cn(e,l,o-1);if(c.c1<o&&c.c2>=o){const s=e[c.r1].cells[c.c1];l===c.r1&&(s.colspan=(s.colspan??1)+1),a.merged=!0}}i.cells.splice(o,0,a)}}function Dg(e,t,n){if(t.length<=1)return"不能删除最后一列";for(let r=0;r<e.length;r++){const o=e[r].cells[n];if(!o.merged&&(o.colspan??1)>1){const i=e[r].cells[n+1];Object.assign(i,ea(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=cn(e,r,n);if(i.c1<n&&i.r1===r){const a=e[i.r1].cells[i.c1];a.colspan=(a.colspan??1)-1}}}for(const r of e)r.cells.splice(n,1);return t.splice(n,1),null}function na(e,t,n){if(n==="data"){const r=e.findIndex((o,i)=>o.type==="data"&&i!==t);if(r>=0)return`数据行已存在(第 ${r+1} 行),全表最多一行`}if(n==="header"){for(let r=0;r<t;r++)if(e[r].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const r=e.findIndex(o=>o.type==="data");if(r<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(t<r)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&e.slice(0,t).some(r=>r.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&e.slice(t+1).some(r=>r.type==="subtotal"))return"汇总行必须位于小计行之后";if(e[t].type==="header"&&n!=="header"){for(let r=t+1;r<e.length;r++)if(e[r].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}if(e[t].type=n,n==="header"){const r=[e[t-1],e[t+1]].find(o=>o?.type==="header");e[t].repeatOnPage=e[t].repeatOnPage!==void 0?e[t].repeatOnPage===!0:r?.repeatOnPage===!0}else delete e[t].repeatOnPage;return null}function $g(e,t){for(const n of e){if(n.type!=="header")break;n.repeatOnPage=t}}function ac(e,t,n,r){for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];if(a.merged)continue;if(n==="none"){delete a.borders;continue}const l=cn(e,o,i),c=l.r1===t.r1,s=l.r2===t.r2,d=l.c1===t.c1,p=l.c2===t.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 Ng="线型 / 宽度 / 颜色是待应用规格:选中格已有的边框规格一致时会填进这三行;四边不一致的项显示「混合」,一条边都没有时显示「无 / 0」。改完点「全部 / 外侧 / 内部」或勾选上、下、左、右某条边才会写入选中的单元格;「无」是清除边框",Lg="多选时不回显单格边框:线型 / 宽度 / 颜色按当前设置作为批写规格,点「全部 / 外侧 / 内部」或勾选某条边后写入所有选中格;「无」是清除边框",Fg="当前单元格四边边框规格不一致:带「混合」的项不谎报,未改项在点「全部 / 外侧 / 内部」或勾选单边时按缺省档(实线 0.75pt)写入,改任一项即按该值批写";function sc(e,t,n){const r={...e.borders??{}};n?r[t]={...n}:delete r[t],e.borders=r.top||r.right||r.bottom||r.left?r:void 0}function lo(e,t){const n=[];for(let r=t.r1;r<=t.r2;r++)for(let o=t.c1;o<=t.c2;o++){const i=e[r]?.cells[o];i&&!i.merged&&n.push(i)}return n}function ra(e,t){const n=lo(e,t).length;return{mode:n>1?"multi":"single",count:n}}function zg(e,t){const n=lo(e,t);if(!n.length)return null;const r=n[0].cellType??"text";return n.every(o=>(o.cellType??"text")===r)?r:null}function lc(e,t){const n=[];for(const o of lo(e,t))for(const i of["top","right","bottom","left"]){const a=o.borders?.[i];a&&n.push(a)}const r=o=>{if(!n.length)return;const i=o(n[0]);return n.every(a=>o(a)===i)?i:"mixed"};return{width:r(o=>o.width),style:r(o=>o.style),color:r(o=>o.color)}}const Bg="1px dashed rgba(0,0,0,0.18)";function co(e,t={}){return e&&e.style!=="none"?`${e.width}pt ${e.style} ${e.color}`:t.designMode&&t.showGhostBorder!==!1?Bg:"none"}function sr(e){const t=(e.tableColWidths??[]).reduce((r,o)=>r+o,0),n=(e.tableRows??[]).reduce((r,o)=>r+o.height,0);e.width=Math.round(t*100)/100,e.height=Math.round(n*100)/100}const cc=5;function Hg(e,t,n,r){const o=e.reduce((l,c,s)=>s===t?l:l+c,0),i=r===1/0?1/0:Math.max(cc,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,cc),i)}const dc=Symbol.for("worm-print-platform.element-capabilities.v1"),uc=globalThis;function dn(){const e=uc[dc];if(e)return e;const t={entries:new Map,nextSeq:0,bootstrapped:!1};return uc[dc]=t,pc(t),t}const Ug={left:7,top:17.6,width:42.3,height:7.1},qg=Object.freeze({text:"示例文本",longText:"示例长文本内容",barcode:"12345678",qrcode:"qrcode"});function Wg(e){if(e)return qg[e]}const lr=Object.freeze({text:{zoneAllowed:!0,defaultTextFit:"clip",bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],defaultOptions:()=>({formatter:"文本",exampleValue:"示例文本",fontSize:12,textAlign:"left",height:5.3}),title:"文本"},longText:{defaultTextFit:"autoHeight",bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],defaultOptions:()=>({width:141.1,height:28.2,fontSize:12,lineHeight:18,exampleValue:"示例长文本内容"}),title:"长文"},barcode:{zoneAllowed:!0,codeRotationDpiGated:!0,bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],defaultOptions:()=>({width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678",exampleValue:"12345678"}),title:"条形码"},qrcode:{zoneAllowed:!0,codeRotationDpiGated:!0,bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],defaultOptions:()=>({width:28.2,height:28.2,title:"二维码",testData:"qrcode",exampleValue:"qrcode"}),title:"二维码"},image:{zoneAllowed:!0,bindings:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],defaultOptions:()=>({width:28.2,height:28.2,fit:"contain"}),title:"图片"},table:{rotationExcluded:!0,acceptsElementBorder:!1,bindings:[],defaultOptions:()=>{const{rows:e,colWidths:t}=Ig(),n=t.reduce((o,i)=>o+i,0),r=e.reduce((o,i)=>o+i.height,0);return{width:n,height:r,tableMode:"dynamic",tableRows:e,tableColWidths:t,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}},title:"表格"},flowList:{rotationExcluded:!0,defaultTextFit:"clip",bindings:[{targetPath:"options.formatter",label:"单元模板",dataSource:"main",placeholder:"{drugs.name} {drugs.spec}"}],defaultOptions:()=>({width:141.1,height:21.2,fontSize:12,formatter:"{name} {spec}",flowColumns:4,flowRowHeight:8,flowGapX:4,flowAutoSpan:!1,flowMaxSpan:2,flowLayoutMode:"fixed",flowPaddingTop:0,flowPaddingRight:0,flowPaddingBottom:0,flowPaddingLeft:0}),title:"流式列表"},hline:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:70.6,height:1.8,borderWidth:.75}),title:"横线"},vline:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:1.8,height:35.3,borderWidth:.75}),title:"竖线"},rect:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:28.2,height:28.2,borderWidth:1,borderColor:"#333"}),title:"矩形"},oval:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:28.2,height:28.2,borderWidth:1,borderColor:"#333"}),title:"椭圆"},html:{blocked:!0,defaultOptions:()=>({width:28.2,height:28.2}),title:"HTML"},pageNumber:{title:"页码"}});function pc(e){if(!e.bootstrapped){e.bootstrapped=!0;for(const[t,n]of Object.entries(lr))e.entries.has(t)||e.entries.set(t,{caps:n,seq:e.nextSeq++})}}function jg(e,t){if(!e||typeof e!="string")throw new Error("registerElementCapabilities: type 必须是非空字符串");if(!t||typeof t!="object")throw new Error("registerElementCapabilities: caps 必须是对象");const n=dn(),r=n.nextSeq++;return n.entries.set(e,{caps:t,seq:r}),()=>{if(dn().entries.get(e)?.caps!==t)return;const i=lr[e];i?dn().entries.set(e,{caps:i,seq:r}):dn().entries.delete(e)}}function ut(e){return e?{...dn().entries.get(e)?.caps??{},type:e}:{type:""}}function oa(){return[...dn().entries.entries()].sort((e,t)=>e[1].seq-t[1].seq).map(([e])=>e)}function Gg(){const e=dn();e.entries.clear(),e.nextSeq=0,e.bootstrapped=!1,pc(e)}function Vg(){return{...Ug}}const fc=Symbol.for("worm-print-platform.element-plugin-registry.v1"),hc=globalThis;function ia(){const e=hc[fc];if(e)return e;const t={plugins:new Map,typeIndex:new Map,configs:new Map,legacyAliases:new Map};return hc[fc]=t,t}function Yg(e,t){const n=e.render||t.render?{...e.render,...t.render}:void 0,r=e.designer||t.designer?{...e.designer,...t.designer}:void 0;return{...e,kind:t,binding:t.binding??e.binding,render:n,designer:r}}function $n(e){const t=ia().typeIndex.get(e);return t?Yg(t.plugin,t.kind):void 0}function gc(){return[...ia().typeIndex.values()]}function Kg(){return Object.fromEntries(ia().legacyAliases)}function cr(e){return e/2.83464566929}function uo(e){return e*(25.4/96)}function un(e){return e*(96/25.4)}const mc=6,Xg=1,Zg=["clip","shrink","autoHeight"];function bc(e){return typeof e=="string"&&Zg.includes(e)?e:void 0}const Jg={text:"clip",longText:"autoHeight",flowList:"clip"};function po(e,t){const n=ut(e).defaultTextFit;return bc(t?.textFit)??n??Jg[e]??"clip"}function yc(e){if(e?.keepLineBreaks===!0&&e.wordWrap!==!1)return"pre-wrap"}function vc(e){return e?.wordWrap===!1?"nowrap":void 0}function aa(e){return bc(e?.textFit)??(e?.wordWrap===!1?"clip":"autoHeight")}function dr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?mc:Math.max(e,Xg)}function sa(e){return Math.round(e*100)/100}function Qg(e){return Math.floor(e*100)/100}function em(e,t,n,r){return`${e}#${t}#${n}:${r}`}function tm(e){const t=e.indexOf("#");if(t<0)return;const n=e.lastIndexOf("#"),r=e.slice(t+1,n);if(r!=="b"&&r!=="st"&&r!=="sm")return;const[o,i]=e.slice(n+1).split(":").map(Number);if(!(!Number.isFinite(o)||!Number.isFinite(i)))return{elementId:e.slice(0,t),kind:r,rowIndex:o,colIndex:i}}function wc(e,t){return(e||"contain")==="cover"?t:void 0}function la(e,t,n,r=1){const o=Math.max(n?.colspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]??0;if(i<=0)return 0;const a=n?.padding??r,l=(cr(n?.borders?.left?.width??0)+cr(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function ur(e,t,n,r=1){const o=Math.max(n?.rowspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]?.height??8;const a=n?.padding??r,l=(cr(n?.borders?.top?.width??0)+cr(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const ca=1,xc=12,nm=3,rm=100,om=0,im=50;function pn(e){return e==="dynamic"?"dynamic":"fixed"}function Nn(e){const t=n=>{const r=e[n];return typeof r=="number"&&Number.isFinite(r)&&r>0?r:0};return{top:t("flowPaddingTop"),right:t("flowPaddingRight"),bottom:t("flowPaddingBottom"),left:t("flowPaddingLeft")}}function Ec(e,t){return Math.max(0,e-t.left-t.right)}const Sc=25.4/72;function am(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)))}function pt(e){return am(e,ca,xc,4)}function vt(e){return typeof e!="number"||!Number.isFinite(e)?4:Math.min(im,Math.max(om,e))}function Xt(e){return typeof e!="number"||!Number.isFinite(e)?8:Math.min(rm,Math.max(nm,e))}function fn(e,t){const n=pt(t),r=Math.min(2,n);return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(1,Math.round(e)))}function sm(e,t,n){const r=pt(t),o=vt(n),i=e-o*(r-1);return i<=0?0:i/r}function lm(e,t,n){const r=Math.max(1,Math.floor(n));return e*r+t*(r-1)}function _c(e,t){if(!e)return 0;const n=typeof t=="number"&&Number.isFinite(t)&&t>0?t*Sc:12*Sc;let r=0;for(const o of e){if(o===" "){r+=.28;continue}const i=o.codePointAt(0)??0;i>=12288&&i<=12351||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=131072?r+=1:/^[0-9A-Z]$/.test(o)?r+=.6:/^[a-z]$/.test(o)?r+=.5:/^[\u0020-\u007f]$/.test(o)?r+=.4:r+=.75}return r*n}function cm(e,t){if(!t.autoSpan)return 1;const n=fn(t.maxSpan,t.columns);if(n<=1||t.colUnitMm<=0)return 1;const r=_c(e,t.fontSizePt);for(let o=1;o<=n;o++)if(r<=lm(t.colUnitMm,t.gapX,o))return o;return n}function da(e,t){const n=pt(t.columns),r=vt(t.gapX),o=sm(t.width,n,r),i=fn(t.maxSpan,n),a=[];let l=[],c=0;for(const s of e){const d=String(s??""),p=cm(d,{...t,columns:n,gapX:r,maxSpan:i,colUnitMm:o});l.length>0&&c+p>n&&(a.push({cells:l}),l=[],c=0),l.push({text:d,span:p}),c+=p}return l.length>0&&a.push({cells:l}),a}function fo(e,t){if(typeof e!="string"||!e.includes("{")||!t)return;const n=new Set;for(const r of e.matchAll(/\{([^{}]*)\}/g))for(const o of(r[1]??"").split(/[^A-Za-z0-9_\u4e00-\u9fa5.]/)){const i=o.split(".")[0];i&&!/^\d/.test(i)&&n.add(i)}for(const r of n)if(Array.isArray(t[r]))return r}function dm(e,t,n){const r=vt(t),o=_c("一",n);if(o<=0||e<=0)return ca;const i=Math.floor((e+r)/(o+r));return Math.min(xc,Math.max(ca,i))}const Mc=e=>`${Math.round(e*1e3)/1e3}mm`;function um(e){const t=pt(e.columns),n=vt(e.gapX),r=Xt(e.rowHeight);return["display:grid",`grid-template-columns:repeat(${t},minmax(0,1fr))`,`column-gap:${Mc(n)}`,`grid-auto-rows:minmax(${Mc(r)},auto)`].join(";")}const pr=25.4,Tc=10;function ua(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):Tc}const Zt=30,ho=10,pa=2,kc=0,pm=.25,fa=.254;function fm(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;const t=e/pr;for(let n=2;n<=8;n+=.5){const r=Math.max(1,Math.round(go(n)*t)),o=r/t;if(o>=fa-1e-9)return{barWidth:n,dotsPerModule:r,moduleWidthMm:o}}return null}function Cc(e,t){const n=fm(e);if(!n)return"";const r=s=>String(Number(s.toFixed(3))),o=`按 ${e}dpi 推荐条宽倍率 ${n.barWidth}(每模块 ${n.dotsPerModule} 个打印点 = ${r(n.moduleWidthMm)}mm,取达到 ${r(fa)}mm 下限的最小档)`,i=go(t??2),a=Math.max(1,Math.round(i*e/pr)),l=a/(e/pr),c=l>=fa-1e-9?`当前倍率 ${t??2} 折算为 ${a} 点 / ${r(l)}mm,已达标`:`当前倍率 ${t??2} 只有 ${a} 点 / ${r(l)}mm,低于下限`;return`${o};${c}。这里只提示,不会替你改值`}function fr(e){const t=typeof e=="number"&&Number.isFinite(e)?e:2;return Math.max(1,t/2)}function go(e){return fr(e)*pm}function hm(e){const{barHeightMm:t,moduleWidthMm:n,boxHeightMm:r,textModules:o}=e,i=typeof t=="number"&&Number.isFinite(t)&&t>0,a=typeof n=="number"&&Number.isFinite(n)&&n>0;if(!i||!a)return Zt;const l=Math.max(1,Math.round(t/n));if(!(typeof r=="number"&&Number.isFinite(r)&&r>0))return l;const s=typeof o=="number"&&Number.isFinite(o)&&o>0?o:0,d=Math.floor((r-s*n)/n);return Math.max(1,Math.min(l,d))}function Ac(e,t,n){const r=Math.max(1,Math.round(e*n)),o=Math.floor(t*n);if(o<1)return null;const i=Math.min(r,o);return{dotsPerModule:i,preferredDots:r,moduleWidthMm:i/n}}function gm(e){const t=go(e.barWidth),n=Math.max(1,Math.ceil(e.unitWidth)),r=e.boxWidthMm>0?e.boxWidthMm/n:Number.POSITIVE_INFINITY,o=e.dpi;if(typeof o=="number"&&Number.isFinite(o)&&o>0){const i=Ac(t,r,o/pr);if(i)return i.moduleWidthMm}return Math.min(t,r)}function Ln(e,t){const n=typeof e=="number"&&e>0?e:Number.POSITIVE_INFINITY,r=typeof t=="number"&&t>0?Math.min(n,t):n;return Number.isFinite(r)?r:0}function mm(e){const t=Math.max(1,Math.ceil(e.unitWidth)),n=Math.max(1,Math.ceil(e.unitHeight)),r=go(e.barWidth),o=Math.min(e.boxWidthMm>0?e.boxWidthMm/t:Number.POSITIVE_INFINITY,e.boxHeightMm>0?e.boxHeightMm/n:Number.POSITIVE_INFINITY),i=e.dpi;if(typeof i=="number"&&Number.isFinite(i)&&i>0){const l=Ac(r,o,i/pr);if(l)return{moduleWidthMm:l.moduleWidthMm,widthMm:t*l.moduleWidthMm,heightMm:n*l.moduleWidthMm,dotsPerModule:l.dotsPerModule,scaledDown:l.dotsPerModule<l.preferredDots}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:t*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}function ha(e){const t=fr(e.barWidth),n=c=>mm({unitWidth:c.widthUnits/t,unitHeight:c.heightUnits/t,boxWidthMm:e.boxWidthMm,boxHeightMm:e.boxHeightMm,dpi:e.dpi,barWidth:e.barWidth}),r=e.measure(Zt);if(!r)return{barHeightModules:Zt,size:null};if(!(typeof e.barHeightMm=="number"&&Number.isFinite(e.barHeightMm)&&e.barHeightMm>0))return{barHeightModules:Zt,size:n(r)};const i=Math.max(0,r.heightUnits/t-Zt),a=hm({barHeightMm:e.barHeightMm,moduleWidthMm:gm({unitWidth:r.widthUnits/t,boxWidthMm:e.boxWidthMm,dpi:e.dpi,barWidth:e.barWidth}),boxHeightMm:e.boxHeightMm,textModules:i});if(a===Zt)return{barHeightModules:a,size:n(r)};const l=e.measure(a);return l?{barHeightModules:a,size:n(l)}:{barHeightModules:Zt,size:null}}const hr=["top","right","bottom","left"],bm=new Set(["rect","oval","hline","vline","table"]);function mo(e){if(!e)return!1;const t=ut(e).acceptsElementBorder;return t===void 0?!bm.has(e):t}const ym=new Set(["solid","dashed","dotted","double"]);function Oc(e,t,n){return typeof e!="number"||!Number.isFinite(e)||e<=0||t==="none"?null:{borderWidth:`${e}pt`,borderStyle:typeof t=="string"&&ym.has(t)?t:"solid",borderColor:n||"#000"}}function bo(e,t){if(!mo(e))return null;const n=Oc(t?.borderWidth,t?.borderStyle,t?.borderColor),r={},o=t?.borders;if(o)for(const i of hr){const a=o[i];if(!a)continue;const l=Oc(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const vm=/[;"'<>\\(){}\[\]@!#]/,wm=64,gr=100,Ic=400;function xm(e){const t=(e??"").trim();return!t||t.length>wm||vm.test(t)?"":t}function Pc(e,t){if((e||"contain")!=="cover"||typeof t!="number"||!Number.isFinite(t))return;const n=Math.round(t);if(!(n<=gr))return Math.min(n,Ic)}function ga(e,t,n){const r=xm(n),o={};r&&(o.objectPosition=r);const i=Pc(e,t);return i!==void 0&&(o.transform=`scale(${Number((i/100).toFixed(2))})`,o.transformOrigin=r||"50% 50%"),o}function mr(e){return typeof e!="number"||!Number.isFinite(e)?0:(e%360+360)%360}function Rc(e,t,n){const r=e.width,o=t,i=mr(n);let a,l;if(i===0||i===180)a=r,l=o;else if(i===90||i===270)a=o,l=r;else{const c=i*Math.PI/180;a=r*Math.abs(Math.cos(c))+o*Math.abs(Math.sin(c)),l=r*Math.abs(Math.sin(c))+o*Math.abs(Math.cos(c))}return{left:e.left-(a-r)/2,top:e.top-(l-o)/2,width:a,height:l}}const Dc=385,Em=new Set(["table","flowList"]);function $c(e){const t=ut(e).rotationExcluded;return t===void 0?Em.has(e):t}function Nc(e){const t=ut(e).codeRotationDpiGated;return t===void 0?e==="barcode"||e==="qrcode":t}const Sm="条码与二维码仅支持 90° 步进;任意角度需 385dpi 以上打印头";function _m(e,t){if(!Nc(e))return!0;const n=t?.printerDpi;return typeof n=="number"&&n>0&&n>=Dc}function ma(e,t,n){const r=t?.rotate;if(typeof r!="number"||!Number.isFinite(r))return;const o=mr(r);if(o!==0&&!$c(e)){if(Nc(e)){if(o===90||o===180||o===270)return o;const i=t?.printerDpi;if(typeof i=="number"&&i>0&&i<Dc){const a=mr(Math.round(o/90)*90);return a===0?void 0:a}}return o}}const yo=e=>typeof e=="number"&&Number.isFinite(e)?e:0;function ft(e){const t=e??{};return{top:yo(t.marginTop),right:yo(t.marginRight),bottom:yo(t.marginBottom),left:yo(t.marginLeft)}}function vo(e){const t=ft(e);return["top","right","bottom","left"].filter(n=>t[n]!==0).map(n=>`margin-${n}:${t[n]}mm`).join(";")}function We(e={},t=e.height??0){const n=ft(e),r=e.left??0,o=e.top??0,i=e.width??100,a=t,l={left:r+n.left,top:o+n.top,right:r+n.left+i,bottom:o+n.top+a,width:i,height:a},c={left:r,top:o,right:r+n.left+i+n.right,bottom:o+n.top+a+n.bottom,width:Math.max(0,n.left+i+n.right),height:Math.max(0,n.top+a+n.bottom)};return{border:l,margin:c}}const hn={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}},Mm=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function Fn(e){return Mm.has(e)}function ht(e){const t=Fn(e.paperSize),n=e.paperSize==="CUSTOM"||t?{width:e.customWidth??hn[e.paperSize].width,height:e.customHeight??hn[e.paperSize].height}:hn[e.paperSize];return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:{...n}}function gn(e){if(Fn(e.paperSize))return ht(e);const n=ht(e);return e.outputRotation===90||e.outputRotation===270?{width:n.height,height:n.width}:n}function ba(e){return Fn(e.paperSize)?0:e.outputRotation??0}function At(e){return Fn(e.paperSize)}function wo(e){return e.options?.pagination??e.pagination}function Tm(e){return e.options?.tablePagination??e.tablePagination}const km=2;function xo(e){return e.type==="table"||e.printElementType?.type==="table"}function br(e){return(e.type||e.printElementType?.type||"text")==="flowList"&&pn(e.options?.flowLayoutMode)==="dynamic"}function ya(e){return xo(e)||br(e)}function Eo(e){return e.options?.fixed!==!0&&e.options?.repeatOnEveryPage===!0}function va(e){return e.options?.fixed===!0}function Lc(e){return e.type||e.printElementType?.type||"text"}function Fc(e){return ma(Lc(e),e.options)}function mn(e,t){const n=t.get(e.id)?.measuredHeight??e.options?.height??0,r=ft(e.options),{border:o}=We({left:e.options?.left??0,top:e.options?.top??0,width:e.options?.width??100,height:n,...e.options},n),i=Fc(e),a=i===void 0?o:Rc(o,n,i);return{height:a.height,shift:o.top-a.top,top:a.top,rot:i,outerTop:a.top-r.top,outerBottom:a.top+a.height+r.bottom,outerHeight:Math.max(0,r.top+a.height+r.bottom)}}function Cm(e,t){const n=e.options?.tableColWidths??[],r=xo(e)&&n.length>0?n.reduce((c,s)=>c+s,0):e.options?.width??0,o=t.get(e.id)?.measuredHeight??e.options?.height??0,{border:i}=We({...e.options,left:e.options?.left??0,top:e.options?.top??0,width:r,height:o},o),a=Fc(e);if(a===void 0)return{left:i.left,width:i.width};const l=Rc(i,o,a);return{left:l.left,width:l.width}}function Am(e){const t=e.options??{},n=t.top??0,o=(t.tableRows??[]).reduce((a,l)=>a+(l.height??0),0),i=Math.max(t.height??0,o);return n+ft(t).top+i}function yr(e){if(br(e)){const t=e.options??{};return(t.top??0)+ft(t).top+Math.max(t.height??0,0)}return Am(e)}function zc(e){return(t,n)=>{const r=t.options?.top??0,o=n.options?.top??0;if(r!==o)return r-o;const i=t.options?.zIndex??0,a=n.options?.zIndex??0;return i!==a?i-a:(e.get(t.id)??0)-(e.get(n.id)??0)}}function Bc(e){const n=e.filter(l=>typeof l.id=="string").map(l=>l).filter(l=>!Eo(l)&&!va(l)),r=new Map;n.forEach((l,c)=>r.set(l.id,c));const o=[...n].sort(zc(r)),i=new Set;for(const l of o)ya(l)||l.options?.groupId&&i.add(l.id);const a=new Set;for(const l of Hc(o,i).values())for(const c of l)a.add(c);return a}function Hc(e,t){const n=new Map;let r=null,o=-1,i=0,a=0;for(const l of e){if(ya(l)){r=l.id,o=yr(l)+ft(l.options).bottom;const d=l.options?.tableColWidths??[],p=d.length>0?d.reduce((f,g)=>f+g,0):l.options?.width??0,u=We({...l.options,width:p}).margin;i=u.left,a=u.right,n.set(l.id,[]);continue}if(t?.has(l.id)||!r||(l.options?.top??0)<o)continue;const s=We({width:0,...l.options}).margin;s.right<=i||s.left>=a||n.get(r).push(l.id)}return n}function wa(e,t,n,r){const o=yr(e)+ft(e.options).bottom;let i=o;for(const a of t){const l=n.elements.find(c=>c.id===a);l&&(i=Math.max(i,We({width:0,...l.options}).margin.bottom))}return Math.max(i-o,0)}function Uc(e,t){return Math.max(e.options?.height??0,t.get(e.id)?.measuredHeight??0)}const qc=25.4/72;function Wc(e){const t=e.options??{};if((e.type||e.printElementType?.type||"text")!=="vline")return{width:100,...t};const o=(t.borderWidth??.75)*qc/2+.05;return{...t,left:(t.left??0)-o,width:o*2}}function bn(e){const t=We(Wc(e)).margin;return[t.left,t.right]}function Om(e){const t=We(Wc(e)).border;return[t.left,t.right]}function vr(e,t){return e[0]<t[1]&&t[0]<e[1]}function jc(e,t){return[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function Im(e,t,n){const r=new Map;for(const f of n.values()){if(f.length<2)continue;const g={anchorId:f[0].id,ids:f.map(m=>m.id),forceFirstPage:f.some(m=>wo(m)?.pageable===!1),band:f.map(bn).reduce(jc)};for(const m of f)r.set(m.id,g)}const o=e.filter(f=>!xo(f)&&!br(f)&&!f.options?.groupId&&wo(f)?.pageable!==!1),i=new Map;o.forEach(f=>i.set(f.id,f.id));const a=f=>{let g=f;for(;i.get(g)!==g;)g=i.get(g);let m=f;for(;i.get(m)!==g;){const b=i.get(m);i.set(m,g),m=b}return g},l=(f,g)=>{const m=a(f),b=a(g);m!==b&&i.set(b,m)},c=[],s=f=>We({width:100,...f.options,height:Uc(f,t)},Uc(f,t)).border,d=[...o].sort((f,g)=>s(f).top-s(g).top);for(const f of d){const g=s(f),m=g.top;for(let w=c.length-1;w>=0;w--)c[w].bottom<=m&&c.splice(w,1);const b=g.bottom,v=Om(f);for(const w of c)w.bottom>m&&vr(w.x,v)&&l(f.id,w.id);c.push({id:f.id,top:m,bottom:b,x:v})}const p=new Map(o.map(f=>[f.id,f])),u=new Map;for(const f of o){const g=a(f.id),m=u.get(g);m?m.push(f.id):u.set(g,[f.id])}for(const f of u.values()){if(f.length<2)continue;const g={anchorId:f[0],ids:f,forceFirstPage:!1,band:f.map(m=>bn(p.get(m))).reduce(jc)};for(const m of f)r.set(m,g)}return r}function xa(e,t){const n=ht(e),{top:r,bottom:o}=e.margins,i=e.header?.height??0,a=e.footer?.height??0,l=At(e),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;e.elements.forEach((M,H)=>s.set(M.id,H));const d=[...e.elements].sort(zc(s)),p=d.filter(Eo),u=d.filter(va),f=d.filter(M=>!Eo(M)&&!va(M)),g=p.reduce((M,H)=>{const B=mn(H,t);return{minTop:Math.min(M.minTop,B.outerTop),maxBottom:Math.max(M.maxBottom,B.outerBottom)}},{minTop:Number.POSITIVE_INFINITY,maxBottom:Number.NEGATIVE_INFINITY}),m=!l&&p.length>0,b=m?g.minTop:0,v=m?Math.max(0,g.maxBottom-b):0,w=new Set,E=new Map;for(const M of f){if(ya(M))continue;const H=M.options?.groupId;if(!H)continue;w.add(M.id);const B=E.get(H);B?B.push(M):E.set(H,[M])}const k=Hc(f,w),L=new Map;for(const[M,H]of k)for(const B of H)L.set(B,M);const R=new Set,P=M=>{for(const H of M)R.add(H)},O=new Map;for(const M of d)O.set(M.id,M);const C=Im(f,t,E),I=[];let S=[],$=[],N=[],z=!1;function T(){return c-km-(z?v:0)}function ie(M){let H=0;for(const B of $)vr(M,[B.x0,B.x1])&&(H+=B.height);return Math.max(0,H)}function pe(M,H,B){N.push({x0:M[0],x1:M[1],renderBottom:H,designBottom:B})}function Ge(M){let H;for(const B of N)vr(M,[B.x0,B.x1])&&(!H||B.renderBottom>=H.renderBottom)&&(H=B);return H}function Q(M,H){const B=M.options?.top??0;if(z)return{top:ne(H),extra:0};const q=Ge(H);if(!q||q.renderBottom<=B)return{top:B,extra:0};const U=Math.max(B,q.renderBottom+B-q.designBottom);return{top:U,extra:Math.max(0,U-q.renderBottom)}}function Te(M){return T()-ie(M)}function he(M){const H=$.filter(B=>vr(M,[B.x0,B.x1]));for(let B=0;B<H.length;B++)for(let q=B+1;q<H.length;q++)if(!vr([H[B].x0,H[B].x1],[H[q].x0,H[q].x1]))return!0;return!1}function de(M,H){$.push({x0:M[0],x1:M[1],height:H})}function ye(M,H=bn(M)){return z?ne(H):M.options?.top??0}function ne(M){return(z?v:0)+ie(M)}let De=!1,it=[];function te(M,H,B){B<=0||it.push(`元素 ${M.id} 旋转 ${H}° 后顶部超出页首 ${Math.round(B*100)/100}mm,打印将被裁切`)}function Ve(){I.push(De||it.length>0?{pageIndex:I.length,sections:[...S],...De?{overflow:!0}:{},...it.length>0?{warnings:[...it]}:{}}:{pageIndex:I.length,sections:[...S]})}function $e(M){M>c&&(De=!0)}function fe(M=!1){if(S.length===0){De=De||M;return}Ve(),S=[],$=[],N=[],z=!0,De=!1,it=[]}let me=0;for(;me<f.length;){const M=f[me];if(L.has(M.id)&&R.has(M.id)){me++;continue}const H=C.get(M.id);if(H&&H.anchorId!==M.id){me++;continue}if(wo(M)?.pageable===!1||H?.forceFirstPage){const B=I[0],q=B?.sections??S,U=(V,ee,_)=>{B?_>0&&(B.warnings=[...B.warnings??[],`元素 ${V.id} 旋转 ${ee}° 后顶部超出页首 ${Math.round(_*100)/100}mm,打印将被裁切`]):te(V,ee,_)};if(H){let V=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,_=Number.NEGATIVE_INFINITY,G;for(const K of H.ids){const Z=O.get(K);if(!Z)continue;const oe=mn(Z,t);V=Math.min(V,oe.top),ee=Math.max(ee,oe.outerBottom),_=Math.max(_,We({width:0,...Z.options}).margin.bottom),oe.rot!==void 0&&(G={el:Z,rot:oe.rot})}G&&U(G.el,G.rot,-V);for(const K of H.ids)q.push({elementId:K,type:"element",renderTop:O.get(K)?.options?.top??0});!B&&_>Number.NEGATIVE_INFINITY&&pe(H.band,Math.max(ee,0),_)}else{const V=mn(M,t),ee=We({width:0,...M.options}).margin.bottom;B||pe(bn(M),V.outerBottom,ee),V.rot!==void 0&&U(M,V.rot,-V.top),q.push({elementId:M.id,type:"element",renderTop:M.options?.top??0})}me++;continue}xo(M)?me=nr(M,t,me):br(M)?me=ge(M,t,me):H?me=ro(H,me):me=no(M,t,f,me)}S.length>0&&Ve(),I.length===0&&I.push({pageIndex:0,sections:[]});const tr=new Map(d.map((M,H)=>[M.id,H]));for(const M of I){const H=M.pageIndex>0?-b:0,B=p.map(U=>({elementId:U.id,type:"element",renderTop:(U.options?.top??0)+H})),q=u.map(U=>({elementId:U.id,type:"element",renderTop:U.options?.top??0}));M.sections=[...M.sections,...B,...q].sort((U,V)=>(tr.get(U.elementId)??Number.MAX_SAFE_INTEGER)-(tr.get(V.elementId)??Number.MAX_SAFE_INTEGER));for(const U of[...p,...u]){const V=mn(U,t),ee=Eo(U)?H:0;if(V.outerBottom+ee>c&&(M.overflow=!0),V.rot!==void 0&&V.top+ee<0){const _=Math.round(-(V.top+ee)*100)/100;M.warnings=[...M.warnings??[],`元素 ${U.id} 旋转 ${V.rot}° 后顶部超出页首 ${_}mm,打印将被裁切`]}}}return to(),I;function to(){if(l)return;const M=e.margins.left;for(const H of I){const B=[];for(const q of H.sections){if(q.type==="flow-group")continue;const U=O.get(q.elementId);if(!U)continue;const{left:V,width:ee}=Cm(U,t),_=M+V,G=_+ee-n.width,K=-_;G>.01?B.push(`元素 ${U.id} 超出纸面右侧 ${Math.round(G*100)/100}mm,打印将被裁切`):K>.01&&B.push(`元素 ${U.id} 超出纸面左侧 ${Math.round(K*100)/100}mm,打印将被裁切`)}B.length>0&&(H.warnings=[...H.warnings??[],...B])}}function no(M,H,B,q){const U=bn(M),V=mn(M,H),ee=V.outerHeight,_=()=>{const K=ye(M,U),Z=z?K+V.shift:K,oe=Z-(M.options?.top??0);$e(V.outerBottom+oe),V.rot!==void 0&&!z&&te(M,V.rot,-V.top),S.push({elementId:M.id,type:"element",renderTop:Z}),de(U,ee),pe(U,Z+V.outerHeight,We({width:0,...M.options}).margin.bottom)};if(!z&&V.outerBottom<=c&&he(U)||ee<=Te(U)){if(_(),wo(M)?.keepWithNext&&q+1<B.length){const K=B[q+1],Z=mn(K,H).outerHeight;if(ee+Z>T())return q+1;Z>Te(U)&&(S.pop(),$.pop(),fe(),_())}return q+1}return fe(),_(),q+1}function ro(M,H){const B=M.ids.map(oe=>O.get(oe)).filter(oe=>!!oe);let q=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,V=Number.NEGATIVE_INFINITY,ee;for(const oe of B){const be=mn(oe,t);q=Math.min(q,be.outerTop),U=Math.max(U,be.outerBottom),V=Math.max(V,We({width:0,...oe.options}).margin.bottom),be.rot!==void 0&&(ee={el:oe,rot:be.rot})}const _=Math.max(U-q,0),G=M.band,K=()=>{const oe=z?ne(G)-q:0;$e(q+oe+_),ee&&!z&&te(ee.el,ee.rot,-q);for(const be of B)S.push({elementId:be.id,type:"element",renderTop:(be.options?.top??0)+oe});de(G,_),pe(G,q+oe+_,V)};if(_<=Te(G))return K(),H+1;const Z=ne(G)+(z?0:q);return fe(Z+_>c),K(),H+1}function nr(M,H,B){const q=M.options??{},U=q._renderRows??[],V=H.get(M.id)?.measuredRowHeights??[],ee=(q._subtotalTemplates?.length??0)>0,_=(q._summaryRows?.length??0)>0,G=ee?Gc(U,V,"subtotal"):0,K=_?Gc(U,V,"summary"):0,Z=ae=>ee&&ae.type==="subtotal"||_&&ae.type==="summary",oe=U.filter(ae=>!Z(ae)),be=V.filter((ae,ue)=>!Z(U[ue]));q._renderRows=oe;const ke=Math.min(oe.length,be.length),Ue=q._repeatHeaderCount??0,Je=H.get(M.id)?.repeatHeaderHeight??V.slice(0,Ue).reduce((ae,ue)=>ae+ue,0),Ne=T(),at=ft(q),ve=at.top+at.bottom,xe=bn(M),{top:Tt,extra:Pn}=Q(M,xe);!z&&Pn>0&&de(xe,Pn);let st=Tt,Ee=0;const Ft=()=>{Mt(M,H,xe);const ae=k.get(M.id)??[],ue=ae.length>0?wa(M,ae,e):0,lt=yr(M)+ft(q).bottom,ct=S[S.length-1],oo=ct?.type==="flow-group"&&ct.elementId===M.id,Fl=oo?ct.groupTop??q.top??0:st,zl=oo&&(ct.startRow??0)===(ct.endRow??0)&&!(ct.subtotal||ct.summary)?0:Ee;return pe(xe,Fl+zl+ue,lt+ue),B+1};if(Je>Ne)throw new Error(`表格 ${M.id} 的重复表头高度 (${Je.toFixed(1)}mm) 超过页面可用高度 (${Ne.toFixed(1)}mm),请减少重复表头行`);if(ke===0)return S.push({elementId:M.id,type:"table-slice",startRow:0,endRow:0,summary:K>0,renderTop:Tt}),st=Tt,Ee=Math.max(0,K),de(xe,Math.max(0,K+ve)),Ft();const bt=be.slice(0,ke).reduce((ae,ue)=>ae+ue,0),Ye=Math.max(0,bt+G+K+ve);if(Tm(M)?.enabled===!1){Ye>Te(xe)&&S.length>0&&fe();const ae=z?ye(M,xe):Tt;return S.push({elementId:M.id,type:"table-slice",startRow:0,endRow:ke,subtotal:G>0,summary:K>0,renderTop:ae}),st=ae,Ee=Math.max(0,Ye),de(xe,Ye),Ft()}const yt=Pm(oe,ke);let Vt=0,sn=!0,Pe=Tt,Le=ve;const Rn=()=>Te(xe)-Le,Dn=(ae,ue)=>{S.push({elementId:M.id,type:"table-slice",startRow:Vt,endRow:ae,subtotal:G>0,...!sn&&ue?{repeatHeader:!0}:{},renderTop:Pe}),de(xe,Math.max(0,Le)),st=Pe,Ee=Math.max(0,Le),Le=0};for(const ae of yt){const ue=be.slice(ae.start,ae.end).reduce((lt,ct)=>lt+ct,0);if(ue+G<=Rn()){Le+=ue;continue}ae.start>Vt&&(Dn(ae.start,Ue>0),sn=!1,Vt=ae.start),fe(),Pe=ye(M,xe),Le=ve,sn||(Le+=Je),Le+=ue}if(Vt<ke&&Dn(ke,Ue>0),K>0)if(K<=Rn()){const ae=S.length-1,ue=S[ae];if(ue&&ue.type==="table-slice"&&ue.elementId===M.id)S[ae]={...ue,summary:!0},de(xe,K),Ee+=K;else{fe();const lt=ye(M,xe);S.push({elementId:M.id,type:"table-slice",startRow:ke,endRow:ke,summary:!0,renderTop:lt}),st=lt,Ee=Math.max(0,K+ve),de(xe,Math.max(0,K+ve))}}else{fe();const ae=ye(M,xe);S.push({elementId:M.id,type:"table-slice",startRow:ke,endRow:ke,summary:!0,renderTop:ae}),st=ae,Ee=Math.max(0,K+ve),de(xe,Math.max(0,K+ve))}return Ft()}function ge(M,H,B){const q=M.options??{},U=H.get(M.id)?.measuredFlowRowHeights??[],ee=(Array.isArray(q._flowRows)?q._flowRows:[]).length,_=Xt(q.flowRowHeight);if(ee===0)return B+1;const G=Nn(q),K=bo(Lc(M),q),Z=Pe=>{if(!Pe)return 0;const Le=Number.parseFloat(Pe.borderWidth);return Number.isFinite(Le)?Le*qc:0},oe=Pe=>{const Le=K?.edges?.[Pe];return Z(Le||(K?.all??void 0))},be=ft(q),ke=be.top+be.bottom+G.top+G.bottom+oe("top")+oe("bottom"),Ue=bn(M);let Je=0,Ne=Q(M,Ue).top,at=z?0:Ne,ve=0,xe=Ne,Tt=0;const Pn=()=>(z?Te(Ue):T()-at)-ve-ke,st=Pe=>{S.push({elementId:M.id,type:"flow-list-slice",startFlowRow:Je,endFlowRow:Pe,renderTop:Ne});const Le=z?Ne:ie(Ue),Rn=Ne+ke+ve;de(Ue,Math.max(0,Rn-Le)),xe=Ne,Tt=ke+ve,ve=0};let Ee=0;for(;Ee<ee;){const Pe=U[Ee]??_;if(Pe<=Pn()){ve+=Pe,Ee++;continue}if(Pe+ke>T()){Ee>Je&&(st(Ee),Je=Ee),S.length>0&&fe(),Ne=ye(M,Ue),at=z?0:Ne,ve=Pe,$e(Ne+ke+ve),Ee++;continue}if(S.length===0&&ve===0&&!z){ve+=Pe,$e(Ne+ke+ve),Ee++;continue}Ee>Je&&(st(Ee),Je=Ee),fe(),Ne=ye(M,Ue),at=z?0:Ne}Je<ee&&st(ee),Mt(M,H,Ue);const Ft=k.get(M.id)??[],bt=Ft.length>0?wa(M,Ft,e):0,Ye=S[S.length-1],yt=Ye?.type==="flow-group"&&Ye.elementId===M.id,Vt=yt?Ye.groupTop??q.top??0:xe,sn=yt&&(Ye.startFlowRow??0)===(Ye.endFlowRow??0)?0:Tt;return pe(Ue,Vt+sn+bt,yr(M)+be.bottom+bt),B+1}function Mt(M,H,B){const q=k.get(M.id)??[];if(q.length===0)return;const U=wa(M,q,e),V=M.options??{};if(U<=Te(B)){const ee=S.length-1,_=S[ee];if(_&&(_.type==="table-slice"||_.type==="flow-list-slice")&&_.elementId===M.id){S[ee]={..._,type:"flow-group",followElementIds:q,groupTop:_.renderTop??V.top??0},de(B,U),P(q);return}}fe(),S.push({elementId:M.id,type:"flow-group",startRow:0,endRow:0,...br(M)?{startFlowRow:0,endFlowRow:0}:{},followElementIds:q,groupTop:ye(M,B)}),de(B,U),P(q)}}function Pm(e,t){const n=[];let r=0,o=1;for(let i=0;i<t;i++){for(const a of e[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 Gc(e,t,n){let r=0;for(let o=0;o<e.length;o++)e[o]?.type===n&&(r+=t[o]??0);return r}const So=25,Vc=5;function Rm(e){return Math.max(So,e)}function Yc(e,t,n=1.1){const r=t>0?e*n:e/n;return Rm(Math.round(r))}function Dm(e,t,n,r,o=.9){if(n<=0||r<=0)return 100;const i=Math.min(e/n,t/r)*o,a=Math.round(i*100);return Math.max(Vc,a)}const $m=2;function Kc(e){const t=e.gap??$m,n=[...e.units].sort((i,a)=>i.order-a.order);if(e.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 e.pinned+a.reduce((c,s)=>c+s.width+t,0)+(i.size>0?e.moreTriggerWidth+t:0)<=e.available};if(r(new Set))return{movedIds:[],overflowRemains:!1};const o=new Set;for(const i of n)if(o.add(i.id),r(o))return{movedIds:[...o],overflowRemains:!1};return{movedIds:[...o],overflowRemains:!0}}function Nm(e){const t=e.gap??4,n=e.boundaryBottom-e.triggerBottom-t,r=e.triggerTop-e.boundaryTop-t;return n>=e.overlayHeight?"down":r>n?"up":"down"}function Lm(){return oa().filter(e=>ut(e).blocked===!0)}Lm();function Fm(e){if(!e)return!1;const t=ut(e).blocked;return t===void 0?lr[e]?.blocked===!0:t}function zn(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ea(e){const t=Vg(),n=ut(e).defaultOptions?.();if(n)return{...t,...n};const r=$n(e)?.kind.defaultOptions?.();return r?{...t,...r}:t}function Sa(e,t){return{id:zn(),options:{...Ea(e),...t},printElementType:{type:e,title:ut(e).title||$n(e)?.kind.label||String(e)}}}const zm=["left","top","width","height","marginTop","marginRight","marginBottom","marginLeft"];function Bm(e){return e.type??e.printElementType?.type}function Hm(e){const t=n=>(n??[]).filter(r=>!Fm(Bm(r)));return{...e,elements:t(e.elements),header:e.header?{...e.header,elements:t(e.header.elements)}:e.header,footer:e.footer?{...e.footer,elements:t(e.footer.elements)}:e.footer}}function Um(e){const t={...e.options};for(const n of zm){const r=t[n];typeof r=="number"&&Number.isFinite(r)&&(t[n]=qm(cr(r)))}return{...e,options:t}}function qm(e){return Math.round(e*100)/100}function Wm(e){const t={...e};delete t.firstPageOverlay;const n=Hm(t);if(n.unit==="mm")return n;const r=n,o=i=>i?.map(Um)??[];return{...r,unit:"mm",elements:o(r.elements),header:r.header?{...r.header,elements:o(r.header.elements)}:r.header,footer:r.footer?{...r.footer,elements:o(r.footer.elements)}:r.footer}}const _a="标签纸",Ot={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:_a},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:_a},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:_a},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(e){return!!e&&Ot[e]?.continuous===!0}function Jt(e){const t=_o(e.paperSize);let n;if(e.paperSize==="CUSTOM"||t){const r=Ot[e.paperSize];n={width:e.customWidth??r?.width??210,height:e.customHeight??r?.height??297}}else{const r=Ot[e.paperSize]||Ot.A4;n={width:r.width,height:r.height}}return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:n}const Ma=.75,jm="线型 / 宽度 / 颜色即时生效,这三行显示的就是当前生效规格:已有边框时任改一行都会按新规格铺满四边并清掉单边覆盖;上、下、左、右只给选中的边加框,撤掉一边会把它其余三边落成单边;「无」清除边框,「内部」仅表格单元格可用",wr=["top","right","bottom","left"];function Xc(e){const t={};for(const n of wr){const r=e.map(o=>!!o?.[n]);t[n]=r.length>0&&r.every(Boolean)?"on":r.some(Boolean)?"mixed":"off"}return t}const Ta=[{value:"none",label:"无"},{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],Gm=new Set(["solid","dashed","dotted","double"]),Bn="none";function xr(e,t){const n=e.borders?.[t];if(n&&n.style!==Bn&&typeof n.width=="number"&&Number.isFinite(n.width)&&n.width>0)return!0;const r=e.borderWidth;return e.borderStyle!==Bn&&typeof r=="number"&&Number.isFinite(r)&&r>0}function Vm(e){const t={};for(const n of wr)xr(e,n)&&(t[n]=e.borders?.[n]??{width:e.borderWidth});return t}function Ym(e){const t=e.borderWidth;return{width:typeof t=="number"&&Number.isFinite(t)&&t>0?t:Ma,style:e.borderStyle||"solid",color:e.borderColor||"#333333"}}function Zc(e,t,n){if(t!=="inner"){if(e.borders=void 0,t==="none"){e.borderWidth=0;return}e.borderWidth=n.width,e.borderStyle=n.style,e.borderColor=n.color}}function Jc(e){return wr.some(t=>xr(e,t))}function ka(e,t){if(!e.length)return;const n=e[0]?.[t];return e.every(r=>r[t]===n)?n:"mixed"}function Km(e){if(!e)return;const t=typeof e.style=="string"&&Gm.has(e.style)?e.style:"solid";return{width:e.width,style:e.style===void 0?void 0:t,color:e.color}}function Xm(e){const t=wr.map(r=>e.borders?.[r]).filter(r=>typeof r?.width=="number"&&Number.isFinite(r.width)&&r.width>0).map(r=>Km(r));if(!t.length)return;const n=ka(t,"style");return{width:ka(t,"width"),style:n===void 0?"solid":n,color:ka(t,"color")}}function Qc(e){const t=e.borderWidth,n=typeof t=="number"&&Number.isFinite(t),r=Xm(e),o=n&&t>0;if(r&&!o)return r;const i=o?e.borderStyle||"solid":Bn;return n?{width:t,style:i,color:e.borderColor}:{width:void 0,style:i,color:void 0}}function ed(e){const t=Qc(e);return{width:typeof t.width=="number"&&t.width>0?t.width:Ma,style:typeof t.style=="string"&&t.style!==Bn?t.style:"solid",color:typeof t.color=="string"?t.color:"#333333"}}function Zm(e,t){e.borderWidth=t.width,e.borderStyle=t.style,e.borderColor=t.color,e.borders=void 0}function Jm(e,t,n){if(t==="borderStyle"&&n===Bn){const r=Jc(e);e.borderStyle=Bn,r&&(e.borderWidth=0,e.borders=void 0);return}if(!Jc(e)){if(t==="borderStyle"){e.borderStyle=n,e.borderWidth=Ma;return}Object.assign(e,{[t]:n});return}if(t==="borderWidth"&&(typeof n!="number"||!(n>0))){e.borderWidth=typeof n=="number"&&n<0?0:n,e.borders=void 0;return}Zm(e,Ym({...e,[t]:n}))}function Ca(e,t,n,r){if(n!==xr(e,t)){if(!n){const o=e.borderWidth;if(typeof o!="number"||!(o>0)){td(e,t,null);return}const i={};for(const a of wr){if(a===t)continue;const l=e.borders?.[a];i[a]={width:l?.width??o,...l?.style!==void 0?{style:l.style}:e.borderStyle!==void 0?{style:e.borderStyle}:{},...l?.color!==void 0?{color:l.color}:e.borderColor!==void 0?{color:e.borderColor}:{}}}e.borders=i,e.borderWidth=0;return}td(e,t,r??ed(e))}}function td(e,t,n){const r={...e.borders??{}};n?r[t]={width:n.width,style:n.style,color:n.color}:delete r[t],e.borders=r}const nd=96/25.4,rd=1,Qm=8,e0=210;function Aa(e,t){if(!e||typeof e!="object")return;if(Array.isArray(e)){for(const r of e)Aa(r,t);return}const n=e;typeof n.printerDpi=="number"&&n.printerDpi>0&&t.add(n.printerDpi);for(const r of Object.keys(n)){if(r==="printerDpi")continue;const o=n[r];o&&typeof o=="object"&&Aa(o,t)}}function t0(e){if(!e)return null;const t=new Set;return Aa(e,t),t.size?Math.max(...t):null}function n0(e){if(!e)return e0*nd;const t=e.pages?.length?e.pages:[e];return Math.max(...t.map(n=>{const r=Jt(n);return((n.outputRotation===90||n.outputRotation===270)&&!_o(n.paperSize)?r.height:r.width)*nd}))}function r0(e,t){return e<=0||t<=0?rd:Math.min(Qm,Math.max(rd,Math.floor(e/t)))}function o0(e,t,n){const r=[];return e&&r.push({key:"dots",value:e/96,label:`点阵 ${e}dpi`,tip:`1 屏幕像素 = 1 个打印点(${e}dpi ÷ 96dpi)。条与间隙按纸面逐点显示,不会在屏幕上糊成一片`}),r.push({key:"fit",value:r0(t,n),label:"适配",tip:"按容器宽放大到放得下整页的最大整数倍"},{key:"100",value:1,label:"100%",tip:"按 CSS 真实尺寸显示(1mm = 3.78 屏幕像素),热敏点距在此档不可分辨"},{key:"200",value:2,label:"200%",tip:"整数倍放大,避免非整数缩放带来的半像素边"},{key:"400",value:4,label:"400%",tip:"整数倍放大,避免非整数缩放带来的半像素边"}),r}function od(e){return"100"}function i0(e,t){return!e||t==="dots"?"":`条码看不清?切「点阵 ${e}dpi」档(1 屏幕像素 = 1 打印点)`}const id="print-preview-zoom-guard";function a0(e,t){if(!e?.documentElement)return;let n=e.getElementById(id);n||(n=e.createElement("style"),n.id=id,(e.head??e.documentElement).appendChild(n)),n.textContent=`html{zoom:${t}}@media print{html{zoom:1 !important}}`}function s0(e,t,n){return e.some(r=>r.key===t)?t:od()}function l0(e,t){return e.find(n=>n.key===t)?.value??1}function c0(){return oa().filter(e=>ut(e).zoneAllowed===!0)}c0();function ad(e){return ut(e).zoneAllowed===!0}function d0(e){return Jt(e)}function Oa(e){const t=d0(e),n=e.margins,r=e.header.height,o=e.footer.height,i=t.width-n.left-n.right,a=t.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,t.height-n.bottom-o,i,o)}}function sd(e,t,n){const r=Oa(e);return r.footer.height>0&&n>=r.footer.top?"footer":r.header.height>0&&n<r.header.top+r.header.height?"header":"content"}function Ia(e,t){const n=e.options;n.width=Math.min(n.width,t.width),n.height=Math.min(n.height,t.height),n.left=Math.min(Math.max(0,n.left),t.width-n.width),n.top=Math.min(Math.max(0,n.top),t.height-n.height)}function u0(e,t){const n=Oa(t),r=e.zone||"content",o=n[r],i=o.left+e.options.left+e.options.width/2,a=o.top+e.options.top+e.options.height/2;let l=sd(t,i,a),c=!1;if(l!=="content"&&!ad(e.printElementType.type)&&(l="content",c=!0),l!==r){const s=n[l];e.options.left=o.left+e.options.left-s.left,e.options.top=o.top+e.options.top-s.top,e.zone=l}return l!=="content"?Ia(e,n[l]):c&&Ia(e,n.content),{rejected:c}}const Pa=22,Ra=[1,2,5,10,20,50,100,200,500,1e3];function p0(e,t=64){const n=e*3.7795275590551185;for(const r of Ra)if(r*n>=t)return r;return Ra[Ra.length-1]}function f0(e){const t=Math.floor(Math.log10(e)+1e-9),n=e/10**t;return n===5||n===1&&e>=10?e/5:n===2?e/2:null}function h0(e){return Math.round(e*1e3)/1e3}function g0(e,t,n){if(t<e||n<=0)return[];const o=f0(n)??n,i=Math.ceil(e/o-1e-9)*o,a=Math.floor((t-i)/o+1e-9),l=[];for(let c=0;c<=a;c++){const s=h0(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 ld=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Mo=[{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","尺寸"]},{key:"ps-margin-top",keywords:["上外边距","外边距","margintop"],default:0,defaultUnit:"mm"},{key:"ps-margin-right",keywords:["右外边距","外边距","marginright"],default:0,defaultUnit:"mm"},{key:"ps-margin-bottom",keywords:["下外边距","外边距","marginbottom"],default:0,defaultUnit:"mm"},{key:"ps-margin-left",keywords:["左外边距","外边距","marginleft"],default:0,defaultUnit:"mm"}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-family",keywords:["字体","字体名","字体族","fontfamily"]},{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]},{key:"ap-text-fit",keywords:["溢出","溢出显示","截断","自动缩小","自适应行高","textfit","overflow"]},{key:"ap-shrink-min",keywords:["最小字号","缩放下限","shrinkminfontsize"],default:mc,defaultUnit:"pt"},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{key:"ap-keep-line-breaks",keywords:["保留换行符","换行符","手动换行","保留空格","连续空格","行首空格","keeplinebreaks"]},{key:"ap-long-text-indent",keywords:["首行缩进","缩进","indent","longtextindent","两字符","段首"],tip:"长文本每段首行空出的宽度,单位「字符」:填 2 即缩进两个汉字宽(中文排版惯例),按 em 落纸——字号被「自动缩小」压小时缩进同步变窄。仅长文本元素生效,写在普通文本上不生效"},{key:"ap-img-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover","填充","裁剪","剪裁","锚点"],tip:"图片在元素框内的缩放方式:包含=完整显示、可能留白;剪裁=铺满框并按「裁剪锚点」取一块;拉伸=填满框会变形;原始尺寸与缩小不放大。画布与三条出纸链路同一口径(缺省包含)"},{key:"ap-img-object-position",keywords:["裁剪锚点","剪裁锚点","锚点","objectposition","object-position","对齐点","上移","头顶"],tip:"取位(仅「剪裁」档有这一行):剪裁把图等比铺满元素框,多出来的那一条边按这里选的位置取舍。先选位置档(贴边/居中/贴另一头),再按百分比微调,0 贴左/贴顶,100 挪到另一头,水平与垂直各自独立;缺省取正中间(保住证件照头顶就选顶部)。其余缩放模式图比框小或刚好铺满,没有可裁的边,所以不出本行"},{key:"ap-img-fit-scale",keywords:["放大比例","剪裁放大","放大倍数","取景","裁切范围","fitscale","zoom"],default:gr,defaultUnit:"%",tip:"剪裁放大:等比铺满之后把画面再推大这么多,两轴才真的各多出一条边可裁——图与框同比例时不放大就什么都裁不掉。100=不放大(缺省),上限 400;超出框的部分由元素框裁掉。锚点选中的那一点既是取位的钉住点、也是放大的中心,两者共用同一个值。仅「剪裁」档生效,其余缩放模式不出本行"},{key:"ap-rotate",keywords:["旋转","角度","rotate","angle","顺时针","逆时针","90度","直角"],tip:"元素绕自身中心旋转的角度(度,0~359):出纸时按旋转后外接盒分页与结算,底部放不下自动移页,超出纸面左右缘或顶部会被裁切并给出纸提示。表格、流式列表与表格下方跟随区的元素不支持旋转(这三类不出本行);条码与二维码的任意角度需 385dpi 以上打印头,低分辨率打印机只按 90° 步进出纸"}]},{group:"flow-list",groupLabel:"流式列表",items:[{key:"fl-columns",keywords:["每行列数","列数","栏数","几列","flowcolumns"],tip:"一行排几个单元,必须由你指定——不随内容自动算列数。填的列数乘单元宽放不下元素框时只给提示、不改你的数,出纸按你填的排"},{key:"fl-row-height",keywords:["行高","每行高度","单元高度","flowrowheight"],tip:"每个单元行的最低高度(毫米),与表格行高同一口径:内容比它高时这一行会撑高,不会裁字"},{key:"fl-gap-x",keywords:["单元间距","横向间距","格间距","列间距","flowgapx"],tip:"相邻单元之间的横向留白(毫米);纵向不留缝,行与行的距离由行高承担"},{key:"fl-auto-span",keywords:["自适应","跨列","内容过长","占两列","自动换行","flowsautspan","flowautospan"],tip:"单元内容比一列还宽时,让它占掉两个或更多列位;当前行剩不够放就把整个单元挪到下一行行首(绝不把词切两半)。默认关——开着时出纸栏数由字号与框宽决定"},{key:"fl-max-span",keywords:["最多跨几列","跨列上限","flowmaxspan"],tip:"跨列的列数上限,最大只能等于「每行列数」:把每行列数改小时,这里会被一并顶回去"},{key:"fl-layout-mode",default:"fixed",keywords:["布局模式","容器模式","固定高度","动态分页","自动高度","flowlayoutmode"],tip:"容器高度由谁决定:固定高度=维持设计高度、一框一页,超高裁切(存量模板默认值,输出不变);动态分页=容器高度由内容撑开,内容满页后按行续页,每一页都画完整边框,元素下方的跟随区与表格同一套规则"},{key:"fl-padding-top",keywords:["上内边距","内边距","顶边距","flowpaddingtop"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器顶部与第一行内容之间的留白(毫米),仅动态模式生效;每页切片都按它留白并计入分页预算,负值与非法值按 0 处理"},{key:"fl-padding-right",keywords:["右内边距","内边距","右边距","flowpaddingright"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器右侧与内容之间的留白(毫米),会压缩参与列宽估算的内容宽度,仅动态模式生效"},{key:"fl-padding-bottom",keywords:["下内边距","内边距","底边距","flowpaddingbottom"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器底部与最后一行内容之间的留白(毫米),每页切片都按它留白并计入分页预算,仅动态模式生效"},{key:"fl-padding-left",keywords:["左内边距","内边距","左边距","flowpaddingleft"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器左侧与内容之间的留白(毫米),会压缩参与列宽估算的内容宽度,仅动态模式生效"}]},{group:"code",groupLabel:"条码设置",items:[{key:"cd-type",keywords:["码制","条码类型","条形码类型","barcodetype","code128","ean13","code39","itf14"]},{key:"cd-dpi",keywords:["打印机分辨率","dpi","打印点","点阵对齐","203","300"]},{key:"cd-bar-width",keywords:["条宽","条粗细","barwidth","模块宽"]},{key:"cd-bar-quiet-zone",keywords:["条码静区","条码白边","条形码留白","条码空白边","barquietzone"],default:Tc,defaultUnit:"模块",tip:"条形码左右两端的空白格数(1 格 = 1 条宽):缺省 10,正是一维码码制要求的下限;数值越小白边越窄、同样的框内条越粗(可放大)。填 0 即不留白边,但静区参与「条→空→条」跳变,紧邻文字或表格线时可能扫不出,需实打验证"},{key:"cd-bar-height",keywords:["条高","条码高度","条区高度","条码多高","barheight"],default:Zt,defaultUnit:"模块",tip:"黑白条本体的目标高度(mm,不含下方文字):折算粒度就是每模块物理宽,所以只能精确到它的整数倍。条宽优先——可用框高装不下时期望条高让位,绝不把条宽挤窄(热敏出纸清晰度靠条宽)。与「最大高度」分工不同:那条限的是整图(含文字)的上限"},{key:"cd-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"],default:ho,defaultUnit:"模块"},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],default:kc,defaultUnit:"模块",tip:"二维码四周留出的空白格数:0 即不留白边、码面等比铺满元素框(此时靠框外的白纸充当静区);数值越大白边越宽、码面在框内越小(缺省 0,需 ISO/IEC 18004 推荐静区时填 4)"},{key:"cd-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover"]},{key:"cd-max-width",keywords:["最大宽度","最大宽","maxwidth"]},{key:"cd-max-height",keywords:["最大高度","最大高","maxheight"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-style",keywords:["线型","边框线型","实线","虚线","点线","双线","borderstyle"]},{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-fixed-position",keywords:["固定","每页固定","fixed"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function Ae(e){for(const t of Mo){const n=t.items.find(r=>r.key===e);if(n)return n.tip??""}return""}function cd(e,t){const n=e.trim().toLowerCase();return n?t.some(r=>r.toLowerCase().includes(n)):!0}function m0(e){const t=[],n=new Set;for(const r of Mo){const o=r.items.filter(i=>cd(e,[...i.keywords,r.groupLabel]));if(o.length>0){t.push(r.group);for(const i of o)n.add(i.key)}}return{groups:t,itemKeys:n}}function b0(e){for(const t of Mo)for(const n of t.items)if(n.key===e&&n.default!==void 0)return{value:n.default,unit:n.defaultUnit}}function y0(e){return/[\u1100-\u115F\u2E80-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/.test(e)}function v0(e){let t=0;for(const n of e)t+=y0(n)?1:.55;return t}function w0(e){return v0(e)>=4}const x0=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),E0=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function Da(e){const t=[];let n=0;const r=e.length;for(;n<r;){const o=e[n];if(/\s/.test(o)){n++;continue}if(/[0-9]/.test(o)||o==="."&&n+1<r&&/[0-9]/.test(e[n+1])){let l=n;for(;l<r&&/[0-9.]/.test(e[l]);)l++;t.push({type:"num",value:e.slice(n,l),position:n}),n=l;continue}if(o==="'"||o==='"'){let l=n+1,c="";for(;l<r&&e[l]!==o;)e[l]==="\\"&&l+1<r?(c+=e[l+1],l+=2):(c+=e[l],l++);if(l>=r)throw new Error("字符串未闭合");t.push({type:"str",value:c,position:n}),n=l+1;continue}if(/[A-Za-z_$\u4e00-\u9fff]/.test(o)){let l=n;for(;l<r&&/[A-Za-z0-9_$\u4e00-\u9fff]/.test(e[l]);)l++;const c=e.slice(n,l);if(E0.has(c))throw new Error(`不允许使用关键字: ${c}`);if(x0.has(c))throw new Error(`禁止访问: ${c}`);c==="true"||c==="false"?t.push({type:"bool",value:c,position:n}):t.push({type:"ident",value:c,position:n}),n=l;continue}const i=e.slice(n,n+3);if(i==="==="||i==="!=="){t.push({type:"punc",value:i,position:n}),n+=3;continue}const a=e.slice(n,n+2);if(a==="=>")throw new Error("不允许函数定义");if(["==","!=","<=",">=","&&","||"].includes(a)){t.push({type:"punc",value:a,position:n}),n+=2;continue}if(o==="=")throw new Error("不允许赋值");if(o===";")throw new Error("不允许多条语句");if("+-*/%()[]{},:.?!<>".includes(o)){t.push({type:"punc",value:o,position:n}),n++;continue}throw new Error(`非法字符: ${o}`)}return t}function $a(e){return new S0(e).parse()}class S0{constructor(t){this.pos=0,this.tokens=t}parse(){const t=this.parseTernary();if(this.pos<this.tokens.length)throw new Error(`表达式存在多余内容: ${this.tokens[this.pos].value}`);return t}peek(){return this.tokens[this.pos]}next(){const t=this.tokens[this.pos++];if(!t)throw new Error("表达式意外结束");return t}eatPunc(t){const n=this.peek();return n&&n.type==="punc"&&n.value===t?(this.pos++,!0):!1}expectPunc(t){if(!this.eatPunc(t)){const n=this.peek()?.position??0;throw new Error(`位置 ${n}: 期望 "${t}"`)}}parseTernary(){const t=this.parseLogicalOr();if(this.eatPunc("?")){const n=this.parseTernary();this.expectPunc(":");const r=this.parseTernary();return{type:"ternary",cond:t,consequent:n,alternate:r}}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.eatPunc("||");){const n=this.parseLogicalAnd();t={type:"binary",op:"||",left:t,right:n}}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.eatPunc("&&");){const n=this.parseEquality();t={type:"binary",op:"&&",left:t,right:n}}return t}parseEquality(){let t=this.parseRelational();for(;;){const n=this.peek();if(n?.type==="punc"&&["==","!=","===","!=="].includes(n.value)){this.pos++;const r=this.parseRelational();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseRelational(){let t=this.parseAdditive();for(;;){const n=this.peek();if(n?.type==="punc"&&["<",">","<=",">="].includes(n.value)){this.pos++;const r=this.parseAdditive();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseAdditive(){let t=this.parseMultiplicative();for(;;){const n=this.peek();if(n?.type==="punc"&&(n.value==="+"||n.value==="-")){this.pos++;const r=this.parseMultiplicative();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseMultiplicative(){let t=this.parseUnary();for(;;){const n=this.peek();if(n?.type==="punc"&&["*","/","%"].includes(n.value)){this.pos++;const r=this.parseUnary();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseUnary(){const t=this.peek();if(t?.type==="punc"&&["!","-","+"].includes(t.value)){this.pos++;const n=this.parseUnary();return{type:"unary",op:t.value,arg:n,prefix:!0}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.eatPunc(".")){const n=this.next();if(n.type!=="ident")throw new Error(`位置 ${n.position}: 成员访问需要属性名`);t={type:"member",object:t,property:n.value,computed:!1}}else if(this.eatPunc("[")){const n=this.parseTernary();this.expectPunc("]"),n.type==="str"?t={type:"member",object:t,property:n.value,computed:!1}:t={type:"member",object:t,property:n.name??String(n.value),computed:!0}}else if(this.peek()?.type==="punc"&&this.peek()?.value==="("&&(t.type==="ident"||t.type==="member")){this.pos++;const n=this.parseArgs();t={type:"call",callee:t,args:n}}else return t}parseArgs(){const t=[];if(this.eatPunc(")"))return t;for(;;){if(t.push(this.parseTernary()),this.eatPunc(")"))return t;this.expectPunc(",")}}parsePrimary(){const t=this.next();if(t.type==="num"){const n=Number(t.value);if(isNaN(n))throw new Error(`非法数字: ${t.value}`);return{type:"num",value:n}}if(t.type==="str")return{type:"str",value:t.value};if(t.type==="bool")return{type:"bool",value:t.value==="true"};if(t.type==="ident")return{type:"ident",name:t.value};if(t.value==="("){const n=this.parseTernary();return this.expectPunc(")"),n}if(t.value==="["){const n=[];if(!this.eatPunc("]"))for(;n.push(this.parseTernary()),!this.eatPunc("]");)this.expectPunc(",");return{type:"array",elements:n}}if(t.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(`位置 ${t.position}: 意外的符号: ${t.value}`)}}const dd=20,_0=8;function et(e,t=0){if(typeof e=="number")return Number.isFinite(e)?e:t;if(typeof e=="string"){const n=e.trim();if(n==="")return t;const r=Number(n);return Number.isFinite(r)?r:t}return e==null?t:typeof e=="boolean"?e?1:0:t}function M0(e){if(typeof e=="number")return Number.isFinite(e);if(typeof e=="string"){const t=e.trim();return t!==""&&Number.isFinite(Number(t))}return!1}function Hn(e){return!Number.isFinite(e)||Number.isInteger(e)||Math.abs(e)>=1e15?e:Number(e.toPrecision(12))}function Un(e){if(!Number.isFinite(e)||Number.isInteger(e))return 0;const t=String(e);if(t.includes("e")||t.includes("E"))return 0;const n=t.indexOf(".");return n===-1?0:t.length-n-1}function Na(e,t){if(!Number.isFinite(e))return 0;const n=Math.min(Math.max(t,0),12);if(n===0)return Math.round(e);const r=10**n,o=e*r;return!Number.isFinite(o)||Math.abs(o)>=1e15?Hn(e):Math.round(o)/r}function La(e,t){const n=et(e),r=et(t),o=n+r;return Na(o,Math.max(Un(n),Un(r)))}function Fa(e,t){const n=et(e),r=et(t),o=n-r;return Na(o,Math.max(Un(n),Un(r)))}function ud(e,t){const n=et(e),r=et(t),o=n*r;return Na(o,Un(n)+Un(r))}function pd(e,t){const n=et(e),r=et(t);return r===0?0:Hn(n/r)}function T0(e,t){const n=et(e),r=et(t);return r===0?0:Hn(n%r)}function k0(e){if(e==null)return 2;const t=Math.trunc(et(e,2));return Number.isFinite(t)?Math.min(Math.max(t,-dd),dd):2}function To(e,t,n){const r=et(e,0),o=k0(t);if(r===0)return 0;if(Math.abs(r)>=1e21)return Hn(r);const i=Math.max(o,0)+_0,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return Hn(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 g=u%d,m=2n*g;n==="up"?g!==0n&&(f+=1n):n!=="down"&&m>=d&&(m>d||n==="half-up"||f%2n===1n)&&(f+=1n);const b=p*f;return Hn(o>=0?Number(b)/10**o:Number(b)*10**-o)}const za={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},C0=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),A0=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function Ke(e,t,n={}){switch(e.type){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"ident":return O0(e.name,t);case"binary":return I0(e,t,n);case"unary":return P0(e,t,n);case"ternary":return Ke(e.cond,t,n)?Ke(e.consequent,t,n):Ke(e.alternate,t,n);case"member":return $0(e,t,n);case"call":return N0(e,t,n);case"array":return e.elements.map(r=>Ke(r,t,n));case"object":return Object.fromEntries(e.properties.map(r=>[r.key,Ke(r.value,t,n)]))}}function O0(e,t,n){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];if(Object.prototype.hasOwnProperty.call(za,e))return za[e];throw new Error(`未定义的标识符: ${e}`)}function I0(e,t,n){const r=Ke(e.left,t,n),o=Ke(e.right,t,n);switch(e.op){case"+":return D0(r,o)?La(r,o):R0(r,o);case"-":return Fa(r,o);case"*":return ud(r,o);case"/":return pd(r,o);case"%":return T0(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(`未知运算符: ${e.op}`)}}function P0(e,t,n){const r=Ke(e.arg,t,n);switch(e.op){case"-":return Fa(0,r);case"+":return et(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${e.op}`)}}function R0(e,t){return`${e==null?"":String(e)}${t==null?"":String(t)}`}function D0(e,t){const n=fd(e),r=fd(t);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function fd(e){return e==null||e===""?"neutral":M0(e)?"num":"other"}function $0(e,t,n){const r=Ke(e.object,t,n);if(r==null)throw new Error("无法访问空值的属性");if(C0.has(e.property))throw new Error(`禁止访问属性: ${e.property}`);return r[e.property]}function N0(e,t,n){if(e.callee.type==="ident"&&A0.has(e.callee.name)){const o=za[e.callee.name],i=e.args.map(a=>Ke(a,t,n));return o(...i)}if(e.callee.type==="member"&&e.callee.object.type==="ident"&&e.callee.object.name==="Math"){const o=Math[e.callee.property];if(typeof o!="function")throw new Error(`Math.${e.callee.property} 不是方法`);const i=e.args.map(a=>Ke(a,t,n));return o(...i)}let r;if(e.callee.type==="ident")r=e.callee.name;else if(e.callee.type==="member")throw new Error("不支持方法调用,请使用顶级函数");if(r&&n[r]){const o=e.args.map(i=>Ke(i,t,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(t,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function L0(e){const t=[];let n=0;const r=e.length;for(;n<r;){if(e[n]==="{"){let i=1,a=n+1;for(;a<r&&i>0;)e[a]==="{"?i++:e[a]==="}"&&i--,a++;if(i!==0)throw new Error(`位置 ${n}: 花括号未闭合`);const l=e.slice(n+1,a-1);if(l.trim()==="")throw new Error(`位置 ${n}: 空表达式`);const c=Da(l),s=$a(c);t.push({type:"expr",expression:s}),n=a;continue}let o=n;for(;o<r&&e[o]!=="{";)e[o]==="\\"&&o+1<r&&(e[o+1]==="{"||e[o+1]==="}")?o+=2:o++;t.push({type:"text",value:e.slice(n,o).replace(/\\([{}])/g,"$1")}),n=o}return{type:"template",parts:t}}function F0(e,t,n={}){let r="";for(const o of e.parts)if(o.type==="text")r+=o.value;else{const i=Ke(o.expression,t,n);r+=String(i??"")}return r}function hd(e,t={}){const n=L0(e);return r=>F0(n,r,t)}function Er(e,t){if(e==null||t==null)return;if(typeof e=="object"&&t in e)return e[t];const n=t.split(".");let r=e;for(const o of n){if(r==null)return;r=r[o]}return r}function gd(e){const t=Number(e);if(isNaN(t))return String(e);const n=t<0?"-":"",r=Math.abs(t),[o,i]=r.toFixed(2).split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n}${a}.${i}`}function md(e,t){let n;if(e instanceof Date)n=e;else if(typeof e=="number")n=new Date(e);else if(typeof e=="string")n=new Date(e);else return String(e);if(isNaN(n.getTime()))return String(e);const r=o=>String(o).padStart(2,"0");return t.replace("YYYY",String(n.getFullYear())).replace("MM",r(n.getMonth()+1)).replace("DD",r(n.getDate())).replace("HH",r(n.getHours())).replace("mm",r(n.getMinutes())).replace("ss",r(n.getSeconds()))}const Ba=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],z0=["","拾","佰","仟"],B0=["","万","亿","万亿","亿亿"];function H0(e){let t="",n=!1;for(let r=3;r>=0;r--){const o=Math.floor(e/10**r)%10;if(o===0){t&&(n=!0);continue}n&&(t+="零",n=!1),t+=Ba[o]+z0[r]}return t}function bd(e){const t=Number(e);if(isNaN(t))return String(e);if(t===0)return"零元整";const n=t<0?"负":"",[r,o]=Math.abs(t).toFixed(2).split("."),i=Math.ceil(r.length/4);let a="",l=!1;for(let d=i-1;d>=0;d--){const p=r.length-d*4,u=parseInt(r.slice(Math.max(0,p-4),p),10);if(u===0){a&&(l=!0);continue}a&&(l||u<1e3)&&(a+="零"),l=!1,a+=H0(u)+(B0[d]??"")}a=`${a||"零"}元`;const c=parseInt(o[0],10),s=parseInt(o[1],10);return c===0&&s===0?a+="整":(c===0?a+="零":a+=Ba[c]+"角",s>0&&(a+=Ba[s]+"分")),n+a}function yd(e,t,n){return e?t:n}function Ha(e,t){return e.reduce((n,r)=>n+(Number(Er(r,t))||0),0)}function vd(e,t){return e.length===0?0:Ha(e,t)/e.length}function wd(e,t){return e.length}function xd(e,t){return e.length===0?0:Math.min(...e.map(n=>Number(Er(n,t))||0))}function Ed(e,t){return e.length===0?0:Math.max(...e.map(n=>Number(Er(n,t))||0))}function Sd(...e){return e.reduce((t,n)=>La(t,n),0)}function _d(...e){return e.length===0?0:e.slice(1).reduce((t,n)=>Fa(t,n),La(e[0],0))}function Md(...e){return e.length===0?0:e.reduce((t,n)=>ud(t,n),1)}function Td(e,t){return pd(e,t)}function kd(e,t){return To(e,t,"half-up")}function ko(e,t){return To(e,t,"up")}function Co(e,t){return To(e,t,"down")}function Cd(e,t){return To(e,t,"half-even")}class U0{constructor(){this.functions={}}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Da(t),o=$a(r);return Ke(o,n,this.functions)}render(t,n){return hd(t,this.functions)(n)}}const Ua=new U0,q0={MONEY:gd,DATE:md,UPPER:bd,IF:yd,CONCAT:(...e)=>e.filter(t=>t!=null).map(String).join(""),IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,LEN:e=>String(e).length,ADD:Sd,SUB:_d,MUL:Md,DIV:Td,ROUND:kd,ROUNDUP:ko,CEIL:ko,ROUNDDOWN:Co,FLOOR:Co,ROUNDBANK:Cd};for(const[e,t]of Object.entries(q0))Ua.registerFunction(e,t);function W0(e,t,n){switch(e.toUpperCase()){case"SUM":return Ha(n,t);case"AVG":return vd(n,t);case"COUNT":return wd(n);case"MIN":return xd(n,t);case"MAX":return Ed(n,t);default:return 0}}function j0(e,t){return Ua.evaluate(e,t)}function Qt(e,t,n){if(!e)return"";if(!e.includes("{"))return e;const r=Array.isArray(t.rows)?t.rows:[],o=e.replace(/\{([^}]+)\}/g,(i,a)=>{let l=a.trim();return l=l.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(c,s,d)=>{const p=d.trim().replace(/^['"]|['"]$/g,"");return String(W0(s,p,r))}),`{${l}}`});try{return Ua.render(o,t)}catch{return n??e}}function Ad(e,t,n,r){const o={...Io(),...t??{}},i=JSON.parse(JSON.stringify(e));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>qa(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>qa(l,o,n))),i.elements=i.elements.map(l=>qa(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 qa(e,t,n){const r={...e,options:{...e.options}};if(!(r.type==="flowList"||r.printElementType?.type==="flowList")&&typeof r.options.formatter=="string"){const c=r.options.formatter;if(_r(c))r.options.rawFormatter=c;else{const s=r.type||r.printElementType?.type,d=typeof r.options.exampleValue=="string"?r.options.exampleValue:Wg(s);r.options.formatter=Qt(c,t,d)}}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let c=r.options.src;c.includes("{")&&(c=Qt(c,t)),c&&n&&!/^([a-z][a-z\d+\-.]*:|\/\/)/i.test(c)&&(c=n.replace(/\/+$/,"")+(c.startsWith("/")?c:`/${c}`)),r.options.src=c}(r.type==="table"||r.printElementType?.type==="table")&&V0(r,t),(r.type==="flowList"||r.printElementType?.type==="flowList")&&G0(r,t);const a=r.type||r.printElementType?.type||"text",l=$n(a)?.binding?.bind;if(l){const c=l(r.options,t);c&&typeof c=="object"&&Object.assign(r.options,c)}return r}function G0(e,t){const n=typeof e.options.formatter=="string"?e.options.formatter:"",r={...e.options,dataSource:e.options.dataSource??fo(n,t)},{list:o,key:i}=Od(r,t),a=c=>i?{...t,...c,[i]:c}:{...t,...c},l=o.map(c=>n?_r(n)?n:Qt(n,a(c)):String(c??""));if(e.options._flowItems=l,e.options._flowRawFormatter=_r(n)?n:void 0,pn(e.options.flowLayoutMode)==="dynamic"){const c=Ec(e.options.width??0,Nn(e.options)),s=l.length>0?l:String(e.options.testData??"").split(/\r?\n/).map(d=>d.trim()).filter(Boolean);e.options._flowRows=da(s,{width:c,columns:pt(e.options.flowColumns),gapX:vt(e.options.flowGapX),fontSizePt:e.options.fontSize??12,autoSpan:e.options.flowAutoSpan===!0,maxSpan:fn(e.options.flowMaxSpan,e.options.flowColumns)})}}function Od(e,t){const n=e.dataSource??e.fields?.[0]?.dataSource??e.fields?.[0]?.field;if(n&&Array.isArray(t[n]))return{list:t[n],key:n};for(const[r,o]of Object.entries(t))if(Array.isArray(o))return{list:o,key:r};return{list:[],key:n}}function V0(e,t){const n=e.options,r=n.tableRows;if(!Array.isArray(r)||r.length===0)return;const o=n.tableMode??"dynamic",{list:i,key:a}=o==="dynamic"?Od(n,t):{list:[],key:void 0},l=g=>a?{...t,...g,[a]:g}:{...t,...g},c=a?i.map(g=>({...g,[a]:g})):i,s=[],d=[],p=[],u=[];let f=-1;for(const g of r){if(o==="dynamic"&&g.type==="data"){Y0(g.cells);for(const m of i){f<0&&(f=s.length);const b=l(m);s.push(Oo(g,v=>Ao(v,b))),d.push(b)}continue}if(o==="dynamic"&&g.type==="subtotal"){const m=Oo(g,b=>Ao(b,{rows:c,...t}),!0);p.push(m),s.push(m);continue}if(o==="dynamic"&&g.type==="summary"){const m=Oo(g,b=>Ao(b,{rows:c,...t}));u.push(m),s.push(m);continue}s.push(Oo(g,m=>Ao(m,t)))}n._renderRows=s,n._repeatHeaderCount=K0(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=t}function Y0(e){const t=new Set;e.forEach((n,r)=>{if(!n||n.merged)return;const o=Math.max(n.colspan??1,1);for(let i=1;i<o;i++)t.add(r+i)}),e.forEach((n,r)=>{n.rowspan&&(n.rowspan=1),n.merged&&!t.has(r)&&(n.merged=!1)})}function Ao(e,t){const n=e.formatter;return n?_r(n)?n:Qt(n,t):""}function Oo(e,t,n=!1){return{type:e.type,height:e.height??8,cells:e.cells.map(r=>({content:r.merged?"":t(r),...(n||_r(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,barQuietZone:r.barQuietZone,barHeight:r.barHeight,barWidth:r.barWidth,barFontSize:r.barFontSize,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,fitScale:r.fitScale,maxWidth:r.maxWidth,maxHeight:r.maxHeight,rowspan:r.rowspan??1,colspan:r.colspan??1,merged:r.merged===!0,...r.mergeSameValue===!0?{mergeSameValue:!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 K0(e){const t=X0(e);return t===0||!e.slice(0,t).some(r=>r.repeatOnPage===!0)?0:J0(e,t)}function X0(e){let t=0;for(const n of e){if(n?.type!=="header")break;t++}return t}function Z0(e,t){for(let n=0;n<t;n++)for(const r of e[n]?.cells??[])if(!r?.merged&&n+(r?.rowspan??1)>t)return!1;return!0}function J0(e,t){for(let n=t;n>=1;n--)if(Z0(e,n))return n;return 1}const Sr=e=>String(e).padStart(2,"0");function Io(e=new Date,t={}){return{printDate:`${e.getFullYear()}-${Sr(e.getMonth()+1)}-${Sr(e.getDate())}`,printTime:`${Sr(e.getHours())}:${Sr(e.getMinutes())}:${Sr(e.getSeconds())}`,pageIndex:t.pageIndex??1,totalPages:t.totalPages??1}}function _r(e){return typeof e=="string"&&/\b(pageIndex|totalPages)\b/.test(e)}function Wa(e,t=new Date){const{printDate:n,printTime:r}=Io(t);return e.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function Mr(e){const t=[];for(const n of e??[]){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";t.push(`@font-face{font-family:${o};src:url("${a}")${Q0(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return t.length?`${t.join("")}
2
- `:""}function Q0(e){const t=e.split(/[?#]/)[0].toLowerCase();return t.endsWith(".woff2")?' format("woff2")':t.endsWith(".woff")?' format("woff")':t.endsWith(".ttf")?' format("truetype")':t.endsWith(".otf")?' format("opentype")':""}const ja=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function Ga(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Va(e){const t=e?.trim();return t?[t.includes(",")?t:`"${t.replace(/"/g,"")}"`,...ja].join(", "):ja.join(", ")}function Ya(e){return e?Va(e):"inherit"}function eb(e){const t=[],n=new Set;for(const r of e??[]){const o=r?.family?.trim();if(!o)continue;const i=o.toLowerCase();if(n.has(i))continue;n.add(i);const a=r?.label?.trim();t.push(a?{family:o,label:a}:{family:o})}return t}function Id(e,t){const n=t?.trim().toLowerCase();if(n)return e.find(r=>r.family.trim().toLowerCase()===n)}function Pd(e){return e.label?`${e.label}(${e.family})`:e.family}function Tr(e){return e.toLowerCase().replace(/\s+/g,"")}function Rd(e,t){if(e===t)return 0;if(e.startsWith(t))return 1;if(e.includes(t))return 2;let n=0;for(const r of e)if(r===t[n]&&n++,n===t.length)return 3;return-1}function tb(e,t){const n=Rd(Tr(e.family),t);if(!e.label)return n;const r=Rd(Tr(e.label),t);return n<0?r:r<0?n:Math.min(n,r)}function nb(e,t){const n=Tr(t.trim());return n?e.map((r,o)=>({font:r,index:o,rank:tb(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...e]}function Y(e){return`${e}mm`}function Ka(e,t){const n=gn(e);return t&&t>0&&At(e)?{width:n.width,height:t}:n}function Dd(e,t){const n=ht(e);return t&&t>0&&At(e)?{width:n.width,height:t}:n}function $d(){return`
1
+ (function(so){typeof define=="function"&&define.amd?define(so):so()})((function(){"use strict";function so(){let e=0;return function(){return e+=1,`cell-${Date.now().toString(36)}-${e}`}}function Ag(){let e=0;return function(){return e+=1,`row-${Date.now().toString(36)}-${e}`}}const Dg=so(),Og=Ag(),Kt={width:.75,style:"solid",color:"#333333"};function ta(e){return JSON.parse(JSON.stringify(e))}function na(e){return{id:Dg(),borders:{top:{...Kt},right:{...Kt},bottom:{...Kt},left:{...Kt}},...e}}function Ig(){const e=[50,50,50],t=(r,o)=>({id:Og(),type:r,height:8,...o!==void 0?{repeatOnPage:o}:{},cells:e.map(()=>na())}),n=t("header",!0);return n.cells.forEach((r,o)=>{r.formatter=`列${o+1}`,r.align="center",r.fontWeight="bold"}),{rows:[n,t("data"),t("subtotal"),t("summary")],colWidths:e}}function ar(e,t,n){if(!e[t].cells[n].merged)return{r:t,c:n};for(let r=t;r>=0;r--)for(let o=n;o>=0;o--){const i=e[r].cells[o];if(i.merged)continue;const a=i.rowspan??1,l=i.colspan??1;if(r+a-1>=t&&o+l-1>=n)return{r,c:o}}return{r:t,c:n}}function cn(e,t,n){const r=ar(e,t,n),o=e[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 tc(e,t,n){let r={r1:Math.min(t.r,n.r),c1:Math.min(t.c,n.c),r2:Math.max(t.r,n.r),c2:Math.max(t.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=cn(e,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 nc(e,t){if((t.r2-t.r1+1)*(t.c2-t.c1+1)<2)return"至少选择 2 个单元格";const r=new Set;for(let i=t.r1;i<=t.r2;i++)r.add(e[i].type);if(r.size>1)return"合并区域不能跨越不同类型的行";if(t.r2>t.r1&&r.has("data"))return"数据行将按列表展开,纵向合并请使用单元格属性「按值合并」";const o=tc(e,{r:t.r1,c:t.c1},{r:t.r2,c:t.c2});return o.r1!==t.r1||o.c1!==t.c1||o.r2!==t.r2||o.c2!==t.c2?"选区与已有合并区域部分重叠":null}function rc(e,t){const n=e[t.r1].cells[t.c1],r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];a.formatter&&r.push(a.formatter),!(o===t.r1&&i===t.c1)&&(a.merged=!0,a.rowspan=1,a.colspan=1,a.formatter="")}n.rowspan=t.r2-t.r1+1,n.colspan=t.c2-t.c1+1,n.formatter=r.join(" ")}function oc(e,t){for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e[n].cells[r];if(!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1)){const i=cn(e,n,r),a=o;for(let l=i.r1;l<=i.r2;l++)for(let c=i.c1;c<=i.c2;c++){const s=e[l].cells[c];s.merged=!1,s.rowspan=1,s.colspan=1,Pg(a,s)}o.rowspan=1,o.colspan=1}}}function Pg(e,t){e!==t&&(t.align=e.align,t.valign=e.valign,t.fontSize=e.fontSize,t.fontFamily=e.fontFamily,t.fontWeight=e.fontWeight,t.color=e.color,t.backgroundColor=e.backgroundColor,t.borders=e.borders?ta(e.borders):void 0,t.padding=e.padding,t.wordWrap=e.wordWrap)}function ic(e,t,n){const r=n==="above"?t:t+1,o=e[t],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:[e[r-1],e[r]].find(c=>c?.type==="header")?.repeatOnPage===!0}:{},cells:Array.from({length:i},()=>na())};for(let c=0;c<i;c++)if(r>0&&r<e.length){const s=cn(e,r-1,c);if(s.r1<r&&s.r2>=r){const d=e[s.r1].cells[s.c1];d.rowspan=(d.rowspan??1)+1,l.cells[c].merged=!0}}e.splice(r,0,l)}function Rg(e,t){if(e.length<=1)return"不能删除最后一行";const n=e[t],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=e[t+1].cells[o];Object.assign(a,ta(i),{id:a.id}),a.rowspan=(i.rowspan??1)-1,a.merged=!1}else if(i.merged){const a=cn(e,t,o);if(a.r1<t&&a.c1===o){const l=e[a.r1].cells[a.c1];l.rowspan=(l.rowspan??1)-1}}}return e.splice(t,1),null}function ac(e,t,n,r){const o=r==="left"?n:n+1;t.splice(o,0,t[n]);for(const i of e){const a=na();if(o>0&&o<i.cells.length){const l=e.indexOf(i),c=cn(e,l,o-1);if(c.c1<o&&c.c2>=o){const s=e[c.r1].cells[c.c1];l===c.r1&&(s.colspan=(s.colspan??1)+1),a.merged=!0}}i.cells.splice(o,0,a)}}function Fg(e,t,n){if(t.length<=1)return"不能删除最后一列";for(let r=0;r<e.length;r++){const o=e[r].cells[n];if(!o.merged&&(o.colspan??1)>1){const i=e[r].cells[n+1];Object.assign(i,ta(o),{id:i.id}),i.colspan=(o.colspan??1)-1,i.merged=!1}else if(o.merged){const i=cn(e,r,n);if(i.c1<n&&i.r1===r){const a=e[i.r1].cells[i.c1];a.colspan=(a.colspan??1)-1}}}for(const r of e)r.cells.splice(n,1);return t.splice(n,1),null}function ra(e,t,n){if(n==="data"){const r=e.findIndex((o,i)=>o.type==="data"&&i!==t);if(r>=0)return`数据行已存在(第 ${r+1} 行),全表最多一行`}if(n==="header"){for(let r=0;r<t;r++)if(e[r].type!=="header")return"标题行必须从表格顶部连续设置"}if(n==="subtotal"||n==="summary"){const r=e.findIndex(o=>o.type==="data");if(r<0)return"请先设置数据行,小计/汇总行必须位于数据行之后";if(t<r)return"小计/汇总行必须位于数据行之后"}if(n==="subtotal"&&e.slice(0,t).some(r=>r.type==="summary"))return"小计行必须位于汇总行之前";if(n==="summary"&&e.slice(t+1).some(r=>r.type==="subtotal"))return"汇总行必须位于小计行之后";if(e[t].type==="header"&&n!=="header"){for(let r=t+1;r<e.length;r++)if(e[r].type==="header")return"取消该标题行会导致标题行不连续,请先调整后续标题行"}if(e[t].type=n,n==="header"){const r=[e[t-1],e[t+1]].find(o=>o?.type==="header");e[t].repeatOnPage=e[t].repeatOnPage!==void 0?e[t].repeatOnPage===!0:r?.repeatOnPage===!0}else delete e[t].repeatOnPage;return null}function $g(e,t){for(const n of e){if(n.type!=="header")break;n.repeatOnPage=t}}function sc(e,t,n,r){for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e[o].cells[i];if(a.merged)continue;if(n==="none"){delete a.borders;continue}const l=cn(e,o,i),c=l.r1===t.r1,s=l.r2===t.r2,d=l.c1===t.c1,p=l.c2===t.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 Ng="线型 / 宽度 / 颜色是待应用规格:选中格已有的边框规格一致时会填进这三行;四边不一致的项显示「混合」,一条边都没有时显示「无 / 0」。改完点「全部 / 外侧 / 内部」或勾选上、下、左、右某条边才会写入选中的单元格;「无」是清除边框",Lg="多选时不回显单格边框:线型 / 宽度 / 颜色按当前设置作为批写规格,点「全部 / 外侧 / 内部」或勾选某条边后写入所有选中格;「无」是清除边框",Bg="当前单元格四边边框规格不一致:带「混合」的项不谎报,未改项在点「全部 / 外侧 / 内部」或勾选单边时按缺省档(实线 0.75pt)写入,改任一项即按该值批写";function lc(e,t,n){const r={...e.borders??{}};n?r[t]={...n}:delete r[t],e.borders=r.top||r.right||r.bottom||r.left?r:void 0}function lo(e,t){const n=[];for(let r=t.r1;r<=t.r2;r++)for(let o=t.c1;o<=t.c2;o++){const i=e[r]?.cells[o];i&&!i.merged&&n.push(i)}return n}function oa(e,t){const n=lo(e,t).length;return{mode:n>1?"multi":"single",count:n}}function zg(e,t){const n=lo(e,t);if(!n.length)return null;const r=n[0].cellType??"text";return n.every(o=>(o.cellType??"text")===r)?r:null}function cc(e,t){const n=[];for(const o of lo(e,t))for(const i of["top","right","bottom","left"]){const a=o.borders?.[i];a&&n.push(a)}const r=o=>{if(!n.length)return;const i=o(n[0]);return n.every(a=>o(a)===i)?i:"mixed"};return{width:r(o=>o.width),style:r(o=>o.style),color:r(o=>o.color)}}const Hg="1px dashed rgba(0,0,0,0.18)";function co(e,t={}){return e&&e.style!=="none"?`${e.width}pt ${e.style} ${e.color}`:t.designMode&&t.showGhostBorder!==!1?Hg:"none"}function sr(e){const t=(e.tableColWidths??[]).reduce((r,o)=>r+o,0),n=(e.tableRows??[]).reduce((r,o)=>r+o.height,0);e.width=Math.round(t*100)/100,e.height=Math.round(n*100)/100}const dc=5;function Ug(e,t,n,r){const o=e.reduce((l,c,s)=>s===t?l:l+c,0),i=r===1/0?1/0:Math.max(dc,r-o),a=Math.round(n*10)/10;return Math.min(Math.max(a,dc),i)}const uc=Symbol.for("worm-print-platform.element-capabilities.v1"),pc=globalThis;function dn(){const e=pc[uc];if(e)return e;const t={entries:new Map,nextSeq:0,bootstrapped:!1};return pc[uc]=t,fc(t),t}const qg={left:7,top:17.6,width:42.3,height:7.1},Wg=Object.freeze({text:"示例文本",longText:"示例长文本内容",barcode:"12345678",qrcode:"qrcode"});function jg(e){if(e)return Wg[e]}const lr=Object.freeze({text:{zoneAllowed:!0,defaultTextFit:"clip",bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],defaultOptions:()=>({formatter:"文本",exampleValue:"示例文本",fontSize:12,textAlign:"left",height:5.3}),title:"文本"},longText:{defaultTextFit:"autoHeight",bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"},{targetPath:"options.styler",label:"样式",dataSource:"main"}],defaultOptions:()=>({width:141.1,height:28.2,fontSize:12,lineHeight:18,exampleValue:"示例长文本内容"}),title:"长文"},barcode:{zoneAllowed:!0,codeRotationDpiGated:!0,bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],defaultOptions:()=>({width:56.4,height:14.1,title:"条形码",barcodeType:"code128",testData:"12345678",exampleValue:"12345678"}),title:"条形码"},qrcode:{zoneAllowed:!0,codeRotationDpiGated:!0,bindings:[{targetPath:"options.formatter",label:"内容",dataSource:"main"}],defaultOptions:()=>({width:28.2,height:28.2,title:"二维码",testData:"qrcode",exampleValue:"qrcode"}),title:"二维码"},image:{zoneAllowed:!0,bindings:[{targetPath:"options.src",label:"内容",dataSource:"main",placeholder:"输入图片路径,支持 /docfiles/... 相对路径、绝对 URL 或 {字段} 表达式"}],defaultOptions:()=>({width:28.2,height:28.2,fit:"contain"}),title:"图片"},table:{rotationExcluded:!0,acceptsElementBorder:!1,bindings:[],defaultOptions:()=>{const{rows:e,colWidths:t}=Ig(),n=t.reduce((o,i)=>o+i,0),r=e.reduce((o,i)=>o+i.height,0);return{width:n,height:r,tableMode:"dynamic",tableRows:e,tableColWidths:t,tableDefaultFontSize:10,tableDefaultColor:"#333333",tableDefaultPadding:1,fields:[],tablePagination:{enabled:!0}}},title:"表格"},flowList:{rotationExcluded:!0,defaultTextFit:"clip",bindings:[{targetPath:"options.formatter",label:"单元模板",dataSource:"main",placeholder:"{drugs.name} {drugs.spec}"}],defaultOptions:()=>({width:141.1,height:21.2,fontSize:12,formatter:"{name} {spec}",flowColumns:4,flowRowHeight:8,flowGapX:4,flowAutoSpan:!1,flowMaxSpan:2,flowLayoutMode:"fixed",flowPaddingTop:0,flowPaddingRight:0,flowPaddingBottom:0,flowPaddingLeft:0}),title:"流式列表"},hline:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:70.6,height:1.8,borderWidth:.75}),title:"横线"},vline:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:1.8,height:35.3,borderWidth:.75}),title:"竖线"},rect:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:28.2,height:28.2,borderWidth:1,borderColor:"#333"}),title:"矩形"},oval:{zoneAllowed:!0,acceptsElementBorder:!1,defaultOptions:()=>({width:28.2,height:28.2,borderWidth:1,borderColor:"#333"}),title:"椭圆"},html:{blocked:!0,defaultOptions:()=>({width:28.2,height:28.2}),title:"HTML"},pageNumber:{title:"页码"}});function fc(e){if(!e.bootstrapped){e.bootstrapped=!0;for(const[t,n]of Object.entries(lr))e.entries.has(t)||e.entries.set(t,{caps:n,seq:e.nextSeq++})}}function Gg(e,t){if(!e||typeof e!="string")throw new Error("registerElementCapabilities: type 必须是非空字符串");if(!t||typeof t!="object")throw new Error("registerElementCapabilities: caps 必须是对象");const n=dn(),r=n.nextSeq++;return n.entries.set(e,{caps:t,seq:r}),()=>{if(dn().entries.get(e)?.caps!==t)return;const i=lr[e];i?dn().entries.set(e,{caps:i,seq:r}):dn().entries.delete(e)}}function ut(e){return e?{...dn().entries.get(e)?.caps??{},type:e}:{type:""}}function ia(){return[...dn().entries.entries()].sort((e,t)=>e[1].seq-t[1].seq).map(([e])=>e)}function Vg(){const e=dn();e.entries.clear(),e.nextSeq=0,e.bootstrapped=!1,fc(e)}function Yg(){return{...qg}}const hc=Symbol.for("worm-print-platform.element-plugin-registry.v1"),gc=globalThis;function aa(){const e=gc[hc];if(e)return e;const t={plugins:new Map,typeIndex:new Map,configs:new Map,legacyAliases:new Map};return gc[hc]=t,t}function Kg(e,t){const n=e.render||t.render?{...e.render,...t.render}:void 0,r=e.designer||t.designer?{...e.designer,...t.designer}:void 0;return{...e,kind:t,binding:t.binding??e.binding,render:n,designer:r}}function Fn(e){const t=aa().typeIndex.get(e);return t?Kg(t.plugin,t.kind):void 0}function mc(){return[...aa().typeIndex.values()]}function Xg(){return Object.fromEntries(aa().legacyAliases)}function cr(e){return e/2.83464566929}function uo(e){return e*(25.4/96)}function un(e){return e*(96/25.4)}const bc=6,Zg=1,Jg=["clip","shrink","autoHeight"];function yc(e){return typeof e=="string"&&Jg.includes(e)?e:void 0}const Qg={text:"clip",longText:"autoHeight",flowList:"clip"};function po(e,t){const n=ut(e).defaultTextFit;return yc(t?.textFit)??n??Qg[e]??"clip"}function vc(e){if(e?.keepLineBreaks===!0&&e.wordWrap!==!1)return"pre-wrap"}function wc(e){return e?.wordWrap===!1?"nowrap":void 0}function sa(e){return yc(e?.textFit)??(e?.wordWrap===!1?"clip":"autoHeight")}function dr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?bc:Math.max(e,Zg)}function la(e){return Math.round(e*100)/100}function em(e){return Math.floor(e*100)/100}function tm(e,t,n,r){return`${e}#${t}#${n}:${r}`}function nm(e){const t=e.indexOf("#");if(t<0)return;const n=e.lastIndexOf("#"),r=e.slice(t+1,n);if(r!=="b"&&r!=="st"&&r!=="sm")return;const[o,i]=e.slice(n+1).split(":").map(Number);if(!(!Number.isFinite(o)||!Number.isFinite(i)))return{elementId:e.slice(0,t),kind:r,rowIndex:o,colIndex:i}}function xc(e,t){return(e||"contain")==="cover"?t:void 0}function ca(e,t,n,r=1){const o=Math.max(n?.colspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]??0;if(i<=0)return 0;const a=n?.padding??r,l=(cr(n?.borders?.left?.width??0)+cr(n?.borders?.right?.width??0))/2;return Math.max(i-a*2-l,.5)}function ur(e,t,n,r=1){const o=Math.max(n?.rowspan??1,1);let i=0;for(let c=0;c<o;c++)i+=e[t+c]?.height??8;const a=n?.padding??r,l=(cr(n?.borders?.top?.width??0)+cr(n?.borders?.bottom?.width??0))/2;return Math.max(i-a*2-l,.5)}const da=1,Ec=12,rm=3,om=100,im=0,am=50;function pn(e){return e==="dynamic"?"dynamic":"fixed"}function $n(e){const t=n=>{const r=e[n];return typeof r=="number"&&Number.isFinite(r)&&r>0?r:0};return{top:t("flowPaddingTop"),right:t("flowPaddingRight"),bottom:t("flowPaddingBottom"),left:t("flowPaddingLeft")}}function Sc(e,t){return Math.max(0,e-t.left-t.right)}const _c=25.4/72;function sm(e,t,n,r){return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)))}function pt(e){return sm(e,da,Ec,4)}function vt(e){return typeof e!="number"||!Number.isFinite(e)?4:Math.min(am,Math.max(im,e))}function Xt(e){return typeof e!="number"||!Number.isFinite(e)?8:Math.min(om,Math.max(rm,e))}function fn(e,t){const n=pt(t),r=Math.min(2,n);return typeof e!="number"||!Number.isFinite(e)?r:Math.min(n,Math.max(1,Math.round(e)))}function lm(e,t,n){const r=pt(t),o=vt(n),i=e-o*(r-1);return i<=0?0:i/r}function cm(e,t,n){const r=Math.max(1,Math.floor(n));return e*r+t*(r-1)}function Mc(e,t){if(!e)return 0;const n=typeof t=="number"&&Number.isFinite(t)&&t>0?t*_c:12*_c;let r=0;for(const o of e){if(o===" "){r+=.28;continue}const i=o.codePointAt(0)??0;i>=12288&&i<=12351||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=65280&&i<=65376||i>=65504&&i<=65510||i>=131072?r+=1:/^[0-9A-Z]$/.test(o)?r+=.6:/^[a-z]$/.test(o)?r+=.5:/^[\u0020-\u007f]$/.test(o)?r+=.4:r+=.75}return r*n}function dm(e,t){if(!t.autoSpan)return 1;const n=fn(t.maxSpan,t.columns);if(n<=1||t.colUnitMm<=0)return 1;const r=Mc(e,t.fontSizePt);for(let o=1;o<=n;o++)if(r<=cm(t.colUnitMm,t.gapX,o))return o;return n}function ua(e,t){const n=pt(t.columns),r=vt(t.gapX),o=lm(t.width,n,r),i=fn(t.maxSpan,n),a=[];let l=[],c=0;for(const s of e){const d=String(s??""),p=dm(d,{...t,columns:n,gapX:r,maxSpan:i,colUnitMm:o});l.length>0&&c+p>n&&(a.push({cells:l}),l=[],c=0),l.push({text:d,span:p}),c+=p}return l.length>0&&a.push({cells:l}),a}function fo(e,t){if(typeof e!="string"||!e.includes("{")||!t)return;const n=new Set;for(const r of e.matchAll(/\{([^{}]*)\}/g))for(const o of(r[1]??"").split(/[^A-Za-z0-9_\u4e00-\u9fa5.]/)){const i=o.split(".")[0];i&&!/^\d/.test(i)&&n.add(i)}for(const r of n)if(Array.isArray(t[r]))return r}function um(e,t,n){const r=vt(t),o=Mc("一",n);if(o<=0||e<=0)return da;const i=Math.floor((e+r)/(o+r));return Math.min(Ec,Math.max(da,i))}const Tc=e=>`${Math.round(e*1e3)/1e3}mm`;function pm(e){const t=pt(e.columns),n=vt(e.gapX),r=Xt(e.rowHeight);return["display:grid",`grid-template-columns:repeat(${t},minmax(0,1fr))`,`column-gap:${Tc(n)}`,`grid-auto-rows:minmax(${Tc(r)},auto)`].join(";")}const pr=25.4,Cc=10;function pa(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):Cc}const Zt=30,ho=10,fa=2,kc=0,fm=.25,ha=.254;function hm(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return null;const t=e/pr;for(let n=2;n<=8;n+=.5){const r=Math.max(1,Math.round(go(n)*t)),o=r/t;if(o>=ha-1e-9)return{barWidth:n,dotsPerModule:r,moduleWidthMm:o}}return null}function Ac(e,t){const n=hm(e);if(!n)return"";const r=s=>String(Number(s.toFixed(3))),o=`按 ${e}dpi 推荐条宽倍率 ${n.barWidth}(每模块 ${n.dotsPerModule} 个打印点 = ${r(n.moduleWidthMm)}mm,取达到 ${r(ha)}mm 下限的最小档)`,i=go(t??2),a=Math.max(1,Math.round(i*e/pr)),l=a/(e/pr),c=l>=ha-1e-9?`当前倍率 ${t??2} 折算为 ${a} 点 / ${r(l)}mm,已达标`:`当前倍率 ${t??2} 只有 ${a} 点 / ${r(l)}mm,低于下限`;return`${o};${c}。这里只提示,不会替你改值`}function fr(e){const t=typeof e=="number"&&Number.isFinite(e)?e:2;return Math.max(1,t/2)}function go(e){return fr(e)*fm}function gm(e){const{barHeightMm:t,moduleWidthMm:n,boxHeightMm:r,textModules:o}=e,i=typeof t=="number"&&Number.isFinite(t)&&t>0,a=typeof n=="number"&&Number.isFinite(n)&&n>0;if(!i||!a)return Zt;const l=Math.max(1,Math.round(t/n));if(!(typeof r=="number"&&Number.isFinite(r)&&r>0))return l;const s=typeof o=="number"&&Number.isFinite(o)&&o>0?o:0,d=Math.floor((r-s*n)/n);return Math.max(1,Math.min(l,d))}function Dc(e,t,n){const r=Math.max(1,Math.round(e*n)),o=Math.floor(t*n);if(o<1)return null;const i=Math.min(r,o);return{dotsPerModule:i,preferredDots:r,moduleWidthMm:i/n}}function mm(e){const t=go(e.barWidth),n=Math.max(1,Math.ceil(e.unitWidth)),r=e.boxWidthMm>0?e.boxWidthMm/n:Number.POSITIVE_INFINITY,o=e.dpi;if(typeof o=="number"&&Number.isFinite(o)&&o>0){const i=Dc(t,r,o/pr);if(i)return i.moduleWidthMm}return Math.min(t,r)}function Nn(e,t){const n=typeof e=="number"&&e>0?e:Number.POSITIVE_INFINITY,r=typeof t=="number"&&t>0?Math.min(n,t):n;return Number.isFinite(r)?r:0}function bm(e){const t=Math.max(1,Math.ceil(e.unitWidth)),n=Math.max(1,Math.ceil(e.unitHeight)),r=go(e.barWidth),o=Math.min(e.boxWidthMm>0?e.boxWidthMm/t:Number.POSITIVE_INFINITY,e.boxHeightMm>0?e.boxHeightMm/n:Number.POSITIVE_INFINITY),i=e.dpi;if(typeof i=="number"&&Number.isFinite(i)&&i>0){const l=Dc(r,o,i/pr);if(l)return{moduleWidthMm:l.moduleWidthMm,widthMm:t*l.moduleWidthMm,heightMm:n*l.moduleWidthMm,dotsPerModule:l.dotsPerModule,scaledDown:l.dotsPerModule<l.preferredDots}}const a=Math.min(r,o);return{moduleWidthMm:a,widthMm:t*a,heightMm:n*a,dotsPerModule:null,scaledDown:a<r}}function ga(e){const t=fr(e.barWidth),n=c=>bm({unitWidth:c.widthUnits/t,unitHeight:c.heightUnits/t,boxWidthMm:e.boxWidthMm,boxHeightMm:e.boxHeightMm,dpi:e.dpi,barWidth:e.barWidth}),r=e.measure(Zt);if(!r)return{barHeightModules:Zt,size:null};if(!(typeof e.barHeightMm=="number"&&Number.isFinite(e.barHeightMm)&&e.barHeightMm>0))return{barHeightModules:Zt,size:n(r)};const i=Math.max(0,r.heightUnits/t-Zt),a=gm({barHeightMm:e.barHeightMm,moduleWidthMm:mm({unitWidth:r.widthUnits/t,boxWidthMm:e.boxWidthMm,dpi:e.dpi,barWidth:e.barWidth}),boxHeightMm:e.boxHeightMm,textModules:i});if(a===Zt)return{barHeightModules:a,size:n(r)};const l=e.measure(a);return l?{barHeightModules:a,size:n(l)}:{barHeightModules:Zt,size:null}}const hr=["top","right","bottom","left"],ym=new Set(["rect","oval","hline","vline","table"]);function mo(e){if(!e)return!1;const t=ut(e).acceptsElementBorder;return t===void 0?!ym.has(e):t}const vm=new Set(["solid","dashed","dotted","double"]);function Oc(e,t,n){return typeof e!="number"||!Number.isFinite(e)||e<=0||t==="none"?null:{borderWidth:`${e}pt`,borderStyle:typeof t=="string"&&vm.has(t)?t:"solid",borderColor:n||"#000"}}function bo(e,t){if(!mo(e))return null;const n=Oc(t?.borderWidth,t?.borderStyle,t?.borderColor),r={},o=t?.borders;if(o)for(const i of hr){const a=o[i];if(!a)continue;const l=Oc(a.width,a.style,a.color);l&&(r[i]=l)}return!n&&Object.keys(r).length===0?null:{all:n,edges:r}}const wm=/[;"'<>\\(){}\[\]@!#]/,xm=64,gr=100,Ic=400;function Em(e){const t=(e??"").trim();return!t||t.length>xm||wm.test(t)?"":t}function Pc(e,t){if((e||"contain")!=="cover"||typeof t!="number"||!Number.isFinite(t))return;const n=Math.round(t);if(!(n<=gr))return Math.min(n,Ic)}function ma(e,t,n){const r=Em(n),o={};r&&(o.objectPosition=r);const i=Pc(e,t);return i!==void 0&&(o.transform=`scale(${Number((i/100).toFixed(2))})`,o.transformOrigin=r||"50% 50%"),o}function mr(e){return typeof e!="number"||!Number.isFinite(e)?0:(e%360+360)%360}function Rc(e,t,n){const r=e.width,o=t,i=mr(n);let a,l;if(i===0||i===180)a=r,l=o;else if(i===90||i===270)a=o,l=r;else{const c=i*Math.PI/180;a=r*Math.abs(Math.cos(c))+o*Math.abs(Math.sin(c)),l=r*Math.abs(Math.sin(c))+o*Math.abs(Math.cos(c))}return{left:e.left-(a-r)/2,top:e.top-(l-o)/2,width:a,height:l}}const Fc=385,Sm=new Set(["table","flowList"]);function $c(e){const t=ut(e).rotationExcluded;return t===void 0?Sm.has(e):t}function Nc(e){const t=ut(e).codeRotationDpiGated;return t===void 0?e==="barcode"||e==="qrcode":t}const _m="条码与二维码仅支持 90° 步进;任意角度需 385dpi 以上打印头";function Mm(e,t){if(!Nc(e))return!0;const n=t?.printerDpi;return typeof n=="number"&&n>0&&n>=Fc}function ba(e,t,n){const r=t?.rotate;if(typeof r!="number"||!Number.isFinite(r))return;const o=mr(r);if(o!==0&&!$c(e)){if(Nc(e)){if(o===90||o===180||o===270)return o;const i=t?.printerDpi;if(typeof i=="number"&&i>0&&i<Fc){const a=mr(Math.round(o/90)*90);return a===0?void 0:a}}return o}}const yo=e=>typeof e=="number"&&Number.isFinite(e)?e:0;function ft(e){const t=e??{};return{top:yo(t.marginTop),right:yo(t.marginRight),bottom:yo(t.marginBottom),left:yo(t.marginLeft)}}function vo(e){const t=ft(e);return["top","right","bottom","left"].filter(n=>t[n]!==0).map(n=>`margin-${n}:${t[n]}mm`).join(";")}function We(e={},t=e.height??0){const n=ft(e),r=e.left??0,o=e.top??0,i=e.width??100,a=t,l={left:r+n.left,top:o+n.top,right:r+n.left+i,bottom:o+n.top+a,width:i,height:a},c={left:r,top:o,right:r+n.left+i+n.right,bottom:o+n.top+a+n.bottom,width:Math.max(0,n.left+i+n.right),height:Math.max(0,n.top+a+n.bottom)};return{border:l,margin:c}}const hn={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}},Tm=new Set(["CONTINUOUS","THERMAL_57","THERMAL_80","THERMAL_110"]);function Ln(e){return Tm.has(e)}function ht(e){const t=Ln(e.paperSize),n=e.paperSize==="CUSTOM"||t?{width:e.customWidth??hn[e.paperSize].width,height:e.customHeight??hn[e.paperSize].height}:hn[e.paperSize];return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:{...n}}function gn(e){if(Ln(e.paperSize))return ht(e);const n=ht(e);return e.outputRotation===90||e.outputRotation===270?{width:n.height,height:n.width}:n}function ya(e){return Ln(e.paperSize)?0:e.outputRotation??0}function At(e){return Ln(e.paperSize)}function wo(e){return e.options?.pagination??e.pagination}function Cm(e){return e.options?.tablePagination??e.tablePagination}const km=2;function xo(e){return e.type==="table"||e.printElementType?.type==="table"}function br(e){return(e.type||e.printElementType?.type||"text")==="flowList"&&pn(e.options?.flowLayoutMode)==="dynamic"}function va(e){return xo(e)||br(e)}function Eo(e){return e.options?.fixed!==!0&&e.options?.repeatOnEveryPage===!0}function wa(e){return e.options?.fixed===!0}function Lc(e){return e.type||e.printElementType?.type||"text"}function Bc(e){return ba(Lc(e),e.options)}function mn(e,t){const n=t.get(e.id)?.measuredHeight??e.options?.height??0,r=ft(e.options),{border:o}=We({left:e.options?.left??0,top:e.options?.top??0,width:e.options?.width??100,height:n,...e.options},n),i=Bc(e),a=i===void 0?o:Rc(o,n,i);return{height:a.height,shift:o.top-a.top,top:a.top,rot:i,outerTop:a.top-r.top,outerBottom:a.top+a.height+r.bottom,outerHeight:Math.max(0,r.top+a.height+r.bottom)}}function Am(e,t){const n=e.options?.tableColWidths??[],r=xo(e)&&n.length>0?n.reduce((c,s)=>c+s,0):e.options?.width??0,o=t.get(e.id)?.measuredHeight??e.options?.height??0,{border:i}=We({...e.options,left:e.options?.left??0,top:e.options?.top??0,width:r,height:o},o),a=Bc(e);if(a===void 0)return{left:i.left,width:i.width};const l=Rc(i,o,a);return{left:l.left,width:l.width}}function Dm(e){const t=e.options??{},n=t.top??0,o=(t.tableRows??[]).reduce((a,l)=>a+(l.height??0),0),i=Math.max(t.height??0,o);return n+ft(t).top+i}function yr(e){if(br(e)){const t=e.options??{};return(t.top??0)+ft(t).top+Math.max(t.height??0,0)}return Dm(e)}function zc(e){return(t,n)=>{const r=t.options?.top??0,o=n.options?.top??0;if(r!==o)return r-o;const i=t.options?.zIndex??0,a=n.options?.zIndex??0;return i!==a?i-a:(e.get(t.id)??0)-(e.get(n.id)??0)}}function Hc(e){const n=e.filter(l=>typeof l.id=="string").map(l=>l).filter(l=>!Eo(l)&&!wa(l)),r=new Map;n.forEach((l,c)=>r.set(l.id,c));const o=[...n].sort(zc(r)),i=new Set;for(const l of o)va(l)||l.options?.groupId&&i.add(l.id);const a=new Set;for(const l of Uc(o,i).values())for(const c of l)a.add(c);return a}function Uc(e,t){const n=new Map;let r=null,o=-1,i=0,a=0;for(const l of e){if(va(l)){r=l.id,o=yr(l)+ft(l.options).bottom;const d=l.options?.tableColWidths??[],p=d.length>0?d.reduce((f,g)=>f+g,0):l.options?.width??0,u=We({...l.options,width:p}).margin;i=u.left,a=u.right,n.set(l.id,[]);continue}if(t?.has(l.id)||!r||(l.options?.top??0)<o)continue;const s=We({width:0,...l.options}).margin;s.right<=i||s.left>=a||n.get(r).push(l.id)}return n}function xa(e,t,n,r){const o=yr(e)+ft(e.options).bottom;let i=o;for(const a of t){const l=n.elements.find(c=>c.id===a);l&&(i=Math.max(i,We({width:0,...l.options}).margin.bottom))}return Math.max(i-o,0)}function qc(e,t){return Math.max(e.options?.height??0,t.get(e.id)?.measuredHeight??0)}const Wc=25.4/72;function jc(e){const t=e.options??{};if((e.type||e.printElementType?.type||"text")!=="vline")return{width:100,...t};const o=(t.borderWidth??.75)*Wc/2+.05;return{...t,left:(t.left??0)-o,width:o*2}}function bn(e){const t=We(jc(e)).margin;return[t.left,t.right]}function Om(e){const t=We(jc(e)).border;return[t.left,t.right]}function vr(e,t){return e[0]<t[1]&&t[0]<e[1]}function Gc(e,t){return[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function Im(e,t,n){const r=new Map;for(const f of n.values()){if(f.length<2)continue;const g={anchorId:f[0].id,ids:f.map(m=>m.id),forceFirstPage:f.some(m=>wo(m)?.pageable===!1),band:f.map(bn).reduce(Gc)};for(const m of f)r.set(m.id,g)}const o=e.filter(f=>!xo(f)&&!br(f)&&!f.options?.groupId&&wo(f)?.pageable!==!1),i=new Map;o.forEach(f=>i.set(f.id,f.id));const a=f=>{let g=f;for(;i.get(g)!==g;)g=i.get(g);let m=f;for(;i.get(m)!==g;){const y=i.get(m);i.set(m,g),m=y}return g},l=(f,g)=>{const m=a(f),y=a(g);m!==y&&i.set(y,m)},c=[],s=f=>We({width:100,...f.options,height:qc(f,t)},qc(f,t)).border,d=[...o].sort((f,g)=>s(f).top-s(g).top);for(const f of d){const g=s(f),m=g.top;for(let w=c.length-1;w>=0;w--)c[w].bottom<=m&&c.splice(w,1);const y=g.bottom,v=Om(f);for(const w of c)w.bottom>m&&vr(w.x,v)&&l(f.id,w.id);c.push({id:f.id,top:m,bottom:y,x:v})}const p=new Map(o.map(f=>[f.id,f])),u=new Map;for(const f of o){const g=a(f.id),m=u.get(g);m?m.push(f.id):u.set(g,[f.id])}for(const f of u.values()){if(f.length<2)continue;const g={anchorId:f[0],ids:f,forceFirstPage:!1,band:f.map(m=>bn(p.get(m))).reduce(Gc)};for(const m of f)r.set(m,g)}return r}function Ea(e,t){const n=ht(e),{top:r,bottom:o}=e.margins,i=e.header?.height??0,a=e.footer?.height??0,l=At(e),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;e.elements.forEach((M,H)=>s.set(M.id,H));const d=[...e.elements].sort(zc(s)),p=d.filter(Eo),u=d.filter(wa),f=d.filter(M=>!Eo(M)&&!wa(M)),g=p.reduce((M,H)=>{const z=mn(H,t);return{minTop:Math.min(M.minTop,z.outerTop),maxBottom:Math.max(M.maxBottom,z.outerBottom)}},{minTop:Number.POSITIVE_INFINITY,maxBottom:Number.NEGATIVE_INFINITY}),m=!l&&p.length>0,y=m?g.minTop:0,v=m?Math.max(0,g.maxBottom-y):0,w=new Set,E=new Map;for(const M of f){if(va(M))continue;const H=M.options?.groupId;if(!H)continue;w.add(M.id);const z=E.get(H);z?z.push(M):E.set(H,[M])}const T=Uc(f,w),P=new Map;for(const[M,H]of T)for(const z of H)P.set(z,M);const O=new Set,I=M=>{for(const H of M)O.add(H)},A=new Map;for(const M of d)A.set(M.id,M);const k=Im(f,t,E),R=[];let S=[],$=[],N=[],B=!1;function C(){return c-km-(B?v:0)}function ie(M){let H=0;for(const z of $)vr(M,[z.x0,z.x1])&&(H+=z.height);return Math.max(0,H)}function pe(M,H,z){N.push({x0:M[0],x1:M[1],renderBottom:H,designBottom:z})}function Ge(M){let H;for(const z of N)vr(M,[z.x0,z.x1])&&(!H||z.renderBottom>=H.renderBottom)&&(H=z);return H}function Q(M,H){const z=M.options?.top??0;if(B)return{top:ne(H),extra:0};const q=Ge(H);if(!q||q.renderBottom<=z)return{top:z,extra:0};const U=Math.max(z,q.renderBottom+z-q.designBottom);return{top:U,extra:Math.max(0,U-q.renderBottom)}}function Te(M){return C()-ie(M)}function he(M){const H=$.filter(z=>vr(M,[z.x0,z.x1]));for(let z=0;z<H.length;z++)for(let q=z+1;q<H.length;q++)if(!vr([H[z].x0,H[z].x1],[H[q].x0,H[q].x1]))return!0;return!1}function de(M,H){$.push({x0:M[0],x1:M[1],height:H})}function ye(M,H=bn(M)){return B?ne(H):M.options?.top??0}function ne(M){return(B?v:0)+ie(M)}let Pe=!1,it=[];function te(M,H,z){z<=0||it.push(`元素 ${M.id} 旋转 ${H}° 后顶部超出页首 ${Math.round(z*100)/100}mm,打印将被裁切`)}function Ve(){R.push(Pe||it.length>0?{pageIndex:R.length,sections:[...S],...Pe?{overflow:!0}:{},...it.length>0?{warnings:[...it]}:{}}:{pageIndex:R.length,sections:[...S]})}function Re(M){M>c&&(Pe=!0)}function fe(M=!1){if(S.length===0){Pe=Pe||M;return}Ve(),S=[],$=[],N=[],B=!0,Pe=!1,it=[]}let me=0;for(;me<f.length;){const M=f[me];if(P.has(M.id)&&O.has(M.id)){me++;continue}const H=k.get(M.id);if(H&&H.anchorId!==M.id){me++;continue}if(wo(M)?.pageable===!1||H?.forceFirstPage){const z=R[0],q=z?.sections??S,U=(V,ee,_)=>{z?_>0&&(z.warnings=[...z.warnings??[],`元素 ${V.id} 旋转 ${ee}° 后顶部超出页首 ${Math.round(_*100)/100}mm,打印将被裁切`]):te(V,ee,_)};if(H){let V=Number.POSITIVE_INFINITY,ee=Number.NEGATIVE_INFINITY,_=Number.NEGATIVE_INFINITY,G;for(const K of H.ids){const Z=A.get(K);if(!Z)continue;const oe=mn(Z,t);V=Math.min(V,oe.top),ee=Math.max(ee,oe.outerBottom),_=Math.max(_,We({width:0,...Z.options}).margin.bottom),oe.rot!==void 0&&(G={el:Z,rot:oe.rot})}G&&U(G.el,G.rot,-V);for(const K of H.ids)q.push({elementId:K,type:"element",renderTop:A.get(K)?.options?.top??0});!z&&_>Number.NEGATIVE_INFINITY&&pe(H.band,Math.max(ee,0),_)}else{const V=mn(M,t),ee=We({width:0,...M.options}).margin.bottom;z||pe(bn(M),V.outerBottom,ee),V.rot!==void 0&&U(M,V.rot,-V.top),q.push({elementId:M.id,type:"element",renderTop:M.options?.top??0})}me++;continue}xo(M)?me=nr(M,t,me):br(M)?me=ge(M,t,me):H?me=ro(H,me):me=no(M,t,f,me)}S.length>0&&Ve(),R.length===0&&R.push({pageIndex:0,sections:[]});const tr=new Map(d.map((M,H)=>[M.id,H]));for(const M of R){const H=M.pageIndex>0?-y:0,z=p.map(U=>({elementId:U.id,type:"element",renderTop:(U.options?.top??0)+H})),q=u.map(U=>({elementId:U.id,type:"element",renderTop:U.options?.top??0}));M.sections=[...M.sections,...z,...q].sort((U,V)=>(tr.get(U.elementId)??Number.MAX_SAFE_INTEGER)-(tr.get(V.elementId)??Number.MAX_SAFE_INTEGER));for(const U of[...p,...u]){const V=mn(U,t),ee=Eo(U)?H:0;if(V.outerBottom+ee>c&&(M.overflow=!0),V.rot!==void 0&&V.top+ee<0){const _=Math.round(-(V.top+ee)*100)/100;M.warnings=[...M.warnings??[],`元素 ${U.id} 旋转 ${V.rot}° 后顶部超出页首 ${_}mm,打印将被裁切`]}}}return to(),R;function to(){if(l)return;const M=e.margins.left;for(const H of R){const z=[];for(const q of H.sections){if(q.type==="flow-group")continue;const U=A.get(q.elementId);if(!U)continue;const{left:V,width:ee}=Am(U,t),_=M+V,G=_+ee-n.width,K=-_;G>.01?z.push(`元素 ${U.id} 超出纸面右侧 ${Math.round(G*100)/100}mm,打印将被裁切`):K>.01&&z.push(`元素 ${U.id} 超出纸面左侧 ${Math.round(K*100)/100}mm,打印将被裁切`)}z.length>0&&(H.warnings=[...H.warnings??[],...z])}}function no(M,H,z,q){const U=bn(M),V=mn(M,H),ee=V.outerHeight,_=()=>{const K=ye(M,U),Z=B?K+V.shift:K,oe=Z-(M.options?.top??0);Re(V.outerBottom+oe),V.rot!==void 0&&!B&&te(M,V.rot,-V.top),S.push({elementId:M.id,type:"element",renderTop:Z}),de(U,ee),pe(U,Z+V.outerHeight,We({width:0,...M.options}).margin.bottom)};if(!B&&V.outerBottom<=c&&he(U)||ee<=Te(U)){if(_(),wo(M)?.keepWithNext&&q+1<z.length){const K=z[q+1],Z=mn(K,H).outerHeight;if(ee+Z>C())return q+1;Z>Te(U)&&(S.pop(),$.pop(),fe(),_())}return q+1}return fe(),_(),q+1}function ro(M,H){const z=M.ids.map(oe=>A.get(oe)).filter(oe=>!!oe);let q=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,V=Number.NEGATIVE_INFINITY,ee;for(const oe of z){const be=mn(oe,t);q=Math.min(q,be.outerTop),U=Math.max(U,be.outerBottom),V=Math.max(V,We({width:0,...oe.options}).margin.bottom),be.rot!==void 0&&(ee={el:oe,rot:be.rot})}const _=Math.max(U-q,0),G=M.band,K=()=>{const oe=B?ne(G)-q:0;Re(q+oe+_),ee&&!B&&te(ee.el,ee.rot,-q);for(const be of z)S.push({elementId:be.id,type:"element",renderTop:(be.options?.top??0)+oe});de(G,_),pe(G,q+oe+_,V)};if(_<=Te(G))return K(),H+1;const Z=ne(G)+(B?0:q);return fe(Z+_>c),K(),H+1}function nr(M,H,z){const q=M.options??{},U=q._renderRows??[],V=H.get(M.id)?.measuredRowHeights??[],ee=(q._subtotalTemplates?.length??0)>0,_=(q._summaryRows?.length??0)>0,G=ee?Vc(U,V,"subtotal"):0,K=_?Vc(U,V,"summary"):0,Z=ae=>ee&&ae.type==="subtotal"||_&&ae.type==="summary",oe=U.filter(ae=>!Z(ae)),be=V.filter((ae,ue)=>!Z(U[ue]));q._renderRows=oe;const Ce=Math.min(oe.length,be.length),Ue=q._repeatHeaderCount??0,Je=H.get(M.id)?.repeatHeaderHeight??V.slice(0,Ue).reduce((ae,ue)=>ae+ue,0),Fe=C(),at=ft(q),ve=at.top+at.bottom,xe=bn(M),{top:Tt,extra:In}=Q(M,xe);!B&&In>0&&de(xe,In);let st=Tt,Ee=0;const Lt=()=>{Mt(M,H,xe);const ae=T.get(M.id)??[],ue=ae.length>0?xa(M,ae,e):0,lt=yr(M)+ft(q).bottom,ct=S[S.length-1],oo=ct?.type==="flow-group"&&ct.elementId===M.id,Bl=oo?ct.groupTop??q.top??0:st,zl=oo&&(ct.startRow??0)===(ct.endRow??0)&&!(ct.subtotal||ct.summary)?0:Ee;return pe(xe,Bl+zl+ue,lt+ue),z+1};if(Je>Fe)throw new Error(`表格 ${M.id} 的重复表头高度 (${Je.toFixed(1)}mm) 超过页面可用高度 (${Fe.toFixed(1)}mm),请减少重复表头行`);if(Ce===0)return S.push({elementId:M.id,type:"table-slice",startRow:0,endRow:0,summary:K>0,renderTop:Tt}),st=Tt,Ee=Math.max(0,K),de(xe,Math.max(0,K+ve)),Lt();const bt=be.slice(0,Ce).reduce((ae,ue)=>ae+ue,0),Ye=Math.max(0,bt+G+K+ve);if(Cm(M)?.enabled===!1){Ye>Te(xe)&&S.length>0&&fe();const ae=B?ye(M,xe):Tt;return S.push({elementId:M.id,type:"table-slice",startRow:0,endRow:Ce,subtotal:G>0,summary:K>0,renderTop:ae}),st=ae,Ee=Math.max(0,Ye),de(xe,Ye),Lt()}const yt=Pm(oe,Ce);let Vt=0,sn=!0,Ie=Tt,$e=ve;const Pn=()=>Te(xe)-$e,Rn=(ae,ue)=>{S.push({elementId:M.id,type:"table-slice",startRow:Vt,endRow:ae,subtotal:G>0,...!sn&&ue?{repeatHeader:!0}:{},renderTop:Ie}),de(xe,Math.max(0,$e)),st=Ie,Ee=Math.max(0,$e),$e=0};for(const ae of yt){const ue=be.slice(ae.start,ae.end).reduce((lt,ct)=>lt+ct,0);if(ue+G<=Pn()){$e+=ue;continue}ae.start>Vt&&(Rn(ae.start,Ue>0),sn=!1,Vt=ae.start),fe(),Ie=ye(M,xe),$e=ve,sn||($e+=Je),$e+=ue}if(Vt<Ce&&Rn(Ce,Ue>0),K>0)if(K<=Pn()){const ae=S.length-1,ue=S[ae];if(ue&&ue.type==="table-slice"&&ue.elementId===M.id)S[ae]={...ue,summary:!0},de(xe,K),Ee+=K;else{fe();const lt=ye(M,xe);S.push({elementId:M.id,type:"table-slice",startRow:Ce,endRow:Ce,summary:!0,renderTop:lt}),st=lt,Ee=Math.max(0,K+ve),de(xe,Math.max(0,K+ve))}}else{fe();const ae=ye(M,xe);S.push({elementId:M.id,type:"table-slice",startRow:Ce,endRow:Ce,summary:!0,renderTop:ae}),st=ae,Ee=Math.max(0,K+ve),de(xe,Math.max(0,K+ve))}return Lt()}function ge(M,H,z){const q=M.options??{},U=H.get(M.id)?.measuredFlowRowHeights??[],ee=(Array.isArray(q._flowRows)?q._flowRows:[]).length,_=Xt(q.flowRowHeight);if(ee===0)return z+1;const G=$n(q),K=bo(Lc(M),q),Z=Ie=>{if(!Ie)return 0;const $e=Number.parseFloat(Ie.borderWidth);return Number.isFinite($e)?$e*Wc:0},oe=Ie=>{const $e=K?.edges?.[Ie];return Z($e||(K?.all??void 0))},be=ft(q),Ce=be.top+be.bottom+G.top+G.bottom+oe("top")+oe("bottom"),Ue=bn(M);let Je=0,Fe=Q(M,Ue).top,at=B?0:Fe,ve=0,xe=Fe,Tt=0;const In=()=>(B?Te(Ue):C()-at)-ve-Ce,st=Ie=>{S.push({elementId:M.id,type:"flow-list-slice",startFlowRow:Je,endFlowRow:Ie,renderTop:Fe});const $e=B?Fe:ie(Ue),Pn=Fe+Ce+ve;de(Ue,Math.max(0,Pn-$e)),xe=Fe,Tt=Ce+ve,ve=0};let Ee=0;for(;Ee<ee;){const Ie=U[Ee]??_;if(Ie<=In()){ve+=Ie,Ee++;continue}if(Ie+Ce>C()){Ee>Je&&(st(Ee),Je=Ee),S.length>0&&fe(),Fe=ye(M,Ue),at=B?0:Fe,ve=Ie,Re(Fe+Ce+ve),Ee++;continue}if(S.length===0&&ve===0&&!B){ve+=Ie,Re(Fe+Ce+ve),Ee++;continue}Ee>Je&&(st(Ee),Je=Ee),fe(),Fe=ye(M,Ue),at=B?0:Fe}Je<ee&&st(ee),Mt(M,H,Ue);const Lt=T.get(M.id)??[],bt=Lt.length>0?xa(M,Lt,e):0,Ye=S[S.length-1],yt=Ye?.type==="flow-group"&&Ye.elementId===M.id,Vt=yt?Ye.groupTop??q.top??0:xe,sn=yt&&(Ye.startFlowRow??0)===(Ye.endFlowRow??0)?0:Tt;return pe(Ue,Vt+sn+bt,yr(M)+be.bottom+bt),z+1}function Mt(M,H,z){const q=T.get(M.id)??[];if(q.length===0)return;const U=xa(M,q,e),V=M.options??{};if(U<=Te(z)){const ee=S.length-1,_=S[ee];if(_&&(_.type==="table-slice"||_.type==="flow-list-slice")&&_.elementId===M.id){S[ee]={..._,type:"flow-group",followElementIds:q,groupTop:_.renderTop??V.top??0},de(z,U),I(q);return}}fe(),S.push({elementId:M.id,type:"flow-group",startRow:0,endRow:0,...br(M)?{startFlowRow:0,endFlowRow:0}:{},followElementIds:q,groupTop:ye(M,z)}),de(z,U),I(q)}}function Pm(e,t){const n=[];let r=0,o=1;for(let i=0;i<t;i++){for(const a of e[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 Vc(e,t,n){let r=0;for(let o=0;o<e.length;o++)e[o]?.type===n&&(r+=t[o]??0);return r}const So=25,Yc=5;function Rm(e){return Math.max(So,e)}function Kc(e,t,n=1.1){const r=t>0?e*n:e/n;return Rm(Math.round(r))}function Fm(e,t,n,r,o=.9){if(n<=0||r<=0)return 100;const i=Math.min(e/n,t/r)*o,a=Math.round(i*100);return Math.max(Yc,a)}const $m=2;function Xc(e){const t=e.gap??$m,n=[...e.units].sort((i,a)=>i.order-a.order);if(e.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 e.pinned+a.reduce((c,s)=>c+s.width+t,0)+(i.size>0?e.moreTriggerWidth+t:0)<=e.available};if(r(new Set))return{movedIds:[],overflowRemains:!1};const o=new Set;for(const i of n)if(o.add(i.id),r(o))return{movedIds:[...o],overflowRemains:!1};return{movedIds:[...o],overflowRemains:!0}}function Nm(e){const t=e.gap??4,n=e.boundaryBottom-e.triggerBottom-t,r=e.triggerTop-e.boundaryTop-t;return n>=e.overlayHeight?"down":r>n?"up":"down"}function Lm(){return ia().filter(e=>ut(e).blocked===!0)}Lm();function Bm(e){if(!e)return!1;const t=ut(e).blocked;return t===void 0?lr[e]?.blocked===!0:t}function Bn(){return`el-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Sa(e){const t=Yg(),n=ut(e).defaultOptions?.();if(n)return{...t,...n};const r=Fn(e)?.kind.defaultOptions?.();return r?{...t,...r}:t}function _a(e,t){return{id:Bn(),options:{...Sa(e),...t},printElementType:{type:e,title:ut(e).title||Fn(e)?.kind.label||String(e)}}}const zm=["left","top","width","height","marginTop","marginRight","marginBottom","marginLeft"];function Hm(e){return e.type??e.printElementType?.type}function Um(e){const t=n=>(n??[]).filter(r=>!Bm(Hm(r)));return{...e,elements:t(e.elements),header:e.header?{...e.header,elements:t(e.header.elements)}:e.header,footer:e.footer?{...e.footer,elements:t(e.footer.elements)}:e.footer}}function qm(e){const t={...e.options};for(const n of zm){const r=t[n];typeof r=="number"&&Number.isFinite(r)&&(t[n]=Wm(cr(r)))}return{...e,options:t}}function Wm(e){return Math.round(e*100)/100}function jm(e){const t={...e};delete t.firstPageOverlay;const n=Um(t);if(n.unit==="mm")return n;const r=n,o=i=>i?.map(qm)??[];return{...r,unit:"mm",elements:o(r.elements),header:r.header?{...r.header,elements:o(r.header.elements)}:r.header,footer:r.footer?{...r.footer,elements:o(r.footer.elements)}:r.footer}}const Ma="标签纸",Dt={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:Ma},LABEL_60X40:{width:60,height:40,label:"60×40mm",group:Ma},LABEL_40X30:{width:40,height:30,label:"40×30mm",group:Ma},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(e){return!!e&&Dt[e]?.continuous===!0}function Jt(e){const t=_o(e.paperSize);let n;if(e.paperSize==="CUSTOM"||t){const r=Dt[e.paperSize];n={width:e.customWidth??r?.width??210,height:e.customHeight??r?.height??297}}else{const r=Dt[e.paperSize]||Dt.A4;n={width:r.width,height:r.height}}return e.orientation==="landscape"&&!t?{width:n.height,height:n.width}:n}const Ta=.75,Gm="线型 / 宽度 / 颜色即时生效,这三行显示的就是当前生效规格:已有边框时任改一行都会按新规格铺满四边并清掉单边覆盖;上、下、左、右只给选中的边加框,撤掉一边会把它其余三边落成单边;「无」清除边框,「内部」仅表格单元格可用",wr=["top","right","bottom","left"];function Zc(e){const t={};for(const n of wr){const r=e.map(o=>!!o?.[n]);t[n]=r.length>0&&r.every(Boolean)?"on":r.some(Boolean)?"mixed":"off"}return t}const Ca=[{value:"none",label:"无"},{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],Vm=new Set(["solid","dashed","dotted","double"]),zn="none";function xr(e,t){const n=e.borders?.[t];if(n&&n.style!==zn&&typeof n.width=="number"&&Number.isFinite(n.width)&&n.width>0)return!0;const r=e.borderWidth;return e.borderStyle!==zn&&typeof r=="number"&&Number.isFinite(r)&&r>0}function Ym(e){const t={};for(const n of wr)xr(e,n)&&(t[n]=e.borders?.[n]??{width:e.borderWidth});return t}function Km(e){const t=e.borderWidth;return{width:typeof t=="number"&&Number.isFinite(t)&&t>0?t:Ta,style:e.borderStyle||"solid",color:e.borderColor||"#333333"}}function Jc(e,t,n){if(t!=="inner"){if(e.borders=void 0,t==="none"){e.borderWidth=0;return}e.borderWidth=n.width,e.borderStyle=n.style,e.borderColor=n.color}}function Qc(e){return wr.some(t=>xr(e,t))}function ka(e,t){if(!e.length)return;const n=e[0]?.[t];return e.every(r=>r[t]===n)?n:"mixed"}function Xm(e){if(!e)return;const t=typeof e.style=="string"&&Vm.has(e.style)?e.style:"solid";return{width:e.width,style:e.style===void 0?void 0:t,color:e.color}}function Zm(e){const t=wr.map(r=>e.borders?.[r]).filter(r=>typeof r?.width=="number"&&Number.isFinite(r.width)&&r.width>0).map(r=>Xm(r));if(!t.length)return;const n=ka(t,"style");return{width:ka(t,"width"),style:n===void 0?"solid":n,color:ka(t,"color")}}function ed(e){const t=e.borderWidth,n=typeof t=="number"&&Number.isFinite(t),r=Zm(e),o=n&&t>0;if(r&&!o)return r;const i=o?e.borderStyle||"solid":zn;return n?{width:t,style:i,color:e.borderColor}:{width:void 0,style:i,color:void 0}}function td(e){const t=ed(e);return{width:typeof t.width=="number"&&t.width>0?t.width:Ta,style:typeof t.style=="string"&&t.style!==zn?t.style:"solid",color:typeof t.color=="string"?t.color:"#333333"}}function Jm(e,t){e.borderWidth=t.width,e.borderStyle=t.style,e.borderColor=t.color,e.borders=void 0}function Qm(e,t,n){if(t==="borderStyle"&&n===zn){const r=Qc(e);e.borderStyle=zn,r&&(e.borderWidth=0,e.borders=void 0);return}if(!Qc(e)){if(t==="borderStyle"){e.borderStyle=n,e.borderWidth=Ta;return}Object.assign(e,{[t]:n});return}if(t==="borderWidth"&&(typeof n!="number"||!(n>0))){e.borderWidth=typeof n=="number"&&n<0?0:n,e.borders=void 0;return}Jm(e,Km({...e,[t]:n}))}function Aa(e,t,n,r){if(n!==xr(e,t)){if(!n){const o=e.borderWidth;if(typeof o!="number"||!(o>0)){nd(e,t,null);return}const i={};for(const a of wr){if(a===t)continue;const l=e.borders?.[a];i[a]={width:l?.width??o,...l?.style!==void 0?{style:l.style}:e.borderStyle!==void 0?{style:e.borderStyle}:{},...l?.color!==void 0?{color:l.color}:e.borderColor!==void 0?{color:e.borderColor}:{}}}e.borders=i,e.borderWidth=0;return}nd(e,t,r??td(e))}}function nd(e,t,n){const r={...e.borders??{}};n?r[t]={width:n.width,style:n.style,color:n.color}:delete r[t],e.borders=r}const rd=96/25.4,od=1,e0=8,t0=210;function Da(e,t){if(!e||typeof e!="object")return;if(Array.isArray(e)){for(const r of e)Da(r,t);return}const n=e;typeof n.printerDpi=="number"&&n.printerDpi>0&&t.add(n.printerDpi);for(const r of Object.keys(n)){if(r==="printerDpi")continue;const o=n[r];o&&typeof o=="object"&&Da(o,t)}}function n0(e){if(!e)return null;const t=new Set;return Da(e,t),t.size?Math.max(...t):null}function r0(e){if(!e)return t0*rd;const t=e.pages?.length?e.pages:[e];return Math.max(...t.map(n=>{const r=Jt(n);return((n.outputRotation===90||n.outputRotation===270)&&!_o(n.paperSize)?r.height:r.width)*rd}))}function o0(e,t){return e<=0||t<=0?od:Math.min(e0,Math.max(od,Math.floor(e/t)))}function i0(e,t,n){const r=[];return e&&r.push({key:"dots",value:e/96,label:`点阵 ${e}dpi`,tip:`1 屏幕像素 = 1 个打印点(${e}dpi ÷ 96dpi)。条与间隙按纸面逐点显示,不会在屏幕上糊成一片`}),r.push({key:"fit",value:o0(t,n),label:"适配",tip:"按容器宽放大到放得下整页的最大整数倍"},{key:"100",value:1,label:"100%",tip:"按 CSS 真实尺寸显示(1mm = 3.78 屏幕像素),热敏点距在此档不可分辨"},{key:"200",value:2,label:"200%",tip:"整数倍放大,避免非整数缩放带来的半像素边"},{key:"400",value:4,label:"400%",tip:"整数倍放大,避免非整数缩放带来的半像素边"}),r}function id(e){return"100"}function a0(e,t){return!e||t==="dots"?"":`条码看不清?切「点阵 ${e}dpi」档(1 屏幕像素 = 1 打印点)`}const ad="print-preview-zoom-guard";function s0(e,t){if(!e?.documentElement)return;let n=e.getElementById(ad);n||(n=e.createElement("style"),n.id=ad,(e.head??e.documentElement).appendChild(n)),n.textContent=`html{zoom:${t}}@media print{html{zoom:1 !important}}`}function l0(e,t,n){return e.some(r=>r.key===t)?t:id()}function c0(e,t){return e.find(n=>n.key===t)?.value??1}function d0(){return ia().filter(e=>ut(e).zoneAllowed===!0)}d0();function sd(e){return ut(e).zoneAllowed===!0}function u0(e){return Jt(e)}function Oa(e){const t=u0(e),n=e.margins,r=e.header.height,o=e.footer.height,i=t.width-n.left-n.right,a=t.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,t.height-n.bottom-o,i,o)}}function ld(e,t,n){const r=Oa(e);return r.footer.height>0&&n>=r.footer.top?"footer":r.header.height>0&&n<r.header.top+r.header.height?"header":"content"}function Ia(e,t){const n=e.options;n.width=Math.min(n.width,t.width),n.height=Math.min(n.height,t.height),n.left=Math.min(Math.max(0,n.left),t.width-n.width),n.top=Math.min(Math.max(0,n.top),t.height-n.height)}function p0(e,t){const n=Oa(t),r=e.zone||"content",o=n[r],i=o.left+e.options.left+e.options.width/2,a=o.top+e.options.top+e.options.height/2;let l=ld(t,i,a),c=!1;if(l!=="content"&&!sd(e.printElementType.type)&&(l="content",c=!0),l!==r){const s=n[l];e.options.left=o.left+e.options.left-s.left,e.options.top=o.top+e.options.top-s.top,e.zone=l}return l!=="content"?Ia(e,n[l]):c&&Ia(e,n.content),{rejected:c}}const Pa=22,Ra=[1,2,5,10,20,50,100,200,500,1e3];function f0(e,t=64){const n=e*3.7795275590551185;for(const r of Ra)if(r*n>=t)return r;return Ra[Ra.length-1]}function h0(e){const t=Math.floor(Math.log10(e)+1e-9),n=e/10**t;return n===5||n===1&&e>=10?e/5:n===2?e/2:null}function g0(e){return Math.round(e*1e3)/1e3}function m0(e,t,n){if(t<e||n<=0)return[];const o=h0(n)??n,i=Math.ceil(e/o-1e-9)*o,a=Math.floor((t-i)/o+1e-9),l=[];for(let c=0;c<=a;c++){const s=g0(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 cd=["#000000","#333333","#666666","#999999","#cccccc","#ffffff","#e53935","#fb8c00","#1e88e5","#43a047","#8d6e63","#00acc1"],Mo=[{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","尺寸"]},{key:"ps-margin-top",keywords:["上外边距","外边距","margintop"],default:0,defaultUnit:"mm"},{key:"ps-margin-right",keywords:["右外边距","外边距","marginright"],default:0,defaultUnit:"mm"},{key:"ps-margin-bottom",keywords:["下外边距","外边距","marginbottom"],default:0,defaultUnit:"mm"},{key:"ps-margin-left",keywords:["左外边距","外边距","marginleft"],default:0,defaultUnit:"mm"}]},{group:"appearance",groupLabel:"外观",items:[{key:"ap-font-family",keywords:["字体","字体名","字体族","fontfamily"]},{key:"ap-font-size",keywords:["字体大小","fontsize","字号"]},{key:"ap-font-weight",keywords:["字体粗细","粗体","bold"]},{key:"ap-align",keywords:["对齐","align"]},{key:"ap-vertical-align",keywords:["垂直对齐","verticalalign","顶对齐","底对齐"]},{key:"ap-color",keywords:["颜色","color"]},{key:"ap-bg-color",keywords:["背景色","background"]},{key:"ap-line-height",keywords:["行高","lineheight"]},{key:"ap-letter-spacing",keywords:["字间距","letterspacing"]},{key:"ap-text-fit",keywords:["溢出","溢出显示","截断","自动缩小","自适应行高","textfit","overflow"]},{key:"ap-shrink-min",keywords:["最小字号","缩放下限","shrinkminfontsize"],default:bc,defaultUnit:"pt"},{key:"ap-word-wrap",keywords:["自动换行","不换行","wordwrap"]},{key:"ap-keep-line-breaks",keywords:["保留换行符","换行符","手动换行","保留空格","连续空格","行首空格","keeplinebreaks"]},{key:"ap-long-text-indent",keywords:["首行缩进","缩进","indent","longtextindent","两字符","段首"],tip:"长文本每段首行空出的宽度,单位「字符」:填 2 即缩进两个汉字宽(中文排版惯例),按 em 落纸——字号被「自动缩小」压小时缩进同步变窄。仅长文本元素生效,写在普通文本上不生效"},{key:"ap-img-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover","填充","裁剪","剪裁","锚点"],tip:"图片在元素框内的缩放方式:包含=完整显示、可能留白;剪裁=铺满框并按「裁剪锚点」取一块;拉伸=填满框会变形;原始尺寸与缩小不放大。画布与三条出纸链路同一口径(缺省包含)"},{key:"ap-img-object-position",keywords:["裁剪锚点","剪裁锚点","锚点","objectposition","object-position","对齐点","上移","头顶"],tip:"取位(仅「剪裁」档有这一行):剪裁把图等比铺满元素框,多出来的那一条边按这里选的位置取舍。先选位置档(贴边/居中/贴另一头),再按百分比微调,0 贴左/贴顶,100 挪到另一头,水平与垂直各自独立;缺省取正中间(保住证件照头顶就选顶部)。其余缩放模式图比框小或刚好铺满,没有可裁的边,所以不出本行"},{key:"ap-img-fit-scale",keywords:["放大比例","剪裁放大","放大倍数","取景","裁切范围","fitscale","zoom"],default:gr,defaultUnit:"%",tip:"剪裁放大:等比铺满之后把画面再推大这么多,两轴才真的各多出一条边可裁——图与框同比例时不放大就什么都裁不掉。100=不放大(缺省),上限 400;超出框的部分由元素框裁掉。锚点选中的那一点既是取位的钉住点、也是放大的中心,两者共用同一个值。仅「剪裁」档生效,其余缩放模式不出本行"},{key:"ap-rotate",keywords:["旋转","角度","rotate","angle","顺时针","逆时针","90度","直角"],tip:"元素绕自身中心旋转的角度(度,0~359):出纸时按旋转后外接盒分页与结算,底部放不下自动移页,超出纸面左右缘或顶部会被裁切并给出纸提示。表格、流式列表与表格下方跟随区的元素不支持旋转(这三类不出本行);条码与二维码的任意角度需 385dpi 以上打印头,低分辨率打印机只按 90° 步进出纸"}]},{group:"flow-list",groupLabel:"流式列表",items:[{key:"fl-columns",keywords:["每行列数","列数","栏数","几列","flowcolumns"],tip:"一行排几个单元,必须由你指定——不随内容自动算列数。填的列数乘单元宽放不下元素框时只给提示、不改你的数,出纸按你填的排"},{key:"fl-row-height",keywords:["行高","每行高度","单元高度","flowrowheight"],tip:"每个单元行的最低高度(毫米),与表格行高同一口径:内容比它高时这一行会撑高,不会裁字"},{key:"fl-gap-x",keywords:["单元间距","横向间距","格间距","列间距","flowgapx"],tip:"相邻单元之间的横向留白(毫米);纵向不留缝,行与行的距离由行高承担"},{key:"fl-auto-span",keywords:["自适应","跨列","内容过长","占两列","自动换行","flowsautspan","flowautospan"],tip:"单元内容比一列还宽时,让它占掉两个或更多列位;当前行剩不够放就把整个单元挪到下一行行首(绝不把词切两半)。默认关——开着时出纸栏数由字号与框宽决定"},{key:"fl-max-span",keywords:["最多跨几列","跨列上限","flowmaxspan"],tip:"跨列的列数上限,最大只能等于「每行列数」:把每行列数改小时,这里会被一并顶回去"},{key:"fl-layout-mode",default:"fixed",keywords:["布局模式","容器模式","固定高度","动态分页","自动高度","flowlayoutmode"],tip:"容器高度由谁决定:固定高度=维持设计高度、一框一页,超高裁切(存量模板默认值,输出不变);动态分页=容器高度由内容撑开,内容满页后按行续页,每一页都画完整边框,元素下方的跟随区与表格同一套规则"},{key:"fl-padding-top",keywords:["上内边距","内边距","顶边距","flowpaddingtop"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器顶部与第一行内容之间的留白(毫米),仅动态模式生效;每页切片都按它留白并计入分页预算,负值与非法值按 0 处理"},{key:"fl-padding-right",keywords:["右内边距","内边距","右边距","flowpaddingright"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器右侧与内容之间的留白(毫米),会压缩参与列宽估算的内容宽度,仅动态模式生效"},{key:"fl-padding-bottom",keywords:["下内边距","内边距","底边距","flowpaddingbottom"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器底部与最后一行内容之间的留白(毫米),每页切片都按它留白并计入分页预算,仅动态模式生效"},{key:"fl-padding-left",keywords:["左内边距","内边距","左边距","flowpaddingleft"],default:0,defaultUnit:"mm",tip:"动态分页模式下容器左侧与内容之间的留白(毫米),会压缩参与列宽估算的内容宽度,仅动态模式生效"}]},{group:"code",groupLabel:"条码设置",items:[{key:"cd-type",keywords:["码制","条码类型","条形码类型","barcodetype","code128","ean13","code39","itf14"]},{key:"cd-dpi",keywords:["打印机分辨率","dpi","打印点","点阵对齐","203","300"]},{key:"cd-bar-width",keywords:["条宽","条粗细","barwidth","模块宽"]},{key:"cd-bar-quiet-zone",keywords:["条码静区","条码白边","条形码留白","条码空白边","barquietzone"],default:Cc,defaultUnit:"模块",tip:"条形码左右两端的空白格数(1 格 = 1 条宽):缺省 10,正是一维码码制要求的下限;数值越小白边越窄、同样的框内条越粗(可放大)。填 0 即不留白边,但静区参与「条→空→条」跳变,紧邻文字或表格线时可能扫不出,需实打验证"},{key:"cd-bar-height",keywords:["条高","条码高度","条区高度","条码多高","barheight"],default:Zt,defaultUnit:"模块",tip:"黑白条本体的目标高度(mm,不含下方文字):折算粒度就是每模块物理宽,所以只能精确到它的整数倍。条宽优先——可用框高装不下时期望条高让位,绝不把条宽挤窄(热敏出纸清晰度靠条宽)。与「最大高度」分工不同:那条限的是整图(含文字)的上限"},{key:"cd-show-text",keywords:["显示文本","条码文本","显示数字"]},{key:"cd-font-size",keywords:["条码字号","文本字号"],default:ho,defaultUnit:"模块"},{key:"cd-ec-level",keywords:["纠错级别","容错","qrcodelevel"]},{key:"cd-quiet-zone",keywords:["静区","静区宽度","白边","空白边","留白","铺满","quietzone"],default:kc,defaultUnit:"模块",tip:"二维码四周留出的空白格数:0 即不留白边、码面等比铺满元素框(此时靠框外的白纸充当静区);数值越大白边越宽、码面在框内越小(缺省 0,需 ISO/IEC 18004 推荐静区时填 4)"},{key:"cd-fit",keywords:["缩放模式","拉伸","等比","fit","contain","cover"]},{key:"cd-max-width",keywords:["最大宽度","最大宽","maxwidth"]},{key:"cd-max-height",keywords:["最大高度","最大高","maxheight"]}]},{group:"content",groupLabel:"内容",items:[{key:"ct-title",keywords:["内容","文本","title"]},{key:"ct-formatter",keywords:["格式化","表达式","formatter"]},{key:"ct-table-mode",keywords:["数据模式","静态布局","动态数据"]},{key:"ct-table-source",keywords:["数据源","列表字段"]},{key:"ct-table-font",keywords:["默认字号","默认颜色","默认内边距"]},{key:"ct-table-cols",keywords:["列宽","表格列"]}]},{group:"border-bg",groupLabel:"边框与背景",items:[{key:"bb-border-style",keywords:["线型","边框线型","实线","虚线","点线","双线","borderstyle"]},{key:"bb-border-width",keywords:["边框宽度","border"]},{key:"bb-border-color",keywords:["边框颜色"]},{key:"bb-bg-color",keywords:["背景色","background"]}]},{group:"binding",groupLabel:"字段绑定",items:[{key:"bd-formatter",keywords:["格式化","表达式","formatter","fx","字段","绑定","field"]},{key:"bd-content",keywords:["内容","表达式","文本","变量"]}]},{group:"pagination",groupLabel:"分页",items:[{key:"pg-enabled",keywords:["分页","pagination","启用分页"]},{key:"pg-pageable",keywords:["参与分页","pageable"]},{key:"pg-keep-with-next",keywords:["同页","keepWithNext"]}]},{group:"advanced",groupLabel:"高级",items:[{key:"ad-locked",keywords:["锁定","lock"]},{key:"ad-fixed",keywords:["每页重复","repeat"]},{key:"ad-fixed-position",keywords:["固定","每页固定","fixed"]},{key:"ad-z-index",keywords:["层级","zindex"]},{key:"ad-delete",keywords:["删除"]}]}];function Ae(e){for(const t of Mo){const n=t.items.find(r=>r.key===e);if(n)return n.tip??""}return""}function dd(e,t){const n=e.trim().toLowerCase();return n?t.some(r=>r.toLowerCase().includes(n)):!0}function b0(e){const t=[],n=new Set;for(const r of Mo){const o=r.items.filter(i=>dd(e,[...i.keywords,r.groupLabel]));if(o.length>0){t.push(r.group);for(const i of o)n.add(i.key)}}return{groups:t,itemKeys:n}}function y0(e){for(const t of Mo)for(const n of t.items)if(n.key===e&&n.default!==void 0)return{value:n.default,unit:n.defaultUnit}}function v0(e){return/[\u1100-\u115F\u2E80-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/.test(e)}function w0(e){let t=0;for(const n of e)t+=v0(n)?1:.55;return t}function x0(e){return w0(e)>=4}const E0=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),S0=new Set(["new","function","class","this","delete","typeof","void","in","of","var","let","const","return","if","while","for"]);function Fa(e){const t=[];let n=0;const r=e.length;for(;n<r;){const o=e[n];if(/\s/.test(o)){n++;continue}if(/[0-9]/.test(o)||o==="."&&n+1<r&&/[0-9]/.test(e[n+1])){let l=n;for(;l<r&&/[0-9.]/.test(e[l]);)l++;t.push({type:"num",value:e.slice(n,l),position:n}),n=l;continue}if(o==="'"||o==='"'){let l=n+1,c="";for(;l<r&&e[l]!==o;)e[l]==="\\"&&l+1<r?(c+=e[l+1],l+=2):(c+=e[l],l++);if(l>=r)throw new Error("字符串未闭合");t.push({type:"str",value:c,position:n}),n=l+1;continue}if(/[A-Za-z_$\u4e00-\u9fff]/.test(o)){let l=n;for(;l<r&&/[A-Za-z0-9_$\u4e00-\u9fff]/.test(e[l]);)l++;const c=e.slice(n,l);if(S0.has(c))throw new Error(`不允许使用关键字: ${c}`);if(E0.has(c))throw new Error(`禁止访问: ${c}`);c==="true"||c==="false"?t.push({type:"bool",value:c,position:n}):t.push({type:"ident",value:c,position:n}),n=l;continue}const i=e.slice(n,n+3);if(i==="==="||i==="!=="){t.push({type:"punc",value:i,position:n}),n+=3;continue}const a=e.slice(n,n+2);if(a==="=>")throw new Error("不允许函数定义");if(["==","!=","<=",">=","&&","||"].includes(a)){t.push({type:"punc",value:a,position:n}),n+=2;continue}if(o==="=")throw new Error("不允许赋值");if(o===";")throw new Error("不允许多条语句");if("+-*/%()[]{},:.?!<>".includes(o)){t.push({type:"punc",value:o,position:n}),n++;continue}throw new Error(`非法字符: ${o}`)}return t}function $a(e){return new _0(e).parse()}class _0{constructor(t){this.pos=0,this.tokens=t}parse(){const t=this.parseTernary();if(this.pos<this.tokens.length)throw new Error(`表达式存在多余内容: ${this.tokens[this.pos].value}`);return t}peek(){return this.tokens[this.pos]}next(){const t=this.tokens[this.pos++];if(!t)throw new Error("表达式意外结束");return t}eatPunc(t){const n=this.peek();return n&&n.type==="punc"&&n.value===t?(this.pos++,!0):!1}expectPunc(t){if(!this.eatPunc(t)){const n=this.peek()?.position??0;throw new Error(`位置 ${n}: 期望 "${t}"`)}}parseTernary(){const t=this.parseLogicalOr();if(this.eatPunc("?")){const n=this.parseTernary();this.expectPunc(":");const r=this.parseTernary();return{type:"ternary",cond:t,consequent:n,alternate:r}}return t}parseLogicalOr(){let t=this.parseLogicalAnd();for(;this.eatPunc("||");){const n=this.parseLogicalAnd();t={type:"binary",op:"||",left:t,right:n}}return t}parseLogicalAnd(){let t=this.parseEquality();for(;this.eatPunc("&&");){const n=this.parseEquality();t={type:"binary",op:"&&",left:t,right:n}}return t}parseEquality(){let t=this.parseRelational();for(;;){const n=this.peek();if(n?.type==="punc"&&["==","!=","===","!=="].includes(n.value)){this.pos++;const r=this.parseRelational();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseRelational(){let t=this.parseAdditive();for(;;){const n=this.peek();if(n?.type==="punc"&&["<",">","<=",">="].includes(n.value)){this.pos++;const r=this.parseAdditive();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseAdditive(){let t=this.parseMultiplicative();for(;;){const n=this.peek();if(n?.type==="punc"&&(n.value==="+"||n.value==="-")){this.pos++;const r=this.parseMultiplicative();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseMultiplicative(){let t=this.parseUnary();for(;;){const n=this.peek();if(n?.type==="punc"&&["*","/","%"].includes(n.value)){this.pos++;const r=this.parseUnary();t={type:"binary",op:n.value,left:t,right:r}}else return t}}parseUnary(){const t=this.peek();if(t?.type==="punc"&&["!","-","+"].includes(t.value)){this.pos++;const n=this.parseUnary();return{type:"unary",op:t.value,arg:n,prefix:!0}}return this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.eatPunc(".")){const n=this.next();if(n.type!=="ident")throw new Error(`位置 ${n.position}: 成员访问需要属性名`);t={type:"member",object:t,property:n.value,computed:!1}}else if(this.eatPunc("[")){const n=this.parseTernary();this.expectPunc("]"),n.type==="str"?t={type:"member",object:t,property:n.value,computed:!1}:t={type:"member",object:t,property:n.name??String(n.value),computed:!0}}else if(this.peek()?.type==="punc"&&this.peek()?.value==="("&&(t.type==="ident"||t.type==="member")){this.pos++;const n=this.parseArgs();t={type:"call",callee:t,args:n}}else return t}parseArgs(){const t=[];if(this.eatPunc(")"))return t;for(;;){if(t.push(this.parseTernary()),this.eatPunc(")"))return t;this.expectPunc(",")}}parsePrimary(){const t=this.next();if(t.type==="num"){const n=Number(t.value);if(isNaN(n))throw new Error(`非法数字: ${t.value}`);return{type:"num",value:n}}if(t.type==="str")return{type:"str",value:t.value};if(t.type==="bool")return{type:"bool",value:t.value==="true"};if(t.type==="ident")return{type:"ident",name:t.value};if(t.value==="("){const n=this.parseTernary();return this.expectPunc(")"),n}if(t.value==="["){const n=[];if(!this.eatPunc("]"))for(;n.push(this.parseTernary()),!this.eatPunc("]");)this.expectPunc(",");return{type:"array",elements:n}}if(t.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(`位置 ${t.position}: 意外的符号: ${t.value}`)}}const ud=20,M0=8;function et(e,t=0){if(typeof e=="number")return Number.isFinite(e)?e:t;if(typeof e=="string"){const n=e.trim();if(n==="")return t;const r=Number(n);return Number.isFinite(r)?r:t}return e==null?t:typeof e=="boolean"?e?1:0:t}function T0(e){if(typeof e=="number")return Number.isFinite(e);if(typeof e=="string"){const t=e.trim();return t!==""&&Number.isFinite(Number(t))}return!1}function Hn(e){return!Number.isFinite(e)||Number.isInteger(e)||Math.abs(e)>=1e15?e:Number(e.toPrecision(12))}function Un(e){if(!Number.isFinite(e)||Number.isInteger(e))return 0;const t=String(e);if(t.includes("e")||t.includes("E"))return 0;const n=t.indexOf(".");return n===-1?0:t.length-n-1}function Na(e,t){if(!Number.isFinite(e))return 0;const n=Math.min(Math.max(t,0),12);if(n===0)return Math.round(e);const r=10**n,o=e*r;return!Number.isFinite(o)||Math.abs(o)>=1e15?Hn(e):Math.round(o)/r}function La(e,t){const n=et(e),r=et(t),o=n+r;return Na(o,Math.max(Un(n),Un(r)))}function Ba(e,t){const n=et(e),r=et(t),o=n-r;return Na(o,Math.max(Un(n),Un(r)))}function pd(e,t){const n=et(e),r=et(t),o=n*r;return Na(o,Un(n)+Un(r))}function fd(e,t){const n=et(e),r=et(t);return r===0?0:Hn(n/r)}function C0(e,t){const n=et(e),r=et(t);return r===0?0:Hn(n%r)}function k0(e){if(e==null)return 2;const t=Math.trunc(et(e,2));return Number.isFinite(t)?Math.min(Math.max(t,-ud),ud):2}function To(e,t,n){const r=et(e,0),o=k0(t);if(r===0)return 0;if(Math.abs(r)>=1e21)return Hn(r);const i=Math.max(o,0)+M0,a=r.toFixed(i);if(!/^-?\d+(\.\d+)?$/.test(a))return Hn(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 g=u%d,m=2n*g;n==="up"?g!==0n&&(f+=1n):n!=="down"&&m>=d&&(m>d||n==="half-up"||f%2n===1n)&&(f+=1n);const y=p*f;return Hn(o>=0?Number(y)/10**o:Number(y)*10**-o)}const za={Math,Number,String,Boolean,parseInt,parseFloat,isNaN,true:!0,false:!1,null:null,undefined:void 0},A0=new Set(["constructor","__proto__","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"]),D0=new Set(["Number","String","Boolean","parseInt","parseFloat","isNaN"]);function Ke(e,t,n={}){switch(e.type){case"num":return e.value;case"str":return e.value;case"bool":return e.value;case"ident":return O0(e.name,t);case"binary":return I0(e,t,n);case"unary":return P0(e,t,n);case"ternary":return Ke(e.cond,t,n)?Ke(e.consequent,t,n):Ke(e.alternate,t,n);case"member":return $0(e,t,n);case"call":return N0(e,t,n);case"array":return e.elements.map(r=>Ke(r,t,n));case"object":return Object.fromEntries(e.properties.map(r=>[r.key,Ke(r.value,t,n)]))}}function O0(e,t,n){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];if(Object.prototype.hasOwnProperty.call(za,e))return za[e];throw new Error(`未定义的标识符: ${e}`)}function I0(e,t,n){const r=Ke(e.left,t,n),o=Ke(e.right,t,n);switch(e.op){case"+":return F0(r,o)?La(r,o):R0(r,o);case"-":return Ba(r,o);case"*":return pd(r,o);case"/":return fd(r,o);case"%":return C0(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(`未知运算符: ${e.op}`)}}function P0(e,t,n){const r=Ke(e.arg,t,n);switch(e.op){case"-":return Ba(0,r);case"+":return et(r);case"!":return!r;default:throw new Error(`未知一元运算符: ${e.op}`)}}function R0(e,t){return`${e==null?"":String(e)}${t==null?"":String(t)}`}function F0(e,t){const n=hd(e),r=hd(t);return n==="other"||r==="other"?!1:n==="num"||r==="num"}function hd(e){return e==null||e===""?"neutral":T0(e)?"num":"other"}function $0(e,t,n){const r=Ke(e.object,t,n);if(r==null)throw new Error("无法访问空值的属性");if(A0.has(e.property))throw new Error(`禁止访问属性: ${e.property}`);return r[e.property]}function N0(e,t,n){if(e.callee.type==="ident"&&D0.has(e.callee.name)){const o=za[e.callee.name],i=e.args.map(a=>Ke(a,t,n));return o(...i)}if(e.callee.type==="member"&&e.callee.object.type==="ident"&&e.callee.object.name==="Math"){const o=Math[e.callee.property];if(typeof o!="function")throw new Error(`Math.${e.callee.property} 不是方法`);const i=e.args.map(a=>Ke(a,t,n));return o(...i)}let r;if(e.callee.type==="ident")r=e.callee.name;else if(e.callee.type==="member")throw new Error("不支持方法调用,请使用顶级函数");if(r&&n[r]){const o=e.args.map(i=>Ke(i,t,n));return n[r](...o)}throw r&&Object.prototype.hasOwnProperty.call(t,r)?new Error(`${r} 不是函数`):new Error(`不允许调用: ${r??"表达式"}`)}function L0(e){const t=[];let n=0;const r=e.length;for(;n<r;){if(e[n]==="{"){let i=1,a=n+1;for(;a<r&&i>0;)e[a]==="{"?i++:e[a]==="}"&&i--,a++;if(i!==0)throw new Error(`位置 ${n}: 花括号未闭合`);const l=e.slice(n+1,a-1);if(l.trim()==="")throw new Error(`位置 ${n}: 空表达式`);const c=Fa(l),s=$a(c);t.push({type:"expr",expression:s}),n=a;continue}let o=n;for(;o<r&&e[o]!=="{";)e[o]==="\\"&&o+1<r&&(e[o+1]==="{"||e[o+1]==="}")?o+=2:o++;t.push({type:"text",value:e.slice(n,o).replace(/\\([{}])/g,"$1")}),n=o}return{type:"template",parts:t}}function B0(e,t,n={}){let r="";for(const o of e.parts)if(o.type==="text")r+=o.value;else{const i=Ke(o.expression,t,n);r+=String(i??"")}return r}function gd(e,t={}){const n=L0(e);return r=>B0(n,r,t)}function Er(e,t){if(e==null||t==null)return;if(typeof e=="object"&&t in e)return e[t];const n=t.split(".");let r=e;for(const o of n){if(r==null)return;r=r[o]}return r}function md(e){const t=Number(e);if(isNaN(t))return String(e);const n=t<0?"-":"",r=Math.abs(t),[o,i]=r.toFixed(2).split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,",");return`${n}${a}.${i}`}function bd(e,t){let n;if(e instanceof Date)n=e;else if(typeof e=="number")n=new Date(e);else if(typeof e=="string")n=new Date(e);else return String(e);if(isNaN(n.getTime()))return String(e);const r=o=>String(o).padStart(2,"0");return t.replace("YYYY",String(n.getFullYear())).replace("MM",r(n.getMonth()+1)).replace("DD",r(n.getDate())).replace("HH",r(n.getHours())).replace("mm",r(n.getMinutes())).replace("ss",r(n.getSeconds()))}const Ha=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],z0=["","拾","佰","仟"],H0=["","万","亿","万亿","亿亿"];function U0(e){let t="",n=!1;for(let r=3;r>=0;r--){const o=Math.floor(e/10**r)%10;if(o===0){t&&(n=!0);continue}n&&(t+="零",n=!1),t+=Ha[o]+z0[r]}return t}function yd(e){const t=Number(e);if(isNaN(t))return String(e);if(t===0)return"零元整";const n=t<0?"负":"",[r,o]=Math.abs(t).toFixed(2).split("."),i=Math.ceil(r.length/4);let a="",l=!1;for(let d=i-1;d>=0;d--){const p=r.length-d*4,u=parseInt(r.slice(Math.max(0,p-4),p),10);if(u===0){a&&(l=!0);continue}a&&(l||u<1e3)&&(a+="零"),l=!1,a+=U0(u)+(H0[d]??"")}a=`${a||"零"}元`;const c=parseInt(o[0],10),s=parseInt(o[1],10);return c===0&&s===0?a+="整":(c===0?a+="零":a+=Ha[c]+"角",s>0&&(a+=Ha[s]+"分")),n+a}function vd(e,t,n){return e?t:n}function Ua(e,t){return e.reduce((n,r)=>n+(Number(Er(r,t))||0),0)}function wd(e,t){return e.length===0?0:Ua(e,t)/e.length}function xd(e,t){return e.length}function Ed(e,t){return e.length===0?0:Math.min(...e.map(n=>Number(Er(n,t))||0))}function Sd(e,t){return e.length===0?0:Math.max(...e.map(n=>Number(Er(n,t))||0))}function _d(...e){return e.reduce((t,n)=>La(t,n),0)}function Md(...e){return e.length===0?0:e.slice(1).reduce((t,n)=>Ba(t,n),La(e[0],0))}function Td(...e){return e.length===0?0:e.reduce((t,n)=>pd(t,n),1)}function Cd(e,t){return fd(e,t)}function kd(e,t){return To(e,t,"half-up")}function Co(e,t){return To(e,t,"up")}function ko(e,t){return To(e,t,"down")}function Ad(e,t){return To(e,t,"half-even")}class q0{constructor(){this.functions={}}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Fa(t),o=$a(r);return Ke(o,n,this.functions)}render(t,n){return gd(t,this.functions)(n)}}const qa=new q0,W0={MONEY:md,DATE:bd,UPPER:yd,IF:vd,CONCAT:(...e)=>e.filter(t=>t!=null).map(String).join(""),IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,LEN:e=>String(e).length,ADD:_d,SUB:Md,MUL:Td,DIV:Cd,ROUND:kd,ROUNDUP:Co,CEIL:Co,ROUNDDOWN:ko,FLOOR:ko,ROUNDBANK:Ad};for(const[e,t]of Object.entries(W0))qa.registerFunction(e,t);function j0(e,t,n){switch(e.toUpperCase()){case"SUM":return Ua(n,t);case"AVG":return wd(n,t);case"COUNT":return xd(n);case"MIN":return Ed(n,t);case"MAX":return Sd(n,t);default:return 0}}function G0(e,t){return qa.evaluate(e,t)}function Qt(e,t,n){if(!e)return"";if(!e.includes("{"))return e;const r=Array.isArray(t.rows)?t.rows:[],o=e.replace(/\{([^}]+)\}/g,(i,a)=>{let l=a.trim();return l=l.replace(/\b(SUM|AVG|COUNT|MIN|MAX)\(([^)]+)\)/g,(c,s,d)=>{const p=d.trim().replace(/^['"]|['"]$/g,"");return String(j0(s,p,r))}),`{${l}}`});try{return qa.render(o,t)}catch{return n??e}}function Dd(e,t,n,r){const o={...Oo(),...t??{}},i=JSON.parse(JSON.stringify(e));i.header?.elements&&(i.header.elements=i.header.elements.map(l=>Wa(l,o,n))),i.footer?.elements&&(i.footer.elements=i.footer.elements.map(l=>Wa(l,o,n))),i.elements=i.elements.map(l=>Wa(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 Wa(e,t,n){const r={...e,options:{...e.options}};if(!(r.type==="flowList"||r.printElementType?.type==="flowList")&&typeof r.options.formatter=="string"){const c=r.options.formatter;if(_r(c))r.options.rawFormatter=c;else{const s=r.type||r.printElementType?.type,d=typeof r.options.exampleValue=="string"?r.options.exampleValue:jg(s);r.options.formatter=Qt(c,t,d)}}if((r.type==="image"||r.printElementType?.type==="image")&&typeof r.options.src=="string"){let c=r.options.src;c.includes("{")&&(c=Qt(c,t)),c&&n&&!/^([a-z][a-z\d+\-.]*:|\/\/)/i.test(c)&&(c=n.replace(/\/+$/,"")+(c.startsWith("/")?c:`/${c}`)),r.options.src=c}(r.type==="table"||r.printElementType?.type==="table")&&Y0(r,t),(r.type==="flowList"||r.printElementType?.type==="flowList")&&V0(r,t);const a=r.type||r.printElementType?.type||"text",l=Fn(a)?.binding?.bind;if(l){const c=l(r.options,t);c&&typeof c=="object"&&Object.assign(r.options,c)}return r}function V0(e,t){const n=typeof e.options.formatter=="string"?e.options.formatter:"",r={...e.options,dataSource:e.options.dataSource??fo(n,t)},{list:o,key:i}=Od(r,t),a=c=>i?{...t,...c,[i]:c}:{...t,...c},l=o.map(c=>n?_r(n)?n:Qt(n,a(c)):String(c??""));if(e.options._flowItems=l,e.options._flowRawFormatter=_r(n)?n:void 0,pn(e.options.flowLayoutMode)==="dynamic"){const c=Sc(e.options.width??0,$n(e.options)),s=l.length>0?l:String(e.options.testData??"").split(/\r?\n/).map(d=>d.trim()).filter(Boolean);e.options._flowRows=ua(s,{width:c,columns:pt(e.options.flowColumns),gapX:vt(e.options.flowGapX),fontSizePt:e.options.fontSize??12,autoSpan:e.options.flowAutoSpan===!0,maxSpan:fn(e.options.flowMaxSpan,e.options.flowColumns)})}}function Od(e,t){const n=e.dataSource??e.fields?.[0]?.dataSource??e.fields?.[0]?.field;if(n&&Array.isArray(t[n]))return{list:t[n],key:n};for(const[r,o]of Object.entries(t))if(Array.isArray(o))return{list:o,key:r};return{list:[],key:n}}function Y0(e,t){const n=e.options,r=n.tableRows;if(!Array.isArray(r)||r.length===0)return;const o=n.tableMode??"dynamic",{list:i,key:a}=o==="dynamic"?Od(n,t):{list:[],key:void 0},l=g=>a?{...t,...g,[a]:g}:{...t,...g},c=a?i.map(g=>({...g,[a]:g})):i,s=[],d=[],p=[],u=[];let f=-1;for(const g of r){if(o==="dynamic"&&g.type==="data"){K0(g.cells);for(const m of i){f<0&&(f=s.length);const y=l(m);s.push(Do(g,v=>Ao(v,y))),d.push(y)}continue}if(o==="dynamic"&&g.type==="subtotal"){const m=Do(g,y=>Ao(y,{rows:c,...t}),!0);p.push(m),s.push(m);continue}if(o==="dynamic"&&g.type==="summary"){const m=Do(g,y=>Ao(y,{rows:c,...t}));u.push(m),s.push(m);continue}s.push(Do(g,m=>Ao(m,t)))}n._renderRows=s,n._repeatHeaderCount=X0(r),n._dataRowCtx=d,n._dataStartIdx=f<0?s.length:f,n._subtotalTemplates=p,n._summaryRows=u,n._mainData=t}function K0(e){const t=new Set;e.forEach((n,r)=>{if(!n||n.merged)return;const o=Math.max(n.colspan??1,1);for(let i=1;i<o;i++)t.add(r+i)}),e.forEach((n,r)=>{n.rowspan&&(n.rowspan=1),n.merged&&!t.has(r)&&(n.merged=!1)})}function Ao(e,t){const n=e.formatter;return n?_r(n)?n:Qt(n,t):""}function Do(e,t,n=!1){return{type:e.type,height:e.height??8,cells:e.cells.map(r=>({content:r.merged?"":t(r),...(n||_r(r.formatter))&&!r.merged?{rawFormatter:r.formatter??""}:{},cellType:r.cellType,barcodeType:r.barcodeType,qrCodeLevel:r.qrCodeLevel,qrQuietZone:r.qrQuietZone,barQuietZone:r.barQuietZone,barHeight:r.barHeight,barWidth:r.barWidth,barFontSize:r.barFontSize,showBarcodeText:r.showBarcodeText,printerDpi:r.printerDpi,fit:r.fit,objectPosition:r.objectPosition,fitScale:r.fitScale,maxWidth:r.maxWidth,maxHeight:r.maxHeight,rowspan:r.rowspan??1,colspan:r.colspan??1,merged:r.merged===!0,...r.mergeSameValue===!0?{mergeSameValue:!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 X0(e){const t=Z0(e);return t===0||!e.slice(0,t).some(r=>r.repeatOnPage===!0)?0:Q0(e,t)}function Z0(e){let t=0;for(const n of e){if(n?.type!=="header")break;t++}return t}function J0(e,t){for(let n=0;n<t;n++)for(const r of e[n]?.cells??[])if(!r?.merged&&n+(r?.rowspan??1)>t)return!1;return!0}function Q0(e,t){for(let n=t;n>=1;n--)if(J0(e,n))return n;return 1}const Sr=e=>String(e).padStart(2,"0");function Oo(e=new Date,t={}){return{printDate:`${e.getFullYear()}-${Sr(e.getMonth()+1)}-${Sr(e.getDate())}`,printTime:`${Sr(e.getHours())}:${Sr(e.getMinutes())}:${Sr(e.getSeconds())}`,pageIndex:t.pageIndex??1,totalPages:t.totalPages??1}}function _r(e){return typeof e=="string"&&/\b(pageIndex|totalPages)\b/.test(e)}function ja(e,t=new Date){const{printDate:n,printTime:r}=Oo(t);return e.replace(/\{printDate\}/g,n).replace(/\{printTime\}/g,r)}function Mr(e){const t=[];for(const n of e??[]){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";t.push(`@font-face{font-family:${o};src:url("${a}")${eb(a)};font-weight:${l};font-style:${c};font-display:block;}`)}}return t.length?`${t.join("")}
2
+ `:""}function eb(e){const t=e.split(/[?#]/)[0].toLowerCase();return t.endsWith(".woff2")?' format("woff2")':t.endsWith(".woff")?' format("woff")':t.endsWith(".ttf")?' format("truetype")':t.endsWith(".otf")?' format("opentype")':""}const Ga=['"Microsoft YaHei"','"PingFang SC"','"Helvetica Neue"',"Arial","sans-serif"];function Va(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Ya(e){const t=e?.trim();return t?[t.includes(",")?t:`"${t.replace(/"/g,"")}"`,...Ga].join(", "):Ga.join(", ")}function Ka(e){return e?Ya(e):"inherit"}function tb(e){const t=[],n=new Set;for(const r of e??[]){const o=r?.family?.trim();if(!o)continue;const i=o.toLowerCase();if(n.has(i))continue;n.add(i);const a=r?.label?.trim();t.push(a?{family:o,label:a}:{family:o})}return t}function Id(e,t){const n=t?.trim().toLowerCase();if(n)return e.find(r=>r.family.trim().toLowerCase()===n)}function Pd(e){return e.label?`${e.label}(${e.family})`:e.family}function Tr(e){return e.toLowerCase().replace(/\s+/g,"")}function Rd(e,t){if(e===t)return 0;if(e.startsWith(t))return 1;if(e.includes(t))return 2;let n=0;for(const r of e)if(r===t[n]&&n++,n===t.length)return 3;return-1}function nb(e,t){const n=Rd(Tr(e.family),t);if(!e.label)return n;const r=Rd(Tr(e.label),t);return n<0?r:r<0?n:Math.min(n,r)}function rb(e,t){const n=Tr(t.trim());return n?e.map((r,o)=>({font:r,index:o,rank:nb(r,n)})).filter(r=>r.rank>=0).sort((r,o)=>r.rank-o.rank||r.index-o.index).map(r=>r.font):[...e]}function Y(e){return`${e}mm`}function Xa(e,t){const n=gn(e);return t&&t>0&&At(e)?{width:n.width,height:t}:n}function Fd(e,t){const n=ht(e);return t&&t>0&&At(e)?{width:n.width,height:t}:n}function $d(){return`
3
3
  /* ── 全局重置 ── */
4
4
  * { margin: 0; padding: 0; box-sizing: border-box; }
5
5
 
6
6
  /* 打印必须保留元素背景色(Chromium 默认剔除背景,需显式声明) */
7
7
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
8
8
 
9
- body { font-family: ${ja.join(", ")}; }
9
+ body { font-family: ${Ga.join(", ")}; }
10
10
 
11
11
  /* ── 屏幕预览:灰底 + 纸张阴影/页间距;打印时去除 ── */
12
12
  @media screen {
@@ -71,7 +71,7 @@ body { font-family: ${ja.join(", ")}; }
71
71
  height: auto;
72
72
  overflow: visible;
73
73
  }
74
- `}function Fd(e,t){return`
74
+ `}function Bd(e,t){return`
75
75
  /* ── 打印纸张:浏览器原生打印按此尺寸分页(Playwright page.pdf 以显式宽高为准,无副作用) ── */
76
76
  @page${t?` ${t}`:""} { size: ${Y(e.width)} ${Y(e.height)}; margin: 0; }
77
77
  `}function zd(e,t,n,r=""){const o=`
@@ -88,7 +88,7 @@ ${r}.print-page-rotor {
88
88
  }`;if(n===0)return o.trim();const a={90:`translate(${Y(e.height)}, 0mm) rotate(90deg)`,180:`translate(${Y(e.width)}, ${Y(e.height)}) rotate(180deg)`,270:`translate(0mm, ${Y(e.width)}) rotate(270deg)`}[n];return[o.trim(),`${r}.print-page-rotor-${n} {
89
89
  transform: ${a};
90
90
  }`].join(`
91
- `)}function Bd(e,t,n,r){const{top:o,right:i,bottom:a,left:l}=e.margins,c=r?"0":`${Y(o)} ${Y(i)} ${Y(a)} ${Y(l)}`;return`
91
+ `)}function Hd(e,t,n,r){const{top:o,right:i,bottom:a,left:l}=e.margins,c=r?"0":`${Y(o)} ${Y(i)} ${Y(a)} ${Y(l)}`;return`
92
92
  /* ── 纸张页面 ── */
93
93
  ${n} {
94
94
  width: ${Y(t.width)};
@@ -102,7 +102,7 @@ ${n} {
102
102
  .print-page:last-child {
103
103
  page-break-after: auto;
104
104
  }
105
- `}function Hd(e,t,n){const{right:r,left:o}=e.margins,{bottom:i}=e.margins,a=e.header?.height??0,l=e.footer?.height??0,c=t.width-o-r;return`
105
+ `}function Ud(e,t,n){const{right:r,left:o}=e.margins,{bottom:i}=e.margins,a=e.header?.height??0,l=e.footer?.height??0,c=t.width-o-r;return`
106
106
  /* ── 页眉 ── */
107
107
  ${n}.page-header {
108
108
  width: ${Y(c)};
@@ -128,12 +128,12 @@ ${n}.content-area {
128
128
  position: relative;
129
129
  overflow: visible;
130
130
  }
131
- `}function rb(){return[$d(),Nd(),Ld()].join("").trim()}function ob(e,t,n){return Fd(Ka(e,t),n).trim()}function ib(e,t,n){const r=ba(e),o=r!==0,i=Ka(e,n),a=Dd(e,n),l=t?`${t}.print-page`:".print-page",c=t?`${t} `:"";return[Bd(e,i,l,o),Hd(e,a,c),...o?[zd(a,e.margins,r,c)]:[]].join("").trim()}function kr(e,t){const n=ba(e),r=n!==0,o=Ka(e,t),i=Dd(e,t);return[Fd(o),$d(),Bd(e,o,".print-page",r),Nd(),Hd(e,i,""),Ld(),...r?[zd(i,e.margins,n)]:[]].join("").trim()}const Xa=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function ab(e,t){if(!At(e))return`${kr(e)}
132
- ${Xa}`;const{bottom:n}=e.margins,r=e.footer?.height??0,o=ht(e).width,i=kr(e,t[0]?.heightMm),a=t.map((l,c)=>{const s=l.heightMm,d=[`@page copy${c} { size: ${Y(o)} ${s?Y(s):"auto"}; margin: 0; }`,`.print-copy-${c} { page: copy${c}; }`];return s&&(d.push(`.print-copy-${c} .print-page { min-height: ${Y(s)}; }`),d.push(`.print-copy-${c} .page-footer { top: ${Y(s-n-r)}; }`)),d.join(`
131
+ `}function ob(){return[$d(),Nd(),Ld()].join("").trim()}function ib(e,t,n){return Bd(Xa(e,t),n).trim()}function ab(e,t,n){const r=ya(e),o=r!==0,i=Xa(e,n),a=Fd(e,n),l=t?`${t}.print-page`:".print-page",c=t?`${t} `:"";return[Hd(e,i,l,o),Ud(e,a,c),...o?[zd(a,e.margins,r,c)]:[]].join("").trim()}function Cr(e,t){const n=ya(e),r=n!==0,o=Xa(e,t),i=Fd(e,t);return[Bd(o),$d(),Hd(e,o,".print-page",r),Nd(),Ud(e,i,""),Ld(),...r?[zd(i,e.margins,n)]:[]].join("").trim()}const Za=".print-copy:not(:last-child){break-after:page;page-break-after:always;}";function sb(e,t){if(!At(e))return`${Cr(e)}
132
+ ${Za}`;const{bottom:n}=e.margins,r=e.footer?.height??0,o=ht(e).width,i=Cr(e,t[0]?.heightMm),a=t.map((l,c)=>{const s=l.heightMm,d=[`@page copy${c} { size: ${Y(o)} ${s?Y(s):"auto"}; margin: 0; }`,`.print-copy-${c} { page: copy${c}; }`];return s&&(d.push(`.print-copy-${c} .print-page { min-height: ${Y(s)}; }`),d.push(`.print-copy-${c} .page-footer { top: ${Y(s-n-r)}; }`)),d.join(`
133
133
  `)}).join(`
134
134
  `);return`${i}
135
135
  ${a}
136
- ${Xa}`}function sb(e){return`
136
+ ${Za}`}function lb(e){return`
137
137
  /* ── 拼版纸张:@page 尺寸 = 目标纸。服务端/客户端链路以 paperMm 显式定尺寸、不看这里,
138
138
  但浏览器链路只看 @page,故这条是硬需求 ── */
139
139
  @page { size: ${Y(e.sheet.width)} ${Y(e.sheet.height)}; margin: 0; }
@@ -166,12 +166,12 @@ ${Xa}`}function sb(e){return`
166
166
  否则设计器预览错位 3.17mm、与出纸不一致 */
167
167
  .print-tile > .print-page { margin: 0; box-shadow: none; }
168
168
  }
169
- `}function Po(e,t,n,r,o,i){const a=["position:absolute",`left:${Y(e)}`,`top:${Y(t)}`,`width:${Y(n)}`];r!==void 0&&r>0&&a.push(`height:${Y(r)}`),o!==void 0&&a.push(`z-index:${o}`);const l=vo(i);return l&&a.push(l),a.join(";")+";"}const Ud=25.4/96,le={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},lb={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function qd(e,t,n){const r=typeof e=="number"&&Number.isFinite(e)?e:t;return Math.max(n,Math.round(r))}function cb(e){return{width:qd(e?.tileWidth,le.tileWidth,le.minTileWidth),height:qd(e?.tileHeight,le.tileHeight,le.minTileHeight)}}function db(e){return e?!e.mode||e.mode==="fixed"?!!e.content&&e.content.trim().length>0:!!e.binding&&e.binding.trim().length>0:!1}function ub(e,t,n){if(!e)return"";let r="";if(!e.mode||e.mode==="fixed")r=e.content??"";else if(typeof e.binding=="string"&&e.binding.trim()){const o=e.binding.trim(),i=Array.isArray(t)?t[0]??{}:t??{},a={...Io(),...n,...i};let l;if(o.includes("{"))l=Qt(o,a);else{try{l=j0(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=Er(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=(typeof e.testData=="string"?e.testData.trim():"")?e.testData:`[${e.binding}]`}return e.timestamp&&r&&(r=`${r} ${pb(e.format)}`),r}function Cr(e){return String(e).padStart(2,"0")}function pb(e){const t=e&&e.trim()?e:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:Cr(n.getMonth()+1),DD:Cr(n.getDate()),HH:Cr(n.getHours()),mm:Cr(n.getMinutes()),ss:Cr(n.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function Ro(e){return Math.round(e*1e4)/1e4}function fb(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Wd(e,t,n,r){if(!db(e))return null;const o=ub(e,t,r);if(!o)return null;const i=cb(e),a=Ro(i.width*Ud),l=Ro(i.height*Ud),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:Ro(f*a),topMm:Ro(u*l),widthMm:a,heightMm:l});return{text:o,color:e?.color||le.color,rotate:e?.rotate??le.rotate,opacity:e?.opacity??le.opacity,fontSizePx:le.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function hb(e,t){const n=e.tileWidthPx,r=e.tileHeightPx,o=n/2,i=r/2;return`<svg class="watermark-tile" style="${`left:${t.leftMm}mm;top:${t.topMm}mm;width:${t.widthMm}mm;height:${t.heightMm}mm`}" viewBox="0 0 ${n} ${r}" xmlns="http://www.w3.org/2000/svg"><text x="${o}" y="${i}" font-size="${e.fontSizePx}" fill="${e.color}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${e.rotate},${o},${i})">${fb(e.text)}</text></svg>`}function jd(e,t,n,r){const o=Wd(e,t,n,r);if(!o)return"";const i=o.tiles.map(a=>hb(o,a)).join(`
169
+ `}function Io(e,t,n,r,o,i){const a=["position:absolute",`left:${Y(e)}`,`top:${Y(t)}`,`width:${Y(n)}`];r!==void 0&&r>0&&a.push(`height:${Y(r)}`),o!==void 0&&a.push(`z-index:${o}`);const l=vo(i);return l&&a.push(l),a.join(";")+";"}const qd=25.4/96,le={color:"#cccccc",opacity:.15,rotate:-30,tileWidth:260,tileHeight:180,minTileWidth:140,minTileHeight:100,fontSize:16},cb={dense:{width:200,height:120,label:"密"},medium:{width:260,height:180,label:"中(默认)"},loose:{width:340,height:260,label:"疏"}};function Wd(e,t,n){const r=typeof e=="number"&&Number.isFinite(e)?e:t;return Math.max(n,Math.round(r))}function db(e){return{width:Wd(e?.tileWidth,le.tileWidth,le.minTileWidth),height:Wd(e?.tileHeight,le.tileHeight,le.minTileHeight)}}function ub(e){return e?!e.mode||e.mode==="fixed"?!!e.content&&e.content.trim().length>0:!!e.binding&&e.binding.trim().length>0:!1}function pb(e,t,n){if(!e)return"";let r="";if(!e.mode||e.mode==="fixed")r=e.content??"";else if(typeof e.binding=="string"&&e.binding.trim()){const o=e.binding.trim(),i=Array.isArray(t)?t[0]??{}:t??{},a={...Oo(),...n,...i};let l;if(o.includes("{"))l=Qt(o,a);else{try{l=G0(o,a)}catch{l=void 0}(l==null||typeof l=="object")&&(l=Er(i,o))}l!=null&&typeof l!="object"&&String(l)!==o?r=String(l):r=(typeof e.testData=="string"?e.testData.trim():"")?e.testData:`[${e.binding}]`}return e.timestamp&&r&&(r=`${r} ${fb(e.format)}`),r}function kr(e){return String(e).padStart(2,"0")}function fb(e){const t=e&&e.trim()?e:"YYYY-MM-DD HH:mm",n=new Date,r={YYYY:String(n.getFullYear()),MM:kr(n.getMonth()+1),DD:kr(n.getDate()),HH:kr(n.getHours()),mm:kr(n.getMinutes()),ss:kr(n.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,o=>r[o]??o)}function Po(e){return Math.round(e*1e4)/1e4}function hb(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function jd(e,t,n,r){if(!ub(e))return null;const o=pb(e,t,r);if(!o)return null;const i=db(e),a=Po(i.width*qd),l=Po(i.height*qd),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:Po(f*a),topMm:Po(u*l),widthMm:a,heightMm:l});return{text:o,color:e?.color||le.color,rotate:e?.rotate??le.rotate,opacity:e?.opacity??le.opacity,fontSizePx:le.fontSize,tileWidthPx:i.width,tileHeightPx:i.height,tileWidthMm:a,tileHeightMm:l,columns:s,rows:d,tiles:p}}function gb(e,t){const n=e.tileWidthPx,r=e.tileHeightPx,o=n/2,i=r/2;return`<svg class="watermark-tile" style="${`left:${t.leftMm}mm;top:${t.topMm}mm;width:${t.widthMm}mm;height:${t.heightMm}mm`}" viewBox="0 0 ${n} ${r}" xmlns="http://www.w3.org/2000/svg"><text x="${o}" y="${i}" font-size="${e.fontSizePx}" fill="${e.color}" text-anchor="middle" dominant-baseline="middle" transform="rotate(${e.rotate},${o},${i})">${hb(e.text)}</text></svg>`}function Gd(e,t,n,r){const o=jd(e,t,n,r);if(!o)return"";const i=o.tiles.map(a=>gb(o,a)).join(`
170
170
  `);return`
171
171
  <div class="watermark-layer" style="opacity:${o.opacity}">
172
172
  ${i}
173
- </div>`}const Gd=(e,t)=>`${e}:${t}`;function gb(e,t,n){if(n-t<2)return;const r=new Set;for(let i=t;i<n;i++){const a=e[i];a?.type==="data"&&a.cells.forEach((l,c)=>{l?.mergeSameValue===!0&&r.add(c)})}if(r.size===0)return;const o={rowspan:new Map,merged:new Set};for(const i of r){let a=!1;for(let c=t;c<n&&!a;c++)e[c]?.cells[i]?.rawFormatter&&(a=!0);if(a)continue;let l=t;for(;l<n;){if(!mb(e[l],i)){l++;continue}const c=e[l].cells[i].content;let s=l;for(;s+1<n&&bb(e[s+1],i,c);)s++;if(s>l){o.rowspan.set(Gd(l,i),s-l+1);for(let d=l+1;d<=s;d++)o.merged.add(Gd(d,i))}l=s+1}}return o.rowspan.size>0?o:void 0}function mb(e,t){if(!e||e.type!=="data")return!1;const n=e.cells[t];return!n||n.merged||n.mergeSameValue!==!0?!1:(n.content??"").trim()!==""}function bb(e,t,n){if(!e||e.type!=="data")return!1;const r=e.cells[t];return!r||r.merged||r.mergeSameValue!==!0?!1:r.content===n}class qn extends Error{constructor(t,n,r){super(n),this.name="PrintFailure",this.code=t,this.cause=r}}function yb(e,t,n){if(e instanceof qn)return e;const r=e instanceof Error?e.message:String(e);return new qn(t,`${n}:${r}`,e)}async function Ar(e,t,n,r){let o;try{return await Promise.race([e,new Promise((i,a)=>{o=setTimeout(()=>a(new qn(n,r)),t)})])}finally{o&&clearTimeout(o)}}function Vd(e){try{return JSON.stringify(e)}catch{return`__unserializable__:${Object.keys(e).sort().join(",")}`}}function Yd(e){return e.key??Vd(e)}function vb(e){const t=new Map;return{renderer:{render(n){const r=Yd(n),o=e?.get(r);if(o)return o;throw t.set(r,{...n,key:r}),new Error("collect")}},takeSpecs(){const n=[...t.values()];return t.clear(),n}}}function wb(e){return{render(t){const n=e.get(Yd(t));if(!n)throw new Error("扩展元素未渲染");return n}}}function Kd(...e){const t=new Map;for(const n of e)for(const[r,o]of n)t.set(r,o);return t}function Xd(e,t){const n={};for(const r of t)n[r]=e;return n}function xb(){return gc().filter(({plugin:e,kind:t})=>{const n=t.render??e.render;return!!(n?.createRenderer||n?.executorBundle)}).map(({kind:e})=>e.type)}function Eb(e){const t=new Map,n=new Map;for(const r of e){const o=r.type??"";if(!o)continue;let i=n.get(o);if(!i){if(i=$n(o)?.render?.createRenderer?.(),!i)continue;n.set(o,i)}try{t.set(r.key,i.render(r))}catch{}}return t}async function Sb(e,t){if(e.length===0)return new Map;const n=Eb(e),r=e.filter(l=>!n.has(l.key));if(r.length===0||!t?.renderAssets)return n;const o=await t.renderAssets(r),i=Kd(n,o),a=r.find(l=>!i.has(l.key)&&_b(String(l.type??"")));if(a)throw new qn("UNSUPPORTED_RUNTIME",`缺少扩展元素执行器产物(${String(a.type)}):请确认宿主已装配 collectExecutorBundles() 收集的插件执行器`);return i}function _b(e){return!!$n(e)?.render?.executorBundle}function Mb(e){return Object.entries(Kg()).filter(([,n])=>n===e).map(([n])=>n).sort()[0]??e}function Za(e){return{...e.data??{},pageIndex:e.pageIndex,totalPages:e.totalPages}}function Tb(e){return Array.isArray(e)?e[0]??{}:e??{}}function Do(e,t,n,r){const o=Mr(e.fonts)+kr(e,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:r?.totalPageCount??t.length,l={codeRenderer:r?.codeRenderer,renderers:r?.renderers,pageHeightMm:r?.pageHeightMm};return i?kb(e,o,l,n):Cb(e,t,o,a,l,n)}function kb(e,t,n,r){const i=rs(e).width-e.margins.left-e.margins.right,a=e.elements.map(s=>Lo(s,!0,void 0,void 0,n)).join(`
174
- `),l=ts(e.header?.elements??[],i,0,0,n);let c=`<!DOCTYPE html>
173
+ </div>`}const Vd=(e,t)=>`${e}:${t}`;function mb(e,t,n){if(n-t<2)return;const r=new Set;for(let i=t;i<n;i++){const a=e[i];a?.type==="data"&&a.cells.forEach((l,c)=>{l?.mergeSameValue===!0&&r.add(c)})}if(r.size===0)return;const o={rowspan:new Map,merged:new Set};for(const i of r){let a=!1;for(let c=t;c<n&&!a;c++)e[c]?.cells[i]?.rawFormatter&&(a=!0);if(a)continue;let l=t;for(;l<n;){if(!bb(e[l],i)){l++;continue}const c=e[l].cells[i].content;let s=l;for(;s+1<n&&yb(e[s+1],i,c);)s++;if(s>l){o.rowspan.set(Vd(l,i),s-l+1);for(let d=l+1;d<=s;d++)o.merged.add(Vd(d,i))}l=s+1}}return o.rowspan.size>0?o:void 0}function bb(e,t){if(!e||e.type!=="data")return!1;const n=e.cells[t];return!n||n.merged||n.mergeSameValue!==!0?!1:(n.content??"").trim()!==""}function yb(e,t,n){if(!e||e.type!=="data")return!1;const r=e.cells[t];return!r||r.merged||r.mergeSameValue!==!0?!1:r.content===n}class qn extends Error{constructor(t,n,r){super(n),this.name="PrintFailure",this.code=t,this.cause=r}}function vb(e,t,n){if(e instanceof qn)return e;const r=e instanceof Error?e.message:String(e);return new qn(t,`${n}:${r}`,e)}async function Ar(e,t,n,r){let o;try{return await Promise.race([e,new Promise((i,a)=>{o=setTimeout(()=>a(new qn(n,r)),t)})])}finally{o&&clearTimeout(o)}}function Yd(e){try{return JSON.stringify(e)}catch{return`__unserializable__:${Object.keys(e).sort().join(",")}`}}function Kd(e){return e.key??Yd(e)}function wb(e){const t=new Map;return{renderer:{render(n){const r=Kd(n),o=e?.get(r);if(o)return o;throw t.set(r,{...n,key:r}),new Error("collect")}},takeSpecs(){const n=[...t.values()];return t.clear(),n}}}function xb(e){return{render(t){const n=e.get(Kd(t));if(!n)throw new Error("扩展元素未渲染");return n}}}function Xd(...e){const t=new Map;for(const n of e)for(const[r,o]of n)t.set(r,o);return t}function Zd(e,t){const n={};for(const r of t)n[r]=e;return n}function Eb(){return mc().filter(({plugin:e,kind:t})=>{const n=t.render??e.render;return!!(n?.createRenderer||n?.executorBundle)}).map(({kind:e})=>e.type)}function Sb(e){const t=new Map,n=new Map;for(const r of e){const o=r.type??"";if(!o)continue;let i=n.get(o);if(!i){if(i=Fn(o)?.render?.createRenderer?.(),!i)continue;n.set(o,i)}try{t.set(r.key,i.render(r))}catch{}}return t}async function _b(e,t){if(e.length===0)return new Map;const n=Sb(e),r=e.filter(l=>!n.has(l.key));if(r.length===0||!t?.renderAssets)return n;const o=await t.renderAssets(r),i=Xd(n,o),a=r.find(l=>!i.has(l.key)&&Mb(String(l.type??"")));if(a)throw new qn("UNSUPPORTED_RUNTIME",`缺少扩展元素执行器产物(${String(a.type)}):请确认宿主已装配 collectExecutorBundles() 收集的插件执行器`);return i}function Mb(e){return!!Fn(e)?.render?.executorBundle}function Tb(e){return Object.entries(Xg()).filter(([,n])=>n===e).map(([n])=>n).sort()[0]??e}function Ja(e){return{...e.data??{},pageIndex:e.pageIndex,totalPages:e.totalPages}}function Cb(e){return Array.isArray(e)?e[0]??{}:e??{}}function Ro(e,t,n,r){const o=Mr(e.fonts)+Cr(e,r?.pageHeightMm),i=r?.isMeasurementPass===!0,a=i?1:r?.totalPageCount??t.length,l={codeRenderer:r?.codeRenderer,renderers:r?.renderers,pageHeightMm:r?.pageHeightMm};return i?kb(e,o,l,n):Ab(e,t,o,a,l,n)}function kb(e,t,n,r){const i=os(e).width-e.margins.left-e.margins.right,a=e.elements.map(s=>No(s,!0,void 0,void 0,n)).join(`
174
+ `),l=ns(e.header?.elements??[],i,0,0,n);let c=`<!DOCTYPE html>
175
175
  <html lang="zh-CN">
176
176
  <head>
177
177
  <meta charset="UTF-8">
@@ -179,15 +179,15 @@ ${i}
179
179
  </head>
180
180
  <body class="measure-mode">
181
181
  <section class="print-page" data-measure-page="0">
182
- ${jd(e.watermark,r,rs(e))}
182
+ ${Gd(e.watermark,r,os(e))}
183
183
  <div class="page-header">${l}</div>
184
184
  <div class="content-area" style="height:auto;overflow:visible;">
185
185
  ${a}
186
186
  </div>
187
187
  </section>
188
188
  </body>
189
- </html>`;return c=Wa(c),c}function $o(e,t,n,r,o){const i=o?.pageOffset??0,a=o?.totalPages??t.length,l=t.map(c=>{const s=c.pageIndex+1+i;return Ab(e,c,s,a,r,n,o?.pageClass)}).join(`
190
- `);return Wa(l)}function No(e,t,n){const r=`<!DOCTYPE html>
189
+ </html>`;return c=ja(c),c}function Fo(e,t,n,r,o){const i=o?.pageOffset??0,a=o?.totalPages??t.length,l=t.map(c=>{const s=c.pageIndex+1+i;return Db(e,c,s,a,r,n,o?.pageClass)}).join(`
190
+ `);return ja(l)}function $o(e,t,n){const r=`<!DOCTYPE html>
191
191
  <html lang="zh-CN">
192
192
  <head>
193
193
  <meta charset="UTF-8">
@@ -196,80 +196,80 @@ ${i}
196
196
  <body${n?` class="${n}"`:""}>
197
197
  ${t}
198
198
  </body>
199
- </html>`;return Wa(r)}function Cb(e,t,n,r,o,i){const a=$o(e,t,i??{},o,{totalPages:r});return No(n,a,At(e)?"continuous":void 0)}function Ab(e,t,n,r,o,i,a){const l=rs(e),c={width:l.width,height:o.pageHeightMm&&o.pageHeightMm>0?o.pageHeightMm:l.height},s=l.width-e.margins.left-e.margins.right,d={pageIndex:n,totalPages:r,data:Tb(i)},p=Ob(e,d),u={...o,pageVars:d},f=ts(p.header?.elements??[],s,n,r,u),g=ts(p.footer?.elements??[],s,n,r,u);let m=t.sections.map(E=>Pb(E,p,u)).join(`
200
- `);m=m.replace(/\{pageIndex\}/g,String(n)),m=m.replace(/\{totalPages\}/g,String(r));const b=`
201
- ${jd(e.watermark,i,c,{pageIndex:n,totalPages:r})}
199
+ </html>`;return ja(r)}function Ab(e,t,n,r,o,i){const a=Fo(e,t,i??{},o,{totalPages:r});return $o(n,a,At(e)?"continuous":void 0)}function Db(e,t,n,r,o,i,a){const l=os(e),c={width:l.width,height:o.pageHeightMm&&o.pageHeightMm>0?o.pageHeightMm:l.height},s=l.width-e.margins.left-e.margins.right,d={pageIndex:n,totalPages:r,data:Cb(i)},p=Ob(e,d),u={...o,pageVars:d},f=ns(p.header?.elements??[],s,n,r,u),g=ns(p.footer?.elements??[],s,n,r,u);let m=t.sections.map(E=>Pb(E,p,u)).join(`
200
+ `);m=m.replace(/\{pageIndex\}/g,String(n)),m=m.replace(/\{totalPages\}/g,String(r));const y=`
201
+ ${Gd(e.watermark,i,c,{pageIndex:n,totalPages:r})}
202
202
  <div class="page-header">${f}</div>
203
203
  <div class="content-area">
204
204
  ${m}
205
205
  </div>
206
- <div class="page-footer">${g}</div>`,v=ba(e),w=v!==0?`<div class="print-page-rotor print-page-rotor-${v}">${b}</div>`:b;return`<section class="print-page${a?` ${a}`:""}" data-page="${n}">
206
+ <div class="page-footer">${g}</div>`,v=ya(e),w=v!==0?`<div class="print-page-rotor print-page-rotor-${v}">${y}</div>`:y;return`<section class="print-page${a?` ${a}`:""}" data-page="${n}">
207
207
  ${w}
208
- </section>`}function Ob(e,t){if(!Ib(e))return e;const n=Za(t),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:Qt(a,n)}}},o=i=>i&&{...i,elements:(i.elements??[]).map(r)};return{...e,elements:e.elements.map(r),header:o(e.header),footer:o(e.footer)}}function Ib(e){return[e.elements,e.header?.elements,e.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function Ja(e,t){const n=e.rawFormatter;return typeof n=="string"&&n!==""&&t?.pageVars?Qt(n,Za(t.pageVars)):e.content}function Pb(e,t,n){const r=ns(t,e.elementId);return r?e.type==="table-slice"?Ub(r,e,n):e.type==="flow-list-slice"?Lb(r,e):e.type==="flow-group"?qb(r,e,t,n):Lo(r,!1,void 0,e.renderTop,n):`<!-- element not found: ${e.elementId} -->`}const Zd={top:"flex-start",middle:"center",bottom:"flex-end"},Rb={left:"flex-start",center:"center",right:"flex-end"};function Or(e,t){const n=[],r=e._fitFontSize===void 0?e.fontSize:sa(e._fitFontSize);return r&&n.push(`font-size:${r}pt`),e.fontFamily&&n.push(`font-family:${Ga(Va(e.fontFamily))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),e.color&&n.push(`color:${e.color}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),e.lineHeight?n.push(`line-height:${e.lineHeight}pt`):t&&n.push(`line-height:${t}`),e.letterSpacing&&n.push(`letter-spacing:${e.letterSpacing}pt`),e.verticalAlign&&(e.textAlign==="justify"?n.push(`display:flex;flex-direction:column;justify-content:${Zd[e.verticalAlign]??"flex-start"}`):(n.push(`display:flex;align-items:${Zd[e.verticalAlign]??"flex-start"}`),n.push(`justify-content:${Rb[e.textAlign??"left"]??"flex-start"}`))),e.textAlign&&n.push(`text-align:${e.textAlign}`),e.textAlign==="justify"&&n.push("text-align-last:justify"),n.length?n.join(";")+";":""}function Db(e){return e.longTextIndent?`text-indent:${e.longTextIndent}em;`:""}function Jd(e){const t=yc(e);return t?`white-space:${t};`:""}function Qd(e,t,n){return Object.entries(ga(e,t,n)).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${Ga(o)};`).join("")}function eu(e,t){const n=vc(t)?"white-space:nowrap;text-overflow:ellipsis;":"";return e==="autoHeight"?`overflow:visible;${n}`:n}function $b(e,t,n,r){if(e!=="shrink")return"";const o=dr(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${wt(t)}" data-fit-base="${n}" data-fit-min="${o}"`}function Lo(e,t,n,r,o){const i=e.options??{},a=i.left??0,l=r??i.top??0,c=i.width??100,s=i.height??void 0,d=e.type||e.printElementType?.type||"text",p=po(d,i),u=d==="flowList"&&pn(i.flowLayoutMode)==="dynamic",f=p==="autoHeight"||u?void 0:s,g=n??Po(a,l,c,f,i.zIndex,i),m=bo(d,i);let b=g;if(m?.all&&(b+=`border:${m.all.borderWidth} ${m.all.borderStyle} ${m.all.borderColor};`),m)for(const E of hr){const k=m.edges[E];k&&(b+=`border-${E}:${k.borderWidth} ${k.borderStyle} ${k.borderColor};`)}if(!t&&n===void 0){const E=ma(d,i);E!==void 0&&(b+=`rotate:${E}deg;`)}const v=t?` data-measure-id="${e.id}"`:` data-element-id="${e.id}"`,w=$b(p,e.id,i.fontSize??12,i);switch(d){case"table":return Hb(e,t,t?v:"",o,r);case"image":return`<div class="print-element" style="${b}"${v}>
209
- <img src="${wt(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${Qd(i.fit,i.fitScale,i.objectPosition)}" />
210
- </div>`;case"barcode":case"qrcode":{const E=String(i.formatter??i.testData??"").trim();return`<div class="print-element" style="${b}"${v}>
211
- ${nu(E,d,i,{fallback:`<span>${wt(E)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
212
- </div>`}case"hline":return`<div class="print-element" style="${b};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${v}></div>`;case"vline":return`<div class="print-element" style="${b};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${v}></div>`;case"rect":return`<div class="print-element" style="${b};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${v}></div>`;case"oval":return`<div class="print-element" style="${b};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${v}></div>`;case"longText":return`<div class="print-element" style="${b}${Or(i,"1.5")}${Db(i)}${Jd(i)}${eu(p,i)}"${v}${w}>${wt(i.formatter??i.testData??"")}</div>`;case"flowList":{const E=pt(i.flowColumns),k=vt(i.flowGapX),L=Xt(i.flowRowHeight),R=fn(i.flowMaxSpan,E),P=Array.isArray(i._flowItems)?i._flowItems:void 0,O=P&&P.length>0?P:String(i.testData??"").split(/\r?\n/).map(S=>S.trim()).filter(Boolean),C={width:c,columns:E,gapX:k,rowHeight:L,maxSpan:R,fontSizePt:i.fontSize??12,autoSpan:i.flowAutoSpan===!0};if(u){const S=Nn(i),$=Array.isArray(i._flowRows)?i._flowRows:da(O,{...C,width:Ec(c,S)});return`<div class="print-element" style="${b}${Or(i)}display:block;box-sizing:border-box;height:auto;overflow:visible;padding:${It(S.top)} ${It(S.right)} ${It(S.bottom)} ${It(S.left)};"${v}${w}>
213
- ${Qa($,E,k,L)}
214
- </div>`}const I=da(O,C).flatMap(S=>S.cells).map(S=>`<div class="print-flow-cell"${S.span>1?` style="grid-column:span ${S.span};"`:""}>${wt(S.text)}</div>`).join(`
215
- `);return`<div class="print-element" style="${b}${Or(i)}overflow:hidden;${um(C)};"${v}${w}>
216
- ${I}
217
- </div>`}case"html":return`<div class="print-element" style="${b}"${v}>${i.testData??i.title??""}</div>`;default:{const E=$n(d);if(E?.render){const k={type:d,...i,widthMm:c,heightMm:f??s??0,fontFamily:i.fontFamily,key:Vd({type:d,...i})},L=o?.renderers?.[d];try{const R=L?L.render(k):E.render.html?.(k);if(typeof R=="string"&&R.length>0)return`<div class="print-element" style="${b}"${v}>${R}</div>`}catch{}}return`<div class="print-element" style="${b}${Or(i)}${Jd(i)}${eu(p,i)}"${v}${w}>${wt(i.formatter??i.testData??"")}</div>`}}}function It(e){return`${Math.round(e*1e3)/1e3}mm`}function Nb(e,t,n){return["display:grid",`grid-template-columns:repeat(${e},minmax(0,1fr))`,`column-gap:${It(t)}`,`min-height:${It(n)}`].join(";")}function Qa(e,t,n,r,o=0){return e.map((i,a)=>{const l=i.cells.map(c=>`<div class="print-flow-cell"${c.span>1?` style="grid-column:span ${c.span};"`:""}>${wt(c.text)}</div>`).join(`
208
+ </section>`}function Ob(e,t){if(!Ib(e))return e;const n=Ja(t),r=i=>{const a=i.options?.rawFormatter;return typeof a!="string"?i:{...i,options:{...i.options,formatter:Qt(a,n)}}},o=i=>i&&{...i,elements:(i.elements??[]).map(r)};return{...e,elements:e.elements.map(r),header:o(e.header),footer:o(e.footer)}}function Ib(e){return[e.elements,e.header?.elements,e.footer?.elements].some(n=>(n??[]).some(r=>typeof r.options?.rawFormatter=="string"))}function Qa(e,t){const n=e.rawFormatter;return typeof n=="string"&&n!==""&&t?.pageVars?Qt(n,Ja(t.pageVars)):e.content}function Pb(e,t,n){const r=rs(t,e.elementId);return r?e.type==="table-slice"?qb(r,e,n):e.type==="flow-list-slice"?Lb(r,e):e.type==="flow-group"?Wb(r,e,t,n):No(r,!1,void 0,e.renderTop,n):`<!-- element not found: ${e.elementId} -->`}const Jd={top:"flex-start",middle:"center",bottom:"flex-end"},Rb={left:"flex-start",center:"center",right:"flex-end"};function Dr(e,t){const n=[],r=e._fitFontSize===void 0?e.fontSize:la(e._fitFontSize);return r&&n.push(`font-size:${r}pt`),e.fontFamily&&n.push(`font-family:${Va(Ya(e.fontFamily))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),e.color&&n.push(`color:${e.color}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),e.lineHeight?n.push(`line-height:${e.lineHeight}pt`):t&&n.push(`line-height:${t}`),e.letterSpacing&&n.push(`letter-spacing:${e.letterSpacing}pt`),e.verticalAlign&&(e.textAlign==="justify"?n.push(`display:flex;flex-direction:column;justify-content:${Jd[e.verticalAlign]??"flex-start"}`):(n.push(`display:flex;align-items:${Jd[e.verticalAlign]??"flex-start"}`),n.push(`justify-content:${Rb[e.textAlign??"left"]??"flex-start"}`))),e.textAlign&&n.push(`text-align:${e.textAlign}`),e.textAlign==="justify"&&n.push("text-align-last:justify"),n.length?n.join(";")+";":""}function Fb(e){return e.longTextIndent?`text-indent:${e.longTextIndent}em;`:""}function Qd(e){const t=vc(e);return t?`white-space:${t};`:""}function eu(e,t,n){return Object.entries(ma(e,t,n)).map(([r,o])=>`${r.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}:${Va(o)};`).join("")}function tu(e,t){const n=wc(t)?"white-space:nowrap;text-overflow:ellipsis;":"";return e==="autoHeight"?`overflow:visible;${n}`:n}function $b(e,t,n,r){if(e!=="shrink")return"";const o=dr(r.shrinkMinFontSize);return` data-fit="shrink" data-fit-key="${wt(t)}" data-fit-base="${n}" data-fit-min="${o}"`}function No(e,t,n,r,o){const i=e.options??{},a=i.left??0,l=r??i.top??0,c=i.width??100,s=i.height??void 0,d=e.type||e.printElementType?.type||"text",p=po(d,i),u=d==="flowList"&&pn(i.flowLayoutMode)==="dynamic",f=p==="autoHeight"||u?void 0:s,g=n??Io(a,l,c,f,i.zIndex,i),m=bo(d,i);let y=g;if(m?.all&&(y+=`border:${m.all.borderWidth} ${m.all.borderStyle} ${m.all.borderColor};`),m)for(const E of hr){const T=m.edges[E];T&&(y+=`border-${E}:${T.borderWidth} ${T.borderStyle} ${T.borderColor};`)}if(!t&&n===void 0){const E=ba(d,i);E!==void 0&&(y+=`rotate:${E}deg;`)}const v=t?` data-measure-id="${e.id}"`:` data-element-id="${e.id}"`,w=$b(p,e.id,i.fontSize??12,i);switch(d){case"table":return Ub(e,t,t?v:"",o,r);case"image":return`<div class="print-element" style="${y}"${v}>
209
+ <img src="${wt(i.src??"")}" style="width:100%;height:100%;object-fit:${i.fit||"contain"};${eu(i.fit,i.fitScale,i.objectPosition)}" />
210
+ </div>`;case"barcode":case"qrcode":{const E=String(i.formatter??i.testData??"").trim();return`<div class="print-element" style="${y}"${v}>
211
+ ${ru(E,d,i,{fallback:`<span>${wt(E)}</span>`,codeRenderer:o?.codeRenderer,fit:i.fit,maxWidth:i.maxWidth,maxHeight:i.maxHeight,printerDpi:i.printerDpi,targetWidthMm:i.width,targetHeightMm:i.height})}
212
+ </div>`}case"hline":return`<div class="print-element" style="${y};border-top:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};height:0;"${v}></div>`;case"vline":return`<div class="print-element" style="${y};border-left:${i.borderWidth||.75}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};width:0;"${v}></div>`;case"rect":return`<div class="print-element" style="${y};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};"${v}></div>`;case"oval":return`<div class="print-element" style="${y};border:${i.borderWidth||1}pt ${i.borderStyle||"solid"} ${i.borderColor||"#333"};border-radius:50%;"${v}></div>`;case"longText":return`<div class="print-element" style="${y}${Dr(i,"1.5")}${Fb(i)}${Qd(i)}${tu(p,i)}"${v}${w}>${wt(i.formatter??i.testData??"")}</div>`;case"flowList":{const E=pt(i.flowColumns),T=vt(i.flowGapX),P=Xt(i.flowRowHeight),O=fn(i.flowMaxSpan,E),I=Array.isArray(i._flowItems)?i._flowItems:void 0,A=I&&I.length>0?I:String(i.testData??"").split(/\r?\n/).map(S=>S.trim()).filter(Boolean),k={width:c,columns:E,gapX:T,rowHeight:P,maxSpan:O,fontSizePt:i.fontSize??12,autoSpan:i.flowAutoSpan===!0};if(u){const S=$n(i),$=Array.isArray(i._flowRows)?i._flowRows:ua(A,{...k,width:Sc(c,S)});return`<div class="print-element" style="${y}${Dr(i)}display:block;box-sizing:border-box;height:auto;overflow:visible;padding:${Ot(S.top)} ${Ot(S.right)} ${Ot(S.bottom)} ${Ot(S.left)};"${v}${w}>
213
+ ${es($,E,T,P)}
214
+ </div>`}const R=ua(A,k).flatMap(S=>S.cells).map(S=>`<div class="print-flow-cell"${S.span>1?` style="grid-column:span ${S.span};"`:""}>${wt(S.text)}</div>`).join(`
215
+ `);return`<div class="print-element" style="${y}${Dr(i)}overflow:hidden;${pm(k)};"${v}${w}>
216
+ ${R}
217
+ </div>`}case"html":return`<div class="print-element" style="${y}"${v}>${i.testData??i.title??""}</div>`;default:{const E=Fn(d);if(E?.render){const T={type:d,...i,widthMm:c,heightMm:f??s??0,fontFamily:i.fontFamily,key:Yd({type:d,...i})},P=o?.renderers?.[d];try{const O=P?P.render(T):E.render.html?.(T);if(typeof O=="string"&&O.length>0)return`<div class="print-element" style="${y}"${v}>${O}</div>`}catch{}}return`<div class="print-element" style="${y}${Dr(i)}${Qd(i)}${tu(p,i)}"${v}${w}>${wt(i.formatter??i.testData??"")}</div>`}}}function Ot(e){return`${Math.round(e*1e3)/1e3}mm`}function Nb(e,t,n){return["display:grid",`grid-template-columns:repeat(${e},minmax(0,1fr))`,`column-gap:${Ot(t)}`,`min-height:${Ot(n)}`].join(";")}function es(e,t,n,r,o=0){return e.map((i,a)=>{const l=i.cells.map(c=>`<div class="print-flow-cell"${c.span>1?` style="grid-column:span ${c.span};"`:""}>${wt(c.text)}</div>`).join(`
218
218
  `);return`<div class="print-flow-row" data-flow-row-index="${o+a}" style="${Nb(t,n,r)};">
219
219
  ${l}
220
220
  </div>`}).join(`
221
- `)}function tu(e,t){let n="";const r=bo(e,t);if(r?.all&&(n+=`border:${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor};`),r)for(const i of hr){const a=r.edges[i];a&&(n+=`border-${i}:${a.borderWidth} ${a.borderStyle} ${a.borderColor};`)}const o=Nn(t);return n+=`${Or(t)}display:block;box-sizing:border-box;height:auto;overflow:visible;padding:${It(o.top)} ${It(o.right)} ${It(o.bottom)} ${It(o.left)};`,n}function Lb(e,t,n){const r=e.options??{},o=Array.isArray(r._flowRows)?r._flowRows:[],i=t.startFlowRow??0,a=t.endFlowRow??o.length;if(i>=a)return"";const l=e.type||e.printElementType?.type||"flowList",c=Po(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex,r),s=pt(r.flowColumns),d=vt(r.flowGapX),p=Xt(r.flowRowHeight);return`<div class="print-flowlist-slice" style="${c}${tu(l,r)}">
222
- ${Qa(o.slice(i,a),s,d,p,i)}
223
- </div>`}function nu(e,t,n,r){if(!e||!r.codeRenderer)return r.fallback;const{fallback:o,codeRenderer:i,fit:a,maxWidth:l,maxHeight:c}=r,s=t==="barcode";try{const d=i.render(e,t,{barcodeType:n.barcodeType,qrCodeLevel:n.qrCodeLevel!=null?String(n.qrCodeLevel):void 0,qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0,barQuietZone:typeof n.barQuietZone=="number"?n.barQuietZone:void 0,barHeightMm:typeof n.barHeight=="number"?n.barHeight:void 0,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof(n.barFontSize??n.fontSize)=="number"?n.barFontSize??n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?Ln(r.targetWidthMm,l):void 0,targetHeightMm:s?Ln(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return Fb(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 Fb(e){return`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${e.replace(/<svg\b/,'<svg style="display:block"')}</div>`}function zb(e,t){const n=[],r=e.fittedFontSize??e.fontSize??t.tableDefaultFontSize,o=e.color??t.tableDefaultColor,i=e.padding??t.tableDefaultPadding??1,a=e.fontFamily??t.tableDefaultFontFamily;r&&n.push(`font-size:${r}pt`),a&&n.push(`font-family:${Ga(Va(a))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),o&&n.push(`color:${o}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),n.push(`text-align:${e.align??"left"}`),e.align==="justify"&&n.push("text-align-last:justify"),n.push(`vertical-align:${e.valign??"middle"}`),n.push(`padding:${i}mm`),n.push(e.wordWrap===!1?"white-space:nowrap;overflow:hidden":"white-space:pre-wrap;word-break:normal;overflow-wrap:break-word");const l=e.borders??{},c=t.tableDefaultBorders??{};for(const s of["top","right","bottom","left"]){const d=l[s]??c[s];n.push(d?`border-${s}:${d.width}pt ${d.style} ${d.color}`:`border-${s}:none`)}return n.join(";")}function yn(e,t,n,r,o,i,a={elementId:"",kind:"b"},l){const c=[],s=r.tableDefaultPadding??1,d=gb(e,t,n);for(let p=t;p<n;p++){const u=e[p];if(!u)continue;const f=o?` data-row-index="${p}"`:"",g=u.cells.map((m,b)=>({cell:m,ci:b})).filter(({cell:m,ci:b})=>!m.merged&&!d?.merged.has(`${p}:${b}`)).map(({cell:m,ci:b})=>{const v=d?.rowspan.get(`${p}:${b}`),w=v??(l===void 0?m.rowspan??1:Math.max(1,Math.min(m.rowspan??1,l-p))),E=v===void 0?m:{...m,rowspan:v},k=`${w>1?` rowspan="${w}"`:""}${m.colspan>1?` colspan="${m.colspan}"`:""}`,L=b;let R;if(m.cellType==="barcode"||m.cellType==="qrcode"){const P=Ja(m,i);R=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${nu(P,m.cellType,m,{fallback:wt(P),codeRenderer:i?.codeRenderer,fit:m.fit,maxWidth:m.maxWidth,maxHeight:m.maxHeight,printerDpi:m.printerDpi,targetWidthMm:la(r.tableColWidths??[],b,m,s),targetHeightMm:ur(e,p,E,s)})}</div>`}else if(m.cellType==="image"){const P=m.fit||"contain",O=m.maxWidth?`max-width:${m.maxWidth}mm;`:"max-width:100%;",C=m.maxHeight?`max-height:${m.maxHeight}mm;`:"max-height:100%;",I=wc(P,ur(e,p,E,s)),S=I===void 0?"height:100%":`height:${I}mm`,$=I===void 0?"":"width:100%;height:100%;";R=`<div style="width:100%;${S};display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${wt(Ja(m,i))}" style="${$}object-fit:${P};${Qd(P,m.fitScale,m.objectPosition)}${O}${C}display:block;" /></div>`}else R=Bb(e,p,L,E,r,a,s,i);return`<td${k} style="${zb(m,r)}">${R}</td>`}).join("");c.push(`<tr${f} style="height:${u.height}mm;">${g}</tr>`)}return c.join(`
224
- `)}function Bb(e,t,n,r,o,i,a,l){const c=aa(r),s=wt(Ja(r,l));if(c==="autoHeight")return s;const d=ur(e,t,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="${wt(em(i.elementId,i.kind,t,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${dr(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function es(e,t){const r=e.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="${e.id}" style="border-collapse:collapse;table-layout:fixed;width:${i}mm;">
221
+ `)}function nu(e,t){let n="";const r=bo(e,t);if(r?.all&&(n+=`border:${r.all.borderWidth} ${r.all.borderStyle} ${r.all.borderColor};`),r)for(const i of hr){const a=r.edges[i];a&&(n+=`border-${i}:${a.borderWidth} ${a.borderStyle} ${a.borderColor};`)}const o=$n(t);return n+=`${Dr(t)}display:block;box-sizing:border-box;height:auto;overflow:visible;padding:${Ot(o.top)} ${Ot(o.right)} ${Ot(o.bottom)} ${Ot(o.left)};`,n}function Lb(e,t,n){const r=e.options??{},o=Array.isArray(r._flowRows)?r._flowRows:[],i=t.startFlowRow??0,a=t.endFlowRow??o.length;if(i>=a)return"";const l=e.type||e.printElementType?.type||"flowList",c=Io(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex,r),s=pt(r.flowColumns),d=vt(r.flowGapX),p=Xt(r.flowRowHeight);return`<div class="print-flowlist-slice" style="${c}${nu(l,r)}">
222
+ ${es(o.slice(i,a),s,d,p,i)}
223
+ </div>`}function ru(e,t,n,r){if(!e||!r.codeRenderer)return r.fallback;const{fallback:o,codeRenderer:i,fit:a,maxWidth:l,maxHeight:c}=r,s=t==="barcode";try{const d=i.render(e,t,{barcodeType:n.barcodeType,qrCodeLevel:n.qrCodeLevel!=null?String(n.qrCodeLevel):void 0,qrQuietZone:typeof n.qrQuietZone=="number"?n.qrQuietZone:void 0,barQuietZone:typeof n.barQuietZone=="number"?n.barQuietZone:void 0,barHeightMm:typeof n.barHeight=="number"?n.barHeight:void 0,showText:n.hideTitle!==void 0?!n.hideTitle:n.showBarcodeText,barWidth:typeof n.barWidth=="number"?n.barWidth:void 0,fontSize:typeof(n.barFontSize??n.fontSize)=="number"?n.barFontSize??n.fontSize:void 0,printerDpi:s?r.printerDpi:void 0,targetWidthMm:s?Nn(r.targetWidthMm,l):void 0,targetHeightMm:s?Nn(r.targetHeightMm,c):void 0});if(s&&/^<svg[\s>]/i.test(d))return Bb(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 Bb(e){return`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${e.replace(/<svg\b/,'<svg style="display:block"')}</div>`}function zb(e,t){const n=[],r=e.fittedFontSize??e.fontSize??t.tableDefaultFontSize,o=e.color??t.tableDefaultColor,i=e.padding??t.tableDefaultPadding??1,a=e.fontFamily??t.tableDefaultFontFamily;r&&n.push(`font-size:${r}pt`),a&&n.push(`font-family:${Va(Ya(a))}`),e.fontWeight&&n.push(`font-weight:${e.fontWeight}`),o&&n.push(`color:${o}`),e.backgroundColor&&n.push(`background-color:${e.backgroundColor}`),n.push(`text-align:${e.align??"left"}`),e.align==="justify"&&n.push("text-align-last:justify"),n.push(`vertical-align:${e.valign??"middle"}`),n.push(`padding:${i}mm`),n.push(e.wordWrap===!1?"white-space:nowrap;overflow:hidden":"white-space:pre-wrap;word-break:normal;overflow-wrap:break-word");const l=e.borders??{},c=t.tableDefaultBorders??{};for(const s of["top","right","bottom","left"]){const d=l[s]??c[s];n.push(d?`border-${s}:${d.width}pt ${d.style} ${d.color}`:`border-${s}:none`)}return n.join(";")}function yn(e,t,n,r,o,i,a={elementId:"",kind:"b"},l){const c=[],s=r.tableDefaultPadding??1,d=mb(e,t,n);for(let p=t;p<n;p++){const u=e[p];if(!u)continue;const f=o?` data-row-index="${p}"`:"",g=u.cells.map((m,y)=>({cell:m,ci:y})).filter(({cell:m,ci:y})=>!m.merged&&!d?.merged.has(`${p}:${y}`)).map(({cell:m,ci:y})=>{const v=d?.rowspan.get(`${p}:${y}`),w=v??(l===void 0?m.rowspan??1:Math.max(1,Math.min(m.rowspan??1,l-p))),E=v===void 0?m:{...m,rowspan:v},T=`${w>1?` rowspan="${w}"`:""}${m.colspan>1?` colspan="${m.colspan}"`:""}`,P=y;let O;if(m.cellType==="barcode"||m.cellType==="qrcode"){const I=Qa(m,i);O=`<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden;">${ru(I,m.cellType,m,{fallback:wt(I),codeRenderer:i?.codeRenderer,fit:m.fit,maxWidth:m.maxWidth,maxHeight:m.maxHeight,printerDpi:m.printerDpi,targetWidthMm:ca(r.tableColWidths??[],y,m,s),targetHeightMm:ur(e,p,E,s)})}</div>`}else if(m.cellType==="image"){const I=m.fit||"contain",A=m.maxWidth?`max-width:${m.maxWidth}mm;`:"max-width:100%;",k=m.maxHeight?`max-height:${m.maxHeight}mm;`:"max-height:100%;",R=xc(I,ur(e,p,E,s)),S=R===void 0?"height:100%":`height:${R}mm`,$=R===void 0?"":"width:100%;height:100%;";O=`<div style="width:100%;${S};display:flex;align-items:center;justify-content:center;overflow:hidden;"><img src="${wt(Qa(m,i))}" style="${$}object-fit:${I};${eu(I,m.fitScale,m.objectPosition)}${A}${k}display:block;" /></div>`}else O=Hb(e,p,P,E,r,a,s,i);return`<td${T} style="${zb(m,r)}">${O}</td>`}).join("");c.push(`<tr${f} style="height:${u.height}mm;">${g}</tr>`)}return c.join(`
224
+ `)}function Hb(e,t,n,r,o,i,a,l){const c=sa(r),s=wt(Qa(r,l));if(c==="autoHeight")return s;const d=ur(e,t,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="${wt(tm(i.elementId,i.kind,t,n))}" data-fit-base="${r.fontSize??o.tableDefaultFontSize??12}" data-fit-min="${dr(r.shrinkMinFontSize)}" data-fit-mm="${d}"`:"";return`<div class="cell-fit" style="${u}"${f}>${s}</div>`}function ts(e,t){const r=e.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="${e.id}" style="border-collapse:collapse;table-layout:fixed;width:${i}mm;">
225
225
  <colgroup>${o}</colgroup>
226
226
  <tbody>${t}</tbody>
227
- </table>`}function Hb(e,t,n,r,o){const i=e.options,a=Po(i.left??0,o??i.top??0,i.width??100,void 0,i.zIndex,i),l=i._renderRows??[],c=yn(l,0,l.length,i,t,r,{elementId:e.id,kind:"b"});return`<div class="print-element" style="${a};overflow:visible;"${n}>
228
- ${es(e,c)}
229
- </div>`}function Ub(e,t,n){const r=e.options,o=Po(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex,r),i=r._renderRows??[],a=t.startRow??0,l=t.endRow??i.length,c=r._repeatHeaderCount??0,s=t.repeatHeader&&c>0?yn(i,0,c,r,!1,n,{elementId:e.id,kind:"b"},c):"",d=yn(i,a,l,r,!1,n,{elementId:e.id,kind:"b"}),p=t.subtotal?ru(e,t,r,n):"",u=t.summary?ou(e,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
230
- ${es(e,`${s}
227
+ </table>`}function Ub(e,t,n,r,o){const i=e.options,a=Io(i.left??0,o??i.top??0,i.width??100,void 0,i.zIndex,i),l=i._renderRows??[],c=yn(l,0,l.length,i,t,r,{elementId:e.id,kind:"b"});return`<div class="print-element" style="${a};overflow:visible;"${n}>
228
+ ${ts(e,c)}
229
+ </div>`}function qb(e,t,n){const r=e.options,o=Io(r.left??0,t.renderTop??r.top??0,r.width??100,void 0,r.zIndex,r),i=r._renderRows??[],a=t.startRow??0,l=t.endRow??i.length,c=r._repeatHeaderCount??0,s=t.repeatHeader&&c>0?yn(i,0,c,r,!1,n,{elementId:e.id,kind:"b"},c):"",d=yn(i,a,l,r,!1,n,{elementId:e.id,kind:"b"}),p=t.subtotal?ou(e,t,r,n):"",u=t.summary?iu(e,r,n):"";return`<div class="print-element" style="${o};overflow:visible;">
230
+ ${ts(e,`${s}
231
231
  ${d}${p}${u}`)}
232
- </div>`}function ru(e,t,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=t.startRow??0,d=t.endRow??c,p=Math.max(s,a),u=Math.max(d,p),f=u>a?i.slice(Math.max(p-a,0),u-a):[],g=r?.pageVars?Za(r.pageVars):{},m=o.map(b=>({...b,cells:b.cells.map(v=>v.rawFormatter?{...v,content:Qt(v.rawFormatter,{rows:f,...l,...g}),rawFormatter:""}:v)}));return yn(m,0,m.length,n,!1,r,{elementId:e.id,kind:"st"})}function ou(e,t,n){const r=t._summaryRows??[];return r.length===0?"":yn(r,0,r.length,t,!1,n,{elementId:e.id,kind:"sm"})}function qb(e,t,n,r){const o=e.options??{},a=(e.type||e.printElementType?.type||"text")==="flowList"&&pn(o.flowLayoutMode)==="dynamic",l=o.left??0,c=o.width??100,s=t.groupTop??o.top??0,d=yr(e)+ft(o).bottom,p=vo(o),u=p?`${p};`:"",f=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",g=`position:absolute;left:${Y(l)};top:${Y(s)};width:${Y(c)};overflow:visible;${f}`;let m="";if(a)m=Wb(e,t);else{const k=t.startRow??0,L=t.endRow??0;if(L>k||t.subtotal||t.summary){const R=o._renderRows??[],P=o._repeatHeaderCount??0,O=t.repeatHeader&&P>0?yn(R,0,P,o,!1,r,{elementId:e.id,kind:"b"},P):"",C=yn(R,k,L,o,!1,r,{elementId:e.id,kind:"b"}),I=t.subtotal?ru(e,t,o,r):"",S=t.summary?ou(e,o,r):"";m=`<div class="flow-slice" style="position:relative;width:${Y(c)};overflow:visible;${u}">
233
- ${es(e,`${O}
234
- ${C}${I}${S}`)}
235
- </div>`}}const b=t.followElementIds??[],v=b.reduce((k,L)=>{const R=ns(n,L);return R?Math.max(k,We({width:0,...R.options}).margin.bottom):k},d),w=b.map(k=>{const L=ns(n,k);if(!L)return"";const R=L.options?.top??0,P=L.options?.left??0,O=L.options?.width??c,C=L.options?.height??0,I=L.options?.zIndex,S=L.type||L.printElementType?.type||"text",$=S==="rect"||S==="oval"||S==="image"||S==="vline",N=vo(L.options),z=["position:absolute",`left:${Y(P-l)}`,`top:${Y(R-d)}`,`width:${Y(O)}`,...$&&C>0?[`height:${Y(C)}`]:[],...typeof I=="number"?[`z-index:${I}`]:[],"overflow:visible",...N?[N]:[]].join(";")+";";return Lo(L,!1,z,void 0,r)}).join(`
236
- `),E=b.length>0?`<div class="flow-follow" style="position:relative;width:${Y(c)};height:${Y(Math.max(v-d,0))};overflow:visible;">
232
+ </div>`}function ou(e,t,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=t.startRow??0,d=t.endRow??c,p=Math.max(s,a),u=Math.max(d,p),f=u>a?i.slice(Math.max(p-a,0),u-a):[],g=r?.pageVars?Ja(r.pageVars):{},m=o.map(y=>({...y,cells:y.cells.map(v=>v.rawFormatter?{...v,content:Qt(v.rawFormatter,{rows:f,...l,...g}),rawFormatter:""}:v)}));return yn(m,0,m.length,n,!1,r,{elementId:e.id,kind:"st"})}function iu(e,t,n){const r=t._summaryRows??[];return r.length===0?"":yn(r,0,r.length,t,!1,n,{elementId:e.id,kind:"sm"})}function Wb(e,t,n,r){const o=e.options??{},a=(e.type||e.printElementType?.type||"text")==="flowList"&&pn(o.flowLayoutMode)==="dynamic",l=o.left??0,c=o.width??100,s=t.groupTop??o.top??0,d=yr(e)+ft(o).bottom,p=vo(o),u=p?`${p};`:"",f=typeof o.zIndex=="number"?`z-index:${o.zIndex};`:"",g=`position:absolute;left:${Y(l)};top:${Y(s)};width:${Y(c)};overflow:visible;${f}`;let m="";if(a)m=jb(e,t);else{const T=t.startRow??0,P=t.endRow??0;if(P>T||t.subtotal||t.summary){const O=o._renderRows??[],I=o._repeatHeaderCount??0,A=t.repeatHeader&&I>0?yn(O,0,I,o,!1,r,{elementId:e.id,kind:"b"},I):"",k=yn(O,T,P,o,!1,r,{elementId:e.id,kind:"b"}),R=t.subtotal?ou(e,t,o,r):"",S=t.summary?iu(e,o,r):"";m=`<div class="flow-slice" style="position:relative;width:${Y(c)};overflow:visible;${u}">
233
+ ${ts(e,`${A}
234
+ ${k}${R}${S}`)}
235
+ </div>`}}const y=t.followElementIds??[],v=y.reduce((T,P)=>{const O=rs(n,P);return O?Math.max(T,We({width:0,...O.options}).margin.bottom):T},d),w=y.map(T=>{const P=rs(n,T);if(!P)return"";const O=P.options?.top??0,I=P.options?.left??0,A=P.options?.width??c,k=P.options?.height??0,R=P.options?.zIndex,S=P.type||P.printElementType?.type||"text",$=S==="rect"||S==="oval"||S==="image"||S==="vline",N=vo(P.options),B=["position:absolute",`left:${Y(I-l)}`,`top:${Y(O-d)}`,`width:${Y(A)}`,...$&&k>0?[`height:${Y(k)}`]:[],...typeof R=="number"?[`z-index:${R}`]:[],"overflow:visible",...N?[N]:[]].join(";")+";";return No(P,!1,B,void 0,r)}).join(`
236
+ `),E=y.length>0?`<div class="flow-follow" style="position:relative;width:${Y(c)};height:${Y(Math.max(v-d,0))};overflow:visible;">
237
237
  ${w}
238
238
  </div>`:"";return`<div class="flow-group" style="${g}">
239
239
  ${m}
240
240
  ${E}
241
- </div>`}function Wb(e,t){const n=e.options??{},r=Array.isArray(n._flowRows)?n._flowRows:[],o=t.startFlowRow??0,i=t.endFlowRow??0;if(o>=i)return"";const a=e.type||e.printElementType?.type||"flowList",l=pt(n.flowColumns),c=vt(n.flowGapX),s=Xt(n.flowRowHeight),d=vo(n),p=d?`${d};`:"";return`<div class="flow-slice" style="position:relative;width:${Y(n.width??100)};overflow:visible;${p}">
242
- <div class="print-flowlist-slice" style="position:relative;width:${Y(n.width??100)};${tu(a,n)}">
243
- ${Qa(r.slice(o,i),l,c,s,o)}
241
+ </div>`}function jb(e,t){const n=e.options??{},r=Array.isArray(n._flowRows)?n._flowRows:[],o=t.startFlowRow??0,i=t.endFlowRow??0;if(o>=i)return"";const a=e.type||e.printElementType?.type||"flowList",l=pt(n.flowColumns),c=vt(n.flowGapX),s=Xt(n.flowRowHeight),d=vo(n),p=d?`${d};`:"";return`<div class="flow-slice" style="position:relative;width:${Y(n.width??100)};overflow:visible;${p}">
242
+ <div class="print-flowlist-slice" style="position:relative;width:${Y(n.width??100)};${nu(a,n)}">
243
+ ${es(r.slice(o,i),l,c,s,o)}
244
244
  </div>
245
- </div>`}function ts(e,t,n,r,o){return e.map(i=>{let a=jb(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(`
246
- `)}function jb(e,t){return Lo(e,!1,void 0,void 0,t)}function ns(e,t){return e.elements.find(n=>n.id===t)}function rs(e){return ht(e)}function wt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Gb=25.4;function Vb(e,t){const n=e.margins?.bottom??0,r=e.footer?.height??0,o=Math.max(t,0)+r+n;return Math.max(Gb,Math.round(o*100)/100)}const iu=3.7795275591;function os(e){return e/iu}function Fo(e){return Math.round(e*iu)}function zo(e){return typeof e=="number"&&e>0?e:void 0}function Yb(e){return zo(e.paperHeightMm)??zo(e.override?.height)}function Kb(e){const t=zo(e.override?.width)??e.paperMm.width,n=zo(e.override?.height);return e.continuous?n?{paperMm:{width:t,height:n},heightSource:"config"}:{paperMm:{width:t,height:e.paperMm.height},heightSource:"derived"}:{paperMm:{width:t,height:n??e.paperMm.height},heightSource:"config"}}function au(e){return{width:Fo(e.width),height:Fo(e.height)}}function Xb(e){return(e?.type??e?.printElementType?.type)!=="flowList"?!1:pn(e?.options?.flowLayoutMode)==="dynamic"}function su(e,t){const n=new Map(t.elements.map(o=>[o.id,o])),r=new Map;for(const o of e){const i=n.get(o.id),a=i?.options?._repeatHeaderCount??0,l=o.rowHeightsPx?.map(os),c=Xb(i);r.set(o.id,{id:o.id,measuredHeight:os(o.heightPx),...c?{measuredFlowRowHeights:l}:{measuredRowHeights:l},repeatHeaderHeight:l&&l.length>0&&a>0?l.slice(0,a).reduce((s,d)=>s+d,0):0})}return r}const Zb={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function lu(e,t){if(!t||t.length===0)return;const n=new Map,r=o=>{for(const i of o??[])n.set(i.id,i)};r(e.elements),r(e.header?.elements),r(e.footer?.elements);for(const o of t){const i=tm(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=sa(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[Zb[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=sa(o.fontSizePt))}}function cu(e,t,n={}){return JSON.stringify([e,t,n.barcodeType??null,n.qrCodeLevel??null,n.showText??null,n.barWidth??null,n.fontSize??null,n.qrQuietZone??null,n.barQuietZone??null,n.barHeightMm??null])}function Jb(e){return{render(t,n,r){const o=e.get(cu(t,n,r));if(!o)throw new Error(`码值未渲染:${t}`);return o}}}function Qb(e){const t=new Map;return{renderer:{render(n,r,o={}){const i=cu(n,r,o),a=e?.get(i);if(a)return a;throw t.set(i,{key:i,value:n,cellType:r,opts:o}),new Error("collect")}},takeSpecs(){const n=[...t.values()];return t.clear(),n}}}function e1(...e){const t=new Map;for(const n of e)for(const[r,o]of n)t.set(r,o);return t}const t1={waitReady:"window",readMeasurements:"document",readContentBottom:"document",readElementRects:"document",renderCodes:"none",renderAssets:"none",applyTextFit:"document"},n1=3e4,r1=5e3;function o1(e,t,n=[]){return{async withSession(r,o){const i=await e.createDriver(),a=Date.now()+(r.timeoutMs??n1),l=r.readinessMs??r1,c=()=>Math.max(1,a-Date.now()),s=(b,v,w)=>yb(b,v,w);let d=!1,p=!1;const u=async()=>{if(!d){if(i.requiresExecutor===!1){d=!0;return}throw new qn("INTERNAL","缺少 core DOM 执行器产物")}},f=async()=>{if(p)return;if(i.requiresExecutor===!1){p=!0;return}const b=new Set;for(const v of n)b.has(v.version)||(b.add(v.version),await i.injectExecutor(v));p=!0},g=async(b,v)=>{await i.open(v),await i.setContent(b),d=!1,p=!1,await u(),await i.evaluate("waitReady",[l])},m={async renderCodes(b){if(b.length===0)return new Map;const v=c();return Ar((async()=>{try{await u();const w=await i.evaluate("renderCodes",[b]);return new Map(Object.entries(w))}catch(w){throw s(w,"INTERNAL","码值渲染失败")}})(),v,"RENDER_TIMEOUT",`码值渲染超过 ${v}ms`)},async renderAssets(b){if(b.length===0)return new Map;const v=c();return Ar((async()=>{try{await u(),await f();const w=Mb("renderAssets"),E=await i.evaluate(w,[b]);return new Map(Object.entries(E??{}))}catch(w){throw s(w,"INTERNAL","扩展元素渲染失败")}})(),v,"RENDER_TIMEOUT",`扩展元素渲染超过 ${v}ms`)},async measure(b,v){const w=c();return Ar((async()=>{try{await g(b,v);const E=await i.evaluate("applyTextFit")??[];return{measurements:await i.evaluate("readMeasurements"),fits:E}}catch(E){throw s(E,"MEASURE_FAILED","测量失败")}})(),w,"RENDER_TIMEOUT",`测量超过 ${w}ms`)},async probeContentBottom(b,v){const w=c();return Ar((async()=>{try{return await g(b,v),await i.evaluate("readContentBottom")}catch(E){throw s(E,"MEASURE_FAILED","连续纸探针失败")}})(),w,"RENDER_TIMEOUT",`连续纸探针超过 ${w}ms`)},async toPdf(b,v,w){if(!i.pdf)throw new qn("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const E=c();return Ar((async()=>{try{return await g(b,w),await i.pdf(b,v)}catch(k){throw s(k,"PDF_FAILED","PDF 生成失败")}})(),E,"RENDER_TIMEOUT",`PDF 生成超过 ${E}ms`)}};try{return await o(m)}finally{try{await i.close()}catch{}}}}}const du=500;function i1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function uu(e){if(e===void 0)return{mode:"single",data:{}};if(!Array.isArray(e))return{mode:"single",data:e};if(e.length===0)throw new Error("批量打印数据必须是非空对象数组");if(e.length>du)throw new Error(`批量打印最多支持 ${du} 份,当前 ${e.length} 份`);for(let t=0;t<e.length;t++)if(!i1(e[t]))throw new Error(`批量打印数据第 ${t+1} 项必须是对象`);return{mode:"batch",dataList:e}}function a1(e){const t=e[0].bound,n=At(t),r=e.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=$o(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,renderers:a.renderers,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
245
+ </div>`}function ns(e,t,n,r,o){return e.map(i=>{let a=Gb(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(`
246
+ `)}function Gb(e,t){return No(e,!1,void 0,void 0,t)}function rs(e,t){return e.elements.find(n=>n.id===t)}function os(e){return ht(e)}function wt(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Vb=25.4;function Yb(e,t){const n=e.margins?.bottom??0,r=e.footer?.height??0,o=Math.max(t,0)+r+n;return Math.max(Vb,Math.round(o*100)/100)}const au=3.7795275591;function is(e){return e/au}function Lo(e){return Math.round(e*au)}function Bo(e){return typeof e=="number"&&e>0?e:void 0}function Kb(e){return Bo(e.paperHeightMm)??Bo(e.override?.height)}function Xb(e){const t=Bo(e.override?.width)??e.paperMm.width,n=Bo(e.override?.height);return e.continuous?n?{paperMm:{width:t,height:n},heightSource:"config"}:{paperMm:{width:t,height:e.paperMm.height},heightSource:"derived"}:{paperMm:{width:t,height:n??e.paperMm.height},heightSource:"config"}}function su(e){return{width:Lo(e.width),height:Lo(e.height)}}function Zb(e){return(e?.type??e?.printElementType?.type)!=="flowList"?!1:pn(e?.options?.flowLayoutMode)==="dynamic"}function lu(e,t){const n=new Map(t.elements.map(o=>[o.id,o])),r=new Map;for(const o of e){const i=n.get(o.id),a=i?.options?._repeatHeaderCount??0,l=o.rowHeightsPx?.map(is),c=Zb(i);r.set(o.id,{id:o.id,measuredHeight:is(o.heightPx),...c?{measuredFlowRowHeights:l}:{measuredRowHeights:l},repeatHeaderHeight:l&&l.length>0&&a>0?l.slice(0,a).reduce((s,d)=>s+d,0):0})}return r}const Jb={b:"_renderRows",st:"_subtotalTemplates",sm:"_summaryRows"};function cu(e,t){if(!t||t.length===0)return;const n=new Map,r=o=>{for(const i of o??[])n.set(i.id,i)};r(e.elements),r(e.header?.elements),r(e.footer?.elements);for(const o of t){const i=nm(o.key);if(!i){const s=n.get(o.key);s&&(s.options._fitFontSize=la(o.fontSizePt));continue}const c=n.get(i.elementId)?.options?.[Jb[i.kind]]?.[i.rowIndex]?.cells?.[i.colIndex];c&&(c.fittedFontSize=la(o.fontSizePt))}}function du(e,t,n={}){return JSON.stringify([e,t,n.barcodeType??null,n.qrCodeLevel??null,n.showText??null,n.barWidth??null,n.fontSize??null,n.qrQuietZone??null,n.barQuietZone??null,n.barHeightMm??null])}function Qb(e){return{render(t,n,r){const o=e.get(du(t,n,r));if(!o)throw new Error(`码值未渲染:${t}`);return o}}}function e1(e){const t=new Map;return{renderer:{render(n,r,o={}){const i=du(n,r,o),a=e?.get(i);if(a)return a;throw t.set(i,{key:i,value:n,cellType:r,opts:o}),new Error("collect")}},takeSpecs(){const n=[...t.values()];return t.clear(),n}}}function t1(...e){const t=new Map;for(const n of e)for(const[r,o]of n)t.set(r,o);return t}const n1={waitReady:"window",readMeasurements:"document",readContentBottom:"document",readElementRects:"document",renderCodes:"none",renderAssets:"none",applyTextFit:"document"},r1=3e4,o1=5e3;function i1(e,t,n=[]){return{async withSession(r,o){const i=await e.createDriver(),a=Date.now()+(r.timeoutMs??r1),l=r.readinessMs??o1,c=()=>Math.max(1,a-Date.now()),s=(y,v,w)=>vb(y,v,w);let d=!1,p=!1;const u=async()=>{if(!d){if(i.requiresExecutor===!1){d=!0;return}throw new qn("INTERNAL","缺少 core DOM 执行器产物")}},f=async()=>{if(p)return;if(i.requiresExecutor===!1){p=!0;return}const y=new Set;for(const v of n)y.has(v.version)||(y.add(v.version),await i.injectExecutor(v));p=!0},g=async(y,v)=>{await i.open(v),await i.setContent(y),d=!1,p=!1,await u(),await i.evaluate("waitReady",[l])},m={async renderCodes(y){if(y.length===0)return new Map;const v=c();return Ar((async()=>{try{await u();const w=await i.evaluate("renderCodes",[y]);return new Map(Object.entries(w))}catch(w){throw s(w,"INTERNAL","码值渲染失败")}})(),v,"RENDER_TIMEOUT",`码值渲染超过 ${v}ms`)},async renderAssets(y){if(y.length===0)return new Map;const v=c();return Ar((async()=>{try{await u(),await f();const w=Tb("renderAssets"),E=await i.evaluate(w,[y]);return new Map(Object.entries(E??{}))}catch(w){throw s(w,"INTERNAL","扩展元素渲染失败")}})(),v,"RENDER_TIMEOUT",`扩展元素渲染超过 ${v}ms`)},async measure(y,v){const w=c();return Ar((async()=>{try{await g(y,v);const E=await i.evaluate("applyTextFit")??[];return{measurements:await i.evaluate("readMeasurements"),fits:E}}catch(E){throw s(E,"MEASURE_FAILED","测量失败")}})(),w,"RENDER_TIMEOUT",`测量超过 ${w}ms`)},async probeContentBottom(y,v){const w=c();return Ar((async()=>{try{return await g(y,v),await i.evaluate("readContentBottom")}catch(E){throw s(E,"MEASURE_FAILED","连续纸探针失败")}})(),w,"RENDER_TIMEOUT",`连续纸探针超过 ${w}ms`)},async toPdf(y,v,w){if(!i.pdf)throw new qn("UNSUPPORTED_RUNTIME","当前宿主不支持生成 PDF");const E=c();return Ar((async()=>{try{return await g(y,w),await i.pdf(y,v)}catch(T){throw s(T,"PDF_FAILED","PDF 生成失败")}})(),E,"RENDER_TIMEOUT",`PDF 生成超过 ${E}ms`)}};try{return await o(m)}finally{try{await i.close()}catch{}}}}}const uu=500;function a1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pu(e){if(e===void 0)return{mode:"single",data:{}};if(!Array.isArray(e))return{mode:"single",data:e};if(e.length===0)throw new Error("批量打印数据必须是非空对象数组");if(e.length>uu)throw new Error(`批量打印最多支持 ${uu} 份,当前 ${e.length} 份`);for(let t=0;t<e.length;t++)if(!a1(e[t]))throw new Error(`批量打印数据第 ${t+1} 项必须是对象`);return{mode:"batch",dataList:e}}function s1(e){const t=e[0].bound,n=At(t),r=e.map((a,l)=>{const c=n?`print-copy print-copy-${l}`:"print-copy",s=Fo(a.bound,a.pageLayouts,a.data,{codeRenderer:a.codeRenderer,renderers:a.renderers,pageHeightMm:a.derivedHeightMm});return`<section class="${c}">
247
247
  ${s}
248
248
  </section>`}).join(`
249
- `),o=n?ab(t,e.map(a=>({heightMm:a.derivedHeightMm}))):`${kr(t)}
250
- .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=Mr(t.fonts)+o;return{html:No(i,r,n?"continuous":void 0),pageCount:e.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:e.map(a=>a.paperMm)}}const Pt={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class s1 extends Error{constructor(t,n){super(n),this.name="TilingError",this.code=t}}function vn(e){return Math.round(e*10)/10}function pu(e,t){const n=e.outputRotation;return n===90||n===270?`(内容旋转 ${n}°,每格 ${t.width}×${t.height}mm)`:""}function Bo(e){const t=e.tiling;return{...Pt,...t,sheetMargin:{...Pt.sheetMargin,...t?.sheetMargin??{}}}}function Ir(e,t){const n=Bo(e),r=t?.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??hn.A4.width,height:n.sheetCustomHeight??hn.A4.height};const o=n.sheetPaperSize??"A4",i=hn[o]??hn.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function fu(e,t){return{w:e.width-t.left-t.right,h:e.height-t.top-t.bottom}}function is(e,t,n){return Math.max(0,Math.floor((e+n)/(t+n)))}function hu(e,t){const n=as(e,t);if(n.length)throw new s1(n[0].code,n[0].message);const r=Bo(e),o=Ir(e,t),i=gn(e),a=fu(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:is(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function l1(e,t){const n=t%e.perSheet,r=n%e.columns,o=Math.floor(n/e.columns);return{left:vn(e.margin.left+r*(e.tile.width+e.gapX)),top:vn(e.margin.top+o*(e.tile.height+e.gapY))}}function gu(e,t){const n=Bo(e),r=Ir(e,t),o=gn(e),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return is(i,o.width,n.gapX)}function as(e,t){const n=[],r=Bo(e);At(e)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=Fn(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=Ir(e,t),c=gn(e),s=fu(l,r.sheetMargin),d=vn(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=is(s.w,c.width,r.gapX);if(r.columns>p){const u=vn(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+vn(l.width)+"mm − 左右留白 "+d+"mm = "+vn(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"+pu(e,c)})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+vn(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"+pu(e,c)}),n}function c1(e){const t=[],n=new Set;for(const r of e)for(const o of r.warnings??[])n.has(o)||(n.add(o),t.push(o));return t}function d1(e){const t=Array.isArray(e.pages)?e.pages:[e],n=[];for(const r of t)try{n.push(...xa(r,new Map))}catch{}return c1(n)}function u1(e){const{copies:t,layout:n}=e,r=t[0].bound,o=[];for(let a=0;a<t.length;a+=n.perSheet){const l=t.slice(a,a+n.perSheet).map((c,s)=>{const d=l1(n,s),p=$o(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer,renderers:c.renderers});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
249
+ `),o=n?sb(t,e.map(a=>({heightMm:a.derivedHeightMm}))):`${Cr(t)}
250
+ .print-copy:not(:last-child){break-after:page;page-break-after:always;}`,i=Mr(t.fonts)+o;return{html:$o(i,r,n?"continuous":void 0),pageCount:e.reduce((a,l)=>a+l.pageLayouts.length,0),copyPaperMm:e.map(a=>a.paperMm)}}const It={enabled:!0,sheetPaperSize:"A4",sheetOrientation:"portrait",sheetMargin:{top:10,right:10,bottom:10,left:10},gapX:2,gapY:2,columns:2};class l1 extends Error{constructor(t,n){super(n),this.name="TilingError",this.code=t}}function vn(e){return Math.round(e*10)/10}function fu(e,t){const n=e.outputRotation;return n===90||n===270?`(内容旋转 ${n}°,每格 ${t.width}×${t.height}mm)`:""}function zo(e){const t=e.tiling;return{...It,...t,sheetMargin:{...It.sheetMargin,...t?.sheetMargin??{}}}}function Or(e,t){const n=zo(e),r=t?.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??hn.A4.width,height:n.sheetCustomHeight??hn.A4.height};const o=n.sheetPaperSize??"A4",i=hn[o]??hn.A4;return n.sheetOrientation==="landscape"?{width:i.height,height:i.width}:{...i}}function hu(e,t){return{w:e.width-t.left-t.right,h:e.height-t.top-t.bottom}}function as(e,t,n){return Math.max(0,Math.floor((e+n)/(t+n)))}function gu(e,t){const n=ss(e,t);if(n.length)throw new l1(n[0].code,n[0].message);const r=zo(e),o=Or(e,t),i=gn(e),a=hu(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:as(a.w,i.width,r.gapX),margin:{...r.sheetMargin},gapX:r.gapX,gapY:r.gapY}}function c1(e,t){const n=t%e.perSheet,r=n%e.columns,o=Math.floor(n/e.columns);return{left:vn(e.margin.left+r*(e.tile.width+e.gapX)),top:vn(e.margin.top+o*(e.tile.height+e.gapY))}}function mu(e,t){const n=zo(e),r=Or(e,t),o=gn(e),i=r.width-n.sheetMargin.left-n.sheetMargin.right;return as(i,o.width,n.gapX)}function ss(e,t){const n=[],r=zo(e);At(e)&&n.push({code:"CONTINUOUS_UNSUPPORTED",message:"连续纸不支持拼版打印,请将模板纸张改为固定纸张或关闭拼版"});const o=r.sheetPaperSize,i=Ln(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=Or(e,t),c=gn(e),s=hu(l,r.sheetMargin),d=vn(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=as(s.w,c.width,r.gapX);if(r.columns>p){const u=vn(r.columns*c.width+(r.columns-1)*r.gapX);n.push({code:"COLUMNS_OVERFLOW",message:"拼版列数 "+r.columns+" 超出纸面可用宽度:"+vn(l.width)+"mm − 左右留白 "+d+"mm = "+vn(s.w)+"mm,最多可放 "+p+" 列;当前 "+r.columns+" 列 "+c.width+"mm 标签含间距需要 "+u+"mm"+fu(e,c)})}return Math.floor((s.h+r.gapY)/(c.height+r.gapY))<1&&n.push({code:"LABEL_TOO_TALL",message:"标签高度 "+c.height+"mm 超出纸面可用高度 "+vn(s.h)+"mm,拼版每张 0 行;请缩小标签高度或改用横向纸"+fu(e,c)}),n}function d1(e){const t=[],n=new Set;for(const r of e)for(const o of r.warnings??[])n.has(o)||(n.add(o),t.push(o));return t}function u1(e){const t=Array.isArray(e.pages)?e.pages:[e],n=[];for(const r of t)try{n.push(...Ea(r,new Map))}catch{}return d1(n)}function p1(e){const{copies:t,layout:n}=e,r=t[0].bound,o=[];for(let a=0;a<t.length;a+=n.perSheet){const l=t.slice(a,a+n.perSheet).map((c,s)=>{const d=c1(n,s),p=Fo(c.bound,c.pageLayouts,c.data,{codeRenderer:c.codeRenderer,renderers:c.renderers});return`<div class="print-tile" style="left:${d.left}mm;top:${d.top}mm">
251
251
  ${p}
252
252
  </div>`}).join(`
253
253
  `);o.push(`<section class="print-sheet">
254
254
  ${l}
255
- </section>`)}const i=Mr(r.fonts)+kr(r)+`
256
- `+sb(n);return{html:No(i,o.join(`
257
- `)),sheetCount:o.length,perSheet:n.perSheet}}function ss(e,t){return e.name?`第 ${t+1} 页「${e.name}」`:`第 ${t+1} 页`}function ls(e){const t=p1(e)?e.pages:[e];if(t.length===0)throw new Error("多页面模板至少需要一页");if(t.length===1)return t;const n=ht(t[0]);return t.forEach((r,o)=>{if(At(r))throw new Error(`多页面模板不支持连续纸(${ss(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${ss(r,o)})`);const i=ht(r),a=i.width===n.width&&i.height===n.height,l=i.width===n.height&&i.height===n.width;if(!a&&!l)throw new Error(`多页面模板各页纸张尺寸必须一致(${ss(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),t}function p1(e){return Array.isArray(e.pages)}function f1(e){const t=new Set,n=[];for(const r of e)for(const o of r.fonts??[]){const i=o.family;t.has(i)||(t.add(i),n.push(o))}return n}function h1(e){if(e.length===0)throw new Error("多页面模板至少需要一份数据");const t=e[0].boundPages,n=Mr(f1(t))+[rb(),...t.flatMap((c,s)=>[ob(c,void 0,`mt-${s}`),`.mt-${s}.print-page { page: mt-${s}; }`,ib(c,`.mt-${s}`)]),...e.length>1?[Xa]:[]].join(`
255
+ </section>`)}const i=Mr(r.fonts)+Cr(r)+`
256
+ `+lb(n);return{html:$o(i,o.join(`
257
+ `)),sheetCount:o.length,perSheet:n.perSheet}}function ls(e,t){return e.name?`第 ${t+1} 页「${e.name}」`:`第 ${t+1} 页`}function cs(e){const t=f1(e)?e.pages:[e];if(t.length===0)throw new Error("多页面模板至少需要一页");if(t.length===1)return t;const n=ht(t[0]);return t.forEach((r,o)=>{if(At(r))throw new Error(`多页面模板不支持连续纸(${ls(r,o)})`);if(r.tiling?.enabled===!0)throw new Error(`多页面模板不支持标签拼版(${ls(r,o)})`);const i=ht(r),a=i.width===n.width&&i.height===n.height,l=i.width===n.height&&i.height===n.width;if(!a&&!l)throw new Error(`多页面模板各页纸张尺寸必须一致(${ls(r,o)} ${i.width}×${i.height}mm 与首页 ${n.width}×${n.height}mm 不同)`)}),t}function f1(e){return Array.isArray(e.pages)}function h1(e){const t=new Set,n=[];for(const r of e)for(const o of r.fonts??[]){const i=o.family;t.has(i)||(t.add(i),n.push(o))}return n}function g1(e){if(e.length===0)throw new Error("多页面模板至少需要一份数据");const t=e[0].boundPages,n=Mr(h1(t))+[ob(),...t.flatMap((c,s)=>[ib(c,void 0,`mt-${s}`),`.mt-${s}.print-page { page: mt-${s}; }`,ab(c,`.mt-${s}`)]),...e.length>1?[Za]:[]].join(`
258
258
 
259
- `),r=e.map(c=>{const s=c.layoutsPerPage.reduce((f,g)=>f+g.length,0);let d=0;const u=c.layoutsPerPage.map((f,g)=>{const m=$o(c.boundPages[g],f,c.data,{codeRenderer:c.codeRenderers?.[g],renderers:c.renderersPerPage?.[g]},{pageOffset:d,totalPages:s,pageClass:`mt-${g}`});return d+=f.length,m}).join(`
259
+ `),r=e.map(c=>{const s=c.layoutsPerPage.reduce((f,g)=>f+g.length,0);let d=0;const u=c.layoutsPerPage.map((f,g)=>{const m=Fo(c.boundPages[g],f,c.data,{codeRenderer:c.codeRenderers?.[g],renderers:c.renderersPerPage?.[g]},{pageOffset:d,totalPages:s,pageClass:`mt-${g}`});return d+=f.length,m}).join(`
260
260
  `);return e.length>1?`<section class="print-copy">
261
261
  ${u}
262
262
  </section>`:u}).join(`
263
- `),o=e.reduce((c,s)=>c+s.layoutsPerPage.reduce((d,p)=>d+p.length,0),0),i=[],a=[];let l=0;for(const c of e)for(const[s,d]of c.layoutsPerPage.entries()){const p=gn(c.boundPages[s]);for(const u of d)i.push({...u,pageIndex:l++}),a.push({...p})}return{html:No(n,r),pageCount:o,pagePaperMm:a,pageLayouts:i}}async function g1(e,t){return t.withSession(e,n=>m1(e,n))}async function m1(e,t){const n=ls(e.templateJson);if(n.length>1){const c=uu(e.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await y1(e,t,s[u]))}catch(f){const g=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${g}`)}const p=h1(d);return{html:p.html,pageCount:p.pageCount,paperMm:gn(n[0]),pagePaperMm:p.pagePaperMm,continuous:!1,heightSource:"config",pageLayouts:p.pageLayouts,copies:d.length}}const r=n[0]!==e.templateJson?{...e,templateJson:n[0]}:e,o=n[0],i=uu(r.printData);if(i.mode==="single"){const c=await bu(r,t,i.data);return o.tiling?.enabled===!0?mu(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,renderers:c.renderers,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):b1(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await bu(r,t,i.dataList[c]);a.push({bound:s.bound,pageLayouts:s.pageLayouts,data:i.dataList[c],codeRenderer:s.codeRenderer,renderers:s.renderers,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 mu(r,a);const l=a1(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:At(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function b1(e){return{html:e.html,pageCount:e.pageCount,paperMm:e.paperMm,continuous:e.continuous,heightSource:e.heightSource,pageLayouts:e.pageLayouts,copies:1}}function mu(e,t){const n=t[0].bound,r=hu(n,{paperOverride:e.paperOverride});t.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=u1({copies:t.map(i=>({bound:i.bound,pageLayouts:i.pageLayouts,data:i.data,codeRenderer:i.codeRenderer,renderers:i.renderers})),layout:r});return{html:o.html,pageCount:o.sheetCount,paperMm:{width:r.sheet.width,height:r.sheet.height},continuous:!1,heightSource:"config",pageLayouts:t.flatMap(i=>i.pageLayouts),copies:t.length}}async function bu(e,t,n){const r=Ad(e.templateJson,n,e.baseUrl,e.fontBaseUrl),o=At(r),i=ht(r),a=au(i),l=Yb({paperHeightMm:e.paperHeightMm,override:e.paperOverride}),c=await Ho({bound:r,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await t.measure(c.html,a);lu(r,s.fits);const d=xa(r,su(s.measurements,r)),p=await Ho({bound:r,job:e,session:t,data:n,pageLayouts:d,isMeasurementPass:!1,codeBaseMap:c.codeMap,assetBaseMap:c.assetMap});let u=p.html,f;if(o){if(l&&l>0)f=l;else{const w=await t.probeContentBottom(u,a);f=Vb(r,os(w))}u=Do(r,d,n,{codeRenderer:p.codeRenderer,renderers:p.renderers,pageHeightMm:f})}const g=o&&l?{...e.paperOverride,height:l}:e.paperOverride,m=gn(r),{paperMm:b,heightSource:v}=Kb({paperMm:{width:m.width,height:f??m.height},continuous:o,override:g});return{html:u,pageCount:d.length,paperMm:b,continuous:o,heightSource:v,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,renderers:p.renderers,derivedHeightMm:f}}async function y1(e,t,n){const r=ls(e.templateJson),o=[],i=[],a=[],l=[];for(const c of r){const s=au(ht(c)),d=Ad(c,n,e.baseUrl,e.fontBaseUrl),p=await Ho({bound:d,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),u=await t.measure(p.html,s);lu(d,u.fits);const f=xa(d,su(u.measurements,d)),g=await Ho({bound:d,job:e,session:t,data:n,pageLayouts:f,isMeasurementPass:!1,codeBaseMap:p.codeMap,assetBaseMap:p.assetMap});o.push(d),i.push(f),a.push(g.codeRenderer),l.push(g.renderers)}return{boundPages:o,layoutsPerPage:i,data:n,codeRenderers:a,renderersPerPage:l}}async function Ho(e){const t=e.codeBaseMap??new Map,n=e.assetBaseMap??new Map,{job:r}=e,o=xb(),i=r.renderers;if(r.codeRenderer&&(o.length===0||i))return{html:Do(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:r.codeRenderer,renderers:i}),codeRenderer:r.codeRenderer,renderers:i,codeMap:t,assetMap:n};const a=Qb(t),l=vb(n),c=r.codeRenderer??a.renderer,s=i??(o.length>0?Xd(l.renderer,o):void 0),d=Do(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:c,renderers:s}),p=r.codeRenderer?[]:a.takeSpecs(),u=i?[]:l.takeSpecs(),[f,g]=await Promise.all([p.length>0?e.session.renderCodes(p):Promise.resolve(new Map),Sb(u,e.session)]),m=e1(t,f),b=Kd(n,g),v=r.codeRenderer??(m.size>0?Jb(m):void 0),w=i??(b.size>0?Xd(wb(b),o):s);return p.length===0&&u.length===0?{html:d,codeRenderer:v,renderers:w,codeMap:m,assetMap:b}:{html:Do(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:v,renderers:w}),codeRenderer:v,renderers:w,codeMap:m,assetMap:b}}class v1{constructor(t){this.functions={},t?.functions&&(this.functions={...t.functions})}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Da(t),o=$a(r);return Ke(o,n,this.functions)}render(t,n){return hd(t,this.functions)(n)}}const yu=new v1,w1={MONEY:gd,CONCAT:(...e)=>e.filter(t=>t!=null).join(""),IF:yd,FORMAT:e=>typeof e!="number"?String(e):e.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(e,t,n)=>String(e).slice(t,n?t+n:void 0),LEN:e=>String(e).length,ADD:Sd,SUB:_d,MUL:Md,DIV:Td,ROUND:kd,ROUNDUP:ko,CEIL:ko,ROUNDDOWN:Co,FLOOR:Co,ROUNDBANK:Cd,NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,PAD:(e,t,n)=>String(e).padStart(t,n),REPLACE:(e,t,n)=>String(e).replace(new RegExp(t,"g"),n),JSON:e=>JSON.stringify(e,null,2),DATE:md,UPPER:bd};for(const[e,t]of Object.entries(w1))yu.registerFunction(e,t);function x1(e,t,n){switch(e.toUpperCase()){case"SUM":return Ha(n,t);case"AVG":return vd(n,t);case"COUNT":return wd(n);case"MIN":return xd(n,t);case"MAX":return Ed(n,t);default:return 0}}function Wn(e,t){if(!e)return"";if(!e.includes("{"))return e;const n=Array.isArray(t.rows)?t.rows:[];let r=e.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(x1(c,d,n))}),`{${a}}`});try{return yu.render(r,t)}catch{return e}}const gt={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级"}]},Uo={left:0,center:50,right:100},qo={top:0,center:50,bottom:100};function jn(e){return Number.isFinite(e)?Math.round(Math.min(100,Math.max(0,e))):50}function vu(e){return Math.round(e*100)/100}function wu(e,t){const n=jn(e),r=jn(t);if(!(n===50&&r===50))return`${n}% ${r}%`}function E1(e){return/^\d+(?:\.\d+)?%$/.test(e)?parseFloat(e):void 0}function S1(e){const t=(e??"").trim();if(!t)return{kind:"empty"};const n=t.toLowerCase().split(/\s+/);let r,o;for(let i=0;i<n.length;i++){const a=n[i],l=E1(a);if(i===0)if(a in Uo)r=Uo[a];else if(l!==void 0)r=l;else if(a in qo)o=qo[a];else return{kind:"custom",raw:e};else if(a in qo&&o===void 0)o=qo[a];else if(l!==void 0&&r===void 0)r=l;else if(l!==void 0&&o===void 0)o=l;else if(a in Uo&&r===void 0)r=Uo[a];else return{kind:"custom",raw:e}}return{kind:"axes",x:jn(r??50),y:jn(o??50)}}const xu=25.4/96;function Eu(e){const{widthMm:t,heightMm:n,naturalWidth:r,naturalHeight:o}=e;if(!r||!o||!t||!n)return null;const i=t/r,a=n/o,l=(Pc(e.fit,e.scalePct)??gr)/100;switch(e.fit||"contain"){case"fill":return{w:t,h:n};case"cover":{const c=Math.max(i,a)*l;return{w:r*c,h:o*c}}case"none":return{w:r*xu,h:o*xu};case"scale-down":{const c=Math.min(1,Math.min(i,a));return{w:r*c,h:o*c}}default:{const c=Math.min(i,a);return{w:r*c,h:o*c}}}}function _1(e){const t=Eu(e);return t?{x:vu(Math.abs(e.widthMm-t.w)),y:vu(Math.abs(e.heightMm-t.h))}:{x:null,y:null}}function M1(e,t,n){const r=Eu(e);if(!r)return null;const o=Math.min(1,e.widthMm/r.w),i=Math.min(1,e.heightMm/r.h);return{leftPct:(1-o)*jn(t),topPct:(1-i)*jn(n),widthPct:o*100,heightPct:i*100}}function Su(e){const t=String(e??"");return t?t.includes("{")?String(Wn(t,gt)):t:""}const _u={vertical:[{value:0,label:"顶部"},{value:50,label:"居中"},{value:100,label:"底部"}],horizontal:[{value:0,label:"左侧"},{value:50,label:"居中"},{value:100,label:"右侧"}]},T1=[{x:0,y:0,label:"左上"},{x:50,y:0,label:"上中"},{x:100,y:0,label:"右上"},{x:0,y:50,label:"左中"},{x:50,y:50,label:"居中"},{x:100,y:50,label:"右中"},{x:0,y:100,label:"左下"},{x:50,y:100,label:"下中"},{x:100,y:100,label:"右下"}],cs=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"剪裁(等比铺满后裁边)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],k1="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNNDAgMFYxMjBNODAgMFYxMjBNMCA0MEgxMjBNMCA4MEgxMjAiIHN0cm9rZT0iI2VlZjFmNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMy41IiBmaWxsPSIjOGI5NWE1Ii8+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMjAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iMTAwIiByPSIzLjUiIGZpbGw9IiM4Yjk1YTUiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iMjAiIHI9IjciIGZpbGw9IiNjMDM5MmIiLz48Y2lyY2xlIGN4PSI2MCIgY3k9IjEwMCIgcj0iNyIgZmlsbD0iIzFmNGZhMyIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iNjAiIHI9IjciIGZpbGw9IiMyYzdhNGEiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSI2MCIgcj0iNyIgZmlsbD0iI2UwN2EyMCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjE0IiBmaWxsPSJub25lIiBzdHJva2U9IiMyZjNhNGEiIHN0cm9rZS13aWR0aD0iNCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYiIGZpbGw9IiMyZjNhNGEiLz48L3N2Zz4=",C1="图片还没设置,上面按内置示例图演示取位;换上真图后档位与可挪量按真图重算";function A1(e){const t=String(e??"").trim();return!t||t.includes("{")||t.includes("}")?{src:k1,isSample:!0}:{src:t,isSample:!1}}function Mu(e){return e==="vertical"?"垂直位置 (%)":"水平位置 (%)"}const O1="放大比例 (%)";function I1(e,t=!1){if(t)return"已保留模板里的原值;改动下面任一项就整体替换成新的取位";const{x:n,y:r}=e;return n===null||r===null?"":n>0&&r>0?`水平可挪 ${n}mm、垂直可挪 ${r}mm:0 贴左/贴顶,100 贴右/贴底`:n>0?`水平可挪 ${n}mm;垂直这一轴已贴满,挪不动`:r>0?`垂直可挪 ${r}mm;水平这一轴已贴满,挪不动`:"这个缩放下图与框正好一样大,两轴都没有可挪的余量"}function P1(e,t,n){return[{name:"horizontal",label:Mu("horizontal"),value:t,travelMm:e.x},{name:"vertical",label:Mu("vertical"),value:n,travelMm:e.y}]}function R1(e,t,n){const r=e.x!==null&&e.x>0,o=e.y!==null&&e.y>0;return o&&!r?_u.vertical.map(i=>({value:`${t},${i.value}`,label:i.label})):r&&!o?_u.horizontal.map(i=>({value:`${i.value},${n}`,label:i.label})):T1.map(i=>({value:`${i.x},${i.y}`,label:i.label}))}function Tu(e){const t=[...e].sort((a,l)=>(a.sortOrder??0)-(l.sortOrder??0)),n=new Map,r=[];for(const a of t){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 t){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 D1(e,t){const n=t.trim().toLowerCase();return n?e.map(r=>({...r,fields:r.fields.filter(o=>o.fieldLabel.toLowerCase().includes(n)||o.fieldKey.toLowerCase().includes(n))})).filter(r=>r.fields.length>0):e}async function ku(e){if(!e)return!1;const t=typeof navigator>"u"?void 0:navigator;if(t?.clipboard?.writeText)try{return await t.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.top="-1000px",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),typeof document.execCommand=="function"&&document.execCommand("copy")}catch{return!1}finally{n.remove()}}const $1=Object.fromEntries(Object.entries(lr).filter(([,e])=>e.bindings!==void 0).map(([e,t])=>[e,[...t.bindings??[]]]));function Cu(e,t,n,r){return e==="data"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:r,placeholder:"{name}"}]:e==="subtotal"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:e==="summary"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function N1(e){const t=e.printElementType.type,n=ut(t).bindings??$1[t]??[],r=[];if(t==="table"){const o=e.options.dataSource;for(const[i,a]of(e.options.tableRows??[]).entries())for(const[l,c]of a.cells.entries())c.merged||r.push(...Cu(a.type,i,l,o))}return[...n,...r]}function L1(e){return Sa("text",{formatter:`{${e.fieldKey}}`,title:e.fieldLabel})}function F1(e){const t=e.fieldLabel||e.fieldKey;return Sa("text",{formatter:t,title:t})}function Au(e,t){let n=e;for(const r of t.split(".")){if(n==null)return;n=Array.isArray(n)?n[0]?.[r]:n[r]}return n}function Ou(e){return Au(gt,e)}function ds(e,t,n="1234567890128"){const r=t?.[0];return(e??"").replace(/\{([^{}]+)\}/g,(i,a)=>{const l=a.trim(),c=l.includes(".")?Au(r,l)??Ou(l):r?.[l]??Ou(l);return c==null?"":String(c)}).trim()||n}const Wo={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function Iu(e){return e==="vCenter"?Wo.center:e==="hCenter"?Wo.middle:Wo[e]??Wo.left}function z1(e,t,n,r={}){const o=r.adsorbMin??1,i=r.adsorbLineMin??2,a=r.showAdsorbLine??!0;let l=e.left,c=e.top;const s=[],d={left:e.left,right:e.left+e.width,vCenter:e.left+e.width/2,top:e.top,bottom:e.top+e.height,hCenter:e.top+e.height/2};let p=1/0;for(const f of t){if(f.id===e.id)continue;const g={left:f.left,right:f.left+f.width,vCenter:f.left+f.width/2,top:f.top,bottom:f.top+f.height,hCenter:f.top+f.height/2},m=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],b=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,w]of m){const E=Math.abs(d[v]-g[w]);E<=o&&E<p&&(p=E,l=e.left+(g[w]-d[v]))}for(const[v,w]of b){const E=Math.abs(d[v]-g[w]);E<=o&&E<p&&(p=E,c=e.top+(g[w]-d[v]))}}if(n){const f={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2},g=["left","vCenter","right"];for(const b of n.vertical)for(const v of g){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,l=e.left+(b-f[v]))}const m=["top","hCenter","bottom"];for(const b of n.horizontal)for(const v of m){const w=Math.abs(f[v]-b);w<=o&&w<p&&(p=w,c=e.top+(b-f[v]))}}const u={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2};if(a){const f=new Set;for(const g of t){if(g.id===e.id)continue;const m={left:g.left,right:g.left+g.width,vCenter:g.left+g.width/2,top:g.top,bottom:g.top+g.height,hCenter:g.top+g.height/2},b=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,E]of b)if(Math.abs(u[w]-m[E])<=i){const L=`v:${m[E]}`;f.has(L)||(f.add(L),s.push({type:"vertical",position:m[E],id:g.id,color:Iu(w)}))}for(const[w,E]of v)if(Math.abs(u[w]-m[E])<=i){const L=`h:${m[E]}`;f.has(L)||(f.add(L),s.push({type:"horizontal",position:m[E],id:g.id,color:Iu(w)}))}}}if(n){for(const f of n.vertical)s.some(g=>g.type==="vertical"&&g.position===f)||s.push({type:"vertical",position:f});for(const f of n.horizontal)s.some(g=>g.type==="horizontal"&&g.position===f)||s.push({type:"horizontal",position:f})}return{left:l,top:c,lines:s}}function B1(){function e(t,n){if(t.length<2)return;const r=t.map(i=>We(i.options).margin),o={minLeft:Math.min(...r.map(i=>i.left)),maxRight:Math.max(...r.map(i=>i.right)),minTop:Math.min(...r.map(i=>i.top)),maxBottom:Math.max(...r.map(i=>i.bottom))};switch(n){case"left":t.forEach(i=>{i.options.left=o.minLeft});break;case"right":t.forEach((i,a)=>{i.options.left=o.maxRight-r[a].width});break;case"top":t.forEach(i=>{i.options.top=o.minTop});break;case"bottom":t.forEach((i,a)=>{i.options.top=o.maxBottom-r[a].height});break;case"vertical":{const i=o.minLeft+(o.maxRight-o.minLeft)/2;t.forEach((a,l)=>{a.options.left=i-r[l].width/2});break}case"horizontal":{const i=o.minTop+(o.maxBottom-o.minTop)/2;t.forEach((a,l)=>{a.options.top=i-r[l].height/2});break}case"distributeHor":{const i=t.map((s,d)=>({element:s,box:r[d]})).sort((s,d)=>s.box.left-d.box.left),a=i.reduce((s,d)=>s+d.box.width,0),l=(o.maxRight-o.minLeft-a)/(i.length-1);let c=o.minLeft;i.forEach(s=>{s.element.options.left=c,c+=s.box.width+l});break}case"distributeVer":{const i=t.map((s,d)=>({element:s,box:r[d]})).sort((s,d)=>s.box.top-d.box.top),a=i.reduce((s,d)=>s+d.box.height,0),l=(o.maxBottom-o.minTop-a)/(i.length-1);let c=o.minTop;i.forEach(s=>{s.element.options.top=c,c+=s.box.height+l});break}}}return{align:e}}function Pu(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function H1(){function e(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=Pu();return r.map(l=>o.has(l.id)?{...l,options:{...l.options,groupId:a}}:l)}function t(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:e,ungroup:t,getGroupedIds:n}}const U1=["nw","n","ne","e","se","s","sw","w"];function q1(e,t,n,r,o,i){let{left:a,top:l,width:c,height:s}=t;switch(e){case"e":c=Math.max(o,t.width+n);break;case"w":c=Math.max(o,t.width-n),a=t.left+t.width-c;break;case"s":s=Math.max(i,t.height+r);break;case"n":s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"se":c=Math.max(o,t.width+n),s=Math.max(i,t.height+r);break;case"sw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height+r);break;case"ne":c=Math.max(o,t.width+n),s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"nw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height-r),l=t.top+t.height-s;break}return{left:a,top:l,width:c,height:s}}function Ru(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jo={},Pr={},Go={},Du;function tt(){if(Du)return Go;Du=1,Object.defineProperty(Go,"__esModule",{value:!0});function e(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}var t=function n(r,o){e(this,n),this.data=r,this.text=o.text||r,this.options=o};return Go.default=t,Go}var $u;function W1(){if($u)return Pr;$u=1,Object.defineProperty(Pr,"__esModule",{value:!0}),Pr.CODE39=void 0;var e=(function(){function m(b,v){for(var w=0;w<v.length;w++){var E=v[w];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(b,E.key,E)}}return function(b,v,w){return v&&m(b.prototype,v),w&&m(b,w),b}})(),t=tt(),n=r(t);function r(m){return m&&m.__esModule?m:{default:m}}function o(m,b){if(!(m instanceof b))throw new TypeError("Cannot call a class as a function")}function i(m,b){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b&&(typeof b=="object"||typeof b=="function")?b:m}function a(m,b){if(typeof b!="function"&&b!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof b);m.prototype=Object.create(b&&b.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(m,b):m.__proto__=b)}var l=(function(m){a(b,m);function b(v,w){return o(this,b),v=v.toUpperCase(),w.mod43&&(v+=u(g(v))),i(this,(b.__proto__||Object.getPrototypeOf(b)).call(this,v,w))}return e(b,[{key:"encode",value:function(){for(var w=d("*"),E=0;E<this.data.length;E++)w+=d(this.data[E])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),b})(n.default),c=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","."," ","$","/","+","%","*"],s=[20957,29783,23639,30485,20951,29813,23669,20855,29789,23645,29975,23831,30533,22295,30149,24005,21623,29981,23837,22301,30023,23879,30545,22343,30161,24017,21959,30065,23921,22385,29015,18263,29141,17879,29045,18293,17783,29021,18269,17477,17489,17681,20753,35770];function d(m){return p(f(m))}function p(m){return s[m].toString(2)}function u(m){return c[m]}function f(m){return c.indexOf(m)}function g(m){for(var b=0,v=0;v<m.length;v++)b+=f(m[v]);return b=b%43,b}return Pr.CODE39=l,Pr}var xt={},Vo={},Yo={},Se={},Nu;function Rr(){if(Nu)return Se;Nu=1,Object.defineProperty(Se,"__esModule",{value:!0});var e;function t(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=Se.SET_A=0,r=Se.SET_B=1,o=Se.SET_C=2;Se.SHIFT=98;var i=Se.START_A=103,a=Se.START_B=104,l=Se.START_C=105;return Se.MODULO=103,Se.STOP=106,Se.FNC1=207,Se.SET_BY_CODE=(e={},t(e,i,n),t(e,a,r),t(e,l,o),e),Se.SWAP={101:n,100:r,99:o},Se.A_START_CHAR="Ð",Se.B_START_CHAR="Ñ",Se.C_START_CHAR="Ò",Se.A_CHARS="[\0-_È-Ï]",Se.B_CHARS="[ -È-Ï]",Se.C_CHARS="(Ï*[0-9]{2}Ï*)",Se.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],Se}var Lu;function Ko(){if(Lu)return Yo;Lu=1,Object.defineProperty(Yo,"__esModule",{value:!0});var e=(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}})(),t=tt(),n=o(t),r=Rr();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(g){return g.charCodeAt(0)}),f}return e(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,g=r.SET_BY_CODE[f];if(g===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,g);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 g=u.shift();return g<32?g+64:g-32}else return f===r.SET_B?u.shift()-32:(u.shift()-48)*10+u.shift()-48}},{key:"next",value:function(u,f,g){if(!u.length)return{result:"",checksum:0};var m=void 0,b=void 0;if(u[0]>=200){b=u.shift()-105;var v=r.SWAP[b];v!==void 0?m=d.next(u,f+1,v):((g===r.SET_A||g===r.SET_B)&&b===r.SHIFT&&(u[0]=g===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,g))}else b=d.correctIndex(u,g),m=d.next(u,f+1,g);var w=d.getBar(b),E=b*f;return{result:w+m.result,checksum:E+m.checksum}}}]),d})(n.default);return Yo.default=c,Yo}var Xo={},Fu;function j1(){if(Fu)return Xo;Fu=1,Object.defineProperty(Xo,"__esModule",{value:!0});var e=Rr(),t=function(l){return l.match(new RegExp("^"+e.A_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+e.B_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+e.C_CHARS+"*"))[0]};function o(a,l){var c=l?e.A_CHARS:e.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=t(a)>=n(a);return l+String.fromCharCode(s?206:205)+o(a,s)}return Xo.default=function(a){var l=void 0,c=r(a).length;if(c>=2)l=e.C_START_CHAR+i(a);else{var s=t(a)>n(a);l=(s?e.A_START_CHAR:e.B_START_CHAR)+o(a,s)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,p){return"Ë"+p})},Xo}var zu;function G1(){if(zu)return Vo;zu=1,Object.defineProperty(Vo,"__esModule",{value:!0});var e=Ko(),t=o(e),n=j1(),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})(t.default);return Vo.default=c,Vo}var Zo={},Bu;function V1(){if(Bu)return Zo;Bu=1,Object.defineProperty(Zo,"__esModule",{value:!0});var e=(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}})(),t=Ko(),n=o(t),r=Rr();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 e(d,[{key:"valid",value:function(){return new RegExp("^"+r.A_CHARS+"+$").test(this.data)}}]),d})(n.default);return Zo.default=c,Zo}var Jo={},Hu;function Y1(){if(Hu)return Jo;Hu=1,Object.defineProperty(Jo,"__esModule",{value:!0});var e=(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}})(),t=Ko(),n=o(t),r=Rr();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 e(d,[{key:"valid",value:function(){return new RegExp("^"+r.B_CHARS+"+$").test(this.data)}}]),d})(n.default);return Jo.default=c,Jo}var Qo={},Uu;function K1(){if(Uu)return Qo;Uu=1,Object.defineProperty(Qo,"__esModule",{value:!0});var e=(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}})(),t=Ko(),n=o(t),r=Rr();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 e(d,[{key:"valid",value:function(){return new RegExp("^"+r.C_CHARS+"+$").test(this.data)}}]),d})(n.default);return Qo.default=c,Qo}var qu;function X1(){if(qu)return xt;qu=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.CODE128C=xt.CODE128B=xt.CODE128A=xt.CODE128=void 0;var e=G1(),t=c(e),n=V1(),r=c(n),o=Y1(),i=c(o),a=K1(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return xt.CODE128=t.default,xt.CODE128A=r.default,xt.CODE128B=i.default,xt.CODE128C=l.default,xt}var Xe={},ei={},Bt={},Wu;function Dr(){return Wu||(Wu=1,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.SIDE_BIN="101",Bt.MIDDLE_BIN="01010",Bt.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"]},Bt.EAN2_STRUCTURE=["LL","LG","GL","GG"],Bt.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],Bt.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),Bt}var ti={},ni={},ju;function $r(){if(ju)return ni;ju=1,Object.defineProperty(ni,"__esModule",{value:!0});var e=Dr(),t=function(r,o,i){var a=r.split("").map(function(c,s){return e.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 ni.default=t,ni}var Gu;function Vu(){if(Gu)return ti;Gu=1,Object.defineProperty(ti,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=Dr(),n=$r(),r=a(n),o=tt(),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,g){l(this,u);var m=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.fontSize=!g.flat&&g.fontSize>g.width*10?g.width*10:g.fontSize,m.guardHeight=g.height+m.fontSize/2+g.textMargin,m}return e(u,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(g,m){return this.text.substr(g,m)}},{key:"leftEncode",value:function(g,m){return(0,r.default)(g,m)}},{key:"rightText",value:function(g,m){return this.text.substr(g,m)}},{key:"rightEncode",value:function(g,m){return(0,r.default)(g,m)}},{key:"encodeGuarded",value:function(){var g={fontSize:this.fontSize},m={height:this.guardHeight};return[{data:t.SIDE_BIN,options:m},{data:this.leftEncode(),text:this.leftText(),options:g},{data:t.MIDDLE_BIN,options:m},{data:this.rightEncode(),text:this.rightText(),options:g},{data:t.SIDE_BIN,options:m}]}},{key:"encodeFlat",value:function(){var g=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:g.join(""),text:this.text}}}]),u})(i.default);return ti.default=d,ti}var Yu;function Z1(){if(Yu)return ei;Yu=1,Object.defineProperty(ei,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=function p(u,f,g){u===null&&(u=Function.prototype);var m=Object.getOwnPropertyDescriptor(u,f);if(m===void 0){var b=Object.getPrototypeOf(u);return b===null?void 0:p(b,f,g)}else{if("value"in m)return m.value;var v=m.get;return v===void 0?void 0:v.call(g)}},n=Dr(),r=Vu(),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(g){return+g}).reduce(function(g,m,b){return b%2?g+m*3:g+m},0);return(10-f%10)%10},d=(function(p){c(u,p);function u(f,g){a(this,u),f.search(/^[0-9]{12}$/)!==-1&&(f+=s(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.lastChar=g.lastChar,m}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===s(this.data)}},{key:"leftText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var g=this.data.substr(1,6),m=n.EAN13_STRUCTURE[this.data[0]];return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftEncode",this).call(this,g,m)}},{key:"rightText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var g=this.data.substr(7,6);return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightEncode",this).call(this,g,"RRRRRR")}},{key:"encodeGuarded",value:function(){var g=t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(g.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(g.push({data:"00"}),g.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),g}}]),u})(o.default);return ei.default=d,ei}var ri={},Ku;function J1(){if(Ku)return ri;Ku=1,Object.defineProperty(ri,"__esModule",{value:!0});var e=(function(){function d(p,u){for(var f=0;f<u.length;f++){var g=u[f];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}return function(p,u,f){return u&&d(p.prototype,u),f&&d(p,f),p}})(),t=function d(p,u,f){p===null&&(p=Function.prototype);var g=Object.getOwnPropertyDescriptor(p,u);if(g===void 0){var m=Object.getPrototypeOf(p);return m===null?void 0:d(m,u,f)}else{if("value"in g)return g.value;var b=g.get;return b===void 0?void 0:b.call(f)}},n=Vu(),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,g,m){return m%2?f+g:f+g*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 e(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:"leftText",value:function(){return t(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 t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftEncode",this).call(this,f,"LLLL")}},{key:"rightText",value:function(){return t(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 t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightEncode",this).call(this,f,"RRRR")}}]),p})(r.default);return ri.default=s,ri}var oi={},Xu;function Q1(){if(Xu)return oi;Xu=1,Object.defineProperty(oi,"__esModule",{value:!0});var e=(function(){function u(f,g){for(var m=0;m<g.length;m++){var b=g[m];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(f,b.key,b)}}return function(f,g,m){return g&&u(f.prototype,g),m&&u(f,m),f}})(),t=Dr(),n=$r(),r=a(n),o=tt(),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 g=f.split("").map(function(m){return+m}).reduce(function(m,b,v){return v%2?m+b*9:m+b*3},0);return g%10},p=(function(u){s(f,u);function f(g,m){return l(this,f),c(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,g,m))}return e(f,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var m=t.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,r.default)(this.data,m,"01"),text:this.text}}}]),f})(i.default);return oi.default=p,oi}var ii={},Zu;function ey(){if(Zu)return ii;Zu=1,Object.defineProperty(ii,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=Dr(),n=$r(),r=a(n),o=tt(),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,g){return l(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g))}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var g=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,r.default)(this.data,g,"01"),text:this.text}}}]),u})(i.default);return ii.default=d,ii}var Nr={},Ju;function Qu(){if(Ju)return Nr;Ju=1,Object.defineProperty(Nr,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})();Nr.checksum=d;var t=$r(),n=i(t),r=tt(),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,g){a(this,u),f.search(/^[0-9]{11}$/)!==-1&&(f+=d(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.displayValue=g.displayValue,g.fontSize>g.width*10?m.fontSize=g.width*10:m.fontSize=g.fontSize,m.guardHeight=g.height+m.fontSize/2+g.textMargin,m}return e(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 g="";return g+="101",g+=(0,n.default)(this.data.substr(0,6),"LLLLLL"),g+="01010",g+=(0,n.default)(this.data.substr(6,6),"RRRRRR"),g+="101",{data:g,text:this.text}}},{key:"guardedEncoding",value:function(){var g=[];return this.displayValue&&g.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),g.push({data:"101"+(0,n.default)(this.data[0],"L"),options:{height:this.guardHeight}}),g.push({data:(0,n.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),g.push({data:"01010",options:{height:this.guardHeight}}),g.push({data:(0,n.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),g.push({data:(0,n.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&g.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),g}}]),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 Nr.default=s,Nr}var ai={},ep;function ty(){if(ep)return ai;ep=1,Object.defineProperty(ai,"__esModule",{value:!0});var e=(function(){function g(m,b){for(var v=0;v<b.length;v++){var w=b[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,w.key,w)}}return function(m,b,v){return b&&g(m.prototype,b),v&&g(m,v),m}})(),t=$r(),n=a(t),r=tt(),o=a(r),i=Qu();function a(g){return g&&g.__esModule?g:{default:g}}function l(g,m){if(!(g instanceof m))throw new TypeError("Cannot call a class as a function")}function c(g,m){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:g}function s(g,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);g.prototype=Object.create(m&&m.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(g,m):g.__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(g){s(m,g);function m(b,v){l(this,m);var w=c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,b,v));if(w.isValid=!1,b.search(/^[0-9]{6}$/)!==-1)w.middleDigits=b,w.upcA=f(b,"0"),w.text=v.text||""+w.upcA[0]+b+w.upcA[w.upcA.length-1],w.isValid=!0;else if(b.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=b.substring(1,b.length-1),w.upcA=f(w.middleDigits,b[0]),w.upcA[w.upcA.length-1]===b[b.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=v.displayValue,v.fontSize>v.width*10?w.fontSize=v.width*10:w.fontSize=v.fontSize,w.guardHeight=v.height+w.fontSize/2+v.textMargin,w}return e(m,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=this.encodeMiddleDigits(),v+="010101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101",options:{height:this.guardHeight}}),v.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),v.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),v}},{key:"encodeMiddleDigits",value:function(){var v=this.upcA[0],w=this.upcA[this.upcA.length-1],E=p[parseInt(w)][parseInt(v)];return(0,n.default)(this.middleDigits,E)}}]),m})(o.default);function f(g,m){for(var b=parseInt(g[g.length-1]),v=d[b],w="",E=0,k=0;k<v.length;k++){var L=v[k];L==="X"?w+=g[E++]:w+=L}return w=""+m+w,""+w+(0,i.checksum)(w)}return ai.default=u,ai}var tp;function ny(){if(tp)return Xe;tp=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.UPCE=Xe.UPC=Xe.EAN2=Xe.EAN5=Xe.EAN8=Xe.EAN13=void 0;var e=Z1(),t=u(e),n=J1(),r=u(n),o=Q1(),i=u(o),a=ey(),l=u(a),c=Qu(),s=u(c),d=ty(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return Xe.EAN13=t.default,Xe.EAN8=r.default,Xe.EAN5=i.default,Xe.EAN2=l.default,Xe.UPC=s.default,Xe.UPCE=p.default,Xe}var wn={},si={},Gn={},np;function ry(){return np||(np=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.START_BIN="1010",Gn.END_BIN="11101",Gn.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Gn}var rp;function op(){if(rp)return si;rp=1,Object.defineProperty(si,"__esModule",{value:!0});var e=(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}})(),t=ry(),n=tt(),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 e(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(g){return u.encodePair(g)}).join("");return{data:t.START_BIN+f+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(u){var f=t.BINARIES[u[1]];return t.BINARIES[u[0]].split("").map(function(g,m){return(g==="1"?"111":"1")+(f[m]==="1"?"000":"0")}).join("")}}]),d})(r.default);return si.default=c,si}var li={},ip;function oy(){if(ip)return li;ip=1,Object.defineProperty(li,"__esModule",{value:!0});var e=(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}})(),t=op(),n=r(t);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,g){return u+f*(3-g%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 e(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===l(this.data)}}]),d})(n.default);return li.default=c,li}var ap;function iy(){if(ap)return wn;ap=1,Object.defineProperty(wn,"__esModule",{value:!0}),wn.ITF14=wn.ITF=void 0;var e=op(),t=o(e),n=oy(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return wn.ITF=t.default,wn.ITF14=r.default,wn}var nt={},ci={},sp;function Lr(){if(sp)return ci;sp=1,Object.defineProperty(ci,"__esModule",{value:!0});var e=(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}})(),t=tt(),n=r(t);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 e(d,[{key:"encode",value:function(){for(var u="110",f=0;f<this.data.length;f++){var g=parseInt(this.data[f]),m=g.toString(2);m=c(m,4-m.length);for(var b=0;b<m.length;b++)u+=m[b]=="0"?"100":"110"}return u+="1001",{data:u,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9]+$/)!==-1}}]),d})(n.default);function c(s,d){for(var p=0;p<d;p++)s="0"+s;return s}return ci.default=l,ci}var di={},Fr={},lp;function ui(){if(lp)return Fr;lp=1,Object.defineProperty(Fr,"__esModule",{value:!0}),Fr.mod10=e,Fr.mod11=t;function e(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 t(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 Fr}var cp;function ay(){if(cp)return di;cp=1,Object.defineProperty(di,"__esModule",{value:!0});var e=Lr(),t=r(e),n=ui();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})(t.default);return di.default=l,di}var pi={},dp;function sy(){if(dp)return pi;dp=1,Object.defineProperty(pi,"__esModule",{value:!0});var e=Lr(),t=r(e),n=ui();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})(t.default);return pi.default=l,pi}var fi={},up;function ly(){if(up)return fi;up=1,Object.defineProperty(fi,"__esModule",{value:!0});var e=Lr(),t=r(e),n=ui();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})(t.default);return fi.default=l,fi}var hi={},pp;function cy(){if(pp)return hi;pp=1,Object.defineProperty(hi,"__esModule",{value:!0});var e=Lr(),t=r(e),n=ui();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})(t.default);return hi.default=l,hi}var fp;function dy(){if(fp)return nt;fp=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.MSI1110=nt.MSI1010=nt.MSI11=nt.MSI10=nt.MSI=void 0;var e=Lr(),t=d(e),n=ay(),r=d(n),o=sy(),i=d(o),a=ly(),l=d(a),c=cy(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return nt.MSI=t.default,nt.MSI10=r.default,nt.MSI11=i.default,nt.MSI1010=l.default,nt.MSI1110=s.default,nt}var zr={},hp;function uy(){if(hp)return zr;hp=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.pharmacode=void 0;var e=(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}})(),t=tt(),n=r(t);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 e(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 zr.pharmacode=l,zr}var Br={},gp;function py(){if(gp)return Br;gp=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.codabar=void 0;var e=(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}})(),t=tt(),n=r(t);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 e(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 Br.codabar=l,Br}var xn={},gi={},Vn={},mp;function fy(){return mp||(mp=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.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","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Vn.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"],Vn.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"]}),Vn}var bp;function yp(){if(bp)return gi;bp=1,Object.defineProperty(gi,"__esModule",{value:!0});var e=(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}})(),t=fy(),n=tt(),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 e(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.data.split("").flatMap(function(b){return t.MULTI_SYMBOLS[b]||b}),f=u.map(function(b){return d.getEncoding(b)}).join(""),g=d.checksum(u,20),m=d.checksum(u.concat(g),15);return{text:this.text,data:d.getEncoding("ÿ")+f+d.getEncoding(g)+d.getEncoding(m)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(u){return t.BINARIES[d.symbolValue(u)]}},{key:"getSymbol",value:function(u){return t.SYMBOLS[u]}},{key:"symbolValue",value:function(u){return t.SYMBOLS.indexOf(u)}},{key:"checksum",value:function(u,f){var g=u.slice().reverse().reduce(function(m,b,v){var w=v%f+1;return m+d.symbolValue(b)*w},0);return d.getSymbol(g%47)}}]),d})(r.default);return gi.default=c,gi}var mi={},vp;function hy(){if(vp)return mi;vp=1,Object.defineProperty(mi,"__esModule",{value:!0});var e=(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}})(),t=yp(),n=r(t);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 e(s,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),s})(n.default);return mi.default=l,mi}var wp;function gy(){if(wp)return xn;wp=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.CODE93FullASCII=xn.CODE93=void 0;var e=yp(),t=o(e),n=hy(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return xn.CODE93=t.default,xn.CODE93FullASCII=r.default,xn}var Hr={},xp;function my(){if(xp)return Hr;xp=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.GenericBarcode=void 0;var e=(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}})(),t=tt(),n=r(t);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 e(s,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),s})(n.default);return Hr.GenericBarcode=l,Hr}var Ep;function by(){if(Ep)return jo;Ep=1,Object.defineProperty(jo,"__esModule",{value:!0});var e=W1(),t=X1(),n=ny(),r=iy(),o=dy(),i=uy(),a=py(),l=gy(),c=my();return jo.default={CODE39:e.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.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},jo}var bi={},Sp;function yi(){if(Sp)return bi;Sp=1,Object.defineProperty(bi,"__esModule",{value:!0});var e=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};return bi.default=function(t,n){return e({},t,n)},bi}var vi={},_p;function yy(){if(_p)return vi;_p=1,Object.defineProperty(vi,"__esModule",{value:!0}),vi.default=e;function e(t){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(t),n}return vi}var wi={},Mp;function vy(){if(Mp)return wi;Mp=1,Object.defineProperty(wi,"__esModule",{value:!0}),wi.default=e;function e(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return wi}var xi={},Ei={},Si={},Tp;function kp(){if(Tp)return Si;Tp=1,Object.defineProperty(Si,"__esModule",{value:!0}),Si.default=e;function e(t){var n=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var r in n)n.hasOwnProperty(r)&&(r=n[r],typeof t[r]=="string"&&(t[r]=parseInt(t[r],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return Si}var _i={},Cp;function Ap(){if(Cp)return _i;Cp=1,Object.defineProperty(_i,"__esModule",{value:!0});var e={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 _i.default=e,_i}var Op;function wy(){if(Op)return Ei;Op=1,Object.defineProperty(Ei,"__esModule",{value:!0});var e=kp(),t=o(e),n=Ap(),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,t.default)(l),l}return Ei.default=i,Ei}var Mi={},Ti={},rt={},Ip;function Pp(){if(Ip)return rt;Ip=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.getTotalWidthOfEncodings=rt.calculateEncodingAttributes=rt.getBarcodePadding=rt.getEncodingHeight=rt.getMaximumHeightOfEncodings=void 0;var e=yi(),t=n(e);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],g=(0,t.default)(d,f.options),m;g.displayValue?m=c(f.text,g,p):m=0;var b=f.data.length*g.width;f.width=Math.ceil(Math.max(m,b)),f.height=r(f,g),f.barcodePadding=o(m,b,g)}}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 g=f.width;return g}return rt.getMaximumHeightOfEncodings=l,rt.getEncodingHeight=r,rt.getBarcodePadding=o,rt.calculateEncodingAttributes=i,rt.getTotalWidthOfEncodings=a,rt}var Rp;function xy(){if(Rp)return Ti;Rp=1,Object.defineProperty(Ti,"__esModule",{value:!0});var e=(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}})(),t=yi(),n=o(t),r=Pp();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 e(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 g=0;g<u.length;g++){var m=g*s.width+d.barcodePadding;u[g]==="1"?p.fillRect(m,f,s.width,s.height):u[g]&&p.fillRect(m,f,s.width,s.height*u[g])}}},{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,g;s.textPosition=="top"?g=s.marginTop+s.fontSize-s.textMargin:g=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,g)}}},{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 Ti.default=a,Ti}var ki={},Dp;function Ey(){if(Dp)return ki;Dp=1,Object.defineProperty(ki,"__esModule",{value:!0});var e=(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}})(),t=yi(),n=o(t),r=Pp();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 e(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),g=this.createGroup(d,f.marginTop,this.svg);this.setGroupOptions(g,f),this.drawSvgBarcode(g,f,u),this.drawSVGText(g,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,g;p.textPosition=="top"?g=p.fontSize+p.textMargin:g=0;for(var m=0,b=0,v=0;v<f.length;v++)b=v*p.width+u.barcodePadding,f[v]==="1"?m++:m>0&&(this.drawRect(b-p.width*m,g,p.width*m,p.height,d),m=0);m>0&&this.drawRect(b-p.width*(m-1),g,p.width*m,p.height,d)}},{key:"drawSVGText",value:function(d,p,u){var f=this.document.createElementNS(a,"text");if(p.displayValue){var g,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?(g=0,f.setAttribute("text-anchor","start")):p.textAlign=="right"?(g=u.width-1,f.setAttribute("text-anchor","end")):(g=u.width/2,f.setAttribute("text-anchor","middle")),f.setAttribute("x",g),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,g){var m=this.document.createElementNS(a,"rect");return m.setAttribute("x",d),m.setAttribute("y",p),m.setAttribute("width",u),m.setAttribute("height",f),g.appendChild(m),m}}]),c})();return ki.default=l,ki}var Ci={},$p;function Sy(){if($p)return Ci;$p=1,Object.defineProperty(Ci,"__esModule",{value:!0});var e=(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 t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o,i,a){t(this,r),this.object=o,this.encodings=i,this.options=a}return e(r,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),r})();return Ci.default=n,Ci}var Np;function _y(){if(Np)return Mi;Np=1,Object.defineProperty(Mi,"__esModule",{value:!0});var e=xy(),t=a(e),n=Ey(),r=a(n),o=Sy(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Mi.default={CanvasRenderer:t.default,SVGRenderer:r.default,ObjectRenderer:i.default},Mi}var Yn={},Lp;function Fp(){if(Lp)return Yn;Lp=1,Object.defineProperty(Yn,"__esModule",{value:!0});function e(a,l){if(!(a instanceof l))throw new TypeError("Cannot call a class as a function")}function t(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){e(this,l);var d=t(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(){e(this,l);var c=t(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(){e(this,l);var c=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="NoElementException",c.message="No element to render on.",c}return l})(Error);return Yn.InvalidInputException=r,Yn.InvalidElementException=o,Yn.NoElementException=i,Yn}var zp;function My(){if(zp)return xi;zp=1,Object.defineProperty(xi,"__esModule",{value:!0});var e=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},t=wy(),n=a(t),r=_y(),o=a(r),i=Fp();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":e(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 xi.default=l,xi}var Ai={},Bp;function Ty(){if(Bp)return Ai;Bp=1,Object.defineProperty(Ai,"__esModule",{value:!0});var e=(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 t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o){t(this,r),this.api=o}return e(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 Ai.default=n,Ai}var us,Hp;function ky(){if(Hp)return us;Hp=1;var e=by(),t=v(e),n=yi(),r=v(n),o=yy(),i=v(o),a=vy(),l=v(a),c=My(),s=v(c),d=kp(),p=v(d),u=Ty(),f=v(u),g=Fp(),m=Ap(),b=v(m);function v(C){return C&&C.__esModule?C:{default:C}}var w=function(){},E=function(I,S,$){var N=new w;if(typeof I>"u")throw Error("No element to render on was provided.");return N._renderProperties=(0,s.default)(I),N._encodings=[],N._options=b.default,N._errorHandler=new f.default(N),typeof S<"u"&&($=$||{},$.format||($.format=P()),N.options($)[$.format](S,$).render()),N};E.getModule=function(C){return t.default[C]};for(var k in t.default)t.default.hasOwnProperty(k)&&L(t.default,k);function L(C,I){w.prototype[I]=w.prototype[I.toUpperCase()]=w.prototype[I.toLowerCase()]=function(S,$){var N=this;return N._errorHandler.wrapBarcodeCall(function(){$.text=typeof $.text>"u"?void 0:""+$.text;var z=(0,r.default)(N._options,$);z=(0,p.default)(z);var T=C[I],ie=R(S,T,z);return N._encodings.push(ie),N})}}function R(C,I,S){C=""+C;var $=new I(C,S);if(!$.valid())throw new g.InvalidInputException($.constructor.name,C);var N=$.encode();N=(0,i.default)(N);for(var z=0;z<N.length;z++)N[z].options=(0,r.default)(S,N[z].options);return N}function P(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}w.prototype.options=function(C){return this._options=(0,r.default)(this._options,C),this},w.prototype.blank=function(C){var I=new Array(C+1).join("0");return this._encodings.push({data:I}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var C;for(var I in this._renderProperties){C=this._renderProperties[I];var S=(0,r.default)(this._options,C.options);S.format=="auto"&&(S.format=P()),this._errorHandler.wrapBarcodeCall(function(){var $=S.value,N=t.default[S.format.toUpperCase()],z=R($,N,S);O(C,z,S)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new g.NoElementException;if(Array.isArray(this._renderProperties))for(var C=0;C<this._renderProperties.length;C++)O(this._renderProperties[C],this._encodings,this._options);else O(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=b.default;function O(C,I,S){I=(0,i.default)(I);for(var $=0;$<I.length;$++)I[$].options=(0,r.default)(S,I[$].options),(0,l.default)(I[$].options);(0,l.default)(S);var N=C.renderer,z=new N(C.element,I,S);z.render(),C.afterRender&&C.afterRender()}return typeof window<"u"&&(window.JsBarcode=E),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(C,I){var S=[];return jQuery(this).each(function(){S.push(this)}),E(S,C,I)}),us=E,us}var Cy=ky();const ps=Ru(Cy);var Kn={},fs,Up;function Ay(){return Up||(Up=1,fs=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),fs}var hs={},en={},qp;function En(){if(qp)return en;qp=1;let e;const t=[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 en.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},en.getSymbolTotalCodewords=function(r){return t[r]},en.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},en.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');e=r},en.isKanjiModeEnabled=function(){return typeof e<"u"},en.toSJIS=function(r){return e(r)},en}var gs={},Wp;function ms(){return Wp||(Wp=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,o){if(e.isValid(r))return r;try{return t(r)}catch{return o}}})(gs)),gs}var bs,jp;function Oy(){if(jp)return bs;jp=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let r=0;r<n;r++)this.putBit((t>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},bs=e,bs}var ys,Gp;function Iy(){if(Gp)return ys;Gp=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,r,o){const i=t*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,r){this.data[t*this.size+n]^=r},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},ys=e,ys}var vs={},Vp;function Py(){return Vp||(Vp=1,(function(e){const t=En().getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=t(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()},e.getPositions=function(r){const o=[],i=e.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}})(vs)),vs}var ws={},Yp;function Ry(){if(Yp)return ws;Yp=1;const e=En().getSymbolSize,t=7;return ws.getPositions=function(r){const o=e(r);return[[0,0],[o-t,0],[0,o-t]]},ws}var xs={},Kp;function Dy(){return Kp||(Kp=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.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+=t.N1+(l-5)),s=f,l=1),f=o.get(u,p),f===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=f,c=1)}l>=5&&(a+=t.N1+(l-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.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*t.N2},e.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*t.N3},e.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)*t.N4};function n(r,o,i){switch(r){case e.Patterns.PATTERN000:return(o+i)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return i%3===0;case e.Patterns.PATTERN011:return(o+i)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case e.Patterns.PATTERN101:return o*i%2+o*i%3===0;case e.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case e.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.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))},e.getBestMask=function(o,i){const a=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let s=0;s<a;s++){i(s),e.applyMask(s,o);const d=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(s,o),d<c&&(c=d,l=s)}return l}})(xs)),xs}var Oi={},Xp;function Zp(){if(Xp)return Oi;Xp=1;const e=ms(),t=[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 Oi.getBlocksCount=function(o,i){switch(i){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Oi.getTotalCodewordsCount=function(o,i){switch(i){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Oi}var Es={},Ur={},Jp;function $y(){if(Jp)return Ur;Jp=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)e[o]=r,t[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Ur.log=function(r){if(r<1)throw new Error("log("+r+")");return t[r]},Ur.exp=function(r){return e[r]},Ur.mul=function(r,o){return r===0||o===0?0:e[t[r]+t[o]]},Ur}var Qp;function Ny(){return Qp||(Qp=1,(function(e){const t=$y();e.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]^=t.mul(r[a],o[l]);return i},e.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]^=t.mul(o[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},e.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=e.mul(o,new Uint8Array([1,t.exp(i)]));return o}})(Es)),Es}var Ss,ef;function Ly(){if(ef)return Ss;ef=1;const e=Ny();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(r){this.degree=r,this.genPoly=e.generateECPolynomial(this.degree)},t.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=e.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},Ss=t,Ss}var _s={},Ms={},Ts={},tf;function nf(){return tf||(tf=1,Ts.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Ts}var Rt={},rf;function of(){if(rf)return Rt;rf=1;const e="[0-9]+",t="[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
264
- ]))+`;Rt.KANJI=new RegExp(n,"g"),Rt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Rt.BYTE=new RegExp(r,"g"),Rt.NUMERIC=new RegExp(e,"g"),Rt.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+e+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Rt.testKanji=function(c){return o.test(c)},Rt.testNumeric=function(c){return i.test(c)},Rt.testAlphanumeric=function(c){return a.test(c)},Rt}var af;function Sn(){return af||(af=1,(function(e){const t=nf(),n=of();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return n.testNumeric(i)?e.NUMERIC:n.testAlphanumeric(i)?e.ALPHANUMERIC:n.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.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 e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(i,a){if(e.isValid(i))return i;try{return r(i)}catch{return a}}})(Ms)),Ms}var sf;function Fy(){return sf||(sf=1,(function(e){const t=En(),n=Zp(),r=ms(),o=Sn(),i=nf(),a=7973,l=t.getBCHDigit(a);function c(u,f,g){for(let m=1;m<=40;m++)if(f<=e.getCapacity(m,g,u))return m}function s(u,f){return o.getCharCountIndicator(u,f)+4}function d(u,f){let g=0;return u.forEach(function(m){const b=s(m.mode,f);g+=b+m.getBitsLength()}),g}function p(u,f){for(let g=1;g<=40;g++)if(d(u,g)<=e.getCapacity(g,f,o.MIXED))return g}e.from=function(f,g){return i.isValid(f)?parseInt(f,10):g},e.getCapacity=function(f,g,m){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=o.BYTE);const b=t.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,g),w=(b-v)*8;if(m===o.MIXED)return w;const E=w-s(m,f);switch(m){case o.NUMERIC:return Math.floor(E/10*3);case o.ALPHANUMERIC:return Math.floor(E/11*2);case o.KANJI:return Math.floor(E/13);case o.BYTE:default:return Math.floor(E/8)}},e.getBestVersionForData=function(f,g){let m;const b=r.from(g,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,b);if(f.length===0)return 1;m=f[0]}else m=f;return c(m.mode,m.getLength(),b)},e.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let g=f<<12;for(;t.getBCHDigit(g)-l>=0;)g^=a<<t.getBCHDigit(g)-l;return f<<12|g}})(_s)),_s}var ks={},lf;function zy(){if(lf)return ks;lf=1;const e=En(),t=1335,n=21522,r=e.getBCHDigit(t);return ks.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;e.getBCHDigit(c)-r>=0;)c^=t<<e.getBCHDigit(c)-r;return(l<<10|c)^n},ks}var Cs={},As,cf;function By(){if(cf)return As;cf=1;const e=Sn();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.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))},As=t,As}var Os,df;function Hy(){if(df)return Os;df=1;const e=Sn(),t=["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=e.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=t.indexOf(this.data[i])*45;a+=t.indexOf(this.data[i+1]),o.put(a,11)}this.data.length%2&&o.put(t.indexOf(this.data[i]),6)},Os=n,Os}var Is,uf;function Uy(){if(uf)return Is;uf=1;const e=Sn();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(r){return r*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},Is=t,Is}var Ps,pf;function qy(){if(pf)return Ps;pf=1;const e=Sn(),t=En();function n(r){this.mode=e.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=t.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]+`
265
- Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ps=n,Ps}var Rs={exports:{}},ff;function Wy(){return ff||(ff=1,(function(e){var t={single_source_shortest_paths:function(n,r,o){var i={},a={};a[r]=0;var l=t.PriorityQueue.make();l.push(r,0);for(var c,s,d,p,u,f,g,m,b;!l.empty();){c=l.pop(),s=c.value,p=c.cost,u=n[s]||{};for(d in u)u.hasOwnProperty(d)&&(f=u[d],g=p+f,m=a[d],b=typeof a[d]>"u",(b||m>g)&&(a[d]=g,l.push(d,g),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var v=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=t.single_source_shortest_paths(n,r,o);return t.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=t.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}}};e.exports=t})(Rs)),Rs.exports}var hf;function jy(){return hf||(hf=1,(function(e){const t=Sn(),n=By(),r=Hy(),o=Uy(),i=qy(),a=of(),l=En(),c=Wy();function s(v){return unescape(encodeURIComponent(v)).length}function d(v,w,E){const k=[];let L;for(;(L=v.exec(E))!==null;)k.push({data:L[0],index:L.index,mode:w,length:L[0].length});return k}function p(v){const w=d(a.NUMERIC,t.NUMERIC,v),E=d(a.ALPHANUMERIC,t.ALPHANUMERIC,v);let k,L;return l.isKanjiModeEnabled()?(k=d(a.BYTE,t.BYTE,v),L=d(a.KANJI,t.KANJI,v)):(k=d(a.BYTE_KANJI,t.BYTE,v),L=[]),w.concat(E,k,L).sort(function(P,O){return P.index-O.index}).map(function(P){return{data:P.data,mode:P.mode,length:P.length}})}function u(v,w){switch(w){case t.NUMERIC:return n.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return i.getBitsLength(v);case t.BYTE:return o.getBitsLength(v)}}function f(v){return v.reduce(function(w,E){const k=w.length-1>=0?w[w.length-1]:null;return k&&k.mode===E.mode?(w[w.length-1].data+=E.data,w):(w.push(E),w)},[])}function g(v){const w=[];for(let E=0;E<v.length;E++){const k=v[E];switch(k.mode){case t.NUMERIC:w.push([k,{data:k.data,mode:t.ALPHANUMERIC,length:k.length},{data:k.data,mode:t.BYTE,length:k.length}]);break;case t.ALPHANUMERIC:w.push([k,{data:k.data,mode:t.BYTE,length:k.length}]);break;case t.KANJI:w.push([k,{data:k.data,mode:t.BYTE,length:s(k.data)}]);break;case t.BYTE:w.push([{data:k.data,mode:t.BYTE,length:s(k.data)}])}}return w}function m(v,w){const E={},k={start:{}};let L=["start"];for(let R=0;R<v.length;R++){const P=v[R],O=[];for(let C=0;C<P.length;C++){const I=P[C],S=""+R+C;O.push(S),E[S]={node:I,lastCount:0},k[S]={};for(let $=0;$<L.length;$++){const N=L[$];E[N]&&E[N].node.mode===I.mode?(k[N][S]=u(E[N].lastCount+I.length,I.mode)-u(E[N].lastCount,I.mode),E[N].lastCount+=I.length):(E[N]&&(E[N].lastCount=I.length),k[N][S]=u(I.length,I.mode)+4+t.getCharCountIndicator(I.mode,w))}}L=O}for(let R=0;R<L.length;R++)k[L[R]].end=0;return{map:k,table:E}}function b(v,w){let E;const k=t.getBestModeForData(v);if(E=t.from(w,k),E!==t.BYTE&&E.bit<k.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(E)+`.
266
- Suggested mode is: `+t.toString(k));switch(E===t.KANJI&&!l.isKanjiModeEnabled()&&(E=t.BYTE),E){case t.NUMERIC:return new n(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new i(v);case t.BYTE:return new o(v)}}e.fromArray=function(w){return w.reduce(function(E,k){return typeof k=="string"?E.push(b(k,null)):k.data&&E.push(b(k.data,k.mode)),E},[])},e.fromString=function(w,E){const k=p(w,l.isKanjiModeEnabled()),L=g(k),R=m(L,E),P=c.find_path(R.map,"start","end"),O=[];for(let C=1;C<P.length-1;C++)O.push(R.table[P[C]].node);return e.fromArray(f(O))},e.rawSplit=function(w){return e.fromArray(p(w,l.isKanjiModeEnabled()))}})(Cs)),Cs}var gf;function Gy(){if(gf)return hs;gf=1;const e=En(),t=ms(),n=Oy(),r=Iy(),o=Py(),i=Ry(),a=Dy(),l=Zp(),c=Ly(),s=Fy(),d=zy(),p=Sn(),u=jy();function f(R,P){const O=R.size,C=i.getPositions(P);for(let I=0;I<C.length;I++){const S=C[I][0],$=C[I][1];for(let N=-1;N<=7;N++)if(!(S+N<=-1||O<=S+N))for(let z=-1;z<=7;z++)$+z<=-1||O<=$+z||(N>=0&&N<=6&&(z===0||z===6)||z>=0&&z<=6&&(N===0||N===6)||N>=2&&N<=4&&z>=2&&z<=4?R.set(S+N,$+z,!0,!0):R.set(S+N,$+z,!1,!0))}}function g(R){const P=R.size;for(let O=8;O<P-8;O++){const C=O%2===0;R.set(O,6,C,!0),R.set(6,O,C,!0)}}function m(R,P){const O=o.getPositions(P);for(let C=0;C<O.length;C++){const I=O[C][0],S=O[C][1];for(let $=-2;$<=2;$++)for(let N=-2;N<=2;N++)$===-2||$===2||N===-2||N===2||$===0&&N===0?R.set(I+$,S+N,!0,!0):R.set(I+$,S+N,!1,!0)}}function b(R,P){const O=R.size,C=s.getEncodedBits(P);let I,S,$;for(let N=0;N<18;N++)I=Math.floor(N/3),S=N%3+O-8-3,$=(C>>N&1)===1,R.set(I,S,$,!0),R.set(S,I,$,!0)}function v(R,P,O){const C=R.size,I=d.getEncodedBits(P,O);let S,$;for(S=0;S<15;S++)$=(I>>S&1)===1,S<6?R.set(S,8,$,!0):S<8?R.set(S+1,8,$,!0):R.set(C-15+S,8,$,!0),S<8?R.set(8,C-S-1,$,!0):S<9?R.set(8,15-S-1+1,$,!0):R.set(8,15-S-1,$,!0);R.set(C-8,8,1,!0)}function w(R,P){const O=R.size;let C=-1,I=O-1,S=7,$=0;for(let N=O-1;N>0;N-=2)for(N===6&&N--;;){for(let z=0;z<2;z++)if(!R.isReserved(I,N-z)){let T=!1;$<P.length&&(T=(P[$]>>>S&1)===1),R.set(I,N-z,T),S--,S===-1&&($++,S=7)}if(I+=C,I<0||O<=I){I-=C,C=-C;break}}}function E(R,P,O){const C=new n;O.forEach(function(z){C.put(z.mode.bit,4),C.put(z.getLength(),p.getCharCountIndicator(z.mode,R)),z.write(C)});const I=e.getSymbolTotalCodewords(R),S=l.getTotalCodewordsCount(R,P),$=(I-S)*8;for(C.getLengthInBits()+4<=$&&C.put(0,4);C.getLengthInBits()%8!==0;)C.putBit(0);const N=($-C.getLengthInBits())/8;for(let z=0;z<N;z++)C.put(z%2?17:236,8);return k(C,R,P)}function k(R,P,O){const C=e.getSymbolTotalCodewords(P),I=l.getTotalCodewordsCount(P,O),S=C-I,$=l.getBlocksCount(P,O),N=C%$,z=$-N,T=Math.floor(C/$),ie=Math.floor(S/$),pe=ie+1,Ge=T-ie,Q=new c(Ge);let Te=0;const he=new Array($),de=new Array($);let ye=0;const ne=new Uint8Array(R.buffer);for(let $e=0;$e<$;$e++){const fe=$e<z?ie:pe;he[$e]=ne.slice(Te,Te+fe),de[$e]=Q.encode(he[$e]),Te+=fe,ye=Math.max(ye,fe)}const De=new Uint8Array(C);let it=0,te,Ve;for(te=0;te<ye;te++)for(Ve=0;Ve<$;Ve++)te<he[Ve].length&&(De[it++]=he[Ve][te]);for(te=0;te<Ge;te++)for(Ve=0;Ve<$;Ve++)De[it++]=de[Ve][te];return De}function L(R,P,O,C){let I;if(Array.isArray(R))I=u.fromArray(R);else if(typeof R=="string"){let T=P;if(!T){const ie=u.rawSplit(R);T=s.getBestVersionForData(ie,O)}I=u.fromString(R,T||40)}else throw new Error("Invalid data");const S=s.getBestVersionForData(I,O);if(!S)throw new Error("The amount of data is too big to be stored in a QR Code");if(!P)P=S;else if(P<S)throw new Error(`
263
+ `),o=e.reduce((c,s)=>c+s.layoutsPerPage.reduce((d,p)=>d+p.length,0),0),i=[],a=[];let l=0;for(const c of e)for(const[s,d]of c.layoutsPerPage.entries()){const p=gn(c.boundPages[s]);for(const u of d)i.push({...u,pageIndex:l++}),a.push({...p})}return{html:$o(n,r),pageCount:o,pagePaperMm:a,pageLayouts:i}}async function m1(e,t){return t.withSession(e,n=>b1(e,n))}async function b1(e,t){const n=cs(e.templateJson);if(n.length>1){const c=pu(e.printData),s=c.mode==="batch"?c.dataList:[c.data],d=[];for(let u=0;u<s.length;u++)try{d.push(await v1(e,t,s[u]))}catch(f){const g=f instanceof Error?f.message:String(f);throw new Error(`第 ${u+1} 份渲染失败:${g}`)}const p=g1(d);return{html:p.html,pageCount:p.pageCount,paperMm:gn(n[0]),pagePaperMm:p.pagePaperMm,continuous:!1,heightSource:"config",pageLayouts:p.pageLayouts,copies:d.length}}const r=n[0]!==e.templateJson?{...e,templateJson:n[0]}:e,o=n[0],i=pu(r.printData);if(i.mode==="single"){const c=await yu(r,t,i.data);return o.tiling?.enabled===!0?bu(r,[{bound:c.bound,pageLayouts:c.pageLayouts,data:i.data,codeRenderer:c.codeRenderer,renderers:c.renderers,derivedHeightMm:c.derivedHeightMm,paperMm:c.paperMm,heightSource:c.heightSource}]):y1(c)}const a=[];for(let c=0;c<i.dataList.length;c++)try{const s=await yu(r,t,i.dataList[c]);a.push({bound:s.bound,pageLayouts:s.pageLayouts,data:i.dataList[c],codeRenderer:s.codeRenderer,renderers:s.renderers,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 bu(r,a);const l=s1(a);return{html:l.html,pageCount:l.pageCount,paperMm:a[0].paperMm,continuous:At(a[0].bound),heightSource:a[0].heightSource,pageLayouts:a.flatMap(c=>c.pageLayouts),copies:a.length,copyPaperMm:l.copyPaperMm}}function y1(e){return{html:e.html,pageCount:e.pageCount,paperMm:e.paperMm,continuous:e.continuous,heightSource:e.heightSource,pageLayouts:e.pageLayouts,copies:1}}function bu(e,t){const n=t[0].bound,r=gu(n,{paperOverride:e.paperOverride});t.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=p1({copies:t.map(i=>({bound:i.bound,pageLayouts:i.pageLayouts,data:i.data,codeRenderer:i.codeRenderer,renderers:i.renderers})),layout:r});return{html:o.html,pageCount:o.sheetCount,paperMm:{width:r.sheet.width,height:r.sheet.height},continuous:!1,heightSource:"config",pageLayouts:t.flatMap(i=>i.pageLayouts),copies:t.length}}async function yu(e,t,n){const r=Dd(e.templateJson,n,e.baseUrl,e.fontBaseUrl),o=At(r),i=ht(r),a=su(i),l=Kb({paperHeightMm:e.paperHeightMm,override:e.paperOverride}),c=await Ho({bound:r,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),s=await t.measure(c.html,a);cu(r,s.fits);const d=Ea(r,lu(s.measurements,r)),p=await Ho({bound:r,job:e,session:t,data:n,pageLayouts:d,isMeasurementPass:!1,codeBaseMap:c.codeMap,assetBaseMap:c.assetMap});let u=p.html,f;if(o){if(l&&l>0)f=l;else{const w=await t.probeContentBottom(u,a);f=Yb(r,is(w))}u=Ro(r,d,n,{codeRenderer:p.codeRenderer,renderers:p.renderers,pageHeightMm:f})}const g=o&&l?{...e.paperOverride,height:l}:e.paperOverride,m=gn(r),{paperMm:y,heightSource:v}=Xb({paperMm:{width:m.width,height:f??m.height},continuous:o,override:g});return{html:u,pageCount:d.length,paperMm:y,continuous:o,heightSource:v,pageLayouts:d,copies:1,bound:r,codeRenderer:p.codeRenderer,renderers:p.renderers,derivedHeightMm:f}}async function v1(e,t,n){const r=cs(e.templateJson),o=[],i=[],a=[],l=[];for(const c of r){const s=su(ht(c)),d=Dd(c,n,e.baseUrl,e.fontBaseUrl),p=await Ho({bound:d,job:e,session:t,data:n,pageLayouts:[],isMeasurementPass:!0}),u=await t.measure(p.html,s);cu(d,u.fits);const f=Ea(d,lu(u.measurements,d)),g=await Ho({bound:d,job:e,session:t,data:n,pageLayouts:f,isMeasurementPass:!1,codeBaseMap:p.codeMap,assetBaseMap:p.assetMap});o.push(d),i.push(f),a.push(g.codeRenderer),l.push(g.renderers)}return{boundPages:o,layoutsPerPage:i,data:n,codeRenderers:a,renderersPerPage:l}}async function Ho(e){const t=e.codeBaseMap??new Map,n=e.assetBaseMap??new Map,{job:r}=e,o=Eb(),i=r.renderers;if(r.codeRenderer&&(o.length===0||i))return{html:Ro(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:r.codeRenderer,renderers:i}),codeRenderer:r.codeRenderer,renderers:i,codeMap:t,assetMap:n};const a=e1(t),l=wb(n),c=r.codeRenderer??a.renderer,s=i??(o.length>0?Zd(l.renderer,o):void 0),d=Ro(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:c,renderers:s}),p=r.codeRenderer?[]:a.takeSpecs(),u=i?[]:l.takeSpecs(),[f,g]=await Promise.all([p.length>0?e.session.renderCodes(p):Promise.resolve(new Map),_b(u,e.session)]),m=t1(t,f),y=Xd(n,g),v=r.codeRenderer??(m.size>0?Qb(m):void 0),w=i??(y.size>0?Zd(xb(y),o):s);return p.length===0&&u.length===0?{html:d,codeRenderer:v,renderers:w,codeMap:m,assetMap:y}:{html:Ro(e.bound,e.pageLayouts,e.data,{isMeasurementPass:e.isMeasurementPass,codeRenderer:v,renderers:w}),codeRenderer:v,renderers:w,codeMap:m,assetMap:y}}class w1{constructor(t){this.functions={},t?.functions&&(this.functions={...t.functions})}registerFunction(t,n){this.functions[t]=n}evaluate(t,n){const r=Fa(t),o=$a(r);return Ke(o,n,this.functions)}render(t,n){return gd(t,this.functions)(n)}}const vu=new w1,x1={MONEY:md,CONCAT:(...e)=>e.filter(t=>t!=null).join(""),IF:vd,FORMAT:e=>typeof e!="number"?String(e):e.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),SUBSTR:(e,t,n)=>String(e).slice(t,n?t+n:void 0),LEN:e=>String(e).length,ADD:_d,SUB:Md,MUL:Td,DIV:Cd,ROUND:kd,ROUNDUP:Co,CEIL:Co,ROUNDDOWN:ko,FLOOR:ko,ROUNDBANK:Ad,NOW:()=>new Date().toISOString().split("T")[0],IFEMPTY:(e,t)=>e!=null&&e!==""?String(e):t,PAD:(e,t,n)=>String(e).padStart(t,n),REPLACE:(e,t,n)=>String(e).replace(new RegExp(t,"g"),n),JSON:e=>JSON.stringify(e,null,2),DATE:bd,UPPER:yd};for(const[e,t]of Object.entries(x1))vu.registerFunction(e,t);function E1(e,t,n){switch(e.toUpperCase()){case"SUM":return Ua(n,t);case"AVG":return wd(n,t);case"COUNT":return xd(n);case"MIN":return Ed(n,t);case"MAX":return Sd(n,t);default:return 0}}function Wn(e,t){if(!e)return"";if(!e.includes("{"))return e;const n=Array.isArray(t.rows)?t.rows:[];let r=e.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(E1(c,d,n))}),`{${a}}`});try{return vu.render(r,t)}catch{return e}}const gt={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级"}]},Uo={left:0,center:50,right:100},qo={top:0,center:50,bottom:100};function jn(e){return Number.isFinite(e)?Math.round(Math.min(100,Math.max(0,e))):50}function wu(e){return Math.round(e*100)/100}function xu(e,t){const n=jn(e),r=jn(t);if(!(n===50&&r===50))return`${n}% ${r}%`}function S1(e){return/^\d+(?:\.\d+)?%$/.test(e)?parseFloat(e):void 0}function _1(e){const t=(e??"").trim();if(!t)return{kind:"empty"};const n=t.toLowerCase().split(/\s+/);let r,o;for(let i=0;i<n.length;i++){const a=n[i],l=S1(a);if(i===0)if(a in Uo)r=Uo[a];else if(l!==void 0)r=l;else if(a in qo)o=qo[a];else return{kind:"custom",raw:e};else if(a in qo&&o===void 0)o=qo[a];else if(l!==void 0&&r===void 0)r=l;else if(l!==void 0&&o===void 0)o=l;else if(a in Uo&&r===void 0)r=Uo[a];else return{kind:"custom",raw:e}}return{kind:"axes",x:jn(r??50),y:jn(o??50)}}const Eu=25.4/96;function Su(e){const{widthMm:t,heightMm:n,naturalWidth:r,naturalHeight:o}=e;if(!r||!o||!t||!n)return null;const i=t/r,a=n/o,l=(Pc(e.fit,e.scalePct)??gr)/100;switch(e.fit||"contain"){case"fill":return{w:t,h:n};case"cover":{const c=Math.max(i,a)*l;return{w:r*c,h:o*c}}case"none":return{w:r*Eu,h:o*Eu};case"scale-down":{const c=Math.min(1,Math.min(i,a));return{w:r*c,h:o*c}}default:{const c=Math.min(i,a);return{w:r*c,h:o*c}}}}function M1(e){const t=Su(e);return t?{x:wu(Math.abs(e.widthMm-t.w)),y:wu(Math.abs(e.heightMm-t.h))}:{x:null,y:null}}function T1(e,t,n){const r=Su(e);if(!r)return null;const o=Math.min(1,e.widthMm/r.w),i=Math.min(1,e.heightMm/r.h);return{leftPct:(1-o)*jn(t),topPct:(1-i)*jn(n),widthPct:o*100,heightPct:i*100}}function _u(e){const t=String(e??"");return t?t.includes("{")?String(Wn(t,gt)):t:""}const Mu={vertical:[{value:0,label:"顶部"},{value:50,label:"居中"},{value:100,label:"底部"}],horizontal:[{value:0,label:"左侧"},{value:50,label:"居中"},{value:100,label:"右侧"}]},C1=[{x:0,y:0,label:"左上"},{x:50,y:0,label:"上中"},{x:100,y:0,label:"右上"},{x:0,y:50,label:"左中"},{x:50,y:50,label:"居中"},{x:100,y:50,label:"右中"},{x:0,y:100,label:"左下"},{x:50,y:100,label:"下中"},{x:100,y:100,label:"右下"}],ds=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"剪裁(等比铺满后裁边)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],k1="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+PHJlY3Qgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIGZpbGw9IiNmZmZmZmYiLz48cGF0aCBkPSJNNDAgMFYxMjBNODAgMFYxMjBNMCA0MEgxMjBNMCA4MEgxMjAiIHN0cm9rZT0iI2VlZjFmNiIgc3Ryb2tlLXdpZHRoPSIxIi8+PGNpcmNsZSBjeD0iMjAiIGN5PSIyMCIgcj0iMy41IiBmaWxsPSIjOGI5NWE1Ii8+PGNpcmNsZSBjeD0iMTAwIiBjeT0iMjAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iMTAwIiByPSIzLjUiIGZpbGw9IiM4Yjk1YTUiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjMuNSIgZmlsbD0iIzhiOTVhNSIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iMjAiIHI9IjciIGZpbGw9IiNjMDM5MmIiLz48Y2lyY2xlIGN4PSI2MCIgY3k9IjEwMCIgcj0iNyIgZmlsbD0iIzFmNGZhMyIvPjxjaXJjbGUgY3g9IjIwIiBjeT0iNjAiIHI9IjciIGZpbGw9IiMyYzdhNGEiLz48Y2lyY2xlIGN4PSIxMDAiIGN5PSI2MCIgcj0iNyIgZmlsbD0iI2UwN2EyMCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjE0IiBmaWxsPSJub25lIiBzdHJva2U9IiMyZjNhNGEiIHN0cm9rZS13aWR0aD0iNCIvPjxjaXJjbGUgY3g9IjYwIiBjeT0iNjAiIHI9IjYiIGZpbGw9IiMyZjNhNGEiLz48L3N2Zz4=",A1="图片还没设置,上面按内置示例图演示取位;换上真图后档位与可挪量按真图重算";function D1(e){const t=String(e??"").trim();return!t||t.includes("{")||t.includes("}")?{src:k1,isSample:!0}:{src:t,isSample:!1}}function Tu(e){return e==="vertical"?"垂直位置 (%)":"水平位置 (%)"}const O1="放大比例 (%)";function I1(e,t=!1){if(t)return"已保留模板里的原值;改动下面任一项就整体替换成新的取位";const{x:n,y:r}=e;return n===null||r===null?"":n>0&&r>0?`水平可挪 ${n}mm、垂直可挪 ${r}mm:0 贴左/贴顶,100 贴右/贴底`:n>0?`水平可挪 ${n}mm;垂直这一轴已贴满,挪不动`:r>0?`垂直可挪 ${r}mm;水平这一轴已贴满,挪不动`:"这个缩放下图与框正好一样大,两轴都没有可挪的余量"}function P1(e,t,n){return[{name:"horizontal",label:Tu("horizontal"),value:t,travelMm:e.x},{name:"vertical",label:Tu("vertical"),value:n,travelMm:e.y}]}function R1(e,t,n){const r=e.x!==null&&e.x>0,o=e.y!==null&&e.y>0;return o&&!r?Mu.vertical.map(i=>({value:`${t},${i.value}`,label:i.label})):r&&!o?Mu.horizontal.map(i=>({value:`${i.value},${n}`,label:i.label})):C1.map(i=>({value:`${i.x},${i.y}`,label:i.label}))}function Cu(e){const t=[...e].sort((a,l)=>(a.sortOrder??0)-(l.sortOrder??0)),n=new Map,r=[];for(const a of t){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 t){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 F1(e,t){const n=t.trim().toLowerCase();return n?e.map(r=>({...r,fields:r.fields.filter(o=>o.fieldLabel.toLowerCase().includes(n)||o.fieldKey.toLowerCase().includes(n))})).filter(r=>r.fields.length>0):e}async function ku(e){if(!e)return!1;const t=typeof navigator>"u"?void 0:navigator;if(t?.clipboard?.writeText)try{return await t.clipboard.writeText(e),!0}catch{}if(typeof document>"u")return!1;const n=document.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.top="-1000px",n.style.opacity="0",document.body.appendChild(n);try{return n.select(),typeof document.execCommand=="function"&&document.execCommand("copy")}catch{return!1}finally{n.remove()}}const $1=Object.fromEntries(Object.entries(lr).filter(([,e])=>e.bindings!==void 0).map(([e,t])=>[e,[...t.bindings??[]]]));function Au(e,t,n,r){return e==="data"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"list",listField:r,placeholder:"{name}"}]:e==="subtotal"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"subtotal",placeholder:"{MONEY(SUM(amount))}"}]:e==="summary"?[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"summary",placeholder:"{MONEY(SUM(amount))}"}]:[{targetPath:`options.tableRows[${t}].cells[${n}].formatter`,label:"内容",dataSource:"main",placeholder:"合计: {order.total}"}]}function N1(e){const t=e.printElementType.type,n=ut(t).bindings??$1[t]??[],r=[];if(t==="table"){const o=e.options.dataSource;for(const[i,a]of(e.options.tableRows??[]).entries())for(const[l,c]of a.cells.entries())c.merged||r.push(...Au(a.type,i,l,o))}return[...n,...r]}function L1(e){return _a("text",{formatter:`{${e.fieldKey}}`,title:e.fieldLabel})}function B1(e){const t=e.fieldLabel||e.fieldKey;return _a("text",{formatter:t,title:t})}function Du(e,t){let n=e;for(const r of t.split(".")){if(n==null)return;n=Array.isArray(n)?n[0]?.[r]:n[r]}return n}function Ou(e){return Du(gt,e)}function us(e,t,n="1234567890128"){const r=t?.[0];return(e??"").replace(/\{([^{}]+)\}/g,(i,a)=>{const l=a.trim(),c=l.includes(".")?Du(r,l)??Ou(l):r?.[l]??Ou(l);return c==null?"":String(c)}).trim()||n}const Wo={left:"#3b82f6",center:"#10b981",right:"#f59e0b",top:"#3b82f6",middle:"#10b981",bottom:"#f59e0b"};function Iu(e){return e==="vCenter"?Wo.center:e==="hCenter"?Wo.middle:Wo[e]??Wo.left}function z1(e,t,n,r={}){const o=r.adsorbMin??1,i=r.adsorbLineMin??2,a=r.showAdsorbLine??!0;let l=e.left,c=e.top;const s=[],d={left:e.left,right:e.left+e.width,vCenter:e.left+e.width/2,top:e.top,bottom:e.top+e.height,hCenter:e.top+e.height/2};let p=1/0;for(const f of t){if(f.id===e.id)continue;const g={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"]],y=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[v,w]of m){const E=Math.abs(d[v]-g[w]);E<=o&&E<p&&(p=E,l=e.left+(g[w]-d[v]))}for(const[v,w]of y){const E=Math.abs(d[v]-g[w]);E<=o&&E<p&&(p=E,c=e.top+(g[w]-d[v]))}}if(n){const f={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2},g=["left","vCenter","right"];for(const y of n.vertical)for(const v of g){const w=Math.abs(f[v]-y);w<=o&&w<p&&(p=w,l=e.left+(y-f[v]))}const m=["top","hCenter","bottom"];for(const y of n.horizontal)for(const v of m){const w=Math.abs(f[v]-y);w<=o&&w<p&&(p=w,c=e.top+(y-f[v]))}}const u={left:l,right:l+e.width,vCenter:l+e.width/2,top:c,bottom:c+e.height,hCenter:c+e.height/2};if(a){const f=new Set;for(const g of t){if(g.id===e.id)continue;const m={left:g.left,right:g.left+g.width,vCenter:g.left+g.width/2,top:g.top,bottom:g.top+g.height,hCenter:g.top+g.height/2},y=[["left","left"],["left","vCenter"],["left","right"],["vCenter","left"],["vCenter","vCenter"],["vCenter","right"],["right","left"],["right","vCenter"],["right","right"]],v=[["top","top"],["top","hCenter"],["top","bottom"],["hCenter","top"],["hCenter","hCenter"],["hCenter","bottom"],["bottom","top"],["bottom","hCenter"],["bottom","bottom"]];for(const[w,E]of y)if(Math.abs(u[w]-m[E])<=i){const P=`v:${m[E]}`;f.has(P)||(f.add(P),s.push({type:"vertical",position:m[E],id:g.id,color:Iu(w)}))}for(const[w,E]of v)if(Math.abs(u[w]-m[E])<=i){const P=`h:${m[E]}`;f.has(P)||(f.add(P),s.push({type:"horizontal",position:m[E],id:g.id,color:Iu(w)}))}}}if(n){for(const f of n.vertical)s.some(g=>g.type==="vertical"&&g.position===f)||s.push({type:"vertical",position:f});for(const f of n.horizontal)s.some(g=>g.type==="horizontal"&&g.position===f)||s.push({type:"horizontal",position:f})}return{left:l,top:c,lines:s}}function H1(){function e(t,n){if(t.length<2)return;const r=t.map(i=>We(i.options).margin),o={minLeft:Math.min(...r.map(i=>i.left)),maxRight:Math.max(...r.map(i=>i.right)),minTop:Math.min(...r.map(i=>i.top)),maxBottom:Math.max(...r.map(i=>i.bottom))};switch(n){case"left":t.forEach(i=>{i.options.left=o.minLeft});break;case"right":t.forEach((i,a)=>{i.options.left=o.maxRight-r[a].width});break;case"top":t.forEach(i=>{i.options.top=o.minTop});break;case"bottom":t.forEach((i,a)=>{i.options.top=o.maxBottom-r[a].height});break;case"vertical":{const i=o.minLeft+(o.maxRight-o.minLeft)/2;t.forEach((a,l)=>{a.options.left=i-r[l].width/2});break}case"horizontal":{const i=o.minTop+(o.maxBottom-o.minTop)/2;t.forEach((a,l)=>{a.options.top=i-r[l].height/2});break}case"distributeHor":{const i=t.map((s,d)=>({element:s,box:r[d]})).sort((s,d)=>s.box.left-d.box.left),a=i.reduce((s,d)=>s+d.box.width,0),l=(o.maxRight-o.minLeft-a)/(i.length-1);let c=o.minLeft;i.forEach(s=>{s.element.options.left=c,c+=s.box.width+l});break}case"distributeVer":{const i=t.map((s,d)=>({element:s,box:r[d]})).sort((s,d)=>s.box.top-d.box.top),a=i.reduce((s,d)=>s+d.box.height,0),l=(o.maxBottom-o.minTop-a)/(i.length-1);let c=o.minTop;i.forEach(s=>{s.element.options.top=c,c+=s.box.height+l});break}}}return{align:e}}function Pu(){return`grp-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function U1(){function e(r,o){if(r.filter(l=>o.has(l.id)).length<2)return r;const a=Pu();return r.map(l=>o.has(l.id)?{...l,options:{...l.options,groupId:a}}:l)}function t(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:e,ungroup:t,getGroupedIds:n}}const q1=["nw","n","ne","e","se","s","sw","w"];function W1(e,t,n,r,o,i){let{left:a,top:l,width:c,height:s}=t;switch(e){case"e":c=Math.max(o,t.width+n);break;case"w":c=Math.max(o,t.width-n),a=t.left+t.width-c;break;case"s":s=Math.max(i,t.height+r);break;case"n":s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"se":c=Math.max(o,t.width+n),s=Math.max(i,t.height+r);break;case"sw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height+r);break;case"ne":c=Math.max(o,t.width+n),s=Math.max(i,t.height-r),l=t.top+t.height-s;break;case"nw":c=Math.max(o,t.width-n),a=t.left+t.width-c,s=Math.max(i,t.height-r),l=t.top+t.height-s;break}return{left:a,top:l,width:c,height:s}}function Ru(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jo={},Ir={},Go={},Fu;function tt(){if(Fu)return Go;Fu=1,Object.defineProperty(Go,"__esModule",{value:!0});function e(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}var t=function n(r,o){e(this,n),this.data=r,this.text=o.text||r,this.options=o};return Go.default=t,Go}var $u;function j1(){if($u)return Ir;$u=1,Object.defineProperty(Ir,"__esModule",{value:!0}),Ir.CODE39=void 0;var e=(function(){function m(y,v){for(var w=0;w<v.length;w++){var E=v[w];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(y,E.key,E)}}return function(y,v,w){return v&&m(y.prototype,v),w&&m(y,w),y}})(),t=tt(),n=r(t);function r(m){return m&&m.__esModule?m:{default:m}}function o(m,y){if(!(m instanceof y))throw new TypeError("Cannot call a class as a function")}function i(m,y){if(!m)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y&&(typeof y=="object"||typeof y=="function")?y:m}function a(m,y){if(typeof y!="function"&&y!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof y);m.prototype=Object.create(y&&y.prototype,{constructor:{value:m,enumerable:!1,writable:!0,configurable:!0}}),y&&(Object.setPrototypeOf?Object.setPrototypeOf(m,y):m.__proto__=y)}var l=(function(m){a(y,m);function y(v,w){return o(this,y),v=v.toUpperCase(),w.mod43&&(v+=u(g(v))),i(this,(y.__proto__||Object.getPrototypeOf(y)).call(this,v,w))}return e(y,[{key:"encode",value:function(){for(var w=d("*"),E=0;E<this.data.length;E++)w+=d(this.data[E])+"0";return w+=d("*"),{data:w,text:this.text}}},{key:"valid",value:function(){return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/)!==-1}}]),y})(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 g(m){for(var y=0,v=0;v<m.length;v++)y+=f(m[v]);return y=y%43,y}return Ir.CODE39=l,Ir}var xt={},Vo={},Yo={},Se={},Nu;function Pr(){if(Nu)return Se;Nu=1,Object.defineProperty(Se,"__esModule",{value:!0});var e;function t(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=Se.SET_A=0,r=Se.SET_B=1,o=Se.SET_C=2;Se.SHIFT=98;var i=Se.START_A=103,a=Se.START_B=104,l=Se.START_C=105;return Se.MODULO=103,Se.STOP=106,Se.FNC1=207,Se.SET_BY_CODE=(e={},t(e,i,n),t(e,a,r),t(e,l,o),e),Se.SWAP={101:n,100:r,99:o},Se.A_START_CHAR="Ð",Se.B_START_CHAR="Ñ",Se.C_START_CHAR="Ò",Se.A_CHARS="[\0-_È-Ï]",Se.B_CHARS="[ -È-Ï]",Se.C_CHARS="(Ï*[0-9]{2}Ï*)",Se.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],Se}var Lu;function Ko(){if(Lu)return Yo;Lu=1,Object.defineProperty(Yo,"__esModule",{value:!0});var e=(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}})(),t=tt(),n=o(t),r=Pr();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(g){return g.charCodeAt(0)}),f}return e(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,g=r.SET_BY_CODE[f];if(g===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,g);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 g=u.shift();return g<32?g+64:g-32}else return f===r.SET_B?u.shift()-32:(u.shift()-48)*10+u.shift()-48}},{key:"next",value:function(u,f,g){if(!u.length)return{result:"",checksum:0};var m=void 0,y=void 0;if(u[0]>=200){y=u.shift()-105;var v=r.SWAP[y];v!==void 0?m=d.next(u,f+1,v):((g===r.SET_A||g===r.SET_B)&&y===r.SHIFT&&(u[0]=g===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,g))}else y=d.correctIndex(u,g),m=d.next(u,f+1,g);var w=d.getBar(y),E=y*f;return{result:w+m.result,checksum:E+m.checksum}}}]),d})(n.default);return Yo.default=c,Yo}var Xo={},Bu;function G1(){if(Bu)return Xo;Bu=1,Object.defineProperty(Xo,"__esModule",{value:!0});var e=Pr(),t=function(l){return l.match(new RegExp("^"+e.A_CHARS+"*"))[0].length},n=function(l){return l.match(new RegExp("^"+e.B_CHARS+"*"))[0].length},r=function(l){return l.match(new RegExp("^"+e.C_CHARS+"*"))[0]};function o(a,l){var c=l?e.A_CHARS:e.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=t(a)>=n(a);return l+String.fromCharCode(s?206:205)+o(a,s)}return Xo.default=function(a){var l=void 0,c=r(a).length;if(c>=2)l=e.C_START_CHAR+i(a);else{var s=t(a)>n(a);l=(s?e.A_START_CHAR:e.B_START_CHAR)+o(a,s)}return l.replace(/[\xCD\xCE]([^])[\xCD\xCE]/,function(d,p){return"Ë"+p})},Xo}var zu;function V1(){if(zu)return Vo;zu=1,Object.defineProperty(Vo,"__esModule",{value:!0});var e=Ko(),t=o(e),n=G1(),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})(t.default);return Vo.default=c,Vo}var Zo={},Hu;function Y1(){if(Hu)return Zo;Hu=1,Object.defineProperty(Zo,"__esModule",{value:!0});var e=(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}})(),t=Ko(),n=o(t),r=Pr();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 e(d,[{key:"valid",value:function(){return new RegExp("^"+r.A_CHARS+"+$").test(this.data)}}]),d})(n.default);return Zo.default=c,Zo}var Jo={},Uu;function K1(){if(Uu)return Jo;Uu=1,Object.defineProperty(Jo,"__esModule",{value:!0});var e=(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}})(),t=Ko(),n=o(t),r=Pr();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 e(d,[{key:"valid",value:function(){return new RegExp("^"+r.B_CHARS+"+$").test(this.data)}}]),d})(n.default);return Jo.default=c,Jo}var Qo={},qu;function X1(){if(qu)return Qo;qu=1,Object.defineProperty(Qo,"__esModule",{value:!0});var e=(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}})(),t=Ko(),n=o(t),r=Pr();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 e(d,[{key:"valid",value:function(){return new RegExp("^"+r.C_CHARS+"+$").test(this.data)}}]),d})(n.default);return Qo.default=c,Qo}var Wu;function Z1(){if(Wu)return xt;Wu=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.CODE128C=xt.CODE128B=xt.CODE128A=xt.CODE128=void 0;var e=V1(),t=c(e),n=Y1(),r=c(n),o=K1(),i=c(o),a=X1(),l=c(a);function c(s){return s&&s.__esModule?s:{default:s}}return xt.CODE128=t.default,xt.CODE128A=r.default,xt.CODE128B=i.default,xt.CODE128C=l.default,xt}var Xe={},ei={},zt={},ju;function Rr(){return ju||(ju=1,Object.defineProperty(zt,"__esModule",{value:!0}),zt.SIDE_BIN="101",zt.MIDDLE_BIN="01010",zt.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"]},zt.EAN2_STRUCTURE=["LL","LG","GL","GG"],zt.EAN5_STRUCTURE=["GGLLL","GLGLL","GLLGL","GLLLG","LGGLL","LLGGL","LLLGG","LGLGL","LGLLG","LLGLG"],zt.EAN13_STRUCTURE=["LLLLLL","LLGLGG","LLGGLG","LLGGGL","LGLLGG","LGGLLG","LGGGLL","LGLGLG","LGLGGL","LGGLGL"]),zt}var ti={},ni={},Gu;function Fr(){if(Gu)return ni;Gu=1,Object.defineProperty(ni,"__esModule",{value:!0});var e=Rr(),t=function(r,o,i){var a=r.split("").map(function(c,s){return e.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 ni.default=t,ni}var Vu;function Yu(){if(Vu)return ti;Vu=1,Object.defineProperty(ti,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=Rr(),n=Fr(),r=a(n),o=tt(),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,g){l(this,u);var m=c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.fontSize=!g.flat&&g.fontSize>g.width*10?g.width*10:g.fontSize,m.guardHeight=g.height+m.fontSize/2+g.textMargin,m}return e(u,[{key:"encode",value:function(){return this.options.flat?this.encodeFlat():this.encodeGuarded()}},{key:"leftText",value:function(g,m){return this.text.substr(g,m)}},{key:"leftEncode",value:function(g,m){return(0,r.default)(g,m)}},{key:"rightText",value:function(g,m){return this.text.substr(g,m)}},{key:"rightEncode",value:function(g,m){return(0,r.default)(g,m)}},{key:"encodeGuarded",value:function(){var g={fontSize:this.fontSize},m={height:this.guardHeight};return[{data:t.SIDE_BIN,options:m},{data:this.leftEncode(),text:this.leftText(),options:g},{data:t.MIDDLE_BIN,options:m},{data:this.rightEncode(),text:this.rightText(),options:g},{data:t.SIDE_BIN,options:m}]}},{key:"encodeFlat",value:function(){var g=[t.SIDE_BIN,this.leftEncode(),t.MIDDLE_BIN,this.rightEncode(),t.SIDE_BIN];return{data:g.join(""),text:this.text}}}]),u})(i.default);return ti.default=d,ti}var Ku;function J1(){if(Ku)return ei;Ku=1,Object.defineProperty(ei,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=function p(u,f,g){u===null&&(u=Function.prototype);var m=Object.getOwnPropertyDescriptor(u,f);if(m===void 0){var y=Object.getPrototypeOf(u);return y===null?void 0:p(y,f,g)}else{if("value"in m)return m.value;var v=m.get;return v===void 0?void 0:v.call(g)}},n=Rr(),r=Yu(),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(g){return+g}).reduce(function(g,m,y){return y%2?g+m*3:g+m},0);return(10-f%10)%10},d=(function(p){c(u,p);function u(f,g){a(this,u),f.search(/^[0-9]{12}$/)!==-1&&(f+=s(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.lastChar=g.lastChar,m}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{13}$/)!==-1&&+this.data[12]===s(this.data)}},{key:"leftText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftText",this).call(this,1,6)}},{key:"leftEncode",value:function(){var g=this.data.substr(1,6),m=n.EAN13_STRUCTURE[this.data[0]];return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"leftEncode",this).call(this,g,m)}},{key:"rightText",value:function(){return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightText",this).call(this,7,6)}},{key:"rightEncode",value:function(){var g=this.data.substr(7,6);return t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"rightEncode",this).call(this,g,"RRRRRR")}},{key:"encodeGuarded",value:function(){var g=t(u.prototype.__proto__||Object.getPrototypeOf(u.prototype),"encodeGuarded",this).call(this);return this.options.displayValue&&(g.unshift({data:"000000000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),this.options.lastChar&&(g.push({data:"00"}),g.push({data:"00000",text:this.options.lastChar,options:{fontSize:this.fontSize}}))),g}}]),u})(o.default);return ei.default=d,ei}var ri={},Xu;function Q1(){if(Xu)return ri;Xu=1,Object.defineProperty(ri,"__esModule",{value:!0});var e=(function(){function d(p,u){for(var f=0;f<u.length;f++){var g=u[f];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(p,g.key,g)}}return function(p,u,f){return u&&d(p.prototype,u),f&&d(p,f),p}})(),t=function d(p,u,f){p===null&&(p=Function.prototype);var g=Object.getOwnPropertyDescriptor(p,u);if(g===void 0){var m=Object.getPrototypeOf(p);return m===null?void 0:d(m,u,f)}else{if("value"in g)return g.value;var y=g.get;return y===void 0?void 0:y.call(f)}},n=Yu(),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,g,m){return m%2?f+g:f+g*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 e(p,[{key:"valid",value:function(){return this.data.search(/^[0-9]{8}$/)!==-1&&+this.data[7]===c(this.data)}},{key:"leftText",value:function(){return t(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 t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"leftEncode",this).call(this,f,"LLLL")}},{key:"rightText",value:function(){return t(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 t(p.prototype.__proto__||Object.getPrototypeOf(p.prototype),"rightEncode",this).call(this,f,"RRRR")}}]),p})(r.default);return ri.default=s,ri}var oi={},Zu;function ey(){if(Zu)return oi;Zu=1,Object.defineProperty(oi,"__esModule",{value:!0});var e=(function(){function u(f,g){for(var m=0;m<g.length;m++){var y=g[m];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(f,y.key,y)}}return function(f,g,m){return g&&u(f.prototype,g),m&&u(f,m),f}})(),t=Rr(),n=Fr(),r=a(n),o=tt(),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 g=f.split("").map(function(m){return+m}).reduce(function(m,y,v){return v%2?m+y*9:m+y*3},0);return g%10},p=(function(u){s(f,u);function f(g,m){return l(this,f),c(this,(f.__proto__||Object.getPrototypeOf(f)).call(this,g,m))}return e(f,[{key:"valid",value:function(){return this.data.search(/^[0-9]{5}$/)!==-1}},{key:"encode",value:function(){var m=t.EAN5_STRUCTURE[d(this.data)];return{data:"1011"+(0,r.default)(this.data,m,"01"),text:this.text}}}]),f})(i.default);return oi.default=p,oi}var ii={},Ju;function ty(){if(Ju)return ii;Ju=1,Object.defineProperty(ii,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})(),t=Rr(),n=Fr(),r=a(n),o=tt(),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,g){return l(this,u),c(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g))}return e(u,[{key:"valid",value:function(){return this.data.search(/^[0-9]{2}$/)!==-1}},{key:"encode",value:function(){var g=t.EAN2_STRUCTURE[parseInt(this.data)%4];return{data:"1011"+(0,r.default)(this.data,g,"01"),text:this.text}}}]),u})(i.default);return ii.default=d,ii}var $r={},Qu;function ep(){if(Qu)return $r;Qu=1,Object.defineProperty($r,"__esModule",{value:!0});var e=(function(){function p(u,f){for(var g=0;g<f.length;g++){var m=f[g];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,m.key,m)}}return function(u,f,g){return f&&p(u.prototype,f),g&&p(u,g),u}})();$r.checksum=d;var t=Fr(),n=i(t),r=tt(),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,g){a(this,u),f.search(/^[0-9]{11}$/)!==-1&&(f+=d(f));var m=l(this,(u.__proto__||Object.getPrototypeOf(u)).call(this,f,g));return m.displayValue=g.displayValue,g.fontSize>g.width*10?m.fontSize=g.width*10:m.fontSize=g.fontSize,m.guardHeight=g.height+m.fontSize/2+g.textMargin,m}return e(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 g="";return g+="101",g+=(0,n.default)(this.data.substr(0,6),"LLLLLL"),g+="01010",g+=(0,n.default)(this.data.substr(6,6),"RRRRRR"),g+="101",{data:g,text:this.text}}},{key:"guardedEncoding",value:function(){var g=[];return this.displayValue&&g.push({data:"00000000",text:this.text.substr(0,1),options:{textAlign:"left",fontSize:this.fontSize}}),g.push({data:"101"+(0,n.default)(this.data[0],"L"),options:{height:this.guardHeight}}),g.push({data:(0,n.default)(this.data.substr(1,5),"LLLLL"),text:this.text.substr(1,5),options:{fontSize:this.fontSize}}),g.push({data:"01010",options:{height:this.guardHeight}}),g.push({data:(0,n.default)(this.data.substr(6,5),"RRRRR"),text:this.text.substr(6,5),options:{fontSize:this.fontSize}}),g.push({data:(0,n.default)(this.data[11],"R")+"101",options:{height:this.guardHeight}}),this.displayValue&&g.push({data:"00000000",text:this.text.substr(11,1),options:{textAlign:"right",fontSize:this.fontSize}}),g}}]),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 $r.default=s,$r}var ai={},tp;function ny(){if(tp)return ai;tp=1,Object.defineProperty(ai,"__esModule",{value:!0});var e=(function(){function g(m,y){for(var v=0;v<y.length;v++){var w=y[v];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(m,w.key,w)}}return function(m,y,v){return y&&g(m.prototype,y),v&&g(m,v),m}})(),t=Fr(),n=a(t),r=tt(),o=a(r),i=ep();function a(g){return g&&g.__esModule?g:{default:g}}function l(g,m){if(!(g instanceof m))throw new TypeError("Cannot call a class as a function")}function c(g,m){if(!g)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m&&(typeof m=="object"||typeof m=="function")?m:g}function s(g,m){if(typeof m!="function"&&m!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof m);g.prototype=Object.create(m&&m.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),m&&(Object.setPrototypeOf?Object.setPrototypeOf(g,m):g.__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(g){s(m,g);function m(y,v){l(this,m);var w=c(this,(m.__proto__||Object.getPrototypeOf(m)).call(this,y,v));if(w.isValid=!1,y.search(/^[0-9]{6}$/)!==-1)w.middleDigits=y,w.upcA=f(y,"0"),w.text=v.text||""+w.upcA[0]+y+w.upcA[w.upcA.length-1],w.isValid=!0;else if(y.search(/^[01][0-9]{7}$/)!==-1)if(w.middleDigits=y.substring(1,y.length-1),w.upcA=f(w.middleDigits,y[0]),w.upcA[w.upcA.length-1]===y[y.length-1])w.isValid=!0;else return c(w);else return c(w);return w.displayValue=v.displayValue,v.fontSize>v.width*10?w.fontSize=v.width*10:w.fontSize=v.fontSize,w.guardHeight=v.height+w.fontSize/2+v.textMargin,w}return e(m,[{key:"valid",value:function(){return this.isValid}},{key:"encode",value:function(){return this.options.flat?this.flatEncoding():this.guardedEncoding()}},{key:"flatEncoding",value:function(){var v="";return v+="101",v+=this.encodeMiddleDigits(),v+="010101",{data:v,text:this.text}}},{key:"guardedEncoding",value:function(){var v=[];return this.displayValue&&v.push({data:"00000000",text:this.text[0],options:{textAlign:"left",fontSize:this.fontSize}}),v.push({data:"101",options:{height:this.guardHeight}}),v.push({data:this.encodeMiddleDigits(),text:this.text.substring(1,7),options:{fontSize:this.fontSize}}),v.push({data:"010101",options:{height:this.guardHeight}}),this.displayValue&&v.push({data:"00000000",text:this.text[7],options:{textAlign:"right",fontSize:this.fontSize}}),v}},{key:"encodeMiddleDigits",value:function(){var v=this.upcA[0],w=this.upcA[this.upcA.length-1],E=p[parseInt(w)][parseInt(v)];return(0,n.default)(this.middleDigits,E)}}]),m})(o.default);function f(g,m){for(var y=parseInt(g[g.length-1]),v=d[y],w="",E=0,T=0;T<v.length;T++){var P=v[T];P==="X"?w+=g[E++]:w+=P}return w=""+m+w,""+w+(0,i.checksum)(w)}return ai.default=u,ai}var np;function ry(){if(np)return Xe;np=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.UPCE=Xe.UPC=Xe.EAN2=Xe.EAN5=Xe.EAN8=Xe.EAN13=void 0;var e=J1(),t=u(e),n=Q1(),r=u(n),o=ey(),i=u(o),a=ty(),l=u(a),c=ep(),s=u(c),d=ny(),p=u(d);function u(f){return f&&f.__esModule?f:{default:f}}return Xe.EAN13=t.default,Xe.EAN8=r.default,Xe.EAN5=i.default,Xe.EAN2=l.default,Xe.UPC=s.default,Xe.UPCE=p.default,Xe}var wn={},si={},Gn={},rp;function oy(){return rp||(rp=1,Object.defineProperty(Gn,"__esModule",{value:!0}),Gn.START_BIN="1010",Gn.END_BIN="11101",Gn.BINARIES=["00110","10001","01001","11000","00101","10100","01100","00011","10010","01010"]),Gn}var op;function ip(){if(op)return si;op=1,Object.defineProperty(si,"__esModule",{value:!0});var e=(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}})(),t=oy(),n=tt(),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 e(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(g){return u.encodePair(g)}).join("");return{data:t.START_BIN+f+t.END_BIN,text:this.text}}},{key:"encodePair",value:function(u){var f=t.BINARIES[u[1]];return t.BINARIES[u[0]].split("").map(function(g,m){return(g==="1"?"111":"1")+(f[m]==="1"?"000":"0")}).join("")}}]),d})(r.default);return si.default=c,si}var li={},ap;function iy(){if(ap)return li;ap=1,Object.defineProperty(li,"__esModule",{value:!0});var e=(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}})(),t=ip(),n=r(t);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,g){return u+f*(3-g%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 e(d,[{key:"valid",value:function(){return this.data.search(/^[0-9]{14}$/)!==-1&&+this.data[13]===l(this.data)}}]),d})(n.default);return li.default=c,li}var sp;function ay(){if(sp)return wn;sp=1,Object.defineProperty(wn,"__esModule",{value:!0}),wn.ITF14=wn.ITF=void 0;var e=ip(),t=o(e),n=iy(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return wn.ITF=t.default,wn.ITF14=r.default,wn}var nt={},ci={},lp;function Nr(){if(lp)return ci;lp=1,Object.defineProperty(ci,"__esModule",{value:!0});var e=(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}})(),t=tt(),n=r(t);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 e(d,[{key:"encode",value:function(){for(var u="110",f=0;f<this.data.length;f++){var g=parseInt(this.data[f]),m=g.toString(2);m=c(m,4-m.length);for(var y=0;y<m.length;y++)u+=m[y]=="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 ci.default=l,ci}var di={},Lr={},cp;function ui(){if(cp)return Lr;cp=1,Object.defineProperty(Lr,"__esModule",{value:!0}),Lr.mod10=e,Lr.mod11=t;function e(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 t(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 Lr}var dp;function sy(){if(dp)return di;dp=1,Object.defineProperty(di,"__esModule",{value:!0});var e=Nr(),t=r(e),n=ui();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})(t.default);return di.default=l,di}var pi={},up;function ly(){if(up)return pi;up=1,Object.defineProperty(pi,"__esModule",{value:!0});var e=Nr(),t=r(e),n=ui();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})(t.default);return pi.default=l,pi}var fi={},pp;function cy(){if(pp)return fi;pp=1,Object.defineProperty(fi,"__esModule",{value:!0});var e=Nr(),t=r(e),n=ui();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})(t.default);return fi.default=l,fi}var hi={},fp;function dy(){if(fp)return hi;fp=1,Object.defineProperty(hi,"__esModule",{value:!0});var e=Nr(),t=r(e),n=ui();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})(t.default);return hi.default=l,hi}var hp;function uy(){if(hp)return nt;hp=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.MSI1110=nt.MSI1010=nt.MSI11=nt.MSI10=nt.MSI=void 0;var e=Nr(),t=d(e),n=sy(),r=d(n),o=ly(),i=d(o),a=cy(),l=d(a),c=dy(),s=d(c);function d(p){return p&&p.__esModule?p:{default:p}}return nt.MSI=t.default,nt.MSI10=r.default,nt.MSI11=i.default,nt.MSI1010=l.default,nt.MSI1110=s.default,nt}var Br={},gp;function py(){if(gp)return Br;gp=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.pharmacode=void 0;var e=(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}})(),t=tt(),n=r(t);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 e(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 Br.pharmacode=l,Br}var zr={},mp;function fy(){if(mp)return zr;mp=1,Object.defineProperty(zr,"__esModule",{value:!0}),zr.codabar=void 0;var e=(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}})(),t=tt(),n=r(t);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 e(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 zr.codabar=l,zr}var xn={},gi={},Vn={},bp;function hy(){return bp||(bp=1,Object.defineProperty(Vn,"__esModule",{value:!0}),Vn.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","-","."," ","$","/","+","%","($)","(%)","(/)","(+)","ÿ"],Vn.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"],Vn.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"]}),Vn}var yp;function vp(){if(yp)return gi;yp=1,Object.defineProperty(gi,"__esModule",{value:!0});var e=(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}})(),t=hy(),n=tt(),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 e(d,[{key:"valid",value:function(){return/^[0-9A-Z\-. $/+%]+$/.test(this.data)}},{key:"encode",value:function(){var u=this.data.split("").flatMap(function(y){return t.MULTI_SYMBOLS[y]||y}),f=u.map(function(y){return d.getEncoding(y)}).join(""),g=d.checksum(u,20),m=d.checksum(u.concat(g),15);return{text:this.text,data:d.getEncoding("ÿ")+f+d.getEncoding(g)+d.getEncoding(m)+d.getEncoding("ÿ")+"1"}}}],[{key:"getEncoding",value:function(u){return t.BINARIES[d.symbolValue(u)]}},{key:"getSymbol",value:function(u){return t.SYMBOLS[u]}},{key:"symbolValue",value:function(u){return t.SYMBOLS.indexOf(u)}},{key:"checksum",value:function(u,f){var g=u.slice().reverse().reduce(function(m,y,v){var w=v%f+1;return m+d.symbolValue(y)*w},0);return d.getSymbol(g%47)}}]),d})(r.default);return gi.default=c,gi}var mi={},wp;function gy(){if(wp)return mi;wp=1,Object.defineProperty(mi,"__esModule",{value:!0});var e=(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}})(),t=vp(),n=r(t);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 e(s,[{key:"valid",value:function(){return/^[\x00-\x7f]+$/.test(this.data)}}]),s})(n.default);return mi.default=l,mi}var xp;function my(){if(xp)return xn;xp=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.CODE93FullASCII=xn.CODE93=void 0;var e=vp(),t=o(e),n=gy(),r=o(n);function o(i){return i&&i.__esModule?i:{default:i}}return xn.CODE93=t.default,xn.CODE93FullASCII=r.default,xn}var Hr={},Ep;function by(){if(Ep)return Hr;Ep=1,Object.defineProperty(Hr,"__esModule",{value:!0}),Hr.GenericBarcode=void 0;var e=(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}})(),t=tt(),n=r(t);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 e(s,[{key:"encode",value:function(){return{data:"10101010101010101010101010101010101010101",text:this.text}}},{key:"valid",value:function(){return!0}}]),s})(n.default);return Hr.GenericBarcode=l,Hr}var Sp;function yy(){if(Sp)return jo;Sp=1,Object.defineProperty(jo,"__esModule",{value:!0});var e=j1(),t=Z1(),n=ry(),r=ay(),o=uy(),i=py(),a=fy(),l=my(),c=by();return jo.default={CODE39:e.CODE39,CODE128:t.CODE128,CODE128A:t.CODE128A,CODE128B:t.CODE128B,CODE128C:t.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},jo}var bi={},_p;function yi(){if(_p)return bi;_p=1,Object.defineProperty(bi,"__esModule",{value:!0});var e=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t};return bi.default=function(t,n){return e({},t,n)},bi}var vi={},Mp;function vy(){if(Mp)return vi;Mp=1,Object.defineProperty(vi,"__esModule",{value:!0}),vi.default=e;function e(t){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(t),n}return vi}var wi={},Tp;function wy(){if(Tp)return wi;Tp=1,Object.defineProperty(wi,"__esModule",{value:!0}),wi.default=e;function e(t){return t.marginTop=t.marginTop||t.margin,t.marginBottom=t.marginBottom||t.margin,t.marginRight=t.marginRight||t.margin,t.marginLeft=t.marginLeft||t.margin,t}return wi}var xi={},Ei={},Si={},Cp;function kp(){if(Cp)return Si;Cp=1,Object.defineProperty(Si,"__esModule",{value:!0}),Si.default=e;function e(t){var n=["width","height","textMargin","fontSize","margin","marginTop","marginBottom","marginLeft","marginRight"];for(var r in n)n.hasOwnProperty(r)&&(r=n[r],typeof t[r]=="string"&&(t[r]=parseInt(t[r],10)));return typeof t.displayValue=="string"&&(t.displayValue=t.displayValue!="false"),t}return Si}var _i={},Ap;function Dp(){if(Ap)return _i;Ap=1,Object.defineProperty(_i,"__esModule",{value:!0});var e={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 _i.default=e,_i}var Op;function xy(){if(Op)return Ei;Op=1,Object.defineProperty(Ei,"__esModule",{value:!0});var e=kp(),t=o(e),n=Dp(),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,t.default)(l),l}return Ei.default=i,Ei}var Mi={},Ti={},rt={},Ip;function Pp(){if(Ip)return rt;Ip=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.getTotalWidthOfEncodings=rt.calculateEncodingAttributes=rt.getBarcodePadding=rt.getEncodingHeight=rt.getMaximumHeightOfEncodings=void 0;var e=yi(),t=n(e);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],g=(0,t.default)(d,f.options),m;g.displayValue?m=c(f.text,g,p):m=0;var y=f.data.length*g.width;f.width=Math.ceil(Math.max(m,y)),f.height=r(f,g),f.barcodePadding=o(m,y,g)}}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 g=f.width;return g}return rt.getMaximumHeightOfEncodings=l,rt.getEncodingHeight=r,rt.getBarcodePadding=o,rt.calculateEncodingAttributes=i,rt.getTotalWidthOfEncodings=a,rt}var Rp;function Ey(){if(Rp)return Ti;Rp=1,Object.defineProperty(Ti,"__esModule",{value:!0});var e=(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}})(),t=yi(),n=o(t),r=Pp();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 e(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 g=0;g<u.length;g++){var m=g*s.width+d.barcodePadding;u[g]==="1"?p.fillRect(m,f,s.width,s.height):u[g]&&p.fillRect(m,f,s.width,s.height*u[g])}}},{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,g;s.textPosition=="top"?g=s.marginTop+s.fontSize-s.textMargin:g=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,g)}}},{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 Ti.default=a,Ti}var Ci={},Fp;function Sy(){if(Fp)return Ci;Fp=1,Object.defineProperty(Ci,"__esModule",{value:!0});var e=(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}})(),t=yi(),n=o(t),r=Pp();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 e(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),g=this.createGroup(d,f.marginTop,this.svg);this.setGroupOptions(g,f),this.drawSvgBarcode(g,f,u),this.drawSVGText(g,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,g;p.textPosition=="top"?g=p.fontSize+p.textMargin:g=0;for(var m=0,y=0,v=0;v<f.length;v++)y=v*p.width+u.barcodePadding,f[v]==="1"?m++:m>0&&(this.drawRect(y-p.width*m,g,p.width*m,p.height,d),m=0);m>0&&this.drawRect(y-p.width*(m-1),g,p.width*m,p.height,d)}},{key:"drawSVGText",value:function(d,p,u){var f=this.document.createElementNS(a,"text");if(p.displayValue){var g,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?(g=0,f.setAttribute("text-anchor","start")):p.textAlign=="right"?(g=u.width-1,f.setAttribute("text-anchor","end")):(g=u.width/2,f.setAttribute("text-anchor","middle")),f.setAttribute("x",g),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,g){var m=this.document.createElementNS(a,"rect");return m.setAttribute("x",d),m.setAttribute("y",p),m.setAttribute("width",u),m.setAttribute("height",f),g.appendChild(m),m}}]),c})();return Ci.default=l,Ci}var ki={},$p;function _y(){if($p)return ki;$p=1,Object.defineProperty(ki,"__esModule",{value:!0});var e=(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 t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o,i,a){t(this,r),this.object=o,this.encodings=i,this.options=a}return e(r,[{key:"render",value:function(){this.object.encodings=this.encodings}}]),r})();return ki.default=n,ki}var Np;function My(){if(Np)return Mi;Np=1,Object.defineProperty(Mi,"__esModule",{value:!0});var e=Ey(),t=a(e),n=Sy(),r=a(n),o=_y(),i=a(o);function a(l){return l&&l.__esModule?l:{default:l}}return Mi.default={CanvasRenderer:t.default,SVGRenderer:r.default,ObjectRenderer:i.default},Mi}var Yn={},Lp;function Bp(){if(Lp)return Yn;Lp=1,Object.defineProperty(Yn,"__esModule",{value:!0});function e(a,l){if(!(a instanceof l))throw new TypeError("Cannot call a class as a function")}function t(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){e(this,l);var d=t(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(){e(this,l);var c=t(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(){e(this,l);var c=t(this,(l.__proto__||Object.getPrototypeOf(l)).call(this));return c.name="NoElementException",c.message="No element to render on.",c}return l})(Error);return Yn.InvalidInputException=r,Yn.InvalidElementException=o,Yn.NoElementException=i,Yn}var zp;function Ty(){if(zp)return xi;zp=1,Object.defineProperty(xi,"__esModule",{value:!0});var e=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},t=xy(),n=a(t),r=My(),o=a(r),i=Bp();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":e(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 xi.default=l,xi}var Ai={},Hp;function Cy(){if(Hp)return Ai;Hp=1,Object.defineProperty(Ai,"__esModule",{value:!0});var e=(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 t(r,o){if(!(r instanceof o))throw new TypeError("Cannot call a class as a function")}var n=(function(){function r(o){t(this,r),this.api=o}return e(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 Ai.default=n,Ai}var ps,Up;function ky(){if(Up)return ps;Up=1;var e=yy(),t=v(e),n=yi(),r=v(n),o=vy(),i=v(o),a=wy(),l=v(a),c=Ty(),s=v(c),d=kp(),p=v(d),u=Cy(),f=v(u),g=Bp(),m=Dp(),y=v(m);function v(k){return k&&k.__esModule?k:{default:k}}var w=function(){},E=function(R,S,$){var N=new w;if(typeof R>"u")throw Error("No element to render on was provided.");return N._renderProperties=(0,s.default)(R),N._encodings=[],N._options=y.default,N._errorHandler=new f.default(N),typeof S<"u"&&($=$||{},$.format||($.format=I()),N.options($)[$.format](S,$).render()),N};E.getModule=function(k){return t.default[k]};for(var T in t.default)t.default.hasOwnProperty(T)&&P(t.default,T);function P(k,R){w.prototype[R]=w.prototype[R.toUpperCase()]=w.prototype[R.toLowerCase()]=function(S,$){var N=this;return N._errorHandler.wrapBarcodeCall(function(){$.text=typeof $.text>"u"?void 0:""+$.text;var B=(0,r.default)(N._options,$);B=(0,p.default)(B);var C=k[R],ie=O(S,C,B);return N._encodings.push(ie),N})}}function O(k,R,S){k=""+k;var $=new R(k,S);if(!$.valid())throw new g.InvalidInputException($.constructor.name,k);var N=$.encode();N=(0,i.default)(N);for(var B=0;B<N.length;B++)N[B].options=(0,r.default)(S,N[B].options);return N}function I(){return t.default.CODE128?"CODE128":Object.keys(t.default)[0]}w.prototype.options=function(k){return this._options=(0,r.default)(this._options,k),this},w.prototype.blank=function(k){var R=new Array(k+1).join("0");return this._encodings.push({data:R}),this},w.prototype.init=function(){if(this._renderProperties){Array.isArray(this._renderProperties)||(this._renderProperties=[this._renderProperties]);var k;for(var R in this._renderProperties){k=this._renderProperties[R];var S=(0,r.default)(this._options,k.options);S.format=="auto"&&(S.format=I()),this._errorHandler.wrapBarcodeCall(function(){var $=S.value,N=t.default[S.format.toUpperCase()],B=O($,N,S);A(k,B,S)})}}},w.prototype.render=function(){if(!this._renderProperties)throw new g.NoElementException;if(Array.isArray(this._renderProperties))for(var k=0;k<this._renderProperties.length;k++)A(this._renderProperties[k],this._encodings,this._options);else A(this._renderProperties,this._encodings,this._options);return this},w.prototype._defaults=y.default;function A(k,R,S){R=(0,i.default)(R);for(var $=0;$<R.length;$++)R[$].options=(0,r.default)(S,R[$].options),(0,l.default)(R[$].options);(0,l.default)(S);var N=k.renderer,B=new N(k.element,R,S);B.render(),k.afterRender&&k.afterRender()}return typeof window<"u"&&(window.JsBarcode=E),typeof jQuery<"u"&&(jQuery.fn.JsBarcode=function(k,R){var S=[];return jQuery(this).each(function(){S.push(this)}),E(S,k,R)}),ps=E,ps}var Ay=ky();const fs=Ru(Ay);var Kn={},hs,qp;function Dy(){return qp||(qp=1,hs=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),hs}var gs={},en={},Wp;function En(){if(Wp)return en;Wp=1;let e;const t=[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 en.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},en.getSymbolTotalCodewords=function(r){return t[r]},en.getBCHDigit=function(n){let r=0;for(;n!==0;)r++,n>>>=1;return r},en.setToSJISFunction=function(r){if(typeof r!="function")throw new Error('"toSJISFunc" is not a valid function.');e=r},en.isKanjiModeEnabled=function(){return typeof e<"u"},en.toSJIS=function(r){return e(r)},en}var ms={},jp;function bs(){return jp||(jp=1,(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,o){if(e.isValid(r))return r;try{return t(r)}catch{return o}}})(ms)),ms}var ys,Gp;function Oy(){if(Gp)return ys;Gp=1;function e(){this.buffer=[],this.length=0}return e.prototype={get:function(t){const n=Math.floor(t/8);return(this.buffer[n]>>>7-t%8&1)===1},put:function(t,n){for(let r=0;r<n;r++)this.putBit((t>>>n-r-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),t&&(this.buffer[n]|=128>>>this.length%8),this.length++}},ys=e,ys}var vs,Vp;function Iy(){if(Vp)return vs;Vp=1;function e(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return e.prototype.set=function(t,n,r,o){const i=t*this.size+n;this.data[i]=r,o&&(this.reservedBit[i]=!0)},e.prototype.get=function(t,n){return this.data[t*this.size+n]},e.prototype.xor=function(t,n,r){this.data[t*this.size+n]^=r},e.prototype.isReserved=function(t,n){return this.reservedBit[t*this.size+n]},vs=e,vs}var ws={},Yp;function Py(){return Yp||(Yp=1,(function(e){const t=En().getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const o=Math.floor(r/7)+2,i=t(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()},e.getPositions=function(r){const o=[],i=e.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}})(ws)),ws}var xs={},Kp;function Ry(){if(Kp)return xs;Kp=1;const e=En().getSymbolSize,t=7;return xs.getPositions=function(r){const o=e(r);return[[0,0],[o-t,0],[0,o-t]]},xs}var Es={},Xp;function Fy(){return Xp||(Xp=1,(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(o){return o!=null&&o!==""&&!isNaN(o)&&o>=0&&o<=7},e.from=function(o){return e.isValid(o)?parseInt(o,10):void 0},e.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+=t.N1+(l-5)),s=f,l=1),f=o.get(u,p),f===d?c++:(c>=5&&(a+=t.N1+(c-5)),d=f,c=1)}l>=5&&(a+=t.N1+(l-5)),c>=5&&(a+=t.N1+(c-5))}return a},e.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*t.N2},e.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*t.N3},e.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)*t.N4};function n(r,o,i){switch(r){case e.Patterns.PATTERN000:return(o+i)%2===0;case e.Patterns.PATTERN001:return o%2===0;case e.Patterns.PATTERN010:return i%3===0;case e.Patterns.PATTERN011:return(o+i)%3===0;case e.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(i/3))%2===0;case e.Patterns.PATTERN101:return o*i%2+o*i%3===0;case e.Patterns.PATTERN110:return(o*i%2+o*i%3)%2===0;case e.Patterns.PATTERN111:return(o*i%3+(o+i)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.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))},e.getBestMask=function(o,i){const a=Object.keys(e.Patterns).length;let l=0,c=1/0;for(let s=0;s<a;s++){i(s),e.applyMask(s,o);const d=e.getPenaltyN1(o)+e.getPenaltyN2(o)+e.getPenaltyN3(o)+e.getPenaltyN4(o);e.applyMask(s,o),d<c&&(c=d,l=s)}return l}})(Es)),Es}var Di={},Zp;function Jp(){if(Zp)return Di;Zp=1;const e=bs(),t=[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 Di.getBlocksCount=function(o,i){switch(i){case e.L:return t[(o-1)*4+0];case e.M:return t[(o-1)*4+1];case e.Q:return t[(o-1)*4+2];case e.H:return t[(o-1)*4+3];default:return}},Di.getTotalCodewordsCount=function(o,i){switch(i){case e.L:return n[(o-1)*4+0];case e.M:return n[(o-1)*4+1];case e.Q:return n[(o-1)*4+2];case e.H:return n[(o-1)*4+3];default:return}},Di}var Ss={},Ur={},Qp;function $y(){if(Qp)return Ur;Qp=1;const e=new Uint8Array(512),t=new Uint8Array(256);return(function(){let r=1;for(let o=0;o<255;o++)e[o]=r,t[r]=o,r<<=1,r&256&&(r^=285);for(let o=255;o<512;o++)e[o]=e[o-255]})(),Ur.log=function(r){if(r<1)throw new Error("log("+r+")");return t[r]},Ur.exp=function(r){return e[r]},Ur.mul=function(r,o){return r===0||o===0?0:e[t[r]+t[o]]},Ur}var ef;function Ny(){return ef||(ef=1,(function(e){const t=$y();e.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]^=t.mul(r[a],o[l]);return i},e.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]^=t.mul(o[c],a);let l=0;for(;l<i.length&&i[l]===0;)l++;i=i.slice(l)}return i},e.generateECPolynomial=function(r){let o=new Uint8Array([1]);for(let i=0;i<r;i++)o=e.mul(o,new Uint8Array([1,t.exp(i)]));return o}})(Ss)),Ss}var _s,tf;function Ly(){if(tf)return _s;tf=1;const e=Ny();function t(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(r){this.degree=r,this.genPoly=e.generateECPolynomial(this.degree)},t.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=e.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},_s=t,_s}var Ms={},Ts={},Cs={},nf;function rf(){return nf||(nf=1,Cs.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),Cs}var Pt={},of;function af(){if(of)return Pt;of=1;const e="[0-9]+",t="[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
264
+ ]))+`;Pt.KANJI=new RegExp(n,"g"),Pt.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Pt.BYTE=new RegExp(r,"g"),Pt.NUMERIC=new RegExp(e,"g"),Pt.ALPHANUMERIC=new RegExp(t,"g");const o=new RegExp("^"+n+"$"),i=new RegExp("^"+e+"$"),a=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Pt.testKanji=function(c){return o.test(c)},Pt.testNumeric=function(c){return i.test(c)},Pt.testAlphanumeric=function(c){return a.test(c)},Pt}var sf;function Sn(){return sf||(sf=1,(function(e){const t=rf(),n=af();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(i,a){if(!i.ccBits)throw new Error("Invalid mode: "+i);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?i.ccBits[0]:a<27?i.ccBits[1]:i.ccBits[2]},e.getBestModeForData=function(i){return n.testNumeric(i)?e.NUMERIC:n.testAlphanumeric(i)?e.ALPHANUMERIC:n.testKanji(i)?e.KANJI:e.BYTE},e.toString=function(i){if(i&&i.id)return i.id;throw new Error("Invalid mode")},e.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 e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+o)}}e.from=function(i,a){if(e.isValid(i))return i;try{return r(i)}catch{return a}}})(Ts)),Ts}var lf;function By(){return lf||(lf=1,(function(e){const t=En(),n=Jp(),r=bs(),o=Sn(),i=rf(),a=7973,l=t.getBCHDigit(a);function c(u,f,g){for(let m=1;m<=40;m++)if(f<=e.getCapacity(m,g,u))return m}function s(u,f){return o.getCharCountIndicator(u,f)+4}function d(u,f){let g=0;return u.forEach(function(m){const y=s(m.mode,f);g+=y+m.getBitsLength()}),g}function p(u,f){for(let g=1;g<=40;g++)if(d(u,g)<=e.getCapacity(g,f,o.MIXED))return g}e.from=function(f,g){return i.isValid(f)?parseInt(f,10):g},e.getCapacity=function(f,g,m){if(!i.isValid(f))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=o.BYTE);const y=t.getSymbolTotalCodewords(f),v=n.getTotalCodewordsCount(f,g),w=(y-v)*8;if(m===o.MIXED)return w;const E=w-s(m,f);switch(m){case o.NUMERIC:return Math.floor(E/10*3);case o.ALPHANUMERIC:return Math.floor(E/11*2);case o.KANJI:return Math.floor(E/13);case o.BYTE:default:return Math.floor(E/8)}},e.getBestVersionForData=function(f,g){let m;const y=r.from(g,r.M);if(Array.isArray(f)){if(f.length>1)return p(f,y);if(f.length===0)return 1;m=f[0]}else m=f;return c(m.mode,m.getLength(),y)},e.getEncodedBits=function(f){if(!i.isValid(f)||f<7)throw new Error("Invalid QR Code version");let g=f<<12;for(;t.getBCHDigit(g)-l>=0;)g^=a<<t.getBCHDigit(g)-l;return f<<12|g}})(Ms)),Ms}var ks={},cf;function zy(){if(cf)return ks;cf=1;const e=En(),t=1335,n=21522,r=e.getBCHDigit(t);return ks.getEncodedBits=function(i,a){const l=i.bit<<3|a;let c=l<<10;for(;e.getBCHDigit(c)-r>=0;)c^=t<<e.getBCHDigit(c)-r;return(l<<10|c)^n},ks}var As={},Ds,df;function Hy(){if(df)return Ds;df=1;const e=Sn();function t(n){this.mode=e.NUMERIC,this.data=n.toString()}return t.getBitsLength=function(r){return 10*Math.floor(r/3)+(r%3?r%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.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))},Ds=t,Ds}var Os,uf;function Uy(){if(uf)return Os;uf=1;const e=Sn(),t=["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=e.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=t.indexOf(this.data[i])*45;a+=t.indexOf(this.data[i+1]),o.put(a,11)}this.data.length%2&&o.put(t.indexOf(this.data[i]),6)},Os=n,Os}var Is,pf;function qy(){if(pf)return Is;pf=1;const e=Sn();function t(n){this.mode=e.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return t.getBitsLength=function(r){return r*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(n){for(let r=0,o=this.data.length;r<o;r++)n.put(this.data[r],8)},Is=t,Is}var Ps,ff;function Wy(){if(ff)return Ps;ff=1;const e=Sn(),t=En();function n(r){this.mode=e.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=t.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]+`
265
+ Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),r.put(i,13)}},Ps=n,Ps}var Rs={exports:{}},hf;function jy(){return hf||(hf=1,(function(e){var t={single_source_shortest_paths:function(n,r,o){var i={},a={};a[r]=0;var l=t.PriorityQueue.make();l.push(r,0);for(var c,s,d,p,u,f,g,m,y;!l.empty();){c=l.pop(),s=c.value,p=c.cost,u=n[s]||{};for(d in u)u.hasOwnProperty(d)&&(f=u[d],g=p+f,m=a[d],y=typeof a[d]>"u",(y||m>g)&&(a[d]=g,l.push(d,g),i[d]=s))}if(typeof o<"u"&&typeof a[o]>"u"){var v=["Could not find a path from ",r," to ",o,"."].join("");throw new Error(v)}return i},extract_shortest_path_from_predecessor_list:function(n,r){for(var o=[],i=r;i;)o.push(i),n[i],i=n[i];return o.reverse(),o},find_path:function(n,r,o){var i=t.single_source_shortest_paths(n,r,o);return t.extract_shortest_path_from_predecessor_list(i,o)},PriorityQueue:{make:function(n){var r=t.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}}};e.exports=t})(Rs)),Rs.exports}var gf;function Gy(){return gf||(gf=1,(function(e){const t=Sn(),n=Hy(),r=Uy(),o=qy(),i=Wy(),a=af(),l=En(),c=jy();function s(v){return unescape(encodeURIComponent(v)).length}function d(v,w,E){const T=[];let P;for(;(P=v.exec(E))!==null;)T.push({data:P[0],index:P.index,mode:w,length:P[0].length});return T}function p(v){const w=d(a.NUMERIC,t.NUMERIC,v),E=d(a.ALPHANUMERIC,t.ALPHANUMERIC,v);let T,P;return l.isKanjiModeEnabled()?(T=d(a.BYTE,t.BYTE,v),P=d(a.KANJI,t.KANJI,v)):(T=d(a.BYTE_KANJI,t.BYTE,v),P=[]),w.concat(E,T,P).sort(function(I,A){return I.index-A.index}).map(function(I){return{data:I.data,mode:I.mode,length:I.length}})}function u(v,w){switch(w){case t.NUMERIC:return n.getBitsLength(v);case t.ALPHANUMERIC:return r.getBitsLength(v);case t.KANJI:return i.getBitsLength(v);case t.BYTE:return o.getBitsLength(v)}}function f(v){return v.reduce(function(w,E){const T=w.length-1>=0?w[w.length-1]:null;return T&&T.mode===E.mode?(w[w.length-1].data+=E.data,w):(w.push(E),w)},[])}function g(v){const w=[];for(let E=0;E<v.length;E++){const T=v[E];switch(T.mode){case t.NUMERIC:w.push([T,{data:T.data,mode:t.ALPHANUMERIC,length:T.length},{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.ALPHANUMERIC:w.push([T,{data:T.data,mode:t.BYTE,length:T.length}]);break;case t.KANJI:w.push([T,{data:T.data,mode:t.BYTE,length:s(T.data)}]);break;case t.BYTE:w.push([{data:T.data,mode:t.BYTE,length:s(T.data)}])}}return w}function m(v,w){const E={},T={start:{}};let P=["start"];for(let O=0;O<v.length;O++){const I=v[O],A=[];for(let k=0;k<I.length;k++){const R=I[k],S=""+O+k;A.push(S),E[S]={node:R,lastCount:0},T[S]={};for(let $=0;$<P.length;$++){const N=P[$];E[N]&&E[N].node.mode===R.mode?(T[N][S]=u(E[N].lastCount+R.length,R.mode)-u(E[N].lastCount,R.mode),E[N].lastCount+=R.length):(E[N]&&(E[N].lastCount=R.length),T[N][S]=u(R.length,R.mode)+4+t.getCharCountIndicator(R.mode,w))}}P=A}for(let O=0;O<P.length;O++)T[P[O]].end=0;return{map:T,table:E}}function y(v,w){let E;const T=t.getBestModeForData(v);if(E=t.from(w,T),E!==t.BYTE&&E.bit<T.bit)throw new Error('"'+v+'" cannot be encoded with mode '+t.toString(E)+`.
266
+ Suggested mode is: `+t.toString(T));switch(E===t.KANJI&&!l.isKanjiModeEnabled()&&(E=t.BYTE),E){case t.NUMERIC:return new n(v);case t.ALPHANUMERIC:return new r(v);case t.KANJI:return new i(v);case t.BYTE:return new o(v)}}e.fromArray=function(w){return w.reduce(function(E,T){return typeof T=="string"?E.push(y(T,null)):T.data&&E.push(y(T.data,T.mode)),E},[])},e.fromString=function(w,E){const T=p(w,l.isKanjiModeEnabled()),P=g(T),O=m(P,E),I=c.find_path(O.map,"start","end"),A=[];for(let k=1;k<I.length-1;k++)A.push(O.table[I[k]].node);return e.fromArray(f(A))},e.rawSplit=function(w){return e.fromArray(p(w,l.isKanjiModeEnabled()))}})(As)),As}var mf;function Vy(){if(mf)return gs;mf=1;const e=En(),t=bs(),n=Oy(),r=Iy(),o=Py(),i=Ry(),a=Fy(),l=Jp(),c=Ly(),s=By(),d=zy(),p=Sn(),u=Gy();function f(O,I){const A=O.size,k=i.getPositions(I);for(let R=0;R<k.length;R++){const S=k[R][0],$=k[R][1];for(let N=-1;N<=7;N++)if(!(S+N<=-1||A<=S+N))for(let B=-1;B<=7;B++)$+B<=-1||A<=$+B||(N>=0&&N<=6&&(B===0||B===6)||B>=0&&B<=6&&(N===0||N===6)||N>=2&&N<=4&&B>=2&&B<=4?O.set(S+N,$+B,!0,!0):O.set(S+N,$+B,!1,!0))}}function g(O){const I=O.size;for(let A=8;A<I-8;A++){const k=A%2===0;O.set(A,6,k,!0),O.set(6,A,k,!0)}}function m(O,I){const A=o.getPositions(I);for(let k=0;k<A.length;k++){const R=A[k][0],S=A[k][1];for(let $=-2;$<=2;$++)for(let N=-2;N<=2;N++)$===-2||$===2||N===-2||N===2||$===0&&N===0?O.set(R+$,S+N,!0,!0):O.set(R+$,S+N,!1,!0)}}function y(O,I){const A=O.size,k=s.getEncodedBits(I);let R,S,$;for(let N=0;N<18;N++)R=Math.floor(N/3),S=N%3+A-8-3,$=(k>>N&1)===1,O.set(R,S,$,!0),O.set(S,R,$,!0)}function v(O,I,A){const k=O.size,R=d.getEncodedBits(I,A);let S,$;for(S=0;S<15;S++)$=(R>>S&1)===1,S<6?O.set(S,8,$,!0):S<8?O.set(S+1,8,$,!0):O.set(k-15+S,8,$,!0),S<8?O.set(8,k-S-1,$,!0):S<9?O.set(8,15-S-1+1,$,!0):O.set(8,15-S-1,$,!0);O.set(k-8,8,1,!0)}function w(O,I){const A=O.size;let k=-1,R=A-1,S=7,$=0;for(let N=A-1;N>0;N-=2)for(N===6&&N--;;){for(let B=0;B<2;B++)if(!O.isReserved(R,N-B)){let C=!1;$<I.length&&(C=(I[$]>>>S&1)===1),O.set(R,N-B,C),S--,S===-1&&($++,S=7)}if(R+=k,R<0||A<=R){R-=k,k=-k;break}}}function E(O,I,A){const k=new n;A.forEach(function(B){k.put(B.mode.bit,4),k.put(B.getLength(),p.getCharCountIndicator(B.mode,O)),B.write(k)});const R=e.getSymbolTotalCodewords(O),S=l.getTotalCodewordsCount(O,I),$=(R-S)*8;for(k.getLengthInBits()+4<=$&&k.put(0,4);k.getLengthInBits()%8!==0;)k.putBit(0);const N=($-k.getLengthInBits())/8;for(let B=0;B<N;B++)k.put(B%2?17:236,8);return T(k,O,I)}function T(O,I,A){const k=e.getSymbolTotalCodewords(I),R=l.getTotalCodewordsCount(I,A),S=k-R,$=l.getBlocksCount(I,A),N=k%$,B=$-N,C=Math.floor(k/$),ie=Math.floor(S/$),pe=ie+1,Ge=C-ie,Q=new c(Ge);let Te=0;const he=new Array($),de=new Array($);let ye=0;const ne=new Uint8Array(O.buffer);for(let Re=0;Re<$;Re++){const fe=Re<B?ie:pe;he[Re]=ne.slice(Te,Te+fe),de[Re]=Q.encode(he[Re]),Te+=fe,ye=Math.max(ye,fe)}const Pe=new Uint8Array(k);let it=0,te,Ve;for(te=0;te<ye;te++)for(Ve=0;Ve<$;Ve++)te<he[Ve].length&&(Pe[it++]=he[Ve][te]);for(te=0;te<Ge;te++)for(Ve=0;Ve<$;Ve++)Pe[it++]=de[Ve][te];return Pe}function P(O,I,A,k){let R;if(Array.isArray(O))R=u.fromArray(O);else if(typeof O=="string"){let C=I;if(!C){const ie=u.rawSplit(O);C=s.getBestVersionForData(ie,A)}R=u.fromString(O,C||40)}else throw new Error("Invalid data");const S=s.getBestVersionForData(R,A);if(!S)throw new Error("The amount of data is too big to be stored in a QR Code");if(!I)I=S;else if(I<S)throw new Error(`
267
267
  The chosen QR Code version cannot contain this amount of data.
268
268
  Minimum version required to store current data is: `+S+`.
269
- `);const $=E(P,O,I),N=e.getSymbolSize(P),z=new r(N);return f(z,P),g(z),m(z,P),v(z,O,0),P>=7&&b(z,P),w(z,$),isNaN(C)&&(C=a.getBestMask(z,v.bind(null,z,O))),a.applyMask(C,z),v(z,O,C),{modules:z,version:P,errorCorrectionLevel:O,maskPattern:C,segments:I}}return hs.create=function(P,O){if(typeof P>"u"||P==="")throw new Error("No input text");let C=t.M,I,S;return typeof O<"u"&&(C=t.from(O.errorCorrectionLevel,t.M),I=s.from(O.version),S=a.from(O.maskPattern),O.toSJISFunc&&e.setToSJISFunction(O.toSJISFunc)),L(P,I,C,S)},hs}var Ds={},$s={},mf;function bf(){return mf||(mf=1,(function(e){function t(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("")}}e.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:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},e.getImageWidth=function(r,o){const i=e.getScale(r,o);return Math.floor((r+o.margin*2)*i)},e.qrToImageData=function(r,o,i){const a=o.modules.size,l=o.modules.data,c=e.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 g=(u*s+f)*4,m=i.color.light;if(u>=d&&f>=d&&u<s-d&&f<s-d){const b=Math.floor((u-d)/c),v=Math.floor((f-d)/c);m=p[l[b*a+v]?1:0]}r[g++]=m.r,r[g++]=m.g,r[g++]=m.b,r[g]=m.a}}})($s)),$s}var yf;function Vy(){return yf||(yf=1,(function(e){const t=bf();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")}}e.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=t.getOptions(c);const d=t.getImageWidth(i.modules.size,c),p=s.getContext("2d"),u=p.createImageData(d,d);return t.qrToImageData(u.data,i,c),n(p,s,d),p.putImageData(u,0,0),s},e.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const s=e.render(i,a,c),d=c.type||"image/png",p=c.rendererOpts||{};return s.toDataURL(d,p.quality)}})(Ds)),Ds}var Ns={},vf;function Yy(){if(vf)return Ns;vf=1;const e=bf();function t(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 Ns.render=function(i,a,l){const c=e.getOptions(a),s=i.modules.size,d=i.modules.data,p=s+c.margin*2,u=c.color.light.a?"<path "+t(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",f="<path "+t(c.color.dark,"stroke")+' d="'+r(d,s,c.margin)+'"/>',g='viewBox="0 0 '+p+" "+p+'"',b='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+g+' shape-rendering="crispEdges">'+u+f+`</svg>
270
- `;return typeof l=="function"&&l(null,b),b},Ns}var wf;function Ky(){if(wf)return Kn;wf=1;const e=Ay(),t=Gy(),n=Vy(),r=Yy();function o(i,a,l,c,s){const d=[].slice.call(arguments,1),p=d.length,u=typeof d[p-1]=="function";if(!u&&!e())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,g){try{const m=t.create(l,c);f(i(m,a,c))}catch(m){g(m)}})}try{const f=t.create(l,c);s(null,i(f,a,c))}catch(f){s(f)}}return Kn.create=t.create,Kn.toCanvas=o.bind(null,n.render),Kn.toDataURL=o.bind(null,n.renderToDataURL),Kn.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),Kn}var Xy=Ky();const Zy=Ru(Xy),xf="http://www.w3.org/2000/svg";function Jy(e){const t=e.getAttribute("viewBox");if(!t)return null;const n=t.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))?null:{width:n[2],height:n[3]}}function Qy(e,t){const n=document.createElementNS(xf,"svg"),r=fr(t.barWidth),o=ua(t.barQuietZone),i=l=>{ps(n,e,{format:t.barcodeType||"CODE128",width:r,height:l*r,displayValue:t.showText!==!1,fontSize:(t.fontSize??ho)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:pa*r});const c=Jy(n);return c?{widthUnits:c.width,heightUnits:c.height}:null},a=ha({barHeightMm:t.barHeightMm,boxWidthMm:t.targetWidthMm??0,boxHeightMm:t.targetHeightMm??0,dpi:t.printerDpi,barWidth:t.barWidth,measure:i});return a.size&&(n.setAttribute("width",`${a.size.widthMm}mm`),n.setAttribute("height",`${a.size.heightMm}mm`)),n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}function ev(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):kc}function tv(e,t){const n=(t.qrCodeLevel??"M").toUpperCase(),o=Zy.create(e,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=ev(t.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="${xf}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function Ef(e,t,n={}){if(!e)throw new Error("empty barcode value");return t==="qrcode"?tv(e,n):Qy(e,n)}const Ls={render(e,t,n={}){return Ef(e,t,n)}},Fs=.5,nv=12;function zs(e,t){const n=e.getAttribute(t);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function Sf(e,t){if(e.scrollWidth>e.clientWidth+Fs)return!0;const n=e.scrollHeight;return t!==void 0?n>t+Fs:n>e.clientHeight+Fs}function _f(e){if(e.getAttribute("data-fit")!=="shrink")return;const t=dr(zs(e,"data-fit-min")),n=Math.max(zs(e,"data-fit-base")??t,t),r=zs(e,"data-fit-mm"),o=r!==void 0&&r>0?un(r):void 0,i=s=>{const d=Qg(s);return e.style.fontSize=`${d}pt`,e.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!Sf(e,o)||n<=t)return a;let l=t,c=n;for(let s=0;s<nv;s++){const d=(l+c)/2;i(d),Sf(e,o)?c=d:l=d}return i(l)}function rv(e){const t=[];return e.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=_f(n),o=n.getAttribute("data-fit-key");r===void 0||!o||t.push({key:o,fontSizePt:r})}),t}const ov="2",iv=5e3;async function av(e,t=iv){const n=e.document,r=i=>Promise.race([i,new Promise(a=>setTimeout(a,t))]),o=(async()=>{n.readyState!=="complete"&&await r(new Promise(a=>e.addEventListener("load",()=>a(),{once:!0})));const i=n.fonts;i&&(await r(Promise.all(sv(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 sv(e){const t=[];for(const r of Array.from(e.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&&t.push({family:l,weight:a.getPropertyValue("font-weight")||"400",style:a.getPropertyValue("font-style")||"normal"})}}return t}function lv(e){const t=[];return e.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){const c=r.querySelectorAll(".print-flow-row[data-flow-row-index]");if(c.length>0){const s=[];c.forEach(d=>s.push(d.getBoundingClientRect().height)),t.push({id:o,heightPx:i,rowHeightsPx:s});return}t.push({id:o,heightPx:i});return}const l=[];a.querySelectorAll("tbody > tr[data-row-index]").forEach(c=>{l.push(c.getBoundingClientRect().height)}),t.push({id:o,heightPx:i,rowHeightsPx:l})}),t}function cv(e){const t=e.querySelector(".print-page"),n=e.querySelector(".content-area");if(!t||!n)return 0;const r=t.getBoundingClientRect().top;let o=0;n.querySelectorAll("*").forEach(a=>{if(a.classList.contains("print-element"))return;const l=a.getBoundingClientRect();l.height>0&&(o=Math.max(o,l.bottom-r))}),n.querySelectorAll(".print-element").forEach(a=>{const l=a.getBoundingClientRect(),c=Number.parseFloat(e.defaultView?.getComputedStyle(a).marginBottom??"0")||0;l.height>0&&(o=Math.max(o,l.bottom-r+c))});const i=n.getBoundingClientRect();return i.height>0&&(o=Math.max(o,i.bottom-r)),o}function dv(e,t=0){const r=e.querySelectorAll(".print-page")[t];if(!r)return[];const o=r.getBoundingClientRect(),i=e.defaultView?.getComputedStyle(r),a=Number.parseFloat(i?.paddingLeft??"0")||0,l=Number.parseFloat(i?.paddingTop??"0")||0,c=[];return r.querySelectorAll("[data-element-id]").forEach(s=>{if(s.querySelector("[data-element-id]"))return;const d=s.getAttribute("data-element-id");if(!d)return;const p=s.getBoundingClientRect(),u=uv(s,o,a,l);c.push({id:d,left:p.left-u.left,top:p.top-u.top,width:p.width,height:p.height,zone:u.zone})}),c}function uv(e,t,n,r){const o=(c,s)=>{const d=c.getBoundingClientRect();return{left:d.left,top:d.top,zone:s}},i=e.closest(".page-header");if(i)return o(i,"header");const a=e.closest(".page-footer");if(a)return o(a,"footer");const l=e.closest(".content-area");return l?o(l,"content"):{left:t.left+n,top:t.top+r,zone:"content"}}function pv(e){const t={};for(const n of e)try{t[n.key]=Ef(n.value,n.cellType,n.opts)}catch{}return t}const fv={version:ov,waitReady:av,readMeasurements:lv,readContentBottom:cv,readElementRects:dv,renderCodes:pv,applyTextFit:rv};function hv(){return{async createDriver(){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;left:-10000px;top:0;border:0;visibility:hidden;pointer-events:none;",document.body.appendChild(e);let t=e.contentDocument??document;return{requiresExecutor:!1,async open(n){e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,t=e.contentDocument??document},async setContent(n){t=e.contentDocument??document,t.open(),t.write(n),t.close()},async injectExecutor(n){},async evaluate(n,r){const o=fv[n];if(typeof o!="function"){const s=(e.contentWindow?.__wormDom??globalThis.__wormDom)?.[n];if(typeof s!="function")throw new Error(`执行器方法 ${n} 未注入`);return s(...r??[])}const i=r??[],a=t1[n],l=o;return a==="window"?l(e.contentWindow,...i):a==="document"?l(t,...i):l(...i)},async close(){e.remove()}}}}}function gv(){return o1(hv())}async function mv(e,t,n,r,o){const i=await g1({templateJson:e,printData:t,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r,renderers:o?.renderers},gv());return{html:i.html,pageCount:i.pageCount,pageLayouts:i.pageLayouts,paperMm:i.paperMm,pagePaperMm:i.pagePaperMm,continuous:i.continuous,copies:i.copies,copyPaperMm:i.copyPaperMm}}var Mf=Symbol.for("worm-print-platform.element-ui-registry.v1"),Tf=globalThis;function Bs(){const e=Tf[Mf];if(e)return e;const t={entries:new Map,listeners:new Set,nextSeq:0};return Tf[Mf]=t,t}function bv(e){if(e)return Bs().entries.get(e)?.ui}function yv(){const e=[...Bs().entries.entries()];return e.sort((t,n)=>t[1].seq-n[1].seq),e.map(([t,n])=>({type:t,ui:n.ui}))}function vv(e){const t=Bs();return t.listeners.add(e),()=>{t.listeners.delete(e)}}function h(e,t={},n=[]){return{tag:e,props:t,children:n}}const Hs="http://www.w3.org/2000/svg",wv=new Set(["draggable","contenteditable","spellcheck"]),xv=new Set(["indeterminate"]);function Ev(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="g"}function Sv(e){return e instanceof Element&&e.namespaceURI===Hs}function Ze(e,t){if(typeof e=="string"){const a=document.createTextNode(e);return t.appendChild(a),a}if(e instanceof Node)return t.appendChild(e),e;const{tag:n,props:r,children:o}=e,i=Ev(n)||Sv(t)?document.createElementNS(Hs,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 xv.has(a)?i[a]=!0:typeof l=="boolean"?l&&i.setAttribute(a,wv.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)Ze(a,i);return t.appendChild(i),i}function kf(e){for(;e.firstChild;)e.removeChild(e.firstChild)}const _v=Hs;function qr(){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 Us="开启拼版后只能有一个设计页面";function qs(e){const t=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&sr(i),{id:o.id||zn(),zone:r,options:i,printElementType:{...o.printElementType}}});return{...e,margins:{...e.margins},header:{height:e.header?.height??10,elements:[]},footer:{height:e.footer?.height??10,elements:[]},guides:[...e.guides??[]],elements:[...t(e.elements??[],"content"),...t(e.header?.elements??[],"header"),...t(e.footer?.elements??[],"footer")]}}function Cf(e){const t=e.elements,n=r=>t.filter(o=>(o.zone||"content")===r).map(o=>({id:o.id,type:o.printElementType.type,options:{...o.options},printElementType:{...o.printElementType}}));return{unit:"mm",...e,header:{...e.header,elements:n("header")},footer:{...e.footer,elements:n("footer")},elements:n("content"),guides:[...e.guides??[]]}}function Af(e){const t=(r,o)=>{const i=qs(Wm(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!e)return[t(qr(),0)];const n=Array.isArray(e.pages)?e.pages:[e];return n.length?n.map(t):[t(qr(),0)]}const Xn=e=>JSON.parse(JSON.stringify(e));class Of{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=B1();group=H1();constructor(t={}){if(this.pages=Af(t.initialTemplate),this.fields=t.initialFields??[],t.initialElements?.length){const n=this.pages[0];n.elements=[...n.elements,...t.initialElements]}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t=!0){t&&(this.dirty=!0);for(const n of[...this.listeners])n()}get templateData(){return this.pages[this.activePageIndex]}set templateData(t){this.pages[this.activePageIndex]=t}get elements(){return this.templateData.elements.map(t=>this.live.get(t.id)??t)}get tilingEnabled(){return this.pages.some(t=>t.tiling?.enabled===!0)}switchPage(t){t<0||t>=this.pages.length||(this.activePageIndex=t,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(Us);return}this.recordHistory();const t=this.pages[this.activePageIndex]??qr();this.pages.push(qs({...qr(),paperSize:t.paperSize,orientation:t.orientation,outputRotation:t.outputRotation,customWidth:t.customWidth,customHeight:t.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const t=new Set(this.pages.map(r=>r.name));let n=this.pages.length+1;for(;t.has(`页面 ${n}`);)n++;return`页面 ${n}`}duplicatePage(t){if(this.tilingEnabled){window.alert(Us);return}this.recordHistory();const n=Xn(this.pages[t]);n.name=`${n.name??`页面 ${t+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:zn()})),this.pages.splice(t+1,0,n),this.switchPage(t+1),this.emit()}deletePage(t){this.pages.length<=1||(this.recordHistory(),this.pages.splice(t,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(t,n){this.recordHistory(),this.pages[t].name=n,this.emit()}movePage(t,n){if(n<0||n>=this.pages.length||t===n)return;this.recordHistory();const[r]=this.pages.splice(t,1);this.pages.splice(n,0,r),this.activePageIndex=n,this.emit()}onSelectionChanged;setSelection(t){this.selectedIds=t,this.onSelectionChanged?.(),this.emit(!1)}select(t){this.setSelection(new Set(t))}selectOne(t,n=!1){if(n){const r=new Set(this.selectedIds);r.has(t)?r.delete(t):r.add(t),this.setSelection(r)}else this.setSelection(new Set([t]))}clearSelection(){this.setSelection(new Set)}selectElement(t,n=!1){if(n){this.selectOne(t,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,t)))}selectAll(){this.setSelection(new Set(this.elements.map(t=>t.id)))}get selectedElements(){return this.elements.filter(t=>this.selectedIds.has(t.id))}get selectedElement(){const t=this.selectedIds.values().next().value;return t?this.elements.find(n=>n.id===t)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(t){this.tableSelection=t,this.emit(!1)}setPreview(t){this.previewIds=t,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=[...r,{id:zn(),type:t,position:Math.round(n*10)/10}],this.emit()}moveGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=r.map(o=>o.id===t?{...o,position:Math.round(n*10)/10}:o),this.emit(!1)}removeGuide(t){this.templateData.guides=(this.templateData.guides??[]).filter(n=>n.id!==t),this.emit()}addElement(t,n={},r){const o=Sa(t,n);return r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}addFieldElement(t,n={},r,o=!1){const i=o?F1(t):L1(t);return Object.assign(i.options,n),r&&!this.placeAtDropPoint(i,r)||(this.recordHistory(),this.templateData.elements.push(i),this.select(new Set([i.id])),this.emit()),i}placeAtDropPoint(t,n){const r=this.templateData,o=sd(r,n.x,n.y);if(o!=="content"&&!ad(t.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Oa(r)[o];return t.zone=o,t.options.left=n.x-i.left,t.options.top=n.y-i.top,o!=="content"&&Ia(t,i),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(t=>!this.selectedIds.has(t.id)),this.selectedIds=new Set,this.emit())}livePatch(t,n){const r=this.templateData.elements.find(i=>i.id===t);if(!r)return;const o=this.live.get(t)??r;this.live.set(t,{...o,options:{...o.options,...n}})}commitLive(){if(!this.live.size)return;this.recordHistory();const t=this.templateData.elements;for(const[n,r]of this.live){const o=t.find(i=>i.id===n);o&&Object.assign(o.options,r.options)}this.live.clear(),this.emit()}dragIds(t){const n=this.templateData.elements.find(r=>r.id===t);return!n||n.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,t))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(t=>[t.id,this.geoSig(t)]))}dragStop(){const t=this.dragBefore;if(!t)return;this.dragBefore=null;let n=!1;for(const r of this.elements){const o=t.get(r.id);!o||o===this.geoSig(r)||u0(r,this.templateData).rejected&&(n=!0)}n&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(t){return`${t.zone||"content"}:${t.options.left},${t.options.top},${t.options.width},${t.options.height}`}updateElement(t,n,r=!0){r&&this.recordHistory();const o=this.templateData.elements.find(i=>i.id===t);o&&(Object.assign(o.options,n),o.printElementType.type==="table"&&sr(o.options),this.emit())}updateTemplateData(t){this.recordHistory(),Object.assign(this.templateData,t);for(const n of["paperSize","customWidth","customHeight"])if(n in t)for(const r of this.pages)Object.assign(r,{[n]:t[n]});this.emit()}moveLayer(t){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(t==="top")this.templateData.elements=[...o,...r];else if(t==="bottom")this.templateData.elements=[...r,...o];else{const i=n.findIndex(c=>this.selectedIds.has(c.id)),a=t==="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(t){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(n=>this.selectedIds.has(n.id)),t),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=Xn(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(t=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?Pu():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=Xn(i);a.id=zn(),a.options.left+=t,a.options.top+=t,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 t=this.templateData.elements;this.selectOne(t[t.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(t,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+=t,o.options.top+=n;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(t){this.recordHistory(),this.templateData.elements.push(t),this.selectedIds=new Set([t.id]),this.emit()}recordHistory(){this.undoStack.push({pages:Xn(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 t=this.undoStack.pop();t&&(this.redoStack.push({pages:Xn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}redo(){const t=this.redoStack.pop();t&&(this.undoStack.push({pages:Xn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(t,n=So){this.scale=Math.max(n,Math.round(t)),this.emit(!1)}getTemplateJson(){const t=this.pages.map(Cf),n=t.length===1?t[0]:{version:1,pages:t};return JSON.stringify(n)}loadTemplate(t){this.pages=Af(t),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return Jt(this.templateData)}}const _n=Symbol("mixed"),Ws=new Set(["text","longText"]),Mv=["top","right","bottom","left"],Tv={on:!0,off:!1,mixed:_n};function If(e){const t=Xc(e),n={};for(const r of Mv)n[r]=Tv[t[r]];return n}const kv=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class Cv{constructor(t){this.store=t}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(t=>this.store.selectedIds.has(t.id)&&!t.options.locked)}get tableElement(){const t=this.store.tableSelection;return t?this.store.elements.find(n=>n.id===t.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 t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return[];const r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=n[o]?.cells[i];a&&!a.merged&&r.push(a)}return r}get textTargets(){return this.selectedElements.filter(t=>Ws.has(t.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(t=>t.options)}pick(t){if(!t.length)return;const n=t[0];return t.every(r=>r===n)?n:_n}hasToken(t,n){return(t??"").split(/\s+/).includes(n)}get values(){const t=this.styleTargets;if(!t.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=t.map(o=>o.fontWeight==="bold"||o.fontWeight==="bolder"),r=t.map(o=>o.textDecoration);return{fontFamily:this.pick(t.map(o=>o.fontFamily)),fontSize:this.pick(t.map(o=>o.fontSize)),color:this.pick(t.map(o=>o.color)),backgroundColor:this.pick(t.map(o=>o.backgroundColor)),textAlign:this.pick(t.map(o=>this.context==="cells"?o.align:o.textAlign)),verticalAlign:this.pick(t.map(o=>this.context==="cells"?o.valign:o.verticalAlign)),bold:n.every(Boolean)?!0:n.some(Boolean)?_n:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?_n:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?_n:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(t){const n=this.targetCells;n.length&&(n.forEach(t),this.commit())}applyStyle(t){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in t&&(l.fontFamily=t.fontFamily),"fontSize"in t&&(l.fontSize=t.fontSize),"color"in t&&(l.color=t.color),"backgroundColor"in t&&(l.backgroundColor=t.backgroundColor),"textAlign"in t&&(l.align=t.textAlign),"verticalAlign"in t&&(l.valign=t.verticalAlign)});return}const n=this.textTargets,r=this.selectedElements,i=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in t),a="backgroundColor"in t;!(n.length&&i)&&!(r.length&&a)||(n.forEach(l=>{const c=l.options;"fontFamily"in t&&(c.fontFamily=t.fontFamily),"fontSize"in t&&(c.fontSize=t.fontSize),"color"in t&&(c.color=t.color),"textAlign"in t&&(c.textAlign=t.textAlign),"verticalAlign"in t&&(c.verticalAlign=t.verticalAlign)}),a&&r.forEach(l=>{l.options.backgroundColor=t.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 t=this.values.bold!==!0,n=this.textTargets;n.length&&(n.forEach(r=>{r.options.fontWeight=t?"bold":"normal"}),this.commit())}toggleDecoration(t){if(this.context==="cells")return;const n=this.textTargets;if(!n.length)return;const r=this.values[t==="underline"?"underline":"strike"]!==!0;n.forEach(o=>{const i=(o.options.textDecoration??"").split(/\s+/).filter(Boolean),a=i.indexOf(t);r&&a<0&&i.push(t),!r&&a>=0&&i.splice(a,1),o.options.textDecoration=i.length?i.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return;const r=`cells:${t.elementId}:${t.r1}:${t.c1}:${t.r2}:${t.c2}`;if(r===this.borderDraftKey)return;if(this.borderDraftKey=r,ra(n,t).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const o=lc(n,t);if(o.style===void 0&&o.width===void 0&&o.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:o.style==="mixed",width:o.width==="mixed",color:o.color==="mixed"},this.borderMixed.style?this.borderStyle=null:o.style===void 0?this.borderStyle="solid":o.style==="none"?this.borderStyle=null:this.borderStyle=o.style,this.borderWidth=this.borderMixed.width?void 0:typeof o.width=="number"?o.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof o.color=="string"?o.color:"#333333"}borderSpec(){const t=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:t,color:this.borderColor??"#333333"}}setBorderWidth(t){this.borderWidth=t,this.borderMixed.width=!1}setBorderColor(t){this.borderColor=t,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(t){const n=this.borderStyle===t?null:t;this.borderMixed.style=!1,this.borderStyle=n,n===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(t,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{Zc(o.options,t,n)}),this.commit())}applyCellBorderPreset(t,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||(ac(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},t,n),this.commit())}applyCellBorderEdges(t,n,r){this.writeCells(o=>{for(const i of t)sc(o,i,r?n:null)})}get cellEdges(){if(this.context!=="cells")return null;const t=this.targetCells;return t.length?If(t.map(n=>n.borders)):null}toggleCellEdge(t,n){const r=this.cellEdges?.[t]!==!0;this.applyCellBorderEdges([t],n,r)}get elementEdges(){if(this.context!=="elements")return null;const t=this.selectedElements;return t.length?If(t.map(n=>Vm(n.options))):null}toggleElementEdge(t,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[t]!==!0;r.forEach(i=>Ca(i.options,t,o,n)),this.commit()}applyBorderPreset(t){const n=this.borderStyle===null;if(this.context==="cells"){const r=n&&!this.borderMixed.style;this.applyCellBorderPreset(r?"none":t,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(n||t==="none"?"none":"all",this.borderSpec())}applyEdge(t){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([t],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(t);return}this.context==="cells"?(this.toggleCellEdge(t,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(t,this.borderSpec())}clearElementEdge(t){const n=this.selectedElements;n.length&&(n.forEach(r=>Ca(r.options,t,!1)),this.commit())}edgeOn(t){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[t]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(t){if(!t)return;const n={};for(const r of hr){const o=t[r];o&&(n[r]={...o})}return n}pickPainterSource(t=!1){const n=this.selectedElements[0];if(!n)return!1;const r=n.options,o=n.printElementType.type;return this.painterSnapshot={text:Ws.has(o)?Object.fromEntries(kv.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:mo(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=t,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(t){const n=this.painterSnapshot;if(!n||t.options.locked||t.id===this.painterSource)return!1;const r=t.options,o=t.printElementType.type;return n.text&&Ws.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&mo(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 t=this.selectedElements;if(!t.length){this.cancelPainter();return}let n=!1;t.forEach(r=>{n=this.applyPainter(r)||n}),n&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(t){if(t.key!=="Escape"||!this.painterActive)return;const n=t.target?.tagName;n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||this.cancelPainter()}}const Av="自定义属性";function Pf(){const e=[];for(const{plugin:t,kind:n}of gc()){const r=bv(n.type);if(!r)continue;const i=(n.designer??t.designer)?.materialCard;e.push({type:n.type,label:n.label,icon:n.icon??i?.icon??"Shapes",group:i?.group??r.group,ui:r})}return e}function js(e){if(e)return Pf().find(t=>t.type===e)}function Gs(e){if(!e)return;const t=js(e.printElementType.type);if(!t||!t.ui.renderProperty)return;const n=t.ui;if(n.hasProperties)try{if(!n.hasProperties(e))return}catch{return}const r=Av;return{ui:n,label:r,icon:t.icon,searchKeywords:n.searchKeywords?[...n.searchKeywords]:[r,t.label,t.type]}}const Ii=Object.freeze([{type:"text",label:"文本",icon:"Type",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"barcode",label:"条形码",icon:"Barcode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"qrcode",label:"二维码",icon:"QrCode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"image",label:"图片",icon:"Image",material:!0,propertyGroup:"general",dblEditableField:"src",origin:"builtin"},{type:"table",label:"表格",icon:"Table",material:!0,propertyGroup:"table",origin:"builtin"},{type:"longText",label:"长文",icon:"TextAlignStart",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"flowList",label:"流式列表",icon:"List",material:!0,propertyGroup:"general",dblEditableField:"formatter",origin:"builtin"},{type:"hline",label:"横线",icon:"Minus",material:!0,propertyGroup:"general",origin:"builtin"},{type:"vline",label:"竖线",icon:"SeparatorVertical",material:!0,propertyGroup:"general",origin:"builtin"},{type:"rect",label:"矩形",icon:"Square",material:!0,propertyGroup:"general",origin:"builtin"},{type:"oval",label:"椭圆",icon:"Circle",material:!0,propertyGroup:"general",origin:"builtin"},{type:"html",label:"HTML",icon:"Code",material:!1,propertyGroup:"general",origin:"builtin"},{type:"pageNumber",label:"页码",icon:"Shapes",material:!1,propertyGroup:"general",origin:"builtin"}]),Rf=Symbol.for("worm-print-platform.element-definitions.v1"),Df=globalThis;function Et(){const e=Df[Rf];if(e)return e;const t={overrides:new Map,builtinRenderers:new Map,rendererOverrides:new Map,listeners:new Set,nextSeq:0,seq:new Map};return Df[Rf]=t,t}function Wr(){for(const e of[...Et().listeners])try{e()}catch{}}function $f(e){const t=Et();return t.listeners.add(e),()=>{t.listeners.delete(e)}}function Ov(){return new Map(Ii.map(e=>[e.type,e]))}function Iv(e){if(!e?.type||typeof e.type!="string")throw new Error("registerElementDefinition: type 必须是非空字符串");if(!e.label||typeof e.label!="string")throw new Error("registerElementDefinition: label 必须是非空字符串");const t=Et(),n={...e,origin:e.origin??"custom"};return t.overrides.set(n.type,n),t.seq.set(n.type,t.nextSeq++),Wr(),()=>{const r=Et();r.overrides.get(n.type)===n&&(r.overrides.delete(n.type),Wr())}}function Pv(e,t){if(!e||typeof t!="function")throw new Error("registerElementRenderer: 需要 type 与渲染函数");return Et().rendererOverrides.set(e,t),Wr(),()=>{const r=Et();r.rendererOverrides.get(e)===t&&(r.rendererOverrides.delete(e),Wr())}}function Nf(e){const t=Et();for(const[n,r]of Object.entries(e))t.builtinRenderers.set(n,r);return()=>{const n=Et();for(const[r,o]of Object.entries(e))n.builtinRenderers.get(r)===o&&n.builtinRenderers.delete(r)}}function Rv(e){const t=js(e);if(t)return{type:t.type,label:t.label,icon:t.icon,group:t.group,material:!0,propertyGroup:"general",origin:"plugin"}}function tn(e){if(!e)return;const t=Et(),n=t.overrides.get(e)??Ov().get(e)??Rv(e);if(!n)return;const r=t.rendererOverrides.get(e)??t.builtinRenderers.get(e);return r?{...n,renderContent:r}:n}function Lf(){const e=Et(),t=[],n=new Set;for(const o of Ii)t.push(tn(o.type)??o),n.add(o.type);const r=[...e.overrides.entries()].filter(([o])=>!n.has(o)).sort((o,i)=>(e.seq.get(o[0])??0)-(e.seq.get(i[0])??0));for(const[o]of r){const i=tn(o);i&&t.push(i),n.add(o)}for(const o of Pf()){if(n.has(o.type))continue;const i=tn(o.type);i&&t.push(i),n.add(o.type)}return t}function Ff(){return Lf().filter(e=>e.material)}function zf(e){return tn(e)?.propertyGroup??"general"}function Bf(e){return tn(e)?.dblEditableField}function Hf(e){return tn(e)?.icon??"Shapes"}function Dv(){const e=Et();e.overrides.clear(),e.rendererOverrides.clear(),e.seq.clear(),e.nextSeq=0,Wr()}const Vs="1.2.0",Uf="print-designer",Ys=["template","fields","name","fonts","design-data","theme","theme-config"],qf=["is-edit","show-help","show-preview","show-save"],$v=Object.freeze({bubbles:!0,composed:!0}),Ks=["container","toolbar","format-bar","left-panel","canvas-area","property-panel","status-bar","page-tabs"],Wf=["--pd-bg","--pd-surface","--pd-field-bg","--pd-sidebar","--pd-sidebar-hover","--pd-canvas-bg","--pd-paper","--pd-accent","--pd-accent-2","--pd-accent-soft","--pd-accent-secondary","--pd-danger-soft","--pd-ink-green","--pd-text","--pd-text-muted","--pd-text-faint","--pd-border","--pd-border-soft","--pd-input-bg","--pd-hover-tint","--pd-danger","--pd-danger-bg","--pd-danger-border","--pd-menu-text","--pd-menu-hover","--pd-menu-border","--pd-menu-divider","--pd-menu-muted","--pd-menu-disabled","--pd-scrollbar","--pd-scrollbar-thumb","--pd-scrollbar-thumb-hover","--pd-help-field-bg","--pd-help-field-line","--pd-help-field-ink","--pd-help-function-bg","--pd-help-function-line","--pd-help-function-ink","--pd-help-variable-bg","--pd-help-variable-line","--pd-help-variable-ink","--pd-help-conditional-bg","--pd-help-conditional-line","--pd-help-conditional-ink","--pd-handle","--pd-ruler","--pd-ruler-bg","--pd-ruler-cursor","--pd-radius","--pd-shadow-sm","--pd-shadow-md","--pd-shadow-paper","--pd-success","--pd-text-regular","--pd-fill-light"],jf=["getTemplateJson","loadTemplate","save","validateTemplate","getGeometryWarnings"],Gf=["template","fields","fonts","designData","isEdit","showHelp","showPreview","showSave","theme","themeConfig","uploadImage","uploadDesignBackground"],St=Object.freeze({save:"save",preview:"preview",help:"help",dblclickElement:"dblclick-element",dblclickCell:"dblclick-cell"}),Vf=[St.save,St.preview,St.help,St.dblclickElement,St.dblclickCell];function Xs(){return{version:Vs,tag:Uf,attributes:Ys,booleanAttributes:qf,events:Vf,parts:Ks,themeTokens:Wf,methods:jf,properties:Gf}}const Nv={"--pd-bg":"#181a20","--pd-surface":"#1f2229","--pd-field-bg":"#252830","--pd-sidebar":"#1f2229","--pd-sidebar-hover":"#2b2f39","--pd-accent":"#4C8DFF","--pd-accent-2":"#6C9DFF","--pd-accent-soft":"rgba(76, 141, 255, .16)","--pd-accent-secondary":"#ff7a7a","--pd-danger-soft":"rgba(255, 122, 122, .14)","--pd-ink-green":"#6cce5a","--pd-text":"#e6e8ee","--pd-text-muted":"#9aa0ad","--pd-text-faint":"#6f7683","--pd-text-regular":"#c9cdd8","--pd-border":"#3a3f4b","--pd-border-soft":"#2d323c","--pd-input-bg":"#262a33","--pd-hover-tint":"rgba(76, 141, 255, .12)","--pd-fill-light":"#2b2f39","--pd-danger":"#ff6b6b","--pd-danger-bg":"#3a2226","--pd-danger-border":"#6b3535","--pd-success":"#4ade80","--pd-menu-text":"#d6d9e0","--pd-menu-hover":"#2b2f39","--pd-menu-border":"#3a3f4b","--pd-menu-divider":"#2d323c","--pd-menu-muted":"#8b91a0","--pd-menu-disabled":"#555b68","--pd-scrollbar":"rgba(255, 255, 255, .18)","--pd-scrollbar-thumb":"rgba(255, 255, 255, .16)","--pd-scrollbar-thumb-hover":"rgba(255, 255, 255, .3)","--pd-help-field-bg":"#16283a","--pd-help-field-line":"#2c5870","--pd-help-field-ink":"#7cc4f5","--pd-help-function-bg":"#162e22","--pd-help-function-line":"#2c5b3c","--pd-help-function-ink":"#79d69a","--pd-help-variable-bg":"#302c16","--pd-help-variable-line":"#6b5d24","--pd-help-variable-ink":"#d6b25e","--pd-help-conditional-bg":"#301a28","--pd-help-conditional-line":"#6b3454","--pd-help-conditional-ink":"#e58ab5","--pd-shadow-sm":"0 1px 2px rgba(0, 0, 0, .3)","--pd-shadow-md":"0 2px 8px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .5)"};function Yf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Lv(e){if(Array.isArray(e))return e}function Fv(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);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 zv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
271
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bv(e,t){return Lv(e)||Fv(e,t)||Hv(e,t)||zv()}function Hv(e,t){if(e){if(typeof e=="string")return Yf(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Yf(e,t):void 0}}const Kf=Object.entries,Uv=Object.keys,Xf=Object.setPrototypeOf,qv=Object.isFrozen,Zf=Object.getPrototypeOf,Jf=Object.getOwnPropertyDescriptor;let ze=Object.freeze,Oe=Object.seal,nn=Object.create,Qf=typeof Reflect<"u"&&Reflect,Pi=Qf.apply,Zs=Qf.construct;ze||(ze=function(t){return t}),Oe||(Oe=function(t){return t}),Pi||(Pi=function(t,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 t.apply(n,o)}),Zs||(Zs=function(t){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 t(...r)});const Ht=we(Array.prototype.forEach),Wv=we(Array.prototype.lastIndexOf),eh=we(Array.prototype.pop),jr=we(Array.prototype.push),jv=we(Array.prototype.slice),Gv=we(Array.prototype.splice),Zn=Array.isArray,Js=rh(Set),Qs=we(Set.prototype.add),Gr=we(Set.prototype.has),Mn=we(String.prototype.toLowerCase),el=we(String.prototype.toString),Vv=we(String.prototype.match),Ri=we(String.prototype.replace),tl=we(String.prototype.indexOf),Yv=we(String.prototype.trim),Kv=we(Number.prototype.toString),Xv=we(Boolean.prototype.toString),th=typeof BigInt>"u"?null:we(BigInt.prototype.toString),nh=typeof Symbol>"u"?null:we(Symbol.prototype.toString),je=we(Object.prototype.hasOwnProperty),Vr=we(Object.prototype.toString),Zv=RegExp.prototype.test,Be=function(t,n){return t instanceof RegExp&&(t.lastIndex=0),Pi(Zv,t,[n])},Ut=rh(TypeError);function we(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Pi(e,t,r)}}function rh(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Zs(e,n)}}function ce(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mn;if(Xf&&Xf(e,null),!Zn(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(qv(t)||(t[r]=i),o=i)}e[o]=!0}return e}function Jv(e){for(let t=0;t<e.length;t++)je(e,t)||(e[t]=null);return e}function Di(e){const t=nn(null);for(const r of Kf(e)){var n=Bv(r,2);const o=n[0],i=n[1];je(e,o)&&(Zn(i)?t[o]=Jv(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=Di(i):t[o]=i)}return t}function Yr(e){const t=nn(null),n=Uv(e);let r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function Qv(e){switch(typeof e){case"string":return e;case"number":return Kv(e);case"boolean":return Xv(e);case"bigint":return th?th(e):"0";case"symbol":return nh?nh(e):"Symbol()";case"undefined":return Vr(e);case"function":case"object":{if(e===null)return Vr(e);const t=e,n=mt(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Vr(r)}return Vr(e)}default:return Vr(e)}}function mt(e,t){for(;e!==null;){const r=Jf(e,t);if(r){if(r.get)return we(r.get);if(typeof r.value=="function")return we(r.value)}e=Zf(e)}function n(){return null}return n}function ew(e,t){for(;e!==null;){const n=Jf(e,t);if(n)return n.get?we(n.get):null;e=Zf(e)}return null}function tw(e){if(!e)return!1;try{return Be(e,""),!0}catch{return!1}}const oh=ze(["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"]),nl=ze(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),rl=ze(["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"]),nw=ze(["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"]),ol=ze(["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"]),rw=ze(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ih=ze(["#text"]),ah=ze(["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"]),il=ze(["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"]),sh=ze(["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"]),$i=ze(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ow=Oe(/{{[\w\W]*|^[\w\W]*}}/g),iw=Oe(/<%[\w\W]*|^[\w\W]*%>/g),aw=Oe(/\${[\w\W]*/g),sw=Oe(/{{|}}|\${|<%|%>|&lt;%|%&gt;/),lw=Oe(/^data-[\-\w.\u00B7-\uFFFF]+$/),cw=Oe(/^aria-[\-\w]+$/),lh=Oe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dw=Oe(/^(?:\w+script|data):/i),uw=Oe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pw=Oe(/^html$/i),fw=Oe(/^[a-z][.\w]*(-[.\w]+)+$/i),al=Oe(/<[/\w!]/g),ch=Oe(/<[/\w]/g),hw=Oe(/<\/no(script|embed|frames)/i),dh=Oe(/\/>/i),gw=Oe(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),mw=Oe(/^[\r\n\t ]+/),Me={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},bw=ze(ce({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),yw=function(){return typeof window>"u"?null:window},vw=function(t,n){if(typeof t!="object"||typeof t.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 t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},uh=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rn=function(t,n,r,o){return je(t,n)&&Zn(t[n])?ce(o.base?Yr(o.base):{},t[n],o.transform):r},sl=function(t,n,r){const o=je(t,n)?t[n]:void 0;return o&&typeof o=="object"?Di(o):r};function ph(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yw();const t=D=>ph(D);if(t.version="3.4.18",t.removed=[],!e||!e.document||e.document.nodeType!==Me.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript,i=e.HTMLTemplateElement,a=e.Node,l=e.Element,c=e.NodeFilter,s=e.DOMParser,d=e.trustedTypes,p=l.prototype,u=mt(p,"cloneNode"),f=mt(p,"remove"),g=mt(p,"removeAttributeNode"),m=mt(p,"nextSibling"),b=mt(p,"childNodes"),v=mt(p,"parentNode"),w=mt(p,"shadowRoot"),E=mt(p,"attributes"),k=a&&a.prototype?mt(a.prototype,"nodeType"):null,L=a&&a.prototype?mt(a.prototype,"nodeName"):null,R=a&&a.prototype?mt(a.prototype,"ownerDocument"):null,P=function(y){return k?k(y):y.nodeType},O=function(y){return L?L(y):y.nodeName},C=ew(p,"namespaceURI"),I=function(y){return C?C(y):y.namespaceURI};if(typeof i=="function"){const D=n.createElement("template");D.content&&D.content.ownerDocument&&(n=D.content.ownerDocument)}let S,$="",N,z=!1,T=0;const ie=function(){if(T>0)throw Ut('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.')},pe=function(y){ie(),T++;try{return S.createHTML(y)}finally{T--}},Ge=function(y){return S&&xe?pe(y):y},Q=function(y){ie(),T++;try{return S.createScriptURL(y)}finally{T--}},Te=function(){return z||(N=vw(d,o),z=!0),N},he=n,de=he.implementation,ye=he.createNodeIterator,ne=he.createDocumentFragment,De=he.getElementsByTagName,it=r.importNode;let te=uh();t.isSupported=typeof Kf=="function"&&typeof v=="function"&&de&&de.createHTMLDocument!==void 0;const Ve=ow,$e=iw,fe=aw,me=lw,tr=cw,to=dw,no=uw,ro=fw;let nr=lh,ge=null;const Mt=ce({},[...oh,...nl,...rl,...ol,...ih]);let M=null;const H=ce({},[...ah,...il,...sh,...$i]);let B=null,q=null,U=null;const V=Object.seal(nn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ee=!0,_=!0,G=!1,K=!0,Z=!1,oe=!0,be=!1,ke=!1,Ue=null,Je=null,Ne=!1,at=!1,ve=!1,xe=!1,Tt=!0,Pn=!1;const st="user-content-";let Ee=!0,Ft=!1,bt=null,Ye=!1,yt=null;const Vt=ce({},["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 sn=null;const Pe=ce({},["audio","video","img","source","image","track"]);let Le=null;const Rn=ce({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Dn="http://www.w3.org/1998/Math/MathML",ae="http://www.w3.org/2000/svg",ue="http://www.w3.org/1999/xhtml";let lt=ue,ct=!1,oo=null;const Fl=ce({},[Dn,ae,ue],el),zl=ze(ce({},["mi","mo","mn","ms","mtext"]));let Bl=null;const xE=ze(ce({},["annotation-xml"]));let Hl=null;const EE=ze(nn(null)),SE=ce({},["title","style","font","a","script"]);let io=null;const _E=["application/xhtml+xml","text/html"],ME="text/html";let Ce=null,Xi=null;const TE=n.createElement("form"),gg=function(y){return y instanceof RegExp||y instanceof Function},Ul=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(!y||typeof y!="object")&&(y={}),y=Di(y),io=_E.indexOf(y.PARSER_MEDIA_TYPE)===-1?ME:y.PARSER_MEDIA_TYPE,Ce=io==="application/xhtml+xml"?el:Mn,ge=rn(y,"ALLOWED_TAGS",Mt,{transform:Ce}),M=rn(y,"ALLOWED_ATTR",H,{transform:Ce}),oo=rn(y,"ALLOWED_NAMESPACES",Fl,{transform:el}),Le=rn(y,"ADD_URI_SAFE_ATTR",Rn,{transform:Ce,base:Rn}),sn=rn(y,"ADD_DATA_URI_TAGS",Pe,{transform:Ce,base:Pe}),yt=rn(y,"FORBID_CONTENTS",Vt,{transform:Ce}),q=rn(y,"FORBID_TAGS",nn(null),{transform:Ce}),U=rn(y,"FORBID_ATTR",nn(null),{transform:Ce}),Ye=je(y,"USE_PROFILES")?y.USE_PROFILES&&typeof y.USE_PROFILES=="object"?Di(y.USE_PROFILES):y.USE_PROFILES:!1,ee=y.ALLOW_ARIA_ATTR!==!1,_=y.ALLOW_DATA_ATTR!==!1,G=y.ALLOW_UNKNOWN_PROTOCOLS||!1,K=y.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Z=y.SAFE_FOR_TEMPLATES||!1,oe=y.SAFE_FOR_XML!==!1,be=y.WHOLE_DOCUMENT||!1,at=y.RETURN_DOM||!1,ve=y.RETURN_DOM_FRAGMENT||!1,xe=y.RETURN_TRUSTED_TYPE||!1,Ne=y.FORCE_BODY||!1,Tt=y.SANITIZE_DOM!==!1,Pn=y.SANITIZE_NAMED_PROPS||!1,Ee=y.KEEP_CONTENT!==!1,Ft=y.IN_PLACE||!1,nr=tw(y.ALLOWED_URI_REGEXP)?y.ALLOWED_URI_REGEXP:lh,lt=typeof y.NAMESPACE=="string"?y.NAMESPACE:ue,Bl=sl(y,"MATHML_TEXT_INTEGRATION_POINTS",zl),Hl=sl(y,"HTML_INTEGRATION_POINTS",xE);const x=sl(y,"CUSTOM_ELEMENT_HANDLING",EE);if(B=nn(null),je(x,"tagNameCheck")&&gg(x.tagNameCheck)&&(B.tagNameCheck=x.tagNameCheck),je(x,"attributeNameCheck")&&gg(x.attributeNameCheck)&&(B.attributeNameCheck=x.attributeNameCheck),je(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(B.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),Oe(B),Z&&(_=!1),ve&&(at=!0),Ye&&((je(y,"ALLOWED_TAGS")||je(y,"ALLOWED_ATTR"))&&typeof console<"u"&&typeof console.warn=="function"&&console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together."),ge=ce({},ih),M=nn(null),Ye.html===!0&&(ce(ge,oh),ce(M,ah)),Ye.svg===!0&&(ce(ge,nl),ce(M,il),ce(M,$i)),Ye.svgFilters===!0&&(ce(ge,rl),ce(M,il),ce(M,$i)),Ye.mathMl===!0&&(ce(ge,ol),ce(M,sh),ce(M,$i))),V.tagCheck=null,V.attributeCheck=null,je(y,"ADD_TAGS")&&(typeof y.ADD_TAGS=="function"?V.tagCheck=y.ADD_TAGS:Zn(y.ADD_TAGS)&&(ge===Mt&&(ge=Yr(ge)),ce(ge,y.ADD_TAGS,Ce))),je(y,"ADD_ATTR")&&(typeof y.ADD_ATTR=="function"?V.attributeCheck=y.ADD_ATTR:Zn(y.ADD_ATTR)&&(M===H&&(M=Yr(M)),ce(M,y.ADD_ATTR,Ce))),je(y,"ADD_FORBID_CONTENTS")&&Zn(y.ADD_FORBID_CONTENTS)&&(yt===Vt&&(yt=Yr(yt)),ce(yt,y.ADD_FORBID_CONTENTS,Ce)),Ee&&(ge["#text"]=!0),be&&ce(ge,["html","head","body"]),ge.table&&(ge.tbody=!0,delete q.tbody),y.TRUSTED_TYPES_POLICY){if(typeof y.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof y.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const A=S;S=y.TRUSTED_TYPES_POLICY;try{$=pe("")}catch(F){throw S=A,F}}else y.TRUSTED_TYPES_POLICY===null?(S=void 0,$=""):(S===void 0&&(S=Te()),S&&typeof $=="string"&&($=pe("")));Xi=ze(y)},mg=ce({},[...nl,...rl,...nw]),bg=ce({},[...ol,...rw]),kE=function(y,x,A){return x===ue?y==="svg":x===Dn?y==="svg"&&(A==="annotation-xml"||Bl[A]):!!mg[y]},CE=function(y,x,A){return x===ue?y==="math":x===ae?y==="math"&&Hl[A]:!!bg[y]},AE=function(y,x,A){return x===ae&&!Hl[A]||x===Dn&&!Bl[A]?!1:!bg[y]&&(SE[y]||!mg[y])},OE=function(y){const x=I(y),A=Mn(O(y)),F=v(y);let j=lt,X="template";return F&&P(F)===Me.element&&(j=I(F),X=Mn(O(F))),oo[x]?x===ae?kE(A,j,X):x===Dn?CE(A,j,X):x===ue?AE(A,j,X):io==="application/xhtml+xml":!1},ln=function(y){jr(t.removed,{element:y});try{v(y).removeChild(y)}catch{if(f(y),!v(y))throw Ut("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},yg=function(y,x,A){try{g(y,x)}catch{try{y.removeAttribute(A)}catch{}}},ql=function(y){Gl(y);const x=b(y);x&&Ht(jv(x),A=>{try{f(A)}catch{}}),P(y)===Me.element&&Wl(y,!1)},rr=function(y,x,A){if(!A)try{A=x.getAttributeNode(y)}catch{A=null}if(jr(t.removed,{attribute:A||null,from:x}),A)yg(x,A,y);else try{x.removeAttribute(y)}catch{}if(y==="is")if(at||ve)try{ln(x)}catch{}else try{x.setAttribute(y,"")}catch{}},Wl=function(y,x){const A=E(y);if(A)for(let F=A.length-1;F>=0;--F){const j=A[F],X=j&&j.name;typeof X=="string"&&!(x&&M[Ce(X)])&&yg(y,j,X)}},jl=function(y,x){let A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const F=[y];for(;F.length>0;){const j=F.pop();if(x(j)===!1)continue;if(A&&P(j)===Me.element){const re=w(j);or(re)&&F.push(re)}const X=b(j);if(X)for(let re=X.length-1;re>=0;--re)F.push(X[re])}},Gl=function(y){jl(y,x=>{P(x)===Me.element&&Wl(x,!0)})},Vl=function(y){const x=[];return jl(y,A=>{x.push(A)},!0),x},IE=function(y,x){const A=Js();Ht(Vl(y),F=>{P(F)===Me.element&&Qs(A,F)}),Ht(x,F=>{P(F)===Me.element&&!Gr(A,F)&&Wl(F,!0)})},vg=function(y,x){let A=!1;return Ht(t.removed,F=>{F.element&&(A=A||F.element===y,Gl(F.element))}),IE(y,x),A},PE=8,RE=function(y,x){const A=bt;let F=null;const j=()=>(F||(F=Js(),Ht(x,X=>{Qs(F,X)})),F);for(let X=0;;X++){const re=Vl(y),Fe=[y];let Yt=!1;if(Ht(re,Ct=>{P(Ct)===Me.documentFragment?jr(Fe,Ct):!Yt&&!Gr(A,Ct)&&(Yt=Gr(j(),Ct))}),!Yt)return;if(X>=PE)throw Ut("the tree kept changing during in-place sanitization; refusing to return it");Ht(Fe,(Ct,dt)=>{DE(Ct,dt>0,y,j())})}},DE=function(y,x,A,F){const j=Zi(y);let X;for(;X=j.nextNode();)!Gr(F,X)||Gr(bt,X)||(x&&kt(te.uponSanitizeShadowNode,X,null),Zl(X,A))},$E=function(y){bt&&Qs(bt,y)},wg=function(y,x){return oe?y==="patchsrc"?!0:y==="for"&&x!=="label"&&x!=="output":!1},NE=function(y){oe&&jl(y,x=>{const A=P(x);if(A===Me.processingInstruction||A===Me.comment&&Be(ch,x.data)){try{f(x)}catch{}return!1}if(A===Me.element){const F=x,j=Ce(O(x));try{F.hasAttribute&&F.hasAttribute("patchsrc")&&F.removeAttribute("patchsrc"),F.hasAttribute&&F.hasAttribute("for")&&wg("for",j)&&F.removeAttribute("for")}catch{}}return!0})},xg=function(y){let x=null,A=null;if(Ne)y="<remove></remove>"+y;else{const X=Vv(y,mw);A=X&&X[0]}io==="application/xhtml+xml"&&lt===ue&&(y='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+y+"</body></html>");const F=S?pe(y):y;if(lt===ue)try{x=new s().parseFromString(F,io)}catch{}if(!x||!x.documentElement){x=de.createDocument(lt,"template",null);try{x.documentElement.innerHTML=ct?$:F}catch{}}const j=x.body||x.documentElement;return y&&A&&j.insertBefore(n.createTextNode(A),j.childNodes[0]||null),lt===ue?De.call(x,be?"html":"body")[0]:be?x.documentElement:j},Zi=function(y){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const A=R?R(y):y.ownerDocument;return ye.call(A||y,y,(x?0:c.SHOW_ELEMENT)|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Yl=function(y){return y=Ri(y,Ve," "),y=Ri(y,$e," "),y=Ri(y,fe," "),y},Kl=function(y){var x;Xl(y);const A=(x=y.querySelectorAll)===null||x===void 0?void 0:x.call(y,"template");A&&Ht(A,F=>{or(F.content)&&Kl(F.content)})},Xl=function(y){y.normalize();const x=Zi(y,!0);let A=x.nextNode();for(;A;)A.data=Yl(A.data),A=x.nextNode()},Ji=function(y){const x=L?L(y):null;return typeof x!="string"||Ce(x)!=="form"?!1:typeof y.nodeName!="string"||typeof y.textContent!="string"||typeof y.removeChild!="function"||y.attributes!==E(y)||typeof y.removeAttribute!="function"||typeof y.removeAttributeNode!="function"||typeof y.getAttributeNode!="function"||typeof y.setAttribute!="function"||typeof y.namespaceURI!="string"||typeof y.insertBefore!="function"||typeof y.hasChildNodes!="function"||y.nodeType!==k(y)||y.childNodes!==b(y)},Eg=function(y){if(!k||typeof y!="object"||y===null)return null;try{const x=k(y);return typeof x=="number"?x:null}catch{return null}},or=function(y){return Eg(y)===Me.documentFragment},ao=function(y){return Eg(y)!==null};function kt(D,y,x){D.length!==0&&Ht(D,A=>{A.call(t,y,x,Xi)})}const LE=function(y,x,A){return!!(oe&&A===Me.element&&y.hasChildNodes()&&!ao(y.firstElementChild)&&Be(al,y.textContent)&&Be(al,y.innerHTML)||oe&&bw[x]&&A===Me.element&&I(y)===ue&&(ao(y.firstElementChild)||typeof y.textContent=="string"&&Be(al,y.textContent))||A===Me.processingInstruction||oe&&A===Me.comment&&Be(ch,y.data))},Qi=function(y,x){if(y instanceof RegExp)return Be(y,x);if(y instanceof Function){for(var A=arguments.length,F=new Array(A>2?A-2:0),j=2;j<A;j++)F[j-2]=arguments[j];return!!y(x,...F)}return!1},FE=function(y,x,A){if(!q[x]&&Mg(x)&&Qi(B.tagNameCheck,x))return!1;if(Ee&&!yt[x]&&!yt[Mn(x)]){const F=v(y),j=b(y);if(j&&F){const X=j.length;for(let re=X-1;re>=0;--re){const Fe=y===A?u(j[re],!0):j[re];F.insertBefore(Fe,m(y))}}}return ln(y),!0},Sg=function(y,x,A,F){return y.length===0?x:x===A||x===F?Yr(x):x},ir=function(y,x){return y===x||v(y)!==null?!1:(Ft&&Gl(y),!0)},zE=function(y,x){if($E(y),kt(te.beforeSanitizeElements,y,null),ir(y,x))return!0;if(Ji(y))return ln(y),!0;const A=Ce(O(y)),F=P(y);if(ge=Sg(te.uponSanitizeElement,ge,Mt,Ue),kt(te.uponSanitizeElement,y,{tagName:A,allowedTags:ge}),ir(y,x))return!0;if(LE(y,A,F))return ln(y),!0;if(q[A]||!(V.tagCheck instanceof Function&&V.tagCheck(A))&&!ge[A]){const j=FE(y,A,x);return j===!1&&(kt(te.afterSanitizeElements,y,null),ir(y,x))?!0:j}if(F===Me.element&&!OE(y)||(A==="noscript"||A==="noembed"||A==="noframes")&&Be(hw,y.innerHTML))return ln(y),!0;if(Z&&F===Me.text){const j=y.textContent,X=Yl(j);j!==X&&(jr(t.removed,{element:y.cloneNode()}),y.textContent=X)}return kt(te.afterSanitizeElements,y,null),ir(y,x)},_g=function(y,x,A){if(U[x]||wg(x,y)||Tt&&(x==="id"||x==="name")&&(A in n||A in TE))return!1;const F=M[x]||V.attributeCheck instanceof Function&&V.attributeCheck(x,y);if(_&&Be(me,x)||ee&&Be(tr,x))return!0;if(!F)return Mg(y)&&Qi(B.tagNameCheck,y)&&Qi(B.attributeNameCheck,x,y)||x==="is"&&B.allowCustomizedBuiltInElements&&Qi(B.tagNameCheck,A);if(Le[x])return!0;const j=Ri(A,no,"");return Be(nr,j)||(x==="src"||x==="xlink:href"||x==="href")&&y!=="script"&&tl(A,"data:")===0&&sn[y]||G&&!Be(to,j)?!0:!A},BE=ce({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Mg=function(y){return!BE[Mn(y)]&&Be(ro,y)},HE=function(y,x,A,F){if(S&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!A)switch(d.getAttributeType(y,x)){case"TrustedHTML":return pe(F);case"TrustedScriptURL":return Q(F)}return F},UE=function(y,x,A,F){try{return A?y.setAttributeNS(A,x,F):y.setAttribute(x,F),Ji(y)?(ln(y),!1):!0}catch{return rr(x,y),!1}},Tg=function(y,x){return oe&&Be(gw,x)?!0:Mn(y)==="attributename"&&tl(x,"href")!==-1},qE=function(y,x){if(kt(te.beforeSanitizeAttributes,y,null),ir(y,x))return;const A=y.attributes;if(!A||Ji(y))return;M=Sg(te.uponSanitizeAttribute,M,H,Je);const F={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:M,forceKeepAttr:void 0};let j=A.length;const X=Ce(O(y));for(;j--;){const re=A[j],Fe=re.name,Yt=re.namespaceURI,Ct=re.value,dt=Ce(Fe),zt=Ct;let qe=Fe==="value"?zt:Yv(zt),kg=!1;if(F.attrName=dt,F.attrValue=qe,F.keepAttr=!0,F.forceKeepAttr=void 0,kt(te.uponSanitizeAttribute,y,F),qe=F.attrValue,Pn&&(dt==="id"||dt==="name")&&tl(qe,st)!==0&&(rr(Fe,y,re),qe=st+qe,kg=!0),Tg(Fe,qe)){rr(Fe,y,re);continue}if(!F.forceKeepAttr){if(!F.keepAttr){rr(Fe,y,re);continue}if(!K&&Be(dh,qe)){rr(Fe,y,re);continue}if(Z&&(qe=Yl(qe)),!_g(X,dt,qe)){rr(Fe,y,re);continue}qe=HE(X,dt,Yt,qe),qe!==zt&&UE(y,Fe,Yt,qe)&&kg&&eh(t.removed)}}kt(te.afterSanitizeAttributes,y,null),ir(y,x)},Zl=function(y,x){zE(y,x),qE(y,x),or(y.content)&&Jl(y.content)},Jl=function(y){let x=null;const A=Zi(y);for(kt(te.beforeSanitizeShadowDOM,y,null);x=A.nextNode();)if(kt(te.uponSanitizeShadowNode,x,null),Zl(x,y),P(x)===Me.element){const F=w(x);or(F)&&(Ql(F),Jl(F))}Z&&Xl(y),kt(te.afterSanitizeShadowDOM,y,null)},Ql=function(y){const x=[{node:y,shadow:null}];for(;x.length>0;){const A=x.pop();if(A.shadow){Jl(A.shadow);continue}const F=A.node,j=P(F)===Me.element,X=b(F);if(X)for(let re=X.length-1;re>=0;--re)x.push({node:X[re],shadow:null});if(j){const re=L?L(F):null;if(typeof re=="string"&&Ce(re)==="template"){const Fe=F.content;or(Fe)&&x.push({node:Fe,shadow:null})}}if(j){const re=w(F);or(re)&&x.push({node:null,shadow:re},{node:re,shadow:null})}}};return t.sanitize=function(D){let y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,A=null,F=null,j=null;if(ct=!D,ct&&(D="<!-->"),typeof D!="string"&&!ao(D)&&(D=Qv(D),typeof D!="string"))throw Ut("dirty is not a string, aborting");if(!t.isSupported)return D;ke?(ge=Ue,M=Je):Ul(y),t.removed=[];const X=Ft&&typeof D!="string"&&ao(D);let re=[];const Fe=bt;if(X){NE(D);const zt=O(D);if(typeof zt=="string"){const qe=Ce(zt);if(!ge[qe]||q[qe])throw ql(D),Ut("root node is forbidden and cannot be sanitized in-place")}if(Ji(D))throw ql(D),Ut("root node is clobbered and cannot be sanitized in-place");re=Vl(D),bt=Js()}else if(ao(D))x=xg("<!---->"),A=x.ownerDocument.importNode(D,!0),A.nodeType===Me.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?x=A:x.appendChild(A),Ql(x);else{if(!at&&!Z&&!be&&D.indexOf("<")===-1)return Ge(D);if(x=xg(D),!x)return at?null:xe?$:""}x&&Ne&&ln(x.firstChild);const Yt=X?D:x;try{X&&Ql(D);const zt=Zi(Yt);for(;F=zt.nextNode();)Zl(F,Yt);X&&RE(D,re)}catch(zt){throw X&&(ql(D),vg(D,re)),zt}finally{bt=Fe}if(X){if(vg(D,re))throw Ut("a node selected for removal could not be safely returned; refusing to sanitize in place");return Z&&Kl(D),D}if(at){if(Z&&Kl(x),ve)for(j=ne.call(x.ownerDocument);x.firstChild;)j.appendChild(x.firstChild);else j=x;return(M.shadowroot||M.shadowrootmode)&&(j=it.call(r,j,!0)),j}const Ct=()=>be?x.outerHTML:x.innerHTML;let dt=Ct();return Z&&Be(sw,dt)&&(Xl(x),dt=Ct()),be&&ge["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Be(pw,x.ownerDocument.doctype.name)&&(dt="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
272
- `+dt),Ge(dt)},t.setConfig=function(){let D=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ul(D),ke=!0,Ue=ge,Je=M},t.clearConfig=function(){Xi=null,ke=!1,Ue=null,Je=null,S=N,$=""},t.isValidAttribute=function(D,y,x){Xi||Ul({});const A=Ce(D),F=Ce(y);return typeof x=="string"&&(Tg(y,x)||!K&&Be(dh,x))?!1:_g(A,F,x)},t.addHook=function(D,y){typeof y=="function"&&je(te,D)&&jr(te[D],y)},t.removeHook=function(D,y){if(je(te,D)){if(y!==void 0){const x=Wv(te[D],y);return x===-1?void 0:Gv(te[D],x,1)[0]}return eh(te[D])}},t.removeHooks=function(D){je(te,D)&&(te[D]=[])},t.removeAllHooks=function(){te=uh()},t}var ww=ph();const xw={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Ew(e,t){const n=e.options;return ds(n.formatter,t,String(n.testData||n.title||""))||"1234567890128"}function Sw(e){return h("div",{class:"print-qrcode",dataset:{codeId:e.id,codeKind:"qrcode"}})}function _w(e){const t=e.options;return h("div",{class:"print-barcode",dataset:{codeId:e.id,codeKind:"barcode"}},[h("svg",{preserveAspectRatio:xw[String(t.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function Mw(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}function Tw(e,t,n){const r=e.options,o=fr(r.barWidth),i=ua(r.barQuietZone),a=l=>{ps(t,Ew(e,n),{format:String(r.barcodeType||"CODE128"),width:o,height:l*o,displayValue:!r.hideTitle,fontSize:(r.fontSize??ho)*o,margin:0,marginLeft:i*o,marginRight:i*o,marginTop:0,marginBottom:pa*o});const c=Mw(t);return c?{widthUnits:c.width,heightUnits:c.height}:null};try{const l=ha({barHeightMm:r.barHeight,boxWidthMm:Ln(r.width,r.maxWidth),boxHeightMm:Ln(r.height,r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:a});t.style.width=l.size?`${l.size.widthMm}mm`:"",t.style.height=l.size?`${l.size.heightMm}mm`:""}catch{t.replaceChildren();return}t.setAttribute("shape-rendering","crispEdges")}function kw(e,t,n){const r=e.options,o=ds(r.formatter,n,String(r.testData||r.title||""))||"二维码";t.replaceChildren();try{const i=Ls.render(o,"qrcode",{qrCodeLevel:String(r.qrCodeLevel??"M"),qrQuietZone:typeof r.qrQuietZone=="number"?r.qrQuietZone:void 0}),a=document.createElement("img");a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,a.alt="qrcode",a.style.width="100%",a.style.height="100%",a.style.objectFit=String(r.fit||"contain"),a.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",a.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%",t.appendChild(a)}catch{}}function Cw(e,t,n){for(const r of Array.from(e.querySelectorAll("[data-code-kind]"))){const o=r.dataset.codeId,i=t.find(a=>a.id===o);if(i)if(r.dataset.codeKind==="barcode"){const a=r.querySelector("svg");a&&Tw(i,a,n)}else kw(i,r,n)}}const Ni=new Map;function Aw(e){return typeof Node<"u"&&e instanceof Node}function fh(e,t,n){if(hh(e),typeof t=="string"){n.innerHTML=t;return}if(Aw(t)){n.appendChild(t);return}typeof t.node=="string"?n.innerHTML=t.node:n.appendChild(t.node),typeof t.dispose=="function"&&Ni.set(e,t.dispose)}function hh(e){const t=Ni.get(e);if(t){Ni.delete(e);try{t()}catch{}}}function gh(){for(const e of[...Ni.keys()])hh(e)}const Ow={header:"题",data:"数",subtotal:"小",summary:"汇"},Iw=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],Li=3.7795275591,Pw=.1,ll=e=>JSON.parse(JSON.stringify(e)),mh=new WeakMap;function qt(e){let t=mh.get(e);return t||(t={menu:null,menuElId:null,anchor:null,layouts:new Map},mh.set(e,t)),t}function Kr(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function Rw(e,t){const n=e.tableSelection;return!n||n.elementId!==t.id?null:e.selectedElement?.id!==t.id?(e.tableSelection=null,null):n}function bh(e,t,n,r){const o=Kr(e,n.id);if(!o)return null;const i=n.options;return{store:e,fire:t,el:n,real:o,options:i,rows:i.tableRows??[],colWidths:i.tableColWidths??[],isSelected:e.selectedIds.has(n.id),selection:Rw(e,n),maxTableWidth:yh(e),designData:r}}function yh(e){return e.paperSize.width-e.templateData.margins.left-e.templateData.margins.right}function cl(e){return e.options.tableDefaultFontSize??10}function vh(e){return e.options.tableDefaultColor??"#333333"}function Dw(e,t){let n=0;for(let r=0;r<t;r++)n+=e.rows[r].height;return n}function $w(e,t){return qt(e.store).layouts.get(e.el.id)?.[t]?.top??Dw(e,t)}function Nw(e,t){return qt(e.store).layouts.get(e.el.id)?.[t]?.height??e.rows[t]?.height??0}function Lw(e){const t=e.options.dataSource;if(t&&Array.isArray(gt[t]))return gt[t];for(const n of Object.values(gt))if(Array.isArray(n))return n}function wh(e){return e.cellType==="barcode"||e.cellType==="qrcode"}function xh(e,t){return wh(t)?ds(t.formatter,Lw(e)):t.formatter||""}function Fw(e,t){const n={designMode:!0,showGhostBorder:e.store.showTableGhostBorder};return{fontFamily:Ya(t.fontFamily??e.options.tableDefaultFontFamily),textAlign:t.align??"left",...t.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:t.valign??"middle",fontSize:(t.fontSize??cl(e))+"pt",fontWeight:t.fontWeight??"normal",color:t.color??vh(e),backgroundColor:t.backgroundColor??"transparent",borderTop:co(t.borders?.top,n),borderRight:co(t.borders?.right,n),borderBottom:co(t.borders?.bottom,n),borderLeft:co(t.borders?.left,n),padding:(t.padding??e.options.tableDefaultPadding??1)+"mm",whiteSpace:t.wordWrap??!0?"pre-wrap":"nowrap",overflow:t.wordWrap??!0?"visible":"hidden"}}function zw(e,t,n){const r=e.selection;return[!!r&&t>=r.r1&&t<=r.r2&&n>=r.c1&&n<=r.c2?"cell-selected":"",e.rows[t]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Eh(e){return aa(e)}function Bw(e){return Eh(e)!=="autoHeight"}function Hw(e,t){return t.fontSize??cl(e)}function Fi(e,t,n){return ur(e.rows,t,n,e.options.tableDefaultPadding??1)}function Uw(e,t,n){return la(e.colWidths,t,n,e.options.tableDefaultPadding??1)}function qw(e,t,n){return{maxHeight:Fi(e,n,t)+"mm",overflow:"hidden",...t.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Ww(e,t,n){const r={fitBase:String(Hw(e,t)),fitMin:String(dr(t.shrinkMinFontSize)),fitMm:String(Fi(e,n,t))};return Eh(t)==="shrink"&&(r.fit="shrink"),r}function jw(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}const Gw={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Vw(e,t,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(_v,"svg");o.appendChild(i);const a=xh(e,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",Gw[r.fit||"contain"]??"xMidYMid meet");const l=fr(r.barWidth),c=ua(r.barQuietZone),s=u=>{ps(i,a,{format:r.barcodeType||"CODE128",width:l,height:u*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??ho)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:pa*l});const f=jw(i);return f?{widthUnits:f.width,heightUnits:f.height}:null};let d=null;try{d=ha({barHeightMm:r.barHeight,boxWidthMm:Ln(Uw(e,n,r),r.maxWidth),boxHeightMm:Ln(Fi(e,t,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:s})}catch{d=null}if(!d){i.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=a||"条码",o.appendChild(u),o}const p=d.size;return p?(i.style.width=`${p.widthMm}mm`,i.style.height=`${p.heightMm}mm`):(i.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",i.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%"),i.setAttribute("shape-rendering","crispEdges"),o}if(i.style.display="none",!a)return o;try{const l=Ls.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 Sh(){const e=document.createElement("div");return e.className="image-placeholder",e.textContent="图片",e}function Yw(e,t){const n=e.formatter||"";if(!n)return"";if(!n.includes("{"))return n;const r=t.designData?.length?t.designData[0]:gt;return Wn(n,r)}function Kw(e,t,n){const r=document.createElement("div");r.className="cell-image";const o=wc(n.fit,Fi(e,t,n));o!==void 0&&(r.style.height=`${o}mm`);const i=Yw(n,e);if(!i)return r.appendChild(Sh()),r;const a=document.createElement("img");a.setAttribute("src",i),o!==void 0&&(a.style.width="100%",a.style.height="100%"),a.style.objectFit=n.fit||"contain";for(const[l,c]of Object.entries(ga(n.fit,n.fitScale,n.objectPosition)))a.style[l]=c;return a.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",a.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",a.addEventListener("error",()=>{a.remove(),r.appendChild(Sh())},{once:!0}),r.appendChild(a),r}function Xw(e,t,n,r,o){if(wh(o))return Vw(e,n,r,o);if(o.cellType==="image")return Kw(e,n,o);const i=xh(e,o),a=()=>t.type==="data"?h("span",{class:"data-placeholder",text:i}):i;return Bw(o)?h("div",{class:"cell-fit",style:qw(e,o,n),dataset:Ww(e,o,n)},[a()]):a()}function zi(e,t,n){const r={elementId:e.el.id,...ec(e.rows,t,n)};e.store.setTableSelection(r),e.fire("table-selection-change",{elementId:e.el.id,selection:r})}function Zw(e,t,n,r,o){if(o.button!==0||(e.fire("table-cell-mousedown",{elementId:e.el.id,r:t,c:n,cellId:r,event:o}),!e.isSelected))return;o.stopPropagation();const i=qt(e.store);o.shiftKey&&e.selection?zi(e,{r:e.selection.r1,c:e.selection.c1},{r:t,c:n}):(i.anchor={r:t,c:n},zi(e,{r:t,c:n},{r:t,c:n})),document.addEventListener("mouseup",()=>{qt(e.store).anchor=null},{once:!0})}function Jw(e,t,n){const r=qt(e.store).anchor;r&&zi(e,r,{r:t,c:n})}function dl(e,t){const n=qt(e);n.menu?.visible&&(n.menu.visible=!1,t("table-menu-close",{elementId:n.menuElId}),e.emit(!1))}function Qw(e,t,n,r){r.preventDefault(),r.stopPropagation(),e.isSelected||e.store.selectOne(e.el.id);const o=e.selection;o&&t>=o.r1&&t<=o.r2&&n>=o.c1&&n<=o.c2||zi(e,{r:t,c:n},{r:t,c:n});const a=qt(e.store);a.menuElId=e.el.id,a.menu&&(a.menu.x=r.clientX,a.menu.y=r.clientY,a.menu.visible=!0),e.fire("table-cell-contextmenu",{elementId:e.el.id,r:t,c:n,clientX:r.clientX,clientY:r.clientY}),e.store.emit(!1),document.addEventListener("mousedown",()=>dl(e.store,e.fire),{once:!0})}function _h(e,t,n){const r=e.reduce((o,i)=>o+i,0)+(e[t]??0);return r>n?`插入后表格总宽 ${Math.round(r*10)/10}mm 超过打印范围宽度 ${n}mm,请先缩小列宽`:null}function ex(e,t){const n=e.real.options.tableRows??[],r=e.real.options.tableColWidths??[],o=t(ll(n),ll(r));return o?(window.alert(o),!1):(e.store.recordHistory(),t(n,r),e.store.setTableSelection(null),sr(e.real.options),e.store.emit(),!0)}function Wt(e,t,n){dl(e.store,e.fire);const r=e.selection;if(!r)return;let o=null;switch(t){case"insert-row-above":o=i=>(oc(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(oc(i,r.r2,"below"),null);break;case"delete-row":o=i=>Rg(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=_h(a,r.c1,e.maxTableWidth);return l||(ic(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=_h(a,r.c2,e.maxTableWidth);return l||(ic(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>Dg(i,a,r.c1);break;case"merge":o=i=>(nc(i,r),null);break;case"split":o=i=>(rc(i,r),null);break;case"set-row-type":o=i=>n?na(i,r.r1,n):"未指定行类型";break}o&&ex(e,o)&&e.fire(`table-${t}`,{elementId:e.el.id,...n?{type:n}:{}})}function tx(e){const t=e.selection;if(!t)return!1;for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e.rows[n]?.cells[r];if(o&&!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1))return!0}return!1}function nx(e){const t=e.selection;if(!t)return;const n=ar(e.rows,t.r1,t.c1),r=!e.rows[n.r]?.cells[n.c]?.mergeSameValue;for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e.rows[o]?.cells[i];a&&!a.merged&&(a.mergeSameValue=r)}e.store.updateElement(e.el.id,{tableRows:e.rows}),dl(e.store,e.fire)}function Mh(e){const t=e.selection;if(!t)return"未选择单元格";for(let n=t.r1;n<=t.r2;n++)if(e.rows[n]?.type!=="data")return"仅数据行(明细行)支持按值合并";return null}function Th(e,t){const n=e.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":na(ll(e.rows),n.r1,t):"未选择单元格"}function Dt(e,t,n={}){return h("div",{class:`menu-item${n.disabled?" disabled":""}${n.active?" active":""}`,title:n.title||"",text:e,onClick:()=>{n.disabled||t()}})}const ul=()=>h("div",{class:"menu-divider"});function rx(e,t,n){const r=qt(e);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=Kr(e,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=bh(e,t,o);if(!i)return"";const a=i.selection?tc(i.rows,i.selection):"未选择单元格",l=i.selection?i.rows[i.selection.r1]?.type??null:null;return h("div",{class:"table-ctx-menu",style:{left:n.x+"px",top:n.y+"px"},onMousedown:c=>c.stopPropagation()},[Dt("在上方插入行",()=>Wt(i,"insert-row-above")),Dt("在下方插入行",()=>Wt(i,"insert-row-below")),Dt("删除行",()=>Wt(i,"delete-row"),{disabled:i.rows.length<=1}),ul(),Dt("在左侧插入列",()=>Wt(i,"insert-col-left")),Dt("在右侧插入列",()=>Wt(i,"insert-col-right")),Dt("删除列",()=>Wt(i,"delete-col"),{disabled:i.colWidths.length<=1}),ul(),Dt("合并单元格",()=>Wt(i,"merge"),{disabled:!!a,title:a||""}),Dt("拆分单元格",()=>Wt(i,"split"),{disabled:!tx(i)}),Dt("按值合并",()=>nx(i),{disabled:!!Mh(i),title:Mh(i)||"",active:(()=>{const c=i.selection;if(!c)return!1;const s=ar(i.rows,c.r1,c.c1);return i.rows[s.r]?.cells[s.c]?.mergeSameValue===!0})()}),ul(),h("div",{class:"menu-group-title",text:"行类型"}),...Iw.map(c=>Dt(c.label,()=>Wt(i,"set-row-type",c.value),{disabled:!!Th(i,c.value),title:Th(i,c.value)||"",active:l===c.value}))])}let Tn=null;function kh(){Tn&&(document.removeEventListener("mousemove",pl),document.removeEventListener("mouseup",fl),Tn.handle.classList.remove("dragging"),Tn=null)}function ox(e,t){const n=e.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(t.scale||100)/100}function ix(e,t,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;kh();const i=e.real.options.tableColWidths??[];Tn={store:e.store,fire:e.fire,elId:e.real.id,boundary:t,startX:n.clientX,startWidth:i[t-1]??0,scale:ox(o,e.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),e.store.recordHistory(),document.addEventListener("mousemove",pl),document.addEventListener("mouseup",fl)}function pl(e){const t=Tn;if(!t)return;const n=Kr(t.store,t.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(e.clientX-t.startX)/(t.scale*Li),i=t.boundary-1;r[i]=Hg(r,i,t.startWidth+o,yh(t.store)),sr(n.options),r.forEach((a,l)=>{const c=t.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${a}mm`)}),t.root.querySelectorAll(".col-resize-handle").forEach((a,l)=>{a.style.left=`${r.slice(0,l+1).reduce((c,s)=>c+s,0)}mm`}),t.wrapper&&(t.wrapper.style.width=`${n.options.width}mm`,t.wrapper.style.height=`${n.options.height}mm`)}function fl(){document.removeEventListener("mousemove",pl),document.removeEventListener("mouseup",fl);const e=Tn;if(!e)return;Tn=null,e.handle.classList.remove("dragging");const t=Kr(e.store,e.elId);t&&sr(t.options),e.store.emit(),e.fire("table-col-resize-end",{elementId:e.elId})}function ax(e,t,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=Kr(e,t);if(!i)return;let a=!1;const l=o/Li;Math.abs(l-(i.options.height??0))>Pw&&(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)/Li,height:p.offsetHeight/Li})),d=qt(e);sx(d.layouts.get(t),s)||(d.layouts.set(t,s),a=!0),a&&e.emit(!1)}function sx(e,t){return!e||e.length!==t.length?!1:t.every((n,r)=>{const o=e[r];return Math.round(n.top*10)===Math.round(o.top*10)&&Math.round(n.height*10)===Math.round(o.height*10)})}function lx(e,t){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&ax(e,t,r)}),n}function cx(e){return e.isSelected&&!e.real.options.locked&&e.colWidths.length>=1}function dx(e){return Array.from({length:e.colWidths.length},(t,n)=>n+1)}function ux(e,t){return e.colWidths.slice(0,t).reduce((n,r)=>n+r,0)}function px(e,t,n,r){const o=bh(t,n,e,r);if(!o)return h("div",{class:"print-table"});const i=[h("table",{style:{fontSize:`${cl(o)}pt`,color:vh(o)}},[h("colgroup",{},o.colWidths.map(a=>h("col",{style:{width:a+"mm"}}))),h("tbody",{},o.rows.map((a,l)=>h("tr",{style:{height:a.height+"mm"}},a.cells.map((c,s)=>c.merged?"":h("td",{rowspan:c.rowspan||1,colspan:c.colspan||1,class:zw(o,l,s),style:Fw(o,c),onMousedown:d=>Zw(o,l,s,c.id,d),onMouseenter:()=>Jw(o,l,s),onContextmenu:d=>Qw(o,l,s,d)},[Xw(o,a,l,s,c)])).filter(Boolean))))])];return cx(o)&&i.push(h("div",{class:"col-resize-layer"},dx(o).map(a=>h("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${a}`,style:{left:ux(o,a)+"mm"},onMousedown:l=>{l.stopPropagation(),l.preventDefault(),ix(o,a,l)}})))),o.isSelected&&i.push(h("div",{class:"row-badges"},o.rows.map((a,l)=>h("span",{class:"row-badge",style:{top:$w(o,l)+"mm",height:Nw(o,l)+"mm"},text:Ow[a.type]})))),i.push(lx(t,e.id)),h("div",{class:"print-table design-mode",dataset:{tableId:e.id},onContextmenu:a=>a.preventDefault()},i)}const fx=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function hl(e){return Array.isArray(e)&&e.length>0?e:[]}function hx(e,t){const n=fo(e,t)??(t?Object.keys(t).find(o=>Array.isArray(t[o])):void 0);if(n)return hl(t?.[n]);const r=fo(e,gt);return r?hl(gt[r]):[]}function gx(e,t){const n=e.options,r=typeof n.formatter=="string"?n.formatter:"",o=hl(t)[0],i=hx(r,o);if(i.length===0)return[...fx];if(!r)return i.map(c=>String(c?.name??JSON.stringify(c)));const a=o??{},l=fo(r,a)??Object.keys(a).find(c=>Array.isArray(a[c]));return i.map(c=>{try{return Wn(r,{...a,...c,...l?{[l]:c}:{}})}catch{return r}})}const mx=3.7795275591,bx=.1;function yx(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function vx(e){const t=e.parentElement;if(!t?.classList.contains("print-element"))return 0;const n=getComputedStyle(t);return(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0)}function wx(e,t,n){const r=n.offsetHeight+vx(n);if(r<=0)return;const o=yx(e,t);if(!o)return;const i=r/mx;Math.abs(i-(o.options.height??0))>bx&&(o.options.height=Math.round(i*100)/100,e.emit(!1))}function xx(e,t){const n=document.createComment("pd-flowlist-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&wx(e,t,r)}),n}function Ex(e,t,n){const r=e.options,o=pt(r.flowColumns),i=vt(r.flowGapX),a=Xt(r.flowRowHeight),l=pn(r.flowLayoutMode)==="dynamic",c=Nn(r),s={display:"grid",gridTemplateColumns:`repeat(${o},minmax(0,1fr))`,columnGap:`${i}mm`,gridAutoRows:`minmax(${a}mm,auto)`,width:"100%",...l?{padding:`${c.top}mm ${c.right}mm ${c.bottom}mm ${c.left}mm`,height:"auto",overflow:"visible"}:{height:"100%",overflow:"hidden"},fontSize:`${r.fontSize||12}pt`,fontWeight:r.fontWeight||"normal",color:r.color||"#333",boxSizing:"border-box"};r.fontFamily&&(s.fontFamily=String(r.fontFamily)),r.backgroundColor&&(s.backgroundColor=String(r.backgroundColor));const d=gx(e,t).map(p=>h("div",{class:"print-flow-cell",text:p}));return l&&n&&d.push(xx(n,e.id)),h("div",{class:"print-flowlist",style:s},d)}const Ch={top:"flex-start",middle:"center",bottom:"flex-end"},Sx={left:"flex-start",center:"center",right:"flex-end"};function _x(e,t){const n=e.options,r=ft(n),o=bo(e.printElementType.type,n),i={};if(o?.all&&(i.border=`${o.all.borderWidth} ${o.all.borderStyle} ${o.all.borderColor}`),o)for(const a of hr){const l=o.edges[a];l&&(i[`border${a.charAt(0).toUpperCase()}${a.slice(1)}`]=`${l.borderWidth} ${l.borderStyle} ${l.borderColor}`)}return{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`,...r.top!==0?{marginTop:`${r.top}mm`}:{},...r.right!==0?{marginRight:`${r.right}mm`}:{},...r.bottom!==0?{marginBottom:`${r.bottom}mm`}:{},...r.left!==0?{marginLeft:`${r.left}mm`}:{},zIndex:String(n.zIndex||"auto"),...i,...Mx(e,t)}}function Mx(e,t){if(t?.has(e.id))return{};const n=ma(e.printElementType.type,e.options);return n===void 0?{}:{rotate:`${n}deg`}}function Ah(e){const t=e.options,n=e.printElementType.type==="longText",r=po(e.printElementType.type,t),o=t.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:t.fontWeight||"normal",fontFamily:Ya(t.fontFamily),color:t.color||"#333",backgroundColor:t.backgroundColor||"transparent",textAlign:t.textAlign||"left",...t.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:t.lineHeight?`${t.lineHeight}pt`:n?"1.5":"normal",letterSpacing:t.letterSpacing?`${t.letterSpacing}pt`:"normal",width:"100%",height:i?"auto":"100%",boxSizing:"border-box",overflow:i?"visible":"hidden",...n?{wordBreak:"break-all",textIndent:t.longTextIndent?`${t.longTextIndent}em`:"0"}:{textDecoration:t.textDecoration||"none",padding:`${t.contentPaddingTop||0}pt ${t.contentPaddingRight||0}pt ${t.contentPaddingBottom||0}pt ${t.contentPaddingLeft||0}pt`}};vc(t)&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis");const l=yc(t);return l&&(a.whiteSpace=l),t.verticalAlign&&(a.display="flex",t.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Ch[t.verticalAlign]??"flex-start"):(a.alignItems=Ch[t.verticalAlign]??"flex-start",a.justifyContent=Sx[t.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function Oh(e){const t=e.options,n=`${t.borderWidth||.75}pt`,r=t.borderStyle||"solid",o=t.borderColor||"#333";return e.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 Ih(e){const t=e.options;return{width:"100%",height:"100%",borderWidth:`${t.borderWidth||1}pt`,borderStyle:t.borderStyle||"solid",borderColor:t.borderColor||"#333",backgroundColor:t.backgroundColor||"transparent",borderRadius:e.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Tx(e){const t=e.options;return{objectFit:t.fit||"contain",...ga(t.fit,t.fitScale,t.objectPosition),maxWidth:t.maxWidth?`${t.maxWidth}mm`:"100%",maxHeight:t.maxHeight?`${t.maxHeight}mm`:"100%"}}function Ph(e){const t=e.options,n={fitBase:String(t.fontSize||12),fitMin:String(dr(t.shrinkMinFontSize))};return po(e.printElementType.type,t)==="shrink"&&(n.fit="shrink"),n}Nf({text:e=>{const{style:t}=Ah(e),n=e.options;return h("div",{class:"print-text",style:t,dataset:Ph(e),text:String(n.testData||n.formatter||"")||"文本"})},longText:e=>{const{style:t}=Ah(e),n=e.options;return h("div",{class:"print-longtext",style:t,dataset:Ph(e),text:String(n.formatter||"")||"长文本内容"})},hline:e=>h("div",{class:"print-line",style:Oh(e)}),vline:e=>h("div",{class:"print-line",style:Oh(e)}),rect:e=>h("div",{class:"print-shape",style:Ih(e)}),oval:e=>h("div",{class:"print-shape",style:Ih(e)}),image:(e,t,n)=>{const r=e.options,o=String(r.src??""),i=n?.designData?.length?n.designData[0]:gt,a=o.includes("{")?Wn(o,i):o;return h("div",{class:"print-image"},[a?h("img",{src:a,style:Tx(e)}):h("div",{class:"image-placeholder",text:"图片"})])},qrcode:e=>Sw(e),barcode:e=>_w(e),html:e=>{const t=e.options,n=String(t.formatter??""),r=n?ww.sanitize(Wn(n,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return h("div",{class:"print-html",html:r})},pageNumber:(e,t)=>{const n=e.options;return h("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:Ya(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:t?n.title||"{pageIndex}/{totalPages}":String(n.title||"")})},table:(e,t,n)=>n?px(e,n.store,n.fire,n.designData):h("div",{class:"print-table"}),flowList:(e,t,n)=>Ex(e,void 0,n?.store)});function kx(e,t,n){const r=e.printElementType.type,o=tn(r)?.renderContent;if(o)return o(e,t,n);const i=js(r);if(!i)return h("div",{text:r});const a=document.createElement("div");a.className="plugin-kit-canvas",a.style.width="100%",a.style.height="100%";try{fh(`canvas:${e.id}`,i.ui.renderCanvas({element:e,data:n?.designData?.length?n.designData:[gt],designMode:!0}),a)}catch{a.textContent=String(r)}return a}function Rh(e){return`x:${Math.round(e.left)} y:${Math.round(e.top)} ${Math.round(e.width)}×${Math.round(e.height)}mm`}function Cx(e,t,n){const r=e.store,o=r.selectedIds.has(t.id),i=r.previewIds.has(t.id),a=t.options,l=t.zone||"content",c=[kx(t,!0,{store:r,fire:e.fire,designData:e.host.designData})];return r.draggingIds.has(t.id)&&c.push(h("div",{class:"drag-preview"})),o&&(c.push(h("div",{class:"resize-handles"},U1.map(s=>h("div",{class:`resize-handle handle-${s}`,dataset:{point:s,elId:t.id},onMousedown:d=>e.fire("resize-start",{event:d,id:t.id,point:s})})))),c.push(h("div",{class:"selected-indicator"},[h("div",{class:"position-label",text:Rh(a)})]))),h("div",{class:["print-element",`type-${t.printElementType.type}`,`zone-${l}`,o?"selected":"",i?"previewed":"",r.draggingIds.has(t.id)?"drag-ghost":"","design-mode",a.locked?"locked":"",a.visible===!1?"hidden":""].filter(Boolean).join(" "),style:_x(t,n),dataset:{elId:t.id},onMousedown:s=>e.fire("element-mousedown",{event:s,id:t.id}),onContextmenu:s=>{s.preventDefault(),s.stopPropagation(),e.fire("contextmenu",{event:s,id:t.id})}},c)}function gl(e,t){const n=e.margins,r=e.header?.height??10,o=e.footer?.height??10,i=t.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:t.height-n.top-n.bottom-r-o},footer:{left:n.left,top:t.height-n.bottom-o,width:i,height:o}}}const Ax='<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 Dh(e,t){return e.type==="vertical"?{left:`${e.position}mm`,top:"0",height:`${t.height}mm`,borderLeftColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${e.position}mm`,left:"0",width:`${t.width}mm`,borderTopColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}}function Ox(e,t){const n=Wd(e.watermark,[],t);return n?h("div",{class:"watermark-layer",style:{opacity:String(n.opacity)}},n.tiles.map(r=>h("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`}},[h("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 ml(e,t,n,r,o,i){const a=e.store,l=[];n!=="content"&&l.push(h("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"}));const c=n==="content"?Bc(o):void 0;if(l.push(...o.map(s=>Cx(e,s,c))),n!=="content"){const s=n==="header"?"bottom":"top";l.push(h("div",{class:`zone-resize-handle handle-${s}`,dataset:{zone:n},onMousedown:d=>e.fire("zone-resize",{event:d,zone:n})},[t.zoneResizing===n?h("div",{class:"zone-height-tip",text:`${(n==="header"?a.templateData.header.height:a.templateData.footer.height).toFixed(1)}mm`}):""]))}return h("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 Ix(e){const t=e.currentTarget,n=e.dataTransfer?.types??[],r=n.includes("fieldkey"),o=n.includes("elementtype");if(!r&&!o){t.querySelector(".drop-hint")?.remove();return}r&&(e.ctrlKey||e.metaKey)&&(t.dataset.dropLabelIntent="1");const i=o?"+ 元素":t.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let a=t.querySelector(".drop-hint");a||(a=document.createElement("div"),a.className="drop-hint",t.appendChild(a)),a.textContent=i,a.style.left=`${e.clientX+14}px`,a.style.top=`${e.clientY+18}px`}function $h(e){e&&(e.querySelector(".drop-hint")?.remove(),delete e.dataset.dropLabelIntent)}function Px(e,t){const n=e.store,r=n.templateData,o=ht(r),i=(n.scale||100)/100,a=gl(r,o),l=p=>n.elements.filter(u=>(u.zone||"content")===p),c=h("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?h("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(Ax)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[Ox(r,o)]:[],ml(e,t,"header",a.header,l("header"),o),ml(e,t,"content",a.content,l("content"),o),ml(e,t,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>h("div",{class:`adsorb-guide guide-${p.type}`,style:Dh(p,o)})),...(r.guides??[]).map(p=>h("div",{class:`manual-guide guide-${p.type}`,style:{...Dh(p,o),"--guide-hit":`${8/i}px`},dataset:{guideId:String(p.id??"")},onMousedown:u=>e.fire("guide-mousedown",{event:u,id:p.id}),onDblclick:u=>{u.preventDefault(),e.fire("guide-remove",p.id)}}))].filter(Boolean)),s=h("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?[h("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)`:""}},[h("img",{src:r.designBackground.src,draggable:!1,alt:""})])]:[],c]),d=[h("div",{class:"canvas-scroll"},[h("div",{class:"paper-wrapper",style:{width:`${Fo(o.width)*i}px`,height:`${Fo(o.height)*i}px`,position:"relative"}},[s])])];if(n.showRuler&&d.push(h("div",{class:"ruler-overlay",style:{transform:`translate(${t.scrollX}px, ${t.scrollY}px)`}},[h("div",{class:"ruler-corner"}),h("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${t.geom.viewW}px`,height:"20px"},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"horizontal"})}),h("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${t.geom.viewH}px`},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"vertical"})})])),t.guidePreview&&d.push(h("div",{class:`ruler-guide-preview guide-${t.guidePreview.type}`,style:t.guidePreview.type==="vertical"?{left:`${t.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${t.guidePreview.position}px`,left:"0",width:"100%"}})),t.marquee.visible&&d.push(h("div",{class:"marquee-selection",style:{left:`${t.marquee.x}px`,top:`${t.marquee.y}px`,width:`${t.marquee.w}px`,height:`${t.marquee.h}px`}})),t.contextMenu.visible){const p=t.contextMenu;d.push(h("div",{class:"context-menu",style:{left:`${t.contextMenu.x+t.contextMenu.flipX}px`,top:`${t.contextMenu.y+t.contextMenu.flipY}px`}},t.contextMenu.targetId?[_t(e,p,"复制","copy"),_t(e,p,"剪切","cut"),_t(e,p,"粘贴","paste",!n.hasClipboard),_t(e,p,"删除","delete"),h("div",{class:"context-menu-sep"}),_t(e,p,"置顶","move-layer",!1,"top"),_t(e,p,"上移","move-layer",!1,"up"),_t(e,p,"下移","move-layer",!1,"down"),_t(e,p,"置底","move-layer",!1,"bottom")]:[_t(e,p,"粘贴","paste-at",!n.hasClipboard),_t(e,p,"全选","select-all"),_t(e,p,"取消选择","clear-selection")]))}return h("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:p=>{const u=p;u.preventDefault(),u.dataTransfer&&(u.dataTransfer.dropEffect="copy"),Ix(u)},onDragleave:p=>{const u=p.currentTarget,f=p.relatedTarget;(!f||!u.contains(f))&&u.querySelector(".drop-hint")?.remove()},onDrop:p=>{const u=p,f=p.currentTarget,g=f.dataset.dropLabelIntent==="1";$h(f),g&&(u.labelIntent=!0),e.fire("drop",u)},onMousedown:p=>e.fire("canvas-mousedown",p),onMousemove:p=>e.fire("canvas-mousemove",p),onMouseleave:()=>e.fire("canvas-mouseleave"),onWheel:p=>e.fire("wheel",p),onScroll:p=>e.fire("scroll",p),onContextmenu:p=>{p.preventDefault(),e.fire("canvas-contextmenu",p)}},d.filter(Boolean))}function _t(e,t,n,r,o=!1,i){return h("div",{class:`context-menu-item${o?" disabled":""}`,text:n,onClick:()=>{t.visible=!1,o||e.fire(r,i),e.repaint()}})}const Rx={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" />',Barcode:'<path d="M3 5v14" /><path d="M8 5v14" /><path d="M12 5v14" /><path d="M17 5v14" /><path d="M21 5v14" />',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" />',ChartArea:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z" />',ChartBar:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 16h8" /><path d="M7 11h12" /><path d="M7 6h3" />',ChartColumn:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M18 17V9" /><path d="M13 17V5" /><path d="M8 17v-3" />',ChartLine:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="m19 9-5 5-4-4-3 3" />',ChartPie:'<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z" /><path d="M21.21 15.89A10 10 0 1 1 8 2.83" />',ChartScatter:'<circle cx="7.5" cy="7.5" r=".5" fill="currentColor" /><circle cx="18.5" cy="5.5" r=".5" fill="currentColor" /><circle cx="11.5" cy="11.5" r=".5" fill="currentColor" /><circle cx="7.5" cy="16.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="14.5" r=".5" fill="currentColor" /><path d="M3 3v16a2 2 0 0 0 2 2h16" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsLeft:'<path d="m11 17-5-5 5-5" /><path d="m18 17-5-5 5-5" />',ChevronsRight:'<path d="m6 17 5-5-5-5" /><path d="m13 17 5-5-5-5" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',Circle:'<circle cx="12" cy="12" r="10" />',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" />',Code:'<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />',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" />',Donut:'<path d="M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3" /><circle cx="12" cy="12" r="3" />',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" />',FileText:'<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 9H8" /><path d="M16 13H8" /><path d="M16 17H8" />',Funnel:'<path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" />',Gauge:'<path d="m12 14 4-4" /><path d="M3.34 19a10 10 0 1 1 17.32 0" />',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" />',Image:'<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />',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" />',List:'<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />',ListTree:'<path d="M8 5h13" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="M3 10a2 2 0 0 0 2 2h3" /><path d="M3 5v12a2 2 0 0 0 2 2h3" />',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" />',Minus:'<path d="M5 12h14" />',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" />',QrCode:'<rect width="5" height="5" x="3" y="3" rx="1" /><rect width="5" height="5" x="16" y="3" rx="1" /><rect width="5" height="5" x="3" y="16" rx="1" /><path d="M21 16h-3a2 2 0 0 0-2 2v3" /><path d="M21 21v.01" /><path d="M12 7v3a2 2 0 0 1-2 2H7" /><path d="M3 12h.01" /><path d="M12 3h.01" /><path d="M12 16v.01" /><path d="M16 12h1" /><path d="M21 12v.01" /><path d="M12 21v-1" />',Radar:'<path d="M19.07 4.93A10 10 0 0 0 6.99 3.34" /><path d="M4 6h.01" /><path d="M2.29 9.62A10 10 0 1 0 21.31 8.35" /><path d="M16.24 7.76A6 6 0 1 0 8.23 16.67" /><path d="M12 18h.01" /><path d="M17.99 11.66A6 6 0 0 1 15.77 16.67" /><circle cx="12" cy="12" r="2" /><path d="m13.41 10.59 5.66-5.66" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',SeparatorVertical:'<path d="M12 3v18" /><path d="m16 16 4-4-4-4" /><path d="m8 8-4 4 4 4" />',Shapes:'<path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z" /><rect x="3" y="14" width="7" height="7" rx="1" /><circle cx="17.5" cy="17.5" r="3.5" />',Square:'<rect width="18" height="18" x="3" y="3" rx="2" />',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" />',Table:'<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />',Table2:'<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18" />',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" />',Type:'<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />',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 Re(e,t=15,n){const r=Rx[e];return r?`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"${n?` class="${n}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`:""}let kn=null;function bl(e){const t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;const n=t[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 yl(e){const t=bl(e);return t?Nh(t):"#000000"}function Nh({r:e,g:t,b:n}){return`#${[e,t,n].map(r=>Math.round(Xr(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function Dx(e,t,n){const r=e/255,o=t/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 $x(e,t,n){const r=n*t,o=(e%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 Nx(e){return((Number.isFinite(e)?e:0)%360+360)%360}function Xr(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:0))}function Lx(e){const t=e.title??"颜色选择";return h("button",{type:"button",class:`preset-color-trigger${e.triggerClass?` ${e.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:t,onClick:n=>{const r=n.currentTarget??n.target,o=r.getRootNode();if(!!kn&&kn.root===o&&kn.title===t&&kn.trigger===r){Zr();return}Zr(),Fx(r,e)}},[h("span",{class:"preset-color-swatch",style:e.value?{background:e.value}:{background:"transparent"}})])}function Zr(){const e=kn;e&&(kn=null,e.teardowns.forEach(t=>t()),e.trigger.setAttribute("aria-expanded","false"),e.panel.remove())}function Fx(e,t){const n=e.getRootNode(),r=n instanceof ShadowRoot?n:document.body,o={root:n,title:t.title??"颜色选择",trigger:e,panel:null,clearable:t.clearable!==!1,onChange:t.onChange,model:t.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:[]};t.value&&wl(o,t.value)?o.hexText=yl(t.value).toUpperCase():o.hexText=t.value?String(t.value):"",o.panel=Ze(Ux(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:ld[a]})),Bi(o),zx(o),Bx(o),kn=o,e.setAttribute("aria-expanded","true")}function zx(e){const t=e.trigger.getBoundingClientRect(),n=190,r=e.panel.offsetHeight||216,o=8,i=Math.max(o,Math.min(t.left,window.innerWidth-n-o)),a=t.bottom+6,l=a+r>window.innerHeight-o?Math.max(o,t.top-r-6):a;e.panel.style.left=`${i}px`,e.panel.style.top=`${l}px`}function Bx(e){const t=o=>{const i=Hx(o);i.includes(e.trigger)||i.includes(e.panel)||Zr()},n=o=>{o.key==="Escape"&&Zr()},r=()=>Zr();document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",n),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),e.root.addEventListener("scroll",r,!0),e.teardowns.push(()=>document.removeEventListener("pointerdown",t,!0),()=>document.removeEventListener("keydown",n),()=>window.removeEventListener("scroll",r,!0),()=>window.removeEventListener("resize",r),()=>e.root.removeEventListener("scroll",r,!0))}function Hx(e){const t=typeof e.composedPath=="function"?e.composedPath():[];return t.length?t:[e.target]}function Ux(e){return h("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:t=>t.stopPropagation()},[h("div",{class:"picker-preview"},[h("span",{class:"picker-current"}),h("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:t=>Wx(e,t.target.value)})]),h("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:t=>jx(e,t),onKeydown:t=>Gx(e,t)},[h("span",{class:"picker-handle"})]),h("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:t=>Vx(e,Number(t.target.value)),onChange:()=>xl(e)}),h("div",{class:"picker-heading"},[h("span",{text:"常用颜色"}),e.clearable?h("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Hi(e,void 0)},[h("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[h("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),h("div",{class:"preset-color-grid"},ld.map(t=>h("button",{type:"button",class:"preset-color-item",style:{background:t},title:t,"aria-label":t,onClick:()=>qx(e,t)})))])}function vl(e){return Nh($x(e.hue,e.saturation,e.value_))}function Bi(e){const t=vl(e);e.hex.value!==e.hexText&&(e.hex.value=e.hexText),e.current.className=e.model?"picker-current":"picker-current is-empty",e.model?e.current.style.background=t:e.current.style.removeProperty("background"),e.area.style.setProperty("--picker-hue",`${Math.round(e.hue)}deg`),e.handle.style.left=`${e.saturation*100}%`,e.handle.style.top=`${(1-e.value_)*100}%`,e.handle.style.background=t;const n=String(Math.round(e.hue));e.hueRange.value!==n&&(e.hueRange.value=n),e.clearBtn&&(e.clearBtn.disabled=!e.model);for(const r of e.items)r.el.className=e.model&&r.color.toLowerCase()===e.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function wl(e,t){const n=bl(t);if(!n)return!1;const r=Dx(n.r,n.g,n.b);return e.hue=r.h,e.saturation=r.s,e.value_=r.v,e.hexText=yl(t).toUpperCase(),!0}function Jn(e,t,n,r){e.hue=Nx(t),e.saturation=Xr(n),e.value_=Xr(r),e.hexText=vl(e).toUpperCase(),Bi(e)}function xl(e){const t=vl(e);e.model=t,Bi(e),e.onChange(t)}function Hi(e,t){e.model=t,t||(e.hexText=""),Bi(e),e.onChange(t)}function qx(e,t){wl(e,t),Hi(e,t)}function Wx(e,t){const n=t.trim();if(!n){e.clearable&&Hi(e,void 0);return}bl(n)&&(wl(e,n),Hi(e,yl(n)))}function jx(e,t){e.dragging=!0,Lh(e,t);const n=o=>{e.dragging&&Lh(e,o)},r=()=>{e.dragging&&(e.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),xl(e))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function Lh(e,t){const n=e.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=Xr((t.clientX-n.left)/n.width),o=Xr(1-(t.clientY-n.top)/n.height);Jn(e,e.hue,r,o)}function Gx(e,t){const n=t.shiftKey?.1:.02;let r=!0;t.key==="ArrowLeft"?Jn(e,e.hue,e.saturation-n,e.value_):t.key==="ArrowRight"?Jn(e,e.hue,e.saturation+n,e.value_):t.key==="ArrowUp"?Jn(e,e.hue,e.saturation,e.value_+n):t.key==="ArrowDown"?Jn(e,e.hue,e.saturation,e.value_-n):r=!1,r&&(t.preventDefault(),xl(e))}function Vx(e,t){Jn(e,t,e.saturation,e.value_)}function _e(e,t,n,r){return h("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:()=>e.fire(n,r.arg),html:Re(t)})}function Ui(e,t,n,r){const o=e.state.openDd===t,i=()=>{e.state.openDd=o?null:t,e.repaint()};return h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${o?" on":""}`,disabled:!!n.disabled,dataset:{test:n.testId??t,tip:n.tip},onClick:i,html:`${n.icon?Re(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${Re("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?h("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function J(e){const t=e.step??1,n=String(t),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 e.min!==void 0&&u<e.min&&(u=e.min),e.max!==void 0&&u>e.max&&(u=e.max),u},l=e.value===void 0||e.value===null||!Number.isFinite(e.value)?void 0:i(e.value),c=l??e.min??0,s=p=>{p!==l&&e.onCommit(p)},d=h("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:e.min,max:e.max,step:t,placeholder:e.placeholder,disabled:!!e.disabled,onChange:p=>{const u=p.target,f=(u.value??"").trim();if(f===""){l!==void 0&&(u.value=String(l));return}const g=Number(f);if(!Number.isFinite(g)){u.value=l===void 0?"":String(l);return}const m=a(g);u.value=String(m),s(m)}});return h("div",{class:"pd-stepper"},[h("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!e.disabled||c<=(e.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>s(a(c-t))}),d,h("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!e.disabled||c>=(e.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>s(a(c+t))})])}function se(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),r??""]),t,n?h("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const El=e=>h("button",{class:"pd-help",type:"button","data-tip":e,"aria-label":"字段说明"});function He(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[e,El(n)]),r??""]),t])}function Cn(e){const t=e.base?.[e.propKey],n=e.target?.[e.propKey]!==t,r=e.force===!0||n,o=e.tipOverride??(e.tipValue===void 0?"恢复默认值":`恢复默认值(${e.tipValue}${e.tipUnit?" "+e.tipUnit:""})`),i=e.force?`${o}(应用到全部选中格)`:o;return h("button",{type:"button",class:`pd-reset-btn${n&&!e.force?" is-dirty":""}`,"data-tip":i,"aria-label":i,html:Re("RotateCcw",13),onClick:()=>{r&&(e.write?e.write(t):e.target[e.propKey]=t,e.onReset?.())}})}const $t=e=>h("h3",{class:"pd-divider",text:e});function ot(e,t,n="颜色选择",r){return Lx({value:e,title:n,triggerClass:r,onChange:o=>t(o)})}function on(e,t,n,r,o=!1){return h("div",{class:`pd-radio-group${o?" pd-radio-group--2col":""}`,role:"radiogroup"},t.map(i=>h("label",{class:"pd-radio"},[h("input",{type:"radio",name:e,value:i.value,checked:n===i.value,onChange:()=>r(i.value)}),h("span",{text:i.label})])))}function Fh(e,t,n,r={}){const o=document.createElement("select");o.className=r.className??"pd-select",r.width&&(o.style.width=r.width);for(const i of t){const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.disabled&&(a.disabled=!0),o.appendChild(a)}return o.value=e,t.some(i=>i.value===e)||(o.selectedIndex=-1),o.addEventListener("change",()=>n(o.value)),o}function Yx(e){const t=window.innerHeight;for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){const r=getComputedStyle(n).overflowY;if(r==="auto"||r==="scroll"||r==="hidden"||r==="clip"){const o=n.getBoundingClientRect();return{top:Math.max(0,o.top),bottom:Math.min(t,o.bottom)}}}return{top:0,bottom:t}}function qi(e){const t=eb(e.fonts),n=e.placeholder??"默认",r=`font-select-list-${e.id}`,o=O=>{const C=O?.trim();return C?Id(t,C)?.label??C:""},i=O=>{const C=Tr(O);return t.find(S=>S.label&&Tr(S.label)===C)?.family??O},a=()=>{const O=e.value?.trim();return O?Id(t,O)?"":O:""},l=O=>{const C=(e.value??"").trim(),I=(N,z,T,ie)=>({kind:N,key:z,label:T,value:ie,selected:(ie??"")===C}),S=O.trim();if(!S){const N=[I("clear","__clear__",n)],z=a();z&&N.push(I("unknown","__unknown__",`${z}(未知)`,z));for(const T of t)N.push(I("font",T.family,Pd(T),T.family));return N}const $=nb(t,S).map(N=>I("font",N.family,Pd(N),N.family));if(!$.length){const N=i(S);$.push(I("free","__free__",`使用「${N}」`,N))}return $},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=!!e.disabled,s.value=o(e.value);const d=document.createElement("ul");d.id=r,d.className="font-select-list",d.setAttribute("role","listbox");const p=e.state.fontOpen?.id===e.id?e.state.fontOpen:null,u={open:!!p&&!e.disabled,query:p?.query??"",highlighted:p?.highlighted??-1};u.open&&(s.value=u.query);const f=()=>{e.state.fontOpen=u.open?{id:e.id,query:u.query,highlighted:u.highlighted}:null};f();const g=()=>{const O=(e.value??"").trim();return l(u.query).findIndex(C=>(C.value??"")===O)},m=()=>{const O=s.getBoundingClientRect(),C=Yx(s);d.classList.toggle("is-up",Nm({triggerTop:O.top,triggerBottom:O.bottom,overlayHeight:d.getBoundingClientRect().height,boundaryTop:C.top,boundaryBottom:C.bottom})==="up")},b=()=>{if(!u.open){d.isConnected&&d.remove(),s.setAttribute("aria-expanded","false"),s.setAttribute("aria-activedescendant","");return}d.isConnected||c.appendChild(d);const O=l(u.query);d.replaceChildren(...O.map((C,I)=>{const S=document.createElement("li");return S.id=`${r}-${I}`,S.className="font-select-option"+(I===u.highlighted?" is-active":"")+(C.kind==="unknown"||C.kind==="free"?" is-muted":""),S.setAttribute("role","option"),S.setAttribute("aria-selected",String(C.selected)),S.textContent=C.label,S.addEventListener("mousedown",$=>{$.preventDefault(),R(C)}),S})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:""),m()},v=()=>{u.open||e.disabled||(u.open=!0,u.query="",u.highlighted=g(),f(),b())},w=()=>{u.open||v()},E=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),b()},k=O=>{if(!u.open){v();return}const C=l(u.query).length-1;if(C<0)return;u.highlighted=Math.min(Math.max(u.highlighted+O,0),C),f(),b(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},L=()=>{if(!u.open)return;const O=l(u.query)[u.highlighted];if(O){R(O);return}const C=u.query.trim();if(C){const I=i(C);R({value:I})}},R=O=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(O.value),b(),e.onChange(O.value)},P=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(e.value),b())};return s.addEventListener("focus",v),s.addEventListener("click",w),s.addEventListener("input",E),s.addEventListener("blur",P),s.addEventListener("keydown",O=>{const C=O;C.key==="ArrowDown"?(C.preventDefault(),k(1)):C.key==="ArrowUp"?(C.preventDefault(),k(-1)):C.key==="Enter"?(C.preventDefault(),L()):C.key==="Escape"&&(C.preventDefault(),P())}),c.append(s),b(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const Kx=[{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"}],Xx={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function an(e,t,n,r,o={}){return h("button",{type:"button",class:`ft-cell-btn${o.on?" on":""}`,dataset:{test:e,tip:t},disabled:!!o.disabled,onClick:r,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${n}</svg>`})}const Qn='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',zh='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Zx(e){const t=e.format;t.syncBorderDraft();const n=t.values,r=!t.fontEditable,o=r||t.context==="cells",i=t.context==="none",a=t.context==="cells",l=!t.painterActive&&(t.context==="none"||t.context==="cells"||!t.painterCapturable),c=t.painterActive?"退出格式刷(Esc)":t.context==="cells"?"格式刷(表格单元格暂不支持)":t.context==="none"?"格式刷(需选中元素)":t.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",s=u=>r?`${u}(需选中文本元素)`:u,d=[h("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[h("div",{class:"ft-border-grid"},[an("preset-none","无边框",`${Qn}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>t.applyBorderPreset("none")),an("preset-all","所有边框",`${zh}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("all")),an("preset-outer","外侧边框",zh,()=>t.applyBorderPreset("outer")),an("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${Qn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("inner"),{disabled:!a}),an("edge-top","上边框",`${Qn}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>t.applyEdge("top"),{on:t.edgeOn("top")}),an("edge-bottom","下边框",`${Qn}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>t.applyEdge("bottom"),{on:t.edgeOn("bottom")}),an("edge-left","左边框",`${Qn}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>t.applyEdge("left"),{on:t.edgeOn("left")}),an("edge-right","右边框",`${Qn}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>t.applyEdge("right"),{on:t.edgeOn("right")})]),h("div",{class:"ft-style-row"},Kx.map(u=>h("button",{type:"button",class:`ft-style-btn${t.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:t.borderStyle===u.key?`${u.label}(再点一次取消,线型=无)`:u.label},onClick:()=>{t.toggleBorderStyle(u.key),e.repaint()}},[h("span",{class:"ft-style-line",style:{borderTop:u.preview}})]))),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"粗细"}),h("div",{class:"ft-line-width"},[J({value:t.borderWidth,min:.25,max:5,step:.25,placeholder:t.borderMixed.width?"混合":void 0,onCommit:u=>{t.setBorderWidth(u),e.repaint()}})])]),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"颜色"}),ot(t.borderColor,u=>{t.setBorderColor(u),e.repaint()},"边框颜色")]),t.borderMixedAny?h("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],p=[h("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[h("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([u,f,g])=>h("button",{type:"button",class:`ft-cell-btn${n.textAlign===u?" on":""}`,dataset:{test:`align-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({textAlign:u}),html:Re(g)}))),h("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([u,f,g])=>h("button",{type:"button",class:`ft-cell-btn${n.verticalAlign===u?" on":""}`,dataset:{test:`valign-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({verticalAlign:u}),html:Re(g)})))])];return h("div",{class:"format-toolbar"},[h("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[h("button",{type:"button",class:`ft-btn${t.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{t.painterActive?t.cancelPainter():t.pickPainterSource(!1),e.repaint()},onDblclick:()=>{t.pickPainterSource(!0),e.repaint()},html:Re("Paintbrush")})]),h("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[h("div",{class:"ft-font"},[qi({id:"ft-font",state:e.state,fonts:e.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===_n?"混合":"默认",disabled:r,onChange:u=>t.applyStyle({fontFamily:u})})]),h("div",{class:"ft-size",dataset:{test:"font-size"}},[J({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===_n?"混合":"默认",onCommit:u=>t.applyStyle({fontSize:u})})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>t.toggleBold()],["underline","Underline","下划线",()=>t.toggleUnderline()],["strike","Strikethrough","删除线",()=>t.toggleStrike()]].map(([u,f,g,m])=>h("button",{type:"button",class:`ft-btn${n[u]===!0?" on":""}`,dataset:{test:u,tip:s(g)},disabled:u==="bold"?r:o,onClick:m,html:Re(f)}))]),h("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[h("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[ot(typeof n.color=="string"?n.color:void 0,u=>t.applyStyle({color:u})),h("span",{class:"ft-glyph",text:"A"})]),h("span",{class:`ft-color-btn${i?" dim":""}`,title:"背景色"},[ot(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>t.applyStyle({backgroundColor:u})),h("span",{class:"ft-glyph",html:Re("PaintBucket",14)})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[Ui(e,"align",{icon:Xx[String(n.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:r?"对齐(需选中文本元素或单元格)":"对齐",disabled:r,testId:"align-dd"},p)]),h("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[Ui(e,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const Jx="1.5.3";Ii.filter(e=>e.material).map(e=>({type:e.type,label:e.label,icon:e.icon}));function Wi(e,t){return Re(e??"Shapes",t)||Re("Shapes",t)}function Qx(e){const t=e.state;if(t.leftCollapsed)return h("div",{class:"left-panel collapsed"},[h("div",{class:"left-collapsed"},[Bh("ChevronsRight","展开素材台",()=>{t.leftCollapsed=!1,e.repaint()}),...[["elements","元素","Table2"],["fields","字段","ListTree"],["layers","图层","Layers"]].map(([r,o,i])=>h("button",{type:"button",class:`lc-btn${t.leftTab===r?" on":""}`,title:o,html:Wi(i,14),onClick:()=>{t.leftTab=r,t.leftCollapsed=!1,e.repaint()}}))])]);const n=(r,o,i="")=>h("div",{class:`pd-tab-pane${i?` ${i}`:""}`,role:"tabpanel",dataset:{pane:`left:${r}`},style:t.leftTab===r?"":{display:"none"}},o);return h("div",{class:"left-panel"},[h("div",{class:"left-head"},[h("span",{class:"left-title",text:"素材台"}),Bh("ChevronsLeft","收起素材台",()=>{t.leftCollapsed=!0,e.repaint()})]),h("div",{class:"pd-tabs left-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([r,o])=>h("button",{type:"button",class:`pd-tab${t.leftTab===r?" active":""}`,text:o,onClick:()=>{t.leftTab=r,e.repaint()}}))]),n("elements",t2(),"material-grid"),n("fields",[n2(e)]),n("layers",[r2(e)])])])}function Bh(e,t,n){return h("button",{type:"button",class:"collapse-btn",title:t,html:Wi(e,14),onClick:n})}function e2(e,t,n){return h("div",{class:`material-card${w0(t)?" material-card--wide":""}`,draggable:!0,dataset:{test:`material-${e}`},onDragstart:r=>{const o=r.dataTransfer;o?.setData("elementType",e),o&&(o.effectAllowed="all")}},[h("span",{class:"material-icon","data-icon":n,html:Wi(n,14)}),h("span",{class:"material-label",text:t})])}function t2(){const e=[];let t;for(const n of Ff()){const r=n.group;r&&r!==t&&e.push(h("div",{class:"material-group-title",text:r})),r&&(t=r),e.push(e2(n.type,n.label,n.icon))}return[h("div",{class:"panel-title",text:"拖拽元素到画布"}),...e]}function n2(e){const t=e.state,n=Tu(e.store.fields),r=(t.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 h("div",{class:"field-tree-panel"},[h("div",{class:"panel-title",text:"业务字段"}),h("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:t.fieldSearch??"",onInput:i=>{t.fieldSearch=i.target.value},onChange:()=>e.repaint()}),h("div",{class:"tree-container"},o.flatMap(i=>{const a=t.collapsedGroups.has(i.key)&&!r,l=i.key?h("div",{class:`field-group-header${i.isList?" is-list":""}`,onClick:()=>{a?t.collapsedGroups.delete(i.key):t.collapsedGroups.add(i.key),e.repaint()}},[h("span",{class:"expand-icon",text:a?"▶":"▼"}),h("span",{class:"node-icon",text:i.isList?"📋":"📁"}),h("span",{class:"group-label",text:i.label,"data-tip":i.label})]):"",c=a?[]:i.fields.map(s=>h("div",{class:"field-row",draggable:!0,"data-tip":`${s.fieldLabel} (${s.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${i.key?22:8}px`},onDragstart:d=>{const p=d.dataTransfer;p?.setData("fieldKey",s.fieldKey),p&&(p.effectAllowed="all")},onClick:()=>{ku(s.fieldLabel||s.fieldKey).then(d=>{d&&(t.copiedFieldKey=s.fieldKey,e.repaint(),setTimeout(()=>{t.copiedFieldKey===s.fieldKey&&(t.copiedFieldKey="",e.repaint())},1200))})}},[h("span",{class:"node-icon",text:"📄"}),h("span",{class:"node-meta"},[h("span",{class:"node-label",text:s.fieldLabel}),h("span",{class:"node-key",text:`(${s.fieldKey})`})]),t.copiedFieldKey===s.fieldKey?h("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[l,h("div",{},c.filter(Boolean))].filter(Boolean)})),o.length===0?h("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function r2(e){const t=e.store,n=[...t.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),r=t.elements.filter(l=>t.selectedIds.has(l.id)),o=r.length>=2,i=r.some(l=>!!l.options.groupId),a=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return h("div",{class:"layer-panel"},[h("div",{class:"panel-title",text:"图层"}),...n.map(l=>{const c=Hf(l.printElementType.type);return h("div",{class:`layer-item${t.selectedIds.has(l.id)?" active":""}`,onClick:s=>t.selectElement(l.id,s.ctrlKey||s.metaKey)},[h("span",{class:"layer-icon","data-icon":c??"Shapes",html:Wi(c,12)}),h("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),a(l)?h("span",{class:"layer-zone",text:a(l)}):"",h("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))}),n.length?h("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,s])=>h("button",{type:"button",class:"pd-button small",title:c,html:Re(s,14),onClick:()=>e.fire("move-layer",l)}))]):"",o||i?h("div",{class:"layer-actions"},[o?h("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:Re("Group",14),onClick:()=>e.fire("group")}):"",i?h("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:Re("Ungroup",14),onClick:()=>e.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function o2(e){const t=e.store,n=e.state,r=t.pages.length>1,o=t.pages[t.activePageIndex]?.name||`页面 ${t.activePageIndex+1}`,i=t.tilingEnabled;return h("div",{class:"page-tabs"},[h("div",{class:"page-tabs-list"},t.pages.map((l,c)=>n.renamingPage===c?h("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,e.repaint())}}):h("button",{type:"button",class:`page-tab${c===t.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>t.switchPage(c),onDblclick:()=>{n.renamingPage=c,n.renameText=l.name??"",e.repaint()}}))),h("div",{class:"page-tabs-actions"},[h("button",{type:"button",dataset:{test:"add-page",tip:i?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:i,text:"+",onClick:()=>e.fire("add-page")}),h("button",{type:"button",dataset:{test:"duplicate-page",tip:i?"拼版模板仅允许一个设计页面":`复制当前页「${o}」`},disabled:i,text:"⧉",onClick:()=>e.fire("duplicate-page")}),h("button",{type:"button",dataset:{test:"delete-page",tip:r?`删除当前页「${o}」`:"仅多页面模板可删除页面"},disabled:!r,text:"✕",onClick:()=>e.fire("delete-page")}),h("button",{type:"button",dataset:{test:"move-left",tip:`前移「${o}」`},disabled:t.activePageIndex<=0,text:"←",onClick:()=>e.fire("move-page",-1)}),h("button",{type:"button",dataset:{test:"move-right",tip:`后移「${o}」`},disabled:t.activePageIndex>=t.pages.length-1,text:"→",onClick:()=>e.fire("move-page",1)})])]);function a(){const l=(n.renameText??"").trim();n.renamingPage!==null&&l&&t.renamePage(n.renamingPage,l),n.renamingPage=null,e.repaint()}}function i2(e){const t=e.store,n=t.templateData,r=Jt(n),o=n.orientation==="landscape"?"横向":"纵向",i=Ot[n.paperSize]?.label??n.paperSize,a=n.outputRotation,l=`${i} ${o} ${Math.round(r.width)}×${Math.round(r.height)}mm${a?`(旋转${a}°)`:""}`;return h("div",{class:"status-bar"},[h("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),h("span",{class:"status-item",text:`缩放 ${t.scale}%`}),h("span",{class:"status-item",text:`元素 ${t.elements.length}${t.selectedIds.size?` (选中 ${t.selectedIds.size})`:""}`}),h("span",{class:"status-item status-version",text:`v${Jx}`}),h("span",{class:"status-item status-paper",text:l})])}const a2=Object.keys(Ot).filter(e=>e!=="CUSTOM"&&!Ot[e]?.continuous);function s2(e){const t=document.createElement("label");t.className="pd-button small upload-label";const n=document.createTextNode("上传背景图"),r=document.createElement("input");r.className="visually-hidden",r.type="file",r.accept="image/*",t.append(n,r);const o=i=>{t.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=e.host.uploadDesignBackground;if(!a){alert("设计背景上传能力未配置"),r.value="";return}o(!0),n.textContent="上传中...";try{const l=await a(i);l?e.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{n.textContent="上传背景图",o(!e.host.uploadDesignBackground),r.value=""}}),e.host.uploadDesignBackground||o(!0),t}function l2(e){const n=e.store.templateData.designBackground,r=n?.rotation??0;return h("div",{class:"design-background-config"},[$t("设计背景"),h("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),n?.src?[h("div",{class:"design-background-path",title:n.src,text:n.src}),h("div",{class:"design-background-actions"},[h("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(r+90)%360}°)`,onClick:()=>e.store.updateTemplateData({designBackground:{...n,rotation:(r+90)%360}})}),h("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>e.store.updateTemplateData({designBackground:void 0})})])]:s2(e)].flat())}function c2(e){const t=e.store,n=t.templateData,r=n.tiling,o={...Pt,...r??{},enabled:r?.enabled??!1,sheetMargin:{...Pt.sheetMargin,...r?.sheetMargin??{}}},i=_o(n.paperSize),a=g=>t.updateTemplateData({tiling:{...o,...g}}),l=g=>Cn({target:o,base:Pt,propKey:g,write:()=>a({[g]:Pt[g]})}),c=g=>Cn({target:o.sheetMargin,base:Pt.sheetMargin,propKey:g,write:()=>s(g,Pt.sheetMargin[g])}),s=(g,m)=>a({sheetMargin:{...o.sheetMargin,[g]:m??0}}),d={...n,tiling:o},p=as(d),u=Math.max(gu(d),1);let f="";if(!p.length)try{const g=hu(d),m=Ir(d),b=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",v=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";f=`目标纸 ${b}${v} ${m.width}×${m.height}mm · ${g.columns} 列 × ${g.rows} 行 = 每张 ${g.perSheet} 格 · 每格 ${g.tile.width}×${g.tile.height}mm`}catch{f=""}return h("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[$t("拼版打印"),h("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),h("div",{class:"pd-field"},[h("label",{class:"tiling-switch"},[h("input",{type:"checkbox",checked:o.enabled===!0,disabled:i,onChange:g=>{if(!g.target.checked){a({enabled:!1});return}a({...Pt,columns:Math.min(Pt.columns,Math.max(u,1))})}}),h("span",{text:"启用拼版"})]),i?h("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[se("目标纸张",h("select",{class:"pd-select",style:{width:"100%"},onChange:g=>{const m=g.target.value;if(m!=="CUSTOM"){a({sheetPaperSize:m});return}const b=Ir(d);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??b.width,sheetCustomHeight:o.sheetCustomHeight??b.height})}},[...a2.map(g=>h("option",{value:g,text:Ot[g]?.label??g,selected:(o.sheetPaperSize??"A4")===g})),h("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),o.sheetPaperSize==="CUSTOM"?se("目标纸宽高 (mm)",h("div",{class:"custom-size-grid"},[J({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:g=>a({sheetCustomWidth:g})}),h("span",{class:"custom-size-x",text:"×"}),J({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:g=>a({sheetCustomHeight:g})})])):se("目标纸方向",on("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",g=>a({sheetOrientation:g})),void 0,l("sheetOrientation")),$t("拼版留白 (mm)"),h("div",{class:"margin-grid"},[se("上",J({value:o.sheetMargin.top??0,min:0,max:100,onCommit:g=>s("top",g)}),void 0,c("top")),se("下",J({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:g=>s("bottom",g)}),void 0,c("bottom")),se("左",J({value:o.sheetMargin.left??0,min:0,max:100,onCommit:g=>s("left",g)}),void 0,c("left")),se("右",J({value:o.sheetMargin.right??0,min:0,max:100,onCommit:g=>s("right",g)}),void 0,c("right"))]),$t("格间距与列数"),se("横向间距",J({value:o.gapX??0,min:0,max:50,onCommit:g=>a({gapX:g??0})}),void 0,l("gapX")),se("纵向间距",J({value:o.gapY??0,min:0,max:50,onCommit:g=>a({gapY:g??0})}),void 0,l("gapY")),se("列数",J({value:o.columns??1,min:1,max:u,onCommit:g=>a({columns:g||1})})),...p.map(g=>h("p",{class:"pd-hint tiling-error",text:g.message})),!p.length&&f?h("p",{class:"pd-hint tiling-summary",text:f}):""]:""].flat().filter(Boolean))}const d2=new Set(Mo.map(e=>e.group)),u2={"table-settings":"content"},Hh=new Map;function Sl(e){const t=e??"";let n=Hh.get(t);if(!n){const{groups:r,itemKeys:o}=m0(t);n={groups:r,keys:o,searching:!!t.trim()},Hh.set(t,n)}return n}function _l(e){const t=u2[e]??e;return d2.has(t)?t:""}function p2(e,t){const n=Sl(e.state.propSearch);if(!n.searching)return!0;const r=_l(t);return!r||n.groups.includes(r)}function f2(e,t){const n=Sl(e.state.propSearch);return!n.searching||n.keys.has(t)}function Uh(e,t){const n=e.props.style??{};return e.props.style={...n,display:t?"":"none"},e}function W(e,t,n){const r=n.props.dataset??{};return n.props.dataset={...r,propKey:t},Uh(n,f2(e,t))}function h2(e,t,n){const r=_l(t);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},Uh(n,p2(e,t))}function qh(e,t){const n=Sl(t);for(const r of Array.from(e.querySelectorAll("[data-prop-group]"))){const o=_l(r.dataset.propGroup??"");r.style.display=!n.searching||!o||n.groups.includes(o)?"":"none"}for(const r of Array.from(e.querySelectorAll("[data-prop-key]")))r.style.display=!n.searching||n.keys.has(r.dataset.propKey??"")?"":"none"}function g2(e){return h("div",{class:"property-search"},[h("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:e.state.propSearch??"",onInput:t=>{const n=t.target,r=n.value;e.state.propSearch=r,qh(n.getRootNode(),r)}})])}const m2={Document:"≡",Brush:"◧",Setting:"⚙"};function b2(e,t){try{const n=window.localStorage.getItem(`property-group-${e}`);return n===null?t:n==="true"}catch{return t}}function y2(e,t){try{window.localStorage.setItem(`property-group-${e}`,String(t))}catch{}}function Qe(e,t,n,r,o,i=!0,a=[]){const l=b2(t,i);return h2(e,t,h("div",{class:`property-group${l?" is-expanded":""}`},[h("div",{class:"group-header",onClick:()=>{y2(t,!l),e.repaint()}},[h("span",{class:"group-icon",text:m2[r]||"•"}),h("span",{class:"group-title",text:n}),...a,h("span",{class:"expand-icon",text:l?"▾":"▸"})]),h("div",{class:"group-content",style:l?"":{display:"none"}},o.filter(Boolean))]))}function ji(e){return h("form",{class:"pd-form",onSubmit:t=>t.preventDefault()},e.filter(Boolean))}function Wh(e){return e.split(".").flatMap(t=>{const n=t.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!n)return[t];const r=n[1],o=[...n[2].matchAll(/\[(\d+)\]/g)].map(i=>Number(i[1]));return[r,...o]})}function jh(e,t){return Wh(t).reduce((o,i)=>o==null?"":o[i],e)??""}function Ml(e,t,n,r){const o=Wh(n),i=o.pop(),a=o.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),t);a[i]=r||void 0,e.recordHistory(),e.emit()}function v2(e,t){const n=e.store;if(t.printElementType.type==="table"&&n.tableSelection?.elementId===t.id){const{r1:r,c1:o}=n.tableSelection,i=(t.options.tableRows??[])[r];if(i)return Cu(i.type,r,o,t.options.fields?.[0]?.dataSource)}return N1(t)}function w2(e,t){const n=document.createElement("label");n.className="pd-button small upload-label",Ze(h("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[h("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=e.host.uploadImage;if(!s){alert("图片上传能力未配置"),o.value="";return}i(!0),r.textContent="上传中...";try{const d=await s(c);d?Ml(e.store,t,"options.src",d):alert("图片上传失败")}catch(d){alert(d instanceof Error?d.message:"图片上传失败")}finally{r.textContent="上传图片",i(!e.host.uploadImage),o.value=""}}),e.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 x2(e,t){const n=r=>e.fire("open-expression",{elementId:t.id,targetPath:r.targetPath,value:jh(t,r.targetPath)});return Qe(e,"binding","内容","Document",[...v2(e,t).map(r=>se(r.label,h("input",{class:"pd-input",type:"text",value:jh(t,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>Ml(e.store,t,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),t.printElementType.type==="image"?w2(e,t):""].filter(Boolean))}const Jr=new Map;function Gi(e){return`${Math.round(e*1e4)/1e4}%`}function Gh(e,t){const n=S1(t.value),r=n.kind==="custom",o=n.kind==="axes"?n.x:50,i=n.kind==="axes"?n.y:50,a=A1(t.src),l=Jr.get(a.src),c={widthMm:t.widthMm,heightMm:t.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:t.fit,scalePct:t.scale},s=_1(c),d=M1(c,o,i),p=document.createElement("select");p.className="pd-select",p.style.width="100%";for(const m of R1(s,o,i)){const b=document.createElement("option");b.value=m.value,b.textContent=m.label,p.appendChild(b)}if(r){const m=document.createElement("option");m.value="custom",m.textContent="自定义(保留原值)",p.appendChild(m)}p.value=r?"custom":`${o},${i}`,p.selectedIndex<0&&(p.selectedIndex=r?p.options.length-1:0),p.addEventListener("change",()=>{if(p.value==="custom")return;const[m,b]=p.value.split(",").map(Number);t.onCommit(wu(m,b))});const u=Ae(t.fieldKey),f=[h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[t.label,El(u)]),t.resetAnchor??""].filter(Boolean)),p])];f.push(h("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[O1,El(Ae("ap-img-fit-scale"))]),t.resetScale??""].filter(Boolean)),J({value:t.scale,min:gr,max:Ic,step:5,placeholder:"默认 100",onCommit:m=>t.onScaleCommit(m>gr?m:void 0)})]));for(const m of P1(s,o,i))f.push(h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label",text:m.label}),J({value:m.value,min:0,max:100,step:1,onCommit:b=>t.onCommit(wu(m.name==="horizontal"?b:o,m.name==="vertical"?b:i))})]));const g=I1(s,r);return g&&f.push(h("p",{class:"pd-crop-note",text:g})),a.isSample&&f.push(h("p",{class:"pd-crop-note",text:C1})),f.push(h("div",{class:"pd-crop-preview"},[h("img",{class:"pd-crop-thumb",src:a.src,alt:a.isSample?"示例图":"原图",onLoad:m=>{const b=m.target;if(!(b.naturalWidth>0&&b.naturalHeight>0))return;const v=Jr.get(a.src);v&&v.width===b.naturalWidth&&v.height===b.naturalHeight||(Jr.set(a.src,{width:b.naturalWidth,height:b.naturalHeight}),e.repaint())},onError:()=>{Jr.has(a.src)&&(Jr.delete(a.src),e.repaint())}}),d?h("div",{class:"pd-crop-win",style:{left:Gi(d.leftPct),top:Gi(d.topPct),width:Gi(d.widthPct),height:Gi(d.heightPct)}}):""])),h("div",{class:t.containerClass??"pd-crop-anchor"},f)}const An=e=>Number(e??0),Tl=e=>e||void 0;function On(e,t,n,r,o,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label",...r?{title:r}:{}},[h("span",{class:"pd-label-t",text:e}),o??""].filter(Boolean)),h("input",{class:"pd-switch",type:"checkbox",checked:t,...i?{disabled:!0}:{},onChange:a=>n(a.target.checked)})])}function Vh(e,t,n,r,o=!1,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),""].filter(Boolean)),h("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:a=>r(a.target.value)},n.map(a=>h("option",{value:a.value,text:a.label,selected:a.value===t})))])}function Qr(e,t,n,r,o={}){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),o.reset??""].filter(Boolean)),Fh(t,n,r,{className:"pd-select",...o.full?{width:"100%"}:{}})])}const er=e=>h("p",{class:"pd-hint",text:e}),E2="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",S2=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],_2=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],M2=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],T2=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],k2={value:"__multi__",label:"多选",disabled:!0};function C2(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[],i=r?o[r.r1]:void 0;if(!r||!i)return Qe(e,"table-row","行属性","Grid",[]);const a=l=>n.updateElement(t.id,l);return Qe(e,"table-row","行属性","Grid",[ji([Vh("行类型",i.type,S2,l=>{const c=na(o,r.r1,l);if(c){window.alert(c);return}a({tableRows:o})},!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"行高 (mm)"}),J({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?On("表头每页重复",i.repeatOnPage??!1,l=>{$g(o,l),a({tableRows:o})},E2):""])])}function A2(e,t){const n=e.store,r=t.options,o=d=>n.updateElement(t.id,d),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(d=>d.fieldType==="list").map(d=>({value:d.fieldKey,label:d.fieldLabel})),c=Ea("table"),s=d=>Cn({target:r,base:c,propKey:d,write:()=>o({[d]:c[d]})});return Qe(e,"table-settings","表格设置","Grid",[ji([Vh("列表数据源字段",r.dataSource??"",l,d=>o({dataSource:d||void 0}),!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字体"}),s("tableDefaultFontFamily")]),qi({id:"table-default-font",state:e.state,fonts:e.host.fonts,value:r.tableDefaultFontFamily,placeholder:"默认",onChange:d=>o({tableDefaultFontFamily:d||void 0})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字号 (pt)"}),s("tableDefaultFontSize")]),J({value:An(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:d=>o({tableDefaultFontSize:Tl(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认文字颜色"}),s("tableDefaultColor")]),ot(r.tableDefaultColor,d=>o({tableDefaultColor:d}),"默认文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),s("tableDefaultPadding")]),J({value:An(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:d=>o({tableDefaultPadding:Tl(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((d,p)=>h("div",{class:"col-width-row"},[h("span",{style:{width:"60px"},text:`列${p+1}`}),J({value:d,min:5,max:200,onCommit:u=>{const f=i.reduce((g,m,b)=>b===p?g:g+m,0);if(f+u>a){const g=Math.max(5,Math.round((a-f)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${p+1} 已调整为 ${g}mm`),i[p]=g}else i[p]=u;o({tableColWidths:i})}})]))])])])}function O2(e,t){const n=e.store,r=t.options,o=t.printElementType.type==="table",i=l=>n.updateElement(t.id,l),a=[];if(o)a.push(W(e,"pg-enabled",On("启用分页",r.tablePagination?.enabled??!0,l=>i({tablePagination:{enabled:l}}))));else{const l=r.pagination?.pageable??!0,c=r.pagination?.keepWithNext??!1;a.push(W(e,"pg-pageable",On("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(W(e,"pg-keep-with-next",On("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return Qe(e,"pagination","分页配置","Document",[ji(a)],!1)}const kl=new WeakMap,Yh=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function I2(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[];if(!r)return Qe(e,"table-cell","单元格","Menu",[]);const i=ar(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return Qe(e,"table-cell","单元格","Menu",[]);const l=()=>lo(o,r),c=ra(o,r),s=c.count,d=c.mode==="multi",p=`${t.id}:${r.r1}:${r.c1}:${r.r2}:${r.c2}`,u=kl.get(n),f=u?.key===p?u:{key:p,border:{},values:{},edges:{}};u?.key!==p&&kl.set(n,f);const g=_=>{kl.set(n,{key:p,border:_.border??f.border,values:_.values??f.values,edges:_.edges??f.edges})},m=(_,G)=>{g({border:{...f.border,[_]:G}}),e.repaint()},b=(_,G)=>{l().forEach(_),d&&G&&g({values:{...f.values,...G}}),n.updateElement(t.id,{tableRows:o})},v=(_,G)=>{b(K=>{K[_]=G},{[_]:G})},w=_=>d?f.values[_]:a[_],E=_=>d&&_ in f.values,k=d?{width:void 0,style:void 0,color:void 0}:lc(o,r),L=!d&&l().some(_=>!!_.borders&&!!(_.borders.top||_.borders.right||_.borders.bottom||_.borders.left)),R=!d&&!L,P={width:R?0:typeof k.width=="number"?k.width:Kt.width,style:R?"none":typeof k.style=="string"&&k.style!=="mixed"?k.style:Kt.style,color:typeof k.color=="string"&&k.color!=="mixed"?k.color:Kt.color,...f.border},O="__mixed__",C={style:!d&&k.style==="mixed",width:!d&&k.width==="mixed",color:!d&&k.color==="mixed"},I=C.style&&!("style"in f.border),S=C.width&&!("width"in f.border),$=C.color&&!("color"in f.border),N=I||S||$,z=I?O:P.style,T=S?void 0:P.width,ie=$?void 0:P.color,pe=_=>{const G={style:_};_!=="none"&&T===0?G.width=Kt.width:_==="none"&&!L&&(G.width=0),g({border:{...f.border,...G}}),e.repaint()},Ge=()=>({...P}),Q=d?Yh.reduce((_,G)=>(_[G.value]=f.edges[G.value]?"on":"off",_),{}):Xc(l().map(_=>_.borders)),Te=d?"cellType"in f.values?f.values.cellType??"text":zg(o,r):a.cellType??"text",he=Te==="barcode",de=Te==="qrcode",ye=Te==="image",ne=Te==="text",De=he&&!!w("printerDpi"),it=Cc(w("printerDpi"),w("barWidth")),te=d?f.values.textFit:aa(a),Ve=d?"cellType"in f.values?f.values.cellType??"text":"":a.cellType||"text",$e=_=>d?[k2,..._]:_,fe=_=>d?"多选":_,me=(_,G)=>d?f.values[_]:G,tr=d?w("barcodeType")??"__multi__":a.barcodeType||"CODE128",to=d?E("printerDpi")?w("printerDpi")?String(w("printerDpi")):"":"__multi__":a.printerDpi?String(a.printerDpi):"",no=d?w("qrCodeLevel")??"__multi__":a.qrCodeLevel||"M",ro=d?w("fit")??"__multi__":a.fit||"contain",nr=te??"__multi__",ge=tc(o,r);let Mt=!0;for(let _=r.r1;_<=r.r2;_++)if(o[_]?.type!=="data"){Mt=!1;break}const M=Mt?"":"仅数据行(明细行)支持按值合并";let H=!1;for(let _=r.r1;_<=r.r2&&!H;_++)for(let G=r.c1;G<=r.c2&&!H;G++){const K=o[_]?.cells[G];K&&!K.merged&&((K.rowspan??1)>1||(K.colspan??1)>1)&&(H=!0)}const B=(_,G,K,Z={},oe)=>h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:_}),oe??""].filter(Boolean)),J({value:G,...Z,onCommit:be=>v(K,Tl(be))})]),q="恢复默认值(跟随表格默认)",U=_=>Cn({target:a,base:{},propKey:_,tipOverride:q,force:d,write:()=>v(_,void 0)}),V=t.options.tableDefaultPadding??1,ee={width:la(t.options.tableColWidths??[],i.c,a,V),height:ur(o,i.r,a,V)};return Qe(e,"table-cell","单元格","Menu",[ji([d?er(`已选 ${s} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"单元格类型"}),on("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],Ve,_=>{const G=_==="text"?void 0:_,K={cellType:_};_!=="barcode"&&Object.assign(K,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),_!=="qrcode"&&Object.assign(K,{qrCodeLevel:void 0,qrQuietZone:void 0}),b(Z=>{Z.cellType=G,_!=="barcode"&&(Z.barcodeType=void 0,Z.showBarcodeText=void 0,Z.printerDpi=void 0,Z.barQuietZone=void 0,Z.barHeight=void 0),_!=="qrcode"&&(Z.qrCodeLevel=void 0,Z.qrQuietZone=void 0)},K)})]),he?Qr("码制",tr,$e(_2),_=>{_!=="__multi__"&&v("barcodeType",_||void 0)}):"",he?On("显示文本",d?f.values.showBarcodeText===!0:a.showBarcodeText!==!1,_=>v("showBarcodeText",_),void 0,U("showBarcodeText")):"",he?B("条宽(倍率)",me("barWidth",a.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:fe("")},U("barWidth")):"",he?er((De?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(it?`。${it}`:"")):"",he?He("静区 (模块)",J({value:me("barQuietZone",a.barQuietZone),min:0,max:20,placeholder:fe("默认 10"),onCommit:_=>v("barQuietZone",_)}),Ae("cd-bar-quiet-zone"),U("barQuietZone")):"",he?He("条高 (mm)",J({value:me("barHeight",a.barHeight),min:1,max:100,placeholder:fe("默认 30 模块"),onCommit:_=>v("barHeight",_??void 0)}),Ae("cd-bar-height"),U("barHeight")):"",he?B("文本字号(相对条高,条高为 30)",me("barFontSize",a.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:fe("默认 10")},U("barFontSize")):"",he?Qr("打印机分辨率",to,$e([{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)"}]),_=>{if(_==="__multi__")return;const G=Number(_);v("printerDpi",G>0?G:void 0)},{reset:U("printerDpi")}):"",he?er("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",de?Qr("纠错级别",no,$e(M2),_=>{_!=="__multi__"&&v("qrCodeLevel",_||void 0)},{reset:U("qrCodeLevel")}):"",de?He("静区 (模块)",J({value:me("qrQuietZone",a.qrQuietZone),min:0,max:8,placeholder:fe("默认 0"),onCommit:_=>v("qrQuietZone",_)}),Ae("cd-quiet-zone"),U("qrQuietZone")):"",he?er("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",de||ye?Qr("缩放模式",ro,$e(cs),_=>{_!=="__multi__"&&v("fit",_)},{reset:U("fit")}):"",ye&&!d&&a.fit==="cover"?Gh(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Su(a.formatter),fit:a.fit,containerClass:"pd-cell-anchor",widthMm:ee.width,heightMm:ee.height,scale:a.fitScale,value:a.objectPosition,onCommit:_=>v("objectPosition",_),onScaleCommit:_=>v("fitScale",_),resetAnchor:U("objectPosition"),resetScale:U("fitScale")}):"",he||de||ye?B("最大宽度 (mm)",me("maxWidth",An(a.maxWidth)),"maxWidth",{min:0,max:200,placeholder:fe("默认")},U("maxWidth")):"",he||de||ye?B("最大高度 (mm)",me("maxHeight",An(a.maxHeight)),"maxHeight",{min:0,max:200,placeholder:fe("默认")},U("maxHeight")):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"内容"}),h("input",{class:"pd-input",type:"text",value:d?w("formatter")??"":a.formatter||"",placeholder:d?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:_=>v("formatter",_.target.value||void 0),onDblclick:()=>e.fire("table-cell-dblclick",{elementId:t.id,r:i.r,c:i.c,cellId:a.id})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"水平对齐"}),U("align")]),on("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],d?f.values.align??"":a.align||"left",_=>v("align",_))]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"垂直对齐"}),U("valign")]),on("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],d?f.values.valign??"":a.valign||"top",_=>v("valign",_))]),h("div",{class:"cell-style-grid"},[h("div",{class:"pd-field cell-font-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"字体"}),U("fontFamily")]),qi({id:"cell-font",state:e.state,fonts:e.host.fonts,value:d?w("fontFamily"):a.fontFamily,placeholder:fe("继承默认"),onChange:_=>v("fontFamily",_)})]),B("字号 (pt)",me("fontSize",An(a.fontSize)),"fontSize",{min:0,max:72,placeholder:fe("默认")},U("fontSize")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"加粗"}),U("fontWeight")]),h("input",{class:"pd-switch",type:"checkbox",checked:d?f.values.fontWeight==="bold":a.fontWeight==="bold",onChange:_=>v("fontWeight",_.target.checked?"bold":void 0)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"文字颜色"}),U("color")]),ot(d?w("color"):a.color,_=>v("color",_),"文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"背景色"}),U("backgroundColor")]),ot(d?w("backgroundColor"):a.backgroundColor,_=>v("backgroundColor",_),"背景颜色")])]),$t("边框"),h("div",{class:"border-style-row"},[Fh(z,[...I?[{value:O,label:"混合",disabled:!0}]:[],...Ta],_=>{_!==O&&pe(_)},{width:"90px"}),h("div",{style:{width:"112px",flexShrink:"0"}},[J({value:T,min:.25,max:5,step:.25,placeholder:d?"多选":S?"混合":void 0,onCommit:_=>m("width",_)})]),ot(ie,_=>m("color",_),"边框颜色")]),h("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([_,G])=>h("button",{type:"button",class:"pd-button small",text:G,onClick:()=>{ac(o,r,P.style==="none"?"none":_,Ge()),n.updateElement(t.id,{tableRows:o})}}))),h("div",{class:"pd-checkbox-group"},Yh.map(_=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",value:_.value,checked:Q[_.value]==="on",indeterminate:Q[_.value]==="mixed",onChange:G=>{const Z=G.target.checked&&P.style!=="none";d&&g({edges:{...f.edges,[_.value]:Z}}),b(oe=>{sc(oe,_.value,Z?Ge():null)})}}),h("span",{text:_.label})]))),er(d?Lg:N?Fg:Ng),B("内边距 (mm)",me("padding",An(a.padding)),"padding",{min:0,max:10,step:.5,placeholder:fe("默认")},U("padding")),On("自动换行",d?f.values.wordWrap===!0:a.wordWrap??!0,_=>v("wordWrap",_),void 0,U("wordWrap")),ne?Qr("文字溢出",nr,$e(T2),_=>{_!=="__multi__"&&v("textFit",_)},{full:!0,reset:U("textFit")}):"",ne&&te==="shrink"?B("最小字号 (pt)",me("shrinkMinFontSize",An(a.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:fe("默认 6")},U("shrinkMinFontSize")):"",h("div",{class:"merge-card"},[h("div",{class:"merge-card-title",text:"单元格合并"}),h("div",{class:"merge-btns"},[h("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!ge,title:ge||"",onClick:()=>{nc(o,r),n.updateElement(t.id,{tableRows:o})}}),h("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!H,onClick:()=>{rc(o,r),n.updateElement(t.id,{tableRows:o})}})]),h("div",{class:"merge-card-divider"}),On("按值合并",d?f.values.mergeSameValue===!0:a.mergeSameValue===!0,_=>v("mergeSameValue",_),M||void 0,Mt?U("mergeSameValue"):void 0,!Mt),er("明细相邻行同值时自动纵向合并;跨页时在该页内成段,续页首行重放该值")])])])}const Cl=lb;function Al(e){const t=e.trim();return t?/[{}]/.test(t)||/^[A-Za-z_$][\w$]*\s*\(/.test(t)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(t):!1}function P2(e){return e?e.mode==="binding"?e.binding??"":e.content??"":""}function R2(e){const t=e.store.templateData.watermark,n=P2(t),r=t?.mode==="binding"||n!==""&&Al(n),o=(()=>{const s=t?.tileWidth??le.tileWidth,d=t?.tileHeight??le.tileHeight;for(const[p,u]of Object.entries(Cl))if(u.width===s&&u.height===d)return p;return"custom"})(),i=s=>{const d={...t,testData:t?.testData??"",rotate:t?.rotate??le.rotate,color:t?.color||le.color,opacity:t?.opacity??le.opacity,tileWidth:t?.tileWidth??le.tileWidth,tileHeight:t?.tileHeight??le.tileHeight};e.store.updateTemplateData({watermark:{...d,...s}})},a=()=>e.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n}),l={rotate:t?.rotate??le.rotate,color:t?.color||le.color,opacity:t?.opacity??le.opacity,tileWidth:t?.tileWidth??le.tileWidth,tileHeight:t?.tileHeight??le.tileHeight},c=s=>Cn({target:l,base:le,propKey:s,write:()=>i({[s]:le[s]})});return h("div",{class:"watermark-config"},[$t("水印"),h("form",{class:"pd-form",onSubmit:s=>s.preventDefault()},[h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"水印表达式"}),h("input",{class:"pd-input",type:"text",value:n,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:s=>{const d=s.target.value;i(Al(d)?{mode:"binding",binding:d,content:""}:{mode:"fixed",content:d,binding:""})},onDblclick:a}),h("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?se("测试值",h("input",{class:"pd-input",type:"text",value:t?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:s=>i({testData:s.target.value})})):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),h("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(t?.rotate??le.rotate),onChange:s=>i({rotate:Number(s.target.value)})}),h("span",{class:"pd-hint",text:`${t?.rotate??le.rotate}°`})]),se("颜色",ot(t?.color||le.color,s=>i({color:s}),"水印颜色"),void 0,c("color")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),h("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(t?.opacity??le.opacity),onChange:s=>i({opacity:Number(s.target.value)})}),h("span",{class:"pd-hint",text:(t?.opacity??le.opacity).toFixed(2)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"密度"}),h("select",{class:"pd-select",style:{width:"100%"},onChange:s=>{const d=s.target.value,p=Cl[d];p&&i({tileWidth:p.width,tileHeight:p.height})}},[...Object.entries(Cl).map(([s,d])=>h("option",{value:s,text:`${d.label}(${d.width}×${d.height})`,selected:o===s})),h("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),h("input",{type:"number",class:"pd-input",min:le.minTileWidth,step:10,value:String(t?.tileWidth??le.tileWidth),onChange:s=>i({tileWidth:Number(s.target.value)})})]):"",o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),h("input",{type:"number",class:"pd-input",min:le.minTileHeight,step:10,value:String(t?.tileHeight??le.tileHeight),onChange:s=>i({tileHeight:Number(s.target.value)})})]):""].filter(Boolean))])}function Ie(e,t,n,r,o={},i){return se(t,J({value:n,...o,onCommit:r}),void 0,i)}function jt(e,t,n,r,o,i,a){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>o(l.value));for(const c of r){const s=document.createElement("option");s.value=c.value,s.textContent=c.label,l.appendChild(s)}return l.value=n,r.some(c=>c.value===n)||(l.selectedIndex=-1),i?He(t,l,i,a):se(t,l,void 0,a)}function In(e,t,n,r,o){return se(t,h("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:i=>r(i.target.checked)}),void 0,o)}const D2=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],$2=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function N2(e,t){const n=e.store,r=t.options,o=t.printElementType.type,i=T=>n.updateElement(t.id,T),a=zf(o),l=a==="text",c=a==="code",s=a==="table",d=s&&n.tableSelection?.elementId===t.id,p=d&&ra(t.options.tableRows??[],n.tableSelection).mode==="multi",u=[];p||u.push(x2(e,t));const f=Ea(o),g=(T,ie)=>{const pe=b0(ie);return Cn({target:r,base:f,propKey:T,tipValue:pe?.value,tipUnit:pe?.unit,write:()=>i({[T]:f[T]})})};d||u.push(Qe(e,"position-size","位置与尺寸","Location",[h("form",{class:"pd-form",onSubmit:T=>T.preventDefault()},[h("div",{class:"position-grid"},[W(e,"ps-left",Ie(e,"X",r.left,T=>i({left:T}),{min:0})),W(e,"ps-top",Ie(e,"Y",r.top,T=>i({top:T}),{min:0})),W(e,"ps-width",Ie(e,"W",r.width,T=>i({width:T}),{min:4})),W(e,"ps-height",Ie(e,"H",r.height,T=>i({height:T}),{min:4}))]),h("h3",{class:"pd-divider",text:"外边距 (mm)"}),h("div",{class:"margin-grid"},[W(e,"ps-margin-top",Ie(e,"上",r.marginTop,T=>i({marginTop:T===0?void 0:T}),{},g("marginTop","ps-margin-top"))),W(e,"ps-margin-right",Ie(e,"右",r.marginRight,T=>i({marginRight:T===0?void 0:T}),{},g("marginRight","ps-margin-right"))),W(e,"ps-margin-bottom",Ie(e,"下",r.marginBottom,T=>i({marginBottom:T===0?void 0:T}),{},g("marginBottom","ps-margin-bottom"))),W(e,"ps-margin-left",Ie(e,"左",r.marginLeft,T=>i({marginLeft:T===0?void 0:T}),{},g("marginLeft","ps-margin-left")))])])]));const m=typeof r.rotate=="number"&&Number.isFinite(r.rotate)&&r.rotate!==0?mr(r.rotate):void 0,b=T=>i({rotate:T===void 0||T===0?void 0:mr(T)}),v=_m(o,r),w=$c(o)||Bc(n.elements).has(t.id),E=w?"":W(e,"ap-rotate",He("旋转 (°)",h("div",{class:"pd-rotate-row"},[h("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>b((m??0)-90)}),h("div",{class:"pd-rotate-stepper"},[J({value:m,min:0,max:359,placeholder:"0",disabled:!v,onCommit:T=>b(T)})]),h("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>b((m??0)+90)})]),Ae("ap-rotate"),g("rotate","ap-rotate"))),k=w||v?"":h("p",{class:"pd-hint pd-rotate-note",text:Sm});if(u.push(Qe(e,"appearance","外观","Brush",[h("form",{class:"pd-form",onSubmit:T=>T.preventDefault()},l?[W(e,"ap-font-family",se("字体",qi({id:"prop-font",state:e.state,fonts:e.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:T=>i({fontFamily:T})}),void 0,g("fontFamily","ap-font-family"))),W(e,"ap-font-size",Ie(e,"字体大小",r.fontSize,T=>i({fontSize:T}),{min:8,max:72},g("fontSize","ap-font-size"))),W(e,"ap-font-weight",jt(e,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],T=>i({fontWeight:T}),void 0,g("fontWeight","ap-font-weight"))),W(e,"ap-align",se("对齐",on("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",T=>i({textAlign:T})),void 0,g("textAlign","ap-align"))),W(e,"ap-vertical-align",se("垂直对齐",on("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",T=>i({verticalAlign:T})),void 0,g("verticalAlign","ap-vertical-align"))),h("div",{class:"color-row"},[W(e,"ap-color",se("颜色",ot(r.color,T=>i({color:T}),"字体颜色"),void 0,g("color","ap-color"))),W(e,"ap-bg-color",se("背景色",ot(r.backgroundColor,T=>i({backgroundColor:T}),"背景颜色"),void 0,g("backgroundColor","ap-bg-color")))]),W(e,"ap-line-height",Ie(e,"行高",r.lineHeight,T=>i({lineHeight:T||void 0}),{min:0,max:100},g("lineHeight","ap-line-height"))),W(e,"ap-letter-spacing",Ie(e,"字间距",r.letterSpacing,T=>i({letterSpacing:T||void 0}),{min:0,max:20,step:.5},g("letterSpacing","ap-letter-spacing"))),W(e,"ap-text-fit",jt(e,"文字溢出",po(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],T=>i({textFit:T}),void 0,g("textFit","ap-text-fit"))),r.textFit==="shrink"?W(e,"ap-shrink-min",se("最小字号 (pt)",J({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:T=>i({shrinkMinFontSize:T||void 0})}),void 0,g("shrinkMinFontSize","ap-shrink-min"))):"",o==="longText"?W(e,"ap-long-text-indent",He("首行缩进 (字符)",J({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:T=>i({longTextIndent:T||void 0})}),Ae("ap-long-text-indent"),g("longTextIndent","ap-long-text-indent"))):"",W(e,"ap-word-wrap",In(e,"自动换行",r.wordWrap!==!1,T=>i({wordWrap:T?void 0:!1}),g("wordWrap","ap-word-wrap"))),W(e,"ap-keep-line-breaks",In(e,"保留换行符",r.keepLineBreaks===!0,T=>i({keepLineBreaks:T?!0:void 0}),g("keepLineBreaks","ap-keep-line-breaks"))),E,k]:[o==="image"?W(e,"ap-img-fit",jt(e,"缩放模式",String(r.fit??"contain"),cs,T=>i({fit:T}),Ae("ap-img-fit"),g("fit","ap-img-fit"))):"",o==="image"&&r.fit==="cover"?W(e,"ap-img-object-position",Gh(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:Su(r.src),widthMm:Number(r.width)||0,heightMm:Number(r.height)||0,fit:r.fit,scale:r.fitScale,value:r.objectPosition===void 0?void 0:String(r.objectPosition),onCommit:T=>i({objectPosition:T}),onScaleCommit:T=>i({fitScale:T}),resetAnchor:g("objectPosition","ap-img-object-position"),resetScale:g("fitScale","ap-img-fit-scale")})):"",E,k,o==="flowList"?h("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),c){const T=o==="barcode",ie=String(r.barcodeType||"CODE128").toUpperCase(),pe=r.printerDpi?String(r.printerDpi):"",Ge=Cc(r.printerDpi,r.barWidth);u.push(Qe(e,"code","条码设置","Postcard",[h("form",{class:"pd-form",onSubmit:Q=>Q.preventDefault()},[T?[W(e,"cd-type",jt(e,"码制",ie,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Q=>i({barcodeType:Q==="CODE128"?void 0:Q}))),W(e,"cd-dpi",jt(e,"打印机分辨率",pe,[{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)"}],Q=>i({printerDpi:Number(Q)>0?Number(Q):void 0}),void 0,g("printerDpi","cd-dpi"))),W(e,"cd-dpi",h("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),W(e,"cd-bar-width",Ie(e,"条宽(倍率)",r.barWidth??2,Q=>i({barWidth:Q}),{min:2,max:8,step:.5},g("barWidth","cd-bar-width"))),W(e,"cd-bar-width",h("p",{class:"pd-hint",text:(pe?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Ge?`。${Ge}`:"")})),W(e,"cd-bar-quiet-zone",He("静区 (模块)",J({value:r.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:Q=>i({barQuietZone:Q})}),Ae("cd-bar-quiet-zone"),g("barQuietZone","cd-bar-quiet-zone"))),W(e,"cd-bar-height",He("条高 (mm)",J({value:r.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:Q=>i({barHeight:Q??void 0})}),Ae("cd-bar-height"),g("barHeight","cd-bar-height"))),W(e,"cd-show-text",In(e,"显示文本",r.hideTitle!==!0,Q=>i({hideTitle:Q?void 0:!0}),g("hideTitle","cd-show-text"))),W(e,"cd-font-size",se("文本字号(相对条高,条高为 30)",J({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:Q=>i({fontSize:Q||void 0})}),void 0,g("fontSize","cd-font-size")))]:[W(e,"cd-ec-level",jt(e,"纠错级别",String(r.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Q=>i({qrCodeLevel:Q}),void 0,g("qrCodeLevel","cd-ec-level"))),W(e,"cd-quiet-zone",He("静区 (模块)",J({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:Q=>i({qrQuietZone:Q})}),Ae("cd-quiet-zone"),g("qrQuietZone","cd-quiet-zone")))],$t("自定义设置"),T?h("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",T?"":W(e,"cd-fit",jt(e,"缩放模式",String(r.fit||"contain"),cs,Q=>i({fit:Q||void 0}),void 0,g("fit","cd-fit"))),W(e,"cd-max-width",se("最大宽度 (mm)",J({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:Q=>i({maxWidth:Q||void 0})}),void 0,g("maxWidth","cd-max-width"))),W(e,"cd-max-height",se("最大高度 (mm)",J({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:Q=>i({maxHeight:Q||void 0})}),void 0,g("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(d&&(u.push(C2(e,t)),u.push(I2(e,t))),s&&u.push(A2(e,t)),o==="flowList"){const T=pt(r.flowColumns),ie=Xt(r.flowRowHeight),pe=vt(r.flowGapX),Ge=fn(r.flowMaxSpan,T),Q=dm(r.width??0,pe,r.fontSize??12),Te=pn(r.flowLayoutMode),he=Te==="dynamic",de=Nn(r),ye=(ne,De)=>{i({[ne]:typeof De=="number"&&Number.isFinite(De)&&De>0?De:0})};u.push(Qe(e,"flowList","流式列表","Grid3x3",[h("form",{class:"pd-form",onSubmit:ne=>ne.preventDefault()},[W(e,"fl-layout-mode",jt(e,"布局模式",Te,[{value:"fixed",label:"固定高度"},{value:"dynamic",label:"动态分页"}],ne=>i({flowLayoutMode:ne==="dynamic"?"dynamic":"fixed"}),Ae("fl-layout-mode"))),...he?[W(e,"fl-padding-top",He("上内边距 (mm)",J({value:de.top,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingTop",ne)}),Ae("fl-padding-top"))),W(e,"fl-padding-right",He("右内边距 (mm)",J({value:de.right,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingRight",ne)}),Ae("fl-padding-right"))),W(e,"fl-padding-bottom",He("下内边距 (mm)",J({value:de.bottom,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingBottom",ne)}),Ae("fl-padding-bottom"))),W(e,"fl-padding-left",He("左内边距 (mm)",J({value:de.left,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingLeft",ne)}),Ae("fl-padding-left")))]:[],W(e,"fl-columns",He("每行列数",J({value:T,min:1,max:12,onCommit:ne=>i({flowColumns:pt(ne),flowMaxSpan:fn(r.flowMaxSpan,pt(ne))})}),Ae("fl-columns"))),W(e,"fl-row-height",He("行高 (mm)",J({value:ie,min:3,max:100,step:.5,onCommit:ne=>i({flowRowHeight:Xt(ne)})}),Ae("fl-row-height"))),W(e,"fl-gap-x",He("单元横向间距 (mm)",J({value:pe,min:0,max:50,step:.5,onCommit:ne=>i({flowGapX:vt(ne)})}),Ae("fl-gap-x"))),W(e,"fl-auto-span",In(e,"内容过长时跨列",r.flowAutoSpan===!0,ne=>{i(ne?{flowAutoSpan:ne,flowMaxSpan:Ge}:{flowAutoSpan:ne})})),r.flowAutoSpan===!0?W(e,"fl-max-span",He("最多跨几列",J({value:Ge,min:1,max:T,onCommit:ne=>i({flowMaxSpan:fn(ne,T)})}),Ae("fl-max-span"))):"",T>Q?h("p",{class:"pd-hint",text:`按当前字号与框宽,${T} 列偏挤(可放约 ${Q} 列)。数值保持不变,出纸按 ${T} 列排。`}):""].flat().filter(Boolean))]))}const L=()=>({borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:r.borders}),R=T=>{const ie=L();Zc(ie,T,ed(ie)),i(ie)},P=T=>{const ie=L();Ca(ie,T,!xr(ie,T)),i(ie)},O=Qc(r),C=O.style==="mixed",I=typeof O.width=="number"?O.width:void 0,S=C||O.style===void 0?"":O.style,$=typeof O.color=="string"?O.color:void 0,N=(T,ie)=>{const pe=L();Jm(pe,T,ie),i(pe)},z=C?[{value:"",label:"混合"},...Ta]:[...Ta];return u.push(Qe(e,"border-bg","边框与背景","Picture",[h("form",{class:"pd-form",onSubmit:T=>T.preventDefault()},[W(e,"bb-border-style",jt(e,"线型",S,z,T=>N("borderStyle",T))),h("div",{class:"border-row"},[W(e,"bb-border-width",Ie(e,"边框宽度",I,T=>N("borderWidth",T),{min:0,max:20,step:.25,placeholder:O.width==="mixed"?"混合":void 0},g("borderWidth","bb-border-width"))),W(e,"bb-border-color",se("边框颜色",ot($,T=>N("borderColor",T),"边框颜色"),void 0,g("borderColor","bb-border-color")))]),...mo(o)?[h("div",{class:"pd-button-group border-presets"},D2.map(T=>h("button",{type:"button",class:"pd-button small",text:T.label,disabled:T.value==="inner",onClick:()=>R(T.value)}))),h("div",{class:"pd-checkbox-group"},$2.map(T=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",checked:xr(r,T.value),onChange:()=>P(T.value)}),h("span",{text:T.label})]))),h("p",{class:"pd-hint",text:jm})]:[],W(e,"bb-bg-color",se("背景色",ot(r.backgroundColor,T=>i({backgroundColor:T}),"背景颜色"),void 0,g("backgroundColor","bb-bg-color")))])])),u.push(O2(e,t)),u.push(Qe(e,"advanced","高级设置","Setting",[h("form",{class:"pd-form",onSubmit:T=>T.preventDefault()},[h("div",{class:"advanced-row"},[W(e,"ad-locked",In(e,"锁定",!!r.locked,T=>i({locked:T}),g("locked","ad-locked"))),W(e,"ad-fixed",In(e,"每页重复",!!r.repeatOnEveryPage,T=>i({repeatOnEveryPage:T}),g("repeatOnEveryPage","ad-fixed"))),W(e,"ad-fixed-position",In(e,"每页固定",!!r.fixed,T=>i({fixed:T}),g("fixed","ad-fixed-position")))]),W(e,"ad-z-index",Ie(e,"层级",r.zIndex,T=>i({zIndex:T}),{min:0,max:999},g("zIndex","ad-z-index"))),W(e,"ad-delete",h("div",{class:"pd-field"},[h("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>n.deleteSelected()})]))])],!1,[h("button",{type:"button",class:"group-help",title:"高级设置说明","aria-label":"高级设置说明",text:"?",onClick:T=>{T.stopPropagation(),e.fire("help","advanced-settings")}})])),h("div",{class:"property-content"},u)}function L2(e){const t=e.store,n=t.templateData,r=c=>t.updateTemplateData(c),o=c=>{const s=n.tiling,d=p=>p===90||p===270;if(s?.enabled&&d(c)!==d(n.outputRotation)){const p=gu({...n,outputRotation:c});r({outputRotation:c,tiling:{...s,columns:Math.max(p,1)}});return}r({outputRotation:c})},i=[];for(const[c,s]of Object.entries(Ot)){const d=s.group??"其他";let p=i.find(u=>u.group===d);p||(p={group:d,items:[]},i.push(p)),p.items.push({key:c,label:s.label??c})}const a=!Ot[n.paperSize],l=_o(n.paperSize);return h("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[$t("纸张设置"),se("纸张尺寸",h("select",{class:"pd-select",style:{width:"100%"},onChange:c=>r({paperSize:c.target.value})},[...i.map(c=>h("optgroup",{label:c.group},c.items.map(s=>h("option",{value:s.key,text:s.label,selected:n.paperSize===s.key})))),h("option",{value:"CUSTOM",text:"自定义宽高",selected:a})])),l||a?se(l?"纸宽 (mm)":"自定义宽高 (mm)",h("div",{class:"custom-size-grid"},[J({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:c=>r({customWidth:c})}),...a?[h("span",{class:"custom-size-x",text:"×"}),J({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:c=>r({customHeight:c})})]:[]])):"",l?"":se("纸张方向",on("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",c=>r({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":se("内容旋转角度",on("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),c=>o(Number(c)),!0),n.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),se("页面背景色",h("div",{class:"page-bg-row"},[ot(n.pageBackground,c=>r({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,Cn({target:n,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>r({pageBackground:void 0})})),l2(e),t.pages.length>1?"":c2(e),$t("页边距 (mm)"),h("div",{class:"margin-grid"},[Ie(e,"上",n.margins.top,c=>r({margins:{...n.margins,top:c}}),{min:0,max:50}),Ie(e,"下",n.margins.bottom,c=>r({margins:{...n.margins,bottom:c}}),{min:0,max:100}),Ie(e,"左",n.margins.left,c=>r({margins:{...n.margins,left:c}}),{min:0,max:50}),Ie(e,"右",n.margins.right,c=>r({margins:{...n.margins,right:c}}),{min:0,max:50})]),$t("页眉/页脚高度 (mm)"),Ie(e,"页眉高度",n.header.height??10,c=>r({header:{...n.header,height:c}}),{min:0,max:100,step:.1}),Ie(e,"页脚高度",n.footer.height??10,c=>r({footer:{...n.footer,height:c}}),{min:0,max:100,step:.1}),R2(e)].filter(Boolean))}function F2(e,t,n){const r=(e.state.propSearch??"").trim(),o=!r||cd(r,[...n.searchKeywords,n.label]),i=document.createElement("div");if(i.className="property-content",o)try{fh(`property:${t.id}`,n.ui.renderProperty({element:t,data:e.host.designData?.length?e.host.designData:[gt],fields:e.host.fields??[],update:a=>e.store.updateElement(t.id,a),repaint:()=>e.repaint()}),i)}catch{}return h("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:custom"},style:e.state.propTab==="custom"?"":{display:"none"}},[i])}function z2(e){const t=e.store,n=e.state,r=t.selectedElement,o=r?Gs(r):void 0;if(n.propCollapsed)return h("div",{class:"property-panel collapsed"},[h("div",{class:"prop-collapsed"},[h("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{n.propCollapsed=!1,e.repaint()}}),...o?[h("button",{type:"button",class:`pc-btn${n.propTab==="custom"?" on":""}`,title:o.label,html:Re(o.icon,14)||Re("Shapes",14),onClick:()=>{n.propTab="custom",n.propCollapsed=!1,e.repaint()}})]:[],...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([a,l,c])=>h("button",{type:"button",class:`pc-btn${n.propTab===a?" on":""}`,title:l,text:c,onClick:()=>{n.propTab=a,n.propCollapsed=!1,e.repaint()}}))])]);const i=r?n.propTab==="custom"&&!o?"element":n.propTab:"page";return h("div",{class:"property-panel"},[h("div",{class:"prop-head"},[h("span",{class:"prop-title",text:"属性台"}),h("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{n.propCollapsed=!0,e.repaint()}})]),h("div",{class:"pd-tabs prop-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[...o?[h("button",{type:"button",class:`pd-tab${i==="custom"?" active":""}`,text:o.label,onClick:()=>{n.propTab="custom",e.repaint()}})]:[],h("button",{type:"button",class:`pd-tab${i==="element"?" active":""}`,text:"元素属性",onClick:()=>{n.propTab="element",e.repaint()}}),h("button",{type:"button",class:`pd-tab${i==="page"?" active":""}`,text:"页面属性",onClick:()=>{n.propTab="page",e.repaint()}})]),o&&r?F2(e,r,o):"",h("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:element"},style:i==="element"?"":{display:"none"}},r?[g2(e),N2(e,r)]:[h("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),h("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:page"},style:i==="page"?"":{display:"none"}},[L2(e)])].filter(Boolean))])}const Ol=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Kh={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},B2=[{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()"}],H2=[{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()"}],U2=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],q2=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],W2=[{title:"聚合函数",items:B2},{title:"数值运算",items:H2},{title:"格式化函数",items:U2}],j2="(输入表达式后预览)",G2="(无法计算)",Il="(表达式错误)";function Xh(e,t){if(!e.trim())return j2;try{const n={...gt,...t??{},...Io()},r=Wn(e,n);return r==null?G2:String(r)}catch{return Il}}function Zh(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):e}function V2(e,t){const n=e.substring(0,t),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}}const Y2=e=>/[\u4e00-\u9fff]/.test(e),K2=e=>`字段「${e}」含中文,请用 {${e}} 引用(函数参数内写 ${e});中文可直接在 {} 中使用,无需 data['...'] 方括号`;function X2(e,t){const n=/^\{\s*([^{}]+?)\s*\}$/.exec(e.trim());if(!n)return null;const r=n[1]??"";return t.find(o=>o.fieldKey===r)??null}function Pl(e,t){return h("div",{class:"ee-field-info"},[h("span",{class:"ee-item-label",text:e}),h("span",{class:"ee-item-key",text:t})])}function Nt(e){return e.currentTarget.getRootNode()}function Vi(e,t,n){const r=[];return n.forEach((o,i)=>{r.push(o),i<n.length-1&&r.push(h("br"))}),h("div",{class:`ee-help-card ${e}`},[h("div",{class:"ee-help-card-title",text:t}),h("div",{class:"ee-help-card-content"},r)])}function Z2(){return h("div",{class:"ee-help-section"},[h("div",{class:"ee-help-title",text:"帮助信息"}),h("div",{class:"ee-help-grid"},[Vi("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","中文 key 直接写 {字段名},如 {姓名}、{supplier.名称}","注意:只能嵌套一层"]),Vi("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Vi("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Vi("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function J2(e,t){const n={activeTab:"field",searchText:"",expression:t.value||"",binding:t.binding,copiedFieldKey:"",keyHint:""},r=(b,v)=>b.querySelector(v),o=b=>{const v=r(b,".ee-preview");if(!v)return;const w=Xh(n.expression,e.demoData);v.textContent=w,v.classList.toggle("ee-preview-error",w===Il)},i=b=>{const v=r(b,".ee-key-hint");v&&(v.textContent=n.keyHint,v.style.display=n.keyHint?"":"none")},a=()=>{if(n.activeTab==="variable")return Zh(q2,n.searchText).map(w=>h("div",{class:"ee-list-item",onDblclick:E=>{const{insideParens:k}=s(E);d(Nt(E),k?w.template.replace(/^\{|\}$/g,""):w.template,void 0,"")}},[Pl(w.label,w.template)]));if(n.activeTab==="function")return W2.map(w=>h("div",{class:"ee-func-group"},[h("div",{class:"ee-func-group-title",text:w.title}),...Zh(w.items,n.searchText).map(E=>h("div",{class:"ee-list-item",onDblclick:k=>{const{insideBlock:L}=s(k),R=L?E.template:`{${E.template}}`;d(Nt(k),R,R.indexOf("(")+1,"")}},[Pl(E.label,`${E.name}()`)]))]));const b=D1(Tu(e.fields??[]),n.searchText);if(!b.length)return[h("p",{class:"pd-empty",text:"暂无字段"})];const v=[];for(const w of b){w.key&&v.push(h("div",{class:`ee-field-group${w.isList?" is-list":""}`},[h("span",{class:"ee-field-group-icon",text:w.isList?"📋":"📁"}),h("span",{text:w.label})]));for(const E of w.fields)v.push(h("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:w.key?"22px":"10px"},onDblclick:k=>{const{insideParens:L}=s(k),R=k;if(R.ctrlKey||R.metaKey){const P=E.fieldLabel||E.fieldKey;d(Nt(k),L?`"${P}"`:P,void 0,"");return}d(Nt(k),L?E.fieldKey:`{${E.fieldKey}}`,void 0,Y2(E.fieldKey)?K2(E.fieldKey):"")}},[Pl(E.fieldLabel,E.fieldKey),h("button",{type:"button",class:`ee-copy-btn${n.copiedFieldKey===E.fieldKey?" is-copied":""}`,"data-tip":n.copiedFieldKey===E.fieldKey?"已复制":`复制字段名「${E.fieldLabel}」`,"aria-label":`复制字段名 ${E.fieldLabel}`,html:Re(n.copiedFieldKey===E.fieldKey?"Check":"Copy",13),onClick:k=>{k.stopPropagation(),c(k,E)},onDblclick:k=>k.stopPropagation()})]))}return v},l=b=>{Array.from(b.querySelectorAll(".ee-nav-tab")).forEach((L,R)=>L.classList.toggle("active",Ol[R]?.key===n.activeTab));const w=r(b,".ee-content-search .pd-input");if(w){const L=Kh[n.activeTab];w.placeholder!==L&&(w.placeholder=L),w.value!==n.searchText&&(w.value=n.searchText)}const E=r(b,".ee-textarea");E&&E.value!==n.expression&&(E.value=n.expression);const k=r(b,".ee-content-list");if(k){kf(k);for(const L of a())Ze(L,k)}o(b),i(b)};function c(b,v){const w=Nt(b);ku(v.fieldLabel||v.fieldKey).then(E=>{E&&(n.copiedFieldKey=v.fieldKey,l(w),setTimeout(()=>{n.copiedFieldKey===v.fieldKey&&(n.copiedFieldKey="",l(w))},1200))})}const s=b=>{const w=r(Nt(b),".ee-textarea")?.selectionStart??n.expression.length;return V2(n.expression,w)},d=(b,v,w=v.length,E)=>{E!==void 0&&(n.keyHint=E);const k=r(b,".ee-textarea");if(!k){n.expression+=v,o(b),i(b);return}const L=k.selectionStart??n.expression.length,R=k.selectionEnd??L;n.expression=n.expression.substring(0,L)+v+n.expression.substring(R);const P=L+w;k.value=n.expression,k.focus(),k.selectionStart=k.selectionEnd=P,o(b),i(b)},p=()=>{const b=n.expression;if(n.binding===void 0){e.onApply({formatter:b}),e.onClose();return}const v=X2(b,e.fields??[]);e.onApply(v?{formatter:b,binding:v.fieldKey,title:v.fieldLabel}:{formatter:b}),e.onClose()},u=h("div",{class:"ee-nav"},[h("div",{class:"ee-nav-title",text:"类型"}),h("div",{class:"ee-nav-tabs"},Ol.map((b,v)=>h("div",{class:`ee-nav-tab${n.activeTab===b.key?" active":""}`,text:b.text,onClick:w=>{n.activeTab=Ol[v].key,l(Nt(w))}})))]),f=h("div",{class:"ee-content"},[h("div",{class:"ee-content-search"},[h("input",{class:"pd-input",placeholder:Kh[n.activeTab],onInput:b=>{n.searchText=b.target.value,l(Nt(b))}})]),h("div",{class:"ee-content-list"},a())]),g=Xh(n.expression,e.demoData),m=h("div",{class:"ee-editor"},[h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"表达式编辑"}),h("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:n.expression,onInput:b=>{n.expression=b.target.value,n.keyHint="",o(Nt(b)),i(Nt(b))}}),h("div",{class:"pd-hint ee-key-hint",style:{display:"none",color:"var(--pd-accent, #165DFF)"},text:""})]),h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"预览结果"}),h("div",{class:`ee-preview${g===Il?" ee-preview-error":""}`,text:g})]),Z2()]);return h("div",{class:"pd-dialog-overlay",onKeydown:b=>{b.key==="Escape"&&e.onClose()}},[h("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[h("header",{class:"pd-dialog-header"},[h("strong",{id:"expression-editor-title",text:"编辑表达式"}),h("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"expression-editor"},[u,f,m]),h("footer",{class:"pd-dialog-footer"},[h("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>e.onClose()}),h("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>p()})])])])}const Yi=[{id:"getting-started",title:"快速入门",content:`
269
+ `);const $=E(I,A,R),N=e.getSymbolSize(I),B=new r(N);return f(B,I),g(B),m(B,I),v(B,A,0),I>=7&&y(B,I),w(B,$),isNaN(k)&&(k=a.getBestMask(B,v.bind(null,B,A))),a.applyMask(k,B),v(B,A,k),{modules:B,version:I,errorCorrectionLevel:A,maskPattern:k,segments:R}}return gs.create=function(I,A){if(typeof I>"u"||I==="")throw new Error("No input text");let k=t.M,R,S;return typeof A<"u"&&(k=t.from(A.errorCorrectionLevel,t.M),R=s.from(A.version),S=a.from(A.maskPattern),A.toSJISFunc&&e.setToSJISFunction(A.toSJISFunc)),P(I,R,k,S)},gs}var Fs={},$s={},bf;function yf(){return bf||(bf=1,(function(e){function t(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("")}}e.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:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,o){return o.width&&o.width>=r+o.margin*2?o.width/(r+o.margin*2):o.scale},e.getImageWidth=function(r,o){const i=e.getScale(r,o);return Math.floor((r+o.margin*2)*i)},e.qrToImageData=function(r,o,i){const a=o.modules.size,l=o.modules.data,c=e.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 g=(u*s+f)*4,m=i.color.light;if(u>=d&&f>=d&&u<s-d&&f<s-d){const y=Math.floor((u-d)/c),v=Math.floor((f-d)/c);m=p[l[y*a+v]?1:0]}r[g++]=m.r,r[g++]=m.g,r[g++]=m.b,r[g]=m.a}}})($s)),$s}var vf;function Yy(){return vf||(vf=1,(function(e){const t=yf();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")}}e.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=t.getOptions(c);const d=t.getImageWidth(i.modules.size,c),p=s.getContext("2d"),u=p.createImageData(d,d);return t.qrToImageData(u.data,i,c),n(p,s,d),p.putImageData(u,0,0),s},e.renderToDataURL=function(i,a,l){let c=l;typeof c>"u"&&(!a||!a.getContext)&&(c=a,a=void 0),c||(c={});const s=e.render(i,a,c),d=c.type||"image/png",p=c.rendererOpts||{};return s.toDataURL(d,p.quality)}})(Fs)),Fs}var Ns={},wf;function Ky(){if(wf)return Ns;wf=1;const e=yf();function t(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 Ns.render=function(i,a,l){const c=e.getOptions(a),s=i.modules.size,d=i.modules.data,p=s+c.margin*2,u=c.color.light.a?"<path "+t(c.color.light,"fill")+' d="M0 0h'+p+"v"+p+'H0z"/>':"",f="<path "+t(c.color.dark,"stroke")+' d="'+r(d,s,c.margin)+'"/>',g='viewBox="0 0 '+p+" "+p+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+g+' shape-rendering="crispEdges">'+u+f+`</svg>
270
+ `;return typeof l=="function"&&l(null,y),y},Ns}var xf;function Xy(){if(xf)return Kn;xf=1;const e=Dy(),t=Vy(),n=Yy(),r=Ky();function o(i,a,l,c,s){const d=[].slice.call(arguments,1),p=d.length,u=typeof d[p-1]=="function";if(!u&&!e())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,g){try{const m=t.create(l,c);f(i(m,a,c))}catch(m){g(m)}})}try{const f=t.create(l,c);s(null,i(f,a,c))}catch(f){s(f)}}return Kn.create=t.create,Kn.toCanvas=o.bind(null,n.render),Kn.toDataURL=o.bind(null,n.renderToDataURL),Kn.toString=o.bind(null,function(i,a,l){return r.render(i,l)}),Kn}var Zy=Xy();const Jy=Ru(Zy),Ef="http://www.w3.org/2000/svg";function Qy(e){const t=e.getAttribute("viewBox");if(!t)return null;const n=t.trim().split(/[\s,]+/).map(Number);return n.length!==4||n.some(r=>!Number.isFinite(r))?null:{width:n[2],height:n[3]}}function ev(e,t){const n=document.createElementNS(Ef,"svg"),r=fr(t.barWidth),o=pa(t.barQuietZone),i=l=>{fs(n,e,{format:t.barcodeType||"CODE128",width:r,height:l*r,displayValue:t.showText!==!1,fontSize:(t.fontSize??ho)*r,margin:0,marginLeft:o*r,marginRight:o*r,marginTop:0,marginBottom:fa*r});const c=Qy(n);return c?{widthUnits:c.width,heightUnits:c.height}:null},a=ga({barHeightMm:t.barHeightMm,boxWidthMm:t.targetWidthMm??0,boxHeightMm:t.targetHeightMm??0,dpi:t.printerDpi,barWidth:t.barWidth,measure:i});return a.size&&(n.setAttribute("width",`${a.size.widthMm}mm`),n.setAttribute("height",`${a.size.heightMm}mm`)),n.setAttribute("shape-rendering","crispEdges"),n.outerHTML}function tv(e){return typeof e=="number"&&Number.isFinite(e)?Math.max(0,Math.floor(e)):kc}function nv(e,t){const n=(t.qrCodeLevel??"M").toUpperCase(),o=Jy.create(e,{errorCorrectionLevel:["L","M","Q","H"].includes(n)?n:"M"}).modules,i=o.size,a=4,l=tv(t.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="${Ef}" viewBox="0 0 ${c} ${c}" width="${c}" height="${c}" shape-rendering="crispEdges">${s}</svg>`}function Sf(e,t,n={}){if(!e)throw new Error("empty barcode value");return t==="qrcode"?nv(e,n):ev(e,n)}const Ls={render(e,t,n={}){return Sf(e,t,n)}},Bs=.5,rv=12;function zs(e,t){const n=e.getAttribute(t);if(n===null||n==="")return;const r=Number(n);return Number.isFinite(r)?r:void 0}function _f(e,t){if(e.scrollWidth>e.clientWidth+Bs)return!0;const n=e.scrollHeight;return t!==void 0?n>t+Bs:n>e.clientHeight+Bs}function Mf(e){if(e.getAttribute("data-fit")!=="shrink")return;const t=dr(zs(e,"data-fit-min")),n=Math.max(zs(e,"data-fit-base")??t,t),r=zs(e,"data-fit-mm"),o=r!==void 0&&r>0?un(r):void 0,i=s=>{const d=em(s);return e.style.fontSize=`${d}pt`,e.setAttribute("data-fit-size",String(d)),d},a=i(n);if(!_f(e,o)||n<=t)return a;let l=t,c=n;for(let s=0;s<rv;s++){const d=(l+c)/2;i(d),_f(e,o)?c=d:l=d}return i(l)}function ov(e){const t=[];return e.querySelectorAll('[data-fit="shrink"]').forEach(n=>{const r=Mf(n),o=n.getAttribute("data-fit-key");r===void 0||!o||t.push({key:o,fontSizePt:r})}),t}const iv="2",av=5e3;async function sv(e,t=av){const n=e.document,r=i=>Promise.race([i,new Promise(a=>setTimeout(a,t))]),o=(async()=>{n.readyState!=="complete"&&await r(new Promise(a=>e.addEventListener("load",()=>a(),{once:!0})));const i=n.fonts;i&&(await r(Promise.all(lv(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 lv(e){const t=[];for(const r of Array.from(e.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&&t.push({family:l,weight:a.getPropertyValue("font-weight")||"400",style:a.getPropertyValue("font-style")||"normal"})}}return t}function cv(e){const t=[];return e.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){const c=r.querySelectorAll(".print-flow-row[data-flow-row-index]");if(c.length>0){const s=[];c.forEach(d=>s.push(d.getBoundingClientRect().height)),t.push({id:o,heightPx:i,rowHeightsPx:s});return}t.push({id:o,heightPx:i});return}const l=[];a.querySelectorAll("tbody > tr[data-row-index]").forEach(c=>{l.push(c.getBoundingClientRect().height)}),t.push({id:o,heightPx:i,rowHeightsPx:l})}),t}function dv(e){const t=e.querySelector(".print-page"),n=e.querySelector(".content-area");if(!t||!n)return 0;const r=t.getBoundingClientRect().top;let o=0;n.querySelectorAll("*").forEach(a=>{if(a.classList.contains("print-element"))return;const l=a.getBoundingClientRect();l.height>0&&(o=Math.max(o,l.bottom-r))}),n.querySelectorAll(".print-element").forEach(a=>{const l=a.getBoundingClientRect(),c=Number.parseFloat(e.defaultView?.getComputedStyle(a).marginBottom??"0")||0;l.height>0&&(o=Math.max(o,l.bottom-r+c))});const i=n.getBoundingClientRect();return i.height>0&&(o=Math.max(o,i.bottom-r)),o}function uv(e,t=0){const r=e.querySelectorAll(".print-page")[t];if(!r)return[];const o=r.getBoundingClientRect(),i=e.defaultView?.getComputedStyle(r),a=Number.parseFloat(i?.paddingLeft??"0")||0,l=Number.parseFloat(i?.paddingTop??"0")||0,c=[];return r.querySelectorAll("[data-element-id]").forEach(s=>{if(s.querySelector("[data-element-id]"))return;const d=s.getAttribute("data-element-id");if(!d)return;const p=s.getBoundingClientRect(),u=pv(s,o,a,l);c.push({id:d,left:p.left-u.left,top:p.top-u.top,width:p.width,height:p.height,zone:u.zone})}),c}function pv(e,t,n,r){const o=(c,s)=>{const d=c.getBoundingClientRect();return{left:d.left,top:d.top,zone:s}},i=e.closest(".page-header");if(i)return o(i,"header");const a=e.closest(".page-footer");if(a)return o(a,"footer");const l=e.closest(".content-area");return l?o(l,"content"):{left:t.left+n,top:t.top+r,zone:"content"}}function fv(e){const t={};for(const n of e)try{t[n.key]=Sf(n.value,n.cellType,n.opts)}catch{}return t}const hv={version:iv,waitReady:sv,readMeasurements:cv,readContentBottom:dv,readElementRects:uv,renderCodes:fv,applyTextFit:ov};function gv(){return{async createDriver(){const e=document.createElement("iframe");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;left:-10000px;top:0;border:0;visibility:hidden;pointer-events:none;",document.body.appendChild(e);let t=e.contentDocument??document;return{requiresExecutor:!1,async open(n){e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,t=e.contentDocument??document},async setContent(n){t=e.contentDocument??document,t.open(),t.write(n),t.close()},async injectExecutor(n){},async evaluate(n,r){const o=hv[n];if(typeof o!="function"){const s=(e.contentWindow?.__wormDom??globalThis.__wormDom)?.[n];if(typeof s!="function")throw new Error(`执行器方法 ${n} 未注入`);return s(...r??[])}const i=r??[],a=n1[n],l=o;return a==="window"?l(e.contentWindow,...i):a==="document"?l(t,...i):l(...i)},async close(){e.remove()}}}}}function mv(){return i1(gv())}async function bv(e,t,n,r,o){const i=await m1({templateJson:e,printData:t,baseUrl:n,fontBaseUrl:o?.fontBaseUrl??"",paperHeightMm:o?.paperHeightMm,codeRenderer:r,renderers:o?.renderers},mv());return{html:i.html,pageCount:i.pageCount,pageLayouts:i.pageLayouts,paperMm:i.paperMm,pagePaperMm:i.pagePaperMm,continuous:i.continuous,copies:i.copies,copyPaperMm:i.copyPaperMm}}var Tf=Symbol.for("worm-print-platform.element-ui-registry.v1"),Cf=globalThis;function Hs(){const e=Cf[Tf];if(e)return e;const t={entries:new Map,listeners:new Set,nextSeq:0};return Cf[Tf]=t,t}function yv(e){if(e)return Hs().entries.get(e)?.ui}function vv(){const e=[...Hs().entries.entries()];return e.sort((t,n)=>t[1].seq-n[1].seq),e.map(([t,n])=>({type:t,ui:n.ui}))}function wv(e){const t=Hs();return t.listeners.add(e),()=>{t.listeners.delete(e)}}function h(e,t={},n=[]){return{tag:e,props:t,children:n}}var Us="http://www.w3.org/2000/svg",xv=new Set(["draggable","contenteditable","spellcheck"]),Ev=new Set(["indeterminate"]);function Sv(e){return e==="svg"||e==="path"||e==="circle"||e==="rect"||e==="line"||e==="g"}function _v(e){return e instanceof Element&&e.namespaceURI===Us}function Ze(e,t){if(typeof e=="string"){const a=document.createTextNode(e);return t.appendChild(a),a}if(e instanceof Node)return t.appendChild(e),e;const{tag:n,props:r,children:o}=e,i=Sv(n)||_v(t)?document.createElementNS(Us,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 Ev.has(a)?i[a]=!0:typeof l=="boolean"?l&&i.setAttribute(a,xv.has(a)?"true":""):i.setAttribute(a,String(l));for(const a of o)Ze(a,i);return t.appendChild(i),i}function kf(e){for(;e.firstChild;)e.removeChild(e.firstChild)}var Mv=Us;function qr(){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 qs="开启拼版后只能有一个设计页面";function Ws(e){const t=(n,r)=>(n??[]).map(o=>{const i={...o.options};return(o.printElementType?.type??o.type)==="table"&&sr(i),{id:o.id||Bn(),zone:r,options:i,printElementType:{...o.printElementType}}});return{...e,margins:{...e.margins},header:{height:e.header?.height??10,elements:[]},footer:{height:e.footer?.height??10,elements:[]},guides:[...e.guides??[]],elements:[...t(e.elements??[],"content"),...t(e.header?.elements??[],"header"),...t(e.footer?.elements??[],"footer")]}}function Af(e){const t=e.elements,n=r=>t.filter(o=>(o.zone||"content")===r).map(o=>({id:o.id,type:o.printElementType.type,options:{...o.options},printElementType:{...o.printElementType}}));return{unit:"mm",...e,header:{...e.header,elements:n("header")},footer:{...e.footer,elements:n("footer")},elements:n("content"),guides:[...e.guides??[]]}}function Df(e){const t=(r,o)=>{const i=Ws(jm(r));return i.name||(i.name=`页面 ${o+1}`),i};if(!e)return[t(qr(),0)];const n=Array.isArray(e.pages)?e.pages:[e];return n.length?n.map(t):[t(qr(),0)]}const Xn=e=>JSON.parse(JSON.stringify(e));class Of{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=H1();group=U1();constructor(t={}){if(this.pages=Df(t.initialTemplate),this.fields=t.initialFields??[],t.initialElements?.length){const n=this.pages[0];n.elements=[...n.elements,...t.initialElements]}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}emit(t=!0){t&&(this.dirty=!0);for(const n of[...this.listeners])n()}get templateData(){return this.pages[this.activePageIndex]}set templateData(t){this.pages[this.activePageIndex]=t}get elements(){return this.templateData.elements.map(t=>this.live.get(t.id)??t)}get tilingEnabled(){return this.pages.some(t=>t.tiling?.enabled===!0)}switchPage(t){t<0||t>=this.pages.length||(this.activePageIndex=t,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(qs);return}this.recordHistory();const t=this.pages[this.activePageIndex]??qr();this.pages.push(Ws({...qr(),paperSize:t.paperSize,orientation:t.orientation,outputRotation:t.outputRotation,customWidth:t.customWidth,customHeight:t.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const t=new Set(this.pages.map(r=>r.name));let n=this.pages.length+1;for(;t.has(`页面 ${n}`);)n++;return`页面 ${n}`}duplicatePage(t){if(this.tilingEnabled){window.alert(qs);return}this.recordHistory();const n=Xn(this.pages[t]);n.name=`${n.name??`页面 ${t+1}`} 副本`,n.elements=n.elements.map(r=>({...r,id:Bn()})),this.pages.splice(t+1,0,n),this.switchPage(t+1),this.emit()}deletePage(t){this.pages.length<=1||(this.recordHistory(),this.pages.splice(t,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(t,n){this.recordHistory(),this.pages[t].name=n,this.emit()}movePage(t,n){if(n<0||n>=this.pages.length||t===n)return;this.recordHistory();const[r]=this.pages.splice(t,1);this.pages.splice(n,0,r),this.activePageIndex=n,this.emit()}onSelectionChanged;setSelection(t){this.selectedIds=t,this.onSelectionChanged?.(),this.emit(!1)}select(t){this.setSelection(new Set(t))}selectOne(t,n=!1){if(n){const r=new Set(this.selectedIds);r.has(t)?r.delete(t):r.add(t),this.setSelection(r)}else this.setSelection(new Set([t]))}clearSelection(){this.setSelection(new Set)}selectElement(t,n=!1){if(n){this.selectOne(t,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,t)))}selectAll(){this.setSelection(new Set(this.elements.map(t=>t.id)))}get selectedElements(){return this.elements.filter(t=>this.selectedIds.has(t.id))}get selectedElement(){const t=this.selectedIds.values().next().value;return t?this.elements.find(n=>n.id===t)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(t){this.tableSelection=t,this.emit(!1)}setPreview(t){this.previewIds=t,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=[...r,{id:Bn(),type:t,position:Math.round(n*10)/10}],this.emit()}moveGuide(t,n){const r=this.templateData.guides??[];this.templateData.guides=r.map(o=>o.id===t?{...o,position:Math.round(n*10)/10}:o),this.emit(!1)}removeGuide(t){this.templateData.guides=(this.templateData.guides??[]).filter(n=>n.id!==t),this.emit()}addElement(t,n={},r){const o=_a(t,n);return r&&!this.placeAtDropPoint(o,r)||(this.recordHistory(),this.templateData.elements.push(o),this.select(new Set([o.id])),this.emit()),o}addFieldElement(t,n={},r,o=!1){const i=o?B1(t):L1(t);return Object.assign(i.options,n),r&&!this.placeAtDropPoint(i,r)||(this.recordHistory(),this.templateData.elements.push(i),this.select(new Set([i.id])),this.emit()),i}placeAtDropPoint(t,n){const r=this.templateData,o=ld(r,n.x,n.y);if(o!=="content"&&!sd(t.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const i=Oa(r)[o];return t.zone=o,t.options.left=n.x-i.left,t.options.top=n.y-i.top,o!=="content"&&Ia(t,i),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(t=>!this.selectedIds.has(t.id)),this.selectedIds=new Set,this.emit())}livePatch(t,n){const r=this.templateData.elements.find(i=>i.id===t);if(!r)return;const o=this.live.get(t)??r;this.live.set(t,{...o,options:{...o.options,...n}})}commitLive(){if(!this.live.size)return;this.recordHistory();const t=this.templateData.elements;for(const[n,r]of this.live){const o=t.find(i=>i.id===n);o&&Object.assign(o.options,r.options)}this.live.clear(),this.emit()}dragIds(t){const n=this.templateData.elements.find(r=>r.id===t);return!n||n.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,t))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(t=>[t.id,this.geoSig(t)]))}dragStop(){const t=this.dragBefore;if(!t)return;this.dragBefore=null;let n=!1;for(const r of this.elements){const o=t.get(r.id);!o||o===this.geoSig(r)||p0(r,this.templateData).rejected&&(n=!0)}n&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(t){return`${t.zone||"content"}:${t.options.left},${t.options.top},${t.options.width},${t.options.height}`}updateElement(t,n,r=!0){r&&this.recordHistory();const o=this.templateData.elements.find(i=>i.id===t);o&&(Object.assign(o.options,n),o.printElementType.type==="table"&&sr(o.options),this.emit())}updateTemplateData(t){this.recordHistory(),Object.assign(this.templateData,t);for(const n of["paperSize","customWidth","customHeight"])if(n in t)for(const r of this.pages)Object.assign(r,{[n]:t[n]});this.emit()}moveLayer(t){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(t==="top")this.templateData.elements=[...o,...r];else if(t==="bottom")this.templateData.elements=[...r,...o];else{const i=n.findIndex(c=>this.selectedIds.has(c.id)),a=t==="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(t){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(n=>this.selectedIds.has(n.id)),t),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=Xn(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(t=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?Pu():void 0);const o=this.templateData.elements;for(const i of this.clipboard){const a=Xn(i);a.id=Bn(),a.options.left+=t,a.options.top+=t,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 t=this.templateData.elements;this.selectOne(t[t.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(t,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+=t,o.options.top+=n;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(t){this.recordHistory(),this.templateData.elements.push(t),this.selectedIds=new Set([t.id]),this.emit()}recordHistory(){this.undoStack.push({pages:Xn(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 t=this.undoStack.pop();t&&(this.redoStack.push({pages:Xn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}redo(){const t=this.redoStack.pop();t&&(this.undoStack.push({pages:Xn(this.pages),activePageIndex:this.activePageIndex}),this.pages=t.pages,this.activePageIndex=Math.min(t.activePageIndex,t.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(t,n=So){this.scale=Math.max(n,Math.round(t)),this.emit(!1)}getTemplateJson(){const t=this.pages.map(Af),n=t.length===1?t[0]:{version:1,pages:t};return JSON.stringify(n)}loadTemplate(t){this.pages=Df(t),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return Jt(this.templateData)}}const _n=Symbol("mixed"),js=new Set(["text","longText"]),Tv=["top","right","bottom","left"],Cv={on:!0,off:!1,mixed:_n};function If(e){const t=Zc(e),n={};for(const r of Tv)n[r]=Cv[t[r]];return n}const kv=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class Av{constructor(t){this.store=t}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(t=>this.store.selectedIds.has(t.id)&&!t.options.locked)}get tableElement(){const t=this.store.tableSelection;return t?this.store.elements.find(n=>n.id===t.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 t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return[];const r=[];for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=n[o]?.cells[i];a&&!a.merged&&r.push(a)}return r}get textTargets(){return this.selectedElements.filter(t=>js.has(t.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(t=>t.options)}pick(t){if(!t.length)return;const n=t[0];return t.every(r=>r===n)?n:_n}hasToken(t,n){return(t??"").split(/\s+/).includes(n)}get values(){const t=this.styleTargets;if(!t.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=t.map(o=>o.fontWeight==="bold"||o.fontWeight==="bolder"),r=t.map(o=>o.textDecoration);return{fontFamily:this.pick(t.map(o=>o.fontFamily)),fontSize:this.pick(t.map(o=>o.fontSize)),color:this.pick(t.map(o=>o.color)),backgroundColor:this.pick(t.map(o=>o.backgroundColor)),textAlign:this.pick(t.map(o=>this.context==="cells"?o.align:o.textAlign)),verticalAlign:this.pick(t.map(o=>this.context==="cells"?o.valign:o.verticalAlign)),bold:n.every(Boolean)?!0:n.some(Boolean)?_n:!1,underline:r.map(o=>this.hasToken(o,"underline")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"underline"))?_n:!1,strike:r.map(o=>this.hasToken(o,"line-through")).every(Boolean)?!0:r.some(o=>this.hasToken(o,"line-through"))?_n:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(t){const n=this.targetCells;n.length&&(n.forEach(t),this.commit())}applyStyle(t){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in t&&(l.fontFamily=t.fontFamily),"fontSize"in t&&(l.fontSize=t.fontSize),"color"in t&&(l.color=t.color),"backgroundColor"in t&&(l.backgroundColor=t.backgroundColor),"textAlign"in t&&(l.align=t.textAlign),"verticalAlign"in t&&(l.valign=t.verticalAlign)});return}const n=this.textTargets,r=this.selectedElements,i=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in t),a="backgroundColor"in t;!(n.length&&i)&&!(r.length&&a)||(n.forEach(l=>{const c=l.options;"fontFamily"in t&&(c.fontFamily=t.fontFamily),"fontSize"in t&&(c.fontSize=t.fontSize),"color"in t&&(c.color=t.color),"textAlign"in t&&(c.textAlign=t.textAlign),"verticalAlign"in t&&(c.verticalAlign=t.verticalAlign)}),a&&r.forEach(l=>{l.options.backgroundColor=t.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 t=this.values.bold!==!0,n=this.textTargets;n.length&&(n.forEach(r=>{r.options.fontWeight=t?"bold":"normal"}),this.commit())}toggleDecoration(t){if(this.context==="cells")return;const n=this.textTargets;if(!n.length)return;const r=this.values[t==="underline"?"underline":"strike"]!==!0;n.forEach(o=>{const i=(o.options.textDecoration??"").split(/\s+/).filter(Boolean),a=i.indexOf(t);r&&a<0&&i.push(t),!r&&a>=0&&i.splice(a,1),o.options.textDecoration=i.length?i.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const t=this.store.tableSelection,n=this.tableElement?.options.tableRows;if(!t||!n)return;const r=`cells:${t.elementId}:${t.r1}:${t.c1}:${t.r2}:${t.c2}`;if(r===this.borderDraftKey)return;if(this.borderDraftKey=r,oa(n,t).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const o=cc(n,t);if(o.style===void 0&&o.width===void 0&&o.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:o.style==="mixed",width:o.width==="mixed",color:o.color==="mixed"},this.borderMixed.style?this.borderStyle=null:o.style===void 0?this.borderStyle="solid":o.style==="none"?this.borderStyle=null:this.borderStyle=o.style,this.borderWidth=this.borderMixed.width?void 0:typeof o.width=="number"?o.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof o.color=="string"?o.color:"#333333"}borderSpec(){const t=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:t,color:this.borderColor??"#333333"}}setBorderWidth(t){this.borderWidth=t,this.borderMixed.width=!1}setBorderColor(t){this.borderColor=t,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(t){const n=this.borderStyle===t?null:t;this.borderMixed.style=!1,this.borderStyle=n,n===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(t,n){const r=this.selectedElements;r.length&&(r.forEach(o=>{Jc(o.options,t,n)}),this.commit())}applyCellBorderPreset(t,n){const r=this.store.tableSelection,o=this.tableElement?.options.tableRows;!r||!o||(sc(o,{r1:r.r1,c1:r.c1,r2:r.r2,c2:r.c2},t,n),this.commit())}applyCellBorderEdges(t,n,r){this.writeCells(o=>{for(const i of t)lc(o,i,r?n:null)})}get cellEdges(){if(this.context!=="cells")return null;const t=this.targetCells;return t.length?If(t.map(n=>n.borders)):null}toggleCellEdge(t,n){const r=this.cellEdges?.[t]!==!0;this.applyCellBorderEdges([t],n,r)}get elementEdges(){if(this.context!=="elements")return null;const t=this.selectedElements;return t.length?If(t.map(n=>Ym(n.options))):null}toggleElementEdge(t,n){const r=this.selectedElements;if(!r.length)return;const o=this.elementEdges?.[t]!==!0;r.forEach(i=>Aa(i.options,t,o,n)),this.commit()}applyBorderPreset(t){const n=this.borderStyle===null;if(this.context==="cells"){const r=n&&!this.borderMixed.style;this.applyCellBorderPreset(r?"none":t,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(n||t==="none"?"none":"all",this.borderSpec())}applyEdge(t){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([t],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(t);return}this.context==="cells"?(this.toggleCellEdge(t,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(t,this.borderSpec())}clearElementEdge(t){const n=this.selectedElements;n.length&&(n.forEach(r=>Aa(r.options,t,!1)),this.commit())}edgeOn(t){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[t]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(t){if(!t)return;const n={};for(const r of hr){const o=t[r];o&&(n[r]={...o})}return n}pickPainterSource(t=!1){const n=this.selectedElements[0];if(!n)return!1;const r=n.options,o=n.printElementType.type;return this.painterSnapshot={text:js.has(o)?Object.fromEntries(kv.map(i=>[i,r[i]])):null,backgroundColor:r.backgroundColor,border:mo(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=t,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(t){const n=this.painterSnapshot;if(!n||t.options.locked||t.id===this.painterSource)return!1;const r=t.options,o=t.printElementType.type;return n.text&&js.has(o)&&Object.assign(r,n.text),r.backgroundColor=n.backgroundColor,n.border&&mo(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 t=this.selectedElements;if(!t.length){this.cancelPainter();return}let n=!1;t.forEach(r=>{n=this.applyPainter(r)||n}),n&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(t){if(t.key!=="Escape"||!this.painterActive)return;const n=t.target?.tagName;n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||this.cancelPainter()}}const Dv="自定义属性";function Pf(){const e=[];for(const{plugin:t,kind:n}of mc()){const r=yv(n.type);if(!r)continue;const i=(n.designer??t.designer)?.materialCard;e.push({type:n.type,label:n.label,icon:n.icon??i?.icon??"Shapes",group:i?.group??r.group,ui:r})}return e}function Gs(e){if(e)return Pf().find(t=>t.type===e)}function Vs(e){if(!e)return;const t=Gs(e.printElementType.type);if(!t||!t.ui.renderProperty)return;const n=t.ui;if(n.hasProperties)try{if(!n.hasProperties(e))return}catch{return}const r=Dv;return{ui:n,label:r,icon:t.icon,searchKeywords:n.searchKeywords?[...n.searchKeywords]:[r,t.label,t.type]}}const Oi=Object.freeze([{type:"text",label:"文本",icon:"Type",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"barcode",label:"条形码",icon:"Barcode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"qrcode",label:"二维码",icon:"QrCode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"image",label:"图片",icon:"Image",material:!0,propertyGroup:"general",dblEditableField:"src",origin:"builtin"},{type:"table",label:"表格",icon:"Table",material:!0,propertyGroup:"table",origin:"builtin"},{type:"longText",label:"长文",icon:"TextAlignStart",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"flowList",label:"流式列表",icon:"List",material:!0,propertyGroup:"general",dblEditableField:"formatter",origin:"builtin"},{type:"hline",label:"横线",icon:"Minus",material:!0,propertyGroup:"general",origin:"builtin"},{type:"vline",label:"竖线",icon:"SeparatorVertical",material:!0,propertyGroup:"general",origin:"builtin"},{type:"rect",label:"矩形",icon:"Square",material:!0,propertyGroup:"general",origin:"builtin"},{type:"oval",label:"椭圆",icon:"Circle",material:!0,propertyGroup:"general",origin:"builtin"},{type:"html",label:"HTML",icon:"Code",material:!1,propertyGroup:"general",origin:"builtin"},{type:"pageNumber",label:"页码",icon:"Shapes",material:!1,propertyGroup:"general",origin:"builtin"}]),Rf=Symbol.for("worm-print-platform.element-definitions.v1"),Ff=globalThis;function Et(){const e=Ff[Rf];if(e)return e;const t={overrides:new Map,builtinRenderers:new Map,rendererOverrides:new Map,listeners:new Set,nextSeq:0,seq:new Map};return Ff[Rf]=t,t}function Wr(){for(const e of[...Et().listeners])try{e()}catch{}}function $f(e){const t=Et();return t.listeners.add(e),()=>{t.listeners.delete(e)}}function Ov(){return new Map(Oi.map(e=>[e.type,e]))}function Iv(e){if(!e?.type||typeof e.type!="string")throw new Error("registerElementDefinition: type 必须是非空字符串");if(!e.label||typeof e.label!="string")throw new Error("registerElementDefinition: label 必须是非空字符串");const t=Et(),n={...e,origin:e.origin??"custom"};return t.overrides.set(n.type,n),t.seq.set(n.type,t.nextSeq++),Wr(),()=>{const r=Et();r.overrides.get(n.type)===n&&(r.overrides.delete(n.type),Wr())}}function Pv(e,t){if(!e||typeof t!="function")throw new Error("registerElementRenderer: 需要 type 与渲染函数");return Et().rendererOverrides.set(e,t),Wr(),()=>{const r=Et();r.rendererOverrides.get(e)===t&&(r.rendererOverrides.delete(e),Wr())}}function Nf(e){const t=Et();for(const[n,r]of Object.entries(e))t.builtinRenderers.set(n,r);return()=>{const n=Et();for(const[r,o]of Object.entries(e))n.builtinRenderers.get(r)===o&&n.builtinRenderers.delete(r)}}function Rv(e){const t=Gs(e);if(t)return{type:t.type,label:t.label,icon:t.icon,group:t.group,material:!0,propertyGroup:"general",origin:"plugin"}}function tn(e){if(!e)return;const t=Et(),n=t.overrides.get(e)??Ov().get(e)??Rv(e);if(!n)return;const r=t.rendererOverrides.get(e)??t.builtinRenderers.get(e);return r?{...n,renderContent:r}:n}function Lf(){const e=Et(),t=[],n=new Set;for(const o of Oi)t.push(tn(o.type)??o),n.add(o.type);const r=[...e.overrides.entries()].filter(([o])=>!n.has(o)).sort((o,i)=>(e.seq.get(o[0])??0)-(e.seq.get(i[0])??0));for(const[o]of r){const i=tn(o);i&&t.push(i),n.add(o)}for(const o of Pf()){if(n.has(o.type))continue;const i=tn(o.type);i&&t.push(i),n.add(o.type)}return t}function Bf(){return Lf().filter(e=>e.material)}function zf(e){return tn(e)?.propertyGroup??"general"}function Hf(e){return tn(e)?.dblEditableField}function Uf(e){return tn(e)?.icon??"Shapes"}function Fv(){const e=Et();e.overrides.clear(),e.rendererOverrides.clear(),e.seq.clear(),e.nextSeq=0,Wr()}const Ys="1.3.0",qf="print-designer",Ks=["template","fields","name","fonts","design-data","theme","theme-config","field-display"],Wf=["is-edit","show-help","show-preview","show-save"],$v=Object.freeze({bubbles:!0,composed:!0}),Xs=["container","toolbar","format-bar","left-panel","canvas-area","property-panel","status-bar","page-tabs"],jf=["--pd-bg","--pd-surface","--pd-field-bg","--pd-sidebar","--pd-sidebar-hover","--pd-canvas-bg","--pd-paper","--pd-accent","--pd-accent-2","--pd-accent-soft","--pd-accent-secondary","--pd-danger-soft","--pd-ink-green","--pd-text","--pd-text-muted","--pd-text-faint","--pd-border","--pd-border-soft","--pd-input-bg","--pd-hover-tint","--pd-danger","--pd-danger-bg","--pd-danger-border","--pd-menu-text","--pd-menu-hover","--pd-menu-border","--pd-menu-divider","--pd-menu-muted","--pd-menu-disabled","--pd-scrollbar","--pd-scrollbar-thumb","--pd-scrollbar-thumb-hover","--pd-help-field-bg","--pd-help-field-line","--pd-help-field-ink","--pd-help-function-bg","--pd-help-function-line","--pd-help-function-ink","--pd-help-variable-bg","--pd-help-variable-line","--pd-help-variable-ink","--pd-help-conditional-bg","--pd-help-conditional-line","--pd-help-conditional-ink","--pd-handle","--pd-ruler","--pd-ruler-bg","--pd-ruler-cursor","--pd-radius","--pd-shadow-sm","--pd-shadow-md","--pd-shadow-paper","--pd-success","--pd-text-regular","--pd-fill-light"],Gf=["getTemplateJson","loadTemplate","save","validateTemplate","getGeometryWarnings"],Vf=["template","fields","fonts","designData","isEdit","showHelp","showPreview","showSave","theme","themeConfig","uploadImage","uploadDesignBackground","fieldDisplay"],St=Object.freeze({save:"save",preview:"preview",help:"help",dblclickElement:"dblclick-element",dblclickCell:"dblclick-cell"}),Yf=[St.save,St.preview,St.help,St.dblclickElement,St.dblclickCell];function Zs(){return{version:Ys,tag:qf,attributes:Ks,booleanAttributes:Wf,events:Yf,parts:Xs,themeTokens:jf,methods:Gf,properties:Vf}}const Nv={"--pd-bg":"#181a20","--pd-surface":"#1f2229","--pd-field-bg":"#252830","--pd-sidebar":"#1f2229","--pd-sidebar-hover":"#2b2f39","--pd-accent":"#4C8DFF","--pd-accent-2":"#6C9DFF","--pd-accent-soft":"rgba(76, 141, 255, .16)","--pd-accent-secondary":"#ff7a7a","--pd-danger-soft":"rgba(255, 122, 122, .14)","--pd-ink-green":"#6cce5a","--pd-text":"#e6e8ee","--pd-text-muted":"#9aa0ad","--pd-text-faint":"#6f7683","--pd-text-regular":"#c9cdd8","--pd-border":"#3a3f4b","--pd-border-soft":"#2d323c","--pd-input-bg":"#262a33","--pd-hover-tint":"rgba(76, 141, 255, .12)","--pd-fill-light":"#2b2f39","--pd-danger":"#ff6b6b","--pd-danger-bg":"#3a2226","--pd-danger-border":"#6b3535","--pd-success":"#4ade80","--pd-menu-text":"#d6d9e0","--pd-menu-hover":"#2b2f39","--pd-menu-border":"#3a3f4b","--pd-menu-divider":"#2d323c","--pd-menu-muted":"#8b91a0","--pd-menu-disabled":"#555b68","--pd-scrollbar":"rgba(255, 255, 255, .18)","--pd-scrollbar-thumb":"rgba(255, 255, 255, .16)","--pd-scrollbar-thumb-hover":"rgba(255, 255, 255, .3)","--pd-help-field-bg":"#16283a","--pd-help-field-line":"#2c5870","--pd-help-field-ink":"#7cc4f5","--pd-help-function-bg":"#162e22","--pd-help-function-line":"#2c5b3c","--pd-help-function-ink":"#79d69a","--pd-help-variable-bg":"#302c16","--pd-help-variable-line":"#6b5d24","--pd-help-variable-ink":"#d6b25e","--pd-help-conditional-bg":"#301a28","--pd-help-conditional-line":"#6b3454","--pd-help-conditional-ink":"#e58ab5","--pd-shadow-sm":"0 1px 2px rgba(0, 0, 0, .3)","--pd-shadow-md":"0 2px 8px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .5)"};function Kf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Lv(e){if(Array.isArray(e))return e}function Bv(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);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 zv(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
271
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hv(e,t){return Lv(e)||Bv(e,t)||Uv(e,t)||zv()}function Uv(e,t){if(e){if(typeof e=="string")return Kf(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Kf(e,t):void 0}}const Xf=Object.entries,qv=Object.keys,Zf=Object.setPrototypeOf,Wv=Object.isFrozen,Jf=Object.getPrototypeOf,Qf=Object.getOwnPropertyDescriptor;let Le=Object.freeze,De=Object.seal,nn=Object.create,eh=typeof Reflect<"u"&&Reflect,Ii=eh.apply,Js=eh.construct;Le||(Le=function(t){return t}),De||(De=function(t){return t}),Ii||(Ii=function(t,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 t.apply(n,o)}),Js||(Js=function(t){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 t(...r)});const Ht=we(Array.prototype.forEach),jv=we(Array.prototype.lastIndexOf),th=we(Array.prototype.pop),jr=we(Array.prototype.push),Gv=we(Array.prototype.slice),Vv=we(Array.prototype.splice),Zn=Array.isArray,Qs=oh(Set),el=we(Set.prototype.add),Gr=we(Set.prototype.has),Mn=we(String.prototype.toLowerCase),tl=we(String.prototype.toString),Yv=we(String.prototype.match),Pi=we(String.prototype.replace),nl=we(String.prototype.indexOf),Kv=we(String.prototype.trim),Xv=we(Number.prototype.toString),Zv=we(Boolean.prototype.toString),nh=typeof BigInt>"u"?null:we(BigInt.prototype.toString),rh=typeof Symbol>"u"?null:we(Symbol.prototype.toString),je=we(Object.prototype.hasOwnProperty),Vr=we(Object.prototype.toString),Jv=RegExp.prototype.test,Be=function(t,n){return t instanceof RegExp&&(t.lastIndex=0),Ii(Jv,t,[n])},Ut=oh(TypeError);function we(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Ii(e,t,r)}}function oh(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Js(e,n)}}function ce(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mn;if(Zf&&Zf(e,null),!Zn(t))return e;let r=t.length;for(;r--;){let o=t[r];if(typeof o=="string"){const i=n(o);i!==o&&(Wv(t)||(t[r]=i),o=i)}e[o]=!0}return e}function Qv(e){for(let t=0;t<e.length;t++)je(e,t)||(e[t]=null);return e}function Ri(e){const t=nn(null);for(const r of Xf(e)){var n=Hv(r,2);const o=n[0],i=n[1];je(e,o)&&(Zn(i)?t[o]=Qv(i):i&&typeof i=="object"&&i.constructor===Object?t[o]=Ri(i):t[o]=i)}return t}function Yr(e){const t=nn(null),n=qv(e);let r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function ew(e){switch(typeof e){case"string":return e;case"number":return Xv(e);case"boolean":return Zv(e);case"bigint":return nh?nh(e):"0";case"symbol":return rh?rh(e):"Symbol()";case"undefined":return Vr(e);case"function":case"object":{if(e===null)return Vr(e);const t=e,n=mt(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Vr(r)}return Vr(e)}default:return Vr(e)}}function mt(e,t){for(;e!==null;){const r=Qf(e,t);if(r){if(r.get)return we(r.get);if(typeof r.value=="function")return we(r.value)}e=Jf(e)}function n(){return null}return n}function tw(e,t){for(;e!==null;){const n=Qf(e,t);if(n)return n.get?we(n.get):null;e=Jf(e)}return null}function nw(e){if(!e)return!1;try{return Be(e,""),!0}catch{return!1}}const ih=Le(["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"]),rl=Le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ol=Le(["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"]),rw=Le(["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"]),il=Le(["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"]),ow=Le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ah=Le(["#text"]),sh=Le(["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"]),al=Le(["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"]),lh=Le(["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"]),Fi=Le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),iw=De(/{{[\w\W]*|^[\w\W]*}}/g),aw=De(/<%[\w\W]*|^[\w\W]*%>/g),sw=De(/\${[\w\W]*/g),lw=De(/{{|}}|\${|<%|%>|&lt;%|%&gt;/),cw=De(/^data-[\-\w.\u00B7-\uFFFF]+$/),dw=De(/^aria-[\-\w]+$/),ch=De(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),uw=De(/^(?:\w+script|data):/i),pw=De(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fw=De(/^html$/i),hw=De(/^[a-z][.\w]*(-[.\w]+)+$/i),sl=De(/<[/\w!]/g),dh=De(/<[/\w]/g),gw=De(/<\/no(script|embed|frames)/i),uh=De(/\/>/i),mw=De(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),bw=De(/^[\r\n\t ]+/),Me={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},yw=Le(ce({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),vw=function(){return typeof window>"u"?null:window},ww=function(t,n){if(typeof t!="object"||typeof t.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 t.createPolicy(i,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},ph=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},rn=function(t,n,r,o){return je(t,n)&&Zn(t[n])?ce(o.base?Yr(o.base):{},t[n],o.transform):r},ll=function(t,n,r){const o=je(t,n)?t[n]:void 0;return o&&typeof o=="object"?Ri(o):r};function fh(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vw();const t=F=>fh(F);if(t.version="3.4.18",t.removed=[],!e||!e.document||e.document.nodeType!==Me.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,o=r.currentScript,i=e.HTMLTemplateElement,a=e.Node,l=e.Element,c=e.NodeFilter,s=e.DOMParser,d=e.trustedTypes,p=l.prototype,u=mt(p,"cloneNode"),f=mt(p,"remove"),g=mt(p,"removeAttributeNode"),m=mt(p,"nextSibling"),y=mt(p,"childNodes"),v=mt(p,"parentNode"),w=mt(p,"shadowRoot"),E=mt(p,"attributes"),T=a&&a.prototype?mt(a.prototype,"nodeType"):null,P=a&&a.prototype?mt(a.prototype,"nodeName"):null,O=a&&a.prototype?mt(a.prototype,"ownerDocument"):null,I=function(b){return T?T(b):b.nodeType},A=function(b){return P?P(b):b.nodeName},k=tw(p,"namespaceURI"),R=function(b){return k?k(b):b.namespaceURI};if(typeof i=="function"){const F=n.createElement("template");F.content&&F.content.ownerDocument&&(n=F.content.ownerDocument)}let S,$="",N,B=!1,C=0;const ie=function(){if(C>0)throw Ut('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.')},pe=function(b){ie(),C++;try{return S.createHTML(b)}finally{C--}},Ge=function(b){return S&&xe?pe(b):b},Q=function(b){ie(),C++;try{return S.createScriptURL(b)}finally{C--}},Te=function(){return B||(N=ww(d,o),B=!0),N},he=n,de=he.implementation,ye=he.createNodeIterator,ne=he.createDocumentFragment,Pe=he.getElementsByTagName,it=r.importNode;let te=ph();t.isSupported=typeof Xf=="function"&&typeof v=="function"&&de&&de.createHTMLDocument!==void 0;const Ve=iw,Re=aw,fe=sw,me=cw,tr=dw,to=uw,no=pw,ro=hw;let nr=ch,ge=null;const Mt=ce({},[...ih,...rl,...ol,...il,...ah]);let M=null;const H=ce({},[...sh,...al,...lh,...Fi]);let z=null,q=null,U=null;const V=Object.seal(nn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ee=!0,_=!0,G=!1,K=!0,Z=!1,oe=!0,be=!1,Ce=!1,Ue=null,Je=null,Fe=!1,at=!1,ve=!1,xe=!1,Tt=!0,In=!1;const st="user-content-";let Ee=!0,Lt=!1,bt=null,Ye=!1,yt=null;const Vt=ce({},["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 sn=null;const Ie=ce({},["audio","video","img","source","image","track"]);let $e=null;const Pn=ce({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Rn="http://www.w3.org/1998/Math/MathML",ae="http://www.w3.org/2000/svg",ue="http://www.w3.org/1999/xhtml";let lt=ue,ct=!1,oo=null;const Bl=ce({},[Rn,ae,ue],tl),zl=Le(ce({},["mi","mo","mn","ms","mtext"]));let Hl=null;const _E=Le(ce({},["annotation-xml"]));let Ul=null;const ME=Le(nn(null)),TE=ce({},["title","style","font","a","script"]);let io=null;const CE=["application/xhtml+xml","text/html"],kE="text/html";let ke=null,Zi=null;const AE=n.createElement("form"),mg=function(b){return b instanceof RegExp||b instanceof Function},ql=function(){let b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(!b||typeof b!="object")&&(b={}),b=Ri(b),io=CE.indexOf(b.PARSER_MEDIA_TYPE)===-1?kE:b.PARSER_MEDIA_TYPE,ke=io==="application/xhtml+xml"?tl:Mn,ge=rn(b,"ALLOWED_TAGS",Mt,{transform:ke}),M=rn(b,"ALLOWED_ATTR",H,{transform:ke}),oo=rn(b,"ALLOWED_NAMESPACES",Bl,{transform:tl}),$e=rn(b,"ADD_URI_SAFE_ATTR",Pn,{transform:ke,base:Pn}),sn=rn(b,"ADD_DATA_URI_TAGS",Ie,{transform:ke,base:Ie}),yt=rn(b,"FORBID_CONTENTS",Vt,{transform:ke}),q=rn(b,"FORBID_TAGS",nn(null),{transform:ke}),U=rn(b,"FORBID_ATTR",nn(null),{transform:ke}),Ye=je(b,"USE_PROFILES")?b.USE_PROFILES&&typeof b.USE_PROFILES=="object"?Ri(b.USE_PROFILES):b.USE_PROFILES:!1,ee=b.ALLOW_ARIA_ATTR!==!1,_=b.ALLOW_DATA_ATTR!==!1,G=b.ALLOW_UNKNOWN_PROTOCOLS||!1,K=b.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Z=b.SAFE_FOR_TEMPLATES||!1,oe=b.SAFE_FOR_XML!==!1,be=b.WHOLE_DOCUMENT||!1,at=b.RETURN_DOM||!1,ve=b.RETURN_DOM_FRAGMENT||!1,xe=b.RETURN_TRUSTED_TYPE||!1,Fe=b.FORCE_BODY||!1,Tt=b.SANITIZE_DOM!==!1,In=b.SANITIZE_NAMED_PROPS||!1,Ee=b.KEEP_CONTENT!==!1,Lt=b.IN_PLACE||!1,nr=nw(b.ALLOWED_URI_REGEXP)?b.ALLOWED_URI_REGEXP:ch,lt=typeof b.NAMESPACE=="string"?b.NAMESPACE:ue,Hl=ll(b,"MATHML_TEXT_INTEGRATION_POINTS",zl),Ul=ll(b,"HTML_INTEGRATION_POINTS",_E);const x=ll(b,"CUSTOM_ELEMENT_HANDLING",ME);if(z=nn(null),je(x,"tagNameCheck")&&mg(x.tagNameCheck)&&(z.tagNameCheck=x.tagNameCheck),je(x,"attributeNameCheck")&&mg(x.attributeNameCheck)&&(z.attributeNameCheck=x.attributeNameCheck),je(x,"allowCustomizedBuiltInElements")&&typeof x.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=x.allowCustomizedBuiltInElements),De(z),Z&&(_=!1),ve&&(at=!0),Ye&&((je(b,"ALLOWED_TAGS")||je(b,"ALLOWED_ATTR"))&&typeof console<"u"&&typeof console.warn=="function"&&console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together."),ge=ce({},ah),M=nn(null),Ye.html===!0&&(ce(ge,ih),ce(M,sh)),Ye.svg===!0&&(ce(ge,rl),ce(M,al),ce(M,Fi)),Ye.svgFilters===!0&&(ce(ge,ol),ce(M,al),ce(M,Fi)),Ye.mathMl===!0&&(ce(ge,il),ce(M,lh),ce(M,Fi))),V.tagCheck=null,V.attributeCheck=null,je(b,"ADD_TAGS")&&(typeof b.ADD_TAGS=="function"?V.tagCheck=b.ADD_TAGS:Zn(b.ADD_TAGS)&&(ge===Mt&&(ge=Yr(ge)),ce(ge,b.ADD_TAGS,ke))),je(b,"ADD_ATTR")&&(typeof b.ADD_ATTR=="function"?V.attributeCheck=b.ADD_ATTR:Zn(b.ADD_ATTR)&&(M===H&&(M=Yr(M)),ce(M,b.ADD_ATTR,ke))),je(b,"ADD_FORBID_CONTENTS")&&Zn(b.ADD_FORBID_CONTENTS)&&(yt===Vt&&(yt=Yr(yt)),ce(yt,b.ADD_FORBID_CONTENTS,ke)),Ee&&(ge["#text"]=!0),be&&ce(ge,["html","head","body"]),ge.table&&(ge.tbody=!0,delete q.tbody),b.TRUSTED_TYPES_POLICY){if(typeof b.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof b.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ut('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const D=S;S=b.TRUSTED_TYPES_POLICY;try{$=pe("")}catch(L){throw S=D,L}}else b.TRUSTED_TYPES_POLICY===null?(S=void 0,$=""):(S===void 0&&(S=Te()),S&&typeof $=="string"&&($=pe("")));Zi=Le(b)},bg=ce({},[...rl,...ol,...rw]),yg=ce({},[...il,...ow]),DE=function(b,x,D){return x===ue?b==="svg":x===Rn?b==="svg"&&(D==="annotation-xml"||Hl[D]):!!bg[b]},OE=function(b,x,D){return x===ue?b==="math":x===ae?b==="math"&&Ul[D]:!!yg[b]},IE=function(b,x,D){return x===ae&&!Ul[D]||x===Rn&&!Hl[D]?!1:!yg[b]&&(TE[b]||!bg[b])},PE=function(b){const x=R(b),D=Mn(A(b)),L=v(b);let j=lt,X="template";return L&&I(L)===Me.element&&(j=R(L),X=Mn(A(L))),oo[x]?x===ae?DE(D,j,X):x===Rn?OE(D,j,X):x===ue?IE(D,j,X):io==="application/xhtml+xml":!1},ln=function(b){jr(t.removed,{element:b});try{v(b).removeChild(b)}catch{if(f(b),!v(b))throw Ut("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},vg=function(b,x,D){try{g(b,x)}catch{try{b.removeAttribute(D)}catch{}}},Wl=function(b){Vl(b);const x=y(b);x&&Ht(Gv(x),D=>{try{f(D)}catch{}}),I(b)===Me.element&&jl(b,!1)},rr=function(b,x,D){if(!D)try{D=x.getAttributeNode(b)}catch{D=null}if(jr(t.removed,{attribute:D||null,from:x}),D)vg(x,D,b);else try{x.removeAttribute(b)}catch{}if(b==="is")if(at||ve)try{ln(x)}catch{}else try{x.setAttribute(b,"")}catch{}},jl=function(b,x){const D=E(b);if(D)for(let L=D.length-1;L>=0;--L){const j=D[L],X=j&&j.name;typeof X=="string"&&!(x&&M[ke(X)])&&vg(b,j,X)}},Gl=function(b,x){let D=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const L=[b];for(;L.length>0;){const j=L.pop();if(x(j)===!1)continue;if(D&&I(j)===Me.element){const re=w(j);or(re)&&L.push(re)}const X=y(j);if(X)for(let re=X.length-1;re>=0;--re)L.push(X[re])}},Vl=function(b){Gl(b,x=>{I(x)===Me.element&&jl(x,!0)})},Yl=function(b){const x=[];return Gl(b,D=>{x.push(D)},!0),x},RE=function(b,x){const D=Qs();Ht(Yl(b),L=>{I(L)===Me.element&&el(D,L)}),Ht(x,L=>{I(L)===Me.element&&!Gr(D,L)&&jl(L,!0)})},wg=function(b,x){let D=!1;return Ht(t.removed,L=>{L.element&&(D=D||L.element===b,Vl(L.element))}),RE(b,x),D},FE=8,$E=function(b,x){const D=bt;let L=null;const j=()=>(L||(L=Qs(),Ht(x,X=>{el(L,X)})),L);for(let X=0;;X++){const re=Yl(b),Ne=[b];let Yt=!1;if(Ht(re,kt=>{I(kt)===Me.documentFragment?jr(Ne,kt):!Yt&&!Gr(D,kt)&&(Yt=Gr(j(),kt))}),!Yt)return;if(X>=FE)throw Ut("the tree kept changing during in-place sanitization; refusing to return it");Ht(Ne,(kt,dt)=>{NE(kt,dt>0,b,j())})}},NE=function(b,x,D,L){const j=Ji(b);let X;for(;X=j.nextNode();)!Gr(L,X)||Gr(bt,X)||(x&&Ct(te.uponSanitizeShadowNode,X,null),Jl(X,D))},LE=function(b){bt&&el(bt,b)},xg=function(b,x){return oe?b==="patchsrc"?!0:b==="for"&&x!=="label"&&x!=="output":!1},BE=function(b){oe&&Gl(b,x=>{const D=I(x);if(D===Me.processingInstruction||D===Me.comment&&Be(dh,x.data)){try{f(x)}catch{}return!1}if(D===Me.element){const L=x,j=ke(A(x));try{L.hasAttribute&&L.hasAttribute("patchsrc")&&L.removeAttribute("patchsrc"),L.hasAttribute&&L.hasAttribute("for")&&xg("for",j)&&L.removeAttribute("for")}catch{}}return!0})},Eg=function(b){let x=null,D=null;if(Fe)b="<remove></remove>"+b;else{const X=Yv(b,bw);D=X&&X[0]}io==="application/xhtml+xml"&&lt===ue&&(b='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+b+"</body></html>");const L=S?pe(b):b;if(lt===ue)try{x=new s().parseFromString(L,io)}catch{}if(!x||!x.documentElement){x=de.createDocument(lt,"template",null);try{x.documentElement.innerHTML=ct?$:L}catch{}}const j=x.body||x.documentElement;return b&&D&&j.insertBefore(n.createTextNode(D),j.childNodes[0]||null),lt===ue?Pe.call(x,be?"html":"body")[0]:be?x.documentElement:j},Ji=function(b){let x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const D=O?O(b):b.ownerDocument;return ye.call(D||b,b,(x?0:c.SHOW_ELEMENT)|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kl=function(b){return b=Pi(b,Ve," "),b=Pi(b,Re," "),b=Pi(b,fe," "),b},Xl=function(b){var x;Zl(b);const D=(x=b.querySelectorAll)===null||x===void 0?void 0:x.call(b,"template");D&&Ht(D,L=>{or(L.content)&&Xl(L.content)})},Zl=function(b){b.normalize();const x=Ji(b,!0);let D=x.nextNode();for(;D;)D.data=Kl(D.data),D=x.nextNode()},Qi=function(b){const x=P?P(b):null;return typeof x!="string"||ke(x)!=="form"?!1:typeof b.nodeName!="string"||typeof b.textContent!="string"||typeof b.removeChild!="function"||b.attributes!==E(b)||typeof b.removeAttribute!="function"||typeof b.removeAttributeNode!="function"||typeof b.getAttributeNode!="function"||typeof b.setAttribute!="function"||typeof b.namespaceURI!="string"||typeof b.insertBefore!="function"||typeof b.hasChildNodes!="function"||b.nodeType!==T(b)||b.childNodes!==y(b)},Sg=function(b){if(!T||typeof b!="object"||b===null)return null;try{const x=T(b);return typeof x=="number"?x:null}catch{return null}},or=function(b){return Sg(b)===Me.documentFragment},ao=function(b){return Sg(b)!==null};function Ct(F,b,x){F.length!==0&&Ht(F,D=>{D.call(t,b,x,Zi)})}const zE=function(b,x,D){return!!(oe&&D===Me.element&&b.hasChildNodes()&&!ao(b.firstElementChild)&&Be(sl,b.textContent)&&Be(sl,b.innerHTML)||oe&&yw[x]&&D===Me.element&&R(b)===ue&&(ao(b.firstElementChild)||typeof b.textContent=="string"&&Be(sl,b.textContent))||D===Me.processingInstruction||oe&&D===Me.comment&&Be(dh,b.data))},ea=function(b,x){if(b instanceof RegExp)return Be(b,x);if(b instanceof Function){for(var D=arguments.length,L=new Array(D>2?D-2:0),j=2;j<D;j++)L[j-2]=arguments[j];return!!b(x,...L)}return!1},HE=function(b,x,D){if(!q[x]&&Tg(x)&&ea(z.tagNameCheck,x))return!1;if(Ee&&!yt[x]&&!yt[Mn(x)]){const L=v(b),j=y(b);if(j&&L){const X=j.length;for(let re=X-1;re>=0;--re){const Ne=b===D?u(j[re],!0):j[re];L.insertBefore(Ne,m(b))}}}return ln(b),!0},_g=function(b,x,D,L){return b.length===0?x:x===D||x===L?Yr(x):x},ir=function(b,x){return b===x||v(b)!==null?!1:(Lt&&Vl(b),!0)},UE=function(b,x){if(LE(b),Ct(te.beforeSanitizeElements,b,null),ir(b,x))return!0;if(Qi(b))return ln(b),!0;const D=ke(A(b)),L=I(b);if(ge=_g(te.uponSanitizeElement,ge,Mt,Ue),Ct(te.uponSanitizeElement,b,{tagName:D,allowedTags:ge}),ir(b,x))return!0;if(zE(b,D,L))return ln(b),!0;if(q[D]||!(V.tagCheck instanceof Function&&V.tagCheck(D))&&!ge[D]){const j=HE(b,D,x);return j===!1&&(Ct(te.afterSanitizeElements,b,null),ir(b,x))?!0:j}if(L===Me.element&&!PE(b)||(D==="noscript"||D==="noembed"||D==="noframes")&&Be(gw,b.innerHTML))return ln(b),!0;if(Z&&L===Me.text){const j=b.textContent,X=Kl(j);j!==X&&(jr(t.removed,{element:b.cloneNode()}),b.textContent=X)}return Ct(te.afterSanitizeElements,b,null),ir(b,x)},Mg=function(b,x,D){if(U[x]||xg(x,b)||Tt&&(x==="id"||x==="name")&&(D in n||D in AE))return!1;const L=M[x]||V.attributeCheck instanceof Function&&V.attributeCheck(x,b);if(_&&Be(me,x)||ee&&Be(tr,x))return!0;if(!L)return Tg(b)&&ea(z.tagNameCheck,b)&&ea(z.attributeNameCheck,x,b)||x==="is"&&z.allowCustomizedBuiltInElements&&ea(z.tagNameCheck,D);if($e[x])return!0;const j=Pi(D,no,"");return Be(nr,j)||(x==="src"||x==="xlink:href"||x==="href")&&b!=="script"&&nl(D,"data:")===0&&sn[b]||G&&!Be(to,j)?!0:!D},qE=ce({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Tg=function(b){return!qE[Mn(b)]&&Be(ro,b)},WE=function(b,x,D,L){if(S&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!D)switch(d.getAttributeType(b,x)){case"TrustedHTML":return pe(L);case"TrustedScriptURL":return Q(L)}return L},jE=function(b,x,D,L){try{return D?b.setAttributeNS(D,x,L):b.setAttribute(x,L),Qi(b)?(ln(b),!1):!0}catch{return rr(x,b),!1}},Cg=function(b,x){return oe&&Be(mw,x)?!0:Mn(b)==="attributename"&&nl(x,"href")!==-1},GE=function(b,x){if(Ct(te.beforeSanitizeAttributes,b,null),ir(b,x))return;const D=b.attributes;if(!D||Qi(b))return;M=_g(te.uponSanitizeAttribute,M,H,Je);const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:M,forceKeepAttr:void 0};let j=D.length;const X=ke(A(b));for(;j--;){const re=D[j],Ne=re.name,Yt=re.namespaceURI,kt=re.value,dt=ke(Ne),Bt=kt;let qe=Ne==="value"?Bt:Kv(Bt),kg=!1;if(L.attrName=dt,L.attrValue=qe,L.keepAttr=!0,L.forceKeepAttr=void 0,Ct(te.uponSanitizeAttribute,b,L),qe=L.attrValue,In&&(dt==="id"||dt==="name")&&nl(qe,st)!==0&&(rr(Ne,b,re),qe=st+qe,kg=!0),Cg(Ne,qe)){rr(Ne,b,re);continue}if(!L.forceKeepAttr){if(!L.keepAttr){rr(Ne,b,re);continue}if(!K&&Be(uh,qe)){rr(Ne,b,re);continue}if(Z&&(qe=Kl(qe)),!Mg(X,dt,qe)){rr(Ne,b,re);continue}qe=WE(X,dt,Yt,qe),qe!==Bt&&jE(b,Ne,Yt,qe)&&kg&&th(t.removed)}}Ct(te.afterSanitizeAttributes,b,null),ir(b,x)},Jl=function(b,x){UE(b,x),GE(b,x),or(b.content)&&Ql(b.content)},Ql=function(b){let x=null;const D=Ji(b);for(Ct(te.beforeSanitizeShadowDOM,b,null);x=D.nextNode();)if(Ct(te.uponSanitizeShadowNode,x,null),Jl(x,b),I(x)===Me.element){const L=w(x);or(L)&&(ec(L),Ql(L))}Z&&Zl(b),Ct(te.afterSanitizeShadowDOM,b,null)},ec=function(b){const x=[{node:b,shadow:null}];for(;x.length>0;){const D=x.pop();if(D.shadow){Ql(D.shadow);continue}const L=D.node,j=I(L)===Me.element,X=y(L);if(X)for(let re=X.length-1;re>=0;--re)x.push({node:X[re],shadow:null});if(j){const re=P?P(L):null;if(typeof re=="string"&&ke(re)==="template"){const Ne=L.content;or(Ne)&&x.push({node:Ne,shadow:null})}}if(j){const re=w(L);or(re)&&x.push({node:null,shadow:re},{node:re,shadow:null})}}};return t.sanitize=function(F){let b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},x=null,D=null,L=null,j=null;if(ct=!F,ct&&(F="<!-->"),typeof F!="string"&&!ao(F)&&(F=ew(F),typeof F!="string"))throw Ut("dirty is not a string, aborting");if(!t.isSupported)return F;Ce?(ge=Ue,M=Je):ql(b),t.removed=[];const X=Lt&&typeof F!="string"&&ao(F);let re=[];const Ne=bt;if(X){BE(F);const Bt=A(F);if(typeof Bt=="string"){const qe=ke(Bt);if(!ge[qe]||q[qe])throw Wl(F),Ut("root node is forbidden and cannot be sanitized in-place")}if(Qi(F))throw Wl(F),Ut("root node is clobbered and cannot be sanitized in-place");re=Yl(F),bt=Qs()}else if(ao(F))x=Eg("<!---->"),D=x.ownerDocument.importNode(F,!0),D.nodeType===Me.element&&D.nodeName==="BODY"||D.nodeName==="HTML"?x=D:x.appendChild(D),ec(x);else{if(!at&&!Z&&!be&&F.indexOf("<")===-1)return Ge(F);if(x=Eg(F),!x)return at?null:xe?$:""}x&&Fe&&ln(x.firstChild);const Yt=X?F:x;try{X&&ec(F);const Bt=Ji(Yt);for(;L=Bt.nextNode();)Jl(L,Yt);X&&$E(F,re)}catch(Bt){throw X&&(Wl(F),wg(F,re)),Bt}finally{bt=Ne}if(X){if(wg(F,re))throw Ut("a node selected for removal could not be safely returned; refusing to sanitize in place");return Z&&Xl(F),F}if(at){if(Z&&Xl(x),ve)for(j=ne.call(x.ownerDocument);x.firstChild;)j.appendChild(x.firstChild);else j=x;return(M.shadowroot||M.shadowrootmode)&&(j=it.call(r,j,!0)),j}const kt=()=>be?x.outerHTML:x.innerHTML;let dt=kt();return Z&&Be(lw,dt)&&(Zl(x),dt=kt()),be&&ge["!doctype"]&&x.ownerDocument&&x.ownerDocument.doctype&&x.ownerDocument.doctype.name&&Be(fw,x.ownerDocument.doctype.name)&&(dt="<!DOCTYPE "+x.ownerDocument.doctype.name+`>
272
+ `+dt),Ge(dt)},t.setConfig=function(){let F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ql(F),Ce=!0,Ue=ge,Je=M},t.clearConfig=function(){Zi=null,Ce=!1,Ue=null,Je=null,S=N,$=""},t.isValidAttribute=function(F,b,x){Zi||ql({});const D=ke(F),L=ke(b);return typeof x=="string"&&(Cg(b,x)||!K&&Be(uh,x))?!1:Mg(D,L,x)},t.addHook=function(F,b){typeof b=="function"&&je(te,F)&&jr(te[F],b)},t.removeHook=function(F,b){if(je(te,F)){if(b!==void 0){const x=jv(te[F],b);return x===-1?void 0:Vv(te[F],x,1)[0]}return th(te[F])}},t.removeHooks=function(F){je(te,F)&&(te[F]=[])},t.removeAllHooks=function(){te=ph()},t}var xw=fh();const Ew={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Sw(e,t){const n=e.options;return us(n.formatter,t,String(n.testData||n.title||""))||"1234567890128"}function _w(e){return h("div",{class:"print-qrcode",dataset:{codeId:e.id,codeKind:"qrcode"}})}function Mw(e){const t=e.options;return h("div",{class:"print-barcode",dataset:{codeId:e.id,codeKind:"barcode"}},[h("svg",{preserveAspectRatio:Ew[String(t.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function Tw(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}function Cw(e,t,n){const r=e.options,o=fr(r.barWidth),i=pa(r.barQuietZone),a=l=>{fs(t,Sw(e,n),{format:String(r.barcodeType||"CODE128"),width:o,height:l*o,displayValue:!r.hideTitle,fontSize:(r.fontSize??ho)*o,margin:0,marginLeft:i*o,marginRight:i*o,marginTop:0,marginBottom:fa*o});const c=Tw(t);return c?{widthUnits:c.width,heightUnits:c.height}:null};try{const l=ga({barHeightMm:r.barHeight,boxWidthMm:Nn(r.width,r.maxWidth),boxHeightMm:Nn(r.height,r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:a});t.style.width=l.size?`${l.size.widthMm}mm`:"",t.style.height=l.size?`${l.size.heightMm}mm`:""}catch{t.replaceChildren();return}t.setAttribute("shape-rendering","crispEdges")}function kw(e,t,n){const r=e.options,o=us(r.formatter,n,String(r.testData||r.title||""))||"二维码";t.replaceChildren();try{const i=Ls.render(o,"qrcode",{qrCodeLevel:String(r.qrCodeLevel??"M"),qrQuietZone:typeof r.qrQuietZone=="number"?r.qrQuietZone:void 0}),a=document.createElement("img");a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,a.alt="qrcode",a.style.width="100%",a.style.height="100%",a.style.objectFit=String(r.fit||"contain"),a.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",a.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%",t.appendChild(a)}catch{}}function Aw(e,t,n){for(const r of Array.from(e.querySelectorAll("[data-code-kind]"))){const o=r.dataset.codeId,i=t.find(a=>a.id===o);if(i)if(r.dataset.codeKind==="barcode"){const a=r.querySelector("svg");a&&Cw(i,a,n)}else kw(i,r,n)}}const $i=new Map;function Dw(e){return typeof Node<"u"&&e instanceof Node}function hh(e,t,n){if(gh(e),typeof t=="string"){n.innerHTML=t;return}if(Dw(t)){n.appendChild(t);return}typeof t.node=="string"?n.innerHTML=t.node:n.appendChild(t.node),typeof t.dispose=="function"&&$i.set(e,t.dispose)}function gh(e){const t=$i.get(e);if(t){$i.delete(e);try{t()}catch{}}}function mh(){for(const e of[...$i.keys()])gh(e)}const Ow={header:"题",data:"数",subtotal:"小",summary:"汇"},Iw=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],Ni=3.7795275591,Pw=.1,cl=e=>JSON.parse(JSON.stringify(e)),bh=new WeakMap;function qt(e){let t=bh.get(e);return t||(t={menu:null,menuElId:null,anchor:null,layouts:new Map},bh.set(e,t)),t}function Kr(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function Rw(e,t){const n=e.tableSelection;return!n||n.elementId!==t.id?null:e.selectedElement?.id!==t.id?(e.tableSelection=null,null):n}function yh(e,t,n,r){const o=Kr(e,n.id);if(!o)return null;const i=n.options;return{store:e,fire:t,el:n,real:o,options:i,rows:i.tableRows??[],colWidths:i.tableColWidths??[],isSelected:e.selectedIds.has(n.id),selection:Rw(e,n),maxTableWidth:vh(e),designData:r}}function vh(e){return e.paperSize.width-e.templateData.margins.left-e.templateData.margins.right}function dl(e){return e.options.tableDefaultFontSize??10}function wh(e){return e.options.tableDefaultColor??"#333333"}function Fw(e,t){let n=0;for(let r=0;r<t;r++)n+=e.rows[r].height;return n}function $w(e,t){return qt(e.store).layouts.get(e.el.id)?.[t]?.top??Fw(e,t)}function Nw(e,t){return qt(e.store).layouts.get(e.el.id)?.[t]?.height??e.rows[t]?.height??0}function Lw(e){const t=e.options.dataSource;if(t&&Array.isArray(gt[t]))return gt[t];for(const n of Object.values(gt))if(Array.isArray(n))return n}function xh(e){return e.cellType==="barcode"||e.cellType==="qrcode"}function Eh(e,t){return xh(t)?us(t.formatter,Lw(e)):t.formatter||""}function Bw(e,t){const n={designMode:!0,showGhostBorder:e.store.showTableGhostBorder};return{fontFamily:Ka(t.fontFamily??e.options.tableDefaultFontFamily),textAlign:t.align??"left",...t.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:t.valign??"middle",fontSize:(t.fontSize??dl(e))+"pt",fontWeight:t.fontWeight??"normal",color:t.color??wh(e),backgroundColor:t.backgroundColor??"transparent",borderTop:co(t.borders?.top,n),borderRight:co(t.borders?.right,n),borderBottom:co(t.borders?.bottom,n),borderLeft:co(t.borders?.left,n),padding:(t.padding??e.options.tableDefaultPadding??1)+"mm",whiteSpace:t.wordWrap??!0?"pre-wrap":"nowrap",overflow:t.wordWrap??!0?"visible":"hidden"}}function zw(e,t,n){const r=e.selection;return[!!r&&t>=r.r1&&t<=r.r2&&n>=r.c1&&n<=r.c2?"cell-selected":"",e.rows[t]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Sh(e){return sa(e)}function Hw(e){return Sh(e)!=="autoHeight"}function Uw(e,t){return t.fontSize??dl(e)}function Li(e,t,n){return ur(e.rows,t,n,e.options.tableDefaultPadding??1)}function qw(e,t,n){return ca(e.colWidths,t,n,e.options.tableDefaultPadding??1)}function Ww(e,t,n){return{maxHeight:Li(e,n,t)+"mm",overflow:"hidden",...t.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function jw(e,t,n){const r={fitBase:String(Uw(e,t)),fitMin:String(dr(t.shrinkMinFontSize)),fitMm:String(Li(e,n,t))};return Sh(t)==="shrink"&&(r.fit="shrink"),r}function Gw(e){const t=(e.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return t.length!==4||t.some(n=>!Number.isFinite(n))?null:{width:t[2],height:t[3]}}const Vw={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Yw(e,t,n,r){const o=document.createElement("div");o.className="cell-barcode";const i=document.createElementNS(Mv,"svg");o.appendChild(i);const a=Eh(e,r);if(r.cellType==="barcode"){i.setAttribute("preserveAspectRatio",Vw[r.fit||"contain"]??"xMidYMid meet");const l=fr(r.barWidth),c=pa(r.barQuietZone),s=u=>{fs(i,a,{format:r.barcodeType||"CODE128",width:l,height:u*l,displayValue:r.showBarcodeText!==!1,fontSize:(r.barFontSize??ho)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:fa*l});const f=Gw(i);return f?{widthUnits:f.width,heightUnits:f.height}:null};let d=null;try{d=ga({barHeightMm:r.barHeight,boxWidthMm:Nn(qw(e,n,r),r.maxWidth),boxHeightMm:Nn(Li(e,t,r),r.maxHeight),dpi:r.printerDpi,barWidth:r.barWidth,measure:s})}catch{d=null}if(!d){i.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=a||"条码",o.appendChild(u),o}const p=d.size;return p?(i.style.width=`${p.widthMm}mm`,i.style.height=`${p.heightMm}mm`):(i.style.maxWidth=r.maxWidth?`${r.maxWidth}mm`:"100%",i.style.maxHeight=r.maxHeight?`${r.maxHeight}mm`:"100%"),i.setAttribute("shape-rendering","crispEdges"),o}if(i.style.display="none",!a)return o;try{const l=Ls.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 _h(){const e=document.createElement("div");return e.className="image-placeholder",e.textContent="图片",e}function Kw(e,t){const n=e.formatter||"";if(!n)return"";if(!n.includes("{"))return n;const r=t.designData?.length?t.designData[0]:gt;return Wn(n,r)}function Xw(e,t,n){const r=document.createElement("div");r.className="cell-image";const o=xc(n.fit,Li(e,t,n));o!==void 0&&(r.style.height=`${o}mm`);const i=Kw(n,e);if(!i)return r.appendChild(_h()),r;const a=document.createElement("img");a.setAttribute("src",i),o!==void 0&&(a.style.width="100%",a.style.height="100%"),a.style.objectFit=n.fit||"contain";for(const[l,c]of Object.entries(ma(n.fit,n.fitScale,n.objectPosition)))a.style[l]=c;return a.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",a.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",a.addEventListener("error",()=>{a.remove(),r.appendChild(_h())},{once:!0}),r.appendChild(a),r}function Zw(e,t,n,r,o){if(xh(o))return Yw(e,n,r,o);if(o.cellType==="image")return Xw(e,n,o);const i=Eh(e,o),a=()=>t.type==="data"?h("span",{class:"data-placeholder",text:i}):i;return Hw(o)?h("div",{class:"cell-fit",style:Ww(e,o,n),dataset:jw(e,o,n)},[a()]):a()}function Bi(e,t,n){const r={elementId:e.el.id,...tc(e.rows,t,n)};e.store.setTableSelection(r),e.fire("table-selection-change",{elementId:e.el.id,selection:r})}function Jw(e,t,n,r,o){if(o.button!==0||(e.fire("table-cell-mousedown",{elementId:e.el.id,r:t,c:n,cellId:r,event:o}),!e.isSelected))return;o.stopPropagation();const i=qt(e.store);o.shiftKey&&e.selection?Bi(e,{r:e.selection.r1,c:e.selection.c1},{r:t,c:n}):(i.anchor={r:t,c:n},Bi(e,{r:t,c:n},{r:t,c:n})),document.addEventListener("mouseup",()=>{qt(e.store).anchor=null},{once:!0})}function Qw(e,t,n){const r=qt(e.store).anchor;r&&Bi(e,r,{r:t,c:n})}function ul(e,t){const n=qt(e);n.menu?.visible&&(n.menu.visible=!1,t("table-menu-close",{elementId:n.menuElId}),e.emit(!1))}function ex(e,t,n,r){r.preventDefault(),r.stopPropagation(),e.isSelected||e.store.selectOne(e.el.id);const o=e.selection;o&&t>=o.r1&&t<=o.r2&&n>=o.c1&&n<=o.c2||Bi(e,{r:t,c:n},{r:t,c:n});const a=qt(e.store);a.menuElId=e.el.id,a.menu&&(a.menu.x=r.clientX,a.menu.y=r.clientY,a.menu.visible=!0),e.fire("table-cell-contextmenu",{elementId:e.el.id,r:t,c:n,clientX:r.clientX,clientY:r.clientY}),e.store.emit(!1),document.addEventListener("mousedown",()=>ul(e.store,e.fire),{once:!0})}function Mh(e,t,n){const r=e.reduce((o,i)=>o+i,0)+(e[t]??0);return r>n?`插入后表格总宽 ${Math.round(r*10)/10}mm 超过打印范围宽度 ${n}mm,请先缩小列宽`:null}function tx(e,t){const n=e.real.options.tableRows??[],r=e.real.options.tableColWidths??[],o=t(cl(n),cl(r));return o?(window.alert(o),!1):(e.store.recordHistory(),t(n,r),e.store.setTableSelection(null),sr(e.real.options),e.store.emit(),!0)}function Wt(e,t,n){ul(e.store,e.fire);const r=e.selection;if(!r)return;let o=null;switch(t){case"insert-row-above":o=i=>(ic(i,r.r1,"above"),null);break;case"insert-row-below":o=i=>(ic(i,r.r2,"below"),null);break;case"delete-row":o=i=>Rg(i,r.r1);break;case"insert-col-left":o=(i,a)=>{const l=Mh(a,r.c1,e.maxTableWidth);return l||(ac(i,a,r.c1,"left"),null)};break;case"insert-col-right":o=(i,a)=>{const l=Mh(a,r.c2,e.maxTableWidth);return l||(ac(i,a,r.c2,"right"),null)};break;case"delete-col":o=(i,a)=>Fg(i,a,r.c1);break;case"merge":o=i=>(rc(i,r),null);break;case"split":o=i=>(oc(i,r),null);break;case"set-row-type":o=i=>n?ra(i,r.r1,n):"未指定行类型";break}o&&tx(e,o)&&e.fire(`table-${t}`,{elementId:e.el.id,...n?{type:n}:{}})}function nx(e){const t=e.selection;if(!t)return!1;for(let n=t.r1;n<=t.r2;n++)for(let r=t.c1;r<=t.c2;r++){const o=e.rows[n]?.cells[r];if(o&&!o.merged&&((o.rowspan??1)>1||(o.colspan??1)>1))return!0}return!1}function rx(e){const t=e.selection;if(!t)return;const n=ar(e.rows,t.r1,t.c1),r=!e.rows[n.r]?.cells[n.c]?.mergeSameValue;for(let o=t.r1;o<=t.r2;o++)for(let i=t.c1;i<=t.c2;i++){const a=e.rows[o]?.cells[i];a&&!a.merged&&(a.mergeSameValue=r)}e.store.updateElement(e.el.id,{tableRows:e.rows}),ul(e.store,e.fire)}function Th(e){const t=e.selection;if(!t)return"未选择单元格";for(let n=t.r1;n<=t.r2;n++)if(e.rows[n]?.type!=="data")return"仅数据行(明细行)支持按值合并";return null}function Ch(e,t){const n=e.selection;return n?n.r1!==n.r2?"行类型仅支持单行设置":ra(cl(e.rows),n.r1,t):"未选择单元格"}function Rt(e,t,n={}){return h("div",{class:`menu-item${n.disabled?" disabled":""}${n.active?" active":""}`,title:n.title||"",text:e,onClick:()=>{n.disabled||t()}})}const pl=()=>h("div",{class:"menu-divider"});function ox(e,t,n){const r=qt(e);if(r.menu=n,!n.visible||!r.menuElId)return"";const o=Kr(e,r.menuElId);if(!o||o.printElementType.type!=="table")return"";const i=yh(e,t,o);if(!i)return"";const a=i.selection?nc(i.rows,i.selection):"未选择单元格",l=i.selection?i.rows[i.selection.r1]?.type??null:null;return h("div",{class:"table-ctx-menu",style:{left:n.x+"px",top:n.y+"px"},onMousedown:c=>c.stopPropagation()},[Rt("在上方插入行",()=>Wt(i,"insert-row-above")),Rt("在下方插入行",()=>Wt(i,"insert-row-below")),Rt("删除行",()=>Wt(i,"delete-row"),{disabled:i.rows.length<=1}),pl(),Rt("在左侧插入列",()=>Wt(i,"insert-col-left")),Rt("在右侧插入列",()=>Wt(i,"insert-col-right")),Rt("删除列",()=>Wt(i,"delete-col"),{disabled:i.colWidths.length<=1}),pl(),Rt("合并单元格",()=>Wt(i,"merge"),{disabled:!!a,title:a||""}),Rt("拆分单元格",()=>Wt(i,"split"),{disabled:!nx(i)}),Rt("按值合并",()=>rx(i),{disabled:!!Th(i),title:Th(i)||"",active:(()=>{const c=i.selection;if(!c)return!1;const s=ar(i.rows,c.r1,c.c1);return i.rows[s.r]?.cells[s.c]?.mergeSameValue===!0})()}),pl(),h("div",{class:"menu-group-title",text:"行类型"}),...Iw.map(c=>Rt(c.label,()=>Wt(i,"set-row-type",c.value),{disabled:!!Ch(i,c.value),title:Ch(i,c.value)||"",active:l===c.value}))])}let Tn=null;function kh(){Tn&&(document.removeEventListener("mousemove",fl),document.removeEventListener("mouseup",hl),Tn.handle.classList.remove("dragging"),Tn=null)}function ix(e,t){const n=e.closest(".hiprint-printPaper");return(n&&n.offsetWidth>0?n.getBoundingClientRect().width/n.offsetWidth:0)||(t.scale||100)/100}function ax(e,t,n){if(n.button!==0)return;const r=n.currentTarget,o=r.closest(".print-table");if(!o)return;kh();const i=e.real.options.tableColWidths??[];Tn={store:e.store,fire:e.fire,elId:e.real.id,boundary:t,startX:n.clientX,startWidth:i[t-1]??0,scale:ix(o,e.store),root:o,wrapper:r.closest(".print-element"),handle:r},r.classList.add("dragging"),e.store.recordHistory(),document.addEventListener("mousemove",fl),document.addEventListener("mouseup",hl)}function fl(e){const t=Tn;if(!t)return;const n=Kr(t.store,t.elId),r=n?.options.tableColWidths;if(!n||!r)return;const o=(e.clientX-t.startX)/(t.scale*Ni),i=t.boundary-1;r[i]=Ug(r,i,t.startWidth+o,vh(t.store)),sr(n.options),r.forEach((a,l)=>{const c=t.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${a}mm`)}),t.root.querySelectorAll(".col-resize-handle").forEach((a,l)=>{a.style.left=`${r.slice(0,l+1).reduce((c,s)=>c+s,0)}mm`}),t.wrapper&&(t.wrapper.style.width=`${n.options.width}mm`,t.wrapper.style.height=`${n.options.height}mm`)}function hl(){document.removeEventListener("mousemove",fl),document.removeEventListener("mouseup",hl);const e=Tn;if(!e)return;Tn=null,e.handle.classList.remove("dragging");const t=Kr(e.store,e.elId);t&&sr(t.options),e.store.emit(),e.fire("table-col-resize-end",{elementId:e.elId})}function sx(e,t,n){const r=n.querySelector("table");if(!r)return;const o=r.offsetHeight;if(o<=0)return;const i=Kr(e,t);if(!i)return;let a=!1;const l=o/Ni;Math.abs(l-(i.options.height??0))>Pw&&(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)/Ni,height:p.offsetHeight/Ni})),d=qt(e);lx(d.layouts.get(t),s)||(d.layouts.set(t,s),a=!0),a&&e.emit(!1)}function lx(e,t){return!e||e.length!==t.length?!1:t.every((n,r)=>{const o=e[r];return Math.round(n.top*10)===Math.round(o.top*10)&&Math.round(n.height*10)===Math.round(o.height*10)})}function cx(e,t){const n=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&sx(e,t,r)}),n}function dx(e){return e.isSelected&&!e.real.options.locked&&e.colWidths.length>=1}function ux(e){return Array.from({length:e.colWidths.length},(t,n)=>n+1)}function px(e,t){return e.colWidths.slice(0,t).reduce((n,r)=>n+r,0)}function fx(e,t,n,r){const o=yh(t,n,e,r);if(!o)return h("div",{class:"print-table"});const i=[h("table",{style:{fontSize:`${dl(o)}pt`,color:wh(o)}},[h("colgroup",{},o.colWidths.map(a=>h("col",{style:{width:a+"mm"}}))),h("tbody",{},o.rows.map((a,l)=>h("tr",{style:{height:a.height+"mm"}},a.cells.map((c,s)=>c.merged?"":h("td",{rowspan:c.rowspan||1,colspan:c.colspan||1,class:zw(o,l,s),style:Bw(o,c),onMousedown:d=>Jw(o,l,s,c.id,d),onMouseenter:()=>Qw(o,l,s),onContextmenu:d=>ex(o,l,s,d)},[Zw(o,a,l,s,c)])).filter(Boolean))))])];return dx(o)&&i.push(h("div",{class:"col-resize-layer"},ux(o).map(a=>h("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${a}`,style:{left:px(o,a)+"mm"},onMousedown:l=>{l.stopPropagation(),l.preventDefault(),ax(o,a,l)}})))),o.isSelected&&i.push(h("div",{class:"row-badges"},o.rows.map((a,l)=>h("span",{class:"row-badge",style:{top:$w(o,l)+"mm",height:Nw(o,l)+"mm"},text:Ow[a.type]})))),i.push(cx(t,e.id)),h("div",{class:"print-table design-mode",dataset:{tableId:e.id},onContextmenu:a=>a.preventDefault()},i)}const hx=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function gl(e){return Array.isArray(e)&&e.length>0?e:[]}function gx(e,t){const n=fo(e,t)??(t?Object.keys(t).find(o=>Array.isArray(t[o])):void 0);if(n)return gl(t?.[n]);const r=fo(e,gt);return r?gl(gt[r]):[]}function mx(e,t){const n=e.options,r=typeof n.formatter=="string"?n.formatter:"",o=gl(t)[0],i=gx(r,o);if(i.length===0)return[...hx];if(!r)return i.map(c=>String(c?.name??JSON.stringify(c)));const a=o??{},l=fo(r,a)??Object.keys(a).find(c=>Array.isArray(a[c]));return i.map(c=>{try{return Wn(r,{...a,...c,...l?{[l]:c}:{}})}catch{return r}})}const bx=3.7795275591,yx=.1;function vx(e,t){return e.templateData.elements.find(n=>n.id===t)??null}function wx(e){const t=e.parentElement;if(!t?.classList.contains("print-element"))return 0;const n=getComputedStyle(t);return(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0)}function xx(e,t,n){const r=n.offsetHeight+wx(n);if(r<=0)return;const o=vx(e,t);if(!o)return;const i=r/bx;Math.abs(i-(o.options.height??0))>yx&&(o.options.height=Math.round(i*100)/100,e.emit(!1))}function Ex(e,t){const n=document.createComment("pd-flowlist-measure");return requestAnimationFrame(()=>{if(!n.isConnected)return;const r=n.parentElement;r&&xx(e,t,r)}),n}function Sx(e,t,n){const r=e.options,o=pt(r.flowColumns),i=vt(r.flowGapX),a=Xt(r.flowRowHeight),l=pn(r.flowLayoutMode)==="dynamic",c=$n(r),s={display:"grid",gridTemplateColumns:`repeat(${o},minmax(0,1fr))`,columnGap:`${i}mm`,gridAutoRows:`minmax(${a}mm,auto)`,width:"100%",...l?{padding:`${c.top}mm ${c.right}mm ${c.bottom}mm ${c.left}mm`,height:"auto",overflow:"visible"}:{height:"100%",overflow:"hidden"},fontSize:`${r.fontSize||12}pt`,fontWeight:r.fontWeight||"normal",color:r.color||"#333",boxSizing:"border-box"};r.fontFamily&&(s.fontFamily=String(r.fontFamily)),r.backgroundColor&&(s.backgroundColor=String(r.backgroundColor));const d=mx(e,t).map(p=>h("div",{class:"print-flow-cell",text:p}));return l&&n&&d.push(Ex(n,e.id)),h("div",{class:"print-flowlist",style:s},d)}const Ah={top:"flex-start",middle:"center",bottom:"flex-end"},_x={left:"flex-start",center:"center",right:"flex-end"};function Mx(e,t){const n=e.options,r=ft(n),o=bo(e.printElementType.type,n),i={};if(o?.all&&(i.border=`${o.all.borderWidth} ${o.all.borderStyle} ${o.all.borderColor}`),o)for(const a of hr){const l=o.edges[a];l&&(i[`border${a.charAt(0).toUpperCase()}${a.slice(1)}`]=`${l.borderWidth} ${l.borderStyle} ${l.borderColor}`)}return{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`,...r.top!==0?{marginTop:`${r.top}mm`}:{},...r.right!==0?{marginRight:`${r.right}mm`}:{},...r.bottom!==0?{marginBottom:`${r.bottom}mm`}:{},...r.left!==0?{marginLeft:`${r.left}mm`}:{},zIndex:String(n.zIndex||"auto"),...i,...Tx(e,t)}}function Tx(e,t){if(t?.has(e.id))return{};const n=ba(e.printElementType.type,e.options);return n===void 0?{}:{rotate:`${n}deg`}}function Dh(e){const t=e.options,n=e.printElementType.type==="longText",r=po(e.printElementType.type,t),o=t.fontSize||12,i=r==="autoHeight",a={fontSize:`${o}pt`,fontWeight:t.fontWeight||"normal",fontFamily:Ka(t.fontFamily),color:t.color||"#333",backgroundColor:t.backgroundColor||"transparent",textAlign:t.textAlign||"left",...t.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:t.lineHeight?`${t.lineHeight}pt`:n?"1.5":"normal",letterSpacing:t.letterSpacing?`${t.letterSpacing}pt`:"normal",width:"100%",height:i?"auto":"100%",boxSizing:"border-box",overflow:i?"visible":"hidden",...n?{wordBreak:"break-all",textIndent:t.longTextIndent?`${t.longTextIndent}em`:"0"}:{textDecoration:t.textDecoration||"none",padding:`${t.contentPaddingTop||0}pt ${t.contentPaddingRight||0}pt ${t.contentPaddingBottom||0}pt ${t.contentPaddingLeft||0}pt`}};wc(t)&&(a.whiteSpace="nowrap",a.textOverflow="ellipsis");const l=vc(t);return l&&(a.whiteSpace=l),t.verticalAlign&&(a.display="flex",t.textAlign==="justify"?(a.flexDirection="column",a.justifyContent=Ah[t.verticalAlign]??"flex-start"):(a.alignItems=Ah[t.verticalAlign]??"flex-start",a.justifyContent=_x[t.textAlign||"left"]??"flex-start")),{style:a,fit:r}}function Oh(e){const t=e.options,n=`${t.borderWidth||.75}pt`,r=t.borderStyle||"solid",o=t.borderColor||"#333";return e.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 Ih(e){const t=e.options;return{width:"100%",height:"100%",borderWidth:`${t.borderWidth||1}pt`,borderStyle:t.borderStyle||"solid",borderColor:t.borderColor||"#333",backgroundColor:t.backgroundColor||"transparent",borderRadius:e.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Cx(e){const t=e.options;return{objectFit:t.fit||"contain",...ma(t.fit,t.fitScale,t.objectPosition),maxWidth:t.maxWidth?`${t.maxWidth}mm`:"100%",maxHeight:t.maxHeight?`${t.maxHeight}mm`:"100%"}}function Ph(e){const t=e.options,n={fitBase:String(t.fontSize||12),fitMin:String(dr(t.shrinkMinFontSize))};return po(e.printElementType.type,t)==="shrink"&&(n.fit="shrink"),n}Nf({text:e=>{const{style:t}=Dh(e),n=e.options;return h("div",{class:"print-text",style:t,dataset:Ph(e),text:String(n.testData||n.formatter||"")||"文本"})},longText:e=>{const{style:t}=Dh(e),n=e.options;return h("div",{class:"print-longtext",style:t,dataset:Ph(e),text:String(n.formatter||"")||"长文本内容"})},hline:e=>h("div",{class:"print-line",style:Oh(e)}),vline:e=>h("div",{class:"print-line",style:Oh(e)}),rect:e=>h("div",{class:"print-shape",style:Ih(e)}),oval:e=>h("div",{class:"print-shape",style:Ih(e)}),image:(e,t,n)=>{const r=e.options,o=String(r.src??""),i=n?.designData?.length?n.designData[0]:gt,a=o.includes("{")?Wn(o,i):o;return h("div",{class:"print-image"},[a?h("img",{src:a,style:Cx(e)}):h("div",{class:"image-placeholder",text:"图片"})])},qrcode:e=>_w(e),barcode:e=>Mw(e),html:e=>{const t=e.options,n=String(t.formatter??""),r=n?xw.sanitize(Wn(n,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return h("div",{class:"print-html",html:r})},pageNumber:(e,t)=>{const n=e.options;return h("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:Ka(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:t?n.title||"{pageIndex}/{totalPages}":String(n.title||"")})},table:(e,t,n)=>n?fx(e,n.store,n.fire,n.designData):h("div",{class:"print-table"}),flowList:(e,t,n)=>Sx(e,void 0,n?.store)});function kx(e,t,n){const r=e.printElementType.type,o=tn(r)?.renderContent;if(o)return o(e,t,n);const i=Gs(r);if(!i)return h("div",{text:r});const a=document.createElement("div");a.className="plugin-kit-canvas",a.style.width="100%",a.style.height="100%";try{hh(`canvas:${e.id}`,i.ui.renderCanvas({element:e,data:n?.designData?.length?n.designData:[gt],designMode:!0}),a)}catch{a.textContent=String(r)}return a}function Rh(e){return`x:${Math.round(e.left)} y:${Math.round(e.top)} ${Math.round(e.width)}×${Math.round(e.height)}mm`}function Ax(e,t,n){const r=e.store,o=r.selectedIds.has(t.id),i=r.previewIds.has(t.id),a=t.options,l=t.zone||"content",c=[kx(t,!0,{store:r,fire:e.fire,designData:e.host.designData})];return r.draggingIds.has(t.id)&&c.push(h("div",{class:"drag-preview"})),o&&(c.push(h("div",{class:"resize-handles"},q1.map(s=>h("div",{class:`resize-handle handle-${s}`,dataset:{point:s,elId:t.id},onMousedown:d=>e.fire("resize-start",{event:d,id:t.id,point:s})})))),c.push(h("div",{class:"selected-indicator"},[h("div",{class:"position-label",text:Rh(a)})]))),h("div",{class:["print-element",`type-${t.printElementType.type}`,`zone-${l}`,o?"selected":"",i?"previewed":"",r.draggingIds.has(t.id)?"drag-ghost":"","design-mode",a.locked?"locked":"",a.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Mx(t,n),dataset:{elId:t.id},onMousedown:s=>e.fire("element-mousedown",{event:s,id:t.id}),onContextmenu:s=>{s.preventDefault(),s.stopPropagation(),e.fire("contextmenu",{event:s,id:t.id})}},c)}function ml(e,t){const n=e.margins,r=e.header?.height??10,o=e.footer?.height??10,i=t.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:t.height-n.top-n.bottom-r-o},footer:{left:n.left,top:t.height-n.bottom-o,width:i,height:o}}}const Dx='<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 Fh(e,t){return e.type==="vertical"?{left:`${e.position}mm`,top:"0",height:`${t.height}mm`,borderLeftColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${e.position}mm`,left:"0",width:`${t.width}mm`,borderTopColor:e.color||"var(--pd-accent-secondary, #f56c6c)"}}function Ox(e,t){const n=jd(e.watermark,[],t);return n?h("div",{class:"watermark-layer",style:{opacity:String(n.opacity)}},n.tiles.map(r=>h("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`}},[h("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 bl(e,t,n,r,o,i){const a=e.store,l=[];n!=="content"&&l.push(h("span",{class:"zone-label",text:n==="header"?"页眉":"页脚"}));const c=n==="content"?Hc(o):void 0;if(l.push(...o.map(s=>Ax(e,s,c))),n!=="content"){const s=n==="header"?"bottom":"top";l.push(h("div",{class:`zone-resize-handle handle-${s}`,dataset:{zone:n},onMousedown:d=>e.fire("zone-resize",{event:d,zone:n})},[t.zoneResizing===n?h("div",{class:"zone-height-tip",text:`${(n==="header"?a.templateData.header.height:a.templateData.footer.height).toFixed(1)}mm`}):""]))}return h("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 Ix(e){const t=e.currentTarget,n=e.dataTransfer?.types??[],r=n.includes("fieldkey"),o=n.includes("elementtype");if(!r&&!o){t.querySelector(".drop-hint")?.remove();return}r&&(e.ctrlKey||e.metaKey)&&(t.dataset.dropLabelIntent="1");const i=o?"+ 元素":t.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let a=t.querySelector(".drop-hint");a||(a=document.createElement("div"),a.className="drop-hint",t.appendChild(a)),a.textContent=i,a.style.left=`${e.clientX+14}px`,a.style.top=`${e.clientY+18}px`}function $h(e){e&&(e.querySelector(".drop-hint")?.remove(),delete e.dataset.dropLabelIntent)}function Px(e,t){const n=e.store,r=n.templateData,o=ht(r),i=(n.scale||100)/100,a=ml(r,o),l=p=>n.elements.filter(u=>(u.zone||"content")===p),c=h("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?h("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(Dx)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...r.watermark&&Object.keys(r.watermark).length?[Ox(r,o)]:[],bl(e,t,"header",a.header,l("header"),o),bl(e,t,"content",a.content,l("content"),o),bl(e,t,"footer",a.footer,l("footer"),o),...n.adsorbGuides.map(p=>h("div",{class:`adsorb-guide guide-${p.type}`,style:Fh(p,o)})),...(r.guides??[]).map(p=>h("div",{class:`manual-guide guide-${p.type}`,style:{...Fh(p,o),"--guide-hit":`${8/i}px`},dataset:{guideId:String(p.id??"")},onMousedown:u=>e.fire("guide-mousedown",{event:u,id:p.id}),onDblclick:u=>{u.preventDefault(),e.fire("guide-remove",p.id)}}))].filter(Boolean)),s=h("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?[h("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)`:""}},[h("img",{src:r.designBackground.src,draggable:!1,alt:""})])]:[],c]),d=[h("div",{class:"canvas-scroll"},[h("div",{class:"paper-wrapper",style:{width:`${Lo(o.width)*i}px`,height:`${Lo(o.height)*i}px`,position:"relative"}},[s])])];if(n.showRuler&&d.push(h("div",{class:"ruler-overlay",style:{transform:`translate(${t.scrollX}px, ${t.scrollY}px)`}},[h("div",{class:"ruler-corner"}),h("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${t.geom.viewW}px`,height:"20px"},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"horizontal"})}),h("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${t.geom.viewH}px`},onMousedown:p=>e.fire("ruler-mousedown",{event:p,orientation:"vertical"})})])),t.guidePreview&&d.push(h("div",{class:`ruler-guide-preview guide-${t.guidePreview.type}`,style:t.guidePreview.type==="vertical"?{left:`${t.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${t.guidePreview.position}px`,left:"0",width:"100%"}})),t.marquee.visible&&d.push(h("div",{class:"marquee-selection",style:{left:`${t.marquee.x}px`,top:`${t.marquee.y}px`,width:`${t.marquee.w}px`,height:`${t.marquee.h}px`}})),t.contextMenu.visible){const p=t.contextMenu;d.push(h("div",{class:"context-menu",style:{left:`${t.contextMenu.x+t.contextMenu.flipX}px`,top:`${t.contextMenu.y+t.contextMenu.flipY}px`}},t.contextMenu.targetId?[_t(e,p,"复制","copy"),_t(e,p,"剪切","cut"),_t(e,p,"粘贴","paste",!n.hasClipboard),_t(e,p,"删除","delete"),h("div",{class:"context-menu-sep"}),_t(e,p,"置顶","move-layer",!1,"top"),_t(e,p,"上移","move-layer",!1,"up"),_t(e,p,"下移","move-layer",!1,"down"),_t(e,p,"置底","move-layer",!1,"bottom")]:[_t(e,p,"粘贴","paste-at",!n.hasClipboard),_t(e,p,"全选","select-all"),_t(e,p,"取消选择","clear-selection")]))}return h("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:p=>{const u=p;u.preventDefault(),u.dataTransfer&&(u.dataTransfer.dropEffect="copy"),Ix(u)},onDragleave:p=>{const u=p.currentTarget,f=p.relatedTarget;(!f||!u.contains(f))&&u.querySelector(".drop-hint")?.remove()},onDrop:p=>{const u=p,f=p.currentTarget,g=f.dataset.dropLabelIntent==="1";$h(f),g&&(u.labelIntent=!0),e.fire("drop",u)},onMousedown:p=>e.fire("canvas-mousedown",p),onMousemove:p=>e.fire("canvas-mousemove",p),onMouseleave:()=>e.fire("canvas-mouseleave"),onWheel:p=>e.fire("wheel",p),onScroll:p=>e.fire("scroll",p),onContextmenu:p=>{p.preventDefault(),e.fire("canvas-contextmenu",p)}},d.filter(Boolean))}function _t(e,t,n,r,o=!1,i){return h("div",{class:`context-menu-item${o?" disabled":""}`,text:n,onClick:()=>{t.visible=!1,o||e.fire(r,i),e.repaint()}})}const Rx={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" />',Barcode:'<path d="M3 5v14" /><path d="M8 5v14" /><path d="M12 5v14" /><path d="M17 5v14" /><path d="M21 5v14" />',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" />',ChartArea:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z" />',ChartBar:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 16h8" /><path d="M7 11h12" /><path d="M7 6h3" />',ChartColumn:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M18 17V9" /><path d="M13 17V5" /><path d="M8 17v-3" />',ChartLine:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="m19 9-5 5-4-4-3 3" />',ChartPie:'<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z" /><path d="M21.21 15.89A10 10 0 1 1 8 2.83" />',ChartScatter:'<circle cx="7.5" cy="7.5" r=".5" fill="currentColor" /><circle cx="18.5" cy="5.5" r=".5" fill="currentColor" /><circle cx="11.5" cy="11.5" r=".5" fill="currentColor" /><circle cx="7.5" cy="16.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="14.5" r=".5" fill="currentColor" /><path d="M3 3v16a2 2 0 0 0 2 2h16" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsLeft:'<path d="m11 17-5-5 5-5" /><path d="m18 17-5-5 5-5" />',ChevronsRight:'<path d="m6 17 5-5-5-5" /><path d="m13 17 5-5-5-5" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',Circle:'<circle cx="12" cy="12" r="10" />',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" />',Code:'<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />',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" />',Donut:'<path d="M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3" /><circle cx="12" cy="12" r="3" />',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" />',FileText:'<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 9H8" /><path d="M16 13H8" /><path d="M16 17H8" />',Funnel:'<path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" />',Gauge:'<path d="m12 14 4-4" /><path d="M3.34 19a10 10 0 1 1 17.32 0" />',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" />',Image:'<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />',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" />',List:'<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />',ListTree:'<path d="M8 5h13" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="M3 10a2 2 0 0 0 2 2h3" /><path d="M3 5v12a2 2 0 0 0 2 2h3" />',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" />',Minus:'<path d="M5 12h14" />',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" />',QrCode:'<rect width="5" height="5" x="3" y="3" rx="1" /><rect width="5" height="5" x="16" y="3" rx="1" /><rect width="5" height="5" x="3" y="16" rx="1" /><path d="M21 16h-3a2 2 0 0 0-2 2v3" /><path d="M21 21v.01" /><path d="M12 7v3a2 2 0 0 1-2 2H7" /><path d="M3 12h.01" /><path d="M12 3h.01" /><path d="M12 16v.01" /><path d="M16 12h1" /><path d="M21 12v.01" /><path d="M12 21v-1" />',Radar:'<path d="M19.07 4.93A10 10 0 0 0 6.99 3.34" /><path d="M4 6h.01" /><path d="M2.29 9.62A10 10 0 1 0 21.31 8.35" /><path d="M16.24 7.76A6 6 0 1 0 8.23 16.67" /><path d="M12 18h.01" /><path d="M17.99 11.66A6 6 0 0 1 15.77 16.67" /><circle cx="12" cy="12" r="2" /><path d="m13.41 10.59 5.66-5.66" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',SeparatorVertical:'<path d="M12 3v18" /><path d="m16 16 4-4-4-4" /><path d="m8 8-4 4 4 4" />',Shapes:'<path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z" /><rect x="3" y="14" width="7" height="7" rx="1" /><circle cx="17.5" cy="17.5" r="3.5" />',Square:'<rect width="18" height="18" x="3" y="3" rx="2" />',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" />',Table:'<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />',Table2:'<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18" />',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" />',Type:'<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />',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 ze(e,t=15,n){const r=Rx[e];return r?`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}"${n?` class="${n}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${r}</svg>`:""}var Cn=null;function yl(e){const t=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;const n=t[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 vl(e){const t=yl(e);return t?Nh(t):"#000000"}function Nh({r:e,g:t,b:n}){return`#${[e,t,n].map(r=>Math.round(Xr(r/255)*255).toString(16).padStart(2,"0")).join("")}`}function Fx(e,t,n){const r=e/255,o=t/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 $x(e,t,n){const r=n*t,o=(e%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 Nx(e){return((Number.isFinite(e)?e:0)%360+360)%360}function Xr(e){return Math.min(1,Math.max(0,Number.isFinite(e)?e:0))}function Lx(e){const t=e.title??"颜色选择";return h("button",{type:"button",class:`preset-color-trigger${e.triggerClass?` ${e.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:t,onClick:n=>{const r=n.currentTarget??n.target,o=r.getRootNode();if(!!Cn&&Cn.root===o&&Cn.title===t&&Cn.trigger===r){Zr();return}Zr(),Bx(r,e)}},[h("span",{class:"preset-color-swatch",style:e.value?{background:e.value}:{background:"transparent"}})])}function Zr(){const e=Cn;e&&(Cn=null,e.teardowns.forEach(t=>t()),e.trigger.setAttribute("aria-expanded","false"),e.panel.remove())}function Bx(e,t){const n=e.getRootNode(),r=n instanceof ShadowRoot?n:document.body,o={root:n,title:t.title??"颜色选择",trigger:e,panel:null,clearable:t.clearable!==!1,onChange:t.onChange,model:t.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:[]};t.value&&xl(o,t.value)?o.hexText=vl(t.value).toUpperCase():o.hexText=t.value?String(t.value):"",o.panel=Ze(qx(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:cd[a]})),zi(o),zx(o),Hx(o),Cn=o,e.setAttribute("aria-expanded","true")}function zx(e){const t=e.trigger.getBoundingClientRect(),n=190,r=e.panel.offsetHeight||216,o=8,i=Math.max(o,Math.min(t.left,window.innerWidth-n-o)),a=t.bottom+6,l=a+r>window.innerHeight-o?Math.max(o,t.top-r-6):a;e.panel.style.left=`${i}px`,e.panel.style.top=`${l}px`}function Hx(e){const t=o=>{const i=Ux(o);i.includes(e.trigger)||i.includes(e.panel)||Zr()},n=o=>{o.key==="Escape"&&Zr()},r=()=>Zr();document.addEventListener("pointerdown",t,!0),document.addEventListener("keydown",n),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),e.root.addEventListener("scroll",r,!0),e.teardowns.push(()=>document.removeEventListener("pointerdown",t,!0),()=>document.removeEventListener("keydown",n),()=>window.removeEventListener("scroll",r,!0),()=>window.removeEventListener("resize",r),()=>e.root.removeEventListener("scroll",r,!0))}function Ux(e){const t=typeof e.composedPath=="function"?e.composedPath():[];return t.length?t:[e.target]}function qx(e){return h("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:t=>t.stopPropagation()},[h("div",{class:"picker-preview"},[h("span",{class:"picker-current"}),h("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:t=>jx(e,t.target.value)})]),h("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:t=>Gx(e,t),onKeydown:t=>Vx(e,t)},[h("span",{class:"picker-handle"})]),h("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:t=>Yx(e,Number(t.target.value)),onChange:()=>El(e)}),h("div",{class:"picker-heading"},[h("span",{text:"常用颜色"}),e.clearable?h("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Hi(e,void 0)},[h("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[h("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),h("div",{class:"preset-color-grid"},cd.map(t=>h("button",{type:"button",class:"preset-color-item",style:{background:t},title:t,"aria-label":t,onClick:()=>Wx(e,t)})))])}function wl(e){return Nh($x(e.hue,e.saturation,e.value_))}function zi(e){const t=wl(e);e.hex.value!==e.hexText&&(e.hex.value=e.hexText),e.current.className=e.model?"picker-current":"picker-current is-empty",e.model?e.current.style.background=t:e.current.style.removeProperty("background"),e.area.style.setProperty("--picker-hue",`${Math.round(e.hue)}deg`),e.handle.style.left=`${e.saturation*100}%`,e.handle.style.top=`${(1-e.value_)*100}%`,e.handle.style.background=t;const n=String(Math.round(e.hue));e.hueRange.value!==n&&(e.hueRange.value=n),e.clearBtn&&(e.clearBtn.disabled=!e.model);for(const r of e.items)r.el.className=e.model&&r.color.toLowerCase()===e.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function xl(e,t){const n=yl(t);if(!n)return!1;const r=Fx(n.r,n.g,n.b);return e.hue=r.h,e.saturation=r.s,e.value_=r.v,e.hexText=vl(t).toUpperCase(),!0}function Jn(e,t,n,r){e.hue=Nx(t),e.saturation=Xr(n),e.value_=Xr(r),e.hexText=wl(e).toUpperCase(),zi(e)}function El(e){const t=wl(e);e.model=t,zi(e),e.onChange(t)}function Hi(e,t){e.model=t,t||(e.hexText=""),zi(e),e.onChange(t)}function Wx(e,t){xl(e,t),Hi(e,t)}function jx(e,t){const n=t.trim();if(!n){e.clearable&&Hi(e,void 0);return}yl(n)&&(xl(e,n),Hi(e,vl(n)))}function Gx(e,t){e.dragging=!0,Lh(e,t);const n=o=>{e.dragging&&Lh(e,o)},r=()=>{e.dragging&&(e.dragging=!1,document.removeEventListener("pointermove",n),document.removeEventListener("pointerup",r),document.removeEventListener("pointercancel",r),El(e))};document.addEventListener("pointermove",n),document.addEventListener("pointerup",r),document.addEventListener("pointercancel",r)}function Lh(e,t){const n=e.area.getBoundingClientRect();if(!n.width||!n.height)return;const r=Xr((t.clientX-n.left)/n.width),o=Xr(1-(t.clientY-n.top)/n.height);Jn(e,e.hue,r,o)}function Vx(e,t){const n=t.shiftKey?.1:.02;let r=!0;t.key==="ArrowLeft"?Jn(e,e.hue,e.saturation-n,e.value_):t.key==="ArrowRight"?Jn(e,e.hue,e.saturation+n,e.value_):t.key==="ArrowUp"?Jn(e,e.hue,e.saturation,e.value_+n):t.key==="ArrowDown"?Jn(e,e.hue,e.saturation,e.value_-n):r=!1,r&&(t.preventDefault(),El(e))}function Yx(e,t){Jn(e,t,e.saturation,e.value_)}function _e(e,t,n,r){return h("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:()=>e.fire(n,r.arg),html:ze(t)})}function Ui(e,t,n,r){const o=e.state.openDd===t,i=()=>{e.state.openDd=o?null:t,e.repaint()};return h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${o?" on":""}`,disabled:!!n.disabled,dataset:{test:n.testId??t,tip:n.tip},onClick:i,html:`${n.icon?ze(n.icon):""}${n.text?`<span class="${n.textClass??"tb-btn-text"}">${n.text}</span>`:""}${ze("ChevronDown",12,`tb-dd-arrow${o?" up":""}`)}`}),o?h("div",{class:`tb-dd-panel${n.panelClass?` ${n.panelClass}`:""}`},r):""].filter(Boolean))}function J(e){const t=e.step??1,n=String(t),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 e.min!==void 0&&u<e.min&&(u=e.min),e.max!==void 0&&u>e.max&&(u=e.max),u},l=e.value===void 0||e.value===null||!Number.isFinite(e.value)?void 0:i(e.value),c=l??e.min??0,s=p=>{p!==l&&e.onCommit(p)},d=h("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:e.min,max:e.max,step:t,placeholder:e.placeholder,disabled:!!e.disabled,onChange:p=>{const u=p.target,f=(u.value??"").trim();if(f===""){l!==void 0&&(u.value=String(l));return}const g=Number(f);if(!Number.isFinite(g)){u.value=l===void 0?"":String(l);return}const m=a(g);u.value=String(m),s(m)}});return h("div",{class:"pd-stepper"},[h("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!e.disabled||c<=(e.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>s(a(c-t))}),d,h("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!e.disabled||c>=(e.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>s(a(c+t))})])}function se(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),r??""]),t,n?h("p",{class:"pd-hint",text:n}):""].filter(Boolean))}const Sl=e=>h("button",{class:"pd-help",type:"button","data-tip":e,"aria-label":"字段说明"});function He(e,t,n,r){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[e,Sl(n)]),r??""]),t])}function kn(e){const t=e.base?.[e.propKey],n=e.target?.[e.propKey]!==t,r=e.force===!0||n,o=e.tipOverride??(e.tipValue===void 0?"恢复默认值":`恢复默认值(${e.tipValue}${e.tipUnit?" "+e.tipUnit:""})`),i=e.force?`${o}(应用到全部选中格)`:o;return h("button",{type:"button",class:`pd-reset-btn${n&&!e.force?" is-dirty":""}`,"data-tip":i,"aria-label":i,html:ze("RotateCcw",13),onClick:()=>{r&&(e.write?e.write(t):e.target[e.propKey]=t,e.onReset?.())}})}const Ft=e=>h("h3",{class:"pd-divider",text:e});function ot(e,t,n="颜色选择",r){return Lx({value:e,title:n,triggerClass:r,onChange:o=>t(o)})}function on(e,t,n,r,o=!1){return h("div",{class:`pd-radio-group${o?" pd-radio-group--2col":""}`,role:"radiogroup"},t.map(i=>h("label",{class:"pd-radio"},[h("input",{type:"radio",name:e,value:i.value,checked:n===i.value,onChange:()=>r(i.value)}),h("span",{text:i.label})])))}function Bh(e,t,n,r={}){const o=document.createElement("select");o.className=r.className??"pd-select",r.width&&(o.style.width=r.width);for(const i of t){const a=document.createElement("option");a.value=i.value,a.textContent=i.label,i.disabled&&(a.disabled=!0),o.appendChild(a)}return o.value=e,t.some(i=>i.value===e)||(o.selectedIndex=-1),o.addEventListener("change",()=>n(o.value)),o}function Kx(e){const t=window.innerHeight;for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){const r=getComputedStyle(n).overflowY;if(r==="auto"||r==="scroll"||r==="hidden"||r==="clip"){const o=n.getBoundingClientRect();return{top:Math.max(0,o.top),bottom:Math.min(t,o.bottom)}}}return{top:0,bottom:t}}function qi(e){const t=tb(e.fonts),n=e.placeholder??"默认",r=`font-select-list-${e.id}`,o=A=>{const k=A?.trim();return k?Id(t,k)?.label??k:""},i=A=>{const k=Tr(A);return t.find(S=>S.label&&Tr(S.label)===k)?.family??A},a=()=>{const A=e.value?.trim();return A?Id(t,A)?"":A:""},l=A=>{const k=(e.value??"").trim(),R=(N,B,C,ie)=>({kind:N,key:B,label:C,value:ie,selected:(ie??"")===k}),S=A.trim();if(!S){const N=[R("clear","__clear__",n)],B=a();B&&N.push(R("unknown","__unknown__",`${B}(未知)`,B));for(const C of t)N.push(R("font",C.family,Pd(C),C.family));return N}const $=rb(t,S).map(N=>R("font",N.family,Pd(N),N.family));if(!$.length){const N=i(S);$.push(R("free","__free__",`使用「${N}」`,N))}return $},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=!!e.disabled,s.value=o(e.value);const d=document.createElement("ul");d.id=r,d.className="font-select-list",d.setAttribute("role","listbox");const p=e.state.fontOpen?.id===e.id?e.state.fontOpen:null,u={open:!!p&&!e.disabled,query:p?.query??"",highlighted:p?.highlighted??-1};u.open&&(s.value=u.query);const f=()=>{e.state.fontOpen=u.open?{id:e.id,query:u.query,highlighted:u.highlighted}:null};f();const g=()=>{const A=(e.value??"").trim();return l(u.query).findIndex(k=>(k.value??"")===A)},m=()=>{const A=s.getBoundingClientRect(),k=Kx(s);d.classList.toggle("is-up",Nm({triggerTop:A.top,triggerBottom:A.bottom,overlayHeight:d.getBoundingClientRect().height,boundaryTop:k.top,boundaryBottom:k.bottom})==="up")},y=()=>{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,R)=>{const S=document.createElement("li");return S.id=`${r}-${R}`,S.className="font-select-option"+(R===u.highlighted?" is-active":"")+(k.kind==="unknown"||k.kind==="free"?" is-muted":""),S.setAttribute("role","option"),S.setAttribute("aria-selected",String(k.selected)),S.textContent=k.label,S.addEventListener("mousedown",$=>{$.preventDefault(),O(k)}),S})),s.setAttribute("aria-expanded","true"),s.setAttribute("aria-activedescendant",u.highlighted>=0?`${r}-${u.highlighted}`:""),m()},v=()=>{u.open||e.disabled||(u.open=!0,u.query="",u.highlighted=g(),f(),y())},w=()=>{u.open||v()},E=()=>{u.open=!0,u.query=s.value,u.highlighted=l(u.query).length?0:-1,f(),y()},T=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(),y(),d.children[u.highlighted]?.scrollIntoView?.({block:"nearest"})},P=()=>{if(!u.open)return;const A=l(u.query)[u.highlighted];if(A){O(A);return}const k=u.query.trim();if(k){const R=i(k);O({value:R})}},O=A=>{u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(A.value),y(),e.onChange(A.value)},I=()=>{u.open&&(u.open=!1,u.query="",u.highlighted=-1,f(),s.value=o(e.value),y())};return s.addEventListener("focus",v),s.addEventListener("click",w),s.addEventListener("input",E),s.addEventListener("blur",I),s.addEventListener("keydown",A=>{const k=A;k.key==="ArrowDown"?(k.preventDefault(),T(1)):k.key==="ArrowUp"?(k.preventDefault(),T(-1)):k.key==="Enter"?(k.preventDefault(),P()):k.key==="Escape"&&(k.preventDefault(),I())}),c.append(s),y(),u.open&&(s.focus(),s.setSelectionRange(u.query.length,u.query.length)),c}const Xx=[{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"}],Zx={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function an(e,t,n,r,o={}){return h("button",{type:"button",class:`ft-cell-btn${o.on?" on":""}`,dataset:{test:e,tip:t},disabled:!!o.disabled,onClick:r,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${n}</svg>`})}const Qn='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',zh='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Jx(e){const t=e.format;t.syncBorderDraft();const n=t.values,r=!t.fontEditable,o=r||t.context==="cells",i=t.context==="none",a=t.context==="cells",l=!t.painterActive&&(t.context==="none"||t.context==="cells"||!t.painterCapturable),c=t.painterActive?"退出格式刷(Esc)":t.context==="cells"?"格式刷(表格单元格暂不支持)":t.context==="none"?"格式刷(需选中元素)":t.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",s=u=>r?`${u}(需选中文本元素)`:u,d=[h("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[h("div",{class:"ft-border-grid"},[an("preset-none","无边框",`${Qn}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>t.applyBorderPreset("none")),an("preset-all","所有边框",`${zh}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("all")),an("preset-outer","外侧边框",zh,()=>t.applyBorderPreset("outer")),an("preset-inner",a?"内部边框":"内部边框(仅表格单元格可用)",`${Qn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>t.applyBorderPreset("inner"),{disabled:!a}),an("edge-top","上边框",`${Qn}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>t.applyEdge("top"),{on:t.edgeOn("top")}),an("edge-bottom","下边框",`${Qn}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>t.applyEdge("bottom"),{on:t.edgeOn("bottom")}),an("edge-left","左边框",`${Qn}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>t.applyEdge("left"),{on:t.edgeOn("left")}),an("edge-right","右边框",`${Qn}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>t.applyEdge("right"),{on:t.edgeOn("right")})]),h("div",{class:"ft-style-row"},Xx.map(u=>h("button",{type:"button",class:`ft-style-btn${t.borderStyle===u.key?" on":""}`,dataset:{test:`style-${u.key}`,tip:t.borderStyle===u.key?`${u.label}(再点一次取消,线型=无)`:u.label},onClick:()=>{t.toggleBorderStyle(u.key),e.repaint()}},[h("span",{class:"ft-style-line",style:{borderTop:u.preview}})]))),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"粗细"}),h("div",{class:"ft-line-width"},[J({value:t.borderWidth,min:.25,max:5,step:.25,placeholder:t.borderMixed.width?"混合":void 0,onCommit:u=>{t.setBorderWidth(u),e.repaint()}})])]),h("div",{class:"ft-border-style-row"},[h("span",{class:"ft-edge-label",text:"颜色"}),ot(t.borderColor,u=>{t.setBorderColor(u),e.repaint()},"边框颜色")]),t.borderMixedAny?h("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],p=[h("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[h("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([u,f,g])=>h("button",{type:"button",class:`ft-cell-btn${n.textAlign===u?" on":""}`,dataset:{test:`align-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({textAlign:u}),html:ze(g)}))),h("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([u,f,g])=>h("button",{type:"button",class:`ft-cell-btn${n.verticalAlign===u?" on":""}`,dataset:{test:`valign-${u}`,tip:f},disabled:r,onClick:()=>t.applyStyle({verticalAlign:u}),html:ze(g)})))])];return h("div",{class:"format-toolbar"},[h("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[h("button",{type:"button",class:`ft-btn${t.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{t.painterActive?t.cancelPainter():t.pickPainterSource(!1),e.repaint()},onDblclick:()=>{t.pickPainterSource(!0),e.repaint()},html:ze("Paintbrush")})]),h("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[h("div",{class:"ft-font"},[qi({id:"ft-font",state:e.state,fonts:e.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:n.fontFamily===_n?"混合":"默认",disabled:r,onChange:u=>t.applyStyle({fontFamily:u})})]),h("div",{class:"ft-size",dataset:{test:"font-size"}},[J({value:typeof n.fontSize=="number"?n.fontSize:void 0,min:5,max:72,disabled:r,placeholder:n.fontSize===_n?"混合":"默认",onCommit:u=>t.applyStyle({fontSize:u})})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>t.toggleBold()],["underline","Underline","下划线",()=>t.toggleUnderline()],["strike","Strikethrough","删除线",()=>t.toggleStrike()]].map(([u,f,g,m])=>h("button",{type:"button",class:`ft-btn${n[u]===!0?" on":""}`,dataset:{test:u,tip:s(g)},disabled:u==="bold"?r:o,onClick:m,html:ze(f)}))]),h("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[h("span",{class:`ft-color-btn${r?" dim":""}`,title:`字体颜色${r?"(需选中或混选文本元素)":""}`},[ot(typeof n.color=="string"?n.color:void 0,u=>t.applyStyle({color:u})),h("span",{class:"ft-glyph",text:"A"})]),h("span",{class:`ft-color-btn${i?" dim":""}`,title:"背景色"},[ot(typeof n.backgroundColor=="string"?n.backgroundColor:void 0,u=>t.applyStyle({backgroundColor:u})),h("span",{class:"ft-glyph",html:ze("PaintBucket",14)})])]),h("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[Ui(e,"align",{icon:Zx[String(n.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:r?"对齐(需选中文本元素或单元格)":"对齐",disabled:r,testId:"align-dd"},p)]),h("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[Ui(e,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:i?"边框(需选中元素)":"边框",disabled:i,testId:"border"},d)])])}const Qx="1.6.0";Oi.filter(e=>e.material).map(e=>({type:e.type,label:e.label,icon:e.icon}));function Wi(e,t){return ze(e??"Shapes",t)||ze("Shapes",t)}function e2(e){const t=e.state;if(t.leftCollapsed)return h("div",{class:"left-panel collapsed"},[h("div",{class:"left-collapsed"},[Hh("ChevronsRight","展开素材台",()=>{t.leftCollapsed=!1,e.repaint()}),...[["elements","元素","Table2"],["fields","字段","ListTree"],["layers","图层","Layers"]].map(([r,o,i])=>h("button",{type:"button",class:`lc-btn${t.leftTab===r?" on":""}`,title:o,html:Wi(i,14),onClick:()=>{t.leftTab=r,t.leftCollapsed=!1,e.repaint()}}))])]);const n=(r,o,i="")=>h("div",{class:`pd-tab-pane${i?` ${i}`:""}`,role:"tabpanel",dataset:{pane:`left:${r}`},style:t.leftTab===r?"":{display:"none"}},o);return h("div",{class:"left-panel"},[h("div",{class:"left-head"},[h("span",{class:"left-title",text:"素材台"}),Hh("ChevronsLeft","收起素材台",()=>{t.leftCollapsed=!0,e.repaint()})]),h("div",{class:"pd-tabs left-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([r,o])=>h("button",{type:"button",class:`pd-tab${t.leftTab===r?" active":""}`,text:o,onClick:()=>{t.leftTab=r,e.repaint()}}))]),n("elements",n2(),"material-grid"),n("fields",[r2(e)]),n("layers",[o2(e)])])])}function Hh(e,t,n){return h("button",{type:"button",class:"collapse-btn",title:t,html:Wi(e,14),onClick:n})}function t2(e,t,n){return h("div",{class:`material-card${x0(t)?" material-card--wide":""}`,draggable:!0,dataset:{test:`material-${e}`},onDragstart:r=>{const o=r.dataTransfer;o?.setData("elementType",e),o&&(o.effectAllowed="all")}},[h("span",{class:"material-icon","data-icon":n,html:Wi(n,14)}),h("span",{class:"material-label",text:t})])}function n2(){const e=[];let t;for(const n of Bf()){const r=n.group;r&&r!==t&&e.push(h("div",{class:"material-group-title",text:r})),r&&(t=r),e.push(t2(n.type,n.label,n.icon))}return[h("div",{class:"panel-title",text:"拖拽元素到画布"}),...e]}function r2(e){const t=e.state,n=t.fieldDisplay??"both",r=Cu(e.store.fields),o=(t.fieldSearch??"").trim().toLowerCase(),i=o?r.map(a=>({...a,fields:a.fields.filter(l=>`${l.fieldLabel}${l.fieldKey}`.toLowerCase().includes(o))})).filter(a=>a.fields.length):r;return h("div",{class:"field-tree-panel"},[h("div",{class:"panel-title",text:"业务字段"}),h("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:t.fieldSearch??"",onInput:a=>{t.fieldSearch=a.target.value},onChange:()=>e.repaint()}),h("div",{class:"tree-container"},i.flatMap(a=>{const l=t.collapsedGroups.has(a.key)&&!o,c=a.key?h("div",{class:`field-group-header${a.isList?" is-list":""}`,onClick:()=>{l?t.collapsedGroups.delete(a.key):t.collapsedGroups.add(a.key),e.repaint()}},[h("span",{class:"expand-icon",text:l?"▶":"▼"}),h("span",{class:"node-icon",text:a.isList?"📋":"📁"}),h("span",{class:"group-label",text:a.label,"data-tip":a.label})]):"",s=l?[]:a.fields.map(d=>h("div",{class:"field-row",draggable:!0,"data-tip":`${d.fieldLabel} (${d.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${a.key?22:8}px`},onDragstart:p=>{const u=p.dataTransfer;u?.setData("fieldKey",d.fieldKey),u&&(u.effectAllowed="all")},onClick:()=>{ku(d.fieldLabel||d.fieldKey).then(p=>{p&&(t.copiedFieldKey=d.fieldKey,e.repaint(),setTimeout(()=>{t.copiedFieldKey===d.fieldKey&&(t.copiedFieldKey="",e.repaint())},1200))})}},[h("span",{class:"node-icon",text:"📄"}),h("span",{class:"node-meta"},[n!=="key"?h("span",{class:"node-label",text:d.fieldLabel||d.fieldKey}):"",n!=="label"?h("span",{class:`node-key${n==="key"?" is-primary":""}`,text:n==="key"?d.fieldKey:`(${d.fieldKey})`}):""].filter(Boolean)),t.copiedFieldKey===d.fieldKey?h("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[c,h("div",{},s.filter(Boolean))].filter(Boolean)})),i.length===0?h("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function o2(e){const t=e.store,n=[...t.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),r=t.elements.filter(l=>t.selectedIds.has(l.id)),o=r.length>=2,i=r.some(l=>!!l.options.groupId),a=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return h("div",{class:"layer-panel"},[h("div",{class:"panel-title",text:"图层"}),...n.map(l=>{const c=Uf(l.printElementType.type);return h("div",{class:`layer-item${t.selectedIds.has(l.id)?" active":""}`,onClick:s=>t.selectElement(l.id,s.ctrlKey||s.metaKey)},[h("span",{class:"layer-icon","data-icon":c??"Shapes",html:Wi(c,12)}),h("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),a(l)?h("span",{class:"layer-zone",text:a(l)}):"",h("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))}),n.length?h("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,s])=>h("button",{type:"button",class:"pd-button small",title:c,html:ze(s,14),onClick:()=>e.fire("move-layer",l)}))]):"",o||i?h("div",{class:"layer-actions"},[o?h("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ze("Group",14),onClick:()=>e.fire("group")}):"",i?h("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ze("Ungroup",14),onClick:()=>e.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function i2(e){const t=e.store,n=e.state,r=t.pages.length>1,o=t.pages[t.activePageIndex]?.name||`页面 ${t.activePageIndex+1}`,i=t.tilingEnabled;return h("div",{class:"page-tabs"},[h("div",{class:"page-tabs-list"},t.pages.map((l,c)=>n.renamingPage===c?h("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,e.repaint())}}):h("button",{type:"button",class:`page-tab${c===t.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>t.switchPage(c),onDblclick:()=>{n.renamingPage=c,n.renameText=l.name??"",e.repaint()}}))),h("div",{class:"page-tabs-actions"},[h("button",{type:"button",dataset:{test:"add-page",tip:i?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:i,text:"+",onClick:()=>e.fire("add-page")}),h("button",{type:"button",dataset:{test:"duplicate-page",tip:i?"拼版模板仅允许一个设计页面":`复制当前页「${o}」`},disabled:i,text:"⧉",onClick:()=>e.fire("duplicate-page")}),h("button",{type:"button",dataset:{test:"delete-page",tip:r?`删除当前页「${o}」`:"仅多页面模板可删除页面"},disabled:!r,text:"✕",onClick:()=>e.fire("delete-page")}),h("button",{type:"button",dataset:{test:"move-left",tip:`前移「${o}」`},disabled:t.activePageIndex<=0,text:"←",onClick:()=>e.fire("move-page",-1)}),h("button",{type:"button",dataset:{test:"move-right",tip:`后移「${o}」`},disabled:t.activePageIndex>=t.pages.length-1,text:"→",onClick:()=>e.fire("move-page",1)})])]);function a(){const l=(n.renameText??"").trim();n.renamingPage!==null&&l&&t.renamePage(n.renamingPage,l),n.renamingPage=null,e.repaint()}}function a2(e){const t=e.store,n=t.templateData,r=Jt(n),o=n.orientation==="landscape"?"横向":"纵向",i=Dt[n.paperSize]?.label??n.paperSize,a=n.outputRotation,l=`${i} ${o} ${Math.round(r.width)}×${Math.round(r.height)}mm${a?`(旋转${a}°)`:""}`;return h("div",{class:"status-bar"},[h("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),h("span",{class:"status-item",text:`缩放 ${t.scale}%`}),h("span",{class:"status-item",text:`元素 ${t.elements.length}${t.selectedIds.size?` (选中 ${t.selectedIds.size})`:""}`}),h("span",{class:"status-item status-version",text:`v${Qx}`}),h("span",{class:"status-item status-paper",text:l})])}const s2=Object.keys(Dt).filter(e=>e!=="CUSTOM"&&!Dt[e]?.continuous);function l2(e){const t=document.createElement("label");t.className="pd-button small upload-label";const n=document.createTextNode("上传背景图"),r=document.createElement("input");r.className="visually-hidden",r.type="file",r.accept="image/*",t.append(n,r);const o=i=>{t.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=e.host.uploadDesignBackground;if(!a){alert("设计背景上传能力未配置"),r.value="";return}o(!0),n.textContent="上传中...";try{const l=await a(i);l?e.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{n.textContent="上传背景图",o(!e.host.uploadDesignBackground),r.value=""}}),e.host.uploadDesignBackground||o(!0),t}function c2(e){const n=e.store.templateData.designBackground,r=n?.rotation??0;return h("div",{class:"design-background-config"},[Ft("设计背景"),h("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),n?.src?[h("div",{class:"design-background-path",title:n.src,text:n.src}),h("div",{class:"design-background-actions"},[h("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(r+90)%360}°)`,onClick:()=>e.store.updateTemplateData({designBackground:{...n,rotation:(r+90)%360}})}),h("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>e.store.updateTemplateData({designBackground:void 0})})])]:l2(e)].flat())}function d2(e){const t=e.store,n=t.templateData,r=n.tiling,o={...It,...r??{},enabled:r?.enabled??!1,sheetMargin:{...It.sheetMargin,...r?.sheetMargin??{}}},i=_o(n.paperSize),a=g=>t.updateTemplateData({tiling:{...o,...g}}),l=g=>kn({target:o,base:It,propKey:g,write:()=>a({[g]:It[g]})}),c=g=>kn({target:o.sheetMargin,base:It.sheetMargin,propKey:g,write:()=>s(g,It.sheetMargin[g])}),s=(g,m)=>a({sheetMargin:{...o.sheetMargin,[g]:m??0}}),d={...n,tiling:o},p=ss(d),u=Math.max(mu(d),1);let f="";if(!p.length)try{const g=gu(d),m=Or(d),y=o.sheetPaperSize==="CUSTOM"?"自定义":o.sheetPaperSize??"A4",v=o.sheetPaperSize==="CUSTOM"?"":o.sheetOrientation==="landscape"?" 横向":" 纵向";f=`目标纸 ${y}${v} ${m.width}×${m.height}mm · ${g.columns} 列 × ${g.rows} 行 = 每张 ${g.perSheet} 格 · 每格 ${g.tile.width}×${g.tile.height}mm`}catch{f=""}return h("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Ft("拼版打印"),h("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),h("div",{class:"pd-field"},[h("label",{class:"tiling-switch"},[h("input",{type:"checkbox",checked:o.enabled===!0,disabled:i,onChange:g=>{if(!g.target.checked){a({enabled:!1});return}a({...It,columns:Math.min(It.columns,Math.max(u,1))})}}),h("span",{text:"启用拼版"})]),i?h("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),o.enabled&&!i?[se("目标纸张",h("select",{class:"pd-select",style:{width:"100%"},onChange:g=>{const m=g.target.value;if(m!=="CUSTOM"){a({sheetPaperSize:m});return}const y=Or(d);a({sheetPaperSize:"CUSTOM",sheetCustomWidth:o.sheetCustomWidth??y.width,sheetCustomHeight:o.sheetCustomHeight??y.height})}},[...s2.map(g=>h("option",{value:g,text:Dt[g]?.label??g,selected:(o.sheetPaperSize??"A4")===g})),h("option",{value:"CUSTOM",text:"自定义",selected:o.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),o.sheetPaperSize==="CUSTOM"?se("目标纸宽高 (mm)",h("div",{class:"custom-size-grid"},[J({value:Number(o.sheetCustomWidth??0),min:25,max:2e3,onCommit:g=>a({sheetCustomWidth:g})}),h("span",{class:"custom-size-x",text:"×"}),J({value:Number(o.sheetCustomHeight??0),min:25,max:2e3,onCommit:g=>a({sheetCustomHeight:g})})])):se("目标纸方向",on("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.sheetOrientation==="landscape"?"landscape":"portrait",g=>a({sheetOrientation:g})),void 0,l("sheetOrientation")),Ft("拼版留白 (mm)"),h("div",{class:"margin-grid"},[se("上",J({value:o.sheetMargin.top??0,min:0,max:100,onCommit:g=>s("top",g)}),void 0,c("top")),se("下",J({value:o.sheetMargin.bottom??0,min:0,max:100,onCommit:g=>s("bottom",g)}),void 0,c("bottom")),se("左",J({value:o.sheetMargin.left??0,min:0,max:100,onCommit:g=>s("left",g)}),void 0,c("left")),se("右",J({value:o.sheetMargin.right??0,min:0,max:100,onCommit:g=>s("right",g)}),void 0,c("right"))]),Ft("格间距与列数"),se("横向间距",J({value:o.gapX??0,min:0,max:50,onCommit:g=>a({gapX:g??0})}),void 0,l("gapX")),se("纵向间距",J({value:o.gapY??0,min:0,max:50,onCommit:g=>a({gapY:g??0})}),void 0,l("gapY")),se("列数",J({value:o.columns??1,min:1,max:u,onCommit:g=>a({columns:g||1})})),...p.map(g=>h("p",{class:"pd-hint tiling-error",text:g.message})),!p.length&&f?h("p",{class:"pd-hint tiling-summary",text:f}):""]:""].flat().filter(Boolean))}const u2=new Set(Mo.map(e=>e.group)),p2={"table-settings":"content"},Uh=new Map;function _l(e){const t=e??"";let n=Uh.get(t);if(!n){const{groups:r,itemKeys:o}=b0(t);n={groups:r,keys:o,searching:!!t.trim()},Uh.set(t,n)}return n}function Ml(e){const t=p2[e]??e;return u2.has(t)?t:""}function f2(e,t){const n=_l(e.state.propSearch);if(!n.searching)return!0;const r=Ml(t);return!r||n.groups.includes(r)}function h2(e,t){const n=_l(e.state.propSearch);return!n.searching||n.keys.has(t)}function qh(e,t){const n=e.props.style??{};return e.props.style={...n,display:t?"":"none"},e}function W(e,t,n){const r=n.props.dataset??{};return n.props.dataset={...r,propKey:t},qh(n,h2(e,t))}function g2(e,t,n){const r=Ml(t);if(!r)return n;const o=n.props.dataset??{};return n.props.dataset={...o,propGroup:r},qh(n,f2(e,t))}function Wh(e,t){const n=_l(t);for(const r of Array.from(e.querySelectorAll("[data-prop-group]"))){const o=Ml(r.dataset.propGroup??"");r.style.display=!n.searching||!o||n.groups.includes(o)?"":"none"}for(const r of Array.from(e.querySelectorAll("[data-prop-key]")))r.style.display=!n.searching||n.keys.has(r.dataset.propKey??"")?"":"none"}function m2(e){return h("div",{class:"property-search"},[h("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:e.state.propSearch??"",onInput:t=>{const n=t.target,r=n.value;e.state.propSearch=r,Wh(n.getRootNode(),r)}})])}const b2={Document:"≡",Brush:"◧",Setting:"⚙"};function y2(e,t){try{const n=window.localStorage.getItem(`property-group-${e}`);return n===null?t:n==="true"}catch{return t}}function v2(e,t){try{window.localStorage.setItem(`property-group-${e}`,String(t))}catch{}}function Qe(e,t,n,r,o,i=!0,a=[]){const l=y2(t,i);return g2(e,t,h("div",{class:`property-group${l?" is-expanded":""}`},[h("div",{class:"group-header",onClick:()=>{v2(t,!l),e.repaint()}},[h("span",{class:"group-icon",text:b2[r]||"•"}),h("span",{class:"group-title",text:n}),...a,h("span",{class:"expand-icon",text:l?"▾":"▸"})]),h("div",{class:"group-content",style:l?"":{display:"none"}},o.filter(Boolean))]))}function ji(e){return h("form",{class:"pd-form",onSubmit:t=>t.preventDefault()},e.filter(Boolean))}function jh(e){return e.split(".").flatMap(t=>{const n=t.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!n)return[t];const r=n[1],o=[...n[2].matchAll(/\[(\d+)\]/g)].map(i=>Number(i[1]));return[r,...o]})}function Gh(e,t){return jh(t).reduce((o,i)=>o==null?"":o[i],e)??""}function Tl(e,t,n,r){const o=jh(n),i=o.pop(),a=o.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),t);a[i]=r||void 0,e.recordHistory(),e.emit()}function w2(e,t){const n=e.store;if(t.printElementType.type==="table"&&n.tableSelection?.elementId===t.id){const{r1:r,c1:o}=n.tableSelection,i=(t.options.tableRows??[])[r];if(i)return Au(i.type,r,o,t.options.fields?.[0]?.dataSource)}return N1(t)}function x2(e,t){const n=document.createElement("label");n.className="pd-button small upload-label",Ze(h("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[h("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=e.host.uploadImage;if(!s){alert("图片上传能力未配置"),o.value="";return}i(!0),r.textContent="上传中...";try{const d=await s(c);d?Tl(e.store,t,"options.src",d):alert("图片上传失败")}catch(d){alert(d instanceof Error?d.message:"图片上传失败")}finally{r.textContent="上传图片",i(!e.host.uploadImage),o.value=""}}),e.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 E2(e,t){const n=r=>e.fire("open-expression",{elementId:t.id,targetPath:r.targetPath,value:Gh(t,r.targetPath)});return Qe(e,"binding","内容","Document",[...w2(e,t).map(r=>se(r.label,h("input",{class:"pd-input",type:"text",value:Gh(t,r.targetPath),placeholder:r.placeholder||"输入内容,支持 {字段} 表达式",onChange:o=>Tl(e.store,t,r.targetPath,o.target.value),onDblclick:()=>n(r)}))),t.printElementType.type==="image"?x2(e,t):""].filter(Boolean))}const Jr=new Map;function Gi(e){return`${Math.round(e*1e4)/1e4}%`}function Vh(e,t){const n=_1(t.value),r=n.kind==="custom",o=n.kind==="axes"?n.x:50,i=n.kind==="axes"?n.y:50,a=D1(t.src),l=Jr.get(a.src),c={widthMm:t.widthMm,heightMm:t.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:t.fit,scalePct:t.scale},s=M1(c),d=T1(c,o,i),p=document.createElement("select");p.className="pd-select",p.style.width="100%";for(const m of R1(s,o,i)){const y=document.createElement("option");y.value=m.value,y.textContent=m.label,p.appendChild(y)}if(r){const m=document.createElement("option");m.value="custom",m.textContent="自定义(保留原值)",p.appendChild(m)}p.value=r?"custom":`${o},${i}`,p.selectedIndex<0&&(p.selectedIndex=r?p.options.length-1:0),p.addEventListener("change",()=>{if(p.value==="custom")return;const[m,y]=p.value.split(",").map(Number);t.onCommit(xu(m,y))});const u=Ae(t.fieldKey),f=[h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[t.label,Sl(u)]),t.resetAnchor??""].filter(Boolean)),p])];f.push(h("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t"},[O1,Sl(Ae("ap-img-fit-scale"))]),t.resetScale??""].filter(Boolean)),J({value:t.scale,min:gr,max:Ic,step:5,placeholder:"默认 100",onCommit:m=>t.onScaleCommit(m>gr?m:void 0)})]));for(const m of P1(s,o,i))f.push(h("div",{class:"pd-field",dataset:{field:t.fieldKey}},[h("span",{class:"pd-label",text:m.label}),J({value:m.value,min:0,max:100,step:1,onCommit:y=>t.onCommit(xu(m.name==="horizontal"?y:o,m.name==="vertical"?y:i))})]));const g=I1(s,r);return g&&f.push(h("p",{class:"pd-crop-note",text:g})),a.isSample&&f.push(h("p",{class:"pd-crop-note",text:A1})),f.push(h("div",{class:"pd-crop-preview"},[h("img",{class:"pd-crop-thumb",src:a.src,alt:a.isSample?"示例图":"原图",onLoad:m=>{const y=m.target;if(!(y.naturalWidth>0&&y.naturalHeight>0))return;const v=Jr.get(a.src);v&&v.width===y.naturalWidth&&v.height===y.naturalHeight||(Jr.set(a.src,{width:y.naturalWidth,height:y.naturalHeight}),e.repaint())},onError:()=>{Jr.has(a.src)&&(Jr.delete(a.src),e.repaint())}}),d?h("div",{class:"pd-crop-win",style:{left:Gi(d.leftPct),top:Gi(d.topPct),width:Gi(d.widthPct),height:Gi(d.heightPct)}}):""])),h("div",{class:t.containerClass??"pd-crop-anchor"},f)}const An=e=>Number(e??0),Cl=e=>e||void 0;function Dn(e,t,n,r,o,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label",...r?{title:r}:{}},[h("span",{class:"pd-label-t",text:e}),o??""].filter(Boolean)),h("input",{class:"pd-switch",type:"checkbox",checked:t,...i?{disabled:!0}:{},onChange:a=>n(a.target.checked)})])}function Yh(e,t,n,r,o=!1,i){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),""].filter(Boolean)),h("select",{class:"pd-select",...o?{style:{width:"100%"}}:{},onChange:a=>r(a.target.value)},n.map(a=>h("option",{value:a.value,text:a.label,selected:a.value===t})))])}function Qr(e,t,n,r,o={}){return h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:e}),o.reset??""].filter(Boolean)),Bh(t,n,r,{className:"pd-select",...o.full?{width:"100%"}:{}})])}const er=e=>h("p",{class:"pd-hint",text:e}),S2="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",_2=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],M2=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],T2=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],C2=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],k2={value:"__multi__",label:"多选",disabled:!0};function A2(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[],i=r?o[r.r1]:void 0;if(!r||!i)return Qe(e,"table-row","行属性","Grid",[]);const a=l=>n.updateElement(t.id,l);return Qe(e,"table-row","行属性","Grid",[ji([Yh("行类型",i.type,_2,l=>{const c=ra(o,r.r1,l);if(c){window.alert(c);return}a({tableRows:o})},!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"行高 (mm)"}),J({value:i.height,min:3,max:100,step:.5,onCommit:l=>{i.height=l,a({tableRows:o})}})]),i.type==="header"?Dn("表头每页重复",i.repeatOnPage??!1,l=>{$g(o,l),a({tableRows:o})},S2):""])])}function D2(e,t){const n=e.store,r=t.options,o=d=>n.updateElement(t.id,d),i=r.tableColWidths??[],a=n.paperSize.width-n.templateData.margins.left-n.templateData.margins.right,l=n.fields.filter(d=>d.fieldType==="list").map(d=>({value:d.fieldKey,label:d.fieldLabel})),c=Sa("table"),s=d=>kn({target:r,base:c,propKey:d,write:()=>o({[d]:c[d]})});return Qe(e,"table-settings","表格设置","Grid",[ji([Yh("列表数据源字段",r.dataSource??"",l,d=>o({dataSource:d||void 0}),!0),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字体"}),s("tableDefaultFontFamily")]),qi({id:"table-default-font",state:e.state,fonts:e.host.fonts,value:r.tableDefaultFontFamily,placeholder:"默认",onChange:d=>o({tableDefaultFontFamily:d||void 0})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认字号 (pt)"}),s("tableDefaultFontSize")]),J({value:An(r.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:d=>o({tableDefaultFontSize:Cl(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认文字颜色"}),s("tableDefaultColor")]),ot(r.tableDefaultColor,d=>o({tableDefaultColor:d}),"默认文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),s("tableDefaultPadding")]),J({value:An(r.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:d=>o({tableDefaultPadding:Cl(d)})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"列宽 (mm)"}),...i.map((d,p)=>h("div",{class:"col-width-row"},[h("span",{style:{width:"60px"},text:`列${p+1}`}),J({value:d,min:5,max:200,onCommit:u=>{const f=i.reduce((g,m,y)=>y===p?g:g+m,0);if(f+u>a){const g=Math.max(5,Math.round((a-f)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${a}mm,列${p+1} 已调整为 ${g}mm`),i[p]=g}else i[p]=u;o({tableColWidths:i})}})]))])])])}function O2(e,t){const n=e.store,r=t.options,o=t.printElementType.type==="table",i=l=>n.updateElement(t.id,l),a=[];if(o)a.push(W(e,"pg-enabled",Dn("启用分页",r.tablePagination?.enabled??!0,l=>i({tablePagination:{enabled:l}}))));else{const l=r.pagination?.pageable??!0,c=r.pagination?.keepWithNext??!1;a.push(W(e,"pg-pageable",Dn("参与分页",l,s=>i({pagination:{pageable:s,keepWithNext:c}})))),a.push(W(e,"pg-keep-with-next",Dn("与下元素同页",c,s=>i({pagination:{pageable:l,keepWithNext:s}}))))}return Qe(e,"pagination","分页配置","Document",[ji(a)],!1)}const kl=new WeakMap,Kh=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function I2(e,t){const n=e.store,r=n.tableSelection,o=t.options.tableRows??[];if(!r)return Qe(e,"table-cell","单元格","Menu",[]);const i=ar(o,r.r1,r.c1),a=o[i.r]?.cells[i.c];if(!a)return Qe(e,"table-cell","单元格","Menu",[]);const l=()=>lo(o,r),c=oa(o,r),s=c.count,d=c.mode==="multi",p=`${t.id}:${r.r1}:${r.c1}:${r.r2}:${r.c2}`,u=kl.get(n),f=u?.key===p?u:{key:p,border:{},values:{},edges:{}};u?.key!==p&&kl.set(n,f);const g=_=>{kl.set(n,{key:p,border:_.border??f.border,values:_.values??f.values,edges:_.edges??f.edges})},m=(_,G)=>{g({border:{...f.border,[_]:G}}),e.repaint()},y=(_,G)=>{l().forEach(_),d&&G&&g({values:{...f.values,...G}}),n.updateElement(t.id,{tableRows:o})},v=(_,G)=>{y(K=>{K[_]=G},{[_]:G})},w=_=>d?f.values[_]:a[_],E=_=>d&&_ in f.values,T=d?{width:void 0,style:void 0,color:void 0}:cc(o,r),P=!d&&l().some(_=>!!_.borders&&!!(_.borders.top||_.borders.right||_.borders.bottom||_.borders.left)),O=!d&&!P,I={width:O?0:typeof T.width=="number"?T.width:Kt.width,style:O?"none":typeof T.style=="string"&&T.style!=="mixed"?T.style:Kt.style,color:typeof T.color=="string"&&T.color!=="mixed"?T.color:Kt.color,...f.border},A="__mixed__",k={style:!d&&T.style==="mixed",width:!d&&T.width==="mixed",color:!d&&T.color==="mixed"},R=k.style&&!("style"in f.border),S=k.width&&!("width"in f.border),$=k.color&&!("color"in f.border),N=R||S||$,B=R?A:I.style,C=S?void 0:I.width,ie=$?void 0:I.color,pe=_=>{const G={style:_};_!=="none"&&C===0?G.width=Kt.width:_==="none"&&!P&&(G.width=0),g({border:{...f.border,...G}}),e.repaint()},Ge=()=>({...I}),Q=d?Kh.reduce((_,G)=>(_[G.value]=f.edges[G.value]?"on":"off",_),{}):Zc(l().map(_=>_.borders)),Te=d?"cellType"in f.values?f.values.cellType??"text":zg(o,r):a.cellType??"text",he=Te==="barcode",de=Te==="qrcode",ye=Te==="image",ne=Te==="text",Pe=he&&!!w("printerDpi"),it=Ac(w("printerDpi"),w("barWidth")),te=d?f.values.textFit:sa(a),Ve=d?"cellType"in f.values?f.values.cellType??"text":"":a.cellType||"text",Re=_=>d?[k2,..._]:_,fe=_=>d?"多选":_,me=(_,G)=>d?f.values[_]:G,tr=d?w("barcodeType")??"__multi__":a.barcodeType||"CODE128",to=d?E("printerDpi")?w("printerDpi")?String(w("printerDpi")):"":"__multi__":a.printerDpi?String(a.printerDpi):"",no=d?w("qrCodeLevel")??"__multi__":a.qrCodeLevel||"M",ro=d?w("fit")??"__multi__":a.fit||"contain",nr=te??"__multi__",ge=nc(o,r);let Mt=!0;for(let _=r.r1;_<=r.r2;_++)if(o[_]?.type!=="data"){Mt=!1;break}const M=Mt?"":"仅数据行(明细行)支持按值合并";let H=!1;for(let _=r.r1;_<=r.r2&&!H;_++)for(let G=r.c1;G<=r.c2&&!H;G++){const K=o[_]?.cells[G];K&&!K.merged&&((K.rowspan??1)>1||(K.colspan??1)>1)&&(H=!0)}const z=(_,G,K,Z={},oe)=>h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:_}),oe??""].filter(Boolean)),J({value:G,...Z,onCommit:be=>v(K,Cl(be))})]),q="恢复默认值(跟随表格默认)",U=_=>kn({target:a,base:{},propKey:_,tipOverride:q,force:d,write:()=>v(_,void 0)}),V=t.options.tableDefaultPadding??1,ee={width:ca(t.options.tableColWidths??[],i.c,a,V),height:ur(o,i.r,a,V)};return Qe(e,"table-cell","单元格","Menu",[ji([d?er(`已选 ${s} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"单元格类型"}),on("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],Ve,_=>{const G=_==="text"?void 0:_,K={cellType:_};_!=="barcode"&&Object.assign(K,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),_!=="qrcode"&&Object.assign(K,{qrCodeLevel:void 0,qrQuietZone:void 0}),y(Z=>{Z.cellType=G,_!=="barcode"&&(Z.barcodeType=void 0,Z.showBarcodeText=void 0,Z.printerDpi=void 0,Z.barQuietZone=void 0,Z.barHeight=void 0),_!=="qrcode"&&(Z.qrCodeLevel=void 0,Z.qrQuietZone=void 0)},K)})]),he?Qr("码制",tr,Re(M2),_=>{_!=="__multi__"&&v("barcodeType",_||void 0)}):"",he?Dn("显示文本",d?f.values.showBarcodeText===!0:a.showBarcodeText!==!1,_=>v("showBarcodeText",_),void 0,U("showBarcodeText")):"",he?z("条宽(倍率)",me("barWidth",a.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:fe("")},U("barWidth")):"",he?er((Pe?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(it?`。${it}`:"")):"",he?He("静区 (模块)",J({value:me("barQuietZone",a.barQuietZone),min:0,max:20,placeholder:fe("默认 10"),onCommit:_=>v("barQuietZone",_)}),Ae("cd-bar-quiet-zone"),U("barQuietZone")):"",he?He("条高 (mm)",J({value:me("barHeight",a.barHeight),min:1,max:100,placeholder:fe("默认 30 模块"),onCommit:_=>v("barHeight",_??void 0)}),Ae("cd-bar-height"),U("barHeight")):"",he?z("文本字号(相对条高,条高为 30)",me("barFontSize",a.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:fe("默认 10")},U("barFontSize")):"",he?Qr("打印机分辨率",to,Re([{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)"}]),_=>{if(_==="__multi__")return;const G=Number(_);v("printerDpi",G>0?G:void 0)},{reset:U("printerDpi")}):"",he?er("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",de?Qr("纠错级别",no,Re(T2),_=>{_!=="__multi__"&&v("qrCodeLevel",_||void 0)},{reset:U("qrCodeLevel")}):"",de?He("静区 (模块)",J({value:me("qrQuietZone",a.qrQuietZone),min:0,max:8,placeholder:fe("默认 0"),onCommit:_=>v("qrQuietZone",_)}),Ae("cd-quiet-zone"),U("qrQuietZone")):"",he?er("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",de||ye?Qr("缩放模式",ro,Re(ds),_=>{_!=="__multi__"&&v("fit",_)},{reset:U("fit")}):"",ye&&!d&&a.fit==="cover"?Vh(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:_u(a.formatter),fit:a.fit,containerClass:"pd-cell-anchor",widthMm:ee.width,heightMm:ee.height,scale:a.fitScale,value:a.objectPosition,onCommit:_=>v("objectPosition",_),onScaleCommit:_=>v("fitScale",_),resetAnchor:U("objectPosition"),resetScale:U("fitScale")}):"",he||de||ye?z("最大宽度 (mm)",me("maxWidth",An(a.maxWidth)),"maxWidth",{min:0,max:200,placeholder:fe("默认")},U("maxWidth")):"",he||de||ye?z("最大高度 (mm)",me("maxHeight",An(a.maxHeight)),"maxHeight",{min:0,max:200,placeholder:fe("默认")},U("maxHeight")):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"内容"}),h("input",{class:"pd-input",type:"text",value:d?w("formatter")??"":a.formatter||"",placeholder:d?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:_=>v("formatter",_.target.value||void 0),onDblclick:()=>e.fire("table-cell-dblclick",{elementId:t.id,r:i.r,c:i.c,cellId:a.id})})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"水平对齐"}),U("align")]),on("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],d?f.values.align??"":a.align||"left",_=>v("align",_))]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"垂直对齐"}),U("valign")]),on("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],d?f.values.valign??"":a.valign||"top",_=>v("valign",_))]),h("div",{class:"cell-style-grid"},[h("div",{class:"pd-field cell-font-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"字体"}),U("fontFamily")]),qi({id:"cell-font",state:e.state,fonts:e.host.fonts,value:d?w("fontFamily"):a.fontFamily,placeholder:fe("继承默认"),onChange:_=>v("fontFamily",_)})]),z("字号 (pt)",me("fontSize",An(a.fontSize)),"fontSize",{min:0,max:72,placeholder:fe("默认")},U("fontSize")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"加粗"}),U("fontWeight")]),h("input",{class:"pd-switch",type:"checkbox",checked:d?f.values.fontWeight==="bold":a.fontWeight==="bold",onChange:_=>v("fontWeight",_.target.checked?"bold":void 0)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"文字颜色"}),U("color")]),ot(d?w("color"):a.color,_=>v("color",_),"文字颜色")]),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"背景色"}),U("backgroundColor")]),ot(d?w("backgroundColor"):a.backgroundColor,_=>v("backgroundColor",_),"背景颜色")])]),Ft("边框"),h("div",{class:"border-style-row"},[Bh(B,[...R?[{value:A,label:"混合",disabled:!0}]:[],...Ca],_=>{_!==A&&pe(_)},{width:"90px"}),h("div",{style:{width:"112px",flexShrink:"0"}},[J({value:C,min:.25,max:5,step:.25,placeholder:d?"多选":S?"混合":void 0,onCommit:_=>m("width",_)})]),ot(ie,_=>m("color",_),"边框颜色")]),h("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([_,G])=>h("button",{type:"button",class:"pd-button small",text:G,onClick:()=>{sc(o,r,I.style==="none"?"none":_,Ge()),n.updateElement(t.id,{tableRows:o})}}))),h("div",{class:"pd-checkbox-group"},Kh.map(_=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",value:_.value,checked:Q[_.value]==="on",indeterminate:Q[_.value]==="mixed",onChange:G=>{const Z=G.target.checked&&I.style!=="none";d&&g({edges:{...f.edges,[_.value]:Z}}),y(oe=>{lc(oe,_.value,Z?Ge():null)})}}),h("span",{text:_.label})]))),er(d?Lg:N?Bg:Ng),z("内边距 (mm)",me("padding",An(a.padding)),"padding",{min:0,max:10,step:.5,placeholder:fe("默认")},U("padding")),Dn("自动换行",d?f.values.wordWrap===!0:a.wordWrap??!0,_=>v("wordWrap",_),void 0,U("wordWrap")),ne?Qr("文字溢出",nr,Re(C2),_=>{_!=="__multi__"&&v("textFit",_)},{full:!0,reset:U("textFit")}):"",ne&&te==="shrink"?z("最小字号 (pt)",me("shrinkMinFontSize",An(a.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:fe("默认 6")},U("shrinkMinFontSize")):"",h("div",{class:"merge-card"},[h("div",{class:"merge-card-title",text:"单元格合并"}),h("div",{class:"merge-btns"},[h("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!ge,title:ge||"",onClick:()=>{rc(o,r),n.updateElement(t.id,{tableRows:o})}}),h("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!H,onClick:()=>{oc(o,r),n.updateElement(t.id,{tableRows:o})}})]),h("div",{class:"merge-card-divider"}),Dn("按值合并",d?f.values.mergeSameValue===!0:a.mergeSameValue===!0,_=>v("mergeSameValue",_),M||void 0,Mt?U("mergeSameValue"):void 0,!Mt),er("明细相邻行同值时自动纵向合并;跨页时在该页内成段,续页首行重放该值")])])])}const Al=cb;function Dl(e){const t=e.trim();return t?/[{}]/.test(t)||/^[A-Za-z_$][\w$]*\s*\(/.test(t)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(t):!1}function P2(e){return e?e.mode==="binding"?e.binding??"":e.content??"":""}function R2(e){const t=e.store.templateData.watermark,n=P2(t),r=t?.mode==="binding"||n!==""&&Dl(n),o=(()=>{const s=t?.tileWidth??le.tileWidth,d=t?.tileHeight??le.tileHeight;for(const[p,u]of Object.entries(Al))if(u.width===s&&u.height===d)return p;return"custom"})(),i=s=>{const d={...t,testData:t?.testData??"",rotate:t?.rotate??le.rotate,color:t?.color||le.color,opacity:t?.opacity??le.opacity,tileWidth:t?.tileWidth??le.tileWidth,tileHeight:t?.tileHeight??le.tileHeight};e.store.updateTemplateData({watermark:{...d,...s}})},a=()=>e.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:n}),l={rotate:t?.rotate??le.rotate,color:t?.color||le.color,opacity:t?.opacity??le.opacity,tileWidth:t?.tileWidth??le.tileWidth,tileHeight:t?.tileHeight??le.tileHeight},c=s=>kn({target:l,base:le,propKey:s,write:()=>i({[s]:le[s]})});return h("div",{class:"watermark-config"},[Ft("水印"),h("form",{class:"pd-form",onSubmit:s=>s.preventDefault()},[h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"水印表达式"}),h("input",{class:"pd-input",type:"text",value:n,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:s=>{const d=s.target.value;i(Dl(d)?{mode:"binding",binding:d,content:""}:{mode:"fixed",content:d,binding:""})},onDblclick:a}),h("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:a})]),r?se("测试值",h("input",{class:"pd-input",type:"text",value:t?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:s=>i({testData:s.target.value})})):"",h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),h("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(t?.rotate??le.rotate),onChange:s=>i({rotate:Number(s.target.value)})}),h("span",{class:"pd-hint",text:`${t?.rotate??le.rotate}°`})]),se("颜色",ot(t?.color||le.color,s=>i({color:s}),"水印颜色"),void 0,c("color")),h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),h("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(t?.opacity??le.opacity),onChange:s=>i({opacity:Number(s.target.value)})}),h("span",{class:"pd-hint",text:(t?.opacity??le.opacity).toFixed(2)})]),h("div",{class:"pd-field"},[h("span",{class:"pd-label",text:"密度"}),h("select",{class:"pd-select",style:{width:"100%"},onChange:s=>{const d=s.target.value,p=Al[d];p&&i({tileWidth:p.width,tileHeight:p.height})}},[...Object.entries(Al).map(([s,d])=>h("option",{value:s,text:`${d.label}(${d.width}×${d.height})`,selected:o===s})),h("option",{value:"custom",text:"自定义",selected:o==="custom"})])]),o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),h("input",{type:"number",class:"pd-input",min:le.minTileWidth,step:10,value:String(t?.tileWidth??le.tileWidth),onChange:s=>i({tileWidth:Number(s.target.value)})})]):"",o==="custom"?h("div",{class:"pd-field"},[h("span",{class:"pd-label"},[h("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),h("input",{type:"number",class:"pd-input",min:le.minTileHeight,step:10,value:String(t?.tileHeight??le.tileHeight),onChange:s=>i({tileHeight:Number(s.target.value)})})]):""].filter(Boolean))])}function Oe(e,t,n,r,o={},i){return se(t,J({value:n,...o,onCommit:r}),void 0,i)}function jt(e,t,n,r,o,i,a){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>o(l.value));for(const c of r){const s=document.createElement("option");s.value=c.value,s.textContent=c.label,l.appendChild(s)}return l.value=n,r.some(c=>c.value===n)||(l.selectedIndex=-1),i?He(t,l,i,a):se(t,l,void 0,a)}function On(e,t,n,r,o){return se(t,h("input",{type:"checkbox",class:"pd-switch",checked:n,onChange:i=>r(i.target.checked)}),void 0,o)}const F2=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],$2=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function N2(e,t){const n=e.store,r=t.options,o=t.printElementType.type,i=C=>n.updateElement(t.id,C),a=zf(o),l=a==="text",c=a==="code",s=a==="table",d=s&&n.tableSelection?.elementId===t.id,p=d&&oa(t.options.tableRows??[],n.tableSelection).mode==="multi",u=[];p||u.push(E2(e,t));const f=Sa(o),g=(C,ie)=>{const pe=y0(ie);return kn({target:r,base:f,propKey:C,tipValue:pe?.value,tipUnit:pe?.unit,write:()=>i({[C]:f[C]})})};d||u.push(Qe(e,"position-size","位置与尺寸","Location",[h("form",{class:"pd-form",onSubmit:C=>C.preventDefault()},[h("div",{class:"position-grid"},[W(e,"ps-left",Oe(e,"X",r.left,C=>i({left:C}),{min:0})),W(e,"ps-top",Oe(e,"Y",r.top,C=>i({top:C}),{min:0})),W(e,"ps-width",Oe(e,"W",r.width,C=>i({width:C}),{min:4})),W(e,"ps-height",Oe(e,"H",r.height,C=>i({height:C}),{min:4}))]),h("h3",{class:"pd-divider",text:"外边距 (mm)"}),h("div",{class:"margin-grid"},[W(e,"ps-margin-top",Oe(e,"上",r.marginTop,C=>i({marginTop:C===0?void 0:C}),{},g("marginTop","ps-margin-top"))),W(e,"ps-margin-right",Oe(e,"右",r.marginRight,C=>i({marginRight:C===0?void 0:C}),{},g("marginRight","ps-margin-right"))),W(e,"ps-margin-bottom",Oe(e,"下",r.marginBottom,C=>i({marginBottom:C===0?void 0:C}),{},g("marginBottom","ps-margin-bottom"))),W(e,"ps-margin-left",Oe(e,"左",r.marginLeft,C=>i({marginLeft:C===0?void 0:C}),{},g("marginLeft","ps-margin-left")))])])]));const m=typeof r.rotate=="number"&&Number.isFinite(r.rotate)&&r.rotate!==0?mr(r.rotate):void 0,y=C=>i({rotate:C===void 0||C===0?void 0:mr(C)}),v=Mm(o,r),w=$c(o)||Hc(n.elements).has(t.id),E=w?"":W(e,"ap-rotate",He("旋转 (°)",h("div",{class:"pd-rotate-row"},[h("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>y((m??0)-90)}),h("div",{class:"pd-rotate-stepper"},[J({value:m,min:0,max:359,placeholder:"0",disabled:!v,onCommit:C=>y(C)})]),h("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>y((m??0)+90)})]),Ae("ap-rotate"),g("rotate","ap-rotate"))),T=w||v?"":h("p",{class:"pd-hint pd-rotate-note",text:_m});if(u.push(Qe(e,"appearance","外观","Brush",[h("form",{class:"pd-form",onSubmit:C=>C.preventDefault()},l?[W(e,"ap-font-family",se("字体",qi({id:"prop-font",state:e.state,fonts:e.host.fonts,value:typeof r.fontFamily=="string"?r.fontFamily:void 0,placeholder:"默认",onChange:C=>i({fontFamily:C})}),void 0,g("fontFamily","ap-font-family"))),W(e,"ap-font-size",Oe(e,"字体大小",r.fontSize,C=>i({fontSize:C}),{min:8,max:72},g("fontSize","ap-font-size"))),W(e,"ap-font-weight",jt(e,"字体粗细",String(r.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],C=>i({fontWeight:C}),void 0,g("fontWeight","ap-font-weight"))),W(e,"ap-align",se("对齐",on("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],r.textAlign||"left",C=>i({textAlign:C})),void 0,g("textAlign","ap-align"))),W(e,"ap-vertical-align",se("垂直对齐",on("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],r.verticalAlign||"top",C=>i({verticalAlign:C})),void 0,g("verticalAlign","ap-vertical-align"))),h("div",{class:"color-row"},[W(e,"ap-color",se("颜色",ot(r.color,C=>i({color:C}),"字体颜色"),void 0,g("color","ap-color"))),W(e,"ap-bg-color",se("背景色",ot(r.backgroundColor,C=>i({backgroundColor:C}),"背景颜色"),void 0,g("backgroundColor","ap-bg-color")))]),W(e,"ap-line-height",Oe(e,"行高",r.lineHeight,C=>i({lineHeight:C||void 0}),{min:0,max:100},g("lineHeight","ap-line-height"))),W(e,"ap-letter-spacing",Oe(e,"字间距",r.letterSpacing,C=>i({letterSpacing:C||void 0}),{min:0,max:20,step:.5},g("letterSpacing","ap-letter-spacing"))),W(e,"ap-text-fit",jt(e,"文字溢出",po(o,r),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],C=>i({textFit:C}),void 0,g("textFit","ap-text-fit"))),r.textFit==="shrink"?W(e,"ap-shrink-min",se("最小字号 (pt)",J({value:r.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:C=>i({shrinkMinFontSize:C||void 0})}),void 0,g("shrinkMinFontSize","ap-shrink-min"))):"",o==="longText"?W(e,"ap-long-text-indent",He("首行缩进 (字符)",J({value:r.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:C=>i({longTextIndent:C||void 0})}),Ae("ap-long-text-indent"),g("longTextIndent","ap-long-text-indent"))):"",W(e,"ap-word-wrap",On(e,"自动换行",r.wordWrap!==!1,C=>i({wordWrap:C?void 0:!1}),g("wordWrap","ap-word-wrap"))),W(e,"ap-keep-line-breaks",On(e,"保留换行符",r.keepLineBreaks===!0,C=>i({keepLineBreaks:C?!0:void 0}),g("keepLineBreaks","ap-keep-line-breaks"))),E,T]:[o==="image"?W(e,"ap-img-fit",jt(e,"缩放模式",String(r.fit??"contain"),ds,C=>i({fit:C}),Ae("ap-img-fit"),g("fit","ap-img-fit"))):"",o==="image"&&r.fit==="cover"?W(e,"ap-img-object-position",Vh(e,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:_u(r.src),widthMm:Number(r.width)||0,heightMm:Number(r.height)||0,fit:r.fit,scale:r.fitScale,value:r.objectPosition===void 0?void 0:String(r.objectPosition),onCommit:C=>i({objectPosition:C}),onScaleCommit:C=>i({fitScale:C}),resetAnchor:g("objectPosition","ap-img-object-position"),resetScale:g("fitScale","ap-img-fit-scale")})):"",E,T,o==="flowList"?h("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),c){const C=o==="barcode",ie=String(r.barcodeType||"CODE128").toUpperCase(),pe=r.printerDpi?String(r.printerDpi):"",Ge=Ac(r.printerDpi,r.barWidth);u.push(Qe(e,"code","条码设置","Postcard",[h("form",{class:"pd-form",onSubmit:Q=>Q.preventDefault()},[C?[W(e,"cd-type",jt(e,"码制",ie,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Q=>i({barcodeType:Q==="CODE128"?void 0:Q}))),W(e,"cd-dpi",jt(e,"打印机分辨率",pe,[{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)"}],Q=>i({printerDpi:Number(Q)>0?Number(Q):void 0}),void 0,g("printerDpi","cd-dpi"))),W(e,"cd-dpi",h("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),W(e,"cd-bar-width",Oe(e,"条宽(倍率)",r.barWidth??2,Q=>i({barWidth:Q}),{min:2,max:8,step:.5},g("barWidth","cd-bar-width"))),W(e,"cd-bar-width",h("p",{class:"pd-hint",text:(pe?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Ge?`。${Ge}`:"")})),W(e,"cd-bar-quiet-zone",He("静区 (模块)",J({value:r.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:Q=>i({barQuietZone:Q})}),Ae("cd-bar-quiet-zone"),g("barQuietZone","cd-bar-quiet-zone"))),W(e,"cd-bar-height",He("条高 (mm)",J({value:r.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:Q=>i({barHeight:Q??void 0})}),Ae("cd-bar-height"),g("barHeight","cd-bar-height"))),W(e,"cd-show-text",On(e,"显示文本",r.hideTitle!==!0,Q=>i({hideTitle:Q?void 0:!0}),g("hideTitle","cd-show-text"))),W(e,"cd-font-size",se("文本字号(相对条高,条高为 30)",J({value:r.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:Q=>i({fontSize:Q||void 0})}),void 0,g("fontSize","cd-font-size")))]:[W(e,"cd-ec-level",jt(e,"纠错级别",String(r.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Q=>i({qrCodeLevel:Q}),void 0,g("qrCodeLevel","cd-ec-level"))),W(e,"cd-quiet-zone",He("静区 (模块)",J({value:r.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:Q=>i({qrQuietZone:Q})}),Ae("cd-quiet-zone"),g("qrQuietZone","cd-quiet-zone")))],Ft("自定义设置"),C?h("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",C?"":W(e,"cd-fit",jt(e,"缩放模式",String(r.fit||"contain"),ds,Q=>i({fit:Q||void 0}),void 0,g("fit","cd-fit"))),W(e,"cd-max-width",se("最大宽度 (mm)",J({value:r.maxWidth,min:1,max:200,placeholder:"默认",onCommit:Q=>i({maxWidth:Q||void 0})}),void 0,g("maxWidth","cd-max-width"))),W(e,"cd-max-height",se("最大高度 (mm)",J({value:r.maxHeight,min:1,max:200,placeholder:"默认",onCommit:Q=>i({maxHeight:Q||void 0})}),void 0,g("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(d&&(u.push(A2(e,t)),u.push(I2(e,t))),s&&u.push(D2(e,t)),o==="flowList"){const C=pt(r.flowColumns),ie=Xt(r.flowRowHeight),pe=vt(r.flowGapX),Ge=fn(r.flowMaxSpan,C),Q=um(r.width??0,pe,r.fontSize??12),Te=pn(r.flowLayoutMode),he=Te==="dynamic",de=$n(r),ye=(ne,Pe)=>{i({[ne]:typeof Pe=="number"&&Number.isFinite(Pe)&&Pe>0?Pe:0})};u.push(Qe(e,"flowList","流式列表","Grid3x3",[h("form",{class:"pd-form",onSubmit:ne=>ne.preventDefault()},[W(e,"fl-layout-mode",jt(e,"布局模式",Te,[{value:"fixed",label:"固定高度"},{value:"dynamic",label:"动态分页"}],ne=>i({flowLayoutMode:ne==="dynamic"?"dynamic":"fixed"}),Ae("fl-layout-mode"))),...he?[W(e,"fl-padding-top",He("上内边距 (mm)",J({value:de.top,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingTop",ne)}),Ae("fl-padding-top"))),W(e,"fl-padding-right",He("右内边距 (mm)",J({value:de.right,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingRight",ne)}),Ae("fl-padding-right"))),W(e,"fl-padding-bottom",He("下内边距 (mm)",J({value:de.bottom,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingBottom",ne)}),Ae("fl-padding-bottom"))),W(e,"fl-padding-left",He("左内边距 (mm)",J({value:de.left,min:0,max:100,step:.5,onCommit:ne=>ye("flowPaddingLeft",ne)}),Ae("fl-padding-left")))]:[],W(e,"fl-columns",He("每行列数",J({value:C,min:1,max:12,onCommit:ne=>i({flowColumns:pt(ne),flowMaxSpan:fn(r.flowMaxSpan,pt(ne))})}),Ae("fl-columns"))),W(e,"fl-row-height",He("行高 (mm)",J({value:ie,min:3,max:100,step:.5,onCommit:ne=>i({flowRowHeight:Xt(ne)})}),Ae("fl-row-height"))),W(e,"fl-gap-x",He("单元横向间距 (mm)",J({value:pe,min:0,max:50,step:.5,onCommit:ne=>i({flowGapX:vt(ne)})}),Ae("fl-gap-x"))),W(e,"fl-auto-span",On(e,"内容过长时跨列",r.flowAutoSpan===!0,ne=>{i(ne?{flowAutoSpan:ne,flowMaxSpan:Ge}:{flowAutoSpan:ne})})),r.flowAutoSpan===!0?W(e,"fl-max-span",He("最多跨几列",J({value:Ge,min:1,max:C,onCommit:ne=>i({flowMaxSpan:fn(ne,C)})}),Ae("fl-max-span"))):"",C>Q?h("p",{class:"pd-hint",text:`按当前字号与框宽,${C} 列偏挤(可放约 ${Q} 列)。数值保持不变,出纸按 ${C} 列排。`}):""].flat().filter(Boolean))]))}const P=()=>({borderWidth:r.borderWidth,borderStyle:r.borderStyle,borderColor:r.borderColor,borders:r.borders}),O=C=>{const ie=P();Jc(ie,C,td(ie)),i(ie)},I=C=>{const ie=P();Aa(ie,C,!xr(ie,C)),i(ie)},A=ed(r),k=A.style==="mixed",R=typeof A.width=="number"?A.width:void 0,S=k||A.style===void 0?"":A.style,$=typeof A.color=="string"?A.color:void 0,N=(C,ie)=>{const pe=P();Qm(pe,C,ie),i(pe)},B=k?[{value:"",label:"混合"},...Ca]:[...Ca];return u.push(Qe(e,"border-bg","边框与背景","Picture",[h("form",{class:"pd-form",onSubmit:C=>C.preventDefault()},[W(e,"bb-border-style",jt(e,"线型",S,B,C=>N("borderStyle",C))),h("div",{class:"border-row"},[W(e,"bb-border-width",Oe(e,"边框宽度",R,C=>N("borderWidth",C),{min:0,max:20,step:.25,placeholder:A.width==="mixed"?"混合":void 0},g("borderWidth","bb-border-width"))),W(e,"bb-border-color",se("边框颜色",ot($,C=>N("borderColor",C),"边框颜色"),void 0,g("borderColor","bb-border-color")))]),...mo(o)?[h("div",{class:"pd-button-group border-presets"},F2.map(C=>h("button",{type:"button",class:"pd-button small",text:C.label,disabled:C.value==="inner",onClick:()=>O(C.value)}))),h("div",{class:"pd-checkbox-group"},$2.map(C=>h("label",{class:"pd-checkbox"},[h("input",{type:"checkbox",checked:xr(r,C.value),onChange:()=>I(C.value)}),h("span",{text:C.label})]))),h("p",{class:"pd-hint",text:Gm})]:[],W(e,"bb-bg-color",se("背景色",ot(r.backgroundColor,C=>i({backgroundColor:C}),"背景颜色"),void 0,g("backgroundColor","bb-bg-color")))])])),u.push(O2(e,t)),u.push(Qe(e,"advanced","高级设置","Setting",[h("form",{class:"pd-form",onSubmit:C=>C.preventDefault()},[h("div",{class:"advanced-row"},[W(e,"ad-locked",On(e,"锁定",!!r.locked,C=>i({locked:C}),g("locked","ad-locked"))),W(e,"ad-fixed",On(e,"每页重复",!!r.repeatOnEveryPage,C=>i({repeatOnEveryPage:C}),g("repeatOnEveryPage","ad-fixed"))),W(e,"ad-fixed-position",On(e,"每页固定",!!r.fixed,C=>i({fixed:C}),g("fixed","ad-fixed-position")))]),W(e,"ad-z-index",Oe(e,"层级",r.zIndex,C=>i({zIndex:C}),{min:0,max:999},g("zIndex","ad-z-index"))),W(e,"ad-delete",h("div",{class:"pd-field"},[h("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>n.deleteSelected()})]))])],!1,[h("button",{type:"button",class:"group-help",title:"高级设置说明","aria-label":"高级设置说明",text:"?",onClick:C=>{C.stopPropagation(),e.fire("help","advanced-settings")}})])),h("div",{class:"property-content"},u)}function L2(e){const t=e.store,n=t.templateData,r=c=>t.updateTemplateData(c),o=c=>{const s=n.tiling,d=p=>p===90||p===270;if(s?.enabled&&d(c)!==d(n.outputRotation)){const p=mu({...n,outputRotation:c});r({outputRotation:c,tiling:{...s,columns:Math.max(p,1)}});return}r({outputRotation:c})},i=[];for(const[c,s]of Object.entries(Dt)){const d=s.group??"其他";let p=i.find(u=>u.group===d);p||(p={group:d,items:[]},i.push(p)),p.items.push({key:c,label:s.label??c})}const a=!Dt[n.paperSize],l=_o(n.paperSize);return h("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Ft("纸张设置"),se("纸张尺寸",h("select",{class:"pd-select",style:{width:"100%"},onChange:c=>r({paperSize:c.target.value})},[...i.map(c=>h("optgroup",{label:c.group},c.items.map(s=>h("option",{value:s.key,text:s.label,selected:n.paperSize===s.key})))),h("option",{value:"CUSTOM",text:"自定义宽高",selected:a})])),l||a?se(l?"纸宽 (mm)":"自定义宽高 (mm)",h("div",{class:"custom-size-grid"},[J({value:Number(n.customWidth??0),min:25,max:2e3,onCommit:c=>r({customWidth:c})}),...a?[h("span",{class:"custom-size-x",text:"×"}),J({value:Number(n.customHeight??0),min:25,max:2e3,onCommit:c=>r({customHeight:c})})]:[]])):"",l?"":se("纸张方向",on("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.orientation==="landscape"?"landscape":"portrait",c=>r({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":se("内容旋转角度",on("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(n.outputRotation??0),c=>o(Number(c)),!0),n.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),se("页面背景色",h("div",{class:"page-bg-row"},[ot(n.pageBackground,c=>r({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,kn({target:n,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>r({pageBackground:void 0})})),c2(e),t.pages.length>1?"":d2(e),Ft("页边距 (mm)"),h("div",{class:"margin-grid"},[Oe(e,"上",n.margins.top,c=>r({margins:{...n.margins,top:c}}),{min:0,max:50}),Oe(e,"下",n.margins.bottom,c=>r({margins:{...n.margins,bottom:c}}),{min:0,max:100}),Oe(e,"左",n.margins.left,c=>r({margins:{...n.margins,left:c}}),{min:0,max:50}),Oe(e,"右",n.margins.right,c=>r({margins:{...n.margins,right:c}}),{min:0,max:50})]),Ft("页眉/页脚高度 (mm)"),Oe(e,"页眉高度",n.header.height??10,c=>r({header:{...n.header,height:c}}),{min:0,max:100,step:.1}),Oe(e,"页脚高度",n.footer.height??10,c=>r({footer:{...n.footer,height:c}}),{min:0,max:100,step:.1}),R2(e)].filter(Boolean))}function B2(e,t,n){const r=(e.state.propSearch??"").trim(),o=!r||dd(r,[...n.searchKeywords,n.label]),i=document.createElement("div");if(i.className="property-content",o)try{hh(`property:${t.id}`,n.ui.renderProperty({element:t,data:e.host.designData?.length?e.host.designData:[gt],fields:e.host.fields??[],update:a=>e.store.updateElement(t.id,a),repaint:()=>e.repaint()}),i)}catch{}return h("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:custom"},style:e.state.propTab==="custom"?"":{display:"none"}},[i])}function z2(e){const t=e.store,n=e.state,r=t.selectedElement,o=r?Vs(r):void 0;if(n.propCollapsed)return h("div",{class:"property-panel collapsed"},[h("div",{class:"prop-collapsed"},[h("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{n.propCollapsed=!1,e.repaint()}}),...o?[h("button",{type:"button",class:`pc-btn${n.propTab==="custom"?" on":""}`,title:o.label,html:ze(o.icon,14)||ze("Shapes",14),onClick:()=>{n.propTab="custom",n.propCollapsed=!1,e.repaint()}})]:[],...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([a,l,c])=>h("button",{type:"button",class:`pc-btn${n.propTab===a?" on":""}`,title:l,text:c,onClick:()=>{n.propTab=a,n.propCollapsed=!1,e.repaint()}}))])]);const i=r?n.propTab==="custom"&&!o?"element":n.propTab:"page";return h("div",{class:"property-panel"},[h("div",{class:"prop-head"},[h("span",{class:"prop-title",text:"属性台"}),h("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{n.propCollapsed=!0,e.repaint()}})]),h("div",{class:"pd-tabs prop-tabs"},[h("div",{class:"pd-tab-bar",role:"tablist"},[...o?[h("button",{type:"button",class:`pd-tab${i==="custom"?" active":""}`,text:o.label,onClick:()=>{n.propTab="custom",e.repaint()}})]:[],h("button",{type:"button",class:`pd-tab${i==="element"?" active":""}`,text:"元素属性",onClick:()=>{n.propTab="element",e.repaint()}}),h("button",{type:"button",class:`pd-tab${i==="page"?" active":""}`,text:"页面属性",onClick:()=>{n.propTab="page",e.repaint()}})]),o&&r?B2(e,r,o):"",h("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:element"},style:i==="element"?"":{display:"none"}},r?[m2(e),N2(e,r)]:[h("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),h("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:page"},style:i==="page"?"":{display:"none"}},[L2(e)])].filter(Boolean))])}var H2={Check:'<path d="M20 6 9 17l-5-5" />',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" />'};function U2(e,t=16){return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${H2[e]??""}</svg>`}function Vi(e){const t=typeof e=="string"?e.trim().toLowerCase():"";return t==="label"||t==="key"||t==="both"?t:"both"}var Ol=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Xh={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},q2=[{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()"}],W2=[{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()"}],j2=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],G2=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],V2=[{title:"聚合函数",items:q2},{title:"数值运算",items:W2},{title:"格式化函数",items:j2}],Y2="(输入表达式后预览)",K2="(无法计算)",Il="(表达式错误)";function Zh(e,t){if(!e.trim())return Y2;try{const n={...gt,...t??{},...Oo()},r=Wn(e,n);return r==null?K2:String(r)}catch{return Il}}function Jh(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)||r.name.toLowerCase().includes(n)):e}function X2(e,t){const n=e.substring(0,t),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}}var Z2=e=>/[\u4e00-\u9fff]/.test(e),J2=e=>`字段「${e}」含中文,请用 {${e}} 引用(函数参数内写 ${e});中文可直接在 {} 中使用,无需 data['...'] 方括号`;function Q2(e,t){const n=/^\{\s*([^{}]+?)\s*\}$/.exec(e.trim());if(!n)return null;const r=n[1]??"";return t.find(o=>o.fieldKey===r)??null}function Pl(e,t,n="both"){return n==="label"?h("div",{class:"ee-field-info"},[h("span",{class:"ee-item-label",text:e})]):n==="key"?h("div",{class:"ee-field-info"},[h("span",{class:"ee-item-key is-primary",text:t})]):h("div",{class:"ee-field-info"},[h("span",{class:"ee-item-label",text:e}),h("span",{class:"ee-item-key",text:t})])}function $t(e){return e.currentTarget.getRootNode()}function Yi(e,t,n){const r=[];return n.forEach((o,i)=>{r.push(o),i<n.length-1&&r.push(h("br"))}),h("div",{class:`ee-help-card ${e}`},[h("div",{class:"ee-help-card-title",text:t}),h("div",{class:"ee-help-card-content"},r)])}function eE(){return h("div",{class:"ee-help-section"},[h("div",{class:"ee-help-title",text:"帮助信息"}),h("div",{class:"ee-help-grid"},[Yi("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","中文 key 直接写 {字段名},如 {姓名}、{supplier.名称}","注意:只能嵌套一层"]),Yi("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Yi("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Yi("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function tE(e,t){const n=Vi(e.fieldDisplay),r={activeTab:"field",searchText:"",expression:t.value||"",binding:t.binding,copiedFieldKey:"",keyHint:""},o=(v,w)=>v.querySelector(w),i=v=>{const w=o(v,".ee-preview");if(!w)return;const E=Zh(r.expression,e.demoData);w.textContent=E,w.classList.toggle("ee-preview-error",E===Il)},a=v=>{const w=o(v,".ee-key-hint");w&&(w.textContent=r.keyHint,w.style.display=r.keyHint?"":"none")},l=()=>{if(r.activeTab==="variable")return Jh(G2,r.searchText).map(E=>h("div",{class:"ee-list-item",onDblclick:T=>{const{insideParens:P}=d(T);p($t(T),P?E.template.replace(/^\{|\}$/g,""):E.template,void 0,"")}},[Pl(E.label,E.template)]));if(r.activeTab==="function")return V2.map(E=>h("div",{class:"ee-func-group"},[h("div",{class:"ee-func-group-title",text:E.title}),...Jh(E.items,r.searchText).map(T=>h("div",{class:"ee-list-item",onDblclick:P=>{const{insideBlock:O}=d(P),I=O?T.template:`{${T.template}}`;p($t(P),I,I.indexOf("(")+1,"")}},[Pl(T.label,`${T.name}()`)]))]));const v=F1(Cu(e.fields??[]),r.searchText);if(!v.length)return[h("p",{class:"pd-empty",text:"暂无字段"})];const w=[];for(const E of v){E.key&&w.push(h("div",{class:`ee-field-group${E.isList?" is-list":""}`},[h("span",{class:"ee-field-group-icon",text:E.isList?"📋":"📁"}),h("span",{text:E.label})]));for(const T of E.fields)w.push(h("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:E.key?"22px":"10px"},onDblclick:P=>{const{insideParens:O}=d(P),I=P;if(I.ctrlKey||I.metaKey){const A=T.fieldLabel||T.fieldKey;p($t(P),O?`"${A}"`:A,void 0,"");return}p($t(P),O?T.fieldKey:`{${T.fieldKey}}`,void 0,Z2(T.fieldKey)?J2(T.fieldKey):"")}},[Pl(T.fieldLabel||T.fieldKey,T.fieldKey,n),h("button",{type:"button",class:`ee-copy-btn${r.copiedFieldKey===T.fieldKey?" is-copied":""}`,"data-tip":r.copiedFieldKey===T.fieldKey?"已复制":`复制字段名「${T.fieldLabel}」`,"aria-label":`复制字段名 ${T.fieldLabel}`,html:U2(r.copiedFieldKey===T.fieldKey?"Check":"Copy",13),onClick:P=>{P.stopPropagation(),s(P,T)},onDblclick:P=>P.stopPropagation()})]))}return w},c=v=>{Array.from(v.querySelectorAll(".ee-nav-tab")).forEach((O,I)=>O.classList.toggle("active",Ol[I]?.key===r.activeTab));const E=o(v,".ee-content-search .pd-input");if(E){const O=Xh[r.activeTab];E.placeholder!==O&&(E.placeholder=O),E.value!==r.searchText&&(E.value=r.searchText)}const T=o(v,".ee-textarea");T&&T.value!==r.expression&&(T.value=r.expression);const P=o(v,".ee-content-list");if(P){kf(P);for(const O of l())Ze(O,P)}i(v),a(v)};function s(v,w){const E=$t(v);ku(w.fieldLabel||w.fieldKey).then(T=>{T&&(r.copiedFieldKey=w.fieldKey,c(E),setTimeout(()=>{r.copiedFieldKey===w.fieldKey&&(r.copiedFieldKey="",c(E))},1200))})}const d=v=>{const E=o($t(v),".ee-textarea")?.selectionStart??r.expression.length;return X2(r.expression,E)},p=(v,w,E=w.length,T)=>{T!==void 0&&(r.keyHint=T);const P=o(v,".ee-textarea");if(!P){r.expression+=w,i(v),a(v);return}const O=P.selectionStart??r.expression.length,I=P.selectionEnd??O;r.expression=r.expression.substring(0,O)+w+r.expression.substring(I);const A=O+E;P.value=r.expression,P.focus(),P.selectionStart=P.selectionEnd=A,i(v),a(v)},u=()=>{const v=r.expression;if(r.binding===void 0){e.onApply({formatter:v}),e.onClose();return}const w=Q2(v,e.fields??[]);e.onApply(w?{formatter:v,binding:w.fieldKey,title:w.fieldLabel}:{formatter:v}),e.onClose()},f=h("div",{class:"ee-nav"},[h("div",{class:"ee-nav-title",text:"类型"}),h("div",{class:"ee-nav-tabs"},Ol.map((v,w)=>h("div",{class:`ee-nav-tab${r.activeTab===v.key?" active":""}`,text:v.text,onClick:E=>{r.activeTab=Ol[w].key,c($t(E))}})))]),g=h("div",{class:"ee-content"},[h("div",{class:"ee-content-search"},[h("input",{class:"pd-input",placeholder:Xh[r.activeTab],onInput:v=>{r.searchText=v.target.value,c($t(v))}})]),h("div",{class:"ee-content-list"},l())]),m=Zh(r.expression,e.demoData),y=h("div",{class:"ee-editor"},[h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"表达式编辑"}),h("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:r.expression,onInput:v=>{r.expression=v.target.value,r.keyHint="",i($t(v)),a($t(v))}}),h("div",{class:"pd-hint ee-key-hint",style:{display:"none",color:"var(--pd-accent, #165DFF)"},text:""})]),h("div",{class:"ee-editor-section"},[h("div",{class:"ee-editor-title",text:"预览结果"}),h("div",{class:`ee-preview${m===Il?" ee-preview-error":""}`,text:m})]),eE()]);return h("div",{class:"pd-dialog-overlay",onKeydown:v=>{v.key==="Escape"&&e.onClose()}},[h("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[h("header",{class:"pd-dialog-header"},[h("strong",{id:"expression-editor-title",text:"编辑表达式"}),h("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"expression-editor"},[f,g,y]),h("footer",{class:"pd-dialog-footer"},[h("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>e.onClose()}),h("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>u()})])])])}const Ki=[{id:"getting-started",title:"快速入门",content:`
273
273
  <h2>界面布局</h2>
274
274
  <p>打印模板设计器采用三栏布局:</p>
275
275
  <ul>
@@ -733,6 +733,18 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
733
733
  <p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
734
734
  </blockquote>
735
735
  `},{id:"changelog",title:"更新记录",content:`
736
+ <h2>V1.6.0<small>(2026-11-19)</small></h2>
737
+
738
+ <h3>新增</h3>
739
+ <ul>
740
+ <li><strong>字段显示可由宿主配置</strong>:新增 <code>field-display</code> 参数(属性名 <code>fieldDisplay</code>),可选「只显示中文名」「只显示字段 key」「两者都显示」,默认两者都显示。只显示 key 时,key 的字号、颜色与字族与中文名一致;字段分组名始终显示,搜索、复制与插入语义不变。</li>
741
+ </ul>
742
+
743
+ <h3>修复</h3>
744
+ <ul>
745
+ <li><strong>图表数据标签偏移</strong>:面板写入 ECharts 原生 <code>offset: [x, y]</code>,旧模板的 <code>offsetX</code> / <code>offsetY</code> 在读取、写回与出图前统一迁移,数据标签偏移现在真正生效。</li>
746
+ </ul>
747
+
736
748
  <h2>V1.5.3<small>(2026-11-18)</small></h2>
737
749
 
738
750
  <h3>新增</h3>
@@ -1193,9 +1205,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1193
1205
  <blockquote>
1194
1206
  <p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
1195
1207
  </blockquote>
1196
- `}],Jh="worm-print-help-tab",Q2="getting-started";function Qh(e){return Yi.some(t=>t.id===e)?String(e):""}function eE(e){let t=null;try{t=window.localStorage.getItem(Jh)}catch{t=null}return Qh(e)||Qh(t)||Q2}function tE(e){const t=eE(e.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=Yi.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(Jh,o)}catch{}};return h("div",{class:"help-modal-overlay",tabindex:"-1",onClick:r=>{r.target===r.currentTarget&&e.onClose()},onKeydown:r=>{r.key==="Escape"&&e.onClose()}},[h("div",{class:"help-modal"},[h("div",{class:"help-modal-header"},[h("div",{class:"help-modal-title-wrap"},[h("h2",{class:"help-modal-title",text:"帮助文档"}),h("span",{class:"help-modal-project",text:"worm-print-platform"})]),h("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"help-modal-body"},[h("div",{class:"help-modal-sidebar"},Yi.map(r=>h("button",{type:"button",class:`help-tab${r.id===t?" active":""}`,text:r.title,onClick:o=>n(o,r.id)}))),h("div",{class:"help-modal-content"},[h("div",{class:"help-content",html:Yi.find(r=>r.id===t)?.content??""})])])])])}function nE(e,t){const n=Ze(tE(t),e),r=o=>{o.key==="Escape"&&t.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const rE=2,oE=74,Rl=[{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 iE(e){const t=!!e.state.openMore,n=Rl.slice().sort((r,o)=>r.order-o.order).map(r=>h("div",{class:"tb-more-item",dataset:{unit:r.id},style:{display:"none"}},[h("div",{class:"tb-menu-label",text:r.label}),h("div",{class:"tb-more-slot",id:`tb-more-slot-${r.id}`,dataset:{unit:r.id}})]));return h("div",{class:"tb-group tb-more-group",style:{display:"none"}},[h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${t?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{e.state.openMore=!t,e.repaint()},html:`${Re("Ellipsis",15)}<span class="tb-btn-text">更多</span>${Re("ChevronDown",12,"tb-dd-arrow")}`}),h("div",{class:`tb-dd-panel tb-more-panel${t?"":" is-hidden"}`},[h("div",{class:"tb-menu tb-more-menu"},n)])])])}const eg=new WeakMap;function tg(e){const t=e.querySelector(".designer-toolbar");if(!t)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(t),r=Number.parseFloat(n.gap)||rE,o=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=new Map;for(const m of Array.from(t.querySelectorAll(".tb-ou[data-unit]"))){const b=m.parentElement;b&&!b.classList.contains("tb-more-slot")&&eg.set(m,{parent:b,next:m.nextSibling}),a.set(m.dataset.unit,m)}for(const m of a.values()){const b=eg.get(m);!b||m.parentElement===b.parent||(b.next?.parentElement===b.parent?b.parent.insertBefore(m,b.next):b.parent.appendChild(m))}let l=0;for(const m of Array.from(t.children)){if(m.classList.contains("tb-spacer")||m.classList.contains("tb-more-group"))continue;const b=Math.max(m.offsetWidth,m.scrollWidth);b<=0||(l+=b+r)}const c=new Map;for(const[m,b]of a){const v=b.offsetWidth;v>0&&c.set(m,v)}const s=Rl.map(m=>({id:m.id,order:m.order,width:c.get(m.id)??0})),d=s.reduce((m,b)=>m-b.width-r,l),p=t.clientWidth-o-i,{movedIds:u,overflowRemains:f}=Kc({available:p,pinned:d,moreTriggerWidth:oE,gap:r,units:s});for(const m of Rl){const b=t.querySelector(`.tb-more-item[data-unit="${m.id}"]`),v=t.querySelector(`#tb-more-slot-${m.id}`),w=a.get(m.id);if(!b||!v||!w)continue;const E=u.includes(m.id);E&&w.parentElement!==v&&v.appendChild(w),b.style.display=E?"":"none"}const g=t.querySelector(".tb-more-group");return g&&(g.style.display=u.length>0?"":"none"),t.classList.toggle("is-tight",f),{movedIds:u,overflowRemains:f}}function aE(e,t){const n=e.store,r=n.selectedIds.size>0,o=n.selectedIds.size>1,i=n.selectedElement,a=!r,l=e.isEdit?"编辑模板":"新建模板",c=[h("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[h("div",{class:"tb-menu-label",text:"对齐 / 分布"}),h("div",{class:"tb-menu-grid"},[_e(e,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),_e(e,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),_e(e,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),_e(e,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),_e(e,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),_e(e,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),_e(e,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),_e(e,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),h("div",{class:"tb-menu-label",text:"层级"}),h("div",{class:"tb-menu-grid"},[_e(e,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),_e(e,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),_e(e,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),_e(e,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),h("div",{class:"tb-menu-label",text:"组合"}),h("div",{class:"tb-menu-grid"},[_e(e,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),_e(e,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!i?.options?.groupId})])])],s=[h("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,g){return h("button",{type:"button",class:`tb-btn tb-menu-row${u?" on":""}`,dataset:{tip:g},onClick:()=>e.fire(f)},[h("span",{class:"dot"}),p])}return h("div",{class:"designer-toolbar"},[h("div",{class:"tb-group tb-brand"},[h("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>'}),h("div",{class:"tb-title"},[h("span",{class:"tb-title-name",text:l}),h("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),h("div",{class:"tb-group"},[_e(e,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),_e(e,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),t,h("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[Ui(e,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),Ui(e,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),h("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[_e(e,"Maximize","fit-window",{tip:"适应窗口"}),_e(e,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),h("span",{class:"tb-zoom",text:`${n.scale}%`}),_e(e,"ZoomIn","zoom",{arg:10,tip:"放大"})]),h("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[_e(e,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),_e(e,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),_e(e,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),iE(e),h("div",{class:"tb-spacer"}),e.showHelp?h("div",{class:"tb-group"},[h("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>e.fire("help")},[h("span",{class:"help-icon",text:"?"})])]):"",(()=>{const p=[e.showPreview!==!1?h("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>e.fire("preview")}):"",e.showSave!==!1?h("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>e.fire("save")}):""].filter(Boolean);return p.length?h("div",{class:"tb-group"},p):""})()].filter(Boolean))}function Dl(e,t,n){for(const r of t){const o=e.getPropertyValue(r).trim();if(o)return o}return n}function sE(e,t){const n=t.orientation==="horizontal",r=t.geom,o=n?r.viewW:r.viewH;e.style.width=`${n?o:Pa}px`,e.style.height=`${n?Pa:o}px`;const i=e.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=Pa;e.width=(n?l:c)*a,e.height=(n?c:l)*a,i.setTransform(a,0,0,a,0,0);const s=getComputedStyle(e),d=Dl(s,["--pd-ruler-bg"],"#F8F9FC"),p=Dl(s,["--pd-ruler"],"#9AA1AF"),u=Dl(s,["--pd-ruler-cursor","--pd-accent"],"#165DFF");i.fillStyle=d,i.fillRect(0,0,n?l:c,n?c:l);const f=t.scale>0?t.scale:r.paperScale>0?r.paperScale:1,g=un(1)*f;if(g<=0)return;const m={ctx:i,horizontal:n,viewportPx:o,thickness:c,originPx:n?r.originX:r.originY,pxPerMM:g,paperLengthMM:t.paperLengthMM},b=-m.originPx/g,v=(l-m.originPx)/g,w=p0(f),E=g0(b,v,w);rg(m,E,p,!0),rg(m,E,p,!1),og(m,0,u),og(m,t.paperLengthMM,u);const k=t.cursorPx??null;if(k!==null&&k>=0&&k<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const L=Math.round(k)+.5;i.moveTo(L,0),i.lineTo(L,c)}else{const L=Math.round(k)+.5;i.moveTo(0,L),i.lineTo(c,L)}i.stroke()}}function ng(e,t){return Math.round(e.originPx+t*e.pxPerMM)+.5}function rg(e,t,n,r){const{ctx:o,horizontal:i,paperLengthMM:a}=e;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 t){if((l.mm<0||l.mm>a)!==r)continue;const s=ng(e,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 og(e,t,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=e,l=ng(e,t);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 lE=':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);--pd-success: #16a34a;--pd-text-regular: #606266;--pd-fill-light: #f5f7fa;height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:248px;min-width:248px;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}.material-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-content:start}.material-grid>.panel-title,.material-grid>.material-group-title,.material-grid>.material-card--wide{grid-column:1 / -1}.material-grid>.panel-title,.material-grid>.material-group-title{margin-bottom:0}.material-grid>.material-card{margin-bottom:0;min-width:0}.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-group-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:4px 2px 6px;margin:2px 0 8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{position:relative;display:flex;align-items:center;gap:9px;padding:7px 8px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:7px;background:transparent;cursor:grab;-webkit-user-select:none;user-select:none;transition:background .16s ease,border-color .16s ease,transform .16s ease,box-shadow .16s ease}.material-card:before{content:"";position:absolute;left:0;top:50%;width:2px;height:0;border-radius:2px;background:var(--pd-accent, #165DFF);transform:translateY(-50%);transition:height .16s ease}.material-card:hover{background:var(--pd-hover-tint, #ecf5ff);border-color:#165dff73;transform:translate(2px)}.material-card:hover:before{height:56%}.material-card:active{cursor:grabbing;transform:translate(2px) scale(.985)}.material-icon{width:30px;height:30px;border:0;border-radius:7px;display:flex;align-items:center;justify-content:center;color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));box-shadow:inset 0 0 0 1px #165dff1f;flex-shrink:0;transition:background .16s ease,color .16s ease,box-shadow .16s ease,transform .16s ease}.material-card:hover .material-icon{background:var(--pd-accent, #165DFF);color:#fff;box-shadow:0 2px 6px #165dff47}.material-card:active .material-icon{transform:scale(.92)}.material-label{min-width:0;flex:1;font-size:12.5px;font-weight:500;line-height:1.3;color:var(--pd-text, #2a2e37);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:color .16s ease}.material-card:hover .material-label{color:var(--pd-accent, #165DFF)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.extension-placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;box-sizing:border-box;padding:2px;font-size:11px;line-height:1.4;text-align:center;color:var(--pd-text-muted, #8b909c);background:repeating-linear-gradient(45deg,#f4f6fa,#f4f6fa 6px,#fff 6px 12px);overflow:hidden}.element-margin-guide{position:absolute;box-sizing:border-box;pointer-events:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.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,.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.margin-grid{margin-top:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.group-help{flex:0 0 auto;width:18px;height:18px;margin-right:6px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:18px;cursor:pointer}.group-help:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.group-help:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}.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{display:flex;gap:8px}.merge-card{margin-top:8px;padding:8px;border:1px solid var(--pd-border, #dcdfe6);border-radius:6px}.merge-card-title{font-size:12px;font-weight:600;color:var(--pd-text, #303133);margin-bottom:8px}.merge-card-divider{height:1px;background:var(--pd-menu-divider, #ebeef5);margin:8px 0}.merge-card-hint{margin-top:6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #8b909c)}.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:304px;min-width:304px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-version{font-variant-numeric:tabular-nums;color:var(--pd-text-muted, #8b909c)}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);--pd-success: #16a34a;--pd-text-regular: #606266;--pd-fill-light: #f5f7fa;height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Ki=20;function ig(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return t}catch{}}const cE=".page-tabs, .field-tree-panel, .pd-dialog-overlay",dE=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),ag="print-studio:left",sg="print-studio:right";function lg(e){try{return localStorage.getItem(e)==="1"}catch{return!1}}function cg(e,t){try{localStorage.setItem(e,t?"1":"0")}catch{}}function $l(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return}if(Array.isArray(t))return t.filter(n=>!!n&&typeof n=="object"&&!Array.isArray(n));if(t&&typeof t=="object")return[t]}class Gt extends HTMLElement{root;store;format;unsub=null;unsubPluginUI=null;unsubDefinitions=null;pluginStyleEls=new Map;instanceDisposers=[];measureRaf=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;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};paneScroll=new Map;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;helpInitialTab;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";_theme="auto";_themeConfig;systemDark=!1;themeMedia=null;onThemeMediaChange=()=>{this.systemDark=this.themeMedia?.matches??!1,this.applyTheme()};appliedThemeTokens=[];uploadImage;uploadDesignBackground;_designData;set designData(t){this._designData=$l(t),this.repaint()}get designData(){return this._designData}_fonts;set fonts(t){this._fonts=t,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=lE,this.root.appendChild(t),Ze(h("div",{class:"designer-container",dataset:{test:"designer-container"},part:"container"}),this.root)}set template(t){this.applyTemplate(t)}get template(){return this.store?.getTemplateJson()}set fields(t){this.store.fields=(typeof t=="string"?JSON.parse(t):t)??[],this.repaint()}set isEdit(t){this.setAttribute("is-edit",String(t)),this.repaint()}set showHelp(t){this.setAttribute("show-help",String(t)),t||this.closeHelp(),this.repaint()}set showPreview(t){this.setAttribute("show-preview",String(t)),this.repaint()}set showSave(t){this.setAttribute("show-save",String(t)),this.repaint()}set theme(t){const n=t==="dark"||t==="light"?t:"auto";this._theme=n,this.setAttribute("theme",n),this.applyTheme()}get theme(){return this._theme}set themeConfig(t){const n=typeof t=="string"?ig(t):t;this._themeConfig=n,n===void 0?this.removeAttribute("theme-config"):this.setAttribute("theme-config",JSON.stringify(n)),this.applyTheme()}get themeConfig(){return this._themeConfig}static contractVersion=Vs;static getHostContract(){return Xs()}getHostContract(){return Xs()}static get observedAttributes(){return[...Ys]}attributeChangedCallback(t,n,r){if(t==="design-data"){this._designData=r===null?void 0:$l(r),this.repaint();return}if(t==="theme"){this._theme=r==="dark"||r==="light"?r:"auto",this.applyTheme();return}if(t==="theme-config"){this._themeConfig=r?ig(r):void 0,this.applyTheme();return}if(!r)return;if(t==="name"){this.repaint();return}let o;try{o=JSON.parse(r)}catch{return}t==="template"?this.applyTemplate(o):t==="fields"?(this.store.fields=o,this.repaint()):t==="fonts"&&Array.isArray(o)&&(this.fonts=o)}connectedCallback(){if(this.attachThemeMedia(),this.applyTheme(),this.store){this.applyFontFace(),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners();return}const t={},n=this.getAttribute("template");if(n)try{t.initialTemplate=JSON.parse(n)}catch{}const r=this.getAttribute("fields");if(r)try{t.initialFields=JSON.parse(r)}catch{}const o=this.getAttribute("design-data");o&&this._designData===void 0&&(this._designData=$l(o)),this.store=new Of(t),this.format=new Cv(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners(),this.applyFontFace(),this.repaint(),this.measureRaf=requestAnimationFrame(()=>{this.measureRaf=null,this.measureRuler()})}attachThemeMedia(){typeof window>"u"||typeof window.matchMedia!="function"||(this.detachThemeMedia(),this.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),this.systemDark=this.themeMedia.matches,this.themeMedia.addEventListener("change",this.onThemeMediaChange))}detachThemeMedia(){this.themeMedia?.removeEventListener("change",this.onThemeMediaChange),this.themeMedia=null}applyTheme(){const t=this.root.querySelector(".designer-container");if(!t)return;for(const o of this.appliedThemeTokens)t.style.removeProperty(o);if(this.appliedThemeTokens=[],(this._theme==="dark"||this._theme==="light"?this._theme:this.systemDark?"dark":"light")==="dark")for(const[o,i]of Object.entries(Nv))i!==void 0&&(t.style.setProperty(o,i),this.appliedThemeTokens.push(o));const r=this._themeConfig?.overrides;if(r)for(const[o,i]of Object.entries(r))!o.startsWith("--pd-")||typeof i!="string"||(t.style.setProperty(o,i),this.appliedThemeTokens.includes(o)||this.appliedThemeTokens.push(o))}readChrome(){this.state.leftCollapsed=lg(ag),this.state.propCollapsed=lg(sg),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const t=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;t!==this.chromeKey&&(this.chromeKey=t,cg(ag,this.state.leftCollapsed),cg(sg,this.state.propCollapsed))}disconnectedCallback(){this.detachThemeMedia(),this.unsub?.(),this.unsub=null,this.unsubPluginUI?.(),this.unsubPluginUI=null,this.unsubDefinitions?.(),this.unsubDefinitions=null,gh(),this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Gt.active===this&&(Gt.active=null),kh(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null);for(const t of this.instanceDisposers)t();this.instanceDisposers=[],this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null,this.measureRaf!==null&&(cancelAnimationFrame(this.measureRaf),this.measureRaf=null)}applyFontFace(){const t=Mr(this._fonts);if(!t){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=t,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=t}attachPluginUI(){this.unsubPluginUI||(this.unsubPluginUI=vv(()=>this.repaint())),this.unsubDefinitions||(this.unsubDefinitions=$f(()=>this.repaint()))}syncPluginUIStyles(){const t=new Map;for(const{type:n,ui:r}of yv())r.styles&&t.set(n,r.styles);for(const[n,r]of[...this.pluginStyleEls])t.has(n)||(r.remove(),this.pluginStyleEls.delete(n));for(const[n,r]of t){let o=this.pluginStyleEls.get(n);o||(o=document.createElement("style"),o.setAttribute("data-plugin-ui",n),this.root.appendChild(o),this.pluginStyleEls.set(n,o)),o.textContent!==r&&(o.textContent=r)}}templateJsonWithFonts(){const t=JSON.parse(this.store.getTemplateJson()),n=this.fonts;if(!n?.length)return t;if(Array.isArray(t.pages)){const r=t;return{...r,pages:r.pages.map(o=>({...o,fonts:[...n]}))}}return{...t,fonts:[...n]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(t){this.applyTemplate(t)}save(){const t=this.validateTemplate();if(t.length){window.alert(t[0].message),this.state.propTab="page",this.repaint();return}const n=this.templateJsonWithFonts();if(Array.isArray(n.pages))try{ls(n)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const r=this.getGeometryWarnings();if(r.length&&!window.confirm(`出纸提示:部分内容超出纸面,打印时会被裁切。
1208
+ `}],Qh="worm-print-help-tab",nE="getting-started";function eg(e){return Ki.some(t=>t.id===e)?String(e):""}function rE(e){let t=null;try{t=window.localStorage.getItem(Qh)}catch{t=null}return eg(e)||eg(t)||nE}function oE(e){const t=rE(e.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=Ki.find(c=>c.id===o)?.content??"");try{window.localStorage.setItem(Qh,o)}catch{}};return h("div",{class:"help-modal-overlay",tabindex:"-1",onClick:r=>{r.target===r.currentTarget&&e.onClose()},onKeydown:r=>{r.key==="Escape"&&e.onClose()}},[h("div",{class:"help-modal"},[h("div",{class:"help-modal-header"},[h("div",{class:"help-modal-title-wrap"},[h("h2",{class:"help-modal-title",text:"帮助文档"}),h("span",{class:"help-modal-project",text:"worm-print-platform"})]),h("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>e.onClose()})]),h("div",{class:"help-modal-body"},[h("div",{class:"help-modal-sidebar"},Ki.map(r=>h("button",{type:"button",class:`help-tab${r.id===t?" active":""}`,text:r.title,onClick:o=>n(o,r.id)}))),h("div",{class:"help-modal-content"},[h("div",{class:"help-content",html:Ki.find(r=>r.id===t)?.content??""})])])])])}function iE(e,t){const n=Ze(oE(t),e),r=o=>{o.key==="Escape"&&t.onClose()};return document.addEventListener("keydown",r),n.focus?.(),()=>{document.removeEventListener("keydown",r),n.remove()}}const aE=2,sE=74,Rl=[{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 lE(e){const t=!!e.state.openMore,n=Rl.slice().sort((r,o)=>r.order-o.order).map(r=>h("div",{class:"tb-more-item",dataset:{unit:r.id},style:{display:"none"}},[h("div",{class:"tb-menu-label",text:r.label}),h("div",{class:"tb-more-slot",id:`tb-more-slot-${r.id}`,dataset:{unit:r.id}})]));return h("div",{class:"tb-group tb-more-group",style:{display:"none"}},[h("div",{class:"tb-dd"},[h("button",{type:"button",class:`tb-dd-trigger${t?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{e.state.openMore=!t,e.repaint()},html:`${ze("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ze("ChevronDown",12,"tb-dd-arrow")}`}),h("div",{class:`tb-dd-panel tb-more-panel${t?"":" is-hidden"}`},[h("div",{class:"tb-menu tb-more-menu"},n)])])])}const tg=new WeakMap;function ng(e){const t=e.querySelector(".designer-toolbar");if(!t)return{movedIds:[],overflowRemains:!1};const n=getComputedStyle(t),r=Number.parseFloat(n.gap)||aE,o=Number.parseFloat(n.paddingLeft)||0,i=Number.parseFloat(n.paddingRight)||0,a=new Map;for(const m of Array.from(t.querySelectorAll(".tb-ou[data-unit]"))){const y=m.parentElement;y&&!y.classList.contains("tb-more-slot")&&tg.set(m,{parent:y,next:m.nextSibling}),a.set(m.dataset.unit,m)}for(const m of a.values()){const y=tg.get(m);!y||m.parentElement===y.parent||(y.next?.parentElement===y.parent?y.parent.insertBefore(m,y.next):y.parent.appendChild(m))}let l=0;for(const m of Array.from(t.children)){if(m.classList.contains("tb-spacer")||m.classList.contains("tb-more-group"))continue;const y=Math.max(m.offsetWidth,m.scrollWidth);y<=0||(l+=y+r)}const c=new Map;for(const[m,y]of a){const v=y.offsetWidth;v>0&&c.set(m,v)}const s=Rl.map(m=>({id:m.id,order:m.order,width:c.get(m.id)??0})),d=s.reduce((m,y)=>m-y.width-r,l),p=t.clientWidth-o-i,{movedIds:u,overflowRemains:f}=Xc({available:p,pinned:d,moreTriggerWidth:sE,gap:r,units:s});for(const m of Rl){const y=t.querySelector(`.tb-more-item[data-unit="${m.id}"]`),v=t.querySelector(`#tb-more-slot-${m.id}`),w=a.get(m.id);if(!y||!v||!w)continue;const E=u.includes(m.id);E&&w.parentElement!==v&&v.appendChild(w),y.style.display=E?"":"none"}const g=t.querySelector(".tb-more-group");return g&&(g.style.display=u.length>0?"":"none"),t.classList.toggle("is-tight",f),{movedIds:u,overflowRemains:f}}function cE(e,t){const n=e.store,r=n.selectedIds.size>0,o=n.selectedIds.size>1,i=n.selectedElement,a=!r,l=e.isEdit?"编辑模板":"新建模板",c=[h("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[h("div",{class:"tb-menu-label",text:"对齐 / 分布"}),h("div",{class:"tb-menu-grid"},[_e(e,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!o}),_e(e,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!o}),_e(e,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!o}),_e(e,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!o}),_e(e,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!o}),_e(e,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!o}),_e(e,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!o}),_e(e,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!o})]),h("div",{class:"tb-menu-label",text:"层级"}),h("div",{class:"tb-menu-grid"},[_e(e,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!r}),_e(e,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!r}),_e(e,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!r}),_e(e,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!r})]),h("div",{class:"tb-menu-label",text:"组合"}),h("div",{class:"tb-menu-grid"},[_e(e,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!o}),_e(e,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!i?.options?.groupId})])])],s=[h("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,g){return h("button",{type:"button",class:`tb-btn tb-menu-row${u?" on":""}`,dataset:{tip:g},onClick:()=>e.fire(f)},[h("span",{class:"dot"}),p])}return h("div",{class:"designer-toolbar"},[h("div",{class:"tb-group tb-brand"},[h("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>'}),h("div",{class:"tb-title"},[h("span",{class:"tb-title-name",text:l}),h("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),h("div",{class:"tb-group"},[_e(e,"Undo2","undo",{tip:"撤销",disabled:!n.canUndo}),_e(e,"Redo2","redo",{tip:"重做",disabled:!n.canRedo})]),t,h("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[Ui(e,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),Ui(e,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},s)]),h("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[_e(e,"Maximize","fit-window",{tip:"适应窗口"}),_e(e,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),h("span",{class:"tb-zoom",text:`${n.scale}%`}),_e(e,"ZoomIn","zoom",{arg:10,tip:"放大"})]),h("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[_e(e,"Copy","copy",{tip:a?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:a,test:"copy"}),_e(e,"ClipboardPaste","paste",{tip:a?"粘贴 (Ctrl+V),需选中元素":n.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:a||!n.hasClipboard,test:"paste"}),_e(e,"Trash2","delete",{tip:a?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:a,danger:!0,test:"delete"})]),lE(e),h("div",{class:"tb-spacer"}),e.showHelp?h("div",{class:"tb-group"},[h("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>e.fire("help")},[h("span",{class:"help-icon",text:"?"})])]):"",(()=>{const p=[e.showPreview!==!1?h("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>e.fire("preview")}):"",e.showSave!==!1?h("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>e.fire("save")}):""].filter(Boolean);return p.length?h("div",{class:"tb-group"},p):""})()].filter(Boolean))}function Fl(e,t,n){for(const r of t){const o=e.getPropertyValue(r).trim();if(o)return o}return n}function dE(e,t){const n=t.orientation==="horizontal",r=t.geom,o=n?r.viewW:r.viewH;e.style.width=`${n?o:Pa}px`,e.style.height=`${n?Pa:o}px`;const i=e.getContext("2d");if(!i)return;const a=window.devicePixelRatio||1,l=Math.max(0,Math.round(o)),c=Pa;e.width=(n?l:c)*a,e.height=(n?c:l)*a,i.setTransform(a,0,0,a,0,0);const s=getComputedStyle(e),d=Fl(s,["--pd-ruler-bg"],"#F8F9FC"),p=Fl(s,["--pd-ruler"],"#9AA1AF"),u=Fl(s,["--pd-ruler-cursor","--pd-accent"],"#165DFF");i.fillStyle=d,i.fillRect(0,0,n?l:c,n?c:l);const f=t.scale>0?t.scale:r.paperScale>0?r.paperScale:1,g=un(1)*f;if(g<=0)return;const m={ctx:i,horizontal:n,viewportPx:o,thickness:c,originPx:n?r.originX:r.originY,pxPerMM:g,paperLengthMM:t.paperLengthMM},y=-m.originPx/g,v=(l-m.originPx)/g,w=f0(f),E=m0(y,v,w);og(m,E,p,!0),og(m,E,p,!1),ig(m,0,u),ig(m,t.paperLengthMM,u);const T=t.cursorPx??null;if(T!==null&&T>=0&&T<=l){if(i.strokeStyle=u,i.lineWidth=1.5,i.beginPath(),n){const P=Math.round(T)+.5;i.moveTo(P,0),i.lineTo(P,c)}else{const P=Math.round(T)+.5;i.moveTo(0,P),i.lineTo(c,P)}i.stroke()}}function rg(e,t){return Math.round(e.originPx+t*e.pxPerMM)+.5}function og(e,t,n,r){const{ctx:o,horizontal:i,paperLengthMM:a}=e;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 t){if((l.mm<0||l.mm>a)!==r)continue;const s=rg(e,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 ig(e,t,n){const{ctx:r,horizontal:o,thickness:i,viewportPx:a}=e,l=rg(e,t);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 uE=':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);--pd-success: #16a34a;--pd-text-regular: #606266;--pd-fill-light: #f5f7fa;height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.field-row .node-key.is-primary{font-size:13px;color:var(--pd-text, #303133)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:248px;min-width:248px;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}.material-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-content:start}.material-grid>.panel-title,.material-grid>.material-group-title,.material-grid>.material-card--wide{grid-column:1 / -1}.material-grid>.panel-title,.material-grid>.material-group-title{margin-bottom:0}.material-grid>.material-card{margin-bottom:0;min-width:0}.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-group-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:4px 2px 6px;margin:2px 0 8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{position:relative;display:flex;align-items:center;gap:9px;padding:7px 8px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:7px;background:transparent;cursor:grab;-webkit-user-select:none;user-select:none;transition:background .16s ease,border-color .16s ease,transform .16s ease,box-shadow .16s ease}.material-card:before{content:"";position:absolute;left:0;top:50%;width:2px;height:0;border-radius:2px;background:var(--pd-accent, #165DFF);transform:translateY(-50%);transition:height .16s ease}.material-card:hover{background:var(--pd-hover-tint, #ecf5ff);border-color:#165dff73;transform:translate(2px)}.material-card:hover:before{height:56%}.material-card:active{cursor:grabbing;transform:translate(2px) scale(.985)}.material-icon{width:30px;height:30px;border:0;border-radius:7px;display:flex;align-items:center;justify-content:center;color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));box-shadow:inset 0 0 0 1px #165dff1f;flex-shrink:0;transition:background .16s ease,color .16s ease,box-shadow .16s ease,transform .16s ease}.material-card:hover .material-icon{background:var(--pd-accent, #165DFF);color:#fff;box-shadow:0 2px 6px #165dff47}.material-card:active .material-icon{transform:scale(.92)}.material-label{min-width:0;flex:1;font-size:12.5px;font-weight:500;line-height:1.3;color:var(--pd-text, #2a2e37);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:color .16s ease}.material-card:hover .material-label{color:var(--pd-accent, #165DFF)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.extension-placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;box-sizing:border-box;padding:2px;font-size:11px;line-height:1.4;text-align:center;color:var(--pd-text-muted, #8b909c);background:repeating-linear-gradient(45deg,#f4f6fa,#f4f6fa 6px,#fff 6px 12px);overflow:hidden}.element-margin-guide{position:absolute;box-sizing:border-box;pointer-events:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.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,.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.margin-grid{margin-top:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-info .ee-item-key.is-primary{font-size:12px;color:var(--pd-text, #303133);font-family:inherit}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.group-help{flex:0 0 auto;width:18px;height:18px;margin-right:6px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:18px;cursor:pointer}.group-help:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.group-help:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}.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{display:flex;gap:8px}.merge-card{margin-top:8px;padding:8px;border:1px solid var(--pd-border, #dcdfe6);border-radius:6px}.merge-card-title{font-size:12px;font-weight:600;color:var(--pd-text, #303133);margin-bottom:8px}.merge-card-divider{height:1px;background:var(--pd-menu-divider, #ebeef5);margin:8px 0}.merge-card-hint{margin-top:6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #8b909c)}.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:304px;min-width:304px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-version{font-variant-numeric:tabular-nums;color:var(--pd-text-muted, #8b909c)}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);--pd-success: #16a34a;--pd-text-regular: #606266;--pd-fill-light: #f5f7fa;height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Xi=20;function ag(e){try{const t=JSON.parse(e);if(t&&typeof t=="object"&&!Array.isArray(t))return t}catch{}}const pE=".page-tabs, .field-tree-panel, .pd-dialog-overlay",fE=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),sg="print-studio:left",lg="print-studio:right";function cg(e){try{return localStorage.getItem(e)==="1"}catch{return!1}}function dg(e,t){try{localStorage.setItem(e,t?"1":"0")}catch{}}function $l(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return}if(Array.isArray(t))return t.filter(n=>!!n&&typeof n=="object"&&!Array.isArray(n));if(t&&typeof t=="object")return[t]}class Gt extends HTMLElement{root;store;format;unsub=null;unsubPluginUI=null;unsubDefinitions=null;pluginStyleEls=new Map;instanceDisposers=[];measureRaf=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null,fieldDisplay:"both"};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};paneScroll=new Map;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;helpInitialTab;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";_theme="auto";_themeConfig;systemDark=!1;themeMedia=null;onThemeMediaChange=()=>{this.systemDark=this.themeMedia?.matches??!1,this.applyTheme()};appliedThemeTokens=[];uploadImage;uploadDesignBackground;_designData;set designData(t){this._designData=$l(t),this.repaint()}get designData(){return this._designData}_fonts;set fonts(t){this._fonts=t,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const t=document.createElement("style");t.textContent=uE,this.root.appendChild(t),Ze(h("div",{class:"designer-container",dataset:{test:"designer-container"},part:"container"}),this.root)}set template(t){this.applyTemplate(t)}get template(){return this.store?.getTemplateJson()}set fields(t){this.store.fields=(typeof t=="string"?JSON.parse(t):t)??[],this.repaint()}set isEdit(t){this.setAttribute("is-edit",String(t)),this.repaint()}set showHelp(t){this.setAttribute("show-help",String(t)),t||this.closeHelp(),this.repaint()}set showPreview(t){this.setAttribute("show-preview",String(t)),this.repaint()}set showSave(t){this.setAttribute("show-save",String(t)),this.repaint()}set fieldDisplay(t){const n=Vi(t);this.state.fieldDisplay=n,this.getAttribute("field-display")!==n&&this.setAttribute("field-display",n),this.repaint()}get fieldDisplay(){return this.state.fieldDisplay??"both"}set theme(t){const n=t==="dark"||t==="light"?t:"auto";this._theme=n,this.setAttribute("theme",n),this.applyTheme()}get theme(){return this._theme}set themeConfig(t){const n=typeof t=="string"?ag(t):t;this._themeConfig=n,n===void 0?this.removeAttribute("theme-config"):this.setAttribute("theme-config",JSON.stringify(n)),this.applyTheme()}get themeConfig(){return this._themeConfig}static contractVersion=Ys;static getHostContract(){return Zs()}getHostContract(){return Zs()}static get observedAttributes(){return[...Ks]}attributeChangedCallback(t,n,r){if(t==="design-data"){this._designData=r===null?void 0:$l(r),this.repaint();return}if(t==="theme"){this._theme=r==="dark"||r==="light"?r:"auto",this.applyTheme();return}if(t==="theme-config"){this._themeConfig=r?ag(r):void 0,this.applyTheme();return}if(t==="field-display"){this.state.fieldDisplay=Vi(r),this.repaint();return}if(!r)return;if(t==="name"){this.repaint();return}let o;try{o=JSON.parse(r)}catch{return}t==="template"?this.applyTemplate(o):t==="fields"?(this.store.fields=o,this.repaint()):t==="fonts"&&Array.isArray(o)&&(this.fonts=o)}connectedCallback(){if(this.attachThemeMedia(),this.applyTheme(),this.store){this.applyFontFace(),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners();return}const t={},n=this.getAttribute("template");if(n)try{t.initialTemplate=JSON.parse(n)}catch{}const r=this.getAttribute("fields");if(r)try{t.initialFields=JSON.parse(r)}catch{}const o=this.getAttribute("design-data");o&&this._designData===void 0&&(this._designData=$l(o)),this.store=new Of(t),this.format=new Av(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.state.fieldDisplay=Vi(this.getAttribute("field-display")),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners(),this.applyFontFace(),this.repaint(),this.measureRaf=requestAnimationFrame(()=>{this.measureRaf=null,this.measureRuler()})}attachThemeMedia(){typeof window>"u"||typeof window.matchMedia!="function"||(this.detachThemeMedia(),this.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),this.systemDark=this.themeMedia.matches,this.themeMedia.addEventListener("change",this.onThemeMediaChange))}detachThemeMedia(){this.themeMedia?.removeEventListener("change",this.onThemeMediaChange),this.themeMedia=null}applyTheme(){const t=this.root.querySelector(".designer-container");if(!t)return;for(const o of this.appliedThemeTokens)t.style.removeProperty(o);if(this.appliedThemeTokens=[],(this._theme==="dark"||this._theme==="light"?this._theme:this.systemDark?"dark":"light")==="dark")for(const[o,i]of Object.entries(Nv))i!==void 0&&(t.style.setProperty(o,i),this.appliedThemeTokens.push(o));const r=this._themeConfig?.overrides;if(r)for(const[o,i]of Object.entries(r))!o.startsWith("--pd-")||typeof i!="string"||(t.style.setProperty(o,i),this.appliedThemeTokens.includes(o)||this.appliedThemeTokens.push(o))}readChrome(){this.state.leftCollapsed=cg(sg),this.state.propCollapsed=cg(lg),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const t=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;t!==this.chromeKey&&(this.chromeKey=t,dg(sg,this.state.leftCollapsed),dg(lg,this.state.propCollapsed))}disconnectedCallback(){this.detachThemeMedia(),this.unsub?.(),this.unsub=null,this.unsubPluginUI?.(),this.unsubPluginUI=null,this.unsubDefinitions?.(),this.unsubDefinitions=null,mh(),this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Gt.active===this&&(Gt.active=null),kh(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null);for(const t of this.instanceDisposers)t();this.instanceDisposers=[],this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null,this.measureRaf!==null&&(cancelAnimationFrame(this.measureRaf),this.measureRaf=null)}applyFontFace(){const t=Mr(this._fonts);if(!t){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=t,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=t}attachPluginUI(){this.unsubPluginUI||(this.unsubPluginUI=wv(()=>this.repaint())),this.unsubDefinitions||(this.unsubDefinitions=$f(()=>this.repaint()))}syncPluginUIStyles(){const t=new Map;for(const{type:n,ui:r}of vv())r.styles&&t.set(n,r.styles);for(const[n,r]of[...this.pluginStyleEls])t.has(n)||(r.remove(),this.pluginStyleEls.delete(n));for(const[n,r]of t){let o=this.pluginStyleEls.get(n);o||(o=document.createElement("style"),o.setAttribute("data-plugin-ui",n),this.root.appendChild(o),this.pluginStyleEls.set(n,o)),o.textContent!==r&&(o.textContent=r)}}templateJsonWithFonts(){const t=JSON.parse(this.store.getTemplateJson()),n=this.fonts;if(!n?.length)return t;if(Array.isArray(t.pages)){const r=t;return{...r,pages:r.pages.map(o=>({...o,fonts:[...n]}))}}return{...t,fonts:[...n]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(t){this.applyTemplate(t)}save(){const t=this.validateTemplate();if(t.length){window.alert(t[0].message),this.state.propTab="page",this.repaint();return}const n=this.templateJsonWithFonts();if(Array.isArray(n.pages))try{cs(n)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const r=this.getGeometryWarnings();if(r.length&&!window.confirm(`出纸提示:部分内容超出纸面,打印时会被裁切。
1197
1209
  是否接受裁切并继续保存?
1198
1210
  点击“确定”继续保存,点击“取消”返回修改。
1199
1211
 
1200
1212
  ${r.join(`
1201
- `)}`))return;const o=JSON.stringify(n);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent(St.save,{detail:o,bubbles:!0,composed:!0}))}validateTemplate(){const t=this.store.templateData;return t.tiling?.enabled===!0?as(t):[]}getGeometryWarnings(){return d1(this.store.templateData)}applyTemplate(t){if(!t)return;const n=typeof t=="string"?JSON.parse(t):t;this.store?this.store.loadTemplate(n):this.setAttribute("template",JSON.stringify(n))}openExpression(t){this.exprTarget=t,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const t=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){t.forEach(r=>r.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;t.forEach(r=>r.remove());const n=this.exprTarget;Ze(J2({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:r=>this.applyExpression(n,r)},n),this.root),this.exprMountedFor=n}openHelp(t){this.helpInitialTab=t,this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const t=this.helpVisible&&this.getAttribute("show-help")!=="false";if(t&&!this.unmountHelp)this.unmountHelp=nE(this.root,{initialTab:this.helpInitialTab,onClose:()=>this.closeHelp()});else if(!t&&this.unmountHelp){const n=this.unmountHelp;this.unmountHelp=null,n()}}applyExpression(t,n){const r=n.formatter??"",o=t.targetPath;if(o.startsWith("options.")){if(o.includes("[")){const a=this.store.elements.find(l=>l.id===t.elementId);a&&Ml(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(t.elementId,i);return}if(o==="watermark.content"){const i={...this.store.templateData.watermark};Al(r)?Object.assign(i,{mode:"binding",binding:r,content:""}):Object.assign(i,{mode:"fixed",content:r,binding:""}),this.store.updateTemplateData({watermark:i})}}dblEditElement(t){const n=this.store.elements.find(o=>o.id===t);if(!n||(this.store.selectOne(t),this.state.propTab=Gs(n)?"custom":"element",n.options.locked))return;const r=Bf(n.printElementType.type);r&&this.openExpression({elementId:n.id,targetPath:`options.${r}`,value:String(n.options[r]??"")})}dblEditCell(t){const n=this.store.elements.find(l=>l.id===t.elementId);if(!n||(this.store.selectOne(n.id),this.state.propTab="element",n.options.locked))return;const r=n.options.tableRows??[],o=ar(r,t.r,t.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:(t,n)=>this.fire(t,n),showHelp:this.getAttribute("show-help")!=="false",showPreview:this.getAttribute("show-preview")!=="false",showSave:this.getAttribute("show-save")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts,designData:this.designData,fields:this.store.fields}}}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;gh(),this.syncPluginUIStyles();const t=[...this.store.selectedIds].join(",");if(t!==this.lastSelKey){this.lastSelKey=t;const a=this.store.selectedElement;this.state.propTab=a?Gs(a)?"custom":"element":"page"}const n=this.root.querySelector(".designer-container");n.classList.toggle("format-painting",this.format.painterActive);for(const a of n.querySelectorAll("[data-pane]"))a.style.display!=="none"&&this.paneScroll.set(a.dataset.pane,a.scrollTop);kf(n);const r=this.ctx;Ze(aE(r,Zx(r)),n),Ze(o2(r),n),Ze(h("div",{class:"designer-body"},[Qx(r),Px(r,this.canvasUi()),z2(r)]),n),Ze(i2(r),n),tg(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>tg(n)),this.toolbarRo.observe(n));const o=rx(this.store,(a,l)=>this.fire(a,l),this.tableMenu);o&&Ze(o,n),Cw(this.root,this.store.elements,this.designData),qh(this.root,this.state.propSearch),this.applyShrinkFit();const i=this.root.querySelector(".canvas-area");i&&(i.scrollLeft=this.scrollPos.x,i.scrollTop=this.scrollPos.y);for(const a of n.querySelectorAll("[data-pane]")){const l=this.paneScroll.get(a.dataset.pane);l!==void 0&&(a.scrollTop=l)}this.syncRulers(),this.persistChrome(),this.applyHostParts(n)}applyHostParts(t){const n={".designer-toolbar":"toolbar",".format-toolbar":"format-bar",".left-panel":"left-panel",".canvas-area":"canvas-area",".property-panel":"property-panel",".status-bar":"status-bar",".page-tabs":"page-tabs"};for(const[r,o]of Object.entries(n)){const i=t.querySelector(r);i&&Ks.includes(o)&&i.setAttribute("part",o)}}applyShrinkFit(){for(const t of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))_f(t);for(const t of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(t.getAttribute("data-fit")==="shrink")continue;t.removeAttribute("data-fit-size");const n=t.getAttribute("data-fit-base");n?t.style.fontSize=`${n}pt`:t.style.removeProperty("font-size")}}measureRuler(){const t=this.root.querySelector(".canvas-area"),n=this.root.querySelector(".hiprint-printPaper");if(!t||!n)return;const r=t.getBoundingClientRect(),o=n.getBoundingClientRect(),i=(this.store.scale||100)/100,a=o.width/un(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-Ki,originY:o.top-r.top-Ki,viewW:t.clientWidth-Ki,viewH:t.clientHeight-Ki},this.observeCanvasArea()}observeCanvasArea(){const t=this.root.querySelector(".canvas-area");!t||typeof ResizeObserver>"u"||this.roArea===t||(this.roArea=t,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(t))}syncRulers(){this.measureRuler();const t=this.store.templateData,n=Jt(t),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";sE(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 t=this.root.querySelector(".position-label"),n=this.store.selectedElement;t&&n&&!this.drag&&(t.textContent=Rh(n.options))}fire(t,n){const r=this.store;switch(t){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(St.preview,{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent(St.help,{bubbles:!0,composed:!0})),this.openHelp(n);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(St.dblclickElement,{detail:o,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const o=n;this.dblEditCell(o),this.dispatchEvent(new CustomEvent(St.dblclickCell,{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(t){t.preventDefault();const n=t.dataTransfer,r=n?.getData("elementType"),o=n?.getData("fieldKey"),i=this.pointToPaperMm(t);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,t.ctrlKey||t.metaKey||t.labelIntent===!0)}}pointToPaperMm(t){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const r=n.getBoundingClientRect(),o=(this.store.scale||100)/100,i=uo((t.clientX-r.left)/o),a=uo((t.clientY-r.top)/o);return i<0||a<0?null:{left:i,top:a}}onCanvasMouseDown(t){const n=t.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()),t.button===0&&(this.store.clearSelection(),this.startMarquee(t)))}onCanvasMouseMove(t){const n=this.pointToPaperMm(t),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 t=this.root.querySelector("[data-coord]");t&&(t.textContent="")}onContextMenu(t){this.openMenu(t,null)}onElementContextMenu(t){this.store.selectedIds.has(t.id)||this.store.selectOne(t.id),this.openMenu(t.event,t.id)}openMenu(t,n){this.menu.x=t.clientX,this.menu.y=t.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(t){const n={x:t.clientX,y:t.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(t,n){const r=this.taps.get(t);return this.taps.set(t,{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(t),!0)}beginDrag(t){const n=t.event;if(n.button!==0)return;const r=this.store;n.stopPropagation();const o=r.elements.find(l=>l.id===t.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 t=this.store.draggingIds;for(const n of Array.from(this.root.querySelectorAll(".print-element"))){const r=t.has(n.dataset.elId??"");n.classList.toggle("drag-ghost",r);const o=n.querySelector(":scope > .drag-preview");r&&!o?Ze(h("div",{class:"drag-preview"}),n):!r&&o&&o.remove()}}finishAltClone(t){const n=this.store;n.adsorbGuides=[];const r=n.elements.find(a=>a.id===t.primary),o=t.movedPositions.get(t.primary);if(n.discardLive(),!r||!o)return;const i=JSON.parse(JSON.stringify(r));i.id=zn(),i.options.left=o.left,i.options.top=o.top,i.options.groupId=void 0,n.cloneElement(i)}flashSnapIndicator(t,n){const r=this.root.querySelector(".hiprint-printPaper-content");r&&(r.querySelector(".snap-indicator")?.remove(),Ze(h("div",{class:"snap-indicator",style:{left:`${t}mm`,top:`${n}mm`}}),r),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{r.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(t){const n=t.event;n.stopPropagation();const r=this.store.elements.find(o=>o.id===t.id);!r||r.options.locked||(this.resize={id:t.id,point:t.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(t){t.event.stopPropagation(),t.event.preventDefault(),this.zoneResizing=t.zone;const n=t.event.clientY,r=this.store.templateData,o=t.zone==="header"?r.header.height:r.footer.height,i=(this.store.scale||100)/100,a=c=>{const s=uo((c.clientY-n)/i),d=Math.max(0,Math.round((o+(t.zone==="header"?s:-s))*10)/10);t.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(t){const n=(this.store.templateData.guides??[]).find(d=>d.id===t.id);if(!n)return;const r=Jt(this.store.templateData),o=n.type==="vertical"?r.width:r.height,i=t.event.clientX,a=t.event.clientY,l=(this.store.scale||100)/100,c=d=>{const p=uo((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(t){const n=t.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(t,n){const r=this.root.querySelector(".hiprint-printPaper");if(!r)return null;const o=r.getBoundingClientRect(),i=un(1)*(this.geom.paperScale||1),a=n==="vertical"?(t.clientX-o.left)/i:(t.clientY-o.top)/i,l=Jt(this.store.templateData),c=n==="vertical"?l.width:l.height;return a<0||a>c?null:a}applyZoom(t,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(t));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,this.scrollPos={x:i.scrollLeft,y:i.scrollTop}}zoomByStep(t){const n=this.root.querySelector(".canvas-area");n&&this.applyZoom(Yc(this.store.scale,t),n.clientWidth/2,n.clientHeight/2,So)}fitToWindow(){const t=this.root.querySelector(".canvas-area");if(!t)return;const n=getComputedStyle(t),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),o=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),i=Jt(this.store.templateData),a=Dm(t.clientWidth-r,t.clientHeight-o,un(i.width),un(i.height));this.applyZoom(a,t.clientWidth/2,t.clientHeight/2,Vc)}onWheel(t){if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault();const n=this.root.querySelector(".canvas-area");if(!n)return;const r=Math.round(this.store.scale),o=Yc(r,t.deltaY>0?-1:1);if(o===r)return;const i=n.getBoundingClientRect();this.applyZoom(o,t.clientX-i.left,t.clientY-i.top,So)}onScroll(){const t=this.root.querySelector(".canvas-area");if(!t)return;this.scrollPos={x:t.scrollLeft,y:t.scrollTop};const n=this.root.querySelector(".ruler-overlay");n&&(n.style.transform=`translate(${this.scrollPos.x}px, ${this.scrollPos.y}px)`),this.syncRulers()}on(t,n,r,o){t.addEventListener(n,r,o),this.instanceDisposers.push(()=>t.removeEventListener(n,r,o))}attachInstanceListeners(){this.instanceDisposers.length||(this.bindPointer(),this.bindKeys(),this.bindPaneScroll())}bindPaneScroll(){this.on(this.root,"scroll",t=>{const n=t.target;if(!(n instanceof HTMLElement))return;const r=n.dataset.pane;r&&this.paneScroll.set(r,n.scrollTop)},!0)}bindPointer(){const t=a=>{const l=this.store;if(!l)return;const s=((l.scale||100)/100||1)*un(1),d=(p,u)=>({dx:p/s,dy:u/s});if(this.drag){const{dx:p,dy:u}=d(a.clientX-this.drag.startX,a.clientY-this.drag.startY);(Math.abs(p)>.05||Math.abs(u)>.05)&&(this.drag.moved=!0);const f=l.elements.find(k=>k.id===this.drag.primary),g=f&&We(f.options).margin,m=f&&g&&{id:f.id,left:(this.drag.origin.get(f.id)?.left??0)+p,top:(this.drag.origin.get(f.id)?.top??0)+u,width:g.width,height:g.height};let b=null;if(m&&l.snapToGrid!==!1){const k=l.elements.filter(P=>!this.drag.ids.includes(P.id)&&(P.zone||"content")===this.drag.zone).map(P=>({id:P.id,...We(P.options).margin})),L=gl(l.templateData,l.paperSize)[this.drag.zone],R=z1(m,k,this.manualGuides());b={left:R.left,top:R.top},l.adsorbGuides=(R.lines??[]).filter(P=>P.position>=0&&P.position<=(P.type==="vertical"?L.width:L.height)),(b.left!==m.left||b.top!==m.top)&&this.flashSnapIndicator(b.left+m.width/2,b.top+m.height/2)}else l.adsorbGuides=[];const v=f?this.drag.origin.get(f.id):void 0,w=b&&v?b.left-v.left:p,E=b&&v?b.top-v.top:u;for(const k of this.drag.ids){const L=this.drag.origin.get(k);if(!L)continue;const R={left:L.left+w,top:L.top+E};this.drag.movedPositions.set(k,R),l.livePatch(k,R)}this.patchElementDom(),l.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:p,dy:u}=d(a.clientX-this.resize.startX,a.clientY-this.resize.startY),f=q1(this.resize.point,this.resize.origin,p,u,3.5,3.5);l.livePatch(this.resize.id,f),this.patchElementDom()}},n=()=>{const a=!!this.drag,l=this.drag;if(l?.moved&&l.altKey){this.finishAltClone(l),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(),a&&(this.store.draggingIds=new Set,this.syncDragGhost()))},r=a=>{const l=a.composedPath(),c=l.some(d=>d.classList?.contains("tb-dd"));this.state.openDd&&!c&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!c&&(this.state.openMore=!1,this.repaint());const s=l.some(d=>d.classList?.contains("context-menu"));this.menu.visible&&!s&&(this.menu.visible=!1,this.repaint())},o=a=>{const c=a.target?.closest?.("[data-tip]");!c||!c.closest(cE)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(c),300))},i=a=>{const l=a,c=l.target?.closest?.("[data-tip]");c&&l.relatedTarget?.closest?.("[data-tip]")!==c&&this.hideHoverTip()};this.on(window,"mousemove",t),this.on(window,"mouseup",n),this.on(this,"pointerdown",r),this.on(this.root,"mouseover",o),this.on(this.root,"mouseout",i)}showHoverTip(t){const n=t.dataset.tip;if(!n)return;this.hideHoverTip();const r=t.getBoundingClientRect(),o=r.left+r.width/2;this.hoverTipEl=Ze(h("div",{class:"pd-hover-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root);const i=this.hoverTipEl.offsetWidth/2;if(!i)return;const a=i+8,l=Math.max(window.innerWidth-i-8,a);this.hoverTipEl.style.left=`${Math.min(Math.max(o,a),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const t=[],n=[];for(const r of this.store.templateData.guides??[])r.type==="vertical"?t.push(r.position):n.push(r.position);return{vertical:t,horizontal:n}}paintGuidesOnly(){const t=this.root.querySelector(".hiprint-printPaper-content");if(!t)return;for(const r of Array.from(t.querySelectorAll(".adsorb-guide")))r.remove();const n=this.store.paperSize;gl(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)"}`,t.appendChild(o)}}bindKeys(){this.setAttribute("tabindex","0");const t=()=>{Gt.active=this};this.on(this,"pointerdown",t),this.on(this,"focusin",t),Gt.active||(Gt.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=t=>this.onGlobalKeydown(t),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>$h(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(t){const n=this.store;if(!n||Gt.active!==this)return;const o=t.composedPath()[0]?.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT")return;if(this.format.handlePainterKeydown(t),t.key.startsWith("Arrow")){t.preventDefault();const a=t.shiftKey?10:t.ctrlKey?.5:1,l=t.key==="ArrowLeft"?-a:t.key==="ArrowRight"?a:0,c=t.key==="ArrowUp"?-a:t.key==="ArrowDown"?a:0;n.moveSelected(l,c);return}if(t.key==="Delete"||t.key==="Backspace"){t.preventDefault(),n.deleteSelected();return}if(!(t.ctrlKey||t.metaKey))return;const i=t.key.toLowerCase();dE.has(i)&&(t.preventDefault(),i==="z"?t.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"?t.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 dg(e="print-designer"){return customElements.get(e)||customElements.define(e,Gt),e}function uE(){return dg()}const pE=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_ELEMENT_CAPABILITIES:lr,BUILTIN_ELEMENT_DEFINITIONS:Ii,DesignerStore:Of,PRINT_DESIGNER_ATTRIBUTES:Ys,PRINT_DESIGNER_BOOLEAN_ATTRIBUTES:qf,PRINT_DESIGNER_CONTRACT_VERSION:Vs,PRINT_DESIGNER_EVENT:St,PRINT_DESIGNER_EVENTS:Vf,PRINT_DESIGNER_EVENT_OPTIONS:$v,PRINT_DESIGNER_METHODS:jf,PRINT_DESIGNER_PARTS:Ks,PRINT_DESIGNER_PROPERTY_NAMES:Gf,PRINT_DESIGNER_TAG:Uf,PRINT_DESIGNER_THEME_TOKENS:Wf,PrintDesignerElement:Gt,TILING_SINGLE_PAGE_TIP:Us,createDefaultTemplate:qr,definePrintDesigner:dg,getElementCapabilities:ut,getElementCapabilityTypes:oa,getElementDblEditableField:Bf,getElementDefinition:tn,getElementDefinitions:Lf,getElementLayerIcon:Hf,getElementPropertyGroup:zf,getHostContract:Xs,getMaterialElementDefinitions:Ff,registerAll:uE,registerElementCapabilities:jg,registerElementDefinition:Iv,registerElementRenderer:Pv,registerElementRenderers:Nf,resetElementCapabilities:Gg,resetElementDefinitions:Dv,serializePage:Cf,subscribeElementDefinitions:$f,toRuntimePool:qs},Symbol.toStringTag,{value:"Module"})),fE=17521,hE=20,eo={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml",TEMPLATE_ATTACH:"template.attach",TEMPLATE_DETACH:"template.detach"};let Nl=0;function gE(){return Nl=(Nl+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${Nl.toString(36)}`}function ug(e,t){const n={id:gE(),type:e,payload:t};return JSON.stringify(n)}function pg(e){let t;try{t=JSON.parse(e)}catch{return{malformed:!0}}if(typeof t!="object"||t===null)return{malformed:!0};const n=t;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}}}function mE(e){if(typeof e!="object"||e===null)return!1;const t=e;return!("ok"in t)&&typeof t.id=="string"&&typeof t.type=="string"&&typeof t.payload=="object"&&t.payload!==null}class Lt extends Error{constructor(t,n){super(n),this.name="WormPrintError",this.code=t}}function bE(e){return e instanceof Lt||e&&typeof e=="object"&&typeof e.code=="string"?e.code:"INTERNAL"}class fg extends Error{constructor(t){super(t),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class yE{constructor(t={}){this.ws=null,this.status_="disconnected",this.hello=null,this.pendings=new Map,this.statusCbs=new Set,this.requestHandler=null,this.manualClose=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.opts=t,this.ctor=t.WebSocketCtor??WebSocket,this.defaultTimeout=t.timeoutMs??15e3}get status(){return this.status_}onStatus(t){return this.statusCbs.add(t),()=>this.statusCbs.delete(t)}setRequestHandler(t){this.requestHandler=t}setToken(t){this.opts={...this.opts,token:t}}async connect(t){if(this.status_==="connected"&&this.hello)return this.hello;this.setStatus("connecting");const n=this.opts.ports??Array.from({length:hE},(r,o)=>fE+o);for(const r of n){if(t?.aborted)throw new Lt("CLIENT_NOT_RUNNING","连接已取消");try{return this.hello=await this.tryPort(r,t),this.manualClose=!1,this.reconnectAttempts=0,this.setStatus("connected"),this.hello}catch(o){if(o instanceof fg)throw this.setStatus("disconnected"),new Lt("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new Lt("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(t,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new Lt("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=ug(t,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new Lt("CLIENT_TIMEOUT",`请求 ${t} 超时未响应`))},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 Lt("CLIENT_NOT_RUNNING","连接已关闭")),this.setStatus("disconnected")}buildUrl(t){const n=new URL(`ws://127.0.0.1:${t}`);return this.opts.token&&n.searchParams.set("token",this.opts.token),n.toString().replace(/\/$/,"")}tryPort(t,n){return new Promise((r,o)=>{const i=new this.ctor(this.buildUrl(t));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(ug("hello",{}))},i.onmessage=c=>{const s=pg(String(c.data));if(!("malformed"in s))if(s.ok&&vE(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 fg(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(t){t.onmessage=n=>{this.handleIncoming(t,String(n.data))},t.onclose=()=>{this.failAllPendings(new Lt("CLIENT_NOT_RUNNING","与客户端的连接中断")),this.hello=null,this.ws=null,this.manualClose||this.scheduleReconnect()},t.onerror=()=>{}}handleIncoming(t,n){let r;try{r=JSON.parse(n)}catch{return}if(mE(r)){this.dispatchServerRequest(t,r);return}const o=pg(n);if("malformed"in o)return;const i=this.pendings.get(o.id);i&&(this.pendings.delete(o.id),clearTimeout(i.timer),o.ok?i.resolve(o.payload):i.reject(new Lt(o.error.code,o.error.message)))}dispatchServerRequest(t,n){const r=this.requestHandler;if(!r){this.safeSend(t,n.id,!1,void 0,"INVALID_REQUEST","桌面端请求未注册处理器");return}Promise.resolve().then(()=>r(n.type,n.payload)).then(o=>this.safeSend(t,n.id,!0,o??{})).catch(o=>{const i=bE(o),a=o instanceof Error?o.message:String(o);this.safeSend(t,n.id,!1,void 0,i,a)})}safeSend(t,n,r,o,i,a){t.readyState===1&&t.send(JSON.stringify(r?{id:n,ok:r,payload:o}:{id:n,ok:r,error:{code:i??"INTERNAL",message:a??"内部错误"}}))}scheduleReconnect(){this.setStatus("connecting");const t=Math.min(1e3*2**this.reconnectAttempts++,1e4);this.reconnectTimer=setTimeout(()=>{this.connect().catch(()=>this.scheduleReconnect())},t)}failAllPendings(t){for(const[,n]of this.pendings)clearTimeout(n.timer),n.reject(t);this.pendings.clear()}setStatus(t){if(this.status_!==t){this.status_=t;for(const n of this.statusCbs)n(t)}}}function vE(e){return typeof e=="object"&&e!==null&&e.app==="worm-print-client"}const hg="worm-print-client:token";class Ll{constructor(t={}){const r={token:t.token??Ll.loadStoredToken()??void 0,timeoutMs:t.timeoutMs,WebSocketCtor:t.WebSocketCtor};this.transport=new yE(r)}get status(){return this.transport.status}connect(t){return this.transport.connect(t)}onStatusChange(t){return this.transport.onStatus(t)}setRequestHandler(t){this.transport.setRequestHandler(t)}async listPrinters(){return(await this.transport.request(eo.PRINTERS_LIST,{})).printers}request(t,n,r){return this.transport.request(t,n,r)}attachTemplate(t){return this.request(eo.TEMPLATE_ATTACH,t)}detachTemplate(t){return this.request(eo.TEMPLATE_DETACH,{sessionId:t})}print(t,n,r={},o){const{baseUrl:i,fontBaseUrl:a,timeoutMs:l,...c}=r,s={templateJson:t,printData:n,baseUrl:i,fontBaseUrl:a,print:c};return typeof o=="string"&&o.trim().length>0&&(s.templateName=o),this.transport.request(eo.PRINT_SUBMIT,s,l)}printHtml(t,n={},r){const{timeoutMs:o,...i}=n,a={html:t.html,paperMm:t.paperMm,pagePaperMm:t.pagePaperMm,continuous:t.continuous,pageCount:t.pageCount,print:i};return typeof r=="string"&&r.trim().length>0&&(a.templateName=r),this.transport.request(eo.PRINT_SUBMIT_HTML,a,o)}pair(t){localStorage.setItem(hg,t),this.transport.setToken(t)}static loadStoredToken(){try{return localStorage.getItem(hg)}catch{return null}}close(){this.transport.close()}}const wE={...pE,renderHtmlPages:mv,browserCodeRenderer:Ls,PrintClient:Ll,WormPrintError:Lt,getPaperDimensions:ht,isContinuousPaperSize:Fn,getByPath:Er,resolvePrinterDpi:t0,paperWidthPx:n0,zoomPresets:o0,defaultZoomKey:od,resolveZoomKey:s0,zoomValueOf:l0,viewZoomHint:i0,applyPreviewViewZoom:a0,resolveToolbarOverflow:Kc};globalThis.WormPrintCanvas??=wE}));
1213
+ `)}`))return;const o=JSON.stringify(n);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent(St.save,{detail:o,bubbles:!0,composed:!0}))}validateTemplate(){const t=this.store.templateData;return t.tiling?.enabled===!0?ss(t):[]}getGeometryWarnings(){return u1(this.store.templateData)}applyTemplate(t){if(!t)return;const n=typeof t=="string"?JSON.parse(t):t;this.store?this.store.loadTemplate(n):this.setAttribute("template",JSON.stringify(n))}openExpression(t){this.exprTarget=t,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const t=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){t.forEach(r=>r.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;t.forEach(r=>r.remove());const n=this.exprTarget;Ze(tE({fields:this.store.fields,fieldDisplay:this.state.fieldDisplay,onClose:()=>this.closeExpression(),onApply:r=>this.applyExpression(n,r)},n),this.root),this.exprMountedFor=n}openHelp(t){this.helpInitialTab=t,this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const t=this.helpVisible&&this.getAttribute("show-help")!=="false";if(t&&!this.unmountHelp)this.unmountHelp=iE(this.root,{initialTab:this.helpInitialTab,onClose:()=>this.closeHelp()});else if(!t&&this.unmountHelp){const n=this.unmountHelp;this.unmountHelp=null,n()}}applyExpression(t,n){const r=n.formatter??"",o=t.targetPath;if(o.startsWith("options.")){if(o.includes("[")){const a=this.store.elements.find(l=>l.id===t.elementId);a&&Tl(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(t.elementId,i);return}if(o==="watermark.content"){const i={...this.store.templateData.watermark};Dl(r)?Object.assign(i,{mode:"binding",binding:r,content:""}):Object.assign(i,{mode:"fixed",content:r,binding:""}),this.store.updateTemplateData({watermark:i})}}dblEditElement(t){const n=this.store.elements.find(o=>o.id===t);if(!n||(this.store.selectOne(t),this.state.propTab=Vs(n)?"custom":"element",n.options.locked))return;const r=Hf(n.printElementType.type);r&&this.openExpression({elementId:n.id,targetPath:`options.${r}`,value:String(n.options[r]??"")})}dblEditCell(t){const n=this.store.elements.find(l=>l.id===t.elementId);if(!n||(this.store.selectOne(n.id),this.state.propTab="element",n.options.locked))return;const r=n.options.tableRows??[],o=ar(r,t.r,t.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:(t,n)=>this.fire(t,n),showHelp:this.getAttribute("show-help")!=="false",showPreview:this.getAttribute("show-preview")!=="false",showSave:this.getAttribute("show-save")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts,designData:this.designData,fields:this.store.fields}}}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;mh(),this.syncPluginUIStyles();const t=[...this.store.selectedIds].join(",");if(t!==this.lastSelKey){this.lastSelKey=t;const a=this.store.selectedElement;this.state.propTab=a?Vs(a)?"custom":"element":"page"}const n=this.root.querySelector(".designer-container");n.classList.toggle("format-painting",this.format.painterActive);for(const a of n.querySelectorAll("[data-pane]"))a.style.display!=="none"&&this.paneScroll.set(a.dataset.pane,a.scrollTop);kf(n);const r=this.ctx;Ze(cE(r,Jx(r)),n),Ze(i2(r),n),Ze(h("div",{class:"designer-body"},[e2(r),Px(r,this.canvasUi()),z2(r)]),n),Ze(a2(r),n),ng(n),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>ng(n)),this.toolbarRo.observe(n));const o=ox(this.store,(a,l)=>this.fire(a,l),this.tableMenu);o&&Ze(o,n),Aw(this.root,this.store.elements,this.designData),Wh(this.root,this.state.propSearch),this.applyShrinkFit();const i=this.root.querySelector(".canvas-area");i&&(i.scrollLeft=this.scrollPos.x,i.scrollTop=this.scrollPos.y);for(const a of n.querySelectorAll("[data-pane]")){const l=this.paneScroll.get(a.dataset.pane);l!==void 0&&(a.scrollTop=l)}this.syncRulers(),this.persistChrome(),this.applyHostParts(n)}applyHostParts(t){const n={".designer-toolbar":"toolbar",".format-toolbar":"format-bar",".left-panel":"left-panel",".canvas-area":"canvas-area",".property-panel":"property-panel",".status-bar":"status-bar",".page-tabs":"page-tabs"};for(const[r,o]of Object.entries(n)){const i=t.querySelector(r);i&&Xs.includes(o)&&i.setAttribute("part",o)}}applyShrinkFit(){for(const t of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Mf(t);for(const t of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(t.getAttribute("data-fit")==="shrink")continue;t.removeAttribute("data-fit-size");const n=t.getAttribute("data-fit-base");n?t.style.fontSize=`${n}pt`:t.style.removeProperty("font-size")}}measureRuler(){const t=this.root.querySelector(".canvas-area"),n=this.root.querySelector(".hiprint-printPaper");if(!t||!n)return;const r=t.getBoundingClientRect(),o=n.getBoundingClientRect(),i=(this.store.scale||100)/100,a=o.width/un(this.store.paperSize.width);this.geom={paperScale:Math.abs(a-i)<.002?i:a,originX:o.left-r.left-Xi,originY:o.top-r.top-Xi,viewW:t.clientWidth-Xi,viewH:t.clientHeight-Xi},this.observeCanvasArea()}observeCanvasArea(){const t=this.root.querySelector(".canvas-area");!t||typeof ResizeObserver>"u"||this.roArea===t||(this.roArea=t,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(t))}syncRulers(){this.measureRuler();const t=this.store.templateData,n=Jt(t),r=this.geom.paperScale;for(const o of Array.from(this.root.querySelectorAll(".pd-ruler"))){const i=o.dataset.ruler==="vertical"?"vertical":"horizontal";dE(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 t=this.root.querySelector(".position-label"),n=this.store.selectedElement;t&&n&&!this.drag&&(t.textContent=Rh(n.options))}fire(t,n){const r=this.store;switch(t){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(St.preview,{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent(St.help,{bubbles:!0,composed:!0})),this.openHelp(n);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(St.dblclickElement,{detail:o,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const o=n;this.dblEditCell(o),this.dispatchEvent(new CustomEvent(St.dblclickCell,{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(t){t.preventDefault();const n=t.dataTransfer,r=n?.getData("elementType"),o=n?.getData("fieldKey"),i=this.pointToPaperMm(t);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,t.ctrlKey||t.metaKey||t.labelIntent===!0)}}pointToPaperMm(t){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const r=n.getBoundingClientRect(),o=(this.store.scale||100)/100,i=uo((t.clientX-r.left)/o),a=uo((t.clientY-r.top)/o);return i<0||a<0?null:{left:i,top:a}}onCanvasMouseDown(t){const n=t.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()),t.button===0&&(this.store.clearSelection(),this.startMarquee(t)))}onCanvasMouseMove(t){const n=this.pointToPaperMm(t),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 t=this.root.querySelector("[data-coord]");t&&(t.textContent="")}onContextMenu(t){this.openMenu(t,null)}onElementContextMenu(t){this.store.selectedIds.has(t.id)||this.store.selectOne(t.id),this.openMenu(t.event,t.id)}openMenu(t,n){this.menu.x=t.clientX,this.menu.y=t.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(t){const n={x:t.clientX,y:t.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(t,n){const r=this.taps.get(t);return this.taps.set(t,{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(t),!0)}beginDrag(t){const n=t.event;if(n.button!==0)return;const r=this.store;n.stopPropagation();const o=r.elements.find(l=>l.id===t.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 t=this.store.draggingIds;for(const n of Array.from(this.root.querySelectorAll(".print-element"))){const r=t.has(n.dataset.elId??"");n.classList.toggle("drag-ghost",r);const o=n.querySelector(":scope > .drag-preview");r&&!o?Ze(h("div",{class:"drag-preview"}),n):!r&&o&&o.remove()}}finishAltClone(t){const n=this.store;n.adsorbGuides=[];const r=n.elements.find(a=>a.id===t.primary),o=t.movedPositions.get(t.primary);if(n.discardLive(),!r||!o)return;const i=JSON.parse(JSON.stringify(r));i.id=Bn(),i.options.left=o.left,i.options.top=o.top,i.options.groupId=void 0,n.cloneElement(i)}flashSnapIndicator(t,n){const r=this.root.querySelector(".hiprint-printPaper-content");r&&(r.querySelector(".snap-indicator")?.remove(),Ze(h("div",{class:"snap-indicator",style:{left:`${t}mm`,top:`${n}mm`}}),r),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{r.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(t){const n=t.event;n.stopPropagation();const r=this.store.elements.find(o=>o.id===t.id);!r||r.options.locked||(this.resize={id:t.id,point:t.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(t){t.event.stopPropagation(),t.event.preventDefault(),this.zoneResizing=t.zone;const n=t.event.clientY,r=this.store.templateData,o=t.zone==="header"?r.header.height:r.footer.height,i=(this.store.scale||100)/100,a=c=>{const s=uo((c.clientY-n)/i),d=Math.max(0,Math.round((o+(t.zone==="header"?s:-s))*10)/10);t.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(t){const n=(this.store.templateData.guides??[]).find(d=>d.id===t.id);if(!n)return;const r=Jt(this.store.templateData),o=n.type==="vertical"?r.width:r.height,i=t.event.clientX,a=t.event.clientY,l=(this.store.scale||100)/100,c=d=>{const p=uo((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(t){const n=t.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(t,n){const r=this.root.querySelector(".hiprint-printPaper");if(!r)return null;const o=r.getBoundingClientRect(),i=un(1)*(this.geom.paperScale||1),a=n==="vertical"?(t.clientX-o.left)/i:(t.clientY-o.top)/i,l=Jt(this.store.templateData),c=n==="vertical"?l.width:l.height;return a<0||a>c?null:a}applyZoom(t,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(t));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,this.scrollPos={x:i.scrollLeft,y:i.scrollTop}}zoomByStep(t){const n=this.root.querySelector(".canvas-area");n&&this.applyZoom(Kc(this.store.scale,t),n.clientWidth/2,n.clientHeight/2,So)}fitToWindow(){const t=this.root.querySelector(".canvas-area");if(!t)return;const n=getComputedStyle(t),r=(parseFloat(n.paddingLeft)||0)+(parseFloat(n.paddingRight)||0),o=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),i=Jt(this.store.templateData),a=Fm(t.clientWidth-r,t.clientHeight-o,un(i.width),un(i.height));this.applyZoom(a,t.clientWidth/2,t.clientHeight/2,Yc)}onWheel(t){if(!t.ctrlKey&&!t.metaKey)return;t.preventDefault();const n=this.root.querySelector(".canvas-area");if(!n)return;const r=Math.round(this.store.scale),o=Kc(r,t.deltaY>0?-1:1);if(o===r)return;const i=n.getBoundingClientRect();this.applyZoom(o,t.clientX-i.left,t.clientY-i.top,So)}onScroll(){const t=this.root.querySelector(".canvas-area");if(!t)return;this.scrollPos={x:t.scrollLeft,y:t.scrollTop};const n=this.root.querySelector(".ruler-overlay");n&&(n.style.transform=`translate(${this.scrollPos.x}px, ${this.scrollPos.y}px)`),this.syncRulers()}on(t,n,r,o){t.addEventListener(n,r,o),this.instanceDisposers.push(()=>t.removeEventListener(n,r,o))}attachInstanceListeners(){this.instanceDisposers.length||(this.bindPointer(),this.bindKeys(),this.bindPaneScroll())}bindPaneScroll(){this.on(this.root,"scroll",t=>{const n=t.target;if(!(n instanceof HTMLElement))return;const r=n.dataset.pane;r&&this.paneScroll.set(r,n.scrollTop)},!0)}bindPointer(){const t=a=>{const l=this.store;if(!l)return;const s=((l.scale||100)/100||1)*un(1),d=(p,u)=>({dx:p/s,dy:u/s});if(this.drag){const{dx:p,dy:u}=d(a.clientX-this.drag.startX,a.clientY-this.drag.startY);(Math.abs(p)>.05||Math.abs(u)>.05)&&(this.drag.moved=!0);const f=l.elements.find(T=>T.id===this.drag.primary),g=f&&We(f.options).margin,m=f&&g&&{id:f.id,left:(this.drag.origin.get(f.id)?.left??0)+p,top:(this.drag.origin.get(f.id)?.top??0)+u,width:g.width,height:g.height};let y=null;if(m&&l.snapToGrid!==!1){const T=l.elements.filter(I=>!this.drag.ids.includes(I.id)&&(I.zone||"content")===this.drag.zone).map(I=>({id:I.id,...We(I.options).margin})),P=ml(l.templateData,l.paperSize)[this.drag.zone],O=z1(m,T,this.manualGuides());y={left:O.left,top:O.top},l.adsorbGuides=(O.lines??[]).filter(I=>I.position>=0&&I.position<=(I.type==="vertical"?P.width:P.height)),(y.left!==m.left||y.top!==m.top)&&this.flashSnapIndicator(y.left+m.width/2,y.top+m.height/2)}else l.adsorbGuides=[];const v=f?this.drag.origin.get(f.id):void 0,w=y&&v?y.left-v.left:p,E=y&&v?y.top-v.top:u;for(const T of this.drag.ids){const P=this.drag.origin.get(T);if(!P)continue;const O={left:P.left+w,top:P.top+E};this.drag.movedPositions.set(T,O),l.livePatch(T,O)}this.patchElementDom(),l.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:p,dy:u}=d(a.clientX-this.resize.startX,a.clientY-this.resize.startY),f=W1(this.resize.point,this.resize.origin,p,u,3.5,3.5);l.livePatch(this.resize.id,f),this.patchElementDom()}},n=()=>{const a=!!this.drag,l=this.drag;if(l?.moved&&l.altKey){this.finishAltClone(l),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(),a&&(this.store.draggingIds=new Set,this.syncDragGhost()))},r=a=>{const l=a.composedPath(),c=l.some(d=>d.classList?.contains("tb-dd"));this.state.openDd&&!c&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!c&&(this.state.openMore=!1,this.repaint());const s=l.some(d=>d.classList?.contains("context-menu"));this.menu.visible&&!s&&(this.menu.visible=!1,this.repaint())},o=a=>{const c=a.target?.closest?.("[data-tip]");!c||!c.closest(pE)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(c),300))},i=a=>{const l=a,c=l.target?.closest?.("[data-tip]");c&&l.relatedTarget?.closest?.("[data-tip]")!==c&&this.hideHoverTip()};this.on(window,"mousemove",t),this.on(window,"mouseup",n),this.on(this,"pointerdown",r),this.on(this.root,"mouseover",o),this.on(this.root,"mouseout",i)}showHoverTip(t){const n=t.dataset.tip;if(!n)return;this.hideHoverTip();const r=t.getBoundingClientRect(),o=r.left+r.width/2;this.hoverTipEl=Ze(h("div",{class:"pd-hover-tip",style:{left:`${o}px`,top:`${r.bottom+6}px`},text:n}),this.root);const i=this.hoverTipEl.offsetWidth/2;if(!i)return;const a=i+8,l=Math.max(window.innerWidth-i-8,a);this.hoverTipEl.style.left=`${Math.min(Math.max(o,a),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const t=[],n=[];for(const r of this.store.templateData.guides??[])r.type==="vertical"?t.push(r.position):n.push(r.position);return{vertical:t,horizontal:n}}paintGuidesOnly(){const t=this.root.querySelector(".hiprint-printPaper-content");if(!t)return;for(const r of Array.from(t.querySelectorAll(".adsorb-guide")))r.remove();const n=this.store.paperSize;ml(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)"}`,t.appendChild(o)}}bindKeys(){this.setAttribute("tabindex","0");const t=()=>{Gt.active=this};this.on(this,"pointerdown",t),this.on(this,"focusin",t),Gt.active||(Gt.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=t=>this.onGlobalKeydown(t),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>$h(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(t){const n=this.store;if(!n||Gt.active!==this)return;const o=t.composedPath()[0]?.tagName;if(o==="INPUT"||o==="TEXTAREA"||o==="SELECT")return;if(this.format.handlePainterKeydown(t),t.key.startsWith("Arrow")){t.preventDefault();const a=t.shiftKey?10:t.ctrlKey?.5:1,l=t.key==="ArrowLeft"?-a:t.key==="ArrowRight"?a:0,c=t.key==="ArrowUp"?-a:t.key==="ArrowDown"?a:0;n.moveSelected(l,c);return}if(t.key==="Delete"||t.key==="Backspace"){t.preventDefault(),n.deleteSelected();return}if(!(t.ctrlKey||t.metaKey))return;const i=t.key.toLowerCase();fE.has(i)&&(t.preventDefault(),i==="z"?t.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"?t.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 ug(e="print-designer"){return customElements.get(e)||customElements.define(e,Gt),e}function hE(){return ug()}const gE=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_ELEMENT_CAPABILITIES:lr,BUILTIN_ELEMENT_DEFINITIONS:Oi,DesignerStore:Of,PRINT_DESIGNER_ATTRIBUTES:Ks,PRINT_DESIGNER_BOOLEAN_ATTRIBUTES:Wf,PRINT_DESIGNER_CONTRACT_VERSION:Ys,PRINT_DESIGNER_EVENT:St,PRINT_DESIGNER_EVENTS:Yf,PRINT_DESIGNER_EVENT_OPTIONS:$v,PRINT_DESIGNER_METHODS:Gf,PRINT_DESIGNER_PARTS:Xs,PRINT_DESIGNER_PROPERTY_NAMES:Vf,PRINT_DESIGNER_TAG:qf,PRINT_DESIGNER_THEME_TOKENS:jf,PrintDesignerElement:Gt,TILING_SINGLE_PAGE_TIP:qs,createDefaultTemplate:qr,definePrintDesigner:ug,getElementCapabilities:ut,getElementCapabilityTypes:ia,getElementDblEditableField:Hf,getElementDefinition:tn,getElementDefinitions:Lf,getElementLayerIcon:Uf,getElementPropertyGroup:zf,getHostContract:Zs,getMaterialElementDefinitions:Bf,registerAll:hE,registerElementCapabilities:Gg,registerElementDefinition:Iv,registerElementRenderer:Pv,registerElementRenderers:Nf,resetElementCapabilities:Vg,resetElementDefinitions:Fv,serializePage:Af,subscribeElementDefinitions:$f,toRuntimePool:Ws},Symbol.toStringTag,{value:"Module"})),mE=17521,bE=20,eo={PRINTERS_LIST:"printers.list",PRINT_SUBMIT:"print.submit",PRINT_SUBMIT_HTML:"print.submitHtml",TEMPLATE_ATTACH:"template.attach",TEMPLATE_DETACH:"template.detach"};let Nl=0;function yE(){return Nl=(Nl+1)%Number.MAX_SAFE_INTEGER,`${Date.now().toString(36)}-${Nl.toString(36)}`}function pg(e,t){const n={id:yE(),type:e,payload:t};return JSON.stringify(n)}function fg(e){let t;try{t=JSON.parse(e)}catch{return{malformed:!0}}if(typeof t!="object"||t===null)return{malformed:!0};const n=t;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}}}function vE(e){if(typeof e!="object"||e===null)return!1;const t=e;return!("ok"in t)&&typeof t.id=="string"&&typeof t.type=="string"&&typeof t.payload=="object"&&t.payload!==null}class Nt extends Error{constructor(t,n){super(n),this.name="WormPrintError",this.code=t}}function wE(e){return e instanceof Nt||e&&typeof e=="object"&&typeof e.code=="string"?e.code:"INTERNAL"}class hg extends Error{constructor(t){super(t),this.code="UNAUTHORIZED",this.name="AuthRejectedError"}}class xE{constructor(t={}){this.ws=null,this.status_="disconnected",this.hello=null,this.pendings=new Map,this.statusCbs=new Set,this.requestHandler=null,this.manualClose=!1,this.reconnectTimer=null,this.reconnectAttempts=0,this.opts=t,this.ctor=t.WebSocketCtor??WebSocket,this.defaultTimeout=t.timeoutMs??15e3}get status(){return this.status_}onStatus(t){return this.statusCbs.add(t),()=>this.statusCbs.delete(t)}setRequestHandler(t){this.requestHandler=t}setToken(t){this.opts={...this.opts,token:t}}async connect(t){if(this.status_==="connected"&&this.hello)return this.hello;this.setStatus("connecting");const n=this.opts.ports??Array.from({length:bE},(r,o)=>mE+o);for(const r of n){if(t?.aborted)throw new Nt("CLIENT_NOT_RUNNING","连接已取消");try{return this.hello=await this.tryPort(r,t),this.manualClose=!1,this.reconnectAttempts=0,this.setStatus("connected"),this.hello}catch(o){if(o instanceof hg)throw this.setStatus("disconnected"),new Nt("UNAUTHORIZED",o.message||"配对 token 无效或来源未授权")}}throw this.setStatus("disconnected"),new Nt("CLIENT_NOT_RUNNING","未发现运行中的打印客户端(已探测默认端口区间),请确认客户端已启动")}request(t,n,r){if(this.status_!=="connected"||!this.ws)return Promise.reject(new Nt("CLIENT_NOT_RUNNING","打印客户端未连接"));const o=pg(t,n),i=JSON.parse(o);return new Promise((a,l)=>{const c=setTimeout(()=>{this.pendings.delete(i.id),l(new Nt("CLIENT_TIMEOUT",`请求 ${t} 超时未响应`))},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 Nt("CLIENT_NOT_RUNNING","连接已关闭")),this.setStatus("disconnected")}buildUrl(t){const n=new URL(`ws://127.0.0.1:${t}`);return this.opts.token&&n.searchParams.set("token",this.opts.token),n.toString().replace(/\/$/,"")}tryPort(t,n){return new Promise((r,o)=>{const i=new this.ctor(this.buildUrl(t));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(pg("hello",{}))},i.onmessage=c=>{const s=fg(String(c.data));if(!("malformed"in s))if(s.ok&&EE(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 hg(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(t){t.onmessage=n=>{this.handleIncoming(t,String(n.data))},t.onclose=()=>{this.failAllPendings(new Nt("CLIENT_NOT_RUNNING","与客户端的连接中断")),this.hello=null,this.ws=null,this.manualClose||this.scheduleReconnect()},t.onerror=()=>{}}handleIncoming(t,n){let r;try{r=JSON.parse(n)}catch{return}if(vE(r)){this.dispatchServerRequest(t,r);return}const o=fg(n);if("malformed"in o)return;const i=this.pendings.get(o.id);i&&(this.pendings.delete(o.id),clearTimeout(i.timer),o.ok?i.resolve(o.payload):i.reject(new Nt(o.error.code,o.error.message)))}dispatchServerRequest(t,n){const r=this.requestHandler;if(!r){this.safeSend(t,n.id,!1,void 0,"INVALID_REQUEST","桌面端请求未注册处理器");return}Promise.resolve().then(()=>r(n.type,n.payload)).then(o=>this.safeSend(t,n.id,!0,o??{})).catch(o=>{const i=wE(o),a=o instanceof Error?o.message:String(o);this.safeSend(t,n.id,!1,void 0,i,a)})}safeSend(t,n,r,o,i,a){t.readyState===1&&t.send(JSON.stringify(r?{id:n,ok:r,payload:o}:{id:n,ok:r,error:{code:i??"INTERNAL",message:a??"内部错误"}}))}scheduleReconnect(){this.setStatus("connecting");const t=Math.min(1e3*2**this.reconnectAttempts++,1e4);this.reconnectTimer=setTimeout(()=>{this.connect().catch(()=>this.scheduleReconnect())},t)}failAllPendings(t){for(const[,n]of this.pendings)clearTimeout(n.timer),n.reject(t);this.pendings.clear()}setStatus(t){if(this.status_!==t){this.status_=t;for(const n of this.statusCbs)n(t)}}}function EE(e){return typeof e=="object"&&e!==null&&e.app==="worm-print-client"}const gg="worm-print-client:token";class Ll{constructor(t={}){const r={token:t.token??Ll.loadStoredToken()??void 0,timeoutMs:t.timeoutMs,WebSocketCtor:t.WebSocketCtor};this.transport=new xE(r)}get status(){return this.transport.status}connect(t){return this.transport.connect(t)}onStatusChange(t){return this.transport.onStatus(t)}setRequestHandler(t){this.transport.setRequestHandler(t)}async listPrinters(){return(await this.transport.request(eo.PRINTERS_LIST,{})).printers}request(t,n,r){return this.transport.request(t,n,r)}attachTemplate(t){return this.request(eo.TEMPLATE_ATTACH,t)}detachTemplate(t){return this.request(eo.TEMPLATE_DETACH,{sessionId:t})}print(t,n,r={},o){const{baseUrl:i,fontBaseUrl:a,timeoutMs:l,...c}=r,s={templateJson:t,printData:n,baseUrl:i,fontBaseUrl:a,print:c};return typeof o=="string"&&o.trim().length>0&&(s.templateName=o),this.transport.request(eo.PRINT_SUBMIT,s,l)}printHtml(t,n={},r){const{timeoutMs:o,...i}=n,a={html:t.html,paperMm:t.paperMm,pagePaperMm:t.pagePaperMm,continuous:t.continuous,pageCount:t.pageCount,print:i};return typeof r=="string"&&r.trim().length>0&&(a.templateName=r),this.transport.request(eo.PRINT_SUBMIT_HTML,a,o)}pair(t){localStorage.setItem(gg,t),this.transport.setToken(t)}static loadStoredToken(){try{return localStorage.getItem(gg)}catch{return null}}close(){this.transport.close()}}const SE={...gE,renderHtmlPages:bv,browserCodeRenderer:Ls,PrintClient:Ll,WormPrintError:Nt,getPaperDimensions:ht,isContinuousPaperSize:Ln,getByPath:Er,resolvePrinterDpi:n0,paperWidthPx:r0,zoomPresets:i0,defaultZoomKey:id,resolveZoomKey:l0,zoomValueOf:c0,viewZoomHint:a0,applyPreviewViewZoom:s0,resolveToolbarOverflow:Xc};globalThis.WormPrintCanvas??=SE}));