@worm-vue3-print/common 1.3.7-beta.0 → 1.4.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 (44) hide show
  1. package/README.md +189 -11
  2. package/dist/browser-bundle.d.ts +3 -1
  3. package/dist/common.css +65 -1
  4. package/dist/common.js +184 -77
  5. package/dist/core/default-template.d.ts +1 -1
  6. package/dist/core/format.d.ts +34 -14
  7. package/dist/core/h.d.ts +1 -1
  8. package/dist/core/icons.d.ts +1 -1
  9. package/dist/core/store.d.ts +1 -1
  10. package/dist/index.cjs +112 -9
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +3752 -3113
  13. package/dist/print-designer.d.ts +11 -6
  14. package/dist/shell/binding.d.ts +1 -1
  15. package/dist/shell/canvas.d.ts +1 -1
  16. package/dist/shell/code.d.ts +1 -1
  17. package/dist/shell/color-picker.d.ts +1 -1
  18. package/dist/shell/controls.d.ts +42 -5
  19. package/dist/shell/crop-anchor.d.ts +29 -0
  20. package/dist/shell/elements.d.ts +3 -3
  21. package/dist/shell/expression-editor.d.ts +1 -1
  22. package/dist/shell/flow-list.d.ts +11 -0
  23. package/dist/shell/font-select.d.ts +4 -4
  24. package/dist/shell/format-bar.d.ts +1 -1
  25. package/dist/shell/help-content/changelog.d.ts +1 -1
  26. package/dist/shell/help-content/faq.d.ts +1 -1
  27. package/dist/shell/help-content/features.d.ts +1 -1
  28. package/dist/shell/help-content/getting-started.d.ts +1 -1
  29. package/dist/shell/help-content/index.d.ts +1 -1
  30. package/dist/shell/help-content/shortcuts.d.ts +1 -1
  31. package/dist/shell/help-modal.d.ts +1 -1
  32. package/dist/shell/page-extras.d.ts +4 -3
  33. package/dist/shell/panels.d.ts +1 -1
  34. package/dist/shell/prop-group.d.ts +1 -1
  35. package/dist/shell/property-panel.d.ts +4 -3
  36. package/dist/shell/property-search.d.ts +1 -1
  37. package/dist/shell/ruler.d.ts +1 -1
  38. package/dist/shell/table-props.d.ts +1 -1
  39. package/dist/shell/table.d.ts +1 -1
  40. package/dist/shell/toolbar-overflow.d.ts +1 -1
  41. package/dist/shell/toolbar.d.ts +1 -1
  42. package/dist/shell/watermark.d.ts +3 -2
  43. package/package.json +7 -3
  44. package/dist/core/font-catalog.d.ts +0 -30
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@worm-vue3-print/core/designer"),R=require("@worm-vue3-print/core"),To=require("@worm-vue3-print/core/browser"),li=require("jsbarcode");function a(t,e={},o=[]){return{tag:t,props:e,children:o}}const di="http://www.w3.org/2000/svg",sr=new Set(["draggable","contenteditable","spellcheck"]);function lr(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function te(t,e){if(typeof t=="string"){const s=document.createTextNode(t);return e.appendChild(s),s}if(t instanceof Node)return e.appendChild(t),t;const{tag:o,props:n,children:i}=t,r=lr(o)?document.createElementNS(di,o):document.createElement(o);for(const[s,l]of Object.entries(n))if(!(l==null||l===!1))if(s==="class")r.setAttribute("class",String(l));else if(s==="style")typeof l=="string"?r.style.cssText=l:Object.assign(r.style,l);else if(s==="html")r.innerHTML=String(l);else if(s==="text")r.textContent=String(l);else if(s.startsWith("on")&&typeof l=="function")r.addEventListener(s.slice(2).toLowerCase(),l);else if(s==="dataset")for(const[c,f]of Object.entries(l))r.dataset[c]=f;else typeof l=="boolean"?l&&r.setAttribute(s,sr.has(s)?"true":""):r.setAttribute(s,String(l));for(const s of i)te(s,r);return e.appendChild(r),r}function ci(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const dr=di;function dt(){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 fo="开启拼版后只能有一个设计页面";function Eo(t){const e=(o,n)=>(o??[]).map(i=>{const r={...i.options};return(i.printElementType?.type??i.type)==="table"&&m.syncTableElementSize(r),{id:i.id||m.generateId(),zone:n,options:r,printElementType:{...i.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},guides:[...t.guides??[]],elements:[...e(t.elements??[],"content"),...e(t.header?.elements??[],"header"),...e(t.footer?.elements??[],"footer")]}}function pi(t){const e=t.elements,o=n=>e.filter(i=>(i.zone||"content")===n).map(i=>({id:i.id,type:i.printElementType.type,options:{...i.options},printElementType:{...i.printElementType}}));return{unit:"mm",...t,header:{...t.header,elements:o("header")},footer:{...t.footer,elements:o("footer")},elements:o("content"),guides:[...t.guides??[]]}}function mn(t){const e=(n,i)=>{const r=Eo(m.normalizeTemplateUnits(n));return r.name||(r.name=`页面 ${i+1}`),r};if(!t)return[e(dt(),0)];const o=Array.isArray(t.pages)?t.pages:[t];return o.length?o.map(e):[e(dt(),0)]}const Ke=t=>JSON.parse(JSON.stringify(t));class ui{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=m.useAlign();group=m.useGroup();constructor(e={}){if(this.pages=mn(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const o=this.pages[0];o.elements=[...o.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const o of[...this.listeners])o()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(fo);return}this.recordHistory();const e=this.pages[this.activePageIndex]??dt();this.pages.push(Eo({...dt(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(n=>n.name));let o=this.pages.length+1;for(;e.has(`页面 ${o}`);)o++;return`页面 ${o}`}duplicatePage(e){if(this.tilingEnabled){window.alert(fo);return}this.recordHistory();const o=Ke(this.pages[e]);o.name=`${o.name??`页面 ${e+1}`} 副本`,o.elements=o.elements.map(n=>({...n,id:m.generateId()})),this.pages.splice(e+1,0,o),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,o){this.recordHistory(),this.pages[e].name=o,this.emit()}movePage(e,o){if(o<0||o>=this.pages.length||e===o)return;this.recordHistory();const[n]=this.pages.splice(e,1);this.pages.splice(o,0,n),this.activePageIndex=o,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,o=!1){if(o){const n=new Set(this.selectedIds);n.has(e)?n.delete(e):n.add(e),this.setSelection(n)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,o=!1){if(o){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(o=>o.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,o){const n=this.templateData.guides??[];this.templateData.guides=[...n,{id:m.generateId(),type:e,position:Math.round(o*10)/10}],this.emit()}moveGuide(e,o){const n=this.templateData.guides??[];this.templateData.guides=n.map(i=>i.id===e?{...i,position:Math.round(o*10)/10}:i),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(o=>o.id!==e),this.emit()}addElement(e,o={},n){const i=m.createRuntimeElement(e,o);return n&&!this.placeAtDropPoint(i,n)||(this.recordHistory(),this.templateData.elements.push(i),this.select(new Set([i.id])),this.emit()),i}addFieldElement(e,o={},n){const i=m.createFieldElement(e);return Object.assign(i.options,o),n&&!this.placeAtDropPoint(i,n)||(this.recordHistory(),this.templateData.elements.push(i),this.select(new Set([i.id])),this.emit()),i}placeAtDropPoint(e,o){const n=this.templateData,i=m.zoneFromPaperPoint(n,o.x,o.y);if(i!=="content"&&!m.ZONE_ALLOWED_TYPES.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=m.getZoneRects(n)[i];return e.zone=i,e.options.left=o.x-r.left,e.options.top=o.y-r.top,i!=="content"&&m.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,o){const n=this.templateData.elements.find(r=>r.id===e);if(!n)return;const i=this.live.get(e)??n;this.live.set(e,{...i,options:{...i.options,...o}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[o,n]of this.live){const i=e.find(r=>r.id===o);i&&Object.assign(i.options,n.options)}this.live.clear(),this.emit()}dragIds(e){const o=this.templateData.elements.find(n=>n.id===e);return!o||o.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let o=!1;for(const n of this.elements){const i=e.get(n.id);!i||i===this.geoSig(n)||m.finalizeElementZone(n,this.templateData).rejected&&(o=!0)}o&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,o,n=!0){n&&this.recordHistory();const i=this.templateData.elements.find(r=>r.id===e);i&&(Object.assign(i.options,o),i.printElementType.type==="table"&&m.syncTableElementSize(i.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const o=this.templateData.elements,n=o.filter(r=>this.selectedIds.has(r.id)),i=o.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...i,...n];else if(e==="bottom")this.templateData.elements=[...n,...i];else{const r=o.findIndex(c=>this.selectedIds.has(c.id)),s=e==="up"?r+1:r-1;if(s<0||s>=o.length)return;const l=[...o];[l[r],l[s]]=[l[s],l[r]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(o=>this.selectedIds.has(o.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=Ke(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const o=new Map;for(const r of this.clipboard){const s=r.options.groupId;s&&o.set(s,(o.get(s)??0)+1)}const n=new Map;for(const[r,s]of o)n.set(r,s>=2?m.generateGroupId():void 0);const i=this.templateData.elements;for(const r of this.clipboard){const s=Ke(r);s.id=m.generateId(),s.options.left+=e,s.options.top+=e,s.options.groupId=s.options.groupId?n.get(s.options.groupId):void 0,i.push(s)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,o){const n=this.selectedElements.filter(i=>!i.options.locked);if(n.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const i of n)i.options.left+=e,i.options.top+=o;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:Ke(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();e&&(this.redoStack.push({pages:Ke(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:Ke(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,o=m.MIN_SCALE_PERCENT){this.scale=Math.max(o,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(pi),o=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(o)}loadTemplate(e){this.pages=mn(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return m.getPaperDimensions(this.templateData)}}const Me=Symbol("mixed"),Qt=new Set(["text","longText"]),gn=["top","right","bottom","left"],cr=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class pr{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(o=>o.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,o=this.tableElement?.options.tableRows;if(!e||!o)return[];const n=[];for(let i=e.r1;i<=e.r2;i++)for(let r=e.c1;r<=e.c2;r++){const s=o[i]?.cells[r];s&&!s.merged&&n.push(s)}return n}get textTargets(){return this.selectedElements.filter(e=>Qt.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const o=e[0];return e.every(n=>n===o)?o:Me}hasToken(e,o){return(e??"").split(/\s+/).includes(o)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const o=e.map(i=>i.fontWeight==="bold"||i.fontWeight==="bolder"),n=e.map(i=>i.textDecoration);return{fontFamily:this.pick(e.map(i=>i.fontFamily)),fontSize:this.pick(e.map(i=>i.fontSize)),color:this.pick(e.map(i=>i.color)),backgroundColor:this.pick(e.map(i=>i.backgroundColor)),textAlign:this.pick(e.map(i=>this.context==="cells"?i.align:i.textAlign)),verticalAlign:this.pick(e.map(i=>this.context==="cells"?i.valign:i.verticalAlign)),bold:o.every(Boolean)?!0:o.some(Boolean)?Me:!1,underline:n.map(i=>this.hasToken(i,"underline")).every(Boolean)?!0:n.some(i=>this.hasToken(i,"underline"))?Me:!1,strike:n.map(i=>this.hasToken(i,"line-through")).every(Boolean)?!0:n.some(i=>this.hasToken(i,"line-through"))?Me:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const o=this.targetCells;o.length&&(o.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const o=this.textTargets,n=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),s="backgroundColor"in e;!(o.length&&r)&&!(n.length&&s)||(o.forEach(l=>{const c=l.options;"fontFamily"in e&&(c.fontFamily=e.fontFamily),"fontSize"in e&&(c.fontSize=e.fontSize),"color"in e&&(c.color=e.color),"textAlign"in e&&(c.textAlign=e.textAlign),"verticalAlign"in e&&(c.verticalAlign=e.verticalAlign)}),s&&n.forEach(l=>{l.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const n=this.values.bold!==!0;this.writeCells(i=>{i.fontWeight=n?"bold":void 0});return}const e=this.values.bold!==!0,o=this.textTargets;o.length&&(o.forEach(n=>{n.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const o=this.textTargets;if(!o.length)return;const n=this.values[e==="underline"?"underline":"strike"]!==!0;o.forEach(i=>{const r=(i.options.textDecoration??"").split(/\s+/).filter(Boolean),s=r.indexOf(e);n&&s<0&&r.push(e),!n&&s>=0&&r.splice(s,1),i.options.textDecoration=r.length?r.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}borderSpec(){return{width:this.borderWidth,style:this.borderStyle,color:this.borderColor}}applyElementBorder(e,o){const n=this.selectedElements;n.length&&(n.forEach(i=>{i.options.borders=void 0,e==="none"?i.options.borderWidth=0:(i.options.borderWidth=o.width,i.options.borderStyle=o.style,i.options.borderColor=o.color)}),this.commit())}applyCellBorderPreset(e,o){const n=this.store.tableSelection,i=this.tableElement?.options.tableRows;!n||!i||(m.applyBorderPreset(i,{r1:n.r1,c1:n.c1,r2:n.r2,c2:n.c2},e,o),this.commit())}applyCellBorderEdges(e,o,n){this.writeCells(i=>{const r={...i.borders??{}};for(const s of e)n?r[s]={...o}:delete r[s];i.borders=r})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;if(!e.length)return null;const o={};for(const n of gn){const i=e.map(r=>!!r.borders?.[n]);o[n]=i.every(Boolean)?!0:i.some(Boolean)?Me:!1}return o}toggleCellEdge(e,o){const n=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],o,n)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;if(!e.length)return null;const o={};for(const n of gn){const i=e.map(r=>!!r.options.borders?.[n]);o[n]=i.every(Boolean)?!0:i.some(Boolean)?Me:!1}return o}toggleElementEdge(e,o){const n=this.selectedElements;if(!n.length)return;const i=this.elementEdges?.[e]!==!0;n.forEach(r=>{const s={...r.options.borders??{}};i?s[e]={width:o.width,style:o.style,color:o.color}:delete s[e],r.options.borders=s}),this.commit()}applyBorderPreset(e){this.context==="cells"?this.applyCellBorderPreset(e,this.borderSpec()):this.applyElementBorder(e==="none"?"none":"all",this.borderSpec())}applyEdge(e){this.context==="cells"?this.toggleCellEdge(e,this.borderSpec()):this.toggleElementEdge(e,this.borderSpec())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const o={};for(const n of m.ELEMENT_BORDER_SIDES){const i=e[n];i&&(o[n]={...i})}return o}pickPainterSource(e=!1){const o=this.selectedElements[0];if(!o)return!1;const n=o.options,i=o.printElementType.type;return this.painterSnapshot={text:Qt.has(i)?Object.fromEntries(cr.map(r=>[r,n[r]])):null,backgroundColor:n.backgroundColor,border:m.acceptsElementBorder(i)?{borderWidth:n.borderWidth,borderStyle:n.borderStyle,borderColor:n.borderColor,borders:this.clonePainterBorders(n.borders)}:null},this.painterSource=o.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const o=this.painterSnapshot;if(!o||e.options.locked||e.id===this.painterSource)return!1;const n=e.options,i=e.printElementType.type;return o.text&&Qt.has(i)&&Object.assign(n,o.text),n.backgroundColor=o.backgroundColor,o.border&&m.acceptsElementBorder(i)&&(n.borderWidth=o.border.borderWidth,n.borderStyle=o.border.borderStyle,n.borderColor=o.border.borderColor,n.borders=this.clonePainterBorders(o.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let o=!1;e.forEach(n=>{o=this.applyPainter(n)||o}),o&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const o=e.target?.tagName;o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||this.cancelPainter()}}function bn(t,e){(e==null||e>t.length)&&(e=t.length);for(var o=0,n=Array(e);o<e;o++)n[o]=t[o];return n}function ur(t){if(Array.isArray(t))return t}function hr(t,e){var o=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(o!=null){var n,i,r,s,l=[],c=!0,f=!1;try{if(r=(o=o.call(t)).next,e!==0)for(;!(c=(n=r.call(o)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(g){f=!0,i=g}finally{try{if(!c&&o.return!=null&&(s=o.return(),Object(s)!==s))return}finally{if(f)throw i}}return l}}function fr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mr(t,e){return ur(t)||hr(t,e)||gr(t,e)||fr()}function gr(t,e){if(t){if(typeof t=="string")return bn(t,e);var o={}.toString.call(t).slice(8,-1);return o==="Object"&&t.constructor&&(o=t.constructor.name),o==="Map"||o==="Set"?Array.from(t):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?bn(t,e):void 0}}const hi=Object.entries,xn=Object.setPrototypeOf,br=Object.isFrozen,xr=Object.getPrototypeOf,vr=Object.getOwnPropertyDescriptor;let K=Object.freeze,X=Object.seal,Xe=Object.create,fi=typeof Reflect<"u"&&Reflect,mo=fi.apply,go=fi.construct;K||(K=function(e){return e});X||(X=function(e){return e});mo||(mo=function(e,o){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return e.apply(o,i)});go||(go=function(e){for(var o=arguments.length,n=new Array(o>1?o-1:0),i=1;i<o;i++)n[i-1]=arguments[i];return new e(...n)});const Oe=Y(Array.prototype.forEach),yr=Y(Array.prototype.lastIndexOf),vn=Y(Array.prototype.pop),it=Y(Array.prototype.push),wr=Y(Array.prototype.splice),Je=Array.isArray,st=Y(String.prototype.toLowerCase),eo=Y(String.prototype.toString),yn=Y(String.prototype.match),rt=Y(String.prototype.replace),wn=Y(String.prototype.indexOf),Sr=Y(String.prototype.trim),Tr=Y(Number.prototype.toString),Er=Y(Boolean.prototype.toString),Sn=typeof BigInt>"u"?null:Y(BigInt.prototype.toString),Tn=typeof Symbol>"u"?null:Y(Symbol.prototype.toString),ie=Y(Object.prototype.hasOwnProperty),at=Y(Object.prototype.toString),Z=Y(RegExp.prototype.test),Ie=kr(TypeError);function Y(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var o=arguments.length,n=new Array(o>1?o-1:0),i=1;i<o;i++)n[i-1]=arguments[i];return mo(t,e,n)}}function kr(t){return function(){for(var e=arguments.length,o=new Array(e),n=0;n<e;n++)o[n]=arguments[n];return go(t,o)}}function L(t,e){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:st;if(xn&&xn(t,null),!Je(e))return t;let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const r=o(i);r!==i&&(br(e)||(e[n]=r),i=r)}t[i]=!0}return t}function Cr(t){for(let e=0;e<t.length;e++)ie(t,e)||(t[e]=null);return t}function ae(t){const e=Xe(null);for(const n of hi(t)){var o=mr(n,2);const i=o[0],r=o[1];ie(t,i)&&(Je(r)?e[i]=Cr(r):r&&typeof r=="object"&&r.constructor===Object?e[i]=ae(r):e[i]=r)}return e}function Ar(t){switch(typeof t){case"string":return t;case"number":return Tr(t);case"boolean":return Er(t);case"bigint":return Sn?Sn(t):"0";case"symbol":return Tn?Tn(t):"Symbol()";case"undefined":return at(t);case"function":case"object":{if(t===null)return at(t);const e=t,o=ue(e,"toString");if(typeof o=="function"){const n=o(e);return typeof n=="string"?n:at(n)}return at(t)}default:return at(t)}}function ue(t,e){for(;t!==null;){const n=vr(t,e);if(n){if(n.get)return Y(n.get);if(typeof n.value=="function")return Y(n.value)}t=xr(t)}function o(){return null}return o}function Dr(t){try{return Z(t,""),!0}catch{return!1}}const En=K(["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"]),to=K(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),oo=K(["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"]),Mr=K(["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"]),no=K(["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"]),_r=K(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),kn=K(["#text"]),Cn=K(["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"]),io=K(["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"]),An=K(["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"]),Ct=K(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),zr=X(/{{[\w\W]*|^[\w\W]*}}/g),Pr=X(/<%[\w\W]*|^[\w\W]*%>/g),Rr=X(/\${[\w\W]*/g),Ir=X(/^data-[\-\w.\u00B7-\uFFFF]+$/),Lr=X(/^aria-[\-\w]+$/),Dn=X(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Fr=X(/^(?:\w+script|data):/i),Or=X(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Nr=X(/^html$/i),$r=X(/^[a-z][.\w]*(-[.\w]+)+$/i),Mn=X(/<[/\w!]/g),_n=X(/<[/\w]/g),Br=X(/<\/no(script|embed|frames)/i),Hr=X(/\/>/i),re={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},mi=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Ur=K(L({},mi)),Wr=(function(){const t={};return Oe(mi,e=>{t[e]=X(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),K(t)})(),Gr=function(){return typeof window>"u"?null:window},qr=function(e,o){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";o&&o.hasAttribute(i)&&(n=o.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},zn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ae=function(e,o,n,i){return ie(e,o)&&Je(e[o])?L(i.base?ae(i.base):{},e[o],i.transform):n},ro=function(e,o,n){const i=ie(e,o)?e[o]:void 0;return i&&typeof i=="object"?ae(i):n()};function gi(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Gr();const e=y=>gi(y);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==re.document||!t.Element)return e.isSupported=!1,e;let o=t.document;const n=o,i=n.currentScript;t.DocumentFragment;const r=t.HTMLTemplateElement,s=t.Node,l=t.Element,c=t.NodeFilter,f=t.NamedNodeMap;f===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const g=t.DOMParser,u=t.trustedTypes,h=l.prototype,A=ue(h,"cloneNode"),x=ue(h,"remove"),S=ue(h,"nextSibling"),T=ue(h,"childNodes"),k=ue(h,"parentNode"),z=ue(h,"shadowRoot"),v=ue(h,"attributes"),w=s&&s.prototype?ue(s.prototype,"nodeType"):null,I=s&&s.prototype?ue(s.prototype,"nodeName"):null,V=s&&s.prototype?ue(s.prototype,"ownerDocument"):null,P=function(d){return w?w(d):d.nodeType},_=function(d){return I?I(d):d.nodeName};if(typeof r=="function"){const y=o.createElement("template");y.content&&y.content.ownerDocument&&(o=y.content.ownerDocument)}let O,$="",be,Q=!1,ce=0;const Te=function(){if(ce>0)throw Ie('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.')},xe=function(d){Te(),ce++;try{return O.createHTML(d)}finally{ce--}},Ri=function(d){Te(),ce++;try{return O.createScriptURL(d)}finally{ce--}},Ii=function(){return Q||(be=qr(u,i),Q=!0),be},ht=o,Ot=ht.implementation,No=ht.createNodeIterator,Li=ht.createDocumentFragment,Fi=ht.getElementsByTagName,Oi=n.importNode;let H=zn();e.isSupported=typeof hi=="function"&&typeof k=="function"&&Ot&&Ot.createHTMLDocument!==void 0;const Ni=zr,$i=Pr,Bi=Rr,Hi=Ir,Ui=Lr,Wi=Fr,$o=Or,Gi=$r;let Bo=Dn,U=null;const Nt=L({},[...En,...to,...oo,...no,...kn]);let W=null;const $t=L({},[...Cn,...io,...An,...Ct]);let he=Object.seal(Xe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),tt=null,Ho=null;const Ee=Object.seal(Xe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Uo=!0,Bt=!0,Wo=!1,Go=!0,ke=!1,ze=!0,Pe=!1,Ht=!1,ft=null,mt=null,Ut=!1,Ue=!1,gt=!1,bt=!1,qo=!0,jo=!1;const Yo="user-content-";let Wt=!0,Gt=!1,We={},Ge=null;const Ko=L({},["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 Vo=null;const Xo=L({},["audio","video","img","source","image","track"]);let Zo=null;const Jo=L({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xt="http://www.w3.org/1998/Math/MathML",vt="http://www.w3.org/2000/svg",fe="http://www.w3.org/1999/xhtml";let qe=fe,qt=!1,jt=null;const qi=L({},[xt,vt,fe],eo),Qo=K(["mi","mo","mn","ms","mtext"]);let Yt=L({},Qo);const en=K(["annotation-xml"]);let Kt=L({},en);const ji=L({},["title","style","font","a","script"]);let ot=null;const Yi=["application/xhtml+xml","text/html"],Ki="text/html";let j=null,je=null;const Vi=o.createElement("form"),tn=function(d){return d instanceof RegExp||d instanceof Function},Vt=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(je&&je===d)return;(!d||typeof d!="object")&&(d={}),d=ae(d),ot=Yi.indexOf(d.PARSER_MEDIA_TYPE)===-1?Ki:d.PARSER_MEDIA_TYPE,j=ot==="application/xhtml+xml"?eo:st,U=Ae(d,"ALLOWED_TAGS",Nt,{transform:j}),W=Ae(d,"ALLOWED_ATTR",$t,{transform:j}),jt=Ae(d,"ALLOWED_NAMESPACES",qi,{transform:eo}),Zo=Ae(d,"ADD_URI_SAFE_ATTR",Jo,{transform:j,base:Jo}),Vo=Ae(d,"ADD_DATA_URI_TAGS",Xo,{transform:j,base:Xo}),Ge=Ae(d,"FORBID_CONTENTS",Ko,{transform:j}),tt=Ae(d,"FORBID_TAGS",ae({}),{transform:j}),Ho=Ae(d,"FORBID_ATTR",ae({}),{transform:j}),We=ie(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?ae(d.USE_PROFILES):d.USE_PROFILES:!1,Uo=d.ALLOW_ARIA_ATTR!==!1,Bt=d.ALLOW_DATA_ATTR!==!1,Wo=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Go=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ke=d.SAFE_FOR_TEMPLATES||!1,ze=d.SAFE_FOR_XML!==!1,Pe=d.WHOLE_DOCUMENT||!1,Ue=d.RETURN_DOM||!1,gt=d.RETURN_DOM_FRAGMENT||!1,bt=d.RETURN_TRUSTED_TYPE||!1,Ut=d.FORCE_BODY||!1,qo=d.SANITIZE_DOM!==!1,jo=d.SANITIZE_NAMED_PROPS||!1,Wt=d.KEEP_CONTENT!==!1,Gt=d.IN_PLACE||!1,Bo=Dr(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Dn,qe=typeof d.NAMESPACE=="string"?d.NAMESPACE:fe,Yt=ro(d,"MATHML_TEXT_INTEGRATION_POINTS",()=>L({},Qo)),Kt=ro(d,"HTML_INTEGRATION_POINTS",()=>L({},en));const p=ro(d,"CUSTOM_ELEMENT_HANDLING",()=>Xe(null));if(he=Xe(null),ie(p,"tagNameCheck")&&tn(p.tagNameCheck)&&(he.tagNameCheck=p.tagNameCheck),ie(p,"attributeNameCheck")&&tn(p.attributeNameCheck)&&(he.attributeNameCheck=p.attributeNameCheck),ie(p,"allowCustomizedBuiltInElements")&&typeof p.allowCustomizedBuiltInElements=="boolean"&&(he.allowCustomizedBuiltInElements=p.allowCustomizedBuiltInElements),X(he),ke&&(Bt=!1),gt&&(Ue=!0),We&&(U=L({},kn),W=Xe(null),We.html===!0&&(L(U,En),L(W,Cn)),We.svg===!0&&(L(U,to),L(W,io),L(W,Ct)),We.svgFilters===!0&&(L(U,oo),L(W,io),L(W,Ct)),We.mathMl===!0&&(L(U,no),L(W,An),L(W,Ct))),Ee.tagCheck=null,Ee.attributeCheck=null,ie(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?Ee.tagCheck=d.ADD_TAGS:Je(d.ADD_TAGS)&&(U===Nt&&(U=ae(U)),L(U,d.ADD_TAGS,j))),ie(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?Ee.attributeCheck=d.ADD_ATTR:Je(d.ADD_ATTR)&&(W===$t&&(W=ae(W)),L(W,d.ADD_ATTR,j))),ie(d,"ADD_FORBID_CONTENTS")&&Je(d.ADD_FORBID_CONTENTS)&&(Ge===Ko&&(Ge=ae(Ge)),L(Ge,d.ADD_FORBID_CONTENTS,j)),Wt&&(U["#text"]=!0),Pe&&L(U,["html","head","body"]),U.table&&(L(U,["tbody"]),delete tt.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ie('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ie('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const b=O;O=d.TRUSTED_TYPES_POLICY;try{$=xe("")}catch(E){throw O=b,E}}else d.TRUSTED_TYPES_POLICY===null?(O=void 0,$=""):(O===void 0&&(O=Ii()),O&&typeof $=="string"&&($=xe("")));K&&K(d),je=d},on=L({},[...to,...oo,...Mr]),nn=L({},[...no,..._r]),Xi=function(d,p,b){return p.namespaceURI===fe?d==="svg":p.namespaceURI===xt?d==="svg"&&(b==="annotation-xml"||Yt[b]):!!on[d]},Zi=function(d,p,b){return p.namespaceURI===fe?d==="math":p.namespaceURI===vt?d==="math"&&Kt[b]:!!nn[d]},Ji=function(d,p,b){return p.namespaceURI===vt&&!Kt[b]||p.namespaceURI===xt&&!Yt[b]?!1:!nn[d]&&(ji[d]||!on[d])},Qi=function(d){let p=k(d);(!p||!p.tagName)&&(p={namespaceURI:qe,tagName:"template"});const b=st(d.tagName),E=st(p.tagName);return jt[d.namespaceURI]?d.namespaceURI===vt?Xi(b,p,E):d.namespaceURI===xt?Zi(b,p,E):d.namespaceURI===fe?Ji(b,p,E):!!(ot==="application/xhtml+xml"&&jt[d.namespaceURI]):!1},Ce=function(d){it(e.removed,{element:d});try{k(d).removeChild(d)}catch{if(x(d),!k(d))throw Ie("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},rn=function(d,p,b){try{d.removeAttributeNode(p)}catch{try{d.removeAttribute(b)}catch{}}},yt=function(d){wt(d);const p=T(d);if(p){const E=[];Oe(p,C=>{it(E,C)}),Oe(E,C=>{try{x(C)}catch{}})}const b=v(d);if(b)for(let E=b.length-1;E>=0;--E){const C=b[E],D=C&&C.name;typeof D=="string"&&rn(d,C,D)}},Re=function(d,p,b){if(!b)try{b=p.getAttributeNode(d)}catch{b=null}it(e.removed,{attribute:b||null,from:p});try{b?p.removeAttributeNode(b):p.removeAttribute(d)}catch{try{p.removeAttribute(d)}catch{}}if(d==="is")if(Ue||gt)try{Ce(p)}catch{}else try{p.setAttribute(d,"")}catch{}},er=function(d){const p=v(d);if(p)for(let b=p.length-1;b>=0;--b){const E=p[b],C=E&&E.name;typeof C!="string"||W[j(C)]||rn(d,E,C)}},wt=function(d){const p=[d];for(;p.length>0;){const b=p.pop();P(b)===re.element&&er(b);const C=T(b);if(C)for(let D=C.length-1;D>=0;--D)p.push(C[D])}},an=function(d,p){return ze?d==="patchsrc"?!0:d==="for"&&p!=="label"&&p!=="output":!1},tr=function(d){if(!ze)return;const p=[d];for(;p.length>0;){const b=p.pop(),E=P(b);if(E===re.processingInstruction||E===re.comment&&Z(_n,b.data)){try{x(b)}catch{}continue}if(E===re.element){const D=b,B=j(_(b));try{D.hasAttribute&&D.hasAttribute("patchsrc")&&D.removeAttribute("patchsrc"),D.hasAttribute&&D.hasAttribute("for")&&an("for",B)&&D.removeAttribute("for")}catch{}}const C=T(b);if(C)for(let D=C.length-1;D>=0;--D)p.push(C[D])}},sn=function(d){let p=null,b=null;if(Ut)d="<remove></remove>"+d;else{const D=yn(d,/^[\r\n\t ]+/);b=D&&D[0]}ot==="application/xhtml+xml"&&qe===fe&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const E=O?xe(d):d;if(qe===fe)try{p=new g().parseFromString(E,ot)}catch{}if(!p||!p.documentElement){p=Ot.createDocument(qe,"template",null);try{p.documentElement.innerHTML=qt?$:E}catch{}}const C=p.body||p.documentElement;return d&&b&&C.insertBefore(o.createTextNode(b),C.childNodes[0]||null),qe===fe?Fi.call(p,Pe?"html":"body")[0]:Pe?p.documentElement:C},ln=function(d){const p=V?V(d):d.ownerDocument;return No.call(p||d,d,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},St=function(d){return d=rt(d,Ni," "),d=rt(d,$i," "),d=rt(d,Bi," "),d},Xt=function(d){var p;d.normalize();const b=V?V(d):d.ownerDocument,E=No.call(b||d,d,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let C=E.nextNode();for(;C;)C.data=St(C.data),C=E.nextNode();const D=(p=d.querySelectorAll)===null||p===void 0?void 0:p.call(d,"template");D&&Oe(D,B=>{Ye(B.content)&&Xt(B.content)})},Tt=function(d){const p=I?I(d):null;return typeof p!="string"||j(p)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==v(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==w(d)||d.childNodes!==T(d)},Ye=function(d){if(!w||typeof d!="object"||d===null)return!1;try{return w(d)===re.documentFragment}catch{return!1}},nt=function(d){if(!w||typeof d!="object"||d===null)return!1;try{return typeof w(d)=="number"}catch{return!1}};function me(y,d,p){y.length!==0&&Oe(y,b=>{b.call(e,d,p,je)})}const or=function(d,p){return!!(ze&&d.hasChildNodes()&&!nt(d.firstElementChild)&&Z(Mn,d.textContent)&&Z(Mn,d.innerHTML)||ze&&d.namespaceURI===fe&&Ur[p]&&(nt(d.firstElementChild)||typeof d.textContent=="string"&&Z(Wr[p],d.textContent))||d.nodeType===re.processingInstruction||ze&&d.nodeType===re.comment&&Z(_n,d.data))},Et=function(d,p){if(d instanceof RegExp)return Z(d,p);if(d instanceof Function){for(var b=arguments.length,E=new Array(b>2?b-2:0),C=2;C<b;C++)E[C-2]=arguments[C];return!!d(p,...E)}return!1},nr=function(d,p,b){if(!tt[p]&&hn(p)&&Et(he.tagNameCheck,p))return!1;if(Wt&&!Ge[p]){const E=k(d),C=T(d);if(C&&E){const D=C.length;for(let B=D-1;B>=0;--B){const G=d===b?A(C[B],!0):C[B];E.insertBefore(G,S(d))}}}return Ce(d),!0},dn=function(d,p,b,E){return d.length===0?p:p===b||p===E?ae(p):p},cn=function(d,p){return d===p||k(d)!==null?!1:(Gt&&wt(d),!0)},pn=function(d,p){if(me(H.beforeSanitizeElements,d,null),cn(d,p))return!0;if(Tt(d))return Ce(d),!0;const b=j(_(d));if(U=dn(H.uponSanitizeElement,U,Nt,ft),me(H.uponSanitizeElement,d,{tagName:b,allowedTags:U}),cn(d,p))return!0;if(or(d,b))return Ce(d),!0;if(tt[b]||!(Ee.tagCheck instanceof Function&&Ee.tagCheck(b))&&!U[b]){const C=nr(d,b,p);return C===!1&&me(H.afterSanitizeElements,d,null),C}if(P(d)===re.element&&!Qi(d)||(b==="noscript"||b==="noembed"||b==="noframes")&&Z(Br,d.innerHTML))return Ce(d),!0;if(ke&&d.nodeType===re.text){const C=St(d.textContent);d.textContent!==C&&(it(e.removed,{element:d.cloneNode()}),d.textContent=C)}return me(H.afterSanitizeElements,d,null),!1},un=function(d,p,b){if(Ho[p]||an(p,d)||qo&&(p==="id"||p==="name")&&(b in o||b in Vi))return!1;const E=W[p]||Ee.attributeCheck instanceof Function&&Ee.attributeCheck(p,d);return Bt&&Z(Hi,p)||Uo&&Z(Ui,p)?!0:E?Zo[p]||Z(Bo,rt(b,$o,""))||(p==="src"||p==="xlink:href"||p==="href")&&d!=="script"&&wn(b,"data:")===0&&Vo[d]||Wo&&!Z(Wi,rt(b,$o,""))?!0:!b:hn(d)&&Et(he.tagNameCheck,d)&&Et(he.attributeNameCheck,p,d)||p==="is"&&he.allowCustomizedBuiltInElements&&Et(he.tagNameCheck,b)},ir=L({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),hn=function(d){return!ir[st(d)]&&Z(Gi,d)},rr=function(d,p,b,E){if(O&&typeof u=="object"&&typeof u.getAttributeType=="function"&&!b)switch(u.getAttributeType(d,p)){case"TrustedHTML":return xe(E);case"TrustedScriptURL":return Ri(E)}return E},ar=function(d,p,b,E){try{b?d.setAttributeNS(b,p,E):d.setAttribute(p,E),Tt(d)?Ce(d):vn(e.removed)}catch{Re(p,d)}},fn=function(d){me(H.beforeSanitizeAttributes,d,null);const p=d.attributes;if(!p||Tt(d))return;W=dn(H.uponSanitizeAttribute,W,$t,mt);const b={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let E=p.length;const C=j(d.nodeName);for(;E--;){const D=p[E],B=D.name,G=D.namespaceURI,oe=D.value,ne=j(B),Jt=oe;let ee=B==="value"?Jt:Sr(Jt);if(b.attrName=ne,b.attrValue=ee,b.keepAttr=!0,b.forceKeepAttr=void 0,me(H.uponSanitizeAttribute,d,b),ee=b.attrValue,jo&&(ne==="id"||ne==="name")&&wn(ee,Yo)!==0&&(Re(B,d,D),ee=Yo+ee),ze&&Z(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ee)){Re(B,d,D);continue}if(ne==="attributename"&&yn(ee,"href")){Re(B,d,D);continue}if(!b.forceKeepAttr){if(!b.keepAttr){Re(B,d,D);continue}if(!Go&&Z(Hr,ee)){Re(B,d,D);continue}if(ke&&(ee=St(ee)),!un(C,ne,ee)){Re(B,d,D);continue}ee=rr(C,ne,G,ee),ee!==Jt&&ar(d,B,G,ee)}}me(H.afterSanitizeAttributes,d,null)},kt=function(d){let p=null;const b=ln(d);for(me(H.beforeSanitizeShadowDOM,d,null);p=b.nextNode();)if(me(H.uponSanitizeShadowNode,p,null),pn(p,d),fn(p),Ye(p.content)&&kt(p.content),P(p)===re.element){const E=z(p);Ye(E)&&(Zt(E),kt(E))}me(H.afterSanitizeShadowDOM,d,null)},Zt=function(d){const p=[{node:d,shadow:null}];for(;p.length>0;){const b=p.pop();if(b.shadow){kt(b.shadow);continue}const E=b.node,D=P(E)===re.element,B=T(E);if(B)for(let G=B.length-1;G>=0;--G)p.push({node:B[G],shadow:null});if(D){const G=I?I(E):null;if(typeof G=="string"&&j(G)==="template"){const oe=E.content;Ye(oe)&&p.push({node:oe,shadow:null})}}if(D){const G=z(E);Ye(G)&&p.push({node:null,shadow:G},{node:G,shadow:null})}}};return e.sanitize=function(y){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},p=null,b=null,E=null,C=null;if(qt=!y,qt&&(y="<!-->"),typeof y!="string"&&!nt(y)&&(y=Ar(y),typeof y!="string"))throw Ie("dirty is not a string, aborting");if(!e.isSupported)return y;Ht?(U=ft,W=mt):Vt(d),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(U=ae(U)),H.uponSanitizeAttribute.length>0&&(W=ae(W)),e.removed=[];const D=Gt&&typeof y!="string"&&nt(y);if(D){tr(y);const oe=_(y);if(typeof oe=="string"){const ne=j(oe);if(!U[ne]||tt[ne])throw yt(y),Ie("root node is forbidden and cannot be sanitized in-place")}if(Tt(y))throw yt(y),Ie("root node is clobbered and cannot be sanitized in-place");try{Zt(y)}catch(ne){throw yt(y),ne}}else if(nt(y))p=sn("<!---->"),b=p.ownerDocument.importNode(y,!0),b.nodeType===re.element&&b.nodeName==="BODY"||b.nodeName==="HTML"?p=b:p.appendChild(b),Zt(b);else{if(!Ue&&!ke&&!Pe&&y.indexOf("<")===-1)return O&&bt?xe(y):y;if(p=sn(y),!p)return Ue?null:bt?$:""}p&&Ut&&Ce(p.firstChild);const B=D?y:p;try{const oe=ln(B);for(;E=oe.nextNode();)pn(E,B),fn(E),Ye(E.content)&&kt(E.content)}catch(oe){throw D&&(yt(y),Oe(e.removed,ne=>{ne.element&&wt(ne.element)})),oe}if(D)return Oe(e.removed,oe=>{oe.element&&wt(oe.element)}),ke&&Xt(y),y;if(Ue){if(ke&&Xt(p),gt)for(C=Li.call(p.ownerDocument);p.firstChild;)C.appendChild(p.firstChild);else C=p;return(W.shadowroot||W.shadowrootmode)&&(C=Oi.call(n,C,!0)),C}let G=Pe?p.outerHTML:p.innerHTML;return Pe&&U["!doctype"]&&p.ownerDocument&&p.ownerDocument.doctype&&p.ownerDocument.doctype.name&&Z(Nr,p.ownerDocument.doctype.name)&&(G="<!DOCTYPE "+p.ownerDocument.doctype.name+`>
3
- `+G),ke&&(G=St(G)),O&&bt?xe(G):G},e.setConfig=function(){let y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Vt(y),Ht=!0,ft=U,mt=W},e.clearConfig=function(){je=null,Ht=!1,ft=null,mt=null,O=be,$=""},e.isValidAttribute=function(y,d,p){je||Vt({});const b=j(y),E=j(d);return un(b,E,p)},e.addHook=function(y,d){typeof d=="function"&&ie(H,y)&&it(H[y],d)},e.removeHook=function(y,d){if(ie(H,y)){if(d!==void 0){const p=yr(H[y],d);return p===-1?void 0:wr(H[y],p,1)[0]}return vn(H[y])}},e.removeHooks=function(y){ie(H,y)&&(H[y]=[])},e.removeAllHooks=function(){H=zn()},e}var jr=gi();const Yr={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Kr(t){const e=t.options;return String(e.testData||e.formatter||e.title||"")||"条码"}function Vr(t){return a("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function Xr(t){const e=t.options;return a("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:Yr[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function Zr(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(o=>!Number.isFinite(o))?null:{width:e[2],height:e[3]}}function Jr(t,e){const o=t.options,n=m.barcodeUnitsPerModule(o.barWidth);try{li(e,Kr(t),{format:String(o.barcodeType||"CODE128"),width:n,height:m.BARCODE_BAR_HEIGHT_MODULES*n,displayValue:!o.hideTitle,fontSize:(o.fontSize??m.BARCODE_TEXT_FONT_SIZE_MODULES)*n,margin:0,marginLeft:m.BARCODE_QUIET_ZONE_MODULES*n,marginRight:m.BARCODE_QUIET_ZONE_MODULES*n,marginTop:0,marginBottom:m.BARCODE_MARGIN_BOTTOM_MODULES*n})}catch{e.replaceChildren();return}const i=Zr(e),r=i?m.resolveBarcodeSize({unitWidth:i.width/n,unitHeight:i.height/n,boxWidthMm:m.barcodeAvailableBoxMm(o.width,o.maxWidth),boxHeightMm:m.barcodeAvailableBoxMm(o.height,o.maxHeight),dpi:o.printerDpi,barWidth:o.barWidth}):null;e.style.width=r?`${r.widthMm}mm`:"",e.style.height=r?`${r.heightMm}mm`:"",e.setAttribute("shape-rendering","crispEdges")}function Qr(t,e){const o=t.options,n=String(o.testData||o.formatter||o.title||"")||"二维码";e.replaceChildren();try{const i=To.browserCodeRenderer.render(n,"qrcode",{qrCodeLevel:String(o.qrCodeLevel??"M"),qrQuietZone:typeof o.qrQuietZone=="number"?o.qrQuietZone:void 0}),r=document.createElement("img");r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,r.alt="qrcode",r.style.width="100%",r.style.height="100%",r.style.objectFit=String(o.fit||"contain"),r.style.maxWidth=o.maxWidth?`${o.maxWidth}mm`:"100%",r.style.maxHeight=o.maxHeight?`${o.maxHeight}mm`:"100%",e.appendChild(r)}catch{}}function ea(t,e){for(const o of Array.from(t.querySelectorAll("[data-code-kind]"))){const n=o.dataset.codeId,i=e.find(r=>r.id===n);if(i)if(o.dataset.codeKind==="barcode"){const r=o.querySelector("svg");r&&Jr(i,r)}else Qr(i,o)}}const ta={header:"题",data:"数",subtotal:"小",summary:"汇"},oa=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],_t=3.7795275591,na=.1,bo=t=>JSON.parse(JSON.stringify(t)),Pn=new WeakMap;function Se(t){let e=Pn.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Pn.set(t,e)),e}function ut(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function ia(t,e){const o=t.tableSelection;return!o||o.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):o}function bi(t,e,o){const n=ut(t,o.id);if(!n)return null;const i=o.options;return{store:t,fire:e,el:o,real:n,options:i,rows:i.tableRows??[],colWidths:i.tableColWidths??[],isSelected:t.selectedIds.has(o.id),selection:ia(t,o),maxTableWidth:xi(t)}}function xi(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function ko(t){return t.options.tableDefaultFontSize??10}function vi(t){return t.options.tableDefaultColor??"#333333"}function ra(t,e){let o=0;for(let n=0;n<e;n++)o+=t.rows[n].height;return o}function aa(t,e){return Se(t.store).layouts.get(t.el.id)?.[e]?.top??ra(t,e)}function sa(t,e){return Se(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function la(t){const e=t.options.dataSource;if(e&&Array.isArray(m.DEFAULT_DEMO_DATA[e]))return m.DEFAULT_DEMO_DATA[e];for(const o of Object.values(m.DEFAULT_DEMO_DATA))if(Array.isArray(o))return o}function yi(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function wi(t,e){return yi(e)?m.resolveBarcodeDesignValue(e.formatter,la(t)):e.formatter||""}function da(t,e){const o={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:e.fontFamily||"inherit",textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??ko(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??vi(t),backgroundColor:e.backgroundColor??"transparent",borderTop:m.resolveCellBorderCss(e.borders?.top,o),borderRight:m.resolveCellBorderCss(e.borders?.right,o),borderBottom:m.resolveCellBorderCss(e.borders?.bottom,o),borderLeft:m.resolveCellBorderCss(e.borders?.left,o),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"normal":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ca(t,e,o){const n=t.selection;return[!!n&&e>=n.r1&&e<=n.r2&&o>=n.c1&&o<=n.c2?"cell-selected":"",t.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Si(t){return m.resolveCellTextFit(t)}function pa(t){return Si(t)!=="autoHeight"}function ua(t,e){return e.fontSize??ko(t)}function Co(t,e,o){return m.cellFitCapMm(t.rows,e,o,t.options.tableDefaultPadding??1)}function ha(t,e,o){return m.cellFitWidthMm(t.colWidths,e,o,t.options.tableDefaultPadding??1)}function fa(t,e,o){return{maxHeight:Co(t,o,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function ma(t,e,o){const n={fitBase:String(ua(t,e)),fitMin:String(m.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(Co(t,o,e))};return Si(e)==="shrink"&&(n.fit="shrink"),n}function ga(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(o=>!Number.isFinite(o))?null:{width:e[2],height:e[3]}}const ba={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function xa(t,e,o,n){const i=document.createElement("div");i.className="cell-barcode";const r=document.createElementNS(dr,"svg");i.appendChild(r);const s=wi(t,n);if(n.cellType==="barcode"){r.setAttribute("preserveAspectRatio",ba[n.fit||"contain"]??"xMidYMid meet");const l=m.barcodeUnitsPerModule(n.barWidth);let c=!0;try{li(r,s,{format:n.barcodeType||"CODE128",width:l,height:m.BARCODE_BAR_HEIGHT_MODULES*l,displayValue:n.showBarcodeText!==!1,fontSize:(n.barFontSize??m.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:m.BARCODE_QUIET_ZONE_MODULES*l,marginRight:m.BARCODE_QUIET_ZONE_MODULES*l,marginTop:0,marginBottom:m.BARCODE_MARGIN_BOTTOM_MODULES*l})}catch{c=!1}if(!c){r.style.display="none";const u=document.createElement("span");return u.className="cell-barcode-fallback",u.textContent=s||"条码",i.appendChild(u),i}const f=ga(r),g=f?m.resolveBarcodeSize({unitWidth:f.width/l,unitHeight:f.height/l,boxWidthMm:m.barcodeAvailableBoxMm(ha(t,o,n),n.maxWidth),boxHeightMm:m.barcodeAvailableBoxMm(Co(t,e,n),n.maxHeight),dpi:n.printerDpi,barWidth:n.barWidth}):null;return g?(r.style.width=`${g.widthMm}mm`,r.style.height=`${g.heightMm}mm`):(r.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",r.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),i}if(r.style.display="none",!s)return i;try{const l=To.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(n.qrCodeLevel||"M"),qrQuietZone:typeof n.qrQuietZone=="number"?n.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=n.fit||"contain",n.objectPosition&&(c.style.objectPosition=n.objectPosition),c.style.maxWidth=n.maxWidth?`${n.maxWidth}mm`:"100%",c.style.maxHeight=n.maxHeight?`${n.maxHeight}mm`:"100%",i.appendChild(c)}catch{}return i}function Rn(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function va(t){const e=t.formatter||"";return e?e.includes("{")?m.evaluateTemplate(e,m.DEFAULT_DEMO_DATA):e:""}function ya(t){const e=document.createElement("div");e.className="cell-image";const o=va(t);if(!o)return e.appendChild(Rn()),e;const n=document.createElement("img");return n.setAttribute("src",o),n.style.objectFit=t.fit||"contain",t.objectPosition&&(n.style.objectPosition=t.objectPosition),n.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",n.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",n.addEventListener("error",()=>{n.remove(),e.appendChild(Rn())},{once:!0}),e.appendChild(n),e}function wa(t,e,o,n,i){if(yi(i))return xa(t,o,n,i);if(i.cellType==="image")return ya(i);const r=wi(t,i),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return pa(i)?a("div",{class:"cell-fit",style:fa(t,i,o),dataset:ma(t,i,o)},[s()]):s()}function Pt(t,e,o){const n={elementId:t.el.id,...m.normalizeSelection(t.rows,e,o)};t.store.setTableSelection(n),t.fire("table-selection-change",{elementId:t.el.id,selection:n})}function Sa(t,e,o,n,i){if(i.button!==0||(t.fire("table-cell-mousedown",{elementId:t.el.id,r:e,c:o,cellId:n,event:i}),!t.isSelected))return;i.stopPropagation();const r=Se(t.store);i.shiftKey&&t.selection?Pt(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:o}):(r.anchor={r:e,c:o},Pt(t,{r:e,c:o},{r:e,c:o})),document.addEventListener("mouseup",()=>{Se(t.store).anchor=null},{once:!0})}function Ta(t,e,o){const n=Se(t.store).anchor;n&&Pt(t,n,{r:e,c:o})}function Ti(t,e){const o=Se(t);o.menu?.visible&&(o.menu.visible=!1,e("table-menu-close",{elementId:o.menuElId}),t.emit(!1))}function Ea(t,e,o,n){n.preventDefault(),n.stopPropagation(),t.isSelected||t.store.selectOne(t.el.id);const i=t.selection;i&&e>=i.r1&&e<=i.r2&&o>=i.c1&&o<=i.c2||Pt(t,{r:e,c:o},{r:e,c:o});const s=Se(t.store);s.menuElId=t.el.id,s.menu&&(s.menu.x=n.clientX,s.menu.y=n.clientY,s.menu.visible=!0),t.fire("table-cell-contextmenu",{elementId:t.el.id,r:e,c:o,clientX:n.clientX,clientY:n.clientY}),t.store.emit(!1),document.addEventListener("mousedown",()=>Ti(t.store,t.fire),{once:!0})}function In(t,e,o){const n=t.reduce((i,r)=>i+r,0)+(t[e]??0);return n>o?`插入后表格总宽 ${Math.round(n*10)/10}mm 超过打印范围宽度 ${o}mm,请先缩小列宽`:null}function ka(t,e){const o=t.real.options.tableRows??[],n=t.real.options.tableColWidths??[],i=e(bo(o),bo(n));return i?(window.alert(i),!1):(t.store.recordHistory(),e(o,n),t.store.setTableSelection(null),m.syncTableElementSize(t.real.options),t.store.emit(),!0)}function ve(t,e,o){Ti(t.store,t.fire);const n=t.selection;if(!n)return;let i=null;switch(e){case"insert-row-above":i=r=>(m.insertRow(r,n.r1,"above"),null);break;case"insert-row-below":i=r=>(m.insertRow(r,n.r2,"below"),null);break;case"delete-row":i=r=>m.deleteRow(r,n.r1);break;case"insert-col-left":i=(r,s)=>{const l=In(s,n.c1,t.maxTableWidth);return l||(m.insertCol(r,s,n.c1,"left"),null)};break;case"insert-col-right":i=(r,s)=>{const l=In(s,n.c2,t.maxTableWidth);return l||(m.insertCol(r,s,n.c2,"right"),null)};break;case"delete-col":i=(r,s)=>m.deleteCol(r,s,n.c1);break;case"merge":i=r=>(m.mergeCells(r,n),null);break;case"split":i=r=>(m.splitCells(r,n),null);break;case"set-row-type":i=r=>o?m.setRowType(r,n.r1,o):"未指定行类型";break}i&&ka(t,i)&&t.fire(`table-${e}`,{elementId:t.el.id,...o?{type:o}:{}})}function Ca(t){const e=t.selection;if(!e)return!1;for(let o=e.r1;o<=e.r2;o++)for(let n=e.c1;n<=e.c2;n++){const i=t.rows[o]?.cells[n];if(i&&!i.merged&&((i.rowspan??1)>1||(i.colspan??1)>1))return!0}return!1}function Ln(t,e){const o=t.selection;return o?o.r1!==o.r2?"行类型仅支持单行设置":m.setRowType(bo(t.rows),o.r1,e):"未选择单元格"}function ye(t,e,o={}){return a("div",{class:`menu-item${o.disabled?" disabled":""}${o.active?" active":""}`,title:o.title||"",text:t,onClick:()=>{o.disabled||e()}})}const ao=()=>a("div",{class:"menu-divider"});function Aa(t,e,o){const n=Se(t);if(n.menu=o,!o.visible||!n.menuElId)return"";const i=ut(t,n.menuElId);if(!i||i.printElementType.type!=="table")return"";const r=bi(t,e,i);if(!r)return"";const s=r.selection?m.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:o.x+"px",top:o.y+"px"},onMousedown:c=>c.stopPropagation()},[ye("在上方插入行",()=>ve(r,"insert-row-above")),ye("在下方插入行",()=>ve(r,"insert-row-below")),ye("删除行",()=>ve(r,"delete-row"),{disabled:r.rows.length<=1}),ao(),ye("在左侧插入列",()=>ve(r,"insert-col-left")),ye("在右侧插入列",()=>ve(r,"insert-col-right")),ye("删除列",()=>ve(r,"delete-col"),{disabled:r.colWidths.length<=1}),ao(),ye("合并单元格",()=>ve(r,"merge"),{disabled:!!s,title:s||""}),ye("拆分单元格",()=>ve(r,"split"),{disabled:!Ca(r)}),ao(),a("div",{class:"menu-group-title",text:"行类型"}),...oa.map(c=>ye(c.label,()=>ve(r,"set-row-type",c.value),{disabled:!!Ln(r,c.value),title:Ln(r,c.value)||"",active:l===c.value}))])}let He=null;function Ei(){He&&(document.removeEventListener("mousemove",Ao),document.removeEventListener("mouseup",Do),He.handle.classList.remove("dragging"),He=null)}function Da(t,e){const o=t.closest(".hiprint-printPaper");return(o&&o.offsetWidth>0?o.getBoundingClientRect().width/o.offsetWidth:0)||(e.scale||100)/100}function Ma(t,e,o){if(o.button!==0)return;const n=o.currentTarget,i=n.closest(".print-table");if(!i)return;Ei();const r=t.real.options.tableColWidths??[];He={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:o.clientX,startWidth:r[e-1]??0,scale:Da(i,t.store),root:i,wrapper:n.closest(".print-element"),handle:n},n.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",Ao),document.addEventListener("mouseup",Do)}function Ao(t){const e=He;if(!e)return;const o=ut(e.store,e.elId),n=o?.options.tableColWidths;if(!o||!n)return;const i=(t.clientX-e.startX)/(e.scale*_t),r=e.boundary-1;n[r]=m.clampResizedColumnWidth(n,r,e.startWidth+i,xi(e.store)),m.syncTableElementSize(o.options),n.forEach((s,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${n.slice(0,l+1).reduce((c,f)=>c+f,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${o.options.width}mm`,e.wrapper.style.height=`${o.options.height}mm`)}function Do(){document.removeEventListener("mousemove",Ao),document.removeEventListener("mouseup",Do);const t=He;if(!t)return;He=null,t.handle.classList.remove("dragging");const e=ut(t.store,t.elId);e&&m.syncTableElementSize(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function _a(t,e,o){const n=o.querySelector("table");if(!n)return;const i=n.offsetHeight;if(i<=0)return;const r=ut(t,e);if(!r)return;let s=!1;const l=i/_t;Math.abs(l-(r.options.height??0))>na&&(r.options.height=Math.round(l*100)/100,s=!0);const c=n.offsetTop,f=Array.from(n.rows).map(u=>({top:(u.offsetTop-c)/_t,height:u.offsetHeight/_t})),g=Se(t);za(g.layouts.get(e),f)||(g.layouts.set(e,f),s=!0),s&&t.emit(!1)}function za(t,e){return!t||t.length!==e.length?!1:e.every((o,n)=>{const i=t[n];return Math.round(o.top*10)===Math.round(i.top*10)&&Math.round(o.height*10)===Math.round(i.height*10)})}function Pa(t,e){const o=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const n=o.parentElement;n&&_a(t,e,n)}),o}function Ra(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function Ia(t){return Array.from({length:t.colWidths.length},(e,o)=>o+1)}function La(t,e){return t.colWidths.slice(0,e).reduce((o,n)=>o+n,0)}function Fa(t,e,o){const n=bi(e,o,t);if(!n)return a("div",{class:"print-table"});const i=[a("table",{style:{fontSize:`${ko(n)}pt`,color:vi(n)}},[a("colgroup",{},n.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},n.rows.map((r,s)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((l,c)=>l.merged?"":a("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ca(n,s,c),style:da(n,l),onMousedown:f=>Sa(n,s,c,l.id,f),onMouseenter:()=>Ta(n,s,c),onContextmenu:f=>Ea(n,s,c,f)},[wa(n,r,s,c,l)])).filter(Boolean))))])];return Ra(n)&&i.push(a("div",{class:"col-resize-layer"},Ia(n).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:La(n,r)+"mm"},onMousedown:s=>{s.stopPropagation(),s.preventDefault(),Ma(n,r,s)}})))),n.isSelected&&i.push(a("div",{class:"row-badges"},n.rows.map((r,s)=>a("span",{class:"row-badge",style:{top:aa(n,s)+"mm",height:sa(n,s)+"mm"},text:ta[r.type]})))),i.push(Pa(e,t.id)),a("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:r=>r.preventDefault()},i)}const Fn={top:"flex-start",middle:"center",bottom:"flex-end"},Oa={left:"flex-start",center:"center",right:"flex-end"};function Na(t){const e=t.options,o=m.resolveElementBorder(t.printElementType.type,e),n={};if(o?.all&&(n.border=`${o.all.borderWidth} ${o.all.borderStyle} ${o.all.borderColor}`),o)for(const i of m.ELEMENT_BORDER_SIDES){const r=o.edges[i];r&&(n[`border${i.charAt(0).toUpperCase()}${i.slice(1)}`]=`${r.borderWidth} ${r.borderStyle} ${r.borderColor}`)}return{position:"absolute",left:`${e.left}mm`,top:`${e.top}mm`,width:`${e.width}mm`,height:`${e.height}mm`,zIndex:String(e.zIndex||"auto"),...n}}function On(t){const e=t.options,o=t.printElementType.type==="longText",n=m.resolveElementTextFit(t.printElementType.type,e),i=e.fontSize||12,r=n==="autoHeight",s={fontSize:`${i}pt`,fontWeight:e.fontWeight||"normal",fontFamily:e.fontFamily||"inherit",color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:o?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...o?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};return e.wordWrap===!1&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis"),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Fn[e.verticalAlign]??"flex-start"):(s.alignItems=Fn[e.verticalAlign]??"flex-start",s.justifyContent=Oa[e.textAlign||"left"]??"flex-start")),{style:s,fit:n}}function $a(t){const e=t.options,o=`${e.borderWidth||.75}pt`,n=e.borderStyle||"solid",i=e.borderColor||"#333";return t.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${o} ${n} ${i}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${o} ${n} ${i}`,boxSizing:"border-box"}}function Ba(t){const e=t.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:t.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ha(t){const e=t.options;return{objectFit:e.fit||"contain",...e.objectPosition?{objectPosition:e.objectPosition}:{},maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function Nn(t){const e=t.options,o={fitBase:String(e.fontSize||12),fitMin:String(m.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return m.resolveElementTextFit(t.printElementType.type,e)==="shrink"&&(o.fit="shrink"),o}function Ua(t,e,o){const n=t.printElementType.type,i=t.options;switch(n){case"text":{const{style:r}=On(t);return a("div",{class:"print-text",style:r,dataset:Nn(t),text:String(i.testData||i.formatter||"")||"文本"})}case"longText":{const{style:r}=On(t);return a("div",{class:"print-longtext",style:r,dataset:Nn(t),text:String(i.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:$a(t)});case"rect":case"oval":return a("div",{class:"print-shape",style:Ba(t)});case"image":{const r=String(i.src??""),s=r.includes("{")?m.evaluateTemplate(r,m.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[s?a("img",{src:s,style:Ha(t)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return Vr(t);case"barcode":return Xr(t);case"html":{const r=String(i.formatter??""),s=r?jr.sanitize(m.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:s})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${i.fontSize||12}pt`,fontWeight:i.fontWeight||"normal",fontFamily:i.fontFamily||"inherit",color:i.color||"#333",textAlign:i.textAlign||"left",...i.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:i.title||"{pageIndex}/{totalPages}"});case"table":return o?Fa(t,o.store,o.fire):a("div",{class:"print-table"});default:return a("div",{text:n})}}function ki(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function Wa(t,e){const o=t.store,n=o.selectedIds.has(e.id),i=o.previewIds.has(e.id),r=e.options,s=e.zone||"content",l=[Ua(e,!0,{store:o,fire:t.fire})];return o.draggingIds.has(e.id)&&l.push(a("div",{class:"drag-preview"})),n&&(l.push(a("div",{class:"resize-handles"},m.RESIZE_POINTS.map(c=>a("div",{class:`resize-handle handle-${c}`,dataset:{point:c,elId:e.id},onMousedown:f=>t.fire("resize-start",{event:f,id:e.id,point:c})})))),l.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:ki(r)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${s}`,n?"selected":"",i?"previewed":"",o.draggingIds.has(e.id)?"drag-ghost":"","design-mode",r.locked?"locked":"",r.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Na(e),dataset:{elId:e.id},onMousedown:c=>t.fire("element-mousedown",{event:c,id:e.id}),onContextmenu:c=>{c.preventDefault(),c.stopPropagation(),t.fire("contextmenu",{event:c,id:e.id})}},l)}function xo(t,e){const o=t.margins,n=t.header?.height??10,i=t.footer?.height??10,r=e.width-o.left-o.right;return{header:{left:o.left,top:o.top,width:r,height:n},content:{left:o.left,top:o.top+n,width:r,height:e.height-o.top-o.bottom-n-i},footer:{left:o.left,top:e.height-o.bottom-i,width:r,height:i}}}const Ga='<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 $n(t,e){return t.type==="vertical"?{left:`${t.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${t.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}}function qa(t,e){const o=R.resolveWatermarkLayout(t.watermark,[],e);return o?a("div",{class:"watermark-layer",style:{opacity:String(o.opacity)}},o.tiles.map(n=>a("svg",{class:"watermark-tile",width:`${n.widthMm}mm`,height:`${n.heightMm}mm`,viewBox:`0 0 ${o.tileWidthPx} ${o.tileHeightPx}`,style:{left:`${n.leftMm}mm`,top:`${n.topMm}mm`}},[a("text",{x:String(o.tileWidthPx/2),y:String(o.tileHeightPx/2),"font-size":String(o.fontSizePx),fill:o.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${o.rotate},${o.tileWidthPx/2},${o.tileHeightPx/2})`,text:o.text})]))):""}function so(t,e,o,n,i,r){const s=t.store,l=[];if(o!=="content"&&l.push(a("span",{class:"zone-label",text:o==="header"?"页眉":"页脚"})),l.push(...i.map(c=>Wa(t,c))),o!=="content"){const c=o==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${c}`,dataset:{zone:o},onMousedown:f=>t.fire("zone-resize",{event:f,zone:o})},[e.zoneResizing===o?a("div",{class:"zone-height-tip",text:`${(o==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${o} design-mode`,style:{position:"absolute",left:`${n.left}mm`,top:`${n.top}mm`,width:`${n.width}mm`,height:`${n.height}mm`},dataset:{zone:o,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function ja(t,e){const o=t.store,n=o.templateData,i=R.getPaperDimensions(n),r=(o.scale||100)/100,s=xo(n,i),l=u=>o.elements.filter(h=>(h.zone||"content")===u),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${n.margins.top}mm ${n.margins.right}mm ${n.margins.bottom}mm ${n.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${i.height}mm`}},[o.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(Ga)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...n.watermark&&Object.keys(n.watermark).length?[qa(n,i)]:[],so(t,e,"header",s.header,l("header"),i),so(t,e,"content",s.content,l("content"),i),so(t,e,"footer",s.footer,l("footer"),i),...o.adsorbGuides.map(u=>a("div",{class:`adsorb-guide guide-${u.type}`,style:$n(u,i)})),...(n.guides??[]).map(u=>a("div",{class:`manual-guide guide-${u.type}`,style:{...$n(u,i),"--guide-hit":`${8/r}px`},dataset:{guideId:String(u.id??"")},onMousedown:h=>t.fire("guide-mousedown",{event:h,id:u.id}),onDblclick:h=>{h.preventDefault(),t.fire("guide-remove",u.id)}}))].filter(Boolean)),f=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${i.width}mm`,minHeight:`${i.height}mm`,background:n.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(${r})`,transformOrigin:"0 0"}},[...n.designBackground?.src?[a("div",{class:"design-background",style:{width:`${i.width}mm`,height:`${i.height}mm`,left:"0",top:"0",transform:n.designBackground.rotation?`rotate(${n.designBackground.rotation}deg)`:""}},[a("img",{src:n.designBackground.src,draggable:!1,alt:""})])]:[],c]),g=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${R.mmToPx(i.width)*r}px`,height:`${R.mmToPx(i.height)*r}px`,position:"relative"}},[f])])];if(o.showRuler&&g.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:u=>t.fire("ruler-mousedown",{event:u,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:u=>t.fire("ruler-mousedown",{event:u,orientation:"vertical"})})])),e.guidePreview&&g.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&g.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const u=e.contextMenu;g.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[pe(t,u,"复制","copy"),pe(t,u,"剪切","cut"),pe(t,u,"粘贴","paste",!o.hasClipboard),pe(t,u,"删除","delete"),a("div",{class:"context-menu-sep"}),pe(t,u,"置顶","move-layer",!1,"top"),pe(t,u,"上移","move-layer",!1,"up"),pe(t,u,"下移","move-layer",!1,"down"),pe(t,u,"置底","move-layer",!1,"bottom")]:[pe(t,u,"粘贴","paste-at",!o.hasClipboard),pe(t,u,"全选","select-all"),pe(t,u,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:u=>u.preventDefault(),onDrop:u=>t.fire("drop",u),onMousedown:u=>t.fire("canvas-mousedown",u),onMousemove:u=>t.fire("canvas-mousemove",u),onMouseleave:()=>t.fire("canvas-mouseleave"),onWheel:u=>t.fire("wheel",u),onScroll:u=>t.fire("scroll",u),onContextmenu:u=>{u.preventDefault(),t.fire("canvas-contextmenu",u)}},g.filter(Boolean))}function pe(t,e,o,n,i=!1,r){return a("div",{class:`context-menu-item${i?" disabled":""}`,text:o,onClick:()=>{e.visible=!1,i||t.fire(n,r),t.repaint()}})}const Ya={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function se(t,e=15,o){const n=Ya[t];return n?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${o?` class="${o}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${n}</svg>`:""}let Be=null;function Mo(t){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return null;const o=e[1],n=o.length===3?o.split("").map(i=>i+i).join(""):o;return{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}function _o(t){const e=Mo(t);return e?Ci(e):"#000000"}function Ci({r:t,g:e,b:o}){return`#${[t,e,o].map(n=>Math.round(ct(n/255)*255).toString(16).padStart(2,"0")).join("")}`}function Ka(t,e,o){const n=t/255,i=e/255,r=o/255,s=Math.max(n,i,r),l=Math.min(n,i,r),c=s-l;let f=0;return c!==0&&(s===n?f=(i-r)/c%6:s===i?f=(r-n)/c+2:f=(n-i)/c+4,f*=60,f<0&&(f+=360)),{h:f,s:s===0?0:c/s,v:s}}function Va(t,e,o){const n=o*e,i=(t%360+360)%360/60,r=n*(1-Math.abs(i%2-1)),[s,l,c]=i<1?[n,r,0]:i<2?[r,n,0]:i<3?[0,n,r]:i<4?[0,r,n]:i<5?[r,0,n]:[n,0,r],f=o-n;return{r:(s+f)*255,g:(l+f)*255,b:(c+f)*255}}function Xa(t){return((Number.isFinite(t)?t:0)%360+360)%360}function ct(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function Za(t){const e=t.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${t.triggerClass?` ${t.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:o=>{const n=o.currentTarget??o.target,i=n.getRootNode();if(!!Be&&Be.root===i&&Be.title===e&&Be.trigger===n){lt();return}lt(),Ja(n,t)}},[a("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function lt(){const t=Be;t&&(Be=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function Ja(t,e){const o=t.getRootNode(),n=o instanceof ShadowRoot?o:document.body,i={root:o,title:e.title??"颜色选择",trigger:t,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&Po(i,e.value)?i.hexText=_o(e.value).toUpperCase():i.hexText=e.value?String(e.value):"",i.panel=te(os(i),n),i.current=i.panel.querySelector(".picker-current"),i.hex=i.panel.querySelector(".picker-hex"),i.area=i.panel.querySelector(".picker-area"),i.handle=i.panel.querySelector(".picker-handle"),i.hueRange=i.panel.querySelector(".picker-hue"),i.clearBtn=i.panel.querySelector(".picker-clear"),i.items=Array.from(i.panel.querySelectorAll(".preset-color-item")).map((r,s)=>({el:r,color:m.PRESET_COLORS[s]})),Lt(i),Qa(i),es(i),Be=i,t.setAttribute("aria-expanded","true")}function Qa(t){const e=t.trigger.getBoundingClientRect(),o=190,n=t.panel.offsetHeight||216,i=8,r=Math.max(i,Math.min(e.left,window.innerWidth-o-i)),s=e.bottom+6,l=s+n>window.innerHeight-i?Math.max(i,e.top-n-6):s;t.panel.style.left=`${r}px`,t.panel.style.top=`${l}px`}function es(t){const e=i=>{const r=ts(i);r.includes(t.trigger)||r.includes(t.panel)||lt()},o=i=>{i.key==="Escape"&&lt()},n=()=>lt();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",o),window.addEventListener("scroll",n,!0),window.addEventListener("resize",n),t.root.addEventListener("scroll",n,!0),t.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",o),()=>window.removeEventListener("scroll",n,!0),()=>window.removeEventListener("resize",n),()=>t.root.removeEventListener("scroll",n,!0))}function ts(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function os(t){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>is(t,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>rs(t,e),onKeydown:e=>as(t,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>ss(t,Number(e.target.value)),onChange:()=>Ro(t)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),t.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>Rt(t,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},m.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ns(t,e)})))])}function zo(t){return Ci(Va(t.hue,t.saturation,t.value_))}function Lt(t){const e=zo(t);t.hex.value!==t.hexText&&(t.hex.value=t.hexText),t.current.className=t.model?"picker-current":"picker-current is-empty",t.model?t.current.style.background=e:t.current.style.removeProperty("background"),t.area.style.setProperty("--picker-hue",`${Math.round(t.hue)}deg`),t.handle.style.left=`${t.saturation*100}%`,t.handle.style.top=`${(1-t.value_)*100}%`,t.handle.style.background=e;const o=String(Math.round(t.hue));t.hueRange.value!==o&&(t.hueRange.value=o),t.clearBtn&&(t.clearBtn.disabled=!t.model);for(const n of t.items)n.el.className=t.model&&n.color.toLowerCase()===t.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function Po(t,e){const o=Mo(e);if(!o)return!1;const n=Ka(o.r,o.g,o.b);return t.hue=n.h,t.saturation=n.s,t.value_=n.v,t.hexText=_o(e).toUpperCase(),!0}function Ze(t,e,o,n){t.hue=Xa(e),t.saturation=ct(o),t.value_=ct(n),t.hexText=zo(t).toUpperCase(),Lt(t)}function Ro(t){const e=zo(t);t.model=e,Lt(t),t.onChange(e)}function Rt(t,e){t.model=e,e||(t.hexText=""),Lt(t),t.onChange(e)}function ns(t,e){Po(t,e),Rt(t,e)}function is(t,e){const o=e.trim();if(!o){t.clearable&&Rt(t,void 0);return}Mo(o)&&(Po(t,o),Rt(t,_o(o)))}function rs(t,e){t.dragging=!0,Bn(t,e);const o=i=>{t.dragging&&Bn(t,i)},n=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",n),document.removeEventListener("pointercancel",n),Ro(t))};document.addEventListener("pointermove",o),document.addEventListener("pointerup",n),document.addEventListener("pointercancel",n)}function Bn(t,e){const o=t.area.getBoundingClientRect();if(!o.width||!o.height)return;const n=ct((e.clientX-o.left)/o.width),i=ct(1-(e.clientY-o.top)/o.height);Ze(t,t.hue,n,i)}function as(t,e){const o=e.shiftKey?.1:.02;let n=!0;e.key==="ArrowLeft"?Ze(t,t.hue,t.saturation-o,t.value_):e.key==="ArrowRight"?Ze(t,t.hue,t.saturation+o,t.value_):e.key==="ArrowUp"?Ze(t,t.hue,t.saturation,t.value_+o):e.key==="ArrowDown"?Ze(t,t.hue,t.saturation,t.value_-o):n=!1,n&&(e.preventDefault(),Ro(t))}function ss(t,e){Ze(t,e,t.saturation,t.value_)}function q(t,e,o,n){return a("button",{class:`tb-btn tb-icon${n.on?" on":""}${n.danger?" danger":""}`,type:"button",disabled:!!n.disabled,dataset:{tip:n.tip,...n.test?{test:n.test}:{}},onClick:()=>t.fire(o,n.arg),html:se(e)})}function It(t,e,o,n){const i=t.state.openDd===e,r=()=>{t.state.openDd=i?null:e,t.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${i?" on":""}`,disabled:!!o.disabled,dataset:{test:o.testId??e,tip:o.tip},onClick:r,html:`${o.icon?se(o.icon):""}${o.text?`<span class="${o.textClass??"tb-btn-text"}">${o.text}</span>`:""}${se("ChevronDown",12,`tb-dd-arrow${i?" up":""}`)}`}),i?a("div",{class:`tb-dd-panel${o.panelClass?` ${o.panelClass}`:""}`},n):""].filter(Boolean))}function N(t){const e=t.step??1,o=String(e),n=o.indexOf("."),i=n===-1?0:o.length-n-1,r=u=>Number.isFinite(u)?Number(u.toFixed(i)):0,s=u=>{let h=r(u);return t.min!==void 0&&h<t.min&&(h=t.min),t.max!==void 0&&h>t.max&&(h=t.max),h},l=t.value===void 0||t.value===null||!Number.isFinite(t.value)?void 0:r(t.value),c=l??t.min??0,f=u=>{u!==l&&t.onCommit(u)},g=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:t.min,max:t.max,step:e,placeholder:t.placeholder,disabled:!!t.disabled,onChange:u=>{const h=u.target,A=(h.value??"").trim();if(A===""){l!==void 0&&(h.value=String(l));return}const x=Number(A);if(!Number.isFinite(x)){h.value=l===void 0?"":String(l);return}const S=s(x);h.value=String(S),f(S)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!t.disabled||c<=(t.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>f(s(c-e))}),g,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!t.disabled||c>=(t.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>f(s(c+e))})])}function F(t,e,o){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:t}),e,o?a("p",{class:"pd-hint",text:o}):""].filter(Boolean))}const ls=t=>a("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function Qe(t,e,o){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[t,ls(o)]),e])}const ge=t=>a("h3",{class:"pd-divider",text:t});function de(t,e,o="颜色选择",n){return Za({value:t,title:o,triggerClass:n,onChange:i=>e(i)})}function _e(t,e,o,n,i=!1){return a("div",{class:`pd-radio-group${i?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:t,value:r.value,checked:o===r.value,onChange:()=>n(r.value)}),a("span",{text:r.label})])))}function ds(t){const e=[],o=new Set;for(const n of t??[]){const r=(typeof n=="string"?{family:n}:n)?.family?.trim();if(!r)continue;const s=r.toLowerCase();if(o.has(s))continue;o.add(s);const l=typeof n=="string"?void 0:n?.label?.trim();e.push(l?{family:r,label:l}:{family:r})}return e}function Hn(t,e){const o=e?.trim().toLowerCase();if(o)return t.find(n=>n.family.trim().toLowerCase()===o)}function Un(t){return t.label?`${t.label}(${t.family})`:t.family}function pt(t){return t.toLowerCase().replace(/\s+/g,"")}function Wn(t,e){if(t===e)return 0;if(t.startsWith(e))return 1;if(t.includes(e))return 2;let o=0;for(const n of t)if(n===e[o]&&o++,o===e.length)return 3;return-1}function cs(t,e){const o=Wn(pt(t.family),e);if(!t.label)return o;const n=Wn(pt(t.label),e);return o<0?n:n<0?o:Math.min(o,n)}function ps(t,e){const o=pt(e.trim());return o?t.map((n,i)=>({font:n,index:i,rank:cs(n,o)})).filter(n=>n.rank>=0).sort((n,i)=>n.rank-i.rank||n.index-i.index).map(n=>n.font):[...t]}function Io(t){const e=ds(t.fonts),o=t.placeholder??"默认",n=`font-select-list-${t.id}`,i=P=>{const _=P?.trim();return _?Hn(e,_)?.label??_:""},r=P=>{const _=pt(P);return e.find($=>$.label&&pt($.label)===_)?.family??P},s=()=>{const P=t.value?.trim();return P?Hn(e,P)?"":P:""},l=P=>{const _=(t.value??"").trim(),O=(Q,ce,Te,xe)=>({kind:Q,key:ce,label:Te,value:xe,selected:(xe??"")===_}),$=P.trim();if(!$){const Q=[O("clear","__clear__",o)],ce=s();ce&&Q.push(O("unknown","__unknown__",`${ce}(未知)`,ce));for(const Te of e)Q.push(O("font",Te.family,Un(Te),Te.family));return Q}const be=ps(e,$).map(Q=>O("font",Q.family,Un(Q),Q.family));if(!be.length){const Q=r($);be.push(O("free","__free__",`使用「${Q}」`,Q))}return be},c=document.createElement("div");c.className="font-select";const f=document.createElement("input");f.className="pd-input font-select-input",f.type="text",f.setAttribute("role","combobox"),f.setAttribute("aria-autocomplete","list"),f.setAttribute("aria-controls",n),f.autocomplete="off",f.placeholder=o,f.disabled=!!t.disabled,f.value=i(t.value);const g=document.createElement("ul");g.id=n,g.className="font-select-list",g.setAttribute("role","listbox");const u=t.state.fontOpen?.id===t.id?t.state.fontOpen:null,h={open:!!u&&!t.disabled,query:u?.query??"",highlighted:u?.highlighted??-1};h.open&&(f.value=h.query);const A=()=>{t.state.fontOpen=h.open?{id:t.id,query:h.query,highlighted:h.highlighted}:null};A();const x=()=>{const P=(t.value??"").trim();return l(h.query).findIndex(_=>(_.value??"")===P)},S=()=>{if(!h.open){g.isConnected&&g.remove(),f.setAttribute("aria-expanded","false"),f.setAttribute("aria-activedescendant","");return}g.isConnected||c.appendChild(g);const P=l(h.query);g.replaceChildren(...P.map((_,O)=>{const $=document.createElement("li");return $.id=`${n}-${O}`,$.className="font-select-option"+(O===h.highlighted?" is-active":"")+(_.kind==="unknown"||_.kind==="free"?" is-muted":""),$.setAttribute("role","option"),$.setAttribute("aria-selected",String(_.selected)),$.textContent=_.label,$.addEventListener("mousedown",be=>{be.preventDefault(),I(_)}),$})),f.setAttribute("aria-expanded","true"),f.setAttribute("aria-activedescendant",h.highlighted>=0?`${n}-${h.highlighted}`:"")},T=()=>{h.open||t.disabled||(h.open=!0,h.query="",h.highlighted=x(),A(),S())},k=()=>{h.open||T()},z=()=>{h.open=!0,h.query=f.value,h.highlighted=l(h.query).length?0:-1,A(),S()},v=P=>{if(!h.open){T();return}const _=l(h.query).length-1;if(_<0)return;h.highlighted=Math.min(Math.max(h.highlighted+P,0),_),A(),S(),g.children[h.highlighted]?.scrollIntoView?.({block:"nearest"})},w=()=>{if(!h.open)return;const P=l(h.query)[h.highlighted];if(P){I(P);return}const _=h.query.trim();if(_){const O=r(_);I({value:O})}},I=P=>{h.open=!1,h.query="",h.highlighted=-1,A(),f.value=i(P.value),S(),t.onChange(P.value)},V=()=>{h.open&&(h.open=!1,h.query="",h.highlighted=-1,A(),f.value=i(t.value),S())};return f.addEventListener("focus",T),f.addEventListener("click",k),f.addEventListener("input",z),f.addEventListener("blur",V),f.addEventListener("keydown",P=>{const _=P;_.key==="ArrowDown"?(_.preventDefault(),v(1)):_.key==="ArrowUp"?(_.preventDefault(),v(-1)):_.key==="Enter"?(_.preventDefault(),w()):_.key==="Escape"&&(_.preventDefault(),V())}),c.append(f),S(),h.open&&(f.focus(),f.setSelectionRange(h.query.length,h.query.length)),c}const us=[{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"}],hs={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function De(t,e,o,n,i={}){return a("button",{type:"button",class:`ft-cell-btn${i.on?" on":""}`,dataset:{test:t,tip:e},disabled:!!i.disabled,onClick:n,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${o}</svg>`})}const Ve='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',Gn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function fs(t){const e=t.format,o=e.values,n=!e.fontEditable,i=n||e.context==="cells",r=e.context==="none",s=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",f=h=>n?`${h}(需选中文本元素)`:h,g=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[De("preset-none","无边框",`${Ve}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),De("preset-all","所有边框",`${Gn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),De("preset-outer","外侧边框",Gn,()=>e.applyBorderPreset("outer")),De("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${Ve}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!s}),De("edge-top","上边框",`${Ve}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),De("edge-bottom","下边框",`${Ve}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),De("edge-left","左边框",`${Ve}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),De("edge-right","右边框",`${Ve}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),a("div",{class:"ft-style-row"},us.map(h=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===h.key?" on":""}`,dataset:{test:`style-${h.key}`,tip:h.label},onClick:()=>{e.borderStyle=h.key,t.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:h.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[N({value:e.borderWidth,min:.25,max:5,step:.25,onCommit:h=>{e.borderWidth=h,t.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),de(e.borderColor,h=>{e.borderColor=h,t.repaint()},"边框颜色")])])],u=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([h,A,x])=>a("button",{type:"button",class:`ft-cell-btn${o.textAlign===h?" on":""}`,dataset:{test:`align-${h}`,tip:A},disabled:n,onClick:()=>e.applyStyle({textAlign:h}),html:se(x)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([h,A,x])=>a("button",{type:"button",class:`ft-cell-btn${o.verticalAlign===h?" on":""}`,dataset:{test:`valign-${h}`,tip:A},disabled:n,onClick:()=>e.applyStyle({verticalAlign:h}),html:se(x)})))])];return a("div",{class:"format-toolbar"},[a("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[a("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),t.repaint()},onDblclick:()=>{e.pickPainterSource(!0),t.repaint()},html:se("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[Io({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof o.fontFamily=="string"?o.fontFamily:void 0,placeholder:o.fontFamily===Me?"混合":"默认",disabled:n,onChange:h=>e.applyStyle({fontFamily:h})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[N({value:typeof o.fontSize=="number"?o.fontSize:void 0,min:5,max:72,disabled:n,placeholder:o.fontSize===Me?"混合":"默认",onCommit:h=>e.applyStyle({fontSize:h})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([h,A,x,S])=>a("button",{type:"button",class:`ft-btn${o[h]===!0?" on":""}`,dataset:{test:h,tip:f(x)},disabled:h==="bold"?n:i,onClick:S,html:se(A)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${n?" dim":""}`,title:`字体颜色${n?"(需选中或混选文本元素)":""}`},[de(typeof o.color=="string"?o.color:void 0,h=>e.applyStyle({color:h})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[de(typeof o.backgroundColor=="string"?o.backgroundColor:void 0,h=>e.applyStyle({backgroundColor:h})),a("span",{class:"ft-glyph",html:se("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[It(t,"align",{icon:hs[String(o.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:n?"对齐(需选中文本元素或单元格)":"对齐",disabled:n,testId:"align-dd"},u)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[It(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},g)])])}const ms=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],gs={text:"T",longText:"¶",table:"⊞",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function bs(t){const e=t.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[qn("»","展开素材台",()=>{e.leftCollapsed=!1,t.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([n,i,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===n?" on":""}`,title:i,text:r,onClick:()=>{e.leftTab=n,e.leftCollapsed=!1,t.repaint()}}))])]);const o=(n,i)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===n?"":{display:"none"}},i);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),qn("«","收起素材台",()=>{e.leftCollapsed=!0,t.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([n,i])=>a("button",{type:"button",class:`pd-tab${e.leftTab===n?" active":""}`,text:i,onClick:()=>{e.leftTab=n,t.repaint()}}))]),o("elements",xs()),o("fields",[vs(t)]),o("layers",[ys(t)])])])}function qn(t,e,o){return a("button",{type:"button",class:"collapse-btn",title:e,text:t,onClick:o})}function xs(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...ms.map(t=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${t.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",t.type)},[a("span",{class:"material-icon",text:t.icon}),a("span",{class:"material-label",text:t.label})]))]}function vs(t){const e=t.state,o=m.groupFields(t.store.fields),n=(e.fieldSearch??"").trim().toLowerCase(),i=n?o.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(n))})).filter(r=>r.fields.length):o;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>t.repaint()}),a("div",{class:"tree-container"},i.flatMap(r=>{const s=e.collapsedGroups.has(r.key)&&!n,l=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{s?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),t.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label})]):"",c=s?[]:r.fields.map(f=>a("div",{class:"field-row",draggable:!0,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:g=>{g.dataTransfer?.setData("fieldKey",f.fieldKey)}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-label",text:f.fieldLabel}),a("span",{class:"node-key",text:`(${f.fieldKey})`})]));return[l,a("div",{},c.filter(Boolean))].filter(Boolean)})),i.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function ys(t){const e=t.store,o=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),n=e.elements.filter(l=>e.selectedIds.has(l.id)),i=n.length>=2,r=n.some(l=>!!l.options.groupId),s=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...o.map(l=>a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:gs[l.printElementType.type]||"?"}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),o.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,f])=>a("button",{type:"button",class:"pd-button small",title:c,html:se(f,14),onClick:()=>t.fire("move-layer",l)}))]):"",i||r?a("div",{class:"layer-actions"},[i?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:se("Group",14),onClick:()=>t.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:se("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function ws(t){const e=t.store,o=t.state,n=e.pages.length>1,i=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,c)=>o.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:o.renameText??"",onInput:f=>{o.renameText=f.target.value},onBlur:()=>s(),onKeydown:f=>{const g=f;if(g.key==="Enter"){s();return}g.key==="Escape"&&(o.renamingPage=null,t.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{o.renamingPage=c,o.renameText=l.name??"",t.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>t.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${i}」`},disabled:r,text:"⧉",onClick:()=>t.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:n?`删除当前页「${i}」`:"仅多页面模板可删除页面"},disabled:!n,text:"✕",onClick:()=>t.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${i}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>t.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${i}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>t.fire("move-page",1)})])]);function s(){const l=(o.renameText??"").trim();o.renamingPage!==null&&l&&e.renamePage(o.renamingPage,l),o.renamingPage=null,t.repaint()}}function Ss(t){const e=t.store,o=e.templateData,n=m.getPaperDimensions(o),i=o.orientation==="landscape"?"横向":"纵向",r=m.PAPER_PRESETS[o.paperSize]?.label??o.paperSize,s=o.outputRotation,l=`${r} ${i} ${Math.round(n.width)}×${Math.round(n.height)}mm${s?`(旋转${s}°)`:""}`;return a("div",{class:"status-bar"},[a("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),a("span",{class:"status-item",text:`缩放 ${e.scale}%`}),a("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),a("span",{class:`status-dirty${e.dirty?" on":""}`},[a("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),a("span",{class:"status-item status-paper",text:l})])}const Ts=Object.keys(m.PAPER_PRESETS).filter(t=>t!=="CUSTOM"&&!m.PAPER_PRESETS[t]?.continuous);function Es(t){const e=document.createElement("label");e.className="pd-button small upload-label";const o=document.createTextNode("上传背景图"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",e.append(o,n);const i=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,n.disabled=r};return n.addEventListener("change",async()=>{const r=n.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const s=t.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),n.value="";return}i(!0),o.textContent="上传中...";try{const l=await s(r);l?t.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{o.textContent="上传背景图",i(!t.host.uploadDesignBackground),n.value=""}}),t.host.uploadDesignBackground||i(!0),e}function ks(t){const o=t.store.templateData.designBackground,n=o?.rotation??0;return a("div",{class:"design-background-config"},[ge("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),o?.src?[a("div",{class:"design-background-path",title:o.src,text:o.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(n+90)%360}°)`,onClick:()=>t.store.updateTemplateData({designBackground:{...o,rotation:(n+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>t.store.updateTemplateData({designBackground:void 0})})])]:Es(t)].flat())}function Cs(t){const e=t.store,o=e.templateData,n=o.tiling,i={...R.TILE_DEFAULTS,...n??{},enabled:n?.enabled??!1,sheetMargin:{...R.TILE_DEFAULTS.sheetMargin,...n?.sheetMargin??{}}},r=m.isContinuousPaperSize(o.paperSize),s=h=>e.updateTemplateData({tiling:{...i,...h}}),l=(h,A)=>s({sheetMargin:{...i.sheetMargin,[h]:A??0}}),c={...o,tiling:i},f=R.validateTiling(c),g=Math.max(R.computeMaxColumns(c),1);let u="";if(!f.length)try{const h=R.computeTileLayout(c),A=R.resolveSheetMm(c),x=i.sheetPaperSize==="CUSTOM"?"自定义":i.sheetPaperSize??"A4",S=i.sheetPaperSize==="CUSTOM"?"":i.sheetOrientation==="landscape"?" 横向":" 纵向";u=`目标纸 ${x}${S} ${A.width}×${A.height}mm · ${h.columns} 列 × ${h.rows} 行 = 每张 ${h.perSheet} 格`}catch{u=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[ge("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:i.enabled===!0,disabled:r,onChange:h=>{if(!h.target.checked){s({enabled:!1});return}s({...R.TILE_DEFAULTS,columns:Math.min(R.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),i.enabled&&!r?[F("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:h=>{const A=h.target.value;if(A!=="CUSTOM"){s({sheetPaperSize:A});return}const x=R.resolveSheetMm(c);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:i.sheetCustomWidth??x.width,sheetCustomHeight:i.sheetCustomHeight??x.height})}},[...Ts.map(h=>a("option",{value:h,text:m.PAPER_PRESETS[h]?.label??h,selected:(i.sheetPaperSize??"A4")===h})),a("option",{value:"CUSTOM",text:"自定义",selected:i.sheetPaperSize==="CUSTOM"})])),i.sheetPaperSize==="CUSTOM"?F("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[N({value:Number(i.sheetCustomWidth??0),min:25,max:2e3,onCommit:h=>s({sheetCustomWidth:h})}),a("span",{class:"custom-size-x",text:"×"}),N({value:Number(i.sheetCustomHeight??0),min:25,max:2e3,onCommit:h=>s({sheetCustomHeight:h})})])):F("目标纸方向",_e("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],i.sheetOrientation==="landscape"?"landscape":"portrait",h=>s({sheetOrientation:h}))),ge("拼版留白 (mm)"),a("div",{class:"margin-grid"},[F("上",N({value:i.sheetMargin.top??0,min:0,max:100,onCommit:h=>l("top",h)})),F("下",N({value:i.sheetMargin.bottom??0,min:0,max:100,onCommit:h=>l("bottom",h)})),F("左",N({value:i.sheetMargin.left??0,min:0,max:100,onCommit:h=>l("left",h)})),F("右",N({value:i.sheetMargin.right??0,min:0,max:100,onCommit:h=>l("right",h)}))]),ge("格间距与列数"),F("横向间距",N({value:i.gapX??0,min:0,max:50,onCommit:h=>s({gapX:h??0})})),F("纵向间距",N({value:i.gapY??0,min:0,max:50,onCommit:h=>s({gapY:h??0})})),F("列数",N({value:i.columns??1,min:1,max:g,onCommit:h=>s({columns:h||1})})),...f.map(h=>a("p",{class:"pd-hint tiling-error",text:h.message})),!f.length&&u?a("p",{class:"pd-hint tiling-summary",text:u}):""]:""].flat().filter(Boolean))}const As=new Set(m.PROPERTY_REGISTRY.map(t=>t.group)),Ds={"table-settings":"content"},jn=new Map;function Lo(t){const e=t??"";let o=jn.get(e);if(!o){const{groups:n,itemKeys:i}=m.searchProperties(e);o={groups:n,keys:i,searching:!!e.trim()},jn.set(e,o)}return o}function Fo(t){const e=Ds[t]??t;return As.has(e)?e:""}function Ms(t,e){const o=Lo(t.state.propSearch);if(!o.searching)return!0;const n=Fo(e);return!n||o.groups.includes(n)}function _s(t,e){const o=Lo(t.state.propSearch);return!o.searching||o.keys.has(e)}function Ai(t,e){const o=t.props.style??{};return t.props.style={...o,display:e?"":"none"},t}function M(t,e,o){const n=o.props.dataset??{};return o.props.dataset={...n,propKey:e},Ai(o,_s(t,e))}function zs(t,e,o){const n=Fo(e);if(!n)return o;const i=o.props.dataset??{};return o.props.dataset={...i,propGroup:n},Ai(o,Ms(t,e))}function Di(t,e){const o=Lo(e);for(const n of Array.from(t.querySelectorAll("[data-prop-group]"))){const i=Fo(n.dataset.propGroup??"");n.style.display=!o.searching||!i||o.groups.includes(i)?"":"none"}for(const n of Array.from(t.querySelectorAll("[data-prop-key]")))n.style.display=!o.searching||o.keys.has(n.dataset.propKey??"")?"":"none"}function Ps(t){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:t.state.propSearch??"",onInput:e=>{const o=e.target,n=o.value;t.state.propSearch=n,Di(o.getRootNode(),n)}})])}const Rs={Document:"≡",Brush:"◧",Setting:"⚙"};function Is(t,e){try{const o=localStorage.getItem(`property-group-${t}`);return o===null?e:o==="true"}catch{return e}}function Ls(t,e){try{localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function le(t,e,o,n,i,r=!0){const s=Is(e,r);return zs(t,e,a("div",{class:`property-group${s?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{Ls(e,!s),t.repaint()}},[a("span",{class:"group-icon",text:Rs[n]||"•"}),a("span",{class:"group-title",text:o}),a("span",{class:"expand-icon",text:s?"▾":"▸"})]),a("div",{class:"group-content",style:s?"":{display:"none"}},i.filter(Boolean))]))}function Ft(t){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function Mi(t){return t.split(".").flatMap(e=>{const o=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!o)return[e];const n=o[1],i=[...o[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[n,...i]})}function Yn(t,e){return Mi(e).reduce((i,r)=>i==null?"":i[r],t)??""}function Oo(t,e,o,n){const i=Mi(o),r=i.pop(),s=i.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);s[r]=n||void 0,t.recordHistory(),t.emit()}function Fs(t,e){const o=t.store;if(e.printElementType.type==="table"&&o.tableSelection?.elementId===e.id){const{r1:n,c1:i}=o.tableSelection,r=(e.options.tableRows??[])[n];if(r)return m.getTableCellBindings(r.type,n,i,e.options.fields?.[0]?.dataSource)}return m.getElementBindings(e)}function Os(t,e){const o=document.createElement("label");o.className="pd-button small upload-label",te(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),o);const n=document.createTextNode("上传图片"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",o.append(n,i);const r=c=>{o.className=`pd-button small upload-label${c?" disabled":""}`,i.disabled=c};i.addEventListener("change",async()=>{const c=i.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const f=t.host.uploadImage;if(!f){alert("图片上传能力未配置"),i.value="";return}r(!0),n.textContent="上传中...";try{const g=await f(c);g?Oo(t.store,e,"options.src",g):alert("图片上传失败")}catch(g){alert(g instanceof Error?g.message:"图片上传失败")}finally{n.textContent="上传图片",r(!t.host.uploadImage),i.value=""}}),t.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(o,l),s}function Ns(t,e){const o=n=>t.fire("open-expression",{elementId:e.id,targetPath:n.targetPath,value:Yn(e,n.targetPath)});return le(t,"binding","内容","Document",[...Fs(t,e).map(n=>F(n.label,a("input",{class:"pd-input",type:"text",value:Yn(e,n.targetPath),placeholder:n.placeholder||"输入内容,支持 {字段} 表达式",onChange:i=>Oo(t.store,e,n.targetPath,i.target.value),onDblclick:()=>o(n)}))),e.printElementType.type==="image"?Os(t,e):""].filter(Boolean))}const Ne=t=>Number(t??0),vo=t=>t||void 0;function et(t,e,o,n){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...n?{title:n}:{},text:t}),a("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:i=>o(i.target.checked)})])}function $e(t,e,o,n,i=!1){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:t}),a("select",{class:"pd-select",...i?{style:{width:"100%"}}:{},onChange:r=>n(r.target.value)},o.map(r=>a("option",{value:r.value,text:r.label,selected:r.value===e})))])}const lo=t=>a("p",{class:"pd-hint",text:t}),$s="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Bs=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Hs=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Us=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Ws=[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"覆盖(保持比例)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],Gs=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}];function qs(t,e){const o=t.store,n=o.tableSelection,i=e.options.tableRows??[],r=n?i[n.r1]:void 0;if(!n||!r)return le(t,"table-row","行属性","Grid",[]);const s=l=>o.updateElement(e.id,l);return le(t,"table-row","行属性","Grid",[Ft([$e("行类型",r.type,Bs,l=>{const c=m.setRowType(i,n.r1,l);if(c){window.alert(c);return}s({tableRows:i})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),N({value:r.height,min:3,max:100,step:.5,onCommit:l=>{r.height=l,s({tableRows:i})}})]),r.type==="header"?et("表头每页重复",r.repeatOnPage??!1,l=>{m.setHeaderRepeat(i,l),s({tableRows:i})},$s):""])])}function js(t,e){const o=t.store,n=e.options,i=c=>o.updateElement(e.id,c),r=n.tableColWidths??[],s=o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right,l=o.fields.filter(c=>c.fieldType==="list").map(c=>({value:c.fieldKey,label:c.fieldLabel}));return le(t,"table-settings","表格设置","Grid",[Ft([$e("列表数据源字段",n.dataSource??"",l,c=>i({dataSource:c||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"默认字号 (pt)"}),N({value:Ne(n.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:c=>i({tableDefaultFontSize:vo(c)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"默认文字颜色"}),de(n.tableDefaultColor,c=>i({tableDefaultColor:c}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"默认内边距 (mm)"}),N({value:Ne(n.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:c=>i({tableDefaultPadding:vo(c)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((c,f)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${f+1}`}),N({value:c,min:5,max:200,onCommit:g=>{const u=r.reduce((h,A,x)=>x===f?h:h+A,0);if(u+g>s){const h=Math.max(5,Math.round((s-u)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${f+1} 已调整为 ${h}mm`),r[f]=h}else r[f]=g;i({tableColWidths:r})}})]))])])])}function Ys(t,e){const o=t.store,n=e.options,i=e.printElementType.type==="table",r=l=>o.updateElement(e.id,l),s=[];if(i)s.push(M(t,"pg-enabled",et("启用分页",n.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=n.pagination?.pageable??!0,c=n.pagination?.keepWithNext??!1;s.push(M(t,"pg-pageable",et("参与分页",l,f=>r({pagination:{pageable:f,keepWithNext:c}})))),s.push(M(t,"pg-keep-with-next",et("与下元素同页",c,f=>r({pagination:{pageable:l,keepWithNext:f}}))))}return le(t,"pagination","分页配置","Document",[Ft(s)],!1)}const Kn=new WeakMap;function Ks(t){let e=Kn.get(t);return e||(e={style:"solid",width:.75,color:"#333333",edges:[]},Kn.set(t,e)),e}const Vs=[{value:"solid",label:"实线"},{value:"dashed",label:"虚线"},{value:"dotted",label:"点线"},{value:"double",label:"双线"}],Vn=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Xs(t,e){const o=t.store,n=o.tableSelection,i=e.options.tableRows??[];if(!n)return le(t,"table-cell","单元格","Menu",[]);const r=m.findMainCell(i,n.r1,n.c1),s=i[r.r]?.cells[r.c];if(!s)return le(t,"table-cell","单元格","Menu",[]);const l=Ks(o),c=v=>{for(let w=n.r1;w<=n.r2;w++)for(let I=n.c1;I<=n.c2;I++){const V=i[w]?.cells[I];V&&!V.merged&&v(V)}o.updateElement(e.id,{tableRows:i})},f=()=>({width:l.width,style:l.style,color:l.color}),g=s.cellType==="barcode",u=s.cellType==="qrcode",h=s.cellType==="image",A=!g&&!u&&!h,x=g&&!!s.printerDpi,S=m.resolveCellTextFit(s),T=m.canMergeReason(i,n);let k=!1;for(let v=n.r1;v<=n.r2&&!k;v++)for(let w=n.c1;w<=n.c2&&!k;w++){const I=i[v]?.cells[w];I&&!I.merged&&((I.rowspan??1)>1||(I.colspan??1)>1)&&(k=!0)}const z=(v,w,I,V={})=>a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:v}),N({value:w,...V,onCommit:P=>c(_=>I(_,vo(P)))})]);return le(t,"table-cell","单元格","Menu",[Ft([a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),_e("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],s.cellType||"text",v=>{c(w=>{w.cellType=v==="text"?void 0:v,v!=="barcode"&&(w.barcodeType=void 0,w.showBarcodeText=void 0,w.printerDpi=void 0),v!=="qrcode"&&(w.qrCodeLevel=void 0,w.qrQuietZone=void 0)})})]),g?$e("码制",s.barcodeType||"CODE128",Hs,v=>c(w=>{w.barcodeType=v||void 0})):"",g?et("显示文本",s.showBarcodeText!==!1,v=>c(w=>{w.showBarcodeText=v})):"",g?z("条宽(倍率)",s.barWidth??2,(v,w)=>{v.barWidth=w},{min:2,max:4,step:.5}):"",g?lo(x?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定"):"",g?z("文本字号(相对条高,条高为 30)",s.barFontSize??10,(v,w)=>{v.barFontSize=w},{min:5,max:24,placeholder:"默认 10"}):"",g?$e("打印机分辨率",s.printerDpi?String(s.printerDpi):"",[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],v=>{const w=Number(v);c(I=>{I.printerDpi=w>0?w:void 0})}):"",g?lo("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",u?$e("纠错级别",s.qrCodeLevel||"M",Us,v=>c(w=>{w.qrCodeLevel=v||void 0})):"",u?Qe("静区 (模块)",N({value:s.qrQuietZone??0,min:0,max:8,placeholder:"默认 0",onCommit:v=>c(w=>{w.qrQuietZone=v})}),m.propertyTip("cd-quiet-zone")):"",g?lo("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限"):"",u||h?$e("缩放模式",s.fit||"contain",Ws,v=>c(w=>{w.fit=v})):"",h?Qe("裁剪锚点",a("input",{class:"pd-input",type:"text",value:String(s.objectPosition??""),placeholder:"缺省居中,如 center 20%",onBlur:v=>c(w=>{w.objectPosition=(v.target.value||"").trim()||void 0})}),m.propertyTip("ap-img-object-position")):"",g||u||h?z("最大宽度 (mm)",Ne(s.maxWidth),(v,w)=>{v.maxWidth=w},{min:0,max:200,placeholder:"默认"}):"",g||u||h?z("最大高度 (mm)",Ne(s.maxHeight),(v,w)=>{v.maxHeight=w},{min:0,max:200,placeholder:"默认"}):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:s.formatter||"",placeholder:"输入内容,支持 {字段} 表达式",onChange:v=>c(w=>{w.formatter=v.target.value||void 0}),onDblclick:()=>t.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水平对齐"}),_e("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],s.align||"left",v=>c(w=>{w.align=v}))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"垂直对齐"}),_e("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],s.valign||"top",v=>c(w=>{w.valign=v}))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label",text:"字体"}),Io({id:"cell-font",state:t.state,fonts:t.host.fonts,value:s.fontFamily,placeholder:"继承默认",onChange:v=>c(w=>{w.fontFamily=v})})]),z("字号 (pt)",Ne(s.fontSize),(v,w)=>{v.fontSize=w},{min:0,max:72,placeholder:"默认"}),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"加粗"}),a("input",{class:"pd-switch",type:"checkbox",checked:s.fontWeight==="bold",onChange:v=>c(w=>{w.fontWeight=v.target.checked?"bold":void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"文字颜色"}),de(s.color,v=>c(w=>{w.color=v}),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"背景色"}),de(s.backgroundColor,v=>c(w=>{w.backgroundColor=v}),"背景颜色")])]),ge("边框"),a("div",{class:"border-style-row"},[a("select",{class:"pd-select",style:{width:"90px"},onChange:v=>{l.style=v.target.value,t.repaint()}},Vs.map(v=>a("option",{value:v.value,text:v.label,selected:v.value===l.style}))),a("div",{style:{width:"112px",flexShrink:"0"}},[N({value:l.width,min:.25,max:5,step:.25,onCommit:v=>{l.width=v,t.repaint()}})]),de(l.color,v=>{l.color=v,t.repaint()},"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([v,w])=>a("button",{type:"button",class:"pd-button small",text:w,onClick:()=>{m.applyBorderPreset(i,n,v,f()),o.updateElement(e.id,{tableRows:i})}}))),a("div",{class:"pd-checkbox-group"},Vn.map(v=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:v.value,checked:l.edges.includes(v.value),onChange:w=>{const I=w.target,V=new Set(l.edges);I.checked?V.add(I.value):V.delete(I.value),l.edges=[...V];const P=f();c(_=>{const O={..._.borders??{}};for(const $ of Vn)V.has($.value)?O[$.value]={...P}:delete O[$.value];_.borders=O})}}),a("span",{text:v.label})]))),z("内边距 (mm)",Ne(s.padding),(v,w)=>{v.padding=w},{min:0,max:10,step:.5,placeholder:"默认"}),et("自动换行",s.wordWrap??!0,v=>c(w=>{w.wordWrap=v})),A?$e("文字溢出",S,Gs,v=>c(w=>{w.textFit=v}),!0):"",A&&S==="shrink"?z("最小字号 (pt)",Ne(s.shrinkMinFontSize),(v,w)=>{v.shrinkMinFontSize=w},{min:0,max:72,step:.5,placeholder:"默认 6"}):"",a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!T,title:T||"",onClick:()=>{m.mergeCells(i,n),o.updateElement(e.id,{tableRows:i})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!k,onClick:()=>{m.splitCells(i,n),o.updateElement(e.id,{tableRows:i})}})])])])}const co=R.WATERMARK_DENSITY_PRESETS;function yo(t){const e=t.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function Zs(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function Js(t){const e=t.store.templateData.watermark,o=Zs(e),n=e?.mode==="binding"||o!==""&&yo(o),i=(()=>{const l=e?.tileWidth??R.WATERMARK_DEFAULTS.tileWidth,c=e?.tileHeight??R.WATERMARK_DEFAULTS.tileHeight;for(const[f,g]of Object.entries(co))if(g.width===l&&g.height===c)return f;return"custom"})(),r=l=>{const c={testData:e?.testData??"",rotate:e?.rotate??R.WATERMARK_DEFAULTS.rotate,color:e?.color||R.WATERMARK_DEFAULTS.color,opacity:e?.opacity??R.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??R.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??R.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};t.store.updateTemplateData({watermark:{...c,...l}})},s=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:o});return a("div",{class:"watermark-config"},[ge("水印"),a("form",{class:"pd-form",onSubmit:l=>l.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:o,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:l=>{const c=l.target.value;r(yo(c)?{mode:"binding",binding:c,content:""}:{mode:"fixed",content:c,binding:""})},onDblclick:s}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:s})]),n?F("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:l=>r({testData:l.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"旋转角度"}),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??R.WATERMARK_DEFAULTS.rotate),onChange:l=>r({rotate:Number(l.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??R.WATERMARK_DEFAULTS.rotate}°`})]),F("颜色",de(e?.color||R.WATERMARK_DEFAULTS.color,l=>r({color:l}),"水印颜色")),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"透明度"}),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??R.WATERMARK_DEFAULTS.opacity),onChange:l=>r({opacity:Number(l.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??R.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:l=>{const c=l.target.value,f=co[c];f&&r({tileWidth:f.width,tileHeight:f.height})}},[...Object.entries(co).map(([l,c])=>a("option",{value:l,text:`${c.label}(${c.width}×${c.height})`,selected:i===l})),a("option",{value:"custom",text:"自定义",selected:i==="custom"})])]),i==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"瓦片宽"}),a("input",{type:"number",class:"pd-input",min:R.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??R.WATERMARK_DEFAULTS.tileWidth),onChange:l=>r({tileWidth:Number(l.target.value)})})]):"",i==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"瓦片高"}),a("input",{type:"number",class:"pd-input",min:R.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??R.WATERMARK_DEFAULTS.tileHeight),onChange:l=>r({tileHeight:Number(l.target.value)})})]):""].filter(Boolean))])}function J(t,e,o,n,i={}){return F(e,N({value:o,...i,onCommit:n}))}function Le(t,e,o,n,i,r){const s=document.createElement("select");s.className="pd-select",s.addEventListener("change",()=>i(s.value));for(const l of n){const c=document.createElement("option");c.value=l.value,c.textContent=l.label,s.appendChild(c)}return s.value=o,n.some(l=>l.value===o)||(s.selectedIndex=-1),r?Qe(e,s,r):F(e,s)}function At(t,e,o,n){return F(e,a("input",{type:"checkbox",class:"pd-switch",checked:o,onChange:i=>n(i.target.checked)}))}function Qs(t,e){const o=t.store,n=e.options,i=e.printElementType.type,r=u=>o.updateElement(e.id,u),s=i==="text"||i==="longText",l=i==="barcode"||i==="qrcode",c=i==="table",f=c&&o.tableSelection?.elementId===e.id,g=[];if(f||g.push(le(t,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"position-grid"},[M(t,"ps-left",J(t,"X",n.left,u=>r({left:u}),{min:0})),M(t,"ps-top",J(t,"Y",n.top,u=>r({top:u}),{min:0})),M(t,"ps-width",J(t,"W",n.width,u=>r({width:u}),{min:4})),M(t,"ps-height",J(t,"H",n.height,u=>r({height:u}),{min:4}))])])])),g.push(le(t,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},s?[M(t,"ap-font-family",F("字体",Io({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof n.fontFamily=="string"?n.fontFamily:void 0,placeholder:"默认",onChange:u=>r({fontFamily:u})}))),M(t,"ap-font-size",J(t,"字体大小",n.fontSize,u=>r({fontSize:u}),{min:8,max:72})),M(t,"ap-font-weight",Le(t,"字体粗细",String(n.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],u=>r({fontWeight:u}))),M(t,"ap-align",F("对齐",_e("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],n.textAlign||"left",u=>r({textAlign:u})))),M(t,"ap-vertical-align",F("垂直对齐",_e("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],n.verticalAlign||"top",u=>r({verticalAlign:u})))),a("div",{class:"color-row"},[M(t,"ap-color",F("颜色",de(n.color,u=>r({color:u}),"字体颜色"))),M(t,"ap-bg-color",F("背景色",de(n.backgroundColor,u=>r({backgroundColor:u}),"背景颜色")))]),M(t,"ap-line-height",J(t,"行高",n.lineHeight,u=>r({lineHeight:u||void 0}),{min:0,max:100})),M(t,"ap-letter-spacing",J(t,"字间距",n.letterSpacing,u=>r({letterSpacing:u||void 0}),{min:0,max:20,step:.5})),M(t,"ap-text-fit",Le(t,"文字溢出",m.resolveElementTextFit(i,n),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],u=>r({textFit:u}))),n.textFit==="shrink"?M(t,"ap-shrink-min",F("最小字号 (pt)",N({value:n.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:u=>r({shrinkMinFontSize:u||void 0})}))):"",i==="longText"?M(t,"ap-long-text-indent",Qe("首行缩进 (字符)",N({value:n.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:u=>r({longTextIndent:u||void 0})}),m.propertyTip("ap-long-text-indent"))):"",M(t,"ap-word-wrap",At(t,"自动换行",n.wordWrap!==!1,u=>r({wordWrap:u?void 0:!1})))]:[i==="image"?M(t,"ap-img-fit",Le(t,"缩放模式",String(n.fit??"contain"),[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"覆盖(保持比例)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],u=>r({fit:u}),m.propertyTip("ap-img-fit"))):"",i==="image"?M(t,"ap-img-object-position",Qe("裁剪锚点",a("input",{class:"pd-input",type:"text",value:String(n.objectPosition??""),placeholder:"缺省居中,如 center 20%",onBlur:u=>r({objectPosition:(u.target.value||"").trim()||void 0})}),m.propertyTip("ap-img-object-position"))):"",!c&&i!=="image"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const u=i==="barcode",h=String(n.barcodeType||"CODE128").toUpperCase(),A=n.printerDpi?String(n.printerDpi):"";g.push(le(t,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[u?[M(t,"cd-type",Le(t,"码制",h,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],x=>r({barcodeType:x==="CODE128"?void 0:x}))),M(t,"cd-dpi",Le(t,"打印机分辨率",A,[{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)"}],x=>r({printerDpi:Number(x)>0?Number(x):void 0}))),M(t,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),M(t,"cd-bar-width",J(t,"条宽(倍率)",n.barWidth??2,x=>r({barWidth:x}),{min:2,max:4,step:.5})),M(t,"cd-bar-width",a("p",{class:"pd-hint",text:A?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定"})),M(t,"cd-show-text",At(t,"显示文本",n.hideTitle!==!0,x=>r({hideTitle:x?void 0:!0}))),M(t,"cd-font-size",F("文本字号(相对条高,条高为 30)",N({value:n.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:x=>r({fontSize:x||void 0})})))]:[M(t,"cd-ec-level",Le(t,"纠错级别",String(n.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],x=>r({qrCodeLevel:x}))),M(t,"cd-quiet-zone",Qe("静区 (模块)",N({value:n.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:x=>r({qrQuietZone:x})}),m.propertyTip("cd-quiet-zone")))],ge("自定义设置"),u?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限"}):"",u?"":M(t,"cd-fit",Le(t,"缩放模式",String(n.fit||"contain"),[{value:"contain",label:"包含(保持比例)"},{value:"cover",label:"覆盖(保持比例)"},{value:"fill",label:"拉伸填满"},{value:"none",label:"原始尺寸"},{value:"scale-down",label:"缩小(保持比例)"}],x=>r({fit:x||void 0}))),M(t,"cd-max-width",F("最大宽度 (mm)",N({value:n.maxWidth,min:1,max:200,placeholder:"默认",onCommit:x=>r({maxWidth:x||void 0})}))),M(t,"cd-max-height",F("最大高度 (mm)",N({value:n.maxHeight,min:1,max:200,placeholder:"默认",onCommit:x=>r({maxHeight:x||void 0})})))].flat().filter(Boolean))]))}return g.push(Ns(t,e)),f&&(g.push(qs(t,e)),g.push(Xs(t,e))),c&&g.push(js(t,e)),g.push(le(t,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"border-row"},[M(t,"bb-border-width",J(t,"边框宽度",n.borderWidth,u=>r({borderWidth:u}),{min:0,max:20,step:.25})),M(t,"bb-border-color",F("边框颜色",de(n.borderColor,u=>r({borderColor:u}),"边框颜色")))]),M(t,"bb-bg-color",F("背景色",de(n.backgroundColor,u=>r({backgroundColor:u}),"背景颜色")))])])),g.push(Ys(t,e)),g.push(le(t,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"advanced-row"},[M(t,"ad-locked",At(t,"锁定",!!n.locked,u=>r({locked:u}))),M(t,"ad-fixed",At(t,"每页重复",!!n.fixed,u=>r({fixed:u})))]),M(t,"ad-z-index",J(t,"层级",n.zIndex,u=>r({zIndex:u}),{min:0,max:999})),M(t,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>o.deleteSelected()})]))])],!1)),a("div",{class:"property-content"},g)}function el(t){const e=t.store,o=e.templateData,n=l=>e.updateTemplateData(l),i=[];for(const[l,c]of Object.entries(m.PAPER_PRESETS)){const f=c.group??"其他";let g=i.find(u=>u.group===f);g||(g={group:f,items:[]},i.push(g)),g.items.push({key:l,label:c.label??l})}const r=!m.PAPER_PRESETS[o.paperSize],s=m.isContinuousPaperSize(o.paperSize);return a("form",{class:"pd-form",onSubmit:l=>l.preventDefault()},[ge("纸张设置"),F("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:l=>n({paperSize:l.target.value})},[...i.map(l=>a("optgroup",{label:l.group},l.items.map(c=>a("option",{value:c.key,text:c.label,selected:o.paperSize===c.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:r})])),s||r?F(s?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[N({value:Number(o.customWidth??0),min:25,max:2e3,onCommit:l=>n({customWidth:l})}),...r?[a("span",{class:"custom-size-x",text:"×"}),N({value:Number(o.customHeight??0),min:25,max:2e3,onCommit:l=>n({customHeight:l})})]:[]])):"",s?"":F("纸张方向",_e("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.orientation==="landscape"?"landscape":"portrait",l=>n({orientation:l})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),!s&&!o.tiling?.enabled?F("内容旋转角度",_e("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(o.outputRotation??0),l=>n({outputRotation:Number(l)}),!0),"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"):"",F("页面背景色",a("div",{class:"page-bg-row"},[de(o.pageBackground,l=>n({pageBackground:l}),"页面背景色","page-bg-picker"),a("button",{type:"button",class:"pd-reset",title:"恢复为默认白色",text:"默认",onClick:()=>n({pageBackground:void 0})})])),ks(t),e.pages.length>1?"":Cs(t),ge("页边距 (mm)"),a("div",{class:"margin-grid"},[J(t,"上",o.margins.top,l=>n({margins:{...o.margins,top:l}}),{min:0,max:50}),J(t,"下",o.margins.bottom,l=>n({margins:{...o.margins,bottom:l}}),{min:0,max:100}),J(t,"左",o.margins.left,l=>n({margins:{...o.margins,left:l}}),{min:0,max:50}),J(t,"右",o.margins.right,l=>n({margins:{...o.margins,right:l}}),{min:0,max:50})]),ge("页眉/页脚高度 (mm)"),J(t,"页眉高度",o.header.height??10,l=>n({header:{...o.header,height:l}}),{min:0,max:100,step:.1}),J(t,"页脚高度",o.footer.height??10,l=>n({footer:{...o.footer,height:l}}),{min:0,max:100,step:.1}),Js(t)].filter(Boolean))}function tl(t){const e=t.store,o=t.state,n=e.selectedElement;if(o.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{o.propCollapsed=!1,t.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([r,s,l])=>a("button",{type:"button",class:`pc-btn${o.propTab===r?" on":""}`,title:s,text:l,onClick:()=>{o.propTab=r,o.propCollapsed=!1,t.repaint()}}))])]);const i=n?o.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{o.propCollapsed=!0,t.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[a("button",{type:"button",class:`pd-tab${i==="element"?" active":""}`,text:"元素属性",onClick:()=>{o.propTab="element",t.repaint()}}),a("button",{type:"button",class:`pd-tab${i==="page"?" active":""}`,text:"页面属性",onClick:()=>{o.propTab="page",t.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:i==="element"?"":{display:"none"}},n?[Ps(t),Qs(t,n)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:i==="page"?"":{display:"none"}},[el(t)])])])}const po=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Xn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},ol=[{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()"}],nl=[{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()"}],il=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],rl=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],al=[{title:"聚合函数",items:ol},{title:"数值运算",items:nl},{title:"格式化函数",items:il}],sl="(输入表达式后预览)",ll="(无法计算)",wo="(表达式错误)";function Zn(t,e){if(!t.trim())return sl;try{const o={...m.DEFAULT_DEMO_DATA,...e??{},...R.resolveSystemVariables()},n=m.evaluateTemplate(t,o);return n==null?ll:String(n)}catch{return wo}}function Jn(t,e){const o=e.trim().toLowerCase();return o?t.filter(n=>n.label.toLowerCase().includes(o)||n.name.toLowerCase().includes(o)):t}function dl(t,e){const o=t.substring(0,e),n=o.lastIndexOf("{"),i=n!==-1&&!o.slice(n+1).includes("}"),r=o.lastIndexOf("("),s=r!==-1&&!o.slice(r+1).includes(")");return{insideBlock:i,insideParens:s}}function cl(t,e){const o=/^\{\s*([^{}]+?)\s*\}$/.exec(t.trim());if(!o)return null;const n=o[1]??"";return e.find(i=>i.fieldKey===n)??null}function uo(t,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:t}),a("span",{class:"ee-item-key",text:e})])}function Fe(t){return t.currentTarget.getRootNode()}function Dt(t,e,o){const n=[];return o.forEach((i,r)=>{n.push(i),r<o.length-1&&n.push(a("br"))}),a("div",{class:`ee-help-card ${t}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},n)])}function pl(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Dt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Dt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Dt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Dt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function ul(t,e){const o={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},n=(x,S)=>x.querySelector(S),i=x=>{const S=n(x,".ee-preview");if(!S)return;const T=Zn(o.expression,t.demoData);S.textContent=T,S.classList.toggle("ee-preview-error",T===wo)},r=()=>{if(o.activeTab==="variable")return Jn(rl,o.searchText).map(T=>a("div",{class:"ee-list-item",onDblclick:k=>{const{insideParens:z}=l(k);c(Fe(k),z?T.template.replace(/^\{|\}$/g,""):T.template)}},[uo(T.label,T.template)]));if(o.activeTab==="function")return al.map(T=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:T.title}),...Jn(T.items,o.searchText).map(k=>a("div",{class:"ee-list-item",onDblclick:z=>{const{insideBlock:v}=l(z),w=v?k.template:`{${k.template}}`;c(Fe(z),w,w.indexOf("(")+1)}},[uo(k.label,`${k.name}()`)]))]));const x=m.filterGroups(m.groupFields(t.fields??[]),o.searchText);if(!x.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const S=[];for(const T of x){T.key&&S.push(a("div",{class:`ee-field-group${T.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:T.isList?"📋":"📁"}),a("span",{text:T.label})]));for(const k of T.fields)S.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:T.key?"22px":"10px"},onDblclick:z=>{const{insideParens:v}=l(z);c(Fe(z),v?k.fieldKey:`{${k.fieldKey}}`)}},[uo(k.fieldLabel,k.fieldKey)]))}return S},s=x=>{Array.from(x.querySelectorAll(".ee-nav-tab")).forEach((v,w)=>v.classList.toggle("active",po[w]?.key===o.activeTab));const T=n(x,".ee-content-search .pd-input");if(T){const v=Xn[o.activeTab];T.placeholder!==v&&(T.placeholder=v),T.value!==o.searchText&&(T.value=o.searchText)}const k=n(x,".ee-textarea");k&&k.value!==o.expression&&(k.value=o.expression);const z=n(x,".ee-content-list");if(z){ci(z);for(const v of r())te(v,z)}i(x)},l=x=>{const T=n(Fe(x),".ee-textarea")?.selectionStart??o.expression.length;return dl(o.expression,T)},c=(x,S,T=S.length)=>{const k=n(x,".ee-textarea");if(!k){o.expression+=S,i(x);return}const z=k.selectionStart??o.expression.length,v=k.selectionEnd??z;o.expression=o.expression.substring(0,z)+S+o.expression.substring(v);const w=z+T;k.value=o.expression,k.focus(),k.selectionStart=k.selectionEnd=w,i(x)},f=()=>{const x=o.expression;if(o.binding===void 0){t.onApply({formatter:x}),t.onClose();return}const S=cl(x,t.fields??[]);t.onApply(S?{formatter:x,binding:S.fieldKey,title:S.fieldLabel}:{formatter:x}),t.onClose()},g=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},po.map((x,S)=>a("div",{class:`ee-nav-tab${o.activeTab===x.key?" active":""}`,text:x.text,onClick:T=>{o.activeTab=po[S].key,s(Fe(T))}})))]),u=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:Xn[o.activeTab],onInput:x=>{o.searchText=x.target.value,s(Fe(x))}})]),a("div",{class:"ee-content-list"},r())]),h=Zn(o.expression,t.demoData),A=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:o.expression,onInput:x=>{o.expression=x.target.value,i(Fe(x))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${h===wo?" ee-preview-error":""}`,text:h})]),pl()]);return a("div",{class:"pd-dialog-overlay",onKeydown:x=>{x.key==="Escape"&&t.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>t.onClose()})]),a("div",{class:"expression-editor"},[g,u,A]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>t.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>f()})])])])}const hl={id:"getting-started",title:"快速入门",content:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@worm-vue3-print/core/designer"),A=require("@worm-vue3-print/core"),Vo=require("@worm-vue3-print/core/browser"),wn=require("jsbarcode");function a(o,e={},t=[]){return{tag:o,props:e,children:t}}const Sn="http://www.w3.org/2000/svg",pr=new Set(["draggable","contenteditable","spellcheck"]),ur=new Set(["indeterminate"]);function hr(o){return o==="svg"||o==="path"||o==="circle"||o==="rect"||o==="line"||o==="g"}function fe(o,e){if(typeof o=="string"){const s=document.createTextNode(o);return e.appendChild(s),s}if(o instanceof Node)return e.appendChild(o),o;const{tag:t,props:i,children:n}=o,r=hr(t)?document.createElementNS(Sn,t):document.createElement(t);for(const[s,l]of Object.entries(i))if(!(l==null||l===!1))if(s==="class")r.setAttribute("class",String(l));else if(s==="style")typeof l=="string"?r.style.cssText=l:Object.assign(r.style,l);else if(s==="html")r.innerHTML=String(l);else if(s==="text")r.textContent=String(l);else if(s.startsWith("on")&&typeof l=="function")r.addEventListener(s.slice(2).toLowerCase(),l);else if(s==="dataset")for(const[c,u]of Object.entries(l))r.dataset[c]=u;else ur.has(s)?r[s]=!0:typeof l=="boolean"?l&&r.setAttribute(s,pr.has(s)?"true":""):r.setAttribute(s,String(l));for(const s of n)fe(s,r);return e.appendChild(r),r}function Tn(o){for(;o.firstChild;)o.removeChild(o.firstChild)}const fr=Sn;function Rt(){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 No="开启拼版后只能有一个设计页面";function Xo(o){const e=(t,i)=>(t??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&p.syncTableElementSize(r),{id:n.id||p.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...o,margins:{...o.margins},header:{height:o.header?.height??10,elements:[]},footer:{height:o.footer?.height??10,elements:[]},guides:[...o.guides??[]],elements:[...e(o.elements??[],"content"),...e(o.header?.elements??[],"header"),...e(o.footer?.elements??[],"footer")]}}function En(o){const e=o.elements,t=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...o,header:{...o.header,elements:t("header")},footer:{...o.footer,elements:t("footer")},elements:t("content"),guides:[...o.guides??[]]}}function Ri(o){const e=(i,n)=>{const r=Xo(p.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!o)return[e(Rt(),0)];const t=Array.isArray(o.pages)?o.pages:[o];return t.length?t.map(e):[e(Rt(),0)]}const pt=o=>JSON.parse(JSON.stringify(o));class kn{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=p.useAlign();group=p.useGroup();constructor(e={}){if(this.pages=Ri(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const t=this.pages[0];t.elements=[...t.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const t of[...this.listeners])t()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const e=this.pages[this.activePageIndex]??Rt();this.pages.push(Xo({...Rt(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let t=this.pages.length+1;for(;e.has(`页面 ${t}`);)t++;return`页面 ${t}`}duplicatePage(e){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const t=pt(this.pages[e]);t.name=`${t.name??`页面 ${e+1}`} 副本`,t.elements=t.elements.map(i=>({...i,id:p.generateId()})),this.pages.splice(e+1,0,t),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,t){this.recordHistory(),this.pages[e].name=t,this.emit()}movePage(e,t){if(t<0||t>=this.pages.length||e===t)return;this.recordHistory();const[i]=this.pages.splice(e,1);this.pages.splice(t,0,i),this.activePageIndex=t,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,t=!1){if(t){const i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,t=!1){if(t){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(t=>t.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=[...i,{id:p.generateId(),type:e,position:Math.round(t*10)/10}],this.emit()}moveGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(t*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(t=>t.id!==e),this.emit()}addElement(e,t={},i){const n=p.createRuntimeElement(e,t);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,t={},i){const n=p.createFieldElement(e);return Object.assign(n.options,t),i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}placeAtDropPoint(e,t){const i=this.templateData,n=p.zoneFromPaperPoint(i,t.x,t.y);if(n!=="content"&&!p.ZONE_ALLOWED_TYPES.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=p.getZoneRects(i)[n];return e.zone=n,e.options.left=t.x-r.left,e.options.top=t.y-r.top,n!=="content"&&p.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,t){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...t}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[t,i]of this.live){const n=e.find(r=>r.id===t);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const t=this.templateData.elements.find(i=>i.id===e);return!t||t.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let t=!1;for(const i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||p.finalizeElementZone(i,this.templateData).rejected&&(t=!0)}t&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,t,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,t),n.printElementType.type==="table"&&p.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const t=this.templateData.elements,i=t.filter(r=>this.selectedIds.has(r.id)),n=t.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=t.findIndex(c=>this.selectedIds.has(c.id)),s=e==="up"?r+1:r-1;if(s<0||s>=t.length)return;const l=[...t];[l[r],l[s]]=[l[s],l[r]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(t=>this.selectedIds.has(t.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=pt(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const t=new Map;for(const r of this.clipboard){const s=r.options.groupId;s&&t.set(s,(t.get(s)??0)+1)}const i=new Map;for(const[r,s]of t)i.set(r,s>=2?p.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const s=pt(r);s.id=p.generateId(),s.options.left+=e,s.options.top+=e,s.options.groupId=s.options.groupId?i.get(s.options.groupId):void 0,n.push(s)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,t){const i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=t;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();e&&(this.redoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,t=p.MIN_SCALE_PERCENT){this.scale=Math.max(t,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(En),t=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(t)}loadTemplate(e){this.pages=Ri(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return p.getPaperDimensions(this.templateData)}}const Qe=Symbol("mixed"),Eo=new Set(["text","longText"]),mr=["top","right","bottom","left"],gr={on:!0,off:!1,mixed:Qe};function zi(o){const e=p.resolveBorderEdgeStates(o),t={};for(const i of mr)t[i]=gr[e[i]];return t}const br=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class xr{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(t=>t.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return[];const i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=t[n]?.cells[r];s&&!s.merged&&i.push(s)}return i}get textTargets(){return this.selectedElements.filter(e=>Eo.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const t=e[0];return e.every(i=>i===t)?t:Qe}hasToken(e,t){return(e??"").split(/\s+/).includes(t)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const t=e.map(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:t.every(Boolean)?!0:t.some(Boolean)?Qe:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?Qe:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?Qe:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const t=this.targetCells;t.length&&(t.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const t=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),s="backgroundColor"in e;!(t.length&&r)&&!(i.length&&s)||(t.forEach(l=>{const c=l.options;"fontFamily"in e&&(c.fontFamily=e.fontFamily),"fontSize"in e&&(c.fontSize=e.fontSize),"color"in e&&(c.color=e.color),"textAlign"in e&&(c.textAlign=e.textAlign),"verticalAlign"in e&&(c.verticalAlign=e.verticalAlign)}),s&&i.forEach(l=>{l.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const i=this.values.bold!==!0;this.writeCells(n=>{n.fontWeight=i?"bold":void 0});return}const e=this.values.bold!==!0,t=this.textTargets;t.length&&(t.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const t=this.textTargets;if(!t.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;t.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),s=r.indexOf(e);i&&s<0&&r.push(e),!i&&s>=0&&r.splice(s,1),n.options.textDecoration=r.length?r.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,p.resolveCellGroupMode(t,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=p.resolveCellBorderDisplay(t,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const t=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=t,t===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,t){const i=this.selectedElements;i.length&&(i.forEach(n=>{p.applyElementBorderPreset(n.options,e,t)}),this.commit())}applyCellBorderPreset(e,t){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(p.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,t),this.commit())}applyCellBorderEdges(e,t,i){this.writeCells(n=>{for(const r of e)p.setCellBorderEdge(n,r,i?t:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?zi(e.map(t=>t.borders)):null}toggleCellEdge(e,t){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],t,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?zi(e.map(t=>p.elementVisibleBorders(t.options))):null}toggleElementEdge(e,t){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>p.setElementBorderEdgeVisible(r.options,e,n,t)),this.commit()}applyBorderPreset(e){const t=this.borderStyle===null;if(this.context==="cells"){const i=t&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(t||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const t=this.selectedElements;t.length&&(t.forEach(i=>p.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const t={};for(const i of p.ELEMENT_BORDER_SIDES){const n=e[i];n&&(t[i]={...n})}return t}pickPainterSource(e=!1){const t=this.selectedElements[0];if(!t)return!1;const i=t.options,n=t.printElementType.type;return this.painterSnapshot={text:Eo.has(n)?Object.fromEntries(br.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:p.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=t.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const t=this.painterSnapshot;if(!t||e.options.locked||e.id===this.painterSource)return!1;const i=e.options,n=e.printElementType.type;return t.text&&Eo.has(n)&&Object.assign(i,t.text),i.backgroundColor=t.backgroundColor,t.border&&p.acceptsElementBorder(n)&&(i.borderWidth=t.border.borderWidth,i.borderStyle=t.border.borderStyle,i.borderColor=t.border.borderColor,i.borders=this.clonePainterBorders(t.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let t=!1;e.forEach(i=>{t=this.applyPainter(i)||t}),t&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const t=e.target?.tagName;t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||this.cancelPainter()}}function Pi(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,i=Array(e);t<e;t++)i[t]=o[t];return i}function vr(o){if(Array.isArray(o))return o}function yr(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var i,n,r,s,l=[],c=!0,u=!1;try{if(r=(t=t.call(o)).next,e!==0)for(;!(c=(i=r.call(t)).done)&&(l.push(i.value),l.length!==e);c=!0);}catch(h){u=!0,n=h}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}function wr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sr(o,e){return vr(o)||yr(o,e)||Tr(o,e)||wr()}function Tr(o,e){if(o){if(typeof o=="string")return Pi(o,e);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Pi(o,e):void 0}}const Cn=Object.entries,Fi=Object.setPrototypeOf,Er=Object.isFrozen,kr=Object.getPrototypeOf,Cr=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,ft=Object.create,An=typeof Reflect<"u"&&Reflect,$o=An.apply,Bo=An.construct;re||(re=function(e){return e});se||(se=function(e){return e});$o||($o=function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(t,n)});Bo||(Bo=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return new e(...i)});const Xe=ie(Array.prototype.forEach),Ar=ie(Array.prototype.lastIndexOf),Li=ie(Array.prototype.pop),Tt=ie(Array.prototype.push),Dr=ie(Array.prototype.splice),gt=Array.isArray,Mt=ie(String.prototype.toLowerCase),ko=ie(String.prototype.toString),Ii=ie(String.prototype.match),Et=ie(String.prototype.replace),Oi=ie(String.prototype.indexOf),Mr=ie(String.prototype.trim),_r=ie(Number.prototype.toString),Rr=ie(Boolean.prototype.toString),Ni=typeof BigInt>"u"?null:ie(BigInt.prototype.toString),$i=typeof Symbol>"u"?null:ie(Symbol.prototype.toString),be=ie(Object.prototype.hasOwnProperty),kt=ie(Object.prototype.toString),le=ie(RegExp.prototype.test),Ye=zr(TypeError);function ie(o){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return $o(o,e,i)}}function zr(o){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Bo(o,t)}}function $(o,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(Fi&&Fi(o,null),!gt(e))return o;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=t(n);r!==n&&(Er(e)||(e[i]=r),n=r)}o[n]=!0}return o}function Pr(o){for(let e=0;e<o.length;e++)be(o,e)||(o[e]=null);return o}function ke(o){const e=ft(null);for(const i of Cn(o)){var t=Sr(i,2);const n=t[0],r=t[1];be(o,n)&&(gt(r)?e[n]=Pr(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ke(r):e[n]=r)}return e}function Fr(o){switch(typeof o){case"string":return o;case"number":return _r(o);case"boolean":return Rr(o);case"bigint":return Ni?Ni(o):"0";case"symbol":return $i?$i(o):"Symbol()";case"undefined":return kt(o);case"function":case"object":{if(o===null)return kt(o);const e=o,t=_e(e,"toString");if(typeof t=="function"){const i=t(e);return typeof i=="string"?i:kt(i)}return kt(o)}default:return kt(o)}}function _e(o,e){for(;o!==null;){const i=Cr(o,e);if(i){if(i.get)return ie(i.get);if(typeof i.value=="function")return ie(i.value)}o=kr(o)}function t(){return null}return t}function Lr(o){try{return le(o,""),!0}catch{return!1}}const Bi=re(["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"]),Co=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ao=re(["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"]),Ir=re(["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"]),Do=re(["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"]),Or=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hi=re(["#text"]),Wi=re(["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"]),Mo=re(["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"]),Ui=re(["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"]),Xt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Nr=se(/{{[\w\W]*|^[\w\W]*}}/g),$r=se(/<%[\w\W]*|^[\w\W]*%>/g),Br=se(/\${[\w\W]*/g),Hr=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wr=se(/^aria-[\-\w]+$/),Gi=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ur=se(/^(?:\w+script|data):/i),Gr=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qr=se(/^html$/i),Kr=se(/^[a-z][.\w]*(-[.\w]+)+$/i),qi=se(/<[/\w!]/g),Ki=se(/<[/\w]/g),jr=se(/<\/no(script|embed|frames)/i),Yr=se(/\/>/i),Ee={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Dn=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Vr=re($({},Dn)),Xr=(function(){const o={};return Xe(Dn,e=>{o[e]=se(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),re(o)})(),Zr=function(){return typeof window>"u"?null:window},Qr=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},ji=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Be=function(e,t,i,n){return be(e,t)&&gt(e[t])?$(n.base?ke(n.base):{},e[t],n.transform):i},_o=function(e,t,i){const n=be(e,t)?e[t]:void 0;return n&&typeof n=="object"?ke(n):i()};function Mn(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zr();const e=E=>Mn(E);if(e.version="3.4.14",e.removed=[],!o||!o.document||o.document.nodeType!==Ee.document||!o.Element)return e.isSupported=!1,e;let t=o.document;const i=t,n=i.currentScript;o.DocumentFragment;const r=o.HTMLTemplateElement,s=o.Node,l=o.Element,c=o.NodeFilter,u=o.NamedNodeMap;u===void 0&&(o.NamedNodeMap||o.MozNamedAttrMap),o.HTMLFormElement;const h=o.DOMParser,m=o.trustedTypes,g=l.prototype,v=_e(g,"cloneNode"),b=_e(g,"remove"),w=_e(g,"nextSibling"),T=_e(g,"childNodes"),k=_e(g,"parentNode"),z=_e(g,"shadowRoot"),W=_e(g,"attributes"),P=s&&s.prototype?_e(s.prototype,"nodeType"):null,ne=s&&s.prototype?_e(s.prototype,"nodeName"):null,ye=s&&s.prototype?_e(s.prototype,"ownerDocument"):null,Y=function(d){return P?P(d):d.nodeType},F=function(d){return ne?ne(d):d.nodeName};if(typeof r=="function"){const E=t.createElement("template");E.content&&E.content.ownerDocument&&(t=E.content.ownerDocument)}let M,G="",V,ce=!1,Z=0;const y=function(){if(Z>0)throw Ye('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.')},H=function(d){y(),Z++;try{return M.createHTML(d)}finally{Z--}},ae=function(d){y(),Z++;try{return M.createScriptURL(d)}finally{Z--}},Fe=function(){return ce||(V=Qr(m,n),ce=!0),V},L=t,ee=L.implementation,Ge=L.createNodeIterator,pe=L.createDocumentFragment,qe=L.getElementsByTagName,ot=i.importNode;let U=ji();e.isSupported=typeof Cn=="function"&&typeof k=="function"&&ee&&ee.createHTMLDocument!==void 0;const co=Nr,Ft=$r,Lt=Br,po=Hr,Ke=Wr,we=Ur,Se=Gr,uo=Kr;let It=Gi,q=null;const xt=$({},[...Bi,...Co,...Ao,...Do,...Hi]);let K=null;const it=$({},[...Wi,...Mo,...Ui,...Xt]);let ue=Object.seal(ft(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ot=null;const N=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let vt=!0,nt=!0,x=!1,O=!0,Q=!1,te=!0,De=!1,yt=!1,Nt=null,$t=null,ho=!1,rt=!1,Bt=!1,Ht=!1,li=!0,di=!1;const ci="user-content-";let fo=!0,mo=!1,at={},st=null;const pi=$({},["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 ui=null;const hi=$({},["audio","video","img","source","image","track"]);let fi=null;const mi=$({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Wt="http://www.w3.org/1998/Math/MathML",Ut="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let lt=Re,go=!1,bo=null;const Vn=$({},[Wt,Ut,Re],ko),gi=re(["mi","mo","mn","ms","mtext"]);let xo=$({},gi);const bi=re(["annotation-xml"]);let vo=$({},bi);const Xn=$({},["title","style","font","a","script"]);let wt=null;const Zn=["application/xhtml+xml","text/html"],Qn="text/html";let oe=null,dt=null;const Jn=t.createElement("form"),xi=function(d){return d instanceof RegExp||d instanceof Function},yo=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(dt&&dt===d)return;(!d||typeof d!="object")&&(d={}),d=ke(d),wt=Zn.indexOf(d.PARSER_MEDIA_TYPE)===-1?Qn:d.PARSER_MEDIA_TYPE,oe=wt==="application/xhtml+xml"?ko:Mt,q=Be(d,"ALLOWED_TAGS",xt,{transform:oe}),K=Be(d,"ALLOWED_ATTR",it,{transform:oe}),bo=Be(d,"ALLOWED_NAMESPACES",Vn,{transform:ko}),fi=Be(d,"ADD_URI_SAFE_ATTR",mi,{transform:oe,base:mi}),ui=Be(d,"ADD_DATA_URI_TAGS",hi,{transform:oe,base:hi}),st=Be(d,"FORBID_CONTENTS",pi,{transform:oe}),Te=Be(d,"FORBID_TAGS",ke({}),{transform:oe}),Ot=Be(d,"FORBID_ATTR",ke({}),{transform:oe}),at=be(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?ke(d.USE_PROFILES):d.USE_PROFILES:!1,vt=d.ALLOW_ARIA_ATTR!==!1,nt=d.ALLOW_DATA_ATTR!==!1,x=d.ALLOW_UNKNOWN_PROTOCOLS||!1,O=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=d.SAFE_FOR_TEMPLATES||!1,te=d.SAFE_FOR_XML!==!1,De=d.WHOLE_DOCUMENT||!1,rt=d.RETURN_DOM||!1,Bt=d.RETURN_DOM_FRAGMENT||!1,Ht=d.RETURN_TRUSTED_TYPE||!1,ho=d.FORCE_BODY||!1,li=d.SANITIZE_DOM!==!1,di=d.SANITIZE_NAMED_PROPS||!1,fo=d.KEEP_CONTENT!==!1,mo=d.IN_PLACE||!1,It=Lr(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Gi,lt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Re,xo=_o(d,"MATHML_TEXT_INTEGRATION_POINTS",()=>$({},gi)),vo=_o(d,"HTML_INTEGRATION_POINTS",()=>$({},bi));const f=_o(d,"CUSTOM_ELEMENT_HANDLING",()=>ft(null));if(ue=ft(null),be(f,"tagNameCheck")&&xi(f.tagNameCheck)&&(ue.tagNameCheck=f.tagNameCheck),be(f,"attributeNameCheck")&&xi(f.attributeNameCheck)&&(ue.attributeNameCheck=f.attributeNameCheck),be(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),se(ue),Q&&(nt=!1),Bt&&(rt=!0),at&&(q=$({},Hi),K=ft(null),at.html===!0&&($(q,Bi),$(K,Wi)),at.svg===!0&&($(q,Co),$(K,Mo),$(K,Xt)),at.svgFilters===!0&&($(q,Ao),$(K,Mo),$(K,Xt)),at.mathMl===!0&&($(q,Do),$(K,Ui),$(K,Xt))),N.tagCheck=null,N.attributeCheck=null,be(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?N.tagCheck=d.ADD_TAGS:gt(d.ADD_TAGS)&&(q===xt&&(q=ke(q)),$(q,d.ADD_TAGS,oe))),be(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?N.attributeCheck=d.ADD_ATTR:gt(d.ADD_ATTR)&&(K===it&&(K=ke(K)),$(K,d.ADD_ATTR,oe))),be(d,"ADD_FORBID_CONTENTS")&&gt(d.ADD_FORBID_CONTENTS)&&(st===pi&&(st=ke(st)),$(st,d.ADD_FORBID_CONTENTS,oe)),fo&&(q["#text"]=!0),De&&$(q,["html","head","body"]),q.table&&($(q,["tbody"]),delete Te.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const S=M;M=d.TRUSTED_TYPES_POLICY;try{G=H("")}catch(C){throw M=S,C}}else d.TRUSTED_TYPES_POLICY===null?(M=void 0,G=""):(M===void 0&&(M=Fe()),M&&typeof G=="string"&&(G=H("")));re&&re(d),dt=d},vi=$({},[...Co,...Ao,...Ir]),yi=$({},[...Do,...Or]),er=function(d,f,S){return f.namespaceURI===Re?d==="svg":f.namespaceURI===Wt?d==="svg"&&(S==="annotation-xml"||xo[S]):!!vi[d]},tr=function(d,f,S){return f.namespaceURI===Re?d==="math":f.namespaceURI===Ut?d==="math"&&vo[S]:!!yi[d]},or=function(d,f,S){return f.namespaceURI===Ut&&!vo[S]||f.namespaceURI===Wt&&!xo[S]?!1:!yi[d]&&(Xn[d]||!vi[d])},ir=function(d){let f=k(d);(!f||!f.tagName)&&(f={namespaceURI:lt,tagName:"template"});const S=Mt(d.tagName),C=Mt(f.tagName);return bo[d.namespaceURI]?d.namespaceURI===Ut?er(S,f,C):d.namespaceURI===Wt?tr(S,f,C):d.namespaceURI===Re?or(S,f,C):!!(wt==="application/xhtml+xml"&&bo[d.namespaceURI]):!1},$e=function(d){Tt(e.removed,{element:d});try{k(d).removeChild(d)}catch{if(b(d),!k(d))throw Ye("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},wi=function(d,f,S){try{d.removeAttributeNode(f)}catch{try{d.removeAttribute(S)}catch{}}},Gt=function(d){qt(d);const f=T(d);if(f){const C=[];Xe(f,D=>{Tt(C,D)}),Xe(C,D=>{try{b(D)}catch{}})}const S=W(d);if(S)for(let C=S.length-1;C>=0;--C){const D=S[C],R=D&&D.name;typeof R=="string"&&wi(d,D,R)}},je=function(d,f,S){if(!S)try{S=f.getAttributeNode(d)}catch{S=null}Tt(e.removed,{attribute:S||null,from:f});try{S?f.removeAttributeNode(S):f.removeAttribute(d)}catch{try{f.removeAttribute(d)}catch{}}if(d==="is")if(rt||Bt)try{$e(f)}catch{}else try{f.setAttribute(d,"")}catch{}},nr=function(d){const f=W(d);if(f)for(let S=f.length-1;S>=0;--S){const C=f[S],D=C&&C.name;typeof D!="string"||K[oe(D)]||wi(d,C,D)}},qt=function(d){const f=[d];for(;f.length>0;){const S=f.pop();Y(S)===Ee.element&&nr(S);const D=T(S);if(D)for(let R=D.length-1;R>=0;--R)f.push(D[R])}},Si=function(d,f){return te?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},rr=function(d){if(!te)return;const f=[d];for(;f.length>0;){const S=f.pop(),C=Y(S);if(C===Ee.processingInstruction||C===Ee.comment&&le(Ki,S.data)){try{b(S)}catch{}continue}if(C===Ee.element){const R=S,j=oe(F(S));try{R.hasAttribute&&R.hasAttribute("patchsrc")&&R.removeAttribute("patchsrc"),R.hasAttribute&&R.hasAttribute("for")&&Si("for",j)&&R.removeAttribute("for")}catch{}}const D=T(S);if(D)for(let R=D.length-1;R>=0;--R)f.push(D[R])}},Ti=function(d){let f=null,S=null;if(ho)d="<remove></remove>"+d;else{const R=Ii(d,/^[\r\n\t ]+/);S=R&&R[0]}wt==="application/xhtml+xml"&&lt===Re&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const C=M?H(d):d;if(lt===Re)try{f=new h().parseFromString(C,wt)}catch{}if(!f||!f.documentElement){f=ee.createDocument(lt,"template",null);try{f.documentElement.innerHTML=go?G:C}catch{}}const D=f.body||f.documentElement;return d&&S&&D.insertBefore(t.createTextNode(S),D.childNodes[0]||null),lt===Re?qe.call(f,De?"html":"body")[0]:De?f.documentElement:D},Ei=function(d){const f=ye?ye(d):d.ownerDocument;return Ge.call(f||d,d,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(d){return d=Et(d,co," "),d=Et(d,Ft," "),d=Et(d,Lt," "),d},wo=function(d){var f;d.normalize();const S=ye?ye(d):d.ownerDocument,C=Ge.call(S||d,d,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let D=C.nextNode();for(;D;)D.data=Kt(D.data),D=C.nextNode();const R=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");R&&Xe(R,j=>{ct(j.content)&&wo(j.content)})},jt=function(d){const f=ne?ne(d):null;return typeof f!="string"||oe(f)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==W(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==P(d)||d.childNodes!==T(d)},ct=function(d){if(!P||typeof d!="object"||d===null)return!1;try{return P(d)===Ee.documentFragment}catch{return!1}},St=function(d){if(!P||typeof d!="object"||d===null)return!1;try{return typeof P(d)=="number"}catch{return!1}};function ze(E,d,f){E.length!==0&&Xe(E,S=>{S.call(e,d,f,dt)})}const ar=function(d,f){return!!(te&&d.hasChildNodes()&&!St(d.firstElementChild)&&le(qi,d.textContent)&&le(qi,d.innerHTML)||te&&d.namespaceURI===Re&&Vr[f]&&(St(d.firstElementChild)||typeof d.textContent=="string"&&le(Xr[f],d.textContent))||d.nodeType===Ee.processingInstruction||te&&d.nodeType===Ee.comment&&le(Ki,d.data))},Yt=function(d,f){if(d instanceof RegExp)return le(d,f);if(d instanceof Function){for(var S=arguments.length,C=new Array(S>2?S-2:0),D=2;D<S;D++)C[D-2]=arguments[D];return!!d(f,...C)}return!1},sr=function(d,f,S){if(!Te[f]&&Mi(f)&&Yt(ue.tagNameCheck,f))return!1;if(fo&&!st[f]){const C=k(d),D=T(d);if(D&&C){const R=D.length;for(let j=R-1;j>=0;--j){const X=d===S?v(D[j],!0):D[j];C.insertBefore(X,w(d))}}}return $e(d),!0},ki=function(d,f,S,C){return d.length===0?f:f===S||f===C?ke(f):f},Ci=function(d,f){return d===f||k(d)!==null?!1:(mo&&qt(d),!0)},Ai=function(d,f){if(ze(U.beforeSanitizeElements,d,null),Ci(d,f))return!0;if(jt(d))return $e(d),!0;const S=oe(F(d));if(q=ki(U.uponSanitizeElement,q,xt,Nt),ze(U.uponSanitizeElement,d,{tagName:S,allowedTags:q}),Ci(d,f))return!0;if(ar(d,S))return $e(d),!0;if(Te[S]||!(N.tagCheck instanceof Function&&N.tagCheck(S))&&!q[S]){const D=sr(d,S,f);return D===!1&&ze(U.afterSanitizeElements,d,null),D}if(Y(d)===Ee.element&&!ir(d)||(S==="noscript"||S==="noembed"||S==="noframes")&&le(jr,d.innerHTML))return $e(d),!0;if(Q&&d.nodeType===Ee.text){const D=Kt(d.textContent);d.textContent!==D&&(Tt(e.removed,{element:d.cloneNode()}),d.textContent=D)}return ze(U.afterSanitizeElements,d,null),!1},Di=function(d,f,S){if(Ot[f]||Si(f,d)||li&&(f==="id"||f==="name")&&(S in t||S in Jn))return!1;const C=K[f]||N.attributeCheck instanceof Function&&N.attributeCheck(f,d);return nt&&le(po,f)||vt&&le(Ke,f)?!0:C?fi[f]||le(It,Et(S,Se,""))||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Oi(S,"data:")===0&&ui[d]||x&&!le(we,Et(S,Se,""))?!0:!S:Mi(d)&&Yt(ue.tagNameCheck,d)&&Yt(ue.attributeNameCheck,f,d)||f==="is"&&ue.allowCustomizedBuiltInElements&&Yt(ue.tagNameCheck,S)},lr=$({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Mi=function(d){return!lr[Mt(d)]&&le(uo,d)},dr=function(d,f,S,C){if(M&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!S)switch(m.getAttributeType(d,f)){case"TrustedHTML":return H(C);case"TrustedScriptURL":return ae(C)}return C},cr=function(d,f,S,C){try{S?d.setAttributeNS(S,f,C):d.setAttribute(f,C),jt(d)?$e(d):Li(e.removed)}catch{je(f,d)}},_i=function(d){ze(U.beforeSanitizeAttributes,d,null);const f=d.attributes;if(!f||jt(d))return;K=ki(U.uponSanitizeAttribute,K,it,$t);const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let C=f.length;const D=oe(d.nodeName);for(;C--;){const R=f[C],j=R.name,X=R.namespaceURI,me=R.value,ge=oe(j),To=me;let he=j==="value"?To:Mr(To);if(S.attrName=ge,S.attrValue=he,S.keepAttr=!0,S.forceKeepAttr=void 0,ze(U.uponSanitizeAttribute,d,S),he=S.attrValue,di&&(ge==="id"||ge==="name")&&Oi(he,ci)!==0&&(je(j,d,R),he=ci+he),te&&le(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,he)){je(j,d,R);continue}if(ge==="attributename"&&Ii(he,"href")){je(j,d,R);continue}if(!S.forceKeepAttr){if(!S.keepAttr){je(j,d,R);continue}if(!O&&le(Yr,he)){je(j,d,R);continue}if(Q&&(he=Kt(he)),!Di(D,ge,he)){je(j,d,R);continue}he=dr(D,ge,X,he),he!==To&&cr(d,j,X,he)}}ze(U.afterSanitizeAttributes,d,null)},Vt=function(d){let f=null;const S=Ei(d);for(ze(U.beforeSanitizeShadowDOM,d,null);f=S.nextNode();)if(ze(U.uponSanitizeShadowNode,f,null),Ai(f,d),_i(f),ct(f.content)&&Vt(f.content),Y(f)===Ee.element){const C=z(f);ct(C)&&(So(C),Vt(C))}ze(U.afterSanitizeShadowDOM,d,null)},So=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const S=f.pop();if(S.shadow){Vt(S.shadow);continue}const C=S.node,R=Y(C)===Ee.element,j=T(C);if(j)for(let X=j.length-1;X>=0;--X)f.push({node:j[X],shadow:null});if(R){const X=ne?ne(C):null;if(typeof X=="string"&&oe(X)==="template"){const me=C.content;ct(me)&&f.push({node:me,shadow:null})}}if(R){const X=z(C);ct(X)&&f.push({node:null,shadow:X},{node:X,shadow:null})}}};return e.sanitize=function(E){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,S=null,C=null,D=null;if(go=!E,go&&(E="<!-->"),typeof E!="string"&&!St(E)&&(E=Fr(E),typeof E!="string"))throw Ye("dirty is not a string, aborting");if(!e.isSupported)return E;yt?(q=Nt,K=$t):yo(d),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(q=ke(q)),U.uponSanitizeAttribute.length>0&&(K=ke(K)),e.removed=[];const R=mo&&typeof E!="string"&&St(E);if(R){rr(E);const me=F(E);if(typeof me=="string"){const ge=oe(me);if(!q[ge]||Te[ge])throw Gt(E),Ye("root node is forbidden and cannot be sanitized in-place")}if(jt(E))throw Gt(E),Ye("root node is clobbered and cannot be sanitized in-place");try{So(E)}catch(ge){throw Gt(E),ge}}else if(St(E))f=Ti("<!---->"),S=f.ownerDocument.importNode(E,!0),S.nodeType===Ee.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?f=S:f.appendChild(S),So(S);else{if(!rt&&!Q&&!De&&E.indexOf("<")===-1)return M&&Ht?H(E):E;if(f=Ti(E),!f)return rt?null:Ht?G:""}f&&ho&&$e(f.firstChild);const j=R?E:f;try{const me=Ei(j);for(;C=me.nextNode();)Ai(C,j),_i(C),ct(C.content)&&Vt(C.content)}catch(me){throw R&&(Gt(E),Xe(e.removed,ge=>{ge.element&&qt(ge.element)})),me}if(R)return Xe(e.removed,me=>{me.element&&qt(me.element)}),Q&&wo(E),E;if(rt){if(Q&&wo(f),Bt)for(D=pe.call(f.ownerDocument);f.firstChild;)D.appendChild(f.firstChild);else D=f;return(K.shadowroot||K.shadowrootmode)&&(D=ot.call(i,D,!0)),D}let X=De?f.outerHTML:f.innerHTML;return De&&q["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&le(qr,f.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
3
+ `+X),Q&&(X=Kt(X)),M&&Ht?H(X):X},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yo(E),yt=!0,Nt=q,$t=K},e.clearConfig=function(){dt=null,yt=!1,Nt=null,$t=null,M=V,G=""},e.isValidAttribute=function(E,d,f){dt||yo({});const S=oe(E),C=oe(d);return Di(S,C,f)},e.addHook=function(E,d){typeof d=="function"&&be(U,E)&&Tt(U[E],d)},e.removeHook=function(E,d){if(be(U,E)){if(d!==void 0){const f=Ar(U[E],d);return f===-1?void 0:Dr(U[E],f,1)[0]}return Li(U[E])}},e.removeHooks=function(E){be(U,E)&&(U[E]=[])},e.removeAllHooks=function(){U=ji()},e}var Jr=Mn();const ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ta(o){const e=o.options;return String(e.testData||e.formatter||e.title||"")||"条码"}function oa(o){return a("div",{class:"print-qrcode",dataset:{codeId:o.id,codeKind:"qrcode"}})}function ia(o){const e=o.options;return a("div",{class:"print-barcode",dataset:{codeId:o.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:ea[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function na(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}function ra(o,e){const t=o.options,i=p.barcodeUnitsPerModule(t.barWidth),n=p.barcodeQuietZoneModules(t.barQuietZone),r=s=>{wn(e,ta(o),{format:String(t.barcodeType||"CODE128"),width:i,height:s*i,displayValue:!t.hideTitle,fontSize:(t.fontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*i,margin:0,marginLeft:n*i,marginRight:n*i,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*i});const l=na(e);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const s=p.layoutBarcodeSize({barHeightMm:t.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(t.width,t.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(t.height,t.maxHeight),dpi:t.printerDpi,barWidth:t.barWidth,measure:r});e.style.width=s.size?`${s.size.widthMm}mm`:"",e.style.height=s.size?`${s.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function aa(o,e){const t=o.options,i=String(t.testData||t.formatter||t.title||"")||"二维码";e.replaceChildren();try{const n=Vo.browserCodeRenderer.render(i,"qrcode",{qrCodeLevel:String(t.qrCodeLevel??"M"),qrQuietZone:typeof t.qrQuietZone=="number"?t.qrQuietZone:void 0}),r=document.createElement("img");r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,r.alt="qrcode",r.style.width="100%",r.style.height="100%",r.style.objectFit=String(t.fit||"contain"),r.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",r.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",e.appendChild(r)}catch{}}function sa(o,e){for(const t of Array.from(o.querySelectorAll("[data-code-kind]"))){const i=t.dataset.codeId,n=e.find(r=>r.id===i);if(n)if(t.dataset.codeKind==="barcode"){const r=t.querySelector("svg");r&&ra(n,r)}else aa(n,t)}}const la={header:"题",data:"数",subtotal:"小",summary:"汇"},da=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],eo=3.7795275591,ca=.1,Ho=o=>JSON.parse(JSON.stringify(o)),Yi=new WeakMap;function Ne(o){let e=Yi.get(o);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Yi.set(o,e)),e}function Pt(o,e){return o.templateData.elements.find(t=>t.id===e)??null}function pa(o,e){const t=o.tableSelection;return!t||t.elementId!==e.id?null:o.selectedElement?.id!==e.id?(o.tableSelection=null,null):t}function _n(o,e,t){const i=Pt(o,t.id);if(!i)return null;const n=t.options;return{store:o,fire:e,el:t,real:i,options:n,rows:n.tableRows??[],colWidths:n.tableColWidths??[],isSelected:o.selectedIds.has(t.id),selection:pa(o,t),maxTableWidth:Rn(o)}}function Rn(o){return o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right}function Zo(o){return o.options.tableDefaultFontSize??10}function zn(o){return o.options.tableDefaultColor??"#333333"}function ua(o,e){let t=0;for(let i=0;i<e;i++)t+=o.rows[i].height;return t}function ha(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.top??ua(o,e)}function fa(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.height??o.rows[e]?.height??0}function ma(o){const e=o.options.dataSource;if(e&&Array.isArray(p.DEFAULT_DEMO_DATA[e]))return p.DEFAULT_DEMO_DATA[e];for(const t of Object.values(p.DEFAULT_DEMO_DATA))if(Array.isArray(t))return t}function Pn(o){return o.cellType==="barcode"||o.cellType==="qrcode"}function Fn(o,e){return Pn(e)?p.resolveBarcodeDesignValue(e.formatter,ma(o)):e.formatter||""}function ga(o,e){const t={designMode:!0,showGhostBorder:o.store.showTableGhostBorder};return{fontFamily:A.resolveCanvasFontFamily(e.fontFamily??o.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??Zo(o))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??zn(o),backgroundColor:e.backgroundColor??"transparent",borderTop:p.resolveCellBorderCss(e.borders?.top,t),borderRight:p.resolveCellBorderCss(e.borders?.right,t),borderBottom:p.resolveCellBorderCss(e.borders?.bottom,t),borderLeft:p.resolveCellBorderCss(e.borders?.left,t),padding:(e.padding??o.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ba(o,e,t){const i=o.selection;return[!!i&&e>=i.r1&&e<=i.r2&&t>=i.c1&&t<=i.c2?"cell-selected":"",o.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Ln(o){return p.resolveCellTextFit(o)}function xa(o){return Ln(o)!=="autoHeight"}function va(o,e){return e.fontSize??Zo(o)}function ro(o,e,t){return p.cellFitCapMm(o.rows,e,t,o.options.tableDefaultPadding??1)}function ya(o,e,t){return p.cellFitWidthMm(o.colWidths,e,t,o.options.tableDefaultPadding??1)}function wa(o,e,t){return{maxHeight:ro(o,t,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Sa(o,e,t){const i={fitBase:String(va(o,e)),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(ro(o,t,e))};return Ln(e)==="shrink"&&(i.fit="shrink"),i}function Ta(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}const Ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ka(o,e,t,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(fr,"svg");n.appendChild(r);const s=Fn(o,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Ea[i.fit||"contain"]??"xMidYMid meet");const l=p.barcodeUnitsPerModule(i.barWidth),c=p.barcodeQuietZoneModules(i.barQuietZone),u=g=>{wn(r,s,{format:i.barcodeType||"CODE128",width:l,height:g*l,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*l});const v=Ta(r);return v?{widthUnits:v.width,heightUnits:v.height}:null};let h=null;try{h=p.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(ya(o,t,i),i.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(ro(o,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=s||"条码",n.appendChild(g),n}const m=h.size;return m?(r.style.width=`${m.widthMm}mm`,r.style.height=`${m.heightMm}mm`):(r.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",r.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),n}if(r.style.display="none",!s)return n;try{const l=Vo.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.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=i.fit||"contain",i.objectPosition&&(c.style.objectPosition=i.objectPosition),c.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",c.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(c)}catch{}return n}function Vi(){const o=document.createElement("div");return o.className="image-placeholder",o.textContent="图片",o}function Ca(o){const e=o.formatter||"";return e?e.includes("{")?p.evaluateTemplate(e,p.DEFAULT_DEMO_DATA):e:""}function Aa(o,e,t){const i=document.createElement("div");i.className="cell-image";const n=p.cellImageBoxMm(t.fit,ro(o,e,t));n!==void 0&&(i.style.height=`${n}mm`);const r=Ca(t);if(!r)return i.appendChild(Vi()),i;const s=document.createElement("img");s.setAttribute("src",r),n!==void 0&&(s.style.width="100%",s.style.height="100%"),s.style.objectFit=t.fit||"contain";for(const[l,c]of Object.entries(p.cropStyleDeclarations(t.fit,t.fitScale,t.objectPosition)))s.style[l]=c;return s.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",s.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",s.addEventListener("error",()=>{s.remove(),i.appendChild(Vi())},{once:!0}),i.appendChild(s),i}function Da(o,e,t,i,n){if(Pn(n))return ka(o,t,i,n);if(n.cellType==="image")return Aa(o,t,n);const r=Fn(o,n),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return xa(n)?a("div",{class:"cell-fit",style:wa(o,n,t),dataset:Sa(o,n,t)},[s()]):s()}function oo(o,e,t){const i={elementId:o.el.id,...p.normalizeSelection(o.rows,e,t)};o.store.setTableSelection(i),o.fire("table-selection-change",{elementId:o.el.id,selection:i})}function Ma(o,e,t,i,n){if(n.button!==0||(o.fire("table-cell-mousedown",{elementId:o.el.id,r:e,c:t,cellId:i,event:n}),!o.isSelected))return;n.stopPropagation();const r=Ne(o.store);n.shiftKey&&o.selection?oo(o,{r:o.selection.r1,c:o.selection.c1},{r:e,c:t}):(r.anchor={r:e,c:t},oo(o,{r:e,c:t},{r:e,c:t})),document.addEventListener("mouseup",()=>{Ne(o.store).anchor=null},{once:!0})}function _a(o,e,t){const i=Ne(o.store).anchor;i&&oo(o,i,{r:e,c:t})}function In(o,e){const t=Ne(o);t.menu?.visible&&(t.menu.visible=!1,e("table-menu-close",{elementId:t.menuElId}),o.emit(!1))}function Ra(o,e,t,i){i.preventDefault(),i.stopPropagation(),o.isSelected||o.store.selectOne(o.el.id);const n=o.selection;n&&e>=n.r1&&e<=n.r2&&t>=n.c1&&t<=n.c2||oo(o,{r:e,c:t},{r:e,c:t});const s=Ne(o.store);s.menuElId=o.el.id,s.menu&&(s.menu.x=i.clientX,s.menu.y=i.clientY,s.menu.visible=!0),o.fire("table-cell-contextmenu",{elementId:o.el.id,r:e,c:t,clientX:i.clientX,clientY:i.clientY}),o.store.emit(!1),document.addEventListener("mousedown",()=>In(o.store,o.fire),{once:!0})}function Xi(o,e,t){const i=o.reduce((n,r)=>n+r,0)+(o[e]??0);return i>t?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${t}mm,请先缩小列宽`:null}function za(o,e){const t=o.real.options.tableRows??[],i=o.real.options.tableColWidths??[],n=e(Ho(t),Ho(i));return n?(window.alert(n),!1):(o.store.recordHistory(),e(t,i),o.store.setTableSelection(null),p.syncTableElementSize(o.real.options),o.store.emit(),!0)}function Le(o,e,t){In(o.store,o.fire);const i=o.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(p.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(p.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>p.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,s)=>{const l=Xi(s,i.c1,o.maxTableWidth);return l||(p.insertCol(r,s,i.c1,"left"),null)};break;case"insert-col-right":n=(r,s)=>{const l=Xi(s,i.c2,o.maxTableWidth);return l||(p.insertCol(r,s,i.c2,"right"),null)};break;case"delete-col":n=(r,s)=>p.deleteCol(r,s,i.c1);break;case"merge":n=r=>(p.mergeCells(r,i),null);break;case"split":n=r=>(p.splitCells(r,i),null);break;case"set-row-type":n=r=>t?p.setRowType(r,i.r1,t):"未指定行类型";break}n&&za(o,n)&&o.fire(`table-${e}`,{elementId:o.el.id,...t?{type:t}:{}})}function Pa(o){const e=o.selection;if(!e)return!1;for(let t=e.r1;t<=e.r2;t++)for(let i=e.c1;i<=e.c2;i++){const n=o.rows[t]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function Zi(o,e){const t=o.selection;return t?t.r1!==t.r2?"行类型仅支持单行设置":p.setRowType(Ho(o.rows),t.r1,e):"未选择单元格"}function Ie(o,e,t={}){return a("div",{class:`menu-item${t.disabled?" disabled":""}${t.active?" active":""}`,title:t.title||"",text:o,onClick:()=>{t.disabled||e()}})}const Ro=()=>a("div",{class:"menu-divider"});function Fa(o,e,t){const i=Ne(o);if(i.menu=t,!t.visible||!i.menuElId)return"";const n=Pt(o,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=_n(o,e,n);if(!r)return"";const s=r.selection?p.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:t.x+"px",top:t.y+"px"},onMousedown:c=>c.stopPropagation()},[Ie("在上方插入行",()=>Le(r,"insert-row-above")),Ie("在下方插入行",()=>Le(r,"insert-row-below")),Ie("删除行",()=>Le(r,"delete-row"),{disabled:r.rows.length<=1}),Ro(),Ie("在左侧插入列",()=>Le(r,"insert-col-left")),Ie("在右侧插入列",()=>Le(r,"insert-col-right")),Ie("删除列",()=>Le(r,"delete-col"),{disabled:r.colWidths.length<=1}),Ro(),Ie("合并单元格",()=>Le(r,"merge"),{disabled:!!s,title:s||""}),Ie("拆分单元格",()=>Le(r,"split"),{disabled:!Pa(r)}),Ro(),a("div",{class:"menu-group-title",text:"行类型"}),...da.map(c=>Ie(c.label,()=>Le(r,"set-row-type",c.value),{disabled:!!Zi(r,c.value),title:Zi(r,c.value)||"",active:l===c.value}))])}let et=null;function On(){et&&(document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo),et.handle.classList.remove("dragging"),et=null)}function La(o,e){const t=o.closest(".hiprint-printPaper");return(t&&t.offsetWidth>0?t.getBoundingClientRect().width/t.offsetWidth:0)||(e.scale||100)/100}function Ia(o,e,t){if(t.button!==0)return;const i=t.currentTarget,n=i.closest(".print-table");if(!n)return;On();const r=o.real.options.tableColWidths??[];et={store:o.store,fire:o.fire,elId:o.real.id,boundary:e,startX:t.clientX,startWidth:r[e-1]??0,scale:La(n,o.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),o.store.recordHistory(),document.addEventListener("mousemove",Qo),document.addEventListener("mouseup",Jo)}function Qo(o){const e=et;if(!e)return;const t=Pt(e.store,e.elId),i=t?.options.tableColWidths;if(!t||!i)return;const n=(o.clientX-e.startX)/(e.scale*eo),r=e.boundary-1;i[r]=p.clampResizedColumnWidth(i,r,e.startWidth+n,Rn(e.store)),p.syncTableElementSize(t.options),i.forEach((s,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${i.slice(0,l+1).reduce((c,u)=>c+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${t.options.width}mm`,e.wrapper.style.height=`${t.options.height}mm`)}function Jo(){document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo);const o=et;if(!o)return;et=null,o.handle.classList.remove("dragging");const e=Pt(o.store,o.elId);e&&p.syncTableElementSize(e.options),o.store.emit(),o.fire("table-col-resize-end",{elementId:o.elId})}function Oa(o,e,t){const i=t.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Pt(o,e);if(!r)return;let s=!1;const l=n/eo;Math.abs(l-(r.options.height??0))>ca&&(r.options.height=Math.round(l*100)/100,s=!0);const c=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-c)/eo,height:m.offsetHeight/eo})),h=Ne(o);Na(h.layouts.get(e),u)||(h.layouts.set(e,u),s=!0),s&&o.emit(!1)}function Na(o,e){return!o||o.length!==e.length?!1:e.every((t,i)=>{const n=o[i];return Math.round(t.top*10)===Math.round(n.top*10)&&Math.round(t.height*10)===Math.round(n.height*10)})}function $a(o,e){const t=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!t.isConnected)return;const i=t.parentElement;i&&Oa(o,e,i)}),t}function Ba(o){return o.isSelected&&!o.real.options.locked&&o.colWidths.length>=1}function Ha(o){return Array.from({length:o.colWidths.length},(e,t)=>t+1)}function Wa(o,e){return o.colWidths.slice(0,e).reduce((t,i)=>t+i,0)}function Ua(o,e,t){const i=_n(e,t,o);if(!i)return a("div",{class:"print-table"});const n=[a("table",{style:{fontSize:`${Zo(i)}pt`,color:zn(i)}},[a("colgroup",{},i.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},i.rows.map((r,s)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((l,c)=>l.merged?"":a("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ba(i,s,c),style:ga(i,l),onMousedown:u=>Ma(i,s,c,l.id,u),onMouseenter:()=>_a(i,s,c),onContextmenu:u=>Ra(i,s,c,u)},[Da(i,r,s,c,l)])).filter(Boolean))))])];return Ba(i)&&n.push(a("div",{class:"col-resize-layer"},Ha(i).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:Wa(i,r)+"mm"},onMousedown:s=>{s.stopPropagation(),s.preventDefault(),Ia(i,r,s)}})))),i.isSelected&&n.push(a("div",{class:"row-badges"},i.rows.map((r,s)=>a("span",{class:"row-badge",style:{top:ha(i,s)+"mm",height:fa(i,s)+"mm"},text:la[r.type]})))),n.push($a(e,o.id)),a("div",{class:"print-table design-mode",dataset:{tableId:o.id},onContextmenu:r=>r.preventDefault()},n)}const Ga=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function Wo(o){return Array.isArray(o)&&o.length>0?o:[]}function qa(o,e){const t=p.detectFlowListKey(o,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(t)return Wo(e?.[t]);const i=p.detectFlowListKey(o,p.DEFAULT_DEMO_DATA);return i?Wo(p.DEFAULT_DEMO_DATA[i]):[]}function Ka(o,e){const t=o.options,i=typeof t.formatter=="string"?t.formatter:"",n=Wo(e)[0],r=qa(i,n);if(r.length===0)return[...Ga];if(!i)return r.map(c=>String(c?.name??JSON.stringify(c)));const s=n??{},l=p.detectFlowListKey(i,s)??Object.keys(s).find(c=>Array.isArray(s[c]));return r.map(c=>{try{return p.evaluateTemplate(i,{...s,...c,...l?{[l]:c}:{}})}catch{return i}})}function ja(o,e){const t=o.options,i=p.resolveFlowColumns(t.flowColumns),n=p.resolveFlowGapX(t.flowGapX),r=p.resolveFlowRowHeight(t.flowRowHeight),s={display:"grid",gridTemplateColumns:`repeat(${i},minmax(0,1fr))`,columnGap:`${n}mm`,gridAutoRows:`minmax(${r}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${t.fontSize||12}pt`,fontWeight:t.fontWeight||"normal",color:t.color||"#333",boxSizing:"border-box"};return t.fontFamily&&(s.fontFamily=String(t.fontFamily)),t.backgroundColor&&(s.backgroundColor=String(t.backgroundColor)),a("div",{class:"print-flowlist",style:s},Ka(o,e).map(l=>a("div",{class:"print-flow-cell",text:l})))}const Qi={top:"flex-start",middle:"center",bottom:"flex-end"},Ya={left:"flex-start",center:"center",right:"flex-end"};function Va(o,e){const t=o.options,i=p.resolveElementBorder(o.printElementType.type,t),n={};if(i?.all&&(n.border=`${i.all.borderWidth} ${i.all.borderStyle} ${i.all.borderColor}`),i)for(const r of p.ELEMENT_BORDER_SIDES){const s=i.edges[r];s&&(n[`border${r.charAt(0).toUpperCase()}${r.slice(1)}`]=`${s.borderWidth} ${s.borderStyle} ${s.borderColor}`)}return{position:"absolute",left:`${t.left}mm`,top:`${t.top}mm`,width:`${t.width}mm`,height:`${t.height}mm`,zIndex:String(t.zIndex||"auto"),...n,...Xa(o,e)}}function Xa(o,e){if(e?.has(o.id))return{};const t=p.resolveElementRotation(o.printElementType.type,o.options);return t===void 0?{}:{rotate:`${t}deg`}}function Ji(o){const e=o.options,t=o.printElementType.type==="longText",i=p.resolveElementTextFit(o.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",s={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:t?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...t?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};p.resolveElementNowrap(e)&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis");const l=p.resolveElementWhiteSpace(e);return l&&(s.whiteSpace=l),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Qi[e.verticalAlign]??"flex-start"):(s.alignItems=Qi[e.verticalAlign]??"flex-start",s.justifyContent=Ya[e.textAlign||"left"]??"flex-start")),{style:s,fit:i}}function Za(o){const e=o.options,t=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return o.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${t} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${t} ${i} ${n}`,boxSizing:"border-box"}}function Qa(o){const e=o.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:o.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ja(o){const e=o.options;return{objectFit:e.fit||"contain",...p.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function en(o){const e=o.options,t={fitBase:String(e.fontSize||12),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return p.resolveElementTextFit(o.printElementType.type,e)==="shrink"&&(t.fit="shrink"),t}function es(o,e,t){const i=o.printElementType.type,n=o.options;switch(i){case"text":{const{style:r}=Ji(o);return a("div",{class:"print-text",style:r,dataset:en(o),text:String(n.testData||n.formatter||"")||"文本"})}case"longText":{const{style:r}=Ji(o);return a("div",{class:"print-longtext",style:r,dataset:en(o),text:String(n.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:Za(o)});case"rect":case"oval":return a("div",{class:"print-shape",style:Qa(o)});case"image":{const r=String(n.src??""),s=r.includes("{")?p.evaluateTemplate(r,p.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[s?a("img",{src:s,style:Ja(o)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return oa(o);case"barcode":return ia(o);case"html":{const r=String(n.formatter??""),s=r?Jr.sanitize(p.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:s})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:n.title||"{pageIndex}/{totalPages}"});case"table":return t?Ua(o,t.store,t.fire):a("div",{class:"print-table"});case"flowList":return ja(o);default:return a("div",{text:i})}}function Nn(o){return`x:${Math.round(o.left)} y:${Math.round(o.top)} ${Math.round(o.width)}×${Math.round(o.height)}mm`}function ts(o,e,t){const i=o.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),s=e.options,l=e.zone||"content",c=[es(e,!0,{store:i,fire:o.fire})];return i.draggingIds.has(e.id)&&c.push(a("div",{class:"drag-preview"})),n&&(c.push(a("div",{class:"resize-handles"},p.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>o.fire("resize-start",{event:h,id:e.id,point:u})})))),c.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Nn(s)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${l}`,n?"selected":"",r?"previewed":"",i.draggingIds.has(e.id)?"drag-ghost":"","design-mode",s.locked?"locked":"",s.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Va(e,t),dataset:{elId:e.id},onMousedown:u=>o.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),o.fire("contextmenu",{event:u,id:e.id})}},c)}function Uo(o,e){const t=o.margins,i=o.header?.height??10,n=o.footer?.height??10,r=e.width-t.left-t.right;return{header:{left:t.left,top:t.top,width:r,height:i},content:{left:t.left,top:t.top+i,width:r,height:e.height-t.top-t.bottom-i-n},footer:{left:t.left,top:e.height-t.bottom-n,width:r,height:n}}}const os='<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 tn(o,e){return o.type==="vertical"?{left:`${o.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${o.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}}function is(o,e){const t=A.resolveWatermarkLayout(o.watermark,[],e);return t?a("div",{class:"watermark-layer",style:{opacity:String(t.opacity)}},t.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${t.tileWidthPx} ${t.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(t.tileWidthPx/2),y:String(t.tileHeightPx/2),"font-size":String(t.fontSizePx),fill:t.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${t.rotate},${t.tileWidthPx/2},${t.tileHeightPx/2})`,text:t.text})]))):""}function zo(o,e,t,i,n,r){const s=o.store,l=[];t!=="content"&&l.push(a("span",{class:"zone-label",text:t==="header"?"页眉":"页脚"}));const c=t==="content"?A.collectFollowMemberIds(n):void 0;if(l.push(...n.map(u=>ts(o,u,c))),t!=="content"){const u=t==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:t},onMousedown:h=>o.fire("zone-resize",{event:h,zone:t})},[e.zoneResizing===t?a("div",{class:"zone-height-tip",text:`${(t==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${t} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:t,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function ns(o,e){const t=o.store,i=t.templateData,n=A.getPaperDimensions(i),r=(t.scale||100)/100,s=Uo(i,n),l=m=>t.elements.filter(g=>(g.zone||"content")===m),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[t.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(os)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[is(i,n)]:[],zo(o,e,"header",s.header,l("header"),n),zo(o,e,"content",s.content,l("content"),n),zo(o,e,"footer",s.footer,l("footer"),n),...t.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:tn(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...tn(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>o.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),o.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.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(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],c]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${A.mmToPx(n.width)*r}px`,height:`${A.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(t.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Me(o,m,"复制","copy"),Me(o,m,"剪切","cut"),Me(o,m,"粘贴","paste",!t.hasClipboard),Me(o,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Me(o,m,"置顶","move-layer",!1,"top"),Me(o,m,"上移","move-layer",!1,"up"),Me(o,m,"下移","move-layer",!1,"down"),Me(o,m,"置底","move-layer",!1,"bottom")]:[Me(o,m,"粘贴","paste-at",!t.hasClipboard),Me(o,m,"全选","select-all"),Me(o,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>m.preventDefault(),onDrop:m=>o.fire("drop",m),onMousedown:m=>o.fire("canvas-mousedown",m),onMousemove:m=>o.fire("canvas-mousemove",m),onMouseleave:()=>o.fire("canvas-mouseleave"),onWheel:m=>o.fire("wheel",m),onScroll:m=>o.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),o.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Me(o,e,t,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:t,onClick:()=>{e.visible=!1,n||o.fire(i,r),o.repaint()}})}const rs={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function ve(o,e=15,t){const i=rs[o];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${t?` class="${t}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let Je=null;function ei(o){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(o.trim());if(!e)return null;const t=e[1],i=t.length===3?t.split("").map(n=>n+n).join(""):t;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function ti(o){const e=ei(o);return e?$n(e):"#000000"}function $n({r:o,g:e,b:t}){return`#${[o,e,t].map(i=>Math.round(zt(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function as(o,e,t){const i=o/255,n=e/255,r=t/255,s=Math.max(i,n,r),l=Math.min(i,n,r),c=s-l;let u=0;return c!==0&&(s===i?u=(n-r)/c%6:s===n?u=(r-i)/c+2:u=(i-n)/c+4,u*=60,u<0&&(u+=360)),{h:u,s:s===0?0:c/s,v:s}}function ss(o,e,t){const i=t*e,n=(o%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[s,l,c]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=t-i;return{r:(s+u)*255,g:(l+u)*255,b:(c+u)*255}}function ls(o){return((Number.isFinite(o)?o:0)%360+360)%360}function zt(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function ds(o){const e=o.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${o.triggerClass?` ${o.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:t=>{const i=t.currentTarget??t.target,n=i.getRootNode();if(!!Je&&Je.root===n&&Je.title===e&&Je.trigger===i){_t();return}_t(),cs(i,o)}},[a("span",{class:"preset-color-swatch",style:o.value?{background:o.value}:{background:"transparent"}})])}function _t(){const o=Je;o&&(Je=null,o.teardowns.forEach(e=>e()),o.trigger.setAttribute("aria-expanded","false"),o.panel.remove())}function cs(o,e){const t=o.getRootNode(),i=t instanceof ShadowRoot?t:document.body,n={root:t,title:e.title??"颜色选择",trigger:o,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&ii(n,e.value)?n.hexText=ti(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=fe(fs(n),i),n.current=n.panel.querySelector(".picker-current"),n.hex=n.panel.querySelector(".picker-hex"),n.area=n.panel.querySelector(".picker-area"),n.handle=n.panel.querySelector(".picker-handle"),n.hueRange=n.panel.querySelector(".picker-hue"),n.clearBtn=n.panel.querySelector(".picker-clear"),n.items=Array.from(n.panel.querySelectorAll(".preset-color-item")).map((r,s)=>({el:r,color:p.PRESET_COLORS[s]})),ao(n),ps(n),us(n),Je=n,o.setAttribute("aria-expanded","true")}function ps(o){const e=o.trigger.getBoundingClientRect(),t=190,i=o.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-t-n)),s=e.bottom+6,l=s+i>window.innerHeight-n?Math.max(n,e.top-i-6):s;o.panel.style.left=`${r}px`,o.panel.style.top=`${l}px`}function us(o){const e=n=>{const r=hs(n);r.includes(o.trigger)||r.includes(o.panel)||_t()},t=n=>{n.key==="Escape"&&_t()},i=()=>_t();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),o.root.addEventListener("scroll",i,!0),o.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",t),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>o.root.removeEventListener("scroll",i,!0))}function hs(o){const e=typeof o.composedPath=="function"?o.composedPath():[];return e.length?e:[o.target]}function fs(o){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>gs(o,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>bs(o,e),onKeydown:e=>xs(o,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>vs(o,Number(e.target.value)),onChange:()=>ni(o)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),o.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>io(o,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},p.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ms(o,e)})))])}function oi(o){return $n(ss(o.hue,o.saturation,o.value_))}function ao(o){const e=oi(o);o.hex.value!==o.hexText&&(o.hex.value=o.hexText),o.current.className=o.model?"picker-current":"picker-current is-empty",o.model?o.current.style.background=e:o.current.style.removeProperty("background"),o.area.style.setProperty("--picker-hue",`${Math.round(o.hue)}deg`),o.handle.style.left=`${o.saturation*100}%`,o.handle.style.top=`${(1-o.value_)*100}%`,o.handle.style.background=e;const t=String(Math.round(o.hue));o.hueRange.value!==t&&(o.hueRange.value=t),o.clearBtn&&(o.clearBtn.disabled=!o.model);for(const i of o.items)i.el.className=o.model&&i.color.toLowerCase()===o.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ii(o,e){const t=ei(e);if(!t)return!1;const i=as(t.r,t.g,t.b);return o.hue=i.h,o.saturation=i.s,o.value_=i.v,o.hexText=ti(e).toUpperCase(),!0}function mt(o,e,t,i){o.hue=ls(e),o.saturation=zt(t),o.value_=zt(i),o.hexText=oi(o).toUpperCase(),ao(o)}function ni(o){const e=oi(o);o.model=e,ao(o),o.onChange(e)}function io(o,e){o.model=e,e||(o.hexText=""),ao(o),o.onChange(e)}function ms(o,e){ii(o,e),io(o,e)}function gs(o,e){const t=e.trim();if(!t){o.clearable&&io(o,void 0);return}ei(t)&&(ii(o,t),io(o,ti(t)))}function bs(o,e){o.dragging=!0,on(o,e);const t=n=>{o.dragging&&on(o,n)},i=()=>{o.dragging&&(o.dragging=!1,document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),ni(o))};document.addEventListener("pointermove",t),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function on(o,e){const t=o.area.getBoundingClientRect();if(!t.width||!t.height)return;const i=zt((e.clientX-t.left)/t.width),n=zt(1-(e.clientY-t.top)/t.height);mt(o,o.hue,i,n)}function xs(o,e){const t=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?mt(o,o.hue,o.saturation-t,o.value_):e.key==="ArrowRight"?mt(o,o.hue,o.saturation+t,o.value_):e.key==="ArrowUp"?mt(o,o.hue,o.saturation,o.value_+t):e.key==="ArrowDown"?mt(o,o.hue,o.saturation,o.value_-t):i=!1,i&&(e.preventDefault(),ni(o))}function vs(o,e){mt(o,e,o.saturation,o.value_)}function J(o,e,t,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>o.fire(t,i.arg),html:ve(e)})}function no(o,e,t,i){const n=o.state.openDd===e,r=()=>{o.state.openDd=n?null:e,o.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!t.disabled,dataset:{test:t.testId??e,tip:t.tip},onClick:r,html:`${t.icon?ve(t.icon):""}${t.text?`<span class="${t.textClass??"tb-btn-text"}">${t.text}</span>`:""}${ve("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${t.panelClass?` ${t.panelClass}`:""}`},i):""].filter(Boolean))}function I(o){const e=o.step??1,t=String(e),i=t.indexOf("."),n=i===-1?0:t.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,s=m=>{let g=r(m);return o.min!==void 0&&g<o.min&&(g=o.min),o.max!==void 0&&g>o.max&&(g=o.max),g},l=o.value===void 0||o.value===null||!Number.isFinite(o.value)?void 0:r(o.value),c=l??o.min??0,u=m=>{m!==l&&o.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:o.min,max:o.max,step:e,placeholder:o.placeholder,disabled:!!o.disabled,onChange:m=>{const g=m.target,v=(g.value??"").trim();if(v===""){l!==void 0&&(g.value=String(l));return}const b=Number(v);if(!Number.isFinite(b)){g.value=l===void 0?"":String(l);return}const w=s(b);g.value=String(w),u(w)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!o.disabled||c<=(o.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(s(c-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!o.disabled||c>=(o.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(s(c+e))})])}function B(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),i??""]),e,t?a("p",{class:"pd-hint",text:t}):""].filter(Boolean))}const Go=o=>a("button",{class:"pd-help",type:"button","data-tip":o,"aria-label":"字段说明"});function Ce(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[o,Go(t)]),i??""]),e])}function tt(o){const e=o.base?.[o.propKey],t=o.target?.[o.propKey]!==e,i=o.force===!0||t,n=o.tipOverride??(o.tipValue===void 0?"恢复默认值":`恢复默认值(${o.tipValue}${o.tipUnit?" "+o.tipUnit:""})`),r=o.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${t&&!o.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ve("RotateCcw",13),onClick:()=>{i&&(o.write?o.write(e):o.target[o.propKey]=e,o.onReset?.())}})}const Pe=o=>a("h3",{class:"pd-divider",text:o});function Ae(o,e,t="颜色选择",i){return ds({value:o,title:t,triggerClass:i,onChange:n=>e(n)})}function Ue(o,e,t,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:o,value:r.value,checked:t===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Bn(o,e,t,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const s=document.createElement("option");s.value=r.value,s.textContent=r.label,r.disabled&&(s.disabled=!0),n.appendChild(s)}return n.value=o,e.some(r=>r.value===o)||(n.selectedIndex=-1),n.addEventListener("change",()=>t(n.value)),n}function ys(o){const e=window.innerHeight;for(let t=o.parentElement;t&&t!==document.body;t=t.parentElement){const i=getComputedStyle(t).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=t.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function so(o){const e=A.normalizeFontCatalog(o.fonts),t=o.placeholder??"默认",i=`font-select-list-${o.id}`,n=F=>{const M=F?.trim();return M?A.findFontOption(e,M)?.label??M:""},r=F=>{const M=A.normalizeFontQuery(F);return e.find(V=>V.label&&A.normalizeFontQuery(V.label)===M)?.family??F},s=()=>{const F=o.value?.trim();return F?A.findFontOption(e,F)?"":F:""},l=F=>{const M=(o.value??"").trim(),G=(Z,y,H,ae)=>({kind:Z,key:y,label:H,value:ae,selected:(ae??"")===M}),V=F.trim();if(!V){const Z=[G("clear","__clear__",t)],y=s();y&&Z.push(G("unknown","__unknown__",`${y}(未知)`,y));for(const H of e)Z.push(G("font",H.family,A.fontOptionLabel(H),H.family));return Z}const ce=A.filterFontOptions(e,V).map(Z=>G("font",Z.family,A.fontOptionLabel(Z),Z.family));if(!ce.length){const Z=r(V);ce.push(G("free","__free__",`使用「${Z}」`,Z))}return ce},c=document.createElement("div");c.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=t,u.disabled=!!o.disabled,u.value=n(o.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=o.state.fontOpen?.id===o.id?o.state.fontOpen:null,g={open:!!m&&!o.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const v=()=>{o.state.fontOpen=g.open?{id:o.id,query:g.query,highlighted:g.highlighted}:null};v();const b=()=>{const F=(o.value??"").trim();return l(g.query).findIndex(M=>(M.value??"")===F)},w=()=>{const F=u.getBoundingClientRect(),M=ys(u);h.classList.toggle("is-up",p.resolveOverlayPlacement({triggerTop:F.top,triggerBottom:F.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:M.top,boundaryBottom:M.bottom})==="up")},T=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||c.appendChild(h);const F=l(g.query);h.replaceChildren(...F.map((M,G)=>{const V=document.createElement("li");return V.id=`${i}-${G}`,V.className="font-select-option"+(G===g.highlighted?" is-active":"")+(M.kind==="unknown"||M.kind==="free"?" is-muted":""),V.setAttribute("role","option"),V.setAttribute("aria-selected",String(M.selected)),V.textContent=M.label,V.addEventListener("mousedown",ce=>{ce.preventDefault(),ye(M)}),V})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),w()},k=()=>{g.open||o.disabled||(g.open=!0,g.query="",g.highlighted=b(),v(),T())},z=()=>{g.open||k()},W=()=>{g.open=!0,g.query=u.value,g.highlighted=l(g.query).length?0:-1,v(),T()},P=F=>{if(!g.open){k();return}const M=l(g.query).length-1;if(M<0)return;g.highlighted=Math.min(Math.max(g.highlighted+F,0),M),v(),T(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},ne=()=>{if(!g.open)return;const F=l(g.query)[g.highlighted];if(F){ye(F);return}const M=g.query.trim();if(M){const G=r(M);ye({value:G})}},ye=F=>{g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(F.value),T(),o.onChange(F.value)},Y=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(o.value),T())};return u.addEventListener("focus",k),u.addEventListener("click",z),u.addEventListener("input",W),u.addEventListener("blur",Y),u.addEventListener("keydown",F=>{const M=F;M.key==="ArrowDown"?(M.preventDefault(),P(1)):M.key==="ArrowUp"?(M.preventDefault(),P(-1)):M.key==="Enter"?(M.preventDefault(),ne()):M.key==="Escape"&&(M.preventDefault(),Y())}),c.append(u),T(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),c}const ws=[{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"}],Ss={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function He(o,e,t,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:o,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${t}</svg>`})}const ut='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',nn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Ts(o){const e=o.format;e.syncBorderDraft();const t=e.values,i=!e.fontEditable,n=i||e.context==="cells",r=e.context==="none",s=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",u=g=>i?`${g}(需选中文本元素)`:g,h=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[He("preset-none","无边框",`${ut}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),He("preset-all","所有边框",`${nn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),He("preset-outer","外侧边框",nn,()=>e.applyBorderPreset("outer")),He("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${ut}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!s}),He("edge-top","上边框",`${ut}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),He("edge-bottom","下边框",`${ut}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),He("edge-left","左边框",`${ut}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),He("edge-right","右边框",`${ut}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),a("div",{class:"ft-style-row"},ws.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),o.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[I({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),o.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Ae(e.borderColor,g=>{e.setBorderColor(g),o.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ve(b)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ve(b)})))])];return a("div",{class:"format-toolbar"},[a("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[a("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),o.repaint()},onDblclick:()=>{e.pickPainterSource(!0),o.repaint()},html:ve("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[so({id:"ft-font",state:o.state,fonts:o.host.fonts,value:typeof t.fontFamily=="string"?t.fontFamily:void 0,placeholder:t.fontFamily===Qe?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[I({value:typeof t.fontSize=="number"?t.fontSize:void 0,min:5,max:72,disabled:i,placeholder:t.fontSize===Qe?"混合":"默认",onCommit:g=>e.applyStyle({fontSize:g})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([g,v,b,w])=>a("button",{type:"button",class:`ft-btn${t[g]===!0?" on":""}`,dataset:{test:g,tip:u(b)},disabled:g==="bold"?i:n,onClick:w,html:ve(v)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Ae(typeof t.color=="string"?t.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Ae(typeof t.backgroundColor=="string"?t.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ve("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[no(o,"align",{icon:Ss[String(t.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[no(o,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const Es=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",label:"流式列表",icon:"⊟"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],ks={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Cs(o){const e=o.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[rn("»","展开素材台",()=>{e.leftCollapsed=!1,o.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,text:r,onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,o.repaint()}}))])]);const t=(i,n)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),rn("«","收起素材台",()=>{e.leftCollapsed=!0,o.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,o.repaint()}}))]),t("elements",As()),t("fields",[Ds(o)]),t("layers",[Ms(o)])])])}function rn(o,e,t){return a("button",{type:"button",class:"collapse-btn",title:e,text:o,onClick:t})}function As(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...Es.map(o=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${o.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",o.type)},[a("span",{class:"material-icon",text:o.icon}),a("span",{class:"material-label",text:o.label})]))]}function Ds(o){const e=o.state,t=p.groupFields(o.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?t.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):t;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>o.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const s=e.collapsedGroups.has(r.key)&&!i,l=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{s?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),o.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",c=s?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey})`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{h.dataTransfer?.setData("fieldKey",u.fieldKey)}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})])]));return[l,a("div",{},c.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function Ms(o){const e=o.store,t=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),i=e.elements.filter(l=>e.selectedIds.has(l.id)),n=i.length>=2,r=i.some(l=>!!l.options.groupId),s=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...t.map(l=>a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:ks[l.printElementType.type]||"?"}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),t.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,u])=>a("button",{type:"button",class:"pd-button small",title:c,html:ve(u,14),onClick:()=>o.fire("move-layer",l)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ve("Group",14),onClick:()=>o.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ve("Ungroup",14),onClick:()=>o.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function _s(o){const e=o.store,t=o.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,c)=>t.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:t.renameText??"",onInput:u=>{t.renameText=u.target.value},onBlur:()=>s(),onKeydown:u=>{const h=u;if(h.key==="Enter"){s();return}h.key==="Escape"&&(t.renamingPage=null,o.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{t.renamingPage=c,t.renameText=l.name??"",o.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>o.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>o.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>o.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>o.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>o.fire("move-page",1)})])]);function s(){const l=(t.renameText??"").trim();t.renamingPage!==null&&l&&e.renamePage(t.renamingPage,l),t.renamingPage=null,o.repaint()}}function Rs(o){const e=o.store,t=e.templateData,i=p.getPaperDimensions(t),n=t.orientation==="landscape"?"横向":"纵向",r=p.PAPER_PRESETS[t.paperSize]?.label??t.paperSize,s=t.outputRotation,l=`${r} ${n} ${Math.round(i.width)}×${Math.round(i.height)}mm${s?`(旋转${s}°)`:""}`;return a("div",{class:"status-bar"},[a("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),a("span",{class:"status-item",text:`缩放 ${e.scale}%`}),a("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),a("span",{class:`status-dirty${e.dirty?" on":""}`},[a("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),a("span",{class:"status-item status-paper",text:l})])}const zs=Object.keys(p.PAPER_PRESETS).filter(o=>o!=="CUSTOM"&&!p.PAPER_PRESETS[o]?.continuous);function Ps(o){const e=document.createElement("label");e.className="pd-button small upload-label";const t=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(t,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const s=o.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),i.value="";return}n(!0),t.textContent="上传中...";try{const l=await s(r);l?o.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{t.textContent="上传背景图",n(!o.host.uploadDesignBackground),i.value=""}}),o.host.uploadDesignBackground||n(!0),e}function Fs(o){const t=o.store.templateData.designBackground,i=t?.rotation??0;return a("div",{class:"design-background-config"},[Pe("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),t?.src?[a("div",{class:"design-background-path",title:t.src,text:t.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>o.store.updateTemplateData({designBackground:{...t,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>o.store.updateTemplateData({designBackground:void 0})})])]:Ps(o)].flat())}function Ls(o){const e=o.store,t=e.templateData,i=t.tiling,n={...A.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{...A.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=p.isContinuousPaperSize(t.paperSize),s=b=>e.updateTemplateData({tiling:{...n,...b}}),l=b=>tt({target:n,base:A.TILE_DEFAULTS,propKey:b,write:()=>s({[b]:A.TILE_DEFAULTS[b]})}),c=b=>tt({target:n.sheetMargin,base:A.TILE_DEFAULTS.sheetMargin,propKey:b,write:()=>u(b,A.TILE_DEFAULTS.sheetMargin[b])}),u=(b,w)=>s({sheetMargin:{...n.sheetMargin,[b]:w??0}}),h={...t,tiling:n},m=A.validateTiling(h),g=Math.max(A.computeMaxColumns(h),1);let v="";if(!m.length)try{const b=A.computeTileLayout(h),w=A.resolveSheetMm(h),T=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",k=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";v=`目标纸 ${T}${k} ${w.width}×${w.height}mm · ${b.columns} 列 × ${b.rows} 行 = 每张 ${b.perSheet} 格 · 每格 ${b.tile.width}×${b.tile.height}mm`}catch{v=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Pe("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:n.enabled===!0,disabled:r,onChange:b=>{if(!b.target.checked){s({enabled:!1});return}s({...A.TILE_DEFAULTS,columns:Math.min(A.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[B("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:b=>{const w=b.target.value;if(w!=="CUSTOM"){s({sheetPaperSize:w});return}const T=A.resolveSheetMm(h);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??T.width,sheetCustomHeight:n.sheetCustomHeight??T.height})}},[...zs.map(b=>a("option",{value:b,text:p.PAPER_PRESETS[b]?.label??b,selected:(n.sheetPaperSize??"A4")===b})),a("option",{value:"CUSTOM",text:"自定义",selected:n.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),n.sheetPaperSize==="CUSTOM"?B("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:b=>s({sheetCustomWidth:b})}),a("span",{class:"custom-size-x",text:"×"}),I({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:b=>s({sheetCustomHeight:b})})])):B("目标纸方向",Ue("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",b=>s({sheetOrientation:b})),void 0,l("sheetOrientation")),Pe("拼版留白 (mm)"),a("div",{class:"margin-grid"},[B("上",I({value:n.sheetMargin.top??0,min:0,max:100,onCommit:b=>u("top",b)}),void 0,c("top")),B("下",I({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:b=>u("bottom",b)}),void 0,c("bottom")),B("左",I({value:n.sheetMargin.left??0,min:0,max:100,onCommit:b=>u("left",b)}),void 0,c("left")),B("右",I({value:n.sheetMargin.right??0,min:0,max:100,onCommit:b=>u("right",b)}),void 0,c("right"))]),Pe("格间距与列数"),B("横向间距",I({value:n.gapX??0,min:0,max:50,onCommit:b=>s({gapX:b??0})}),void 0,l("gapX")),B("纵向间距",I({value:n.gapY??0,min:0,max:50,onCommit:b=>s({gapY:b??0})}),void 0,l("gapY")),B("列数",I({value:n.columns??1,min:1,max:g,onCommit:b=>s({columns:b||1})})),...m.map(b=>a("p",{class:"pd-hint tiling-error",text:b.message})),!m.length&&v?a("p",{class:"pd-hint tiling-summary",text:v}):""]:""].flat().filter(Boolean))}const Is=new Set(p.PROPERTY_REGISTRY.map(o=>o.group)),Os={"table-settings":"content"},an=new Map;function ri(o){const e=o??"";let t=an.get(e);if(!t){const{groups:i,itemKeys:n}=p.searchProperties(e);t={groups:i,keys:n,searching:!!e.trim()},an.set(e,t)}return t}function ai(o){const e=Os[o]??o;return Is.has(e)?e:""}function Ns(o,e){const t=ri(o.state.propSearch);if(!t.searching)return!0;const i=ai(e);return!i||t.groups.includes(i)}function $s(o,e){const t=ri(o.state.propSearch);return!t.searching||t.keys.has(e)}function Hn(o,e){const t=o.props.style??{};return o.props.style={...t,display:e?"":"none"},o}function _(o,e,t){const i=t.props.dataset??{};return t.props.dataset={...i,propKey:e},Hn(t,$s(o,e))}function Bs(o,e,t){const i=ai(e);if(!i)return t;const n=t.props.dataset??{};return t.props.dataset={...n,propGroup:i},Hn(t,Ns(o,e))}function Wn(o,e){const t=ri(e);for(const i of Array.from(o.querySelectorAll("[data-prop-group]"))){const n=ai(i.dataset.propGroup??"");i.style.display=!t.searching||!n||t.groups.includes(n)?"":"none"}for(const i of Array.from(o.querySelectorAll("[data-prop-key]")))i.style.display=!t.searching||t.keys.has(i.dataset.propKey??"")?"":"none"}function Hs(o){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:o.state.propSearch??"",onInput:e=>{const t=e.target,i=t.value;o.state.propSearch=i,Wn(t.getRootNode(),i)}})])}const Ws={Document:"≡",Brush:"◧",Setting:"⚙"};function Us(o,e){try{const t=window.localStorage.getItem(`property-group-${o}`);return t===null?e:t==="true"}catch{return e}}function Gs(o,e){try{window.localStorage.setItem(`property-group-${o}`,String(e))}catch{}}function xe(o,e,t,i,n,r=!0){const s=Us(e,r);return Bs(o,e,a("div",{class:`property-group${s?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{Gs(e,!s),o.repaint()}},[a("span",{class:"group-icon",text:Ws[i]||"•"}),a("span",{class:"group-title",text:t}),a("span",{class:"expand-icon",text:s?"▾":"▸"})]),a("div",{class:"group-content",style:s?"":{display:"none"}},n.filter(Boolean))]))}function lo(o){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},o.filter(Boolean))}function Un(o){return o.split(".").flatMap(e=>{const t=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!t)return[e];const i=t[1],n=[...t[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function sn(o,e){return Un(e).reduce((n,r)=>n==null?"":n[r],o)??""}function si(o,e,t,i){const n=Un(t),r=n.pop(),s=n.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);s[r]=i||void 0,o.recordHistory(),o.emit()}function qs(o,e){const t=o.store;if(e.printElementType.type==="table"&&t.tableSelection?.elementId===e.id){const{r1:i,c1:n}=t.tableSelection,r=(e.options.tableRows??[])[i];if(r)return p.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return p.getElementBindings(e)}function Ks(o,e){const t=document.createElement("label");t.className="pd-button small upload-label",fe(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),t);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",t.append(i,n);const r=c=>{t.className=`pd-button small upload-label${c?" disabled":""}`,n.disabled=c};n.addEventListener("change",async()=>{const c=n.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=o.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(c);h?si(o.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!o.host.uploadImage),n.value=""}}),o.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(t,l),s}function js(o,e){const t=i=>o.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:sn(e,i.targetPath)});return xe(o,"binding","内容","Document",[...qs(o,e).map(i=>B(i.label,a("input",{class:"pd-input",type:"text",value:sn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>si(o.store,e,i.targetPath,n.target.value),onDblclick:()=>t(i)}))),e.printElementType.type==="image"?Ks(o,e):""].filter(Boolean))}const Ct=new Map;function Zt(o){return`${Math.round(o*1e4)/1e4}%`}function Gn(o,e){const t=p.parseCropAnchor(e.value),i=t.kind==="custom",n=t.kind==="axes"?t.x:50,r=t.kind==="axes"?t.y:50,s=p.resolveCropPreview(e.src),l=Ct.get(s.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},u=p.resolveCropTravel(c),h=p.cropWindow(c,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const w of p.cropPresetOptions(u,n,r)){const T=document.createElement("option");T.value=w.value,T.textContent=w.label,m.appendChild(T)}if(i){const w=document.createElement("option");w.value="custom",w.textContent="自定义(保留原值)",m.appendChild(w)}m.value=i?"custom":`${n},${r}`,m.selectedIndex<0&&(m.selectedIndex=i?m.options.length-1:0),m.addEventListener("change",()=>{if(m.value==="custom")return;const[w,T]=m.value.split(",").map(Number);e.onCommit(p.buildCropAnchor(w,T))});const g=p.propertyTip(e.fieldKey),v=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,Go(g)]),e.resetAnchor??""].filter(Boolean)),m])];v.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[p.CROP_SCALE_LABEL,Go(p.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),I({value:e.scale,min:p.CROP_SCALE_MIN,max:p.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:w=>e.onScaleCommit(w>p.CROP_SCALE_MIN?w:void 0)})]));for(const w of p.cropAxisFields(u,n,r))v.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:w.label}),I({value:w.value,min:0,max:100,step:1,onCommit:T=>e.onCommit(p.buildCropAnchor(w.name==="horizontal"?T:n,w.name==="vertical"?T:r))})]));const b=p.cropAxisNote(u,i);return b&&v.push(a("p",{class:"pd-crop-note",text:b})),s.isSample&&v.push(a("p",{class:"pd-crop-note",text:p.CROP_SAMPLE_NOTE})),v.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:s.src,alt:s.isSample?"示例图":"原图",onLoad:w=>{const T=w.target;if(!(T.naturalWidth>0&&T.naturalHeight>0))return;const k=Ct.get(s.src);k&&k.width===T.naturalWidth&&k.height===T.naturalHeight||(Ct.set(s.src,{width:T.naturalWidth,height:T.naturalHeight}),o.repaint())},onError:()=>{Ct.has(s.src)&&(Ct.delete(s.src),o.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:Zt(h.leftPct),top:Zt(h.topPct),width:Zt(h.widthPct),height:Zt(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},v)}const Ze=o=>Number(o??0),qo=o=>o||void 0;function bt(o,e,t,i,n){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:o}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:r=>t(r.target.checked)})])}function qn(o,e,t,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:s=>i(s.target.value)},t.map(s=>a("option",{value:s.value,text:s.label,selected:s.value===e})))])}function At(o,e,t,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),n.reset??""].filter(Boolean)),Bn(e,t,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Dt=o=>a("p",{class:"pd-hint",text:o}),Ys="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Vs=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Xs=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Zs=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Qs=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Js={value:"__multi__",label:"多选",disabled:!0};function el(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return xe(o,"table-row","行属性","Grid",[]);const s=l=>t.updateElement(e.id,l);return xe(o,"table-row","行属性","Grid",[lo([qn("行类型",r.type,Vs,l=>{const c=p.setRowType(n,i.r1,l);if(c){window.alert(c);return}s({tableRows:n})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),I({value:r.height,min:3,max:100,step:.5,onCommit:l=>{r.height=l,s({tableRows:n})}})]),r.type==="header"?bt("表头每页重复",r.repeatOnPage??!1,l=>{p.setHeaderRepeat(n,l),s({tableRows:n})},Ys):""])])}function tl(o,e){const t=o.store,i=e.options,n=h=>t.updateElement(e.id,h),r=i.tableColWidths??[],s=t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right,l=t.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),c=p.createDefaultOptions("table"),u=h=>tt({target:i,base:c,propKey:h,write:()=>n({[h]:c[h]})});return xe(o,"table-settings","表格设置","Grid",[lo([qn("列表数据源字段",i.dataSource??"",l,h=>n({dataSource:h||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字体"}),u("tableDefaultFontFamily")]),so({id:"table-default-font",state:o.state,fonts:o.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),I({value:Ze(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Ae(i.tableDefaultColor,h=>n({tableDefaultColor:h}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),u("tableDefaultPadding")]),I({value:Ze(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((h,m)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${m+1}`}),I({value:h,min:5,max:200,onCommit:g=>{const v=r.reduce((b,w,T)=>T===m?b:b+w,0);if(v+g>s){const b=Math.max(5,Math.round((s-v)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${m+1} 已调整为 ${b}mm`),r[m]=b}else r[m]=g;n({tableColWidths:r})}})]))])])])}function ol(o,e){const t=o.store,i=e.options,n=e.printElementType.type==="table",r=l=>t.updateElement(e.id,l),s=[];if(n)s.push(_(o,"pg-enabled",bt("启用分页",i.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=i.pagination?.pageable??!0,c=i.pagination?.keepWithNext??!1;s.push(_(o,"pg-pageable",bt("参与分页",l,u=>r({pagination:{pageable:u,keepWithNext:c}})))),s.push(_(o,"pg-keep-with-next",bt("与下元素同页",c,u=>r({pagination:{pageable:l,keepWithNext:u}}))))}return xe(o,"pagination","分页配置","Document",[lo(s)],!1)}const Po=new WeakMap,ln=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function il(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[];if(!i)return xe(o,"table-cell","单元格","Menu",[]);const r=p.findMainCell(n,i.r1,i.c1),s=n[r.r]?.cells[r.c];if(!s)return xe(o,"table-cell","单元格","Menu",[]);const l=()=>p.collectWritableCells(n,i),c=p.resolveCellGroupMode(n,i),u=c.count,h=c.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=Po.get(t),v=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&Po.set(t,v);const b=x=>{Po.set(t,{key:m,border:x.border??v.border,values:x.values??v.values,edges:x.edges??v.edges})},w=(x,O)=>{b({border:{...v.border,[x]:O}}),o.repaint()},T=(x,O)=>{l().forEach(x),h&&O&&b({values:{...v.values,...O}}),t.updateElement(e.id,{tableRows:n})},k=(x,O)=>{T(Q=>{Q[x]=O},{[x]:O})},z=x=>h?v.values[x]:s[x],W=x=>h&&x in v.values,P=h?{width:void 0,style:void 0,color:void 0}:p.resolveCellBorderDisplay(n,i),ne=!h&&l().some(x=>!!x.borders&&!!(x.borders.top||x.borders.right||x.borders.bottom||x.borders.left)),ye=!h&&!ne,Y={width:ye?0:typeof P.width=="number"?P.width:p.DEFAULT_BORDER.width,style:ye?"none":typeof P.style=="string"&&P.style!=="mixed"?P.style:p.DEFAULT_BORDER.style,color:typeof P.color=="string"&&P.color!=="mixed"?P.color:p.DEFAULT_BORDER.color,...v.border},F="__mixed__",M={style:!h&&P.style==="mixed",width:!h&&P.width==="mixed",color:!h&&P.color==="mixed"},G=M.style&&!("style"in v.border),V=M.width&&!("width"in v.border),ce=M.color&&!("color"in v.border),Z=G||V||ce,y=G?F:Y.style,H=V?void 0:Y.width,ae=ce?void 0:Y.color,Fe=x=>{const O={style:x};x!=="none"&&H===0?O.width=p.DEFAULT_BORDER.width:x==="none"&&!ne&&(O.width=0),b({border:{...v.border,...O}}),o.repaint()},L=()=>({...Y}),ee=h?ln.reduce((x,O)=>(x[O.value]=v.edges[O.value]?"on":"off",x),{}):p.resolveBorderEdgeStates(l().map(x=>x.borders)),Ge=h?"cellType"in v.values?v.values.cellType??"text":p.resolveSharedCellType(n,i):s.cellType??"text",pe=Ge==="barcode",qe=Ge==="qrcode",ot=Ge==="image",U=Ge==="text",co=pe&&!!z("printerDpi"),Ft=p.barcodeBarWidthRecommendText(z("printerDpi"),z("barWidth")),Lt=h?v.values.textFit:p.resolveCellTextFit(s),po=h?"cellType"in v.values?v.values.cellType??"text":"":s.cellType||"text",Ke=x=>h?[Js,...x]:x,we=x=>h?"多选":x,Se=(x,O)=>h?v.values[x]:O,uo=h?z("barcodeType")??"__multi__":s.barcodeType||"CODE128",It=h?W("printerDpi")?z("printerDpi")?String(z("printerDpi")):"":"__multi__":s.printerDpi?String(s.printerDpi):"",q=h?z("qrCodeLevel")??"__multi__":s.qrCodeLevel||"M",xt=h?z("fit")??"__multi__":s.fit||"contain",K=Lt??"__multi__",it=p.canMergeReason(n,i);let ue=!1;for(let x=i.r1;x<=i.r2&&!ue;x++)for(let O=i.c1;O<=i.c2&&!ue;O++){const Q=n[x]?.cells[O];Q&&!Q.merged&&((Q.rowspan??1)>1||(Q.colspan??1)>1)&&(ue=!0)}const Te=(x,O,Q,te={},De)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:x}),De??""].filter(Boolean)),I({value:O,...te,onCommit:yt=>k(Q,qo(yt))})]),Ot="恢复默认值(跟随表格默认)",N=x=>tt({target:s,base:{},propKey:x,tipOverride:Ot,force:h,write:()=>k(x,void 0)}),vt=e.options.tableDefaultPadding??1,nt={width:p.cellFitWidthMm(e.options.tableColWidths??[],r.c,s,vt),height:p.cellFitCapMm(n,r.r,s,vt)};return xe(o,"table-cell","单元格","Menu",[lo([h?Dt(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),Ue("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],po,x=>{const O=x==="text"?void 0:x,Q={cellType:x};x!=="barcode"&&Object.assign(Q,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),x!=="qrcode"&&Object.assign(Q,{qrCodeLevel:void 0,qrQuietZone:void 0}),T(te=>{te.cellType=O,x!=="barcode"&&(te.barcodeType=void 0,te.showBarcodeText=void 0,te.printerDpi=void 0,te.barQuietZone=void 0,te.barHeight=void 0),x!=="qrcode"&&(te.qrCodeLevel=void 0,te.qrQuietZone=void 0)},Q)})]),pe?At("码制",uo,Ke(Xs),x=>{x!=="__multi__"&&k("barcodeType",x||void 0)}):"",pe?bt("显示文本",h?v.values.showBarcodeText===!0:s.showBarcodeText!==!1,x=>k("showBarcodeText",x),void 0,N("showBarcodeText")):"",pe?Te("条宽(倍率)",Se("barWidth",s.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:we("")},N("barWidth")):"",pe?Dt((co?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Ft?`。${Ft}`:"")):"",pe?Ce("静区 (模块)",I({value:Se("barQuietZone",s.barQuietZone),min:0,max:20,placeholder:we("默认 10"),onCommit:x=>k("barQuietZone",x)}),p.propertyTip("cd-bar-quiet-zone"),N("barQuietZone")):"",pe?Ce("条高 (mm)",I({value:Se("barHeight",s.barHeight),min:1,max:100,placeholder:we("默认 30 模块"),onCommit:x=>k("barHeight",x??void 0)}),p.propertyTip("cd-bar-height"),N("barHeight")):"",pe?Te("文本字号(相对条高,条高为 30)",Se("barFontSize",s.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:we("默认 10")},N("barFontSize")):"",pe?At("打印机分辨率",It,Ke([{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)"}]),x=>{if(x==="__multi__")return;const O=Number(x);k("printerDpi",O>0?O:void 0)},{reset:N("printerDpi")}):"",pe?Dt("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",qe?At("纠错级别",q,Ke(Zs),x=>{x!=="__multi__"&&k("qrCodeLevel",x||void 0)},{reset:N("qrCodeLevel")}):"",qe?Ce("静区 (模块)",I({value:Se("qrQuietZone",s.qrQuietZone),min:0,max:8,placeholder:we("默认 0"),onCommit:x=>k("qrQuietZone",x)}),p.propertyTip("cd-quiet-zone"),N("qrQuietZone")):"",pe?Dt("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",qe||ot?At("缩放模式",xt,Ke(p.IMAGE_FIT_OPTIONS),x=>{x!=="__multi__"&&k("fit",x)},{reset:N("fit")}):"",ot&&!h&&s.fit==="cover"?Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(s.formatter),fit:s.fit,containerClass:"pd-cell-anchor",widthMm:nt.width,heightMm:nt.height,scale:s.fitScale,value:s.objectPosition,onCommit:x=>k("objectPosition",x),onScaleCommit:x=>k("fitScale",x),resetAnchor:N("objectPosition"),resetScale:N("fitScale")}):"",pe||qe||ot?Te("最大宽度 (mm)",Se("maxWidth",Ze(s.maxWidth)),"maxWidth",{min:0,max:200,placeholder:we("默认")},N("maxWidth")):"",pe||qe||ot?Te("最大高度 (mm)",Se("maxHeight",Ze(s.maxHeight)),"maxHeight",{min:0,max:200,placeholder:we("默认")},N("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?z("formatter")??"":s.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:x=>k("formatter",x.target.value||void 0),onDblclick:()=>o.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),N("align")]),Ue("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?v.values.align??"":s.align||"left",x=>k("align",x))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),N("valign")]),Ue("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?v.values.valign??"":s.valign||"top",x=>k("valign",x))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"字体"}),N("fontFamily")]),so({id:"cell-font",state:o.state,fonts:o.host.fonts,value:h?z("fontFamily"):s.fontFamily,placeholder:we("继承默认"),onChange:x=>k("fontFamily",x)})]),Te("字号 (pt)",Se("fontSize",Ze(s.fontSize)),"fontSize",{min:0,max:72,placeholder:we("默认")},N("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),N("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?v.values.fontWeight==="bold":s.fontWeight==="bold",onChange:x=>k("fontWeight",x.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),N("color")]),Ae(h?z("color"):s.color,x=>k("color",x),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),N("backgroundColor")]),Ae(h?z("backgroundColor"):s.backgroundColor,x=>k("backgroundColor",x),"背景颜色")])]),Pe("边框"),a("div",{class:"border-style-row"},[Bn(y,[...G?[{value:F,label:"混合",disabled:!0}]:[],...p.BORDER_LINE_STYLES],x=>{x!==F&&Fe(x)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[I({value:H,min:.25,max:5,step:.25,placeholder:h?"多选":V?"混合":void 0,onCommit:x=>w("width",x)})]),Ae(ae,x=>w("color",x),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([x,O])=>a("button",{type:"button",class:"pd-button small",text:O,onClick:()=>{p.applyBorderPreset(n,i,Y.style==="none"?"none":x,L()),t.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},ln.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:x.value,checked:ee[x.value]==="on",indeterminate:ee[x.value]==="mixed",onChange:O=>{const te=O.target.checked&&Y.style!=="none";h&&b({edges:{...v.edges,[x.value]:te}}),T(De=>{p.setCellBorderEdge(De,x.value,te?L():null)})}}),a("span",{text:x.label})]))),Dt(h?p.CELL_BORDER_APPLY_HINT_MULTI:Z?p.CELL_BORDER_APPLY_HINT_MIXED:p.CELL_BORDER_APPLY_HINT),Te("内边距 (mm)",Se("padding",Ze(s.padding)),"padding",{min:0,max:10,step:.5,placeholder:we("默认")},N("padding")),bt("自动换行",h?v.values.wordWrap===!0:s.wordWrap??!0,x=>k("wordWrap",x),void 0,N("wordWrap")),U?At("文字溢出",K,Ke(Qs),x=>{x!=="__multi__"&&k("textFit",x)},{full:!0,reset:N("textFit")}):"",U&&Lt==="shrink"?Te("最小字号 (pt)",Se("shrinkMinFontSize",Ze(s.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:we("默认 6")},N("shrinkMinFontSize")):"",a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!it,title:it||"",onClick:()=>{p.mergeCells(n,i),t.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!ue,onClick:()=>{p.splitCells(n,i),t.updateElement(e.id,{tableRows:n})}})])])])}const Fo=A.WATERMARK_DENSITY_PRESETS;function Ko(o){const e=o.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function nl(o){return o?o.mode==="binding"?o.binding??"":o.content??"":""}function rl(o){const e=o.store.templateData.watermark,t=nl(e),i=e?.mode==="binding"||t!==""&&Ko(t),n=(()=>{const u=e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(Fo))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={testData:e?.testData??"",rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};o.store.updateTemplateData({watermark:{...h,...u}})},s=()=>o.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:t}),l={rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight},c=u=>tt({target:l,base:A.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:A.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[Pe("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:t,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(Ko(h)?{mode:"binding",binding:h,content:""}:{mode:"fixed",content:h,binding:""})},onDblclick:s}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:s})]),i?B("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??A.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??A.WATERMARK_DEFAULTS.rotate}°`})]),B("颜色",Ae(e?.color||A.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,c("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??A.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??A.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const h=u.target.value,m=Fo[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(Fo).map(([u,h])=>a("option",{value:u,text:`${h.label}(${h.width}×${h.height})`,selected:n===u})),a("option",{value:"custom",text:"自定义",selected:n==="custom"})])]),n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth),onChange:u=>r({tileWidth:Number(u.target.value)})})]):"",n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function de(o,e,t,i,n={},r){return B(e,I({value:t,...n,onCommit:i}),void 0,r)}function We(o,e,t,i,n,r,s){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>n(l.value));for(const c of i){const u=document.createElement("option");u.value=c.value,u.textContent=c.label,l.appendChild(u)}return l.value=t,i.some(c=>c.value===t)||(l.selectedIndex=-1),r?Ce(e,l,r,s):B(e,l,void 0,s)}function ht(o,e,t,i,n){return B(e,a("input",{type:"checkbox",class:"pd-switch",checked:t,onChange:r=>i(r.target.checked)}),void 0,n)}const al=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],sl=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function ll(o,e){const t=o.store,i=e.options,n=e.printElementType.type,r=y=>t.updateElement(e.id,y),s=n==="text"||n==="longText",l=n==="barcode"||n==="qrcode",c=n==="table",u=c&&t.tableSelection?.elementId===e.id,h=u&&p.resolveCellGroupMode(e.options.tableRows??[],t.tableSelection).mode==="multi",m=[];u||m.push(xe(o,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"position-grid"},[_(o,"ps-left",de(o,"X",i.left,y=>r({left:y}),{min:0})),_(o,"ps-top",de(o,"Y",i.top,y=>r({top:y}),{min:0})),_(o,"ps-width",de(o,"W",i.width,y=>r({width:y}),{min:4})),_(o,"ps-height",de(o,"H",i.height,y=>r({height:y}),{min:4}))])])]));const g=p.createDefaultOptions(n),v=(y,H)=>{const ae=p.propertyDefault(H);return tt({target:i,base:g,propKey:y,tipValue:ae?.value,tipUnit:ae?.unit,write:()=>r({[y]:g[y]})})},b=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?p.normalizeRotationAngle(i.rotate):void 0,w=y=>r({rotate:y===void 0||y===0?void 0:p.normalizeRotationAngle(y)}),T=p.isFreeAngleEditable(n,i),k=p.isRotationExcludedType(n)||p.collectFollowMemberIds(t.elements).has(e.id),z=k?"":_(o,"ap-rotate",Ce("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>w((b??0)-90)}),a("div",{class:"pd-rotate-stepper"},[I({value:b,min:0,max:359,placeholder:"0",disabled:!T,onCommit:y=>w(y)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>w((b??0)+90)})]),p.propertyTip("ap-rotate"),v("rotate","ap-rotate"))),W=k||T?"":a("p",{class:"pd-hint pd-rotate-note",text:p.CODE_OBLIQUE_NOTE});if(m.push(xe(o,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},s?[_(o,"ap-font-family",B("字体",so({id:"prop-font",state:o.state,fonts:o.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:y=>r({fontFamily:y})}),void 0,v("fontFamily","ap-font-family"))),_(o,"ap-font-size",de(o,"字体大小",i.fontSize,y=>r({fontSize:y}),{min:8,max:72},v("fontSize","ap-font-size"))),_(o,"ap-font-weight",We(o,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],y=>r({fontWeight:y}),void 0,v("fontWeight","ap-font-weight"))),_(o,"ap-align",B("对齐",Ue("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",y=>r({textAlign:y})),void 0,v("textAlign","ap-align"))),_(o,"ap-vertical-align",B("垂直对齐",Ue("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",y=>r({verticalAlign:y})),void 0,v("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[_(o,"ap-color",B("颜色",Ae(i.color,y=>r({color:y}),"字体颜色"),void 0,v("color","ap-color"))),_(o,"ap-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","ap-bg-color")))]),_(o,"ap-line-height",de(o,"行高",i.lineHeight,y=>r({lineHeight:y||void 0}),{min:0,max:100},v("lineHeight","ap-line-height"))),_(o,"ap-letter-spacing",de(o,"字间距",i.letterSpacing,y=>r({letterSpacing:y||void 0}),{min:0,max:20,step:.5},v("letterSpacing","ap-letter-spacing"))),_(o,"ap-text-fit",We(o,"文字溢出",p.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],y=>r({textFit:y}),void 0,v("textFit","ap-text-fit"))),i.textFit==="shrink"?_(o,"ap-shrink-min",B("最小字号 (pt)",I({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:y=>r({shrinkMinFontSize:y||void 0})}),void 0,v("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?_(o,"ap-long-text-indent",Ce("首行缩进 (字符)",I({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:y=>r({longTextIndent:y||void 0})}),p.propertyTip("ap-long-text-indent"),v("longTextIndent","ap-long-text-indent"))):"",_(o,"ap-word-wrap",ht(o,"自动换行",i.wordWrap!==!1,y=>r({wordWrap:y?void 0:!1}),v("wordWrap","ap-word-wrap"))),_(o,"ap-keep-line-breaks",ht(o,"保留换行符",i.keepLineBreaks===!0,y=>r({keepLineBreaks:y?!0:void 0}),v("keepLineBreaks","ap-keep-line-breaks"))),z,W]:[n==="image"?_(o,"ap-img-fit",We(o,"缩放模式",String(i.fit??"contain"),p.IMAGE_FIT_OPTIONS,y=>r({fit:y}),p.propertyTip("ap-img-fit"),v("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?_(o,"ap-img-object-position",Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(i.src),widthMm:Number(i.width)||0,heightMm:Number(i.height)||0,fit:i.fit,scale:i.fitScale,value:i.objectPosition===void 0?void 0:String(i.objectPosition),onCommit:y=>r({objectPosition:y}),onScaleCommit:y=>r({fitScale:y}),resetAnchor:v("objectPosition","ap-img-object-position"),resetScale:v("fitScale","ap-img-fit-scale")})):"",z,W,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const y=n==="barcode",H=String(i.barcodeType||"CODE128").toUpperCase(),ae=i.printerDpi?String(i.printerDpi):"",Fe=p.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);m.push(xe(o,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:L=>L.preventDefault()},[y?[_(o,"cd-type",We(o,"码制",H,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],L=>r({barcodeType:L==="CODE128"?void 0:L}))),_(o,"cd-dpi",We(o,"打印机分辨率",ae,[{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)"}],L=>r({printerDpi:Number(L)>0?Number(L):void 0}),void 0,v("printerDpi","cd-dpi"))),_(o,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),_(o,"cd-bar-width",de(o,"条宽(倍率)",i.barWidth??2,L=>r({barWidth:L}),{min:2,max:8,step:.5},v("barWidth","cd-bar-width"))),_(o,"cd-bar-width",a("p",{class:"pd-hint",text:(ae?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Fe?`。${Fe}`:"")})),_(o,"cd-bar-quiet-zone",Ce("静区 (模块)",I({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:L=>r({barQuietZone:L})}),p.propertyTip("cd-bar-quiet-zone"),v("barQuietZone","cd-bar-quiet-zone"))),_(o,"cd-bar-height",Ce("条高 (mm)",I({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:L=>r({barHeight:L??void 0})}),p.propertyTip("cd-bar-height"),v("barHeight","cd-bar-height"))),_(o,"cd-show-text",ht(o,"显示文本",i.hideTitle!==!0,L=>r({hideTitle:L?void 0:!0}),v("hideTitle","cd-show-text"))),_(o,"cd-font-size",B("文本字号(相对条高,条高为 30)",I({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:L=>r({fontSize:L||void 0})}),void 0,v("fontSize","cd-font-size")))]:[_(o,"cd-ec-level",We(o,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],L=>r({qrCodeLevel:L}),void 0,v("qrCodeLevel","cd-ec-level"))),_(o,"cd-quiet-zone",Ce("静区 (模块)",I({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:L=>r({qrQuietZone:L})}),p.propertyTip("cd-quiet-zone"),v("qrQuietZone","cd-quiet-zone")))],Pe("自定义设置"),y?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",y?"":_(o,"cd-fit",We(o,"缩放模式",String(i.fit||"contain"),p.IMAGE_FIT_OPTIONS,L=>r({fit:L||void 0}),void 0,v("fit","cd-fit"))),_(o,"cd-max-width",B("最大宽度 (mm)",I({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxWidth:L||void 0})}),void 0,v("maxWidth","cd-max-width"))),_(o,"cd-max-height",B("最大高度 (mm)",I({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxHeight:L||void 0})}),void 0,v("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(h||m.push(js(o,e)),u&&(m.push(el(o,e)),m.push(il(o,e))),c&&m.push(tl(o,e)),n==="flowList"){const y=p.resolveFlowColumns(i.flowColumns),H=p.resolveFlowRowHeight(i.flowRowHeight),ae=p.resolveFlowGapX(i.flowGapX),Fe=p.resolveFlowMaxSpan(i.flowMaxSpan,y),L=p.suggestFlowColumns(i.width??0,ae,i.fontSize??12);m.push(xe(o,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:ee=>ee.preventDefault()},[_(o,"fl-columns",Ce("每行列数",I({value:y,min:1,max:12,onCommit:ee=>r({flowColumns:p.resolveFlowColumns(ee),flowMaxSpan:p.resolveFlowMaxSpan(i.flowMaxSpan,p.resolveFlowColumns(ee))})}),p.propertyTip("fl-columns"))),_(o,"fl-row-height",Ce("行高 (mm)",I({value:H,min:3,max:100,step:.5,onCommit:ee=>r({flowRowHeight:p.resolveFlowRowHeight(ee)})}),p.propertyTip("fl-row-height"))),_(o,"fl-gap-x",Ce("单元横向间距 (mm)",I({value:ae,min:0,max:50,step:.5,onCommit:ee=>r({flowGapX:p.resolveFlowGapX(ee)})}),p.propertyTip("fl-gap-x"))),_(o,"fl-auto-span",ht(o,"内容过长时跨列",i.flowAutoSpan===!0,ee=>{r(ee?{flowAutoSpan:ee,flowMaxSpan:Fe}:{flowAutoSpan:ee})})),i.flowAutoSpan===!0?_(o,"fl-max-span",Ce("最多跨几列",I({value:Fe,min:1,max:y,onCommit:ee=>r({flowMaxSpan:p.resolveFlowMaxSpan(ee,y)})}),p.propertyTip("fl-max-span"))):"",y>L?a("p",{class:"pd-hint",text:`按当前字号与框宽,${y} 列偏挤(可放约 ${L} 列)。数值保持不变,出纸按 ${y} 列排。`}):""].flat().filter(Boolean))]))}const P=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),ne=y=>{const H=P();p.applyElementBorderPreset(H,y,p.effectiveElementBorderSpec(H)),r(H)},ye=y=>{const H=P();p.setElementBorderEdgeVisible(H,y,!p.elementBorderEdgeVisible(H,y)),r(H)},Y=p.resolveElementBorderDisplay(i),F=Y.style==="mixed",M=typeof Y.width=="number"?Y.width:void 0,G=F||Y.style===void 0?"":Y.style,V=typeof Y.color=="string"?Y.color:void 0,ce=(y,H)=>{const ae=P();p.setElementBorderField(ae,y,H),r(ae)},Z=F?[{value:"",label:"混合"},...p.BORDER_LINE_STYLES]:[...p.BORDER_LINE_STYLES];return m.push(xe(o,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[_(o,"bb-border-style",We(o,"线型",G,Z,y=>ce("borderStyle",y))),a("div",{class:"border-row"},[_(o,"bb-border-width",de(o,"边框宽度",M,y=>ce("borderWidth",y),{min:0,max:20,step:.25,placeholder:Y.width==="mixed"?"混合":void 0},v("borderWidth","bb-border-width"))),_(o,"bb-border-color",B("边框颜色",Ae(V,y=>ce("borderColor",y),"边框颜色"),void 0,v("borderColor","bb-border-color")))]),...p.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},al.map(y=>a("button",{type:"button",class:"pd-button small",text:y.label,disabled:y.value==="inner",onClick:()=>ne(y.value)}))),a("div",{class:"pd-checkbox-group"},sl.map(y=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:p.elementBorderEdgeVisible(i,y.value),onChange:()=>ye(y.value)}),a("span",{text:y.label})]))),a("p",{class:"pd-hint",text:p.ELEMENT_BORDER_APPLY_HINT})]:[],_(o,"bb-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","bb-bg-color")))])])),m.push(ol(o,e)),m.push(xe(o,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"advanced-row"},[_(o,"ad-locked",ht(o,"锁定",!!i.locked,y=>r({locked:y}),v("locked","ad-locked"))),_(o,"ad-fixed",ht(o,"每页重复",!!i.fixed,y=>r({fixed:y}),v("fixed","ad-fixed")))]),_(o,"ad-z-index",de(o,"层级",i.zIndex,y=>r({zIndex:y}),{min:0,max:999},v("zIndex","ad-z-index"))),_(o,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>t.deleteSelected()})]))])],!1)),a("div",{class:"property-content"},m)}function dl(o){const e=o.store,t=e.templateData,i=c=>e.updateTemplateData(c),n=c=>{const u=t.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(c)!==h(t.outputRotation)){const m=A.computeMaxColumns({...t,outputRotation:c});i({outputRotation:c,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:c})},r=[];for(const[c,u]of Object.entries(p.PAPER_PRESETS)){const h=u.group??"其他";let m=r.find(g=>g.group===h);m||(m={group:h,items:[]},r.push(m)),m.items.push({key:c,label:u.label??c})}const s=!p.PAPER_PRESETS[t.paperSize],l=p.isContinuousPaperSize(t.paperSize);return a("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Pe("纸张设置"),B("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:c=>i({paperSize:c.target.value})},[...r.map(c=>a("optgroup",{label:c.group},c.items.map(u=>a("option",{value:u.key,text:u.label,selected:t.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:s})])),l||s?B(l?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(t.customWidth??0),min:25,max:2e3,onCommit:c=>i({customWidth:c})}),...s?[a("span",{class:"custom-size-x",text:"×"}),I({value:Number(t.customHeight??0),min:25,max:2e3,onCommit:c=>i({customHeight:c})})]:[]])):"",l?"":B("纸张方向",Ue("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],t.orientation==="landscape"?"landscape":"portrait",c=>i({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":B("内容旋转角度",Ue("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(t.outputRotation??0),c=>n(Number(c)),!0),t.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),B("页面背景色",a("div",{class:"page-bg-row"},[Ae(t.pageBackground,c=>i({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,tt({target:t,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),Fs(o),e.pages.length>1?"":Ls(o),Pe("页边距 (mm)"),a("div",{class:"margin-grid"},[de(o,"上",t.margins.top,c=>i({margins:{...t.margins,top:c}}),{min:0,max:50}),de(o,"下",t.margins.bottom,c=>i({margins:{...t.margins,bottom:c}}),{min:0,max:100}),de(o,"左",t.margins.left,c=>i({margins:{...t.margins,left:c}}),{min:0,max:50}),de(o,"右",t.margins.right,c=>i({margins:{...t.margins,right:c}}),{min:0,max:50})]),Pe("页眉/页脚高度 (mm)"),de(o,"页眉高度",t.header.height??10,c=>i({header:{...t.header,height:c}}),{min:0,max:100,step:.1}),de(o,"页脚高度",t.footer.height??10,c=>i({footer:{...t.footer,height:c}}),{min:0,max:100,step:.1}),rl(o)].filter(Boolean))}function cl(o){const e=o.store,t=o.state,i=e.selectedElement;if(t.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{t.propCollapsed=!1,o.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([r,s,l])=>a("button",{type:"button",class:`pc-btn${t.propTab===r?" on":""}`,title:s,text:l,onClick:()=>{t.propTab=r,t.propCollapsed=!1,o.repaint()}}))])]);const n=i?t.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{t.propCollapsed=!0,o.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[a("button",{type:"button",class:`pd-tab${n==="element"?" active":""}`,text:"元素属性",onClick:()=>{t.propTab="element",o.repaint()}}),a("button",{type:"button",class:`pd-tab${n==="page"?" active":""}`,text:"页面属性",onClick:()=>{t.propTab="page",o.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="element"?"":{display:"none"}},i?[Hs(o),ll(o,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="page"?"":{display:"none"}},[dl(o)])])])}const Lo=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],dn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},pl=[{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()"}],ul=[{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()"}],hl=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],fl=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],ml=[{title:"聚合函数",items:pl},{title:"数值运算",items:ul},{title:"格式化函数",items:hl}],gl="(输入表达式后预览)",bl="(无法计算)",jo="(表达式错误)";function cn(o,e){if(!o.trim())return gl;try{const t={...p.DEFAULT_DEMO_DATA,...e??{},...A.resolveSystemVariables()},i=p.evaluateTemplate(o,t);return i==null?bl:String(i)}catch{return jo}}function pn(o,e){const t=e.trim().toLowerCase();return t?o.filter(i=>i.label.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):o}function xl(o,e){const t=o.substring(0,e),i=t.lastIndexOf("{"),n=i!==-1&&!t.slice(i+1).includes("}"),r=t.lastIndexOf("("),s=r!==-1&&!t.slice(r+1).includes(")");return{insideBlock:n,insideParens:s}}function vl(o,e){const t=/^\{\s*([^{}]+?)\s*\}$/.exec(o.trim());if(!t)return null;const i=t[1]??"";return e.find(n=>n.fieldKey===i)??null}function Io(o,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:o}),a("span",{class:"ee-item-key",text:e})])}function Ve(o){return o.currentTarget.getRootNode()}function Qt(o,e,t){const i=[];return t.forEach((n,r)=>{i.push(n),r<t.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${o}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function yl(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Qt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Qt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Qt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Qt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function wl(o,e){const t={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},i=(b,w)=>b.querySelector(w),n=b=>{const w=i(b,".ee-preview");if(!w)return;const T=cn(t.expression,o.demoData);w.textContent=T,w.classList.toggle("ee-preview-error",T===jo)},r=()=>{if(t.activeTab==="variable")return pn(fl,t.searchText).map(T=>a("div",{class:"ee-list-item",onDblclick:k=>{const{insideParens:z}=l(k);c(Ve(k),z?T.template.replace(/^\{|\}$/g,""):T.template)}},[Io(T.label,T.template)]));if(t.activeTab==="function")return ml.map(T=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:T.title}),...pn(T.items,t.searchText).map(k=>a("div",{class:"ee-list-item",onDblclick:z=>{const{insideBlock:W}=l(z),P=W?k.template:`{${k.template}}`;c(Ve(z),P,P.indexOf("(")+1)}},[Io(k.label,`${k.name}()`)]))]));const b=p.filterGroups(p.groupFields(o.fields??[]),t.searchText);if(!b.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const w=[];for(const T of b){T.key&&w.push(a("div",{class:`ee-field-group${T.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:T.isList?"📋":"📁"}),a("span",{text:T.label})]));for(const k of T.fields)w.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:T.key?"22px":"10px"},onDblclick:z=>{const{insideParens:W}=l(z);c(Ve(z),W?k.fieldKey:`{${k.fieldKey}}`)}},[Io(k.fieldLabel,k.fieldKey)]))}return w},s=b=>{Array.from(b.querySelectorAll(".ee-nav-tab")).forEach((W,P)=>W.classList.toggle("active",Lo[P]?.key===t.activeTab));const T=i(b,".ee-content-search .pd-input");if(T){const W=dn[t.activeTab];T.placeholder!==W&&(T.placeholder=W),T.value!==t.searchText&&(T.value=t.searchText)}const k=i(b,".ee-textarea");k&&k.value!==t.expression&&(k.value=t.expression);const z=i(b,".ee-content-list");if(z){Tn(z);for(const W of r())fe(W,z)}n(b)},l=b=>{const T=i(Ve(b),".ee-textarea")?.selectionStart??t.expression.length;return xl(t.expression,T)},c=(b,w,T=w.length)=>{const k=i(b,".ee-textarea");if(!k){t.expression+=w,n(b);return}const z=k.selectionStart??t.expression.length,W=k.selectionEnd??z;t.expression=t.expression.substring(0,z)+w+t.expression.substring(W);const P=z+T;k.value=t.expression,k.focus(),k.selectionStart=k.selectionEnd=P,n(b)},u=()=>{const b=t.expression;if(t.binding===void 0){o.onApply({formatter:b}),o.onClose();return}const w=vl(b,o.fields??[]);o.onApply(w?{formatter:b,binding:w.fieldKey,title:w.fieldLabel}:{formatter:b}),o.onClose()},h=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},Lo.map((b,w)=>a("div",{class:`ee-nav-tab${t.activeTab===b.key?" active":""}`,text:b.text,onClick:T=>{t.activeTab=Lo[w].key,s(Ve(T))}})))]),m=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:dn[t.activeTab],onInput:b=>{t.searchText=b.target.value,s(Ve(b))}})]),a("div",{class:"ee-content-list"},r())]),g=cn(t.expression,o.demoData),v=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:t.expression,onInput:b=>{t.expression=b.target.value,n(Ve(b))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${g===jo?" ee-preview-error":""}`,text:g})]),yl()]);return a("div",{class:"pd-dialog-overlay",onKeydown:b=>{b.key==="Escape"&&o.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"expression-editor"},[h,m,v]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>o.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>u()})])])])}const Sl={id:"getting-started",title:"快速入门",content:`
4
4
  <h2>界面布局</h2>
5
5
  <p>打印模板设计器采用三栏布局:</p>
6
6
  <ul>
@@ -40,7 +40,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
40
40
  <p><strong>项目名称:</strong>worm-vue3-print</p>
41
41
  <p><strong>仓库地址:</strong><a href="https://gitee.com/liulong_oschina/worm-vue3-print" target="_blank" rel="noopener noreferrer">https://gitee.com/liulong_oschina/worm-vue3-print</a></p>
42
42
  <p>基于 Vue 3 的可视化打印模板设计器,支持拖拽式模板编辑、表达式数据绑定和浏览器端打印预览。</p>
43
- `},fl={id:"features",title:"功能说明",content:`
43
+ `},Tl={id:"features",title:"功能说明",content:`
44
44
  <h2>元素类型</h2>
45
45
  <table>
46
46
  <thead>
@@ -211,7 +211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
211
211
  <li>支持调节水印密度(密/中/疏/自定义瓦片尺寸),以及设置水印颜色</li>
212
212
  <li>水印在画布、浏览器预览、服务端 PDF、静默打印四端渲染一致</li>
213
213
  </ul>
214
- `},ml={id:"shortcuts",title:"快捷键",content:`
214
+ `},El={id:"shortcuts",title:"快捷键",content:`
215
215
  <h2>常用操作</h2>
216
216
  <table>
217
217
  <thead>
@@ -281,16 +281,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
281
281
  <blockquote>
282
282
  <p><strong>注意</strong>:当焦点在输入框、文本框、下拉框内时,快捷键不生效。</p>
283
283
  </blockquote>
284
- `},gl={id:"faq",title:"常见问题",content:`
284
+ `},kl={id:"faq",title:"常见问题",content:`
285
285
  <h2>如何调整纸张大小?</h2>
286
286
  <ol>
287
287
  <li>在右侧面板选择"页面设置"</li>
288
288
  <li>选择预设纸张:常用纸张(A4、A3、A5、Letter、Legal)、针式打印纸(全等分 / 二等分 / 三等分)、标签纸(80×60、60×40、40×30)、小票纸(57 / 80 / 110mm)</li>
289
289
  <li>或选择"自定义"输入宽度和高度(mm);"连续纸"可自定义纸宽,出纸高度按内容自动推导</li>
290
290
  <li>设置方向:纵向(portrait)或横向(landscape);切换即交换纸张长宽,设计稿内容随之铺在该尺寸上。连续纸与小票纸固定纵向</li>
291
- <li>内容旋转角度:0° / 90° / 180° / 270°,整页内容旋转对应角度出纸。90° / 270° 时纸张长宽互换以贴合旋转后的内容,设计稿内容保持原方向、不变形不裁切;0° 为不旋转(默认)。连续纸与小票纸固定纵向、无旋转概念</li>
291
+ <li>内容旋转角度:0° / 90° / 180° / 270°,整页内容旋转对应角度出纸。90° / 270° 时纸张长宽互换以贴合旋转后的内容,设计稿内容保持原方向、不变形不裁切;0° 为不旋转(默认)。启用拼版时按每个标签的内容旋转:90° / 270° 时每格占位宽高互换,列数自动铺满新档位的列数上限,行数与每张格数按互换后重算。连续纸与小票纸固定纵向、无旋转概念</li>
292
292
  </ol>
293
293
 
294
+ <h2>元素可以斜着排或转 90° 吗?</h2>
295
+ <p>可以。选中元素后,在右侧「外观」组的「旋转 (°)」里输入角度,或点两侧按钮按 90° 步进(绕元素自身中心旋转),行末图标可恢复默认值。几点口径:</p>
296
+ <ul>
297
+ <li>上纸时按旋转后的外接方框排版:底部放不下会自动移到下一页;越过纸面左右缘或纸头会给出「打印将被裁切」提示(Vue3 画布的预览层顶部常驻一条,点保存时再提醒一次,都不阻断出纸)</li>
298
+ <li>表格、流式列表,以及紧跟在表格下方的「跟随区」元素不支持旋转——这三类不显示该行,画布所见与出纸一致</li>
299
+ <li>条码与二维码要任意角度需要 385dpi 以上打印头;分辨率不够时按 90° 步进出纸,模板未填写打印头分辨率时角度输入会置灰并写明原因</li>
300
+ </ul>
301
+
294
302
  <h2>如何处理分页?</h2>
295
303
  <p>数据表格支持自动分页:</p>
296
304
  <ol>
@@ -407,7 +415,100 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
407
415
  <blockquote>
408
416
  <p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
409
417
  </blockquote>
410
- `},bl={id:"changelog",title:"更新记录",content:`
418
+ `},Cl={id:"changelog",title:"更新记录",content:`
419
+ <h2>V1.4.0<small>(2026-10-28)</small></h2>
420
+
421
+ <h3>新增</h3>
422
+ <ul>
423
+ <li><strong>元素可以任意角度旋转</strong>:外观组新增「旋转 (°)」行,输入角度或点两侧按钮按 90° 步进,绕元素自身中心旋转,配套「恢复默认值」。上纸时按旋转后的外接方框排版——底部放不下会自动移到下一页,纸面左右缘超出或顶部越界会给出「打印将被裁切」提示。表格、流式列表以及表格下方跟随区的元素不支持旋转(这三类不出该行,画布与出纸保持一致)。条码与二维码要任意角度需 385dpi 以上打印头,分辨率不够时只按 90° 步进出纸,未设置打印头分辨率时角度输入框会置灰并写明原因。</li>
424
+ <li><strong>出纸裁切提示</strong>:元素旋转后越过页首、或(含旋转后的外接方框)超出纸面左右缘时,给出「打印将被裁切」提示并列出元素与超出量。Vue3 画布的预览层顶部常驻这条提示(按真实分页与实测高计算);点保存时也给一次提示,但那是按设计盒估算的预估口径(长文本等自适应高度可能偏保守),<strong>不阻断保存</strong>。</li>
425
+ <li><strong>拼版也能设置内容旋转角度</strong>:启用拼版后「内容旋转角度」不再隐藏。0° / 180° 只转每个标签的内容、格子位置不变;90° / 270° 时每格占位宽高互换(70×40 的标签变成 40×70 的格),每张纸能放的列数、行数与格数会按互换后的尺寸重算,切换旋转档位时拼版列数还会自动铺满新档位的列数上限(切回原档位同样回排,手动改小的列数在重排后仍可再改)。拼版摘要会直接显示「每格 宽×高」,列数超宽的红字也会注明旋转后的每格尺寸。未设置旋转的模板产物不变。</li>
426
+ </ul>
427
+
428
+ <h3>变更</h3>
429
+ <ul>
430
+ <li><strong>打印预览默认按 100% 显示</strong>:此前模板设了打印机分辨率时预览默认放大到「点阵」档(203dpi ≈ 2.11 倍),现在一律从 100%(纸张真实尺寸)打开,五档档位与「点阵」入口不变,点一下就能切回去。注意 100% 档下细条码在屏幕上仍会糊成一团——那是屏幕像素不够,不是打印问题,纸面点距由「打印机分辨率」在出纸时结算;预览条此时会提示「条码看不清?切点阵档」,切到点阵档提示自动收起。</li>
431
+ </ul>
432
+
433
+ <h3>修复</h3>
434
+ <ul>
435
+ <li><strong>二维码不再漏掉打印分辨率判定</strong>:此前只有条码会按打印头分辨率把斜角吸附成 90° 步进,二维码被漏掉——低分辨率工位机上斜角二维码照样旋转出纸。现在条码与二维码走同一条判定,字段说明也改成与实际一致。</li>
436
+ <li><strong>并排的紧尺寸标签不再被挤到第二页</strong>:左右并排的二维码与信息行此前各占一列,下方整宽尾行会把两列高度重复扣两次,称签 / 资产 / 卷纸三类模板在紧尺寸下会多出一页(拼版模板因此拒纸)。现在这类并排块按组合记账,整组同页、纵向只扣一次;示例库已同步,未并排的模板产物不变。</li>
437
+ </ul>
438
+
439
+ <h2>V1.3.11<small>(2026-10-26)</small></h2>
440
+
441
+ <h3>新增</h3>
442
+ <ul>
443
+ <li><strong>文本 / 长文本可选「保留换行符」</strong>:内容里手打的换行符、行首空格与连续空格可以原样上纸了(属性台「自动换行」下方新增一行,缺省关)。多行正文也可放进表格单元格——那里默认就断行。</li>
444
+ <li><strong>示例库新增「文本换行与跟随示例」</strong>:一份 A4 模板同时演示本版四条出纸口径——保留换行符的多行正文、关自动换行的单行溢出、长文本行距,以及表格旁侧一栏不会被跟随区拖走。</li>
445
+ </ul>
446
+
447
+ <h3>修复</h3>
448
+ <ul>
449
+ <li><strong>表格旁边那一栏不会再被拖走</strong>:跟着表格走的只保留「与表格上下对齐(横向有交集)」的元素,放在表格右边或横向离得远的元素留在原处;同列正下方的元素照旧跟随。</li>
450
+ <li><strong>长文本的行距与设计器一致了</strong>:未单独设行高的长文本,此前纸面比设计器紧约 9%,现按设计器同口径排版(自适应行高的会长一点,截断档同一个框能少显示一行)。</li>
451
+ <li><strong>表格下方的竖线不再消失</strong>:放在表格跟随区的竖线此前出纸高度为 0、整条看不见,现按设计长度印出(横线行为不变)。</li>
452
+ <li><strong>长文本关掉「自动换行」真的走单行</strong>:此前纸面仍按多行折行、只有设计器是单行。现三端一致。注意这一档的组合是「单行溢出」而不是省略号——要省略号请把显示形式显式设为「截断」。</li>
453
+ </ul>
454
+
455
+ <h2>V1.3.10<small>(2026-10-24)</small></h2>
456
+
457
+ <h3>新增</h3>
458
+ <ul>
459
+ <li><strong>打印预览可缩放</strong>:预览顶部新增「点阵 / 适配 / 100% / 200% / 400%」档位。模板设置了打印机分辨率时默认落在「点阵」档,屏幕上 1 像素正好对应纸上 1 个打印点,细条码不会再糊成一片;「适配」档按真实纸宽计算,A3 / A5 横版、Letter / 热敏纸同样正确。</li>
460
+ <li><strong>流式列表</strong>:新增一栏类型,把一组明细按「每行几列」横着密排、排满自动换行,适合处方药材、配件清单这类没有格线的栏位。每行列数、行高与横向间距都由你填;打开「内容过长时跨列」后,比一列更宽的条目会占两列以上,当前行放不下时整条挪到下一行行首,不会把词切两半。列数挤不下只提示「可放约几列」,不会替你改值。一个框只排一页,需要续排请用表格。</li>
461
+ <li><strong>每一行都能一键恢复默认值</strong>:凡是有出厂默认值的属性行,标签最右侧多了一个恢复图标,只在当前值与默认值不同时点亮,点一下把这一行写回默认值;已是默认值时置灰,点了不产生历史记录。悬浮提示会直接说清要恢复成什么。没有整组或整个元素的一键重置。</li>
462
+ <li><strong>元素也能分边设边框</strong>:「边框与背景」补齐线型与「全部 / 外侧 / 内部 / 无」预设、上右下左单边勾选,与表格单元格同一形态。元素只有一圈边、没有相邻格共用的内部线,所以「内部」对元素保持置灰。</li>
463
+ <li><strong>示例库新增三份模板</strong>:中药处方笺(演示流式列表)、电池模块出货标签两份(含条码格与不含标签格,只差一行的格子划分,便于对照)。</li>
464
+ <li><strong>条形码条高与静区可调</strong>:条形码元素与表格单元格都能设置「条高 (mm)」与「静区 (模块)」。条高只量黑白条本体;静区缺省 10 模块,调小可以让同样宽度里的条更粗。条宽倍率上限由 4 提高到 8。选好打印机分辨率后,条宽一行会给出推荐档与当前折算毫米数,只作参考,不会替你改值。</li>
465
+ </ul>
466
+
467
+ <h3>变更</h3>
468
+ <ul>
469
+ <li><strong>不再预置字体</strong>:新建元素不再自动写上字体名,字体下拉也不再列出内置字体档——黑体、微软雅黑等是厂商授权字体,项目不再替你的产出物决定用谁的字体。没配置字体的模板落纸交还各端的系统默认字体;要三端字面完全一致,请声明随模板分发的字体文件,或填写本机已装的字体名。已有模板里写好的字体名照常生效。</li>
470
+ <li><strong>表格边框改成所见即所得</strong>:单选一个单元格时,线型 / 宽度 / 颜色与上右下左四边会读回这个格子的真实设置;四边规格不一致的项显示「混合」,一条边都没有时显示「无 / 0」;选中多个格子时只做批量设置,不拿其中某一格冒充全部。勾某一条边不再把该格已有的其余三条边写没。顶部工具栏的边框面板与属性台同一套回显。</li>
471
+ <li><strong>线型新增「无」</strong>:属性台与顶部工具栏都能表达「这里没有边框」;工具栏的线型按钮再点一次即取消,四个图标可以全不亮。给一个没有边框的元素选任一条线型,会按缺省粗细开一条框。</li>
472
+ <li><strong>单元格里的换行符真的换行</strong>:可换行的格子按换行断行,英文按整词折行(不再逐字拆开),中文仍按字断。数据里带换行的字段(地址、备注)出纸会占更多行、表格变长,可能引起分页位移。</li>
473
+ </ul>
474
+
475
+ <h3>修复</h3>
476
+ <ul>
477
+ <li><strong>表格单元格的条宽与条码字号现在会出纸</strong>:以前在属性台把单元格条宽调到 3/4/8 只有设计器里变化,出纸仍是缺省宽度;单元格条码的文字字号也取错了字段,现已与画布一致。</li>
478
+ <li><strong>预览「适配」档按真实纸宽计算</strong>:此前缩放自带一份纸型宽度表,A3 / A5 横版、部分针式与热敏纸的宽度漏算或按纵向 A4 处理,适配比例有偏差;现已与出纸几何同源。</li>
479
+ <li><strong>素材台与页签的悬停提示更易读</strong>:长字段名被省略后,悬停会显示统一风格的提示气泡并展示完整的「中文名 (变量名)」;页签与素材台不再同时冒出两个气泡。</li>
480
+ </ul>
481
+
482
+ <h2>V1.3.9<small>(2026-10-22)</small></h2>
483
+
484
+ <h3>修复</h3>
485
+ <ul>
486
+ <li><strong>补上字段长名那条更新说明</strong>:「变量名过长时中文名自动占满一行」其实已经随 1.3.8 生效,只是这条说明当时漏在了应用内的更新记录里,现在补上;功能没有再改动。</li>
487
+ </ul>
488
+
489
+ <h2>V1.3.8<small>(2026-10-22)</small></h2>
490
+
491
+ <h3>新增</h3>
492
+ <ul>
493
+ <li><strong>图片裁剪取位可视化</strong>:属性台改为「位置档 + 数字框 + 原图示意」,红框就是最终打印出来的画面,换档或改数字时同步移动;有图时只显示真正能挪的方向,两个方向都能挪才给九宫格。缩放模式里的「覆盖」统一改叫「剪裁(等比铺满后裁边)」。</li>
494
+ <li><strong>裁剪放大比例</strong>:图与框比例相同时,铺满后其实没有可裁的边;填 100~400 的放大比例把画面再推大,才能裁出顶部 / 底部或左右。不填即保持原样。</li>
495
+ </ul>
496
+
497
+ <h3>变更</h3>
498
+ <ul>
499
+ <li><strong>锚点只在「剪裁」档出现</strong>:包含、拉伸填满、原始尺寸、缩小四档不再显示锚点与放大比例。</li>
500
+ <li><strong>表格图片单元格剪裁后行高会变</strong>:选「剪裁」时图片不再把行撑高,按声明行高出纸;取顶 / 取底会真的裁到画面。既有模板若用了这一档,升级后请复核行高。</li>
501
+ </ul>
502
+
503
+ <h3>修复</h3>
504
+ <ul>
505
+ <li><strong>大写金额的万 / 亿不再丢失</strong>:超过一万的金额会正确写出「万 / 亿」;角位为 0 而分位非 0 时补「零」,不足一元保留「元」位。</li>
506
+ <li><strong>字体下拉不再撑乱页面</strong>:展开候选时改为浮层,顶栏、属性台不再被撑高或错位,空间不足时向上翻。</li>
507
+ <li><strong>表格与横竖线不再被误拆页</strong>:单页模板不会因为竖线占用高度被拆成两页,元素回到设计位置;表格跟随区的数据驱动位移仍在处理中。</li>
508
+ <li><strong>裁剪示意更可信</strong>:图片未设置或表达式还没求值时显示示例图并说明;换图、加载失败不再沿用上一张图的可挪量,示意框也不再被拉成横条。</li>
509
+ <li><strong>字段名过长不再挤掉中文名</strong>:素材台里变量名太长时会自动挪到第二行,中文名始终占满一整行;确实放不下时才省略,鼠标停在字段上可看到完整的中文名和变量名,分组名同样有提示。</li>
510
+ </ul>
511
+
411
512
  <h2>V1.3.7<small>(2026-10-19)</small></h2>
412
513
 
413
514
  <h3>新增</h3>
@@ -654,4 +755,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
654
755
  <blockquote>
655
756
  <p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
656
757
  </blockquote>
657
- `},zt=[hl,fl,ml,gl,bl],_i="worm-print-help-tab",xl="getting-started";function Qn(t){return zt.some(e=>e.id===t)?String(t):""}function vl(t){let e=null;try{e=window.localStorage.getItem(_i)}catch{e=null}return Qn(e)||Qn(t)||xl}function yl(t){const e=vl(t.initialTab),o=(n,i)=>{const r=n.currentTarget,s=r.closest(".help-modal");if(!s)return;for(const c of Array.from(s.querySelectorAll(".help-tab")))c.classList.toggle("active",c===r);const l=s.querySelector(".help-content");l&&(l.innerHTML=zt.find(c=>c.id===i)?.content??"");try{window.localStorage.setItem(_i,i)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:n=>{n.target===n.currentTarget&&t.onClose()},onKeydown:n=>{n.key==="Escape"&&t.onClose()}},[a("div",{class:"help-modal"},[a("div",{class:"help-modal-header"},[a("div",{class:"help-modal-title-wrap"},[a("h2",{class:"help-modal-title",text:"帮助文档"}),a("span",{class:"help-modal-project",text:"worm-vue3-print"})]),a("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>t.onClose()})]),a("div",{class:"help-modal-body"},[a("div",{class:"help-modal-sidebar"},zt.map(n=>a("button",{type:"button",class:`help-tab${n.id===e?" active":""}`,text:n.title,onClick:i=>o(i,n.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:zt.find(n=>n.id===e)?.content??""})])])])])}function wl(t,e){const o=te(yl(e),t),n=i=>{i.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",n),o.focus?.(),()=>{document.removeEventListener("keydown",n),o.remove()}}const Sl=2,Tl=74,So=[{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 El(t){const e=!!t.state.openMore,o=So.slice().sort((n,i)=>n.order-i.order).map(n=>a("div",{class:"tb-more-item",dataset:{unit:n.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:n.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${n.id}`,dataset:{unit:n.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{t.state.openMore=!e,t.repaint()},html:`${se("Ellipsis",15)}<span class="tb-btn-text">更多</span>${se("ChevronDown",12,"tb-dd-arrow")}`}),a("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[a("div",{class:"tb-menu tb-more-menu"},o)])])])}const ei=new WeakMap;function ti(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const o=getComputedStyle(e),n=Number.parseFloat(o.gap)||Sl,i=Number.parseFloat(o.paddingLeft)||0,r=Number.parseFloat(o.paddingRight)||0,s=new Map;for(const S of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const T=S.parentElement;T&&!T.classList.contains("tb-more-slot")&&ei.set(S,{parent:T,next:S.nextSibling}),s.set(S.dataset.unit,S)}for(const S of s.values()){const T=ei.get(S);!T||S.parentElement===T.parent||(T.next?.parentElement===T.parent?T.parent.insertBefore(S,T.next):T.parent.appendChild(S))}let l=0;for(const S of Array.from(e.children)){if(S.classList.contains("tb-spacer")||S.classList.contains("tb-more-group"))continue;const T=Math.max(S.offsetWidth,S.scrollWidth);T<=0||(l+=T+n)}const c=new Map;for(const[S,T]of s){const k=T.offsetWidth;k>0&&c.set(S,k)}const f=So.map(S=>({id:S.id,order:S.order,width:c.get(S.id)??0})),g=f.reduce((S,T)=>S-T.width-n,l),u=e.clientWidth-i-r,{movedIds:h,overflowRemains:A}=m.resolveToolbarOverflow({available:u,pinned:g,moreTriggerWidth:Tl,gap:n,units:f});for(const S of So){const T=e.querySelector(`.tb-more-item[data-unit="${S.id}"]`),k=e.querySelector(`#tb-more-slot-${S.id}`),z=s.get(S.id);if(!T||!k||!z)continue;const v=h.includes(S.id);v&&z.parentElement!==k&&k.appendChild(z),T.style.display=v?"":"none"}const x=e.querySelector(".tb-more-group");return x&&(x.style.display=h.length>0?"":"none"),e.classList.toggle("is-tight",A),{movedIds:h,overflowRemains:A}}function kl(t,e){const o=t.store,n=o.selectedIds.size>0,i=o.selectedIds.size>1,r=o.selectedElement,s=!n,l=t.isEdit?"编辑模板":"新建模板",c=[a("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[a("div",{class:"tb-menu-label",text:"对齐 / 分布"}),a("div",{class:"tb-menu-grid"},[q(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!i}),q(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!i}),q(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!i}),q(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!i}),q(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!i}),q(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!i}),q(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!i}),q(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!i})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[q(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!n}),q(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!n}),q(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!n}),q(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!n})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[q(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!i}),q(t,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],f=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[g("标尺",o.showRuler,"toggle-ruler","显示/隐藏标尺"),g("网格",o.showGrid,"toggle-grid","显示/隐藏网格背景"),g("虚框",o.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),g("吸附",o.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function g(u,h,A,x){return a("button",{type:"button",class:`tb-btn tb-menu-row${h?" on":""}`,dataset:{tip:x},onClick:()=>t.fire(A)},[a("span",{class:"dot"}),u])}return a("div",{class:"designer-toolbar"},[a("div",{class:"tb-group tb-brand"},[a("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>'}),a("div",{class:"tb-title"},[a("span",{class:"tb-title-name",text:l}),a("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),a("div",{class:"tb-group"},[q(t,"Undo2","undo",{tip:"撤销",disabled:!o.canUndo}),q(t,"Redo2","redo",{tip:"重做",disabled:!o.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[It(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),It(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},f)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[q(t,"Maximize","fit-window",{tip:"适应窗口"}),q(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${o.scale}%`}),q(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[q(t,"Copy","copy",{tip:s?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:s,test:"copy"}),q(t,"ClipboardPaste","paste",{tip:s?"粘贴 (Ctrl+V),需选中元素":o.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:s||!o.hasClipboard,test:"paste"}),q(t,"Trash2","delete",{tip:s?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:s,danger:!0,test:"delete"})]),El(t),a("div",{class:"tb-spacer"}),t.showHelp?a("div",{class:"tb-group"},[a("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>t.fire("help")},[a("span",{class:"help-icon",text:"?"})])]):"",a("div",{class:"tb-group"},[a("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>t.fire("preview")}),a("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>t.fire("save")})])].filter(Boolean))}function ho(t,e,o){for(const n of e){const i=t.getPropertyValue(n).trim();if(i)return i}return o}function Cl(t,e){const o=e.orientation==="horizontal",n=e.geom,i=o?n.viewW:n.viewH;t.style.width=`${o?i:m.RULER_THICKNESS}px`,t.style.height=`${o?m.RULER_THICKNESS:i}px`;const r=t.getContext("2d");if(!r)return;const s=window.devicePixelRatio||1,l=Math.max(0,Math.round(i)),c=m.RULER_THICKNESS;t.width=(o?l:c)*s,t.height=(o?c:l)*s,r.setTransform(s,0,0,s,0,0);const f=getComputedStyle(t),g=ho(f,["--pd-ruler-bg"],"#F8F9FC"),u=ho(f,["--pd-ruler"],"#9AA1AF"),h=ho(f,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=g,r.fillRect(0,0,o?l:c,o?c:l);const A=e.scale>0?e.scale:n.paperScale>0?n.paperScale:1,x=m.mmToPx(1)*A;if(x<=0)return;const S={ctx:r,horizontal:o,viewportPx:i,thickness:c,originPx:o?n.originX:n.originY,pxPerMM:x,paperLengthMM:e.paperLengthMM},T=-S.originPx/x,k=(l-S.originPx)/x,z=m.chooseMajorStepMM(A),v=m.buildRulerTicks(T,k,z);oi(S,v,u,!0),oi(S,v,u,!1),ni(S,0,h),ni(S,e.paperLengthMM,h);const w=e.cursorPx??null;if(w!==null&&w>=0&&w<=l){if(r.strokeStyle=h,r.lineWidth=1.5,r.beginPath(),o){const I=Math.round(w)+.5;r.moveTo(I,0),r.lineTo(I,c)}else{const I=Math.round(w)+.5;r.moveTo(0,I),r.lineTo(c,I)}r.stroke()}}function zi(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function oi(t,e,o,n){const{ctx:i,horizontal:r,paperLengthMM:s}=t;i.strokeStyle=o,i.fillStyle=o,i.globalAlpha=n?.32:1,i.lineWidth=1,i.font="9px ui-monospace, Menlo, monospace",i.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>s)!==n)continue;const f=zi(t,l.mm),g=l.major?8:4;i.beginPath(),r?(i.moveTo(f,0),i.lineTo(f,g)):(i.moveTo(0,f),i.lineTo(g,f)),i.stroke(),l.major&&l.label&&(r?i.fillText(l.label,f+2,11):(i.save(),i.translate(11,f+2),i.rotate(-Math.PI/2),i.fillText(l.label,0,0),i.restore()))}i.globalAlpha=1}function ni(t,e,o){const{ctx:n,horizontal:i,thickness:r,viewportPx:s}=t,l=zi(t,e);l<=0||l>=s||(n.strokeStyle=o,n.globalAlpha=.55,n.lineWidth=1,n.beginPath(),i?(n.moveTo(l,0),n.lineTo(l,r)):(n.moveTo(0,l),n.lineTo(r,l)),n.stroke(),n.globalAlpha=1)}const Al=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select-input{width:100%}.font-select-list{margin-top:4px;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);list-style:none}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{font-size:11px;color:var(--pd-text-muted, #909399);flex-shrink:0}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:break-all}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-4682b43a .3s ease-out}@keyframes snap-pulse-4682b43a{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.pd-reset{height:26px;padding:0 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;flex-shrink:0;transition:all .14s ease}.pd-reset:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.page-tabs-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;white-space:nowrap;pointer-events:none}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}',Mt=20,Dl=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),Ml={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},ii="print-studio:left",ri="print-studio:right";function ai(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function si(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}class we extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;pageTipEl=null;pageTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Al,this.root.appendChild(e),te(a("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(e){this.applyTemplate(e)}get template(){return this.store?.getTemplateJson()}set fields(e){this.store.fields=(typeof e=="string"?JSON.parse(e):e)??[],this.repaint()}set isEdit(e){this.setAttribute("is-edit",String(e)),this.repaint()}set showHelp(e){this.setAttribute("show-help",String(e)),e||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(e,o,n){if(!n)return;if(e==="name"){this.repaint();return}let i;try{i=JSON.parse(n)}catch{return}e==="template"?this.applyTemplate(i):e==="fields"?(this.store.fields=i,this.repaint()):e==="fonts"&&Array.isArray(i)&&(this.fonts=i)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},o=this.getAttribute("template");if(o)try{e.initialTemplate=JSON.parse(o)}catch{}const n=this.getAttribute("fields");if(n)try{e.initialFields=JSON.parse(n)}catch{}this.store=new ui(e),this.format=new pr(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=ai(ii),this.state.propCollapsed=ai(ri),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const e=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;e!==this.chromeKey&&(this.chromeKey=e,si(ii,this.state.leftCollapsed),si(ri,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,we.active===this&&(we.active=null),Ei(),this.unmountHelp?.(),this.unmountHelp=null,this.hidePageTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=R.buildFontFaceCss(this._fonts);if(!e){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=e,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=e}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),o=this.fonts;if(!o?.length)return e;if(Array.isArray(e.pages)){const n=e;return{...n,pages:n.pages.map(i=>({...i,fonts:[...o]}))}}return{...e,fonts:[...o]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const o=this.templateJsonWithFonts();if(Array.isArray(o.pages))try{R.normalizeTemplate(o)}catch(i){window.alert(i instanceof Error?i.message:String(i));return}const n=JSON.stringify(o);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?R.validateTiling(e):[]}applyTemplate(e){if(!e)return;const o=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(o):this.setAttribute("template",JSON.stringify(o))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(n=>n.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(n=>n.remove());const o=this.exprTarget;te(ul({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:n=>this.applyExpression(o,n)},o),this.root),this.exprMountedFor=o}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const e=this.helpVisible&&this.getAttribute("show-help")!=="false";if(e&&!this.unmountHelp)this.unmountHelp=wl(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const o=this.unmountHelp;this.unmountHelp=null,o()}}applyExpression(e,o){const n=o.formatter??"",i=e.targetPath;if(i.startsWith("options.")){if(i.includes("[")){const s=this.store.elements.find(l=>l.id===e.elementId);s&&Oo(this.store,s,i,n);return}const r={[i.slice(8)]:n||void 0};o.title!==void 0&&(r.title=o.title),this.store.updateElement(e.elementId,r);return}if(i==="watermark.content"){const r={...this.store.templateData.watermark};yo(n)?Object.assign(r,{mode:"binding",binding:n,content:""}):Object.assign(r,{mode:"fixed",content:n,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const o=this.store.elements.find(i=>i.id===e);if(!o||(this.store.selectOne(e),this.state.propTab="element",o.options.locked))return;const n=Ml[o.printElementType.type];n&&this.openExpression({elementId:o.id,targetPath:`options.${n}`,value:String(o.options[n]??"")})}dblEditCell(e){const o=this.store.elements.find(l=>l.id===e.elementId);if(!o||(this.store.selectOne(o.id),this.state.propTab="element",o.options.locked))return;const n=o.options.tableRows??[],i=m.findMainCell(n,e.r,e.c),s=n[i.r]?.cells[i.c];s&&this.openExpression({elementId:o.id,targetPath:`options.tableRows[${i.r}].cells[${i.c}].formatter`,value:s.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(e,o)=>this.fire(e,o),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const e=[...this.store.selectedIds].join(",");e!==this.lastSelKey&&(this.lastSelKey=e,this.state.propTab=e?"element":"page");const o=this.root.querySelector(".designer-container");o.classList.toggle("format-painting",this.format.painterActive),ci(o);const n=this.ctx;te(kl(n,fs(n)),o),te(ws(n),o),te(a("div",{class:"designer-body"},[bs(n),ja(n,this.canvasUi()),tl(n)]),o),te(Ss(n),o),ti(o),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>ti(o)),this.toolbarRo.observe(o));const i=Aa(this.store,(r,s)=>this.fire(r,s),this.tableMenu);i&&te(i,o),ea(this.root,this.store.elements),Di(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))To.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const o=e.getAttribute("data-fit-base");o?e.style.fontSize=`${o}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),o=this.root.querySelector(".hiprint-printPaper");if(!e||!o)return;const n=e.getBoundingClientRect(),i=o.getBoundingClientRect(),r=(this.store.scale||100)/100,s=i.width/m.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(s-r)<.002?r:s,originX:i.left-n.left-Mt+this.scrollPos.x,originY:i.top-n.top-Mt+this.scrollPos.y,viewW:e.clientWidth-Mt,viewH:e.clientHeight-Mt},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,o=m.getPaperDimensions(e),n=this.geom.paperScale;for(const i of Array.from(this.root.querySelectorAll(".pd-ruler"))){const r=i.dataset.ruler==="vertical"?"vertical":"horizontal";Cl(i,{orientation:r,geom:this.geom,scale:n,paperLengthMM:r==="horizontal"?o.width:o.height})}}patchElementDom(){for(const n of this.store.elements){const i=this.root.querySelector(`[data-el-id="${CSS.escape(n.id)}"]`);i&&(i.style.left=`${n.options.left}mm`,i.style.top=`${n.options.top}mm`,i.style.width=`${n.options.width}mm`,i.style.height=`${n.options.height}mm`)}const e=this.root.querySelector(".position-label"),o=this.store.selectedElement;e&&o&&!this.drag&&(e.textContent=ki(o.options))}fire(e,o){const n=this.store;switch(e){case"undo":n.undo();break;case"redo":n.redo();break;case"align":n.alignSelected(o);break;case"move-layer":n.moveLayer(o);break;case"group":n.groupSelected();break;case"ungroup":n.ungroupSelected();break;case"copy":n.copy();break;case"cut":n.cutSelected();break;case"paste":n.paste();break;case"paste-at":n.paste();break;case"delete":n.deleteSelected();break;case"delete-page":n.deletePage(n.activePageIndex);break;case"add-page":n.addPage();break;case"duplicate-page":n.duplicatePage(n.activePageIndex);break;case"move-page":n.movePage(n.activePageIndex,n.activePageIndex+o);break;case"select-all":n.selectAll();break;case"clear-selection":n.clearSelection();break;case"toggle-ruler":n.showRuler=!n.showRuler,this.repaint();break;case"toggle-grid":n.showGrid=!n.showGrid,this.repaint();break;case"toggle-snap":n.snapToGrid=!n.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":n.showTableGhostBorder=!n.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(o>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":n.removeGuide(o);break;case"resize-start":this.beginResize(o);break;case"element-mousedown":{const i=o;i.event.button===0&&this.isDoubleTap(`el:${i.id}`,i.event)&&this.fire("element-dblclick",{event:i.event,id:i.id}),this.beginDrag(i);break}case"table-cell-mousedown":{const i=o;this.isDoubleTap(`cell:${i.elementId}:${i.r}:${i.c}`,i.event)&&(this.taps.delete(`el:${i.elementId}`),this.fire("table-cell-dblclick",{elementId:i.elementId,r:i.r,c:i.c,cellId:i.cellId}));break}case"zone-resize":this.beginZoneResize(o);break;case"guide-mousedown":this.beginGuideDrag(o);break;case"ruler-mousedown":this.beginRulerGuide(o);break;case"canvas-mousedown":this.onCanvasMouseDown(o);break;case"canvas-mousemove":this.onCanvasMouseMove(o);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(o);break;case"contextmenu":this.onElementContextMenu(o);break;case"element-dblclick":{const{id:i}=o;this.dblEditElement(i),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:i,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const i=o;this.dblEditCell(i),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:i.elementId,r:i.r,c:i.c,cellId:i.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(o);break;case"drop":this.onDrop(o);break;case"wheel":this.onWheel(o);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const o=e.dataTransfer,n=o?.getData("elementType"),i=o?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const s={x:r.left,y:r.top};if(n)this.store.addElement(n,{},s);else if(i){const l=this.store.fields.find(c=>c.fieldKey===i);l&&this.store.addFieldElement(l,{},s)}}pointToPaperMm(e){const o=this.root.querySelector(".hiprint-printPaper");if(!o)return null;const n=o.getBoundingClientRect(),i=(this.store.scale||100)/100,r=m.pxToMm((e.clientX-n.left)/i),s=m.pxToMm((e.clientY-n.top)/i);return r<0||s<0?null:{left:r,top:s}}onCanvasMouseDown(e){const o=e.target;(o===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(i=>o.classList.contains(i)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const o=this.pointToPaperMm(e),n=this.root.querySelector("[data-coord]");if(n){if(!o){n.style.display="none";return}n.style.display="",n.textContent=`x:${(o.left-this.store.templateData.margins.left).toFixed(1)} y:${(o.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,o){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=o,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const n=this.root.querySelector(".context-menu");if(!n)return;const i=n.getBoundingClientRect();this.menu.flipX=i.right>window.innerWidth?window.innerWidth-i.right-8:0,this.menu.flipY=i.bottom>window.innerHeight?window.innerHeight-i.bottom-8:0,this.paint()})}startMarquee(e){const o={x:e.clientX,y:e.clientY},n=r=>{this.marquee={visible:!0,x:Math.min(o.x,r.clientX),y:Math.min(o.y,r.clientY),w:Math.abs(r.clientX-o.x),h:Math.abs(r.clientY-o.y)},this.paint()},i=()=>{window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",i);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const s=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const f=c.getBoundingClientRect();return f.left<r.x+r.w&&f.right>r.x&&f.top<r.y+r.h&&f.bottom>r.y});this.store.select(new Set(s.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",n),window.addEventListener("mouseup",i)}taps=new Map;isDoubleTap(e,o){const n=this.taps.get(e);return this.taps.set(e,{t:o.timeStamp,x:o.clientX,y:o.clientY}),!n||o.timeStamp-n.t>=500||Math.abs(o.clientX-n.x)>6||Math.abs(o.clientY-n.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const o=e.event;if(o.button!==0)return;const n=this.store;o.stopPropagation();const i=n.elements.find(l=>l.id===e.id);if(!i||(n.selectElement(i.id,o.ctrlKey||o.metaKey),i.options.locked))return;const r=o.altKey?[i.id]:n.dragIds(i.id),s=new Map;for(const l of r){const c=n.elements.find(f=>f.id===l);c&&s.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:r,primary:i.id,altKey:o.altKey,movedPositions:new Map,startX:o.clientX,startY:o.clientY,origin:s,zone:i.zone||"content",moved:!1},n.draggingIds=new Set(r),n.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const o of Array.from(this.root.querySelectorAll(".print-element"))){const n=e.has(o.dataset.elId??"");o.classList.toggle("drag-ghost",n);const i=o.querySelector(":scope > .drag-preview");n&&!i?te(a("div",{class:"drag-preview"}),o):!n&&i&&i.remove()}}finishAltClone(e){const o=this.store;o.adsorbGuides=[];const n=o.elements.find(s=>s.id===e.primary),i=e.movedPositions.get(e.primary);if(o.discardLive(),!n||!i)return;const r=JSON.parse(JSON.stringify(n));r.id=m.generateId(),r.options.left=i.left,r.options.top=i.top,r.options.groupId=void 0,o.cloneElement(r)}flashSnapIndicator(e,o){const n=this.root.querySelector(".hiprint-printPaper-content");n&&(n.querySelector(".snap-indicator")?.remove(),te(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${o}mm`}}),n),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{n.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const o=e.event;o.stopPropagation();const n=this.store.elements.find(i=>i.id===e.id);!n||n.options.locked||(this.resize={id:e.id,point:e.point,startX:o.clientX,startY:o.clientY,origin:{left:n.options.left,top:n.options.top,width:n.options.width,height:n.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const o=e.event.clientY,n=this.store.templateData,i=e.zone==="header"?n.header.height:n.footer.height,r=(this.store.scale||100)/100,s=c=>{const f=m.pxToMm((c.clientY-o)/r),g=Math.max(0,Math.round((i+(e.zone==="header"?f:-f))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...n.header,height:g}}):this.store.updateTemplateData({footer:{...n.footer,height:g}}),this.paint()},l=()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",s),window.addEventListener("mouseup",l)}beginGuideDrag(e){const o=(this.store.templateData.guides??[]).find(g=>g.id===e.id);if(!o)return;const n=m.getPaperDimensions(this.store.templateData),i=o.type==="vertical"?n.width:n.height,r=e.event.clientX,s=e.event.clientY,l=(this.store.scale||100)/100,c=g=>{const u=m.pxToMm((o.type==="vertical"?g.clientX-r:g.clientY-s)/l);this.store.moveGuide(o.id,Math.min(i,Math.max(0,o.position+u))),this.paint()},f=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",f),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",f)}beginRulerGuide(e){const o=e.orientation==="horizontal"?"vertical":"horizontal",n=r=>{this.guidePreview={type:o,position:o==="vertical"?r.clientX:r.clientY},this.paint()},i=r=>{window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",i);const s=this.rulerPointToMM(r,o);this.guidePreview=null,s!==null?this.store.addGuide(o,s):this.repaint()};window.addEventListener("mousemove",n),window.addEventListener("mouseup",i)}rulerPointToMM(e,o){const n=this.root.querySelector(".hiprint-printPaper");if(!n)return null;const i=n.getBoundingClientRect(),r=m.mmToPx(1)*(this.geom.paperScale||1),s=o==="vertical"?(e.clientX-i.left)/r:(e.clientY-i.top)/r,l=m.getPaperDimensions(this.store.templateData),c=o==="vertical"?l.width:l.height;return s<0||s>c?null:s}applyZoom(e,o,n,i){const r=this.root.querySelector(".canvas-area");if(!r)return;const s=Math.round(this.store.scale),l=Math.max(i,Math.round(e));if(l===s)return;const c=getComputedStyle(r),f=parseFloat(c.paddingLeft)||0,g=parseFloat(c.paddingTop)||0,u=r.scrollLeft+o-f,h=r.scrollTop+n-g,A=l/s;this.store.setScale(l,i),r.scrollLeft=u*A-o+f,r.scrollTop=h*A-n+g}zoomByStep(e){const o=this.root.querySelector(".canvas-area");o&&this.applyZoom(m.nextWheelScale(this.store.scale,e),o.clientWidth/2,o.clientHeight/2,m.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const o=getComputedStyle(e),n=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0),i=(parseFloat(o.paddingTop)||0)+(parseFloat(o.paddingBottom)||0),r=m.getPaperDimensions(this.store.templateData),s=m.computeFitScale(e.clientWidth-n,e.clientHeight-i,m.mmToPx(r.width),m.mmToPx(r.height));this.applyZoom(s,e.clientWidth/2,e.clientHeight/2,m.FIT_SCALE_MIN_PERCENT)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const o=this.root.querySelector(".canvas-area");if(!o)return;const n=Math.round(this.store.scale),i=m.nextWheelScale(n,e.deltaY>0?-1:1);if(i===n)return;const r=o.getBoundingClientRect();this.applyZoom(i,e.clientX-r.left,e.clientY-r.top,m.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const o=this.store;if(!o)return;const i=((o.scale||100)/100||1)*m.mmToPx(1),r=(s,l)=>({dx:s/i,dy:l/i});if(this.drag){const{dx:s,dy:l}=r(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(s)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=o.elements.find(x=>x.id===this.drag.primary),f=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+s,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let g=null;if(f&&o.snapToGrid!==!1){const x=o.elements.filter(k=>!this.drag.ids.includes(k.id)&&(k.zone||"content")===this.drag.zone).map(k=>({id:k.id,left:k.options.left,top:k.options.top,width:k.options.width,height:k.options.height})),S=xo(o.templateData,o.paperSize)[this.drag.zone],T=m.computeAdsorb(f,x,this.manualGuides());g={left:T.left,top:T.top},o.adsorbGuides=(T.lines??[]).filter(k=>k.position>=0&&k.position<=(k.type==="vertical"?S.width:S.height)),(g.left!==f.left||g.top!==f.top)&&this.flashSnapIndicator(g.left+f.width/2,g.top+f.height/2)}else o.adsorbGuides=[];const u=c?this.drag.origin.get(c.id):void 0,h=g&&u?g.left-u.left:s,A=g&&u?g.top-u.top:l;for(const x of this.drag.ids){const S=this.drag.origin.get(x);if(!S)continue;const T={left:S.left+h,top:S.top+A};this.drag.movedPositions.set(x,T),o.livePatch(x,T)}this.patchElementDom(),o.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:s,dy:l}=r(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=m.calcResizeRect(this.resize.point,this.resize.origin,s,l,3.5,3.5);o.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const e=!!this.drag,o=this.drag;if(o?.moved&&o.altKey){this.finishAltClone(o),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),e&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",e=>{const o=e.composedPath(),n=o.some(r=>r.classList?.contains("tb-dd"));this.state.openDd&&!n&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!n&&(this.state.openMore=!1,this.repaint());const i=o.some(r=>r.classList?.contains("context-menu"));this.menu.visible&&!i&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const n=e.target?.closest?.("[data-tip]");!n||!n.closest(".page-tabs")||(this.pageTipTimer&&clearTimeout(this.pageTipTimer),this.pageTipTimer=setTimeout(()=>this.showPageTip(n),300))}),this.root.addEventListener("mouseout",e=>{const o=e,n=o.target?.closest?.("[data-tip]");n&&o.relatedTarget?.closest?.("[data-tip]")!==n&&this.hidePageTip()})}showPageTip(e){const o=e.dataset.tip;if(!o)return;this.hidePageTip();const n=e.getBoundingClientRect(),i=Math.min(Math.max(n.left+n.width/2,80),window.innerWidth-80);this.pageTipEl=te(a("div",{class:"page-tabs-tip",style:{left:`${i}px`,top:`${n.bottom+6}px`},text:o}),this.root)}hidePageTip(){this.pageTipTimer&&(clearTimeout(this.pageTipTimer),this.pageTipTimer=null),this.pageTipEl?.remove(),this.pageTipEl=null}manualGuides(){const e=[],o=[];for(const n of this.store.templateData.guides??[])n.type==="vertical"?e.push(n.position):o.push(n.position);return{vertical:e,horizontal:o}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const n of Array.from(e.querySelectorAll(".adsorb-guide")))n.remove();const o=this.store.paperSize;xo(this.store.templateData,o);for(const n of this.store.adsorbGuides){const i=document.createElement("div");i.className=`adsorb-guide guide-${n.type}`,n.type==="vertical"?i.style.cssText=`left:${n.position}mm;top:0;height:${o.height}mm;border-left-color:${n.color||"var(--pd-accent-secondary, #f56c6c)"}`:i.style.cssText=`top:${n.position}mm;left:0;width:${o.width}mm;border-top-color:${n.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(i)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{we.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),we.active||(we.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null)}onGlobalKeydown(e){const o=this.store;if(!o||we.active!==this)return;const i=e.composedPath()[0]?.tagName;if(i==="INPUT"||i==="TEXTAREA"||i==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const s=e.shiftKey?10:e.ctrlKey?.5:1,l=e.key==="ArrowLeft"?-s:e.key==="ArrowRight"?s:0,c=e.key==="ArrowUp"?-s:e.key==="ArrowDown"?s:0;o.moveSelected(l,c);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),o.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const r=e.key.toLowerCase();Dl.has(r)&&(e.preventDefault(),r==="z"?e.shiftKey?o.redo():o.undo():r==="y"?o.redo():r==="a"?o.selectAll():r==="c"?o.copy():r==="x"?o.cutSelected():r==="v"?o.paste():r==="d"?o.duplicateSelected():r==="g"?e.shiftKey?o.ungroupSelected():o.groupSelected():r==="1"?o.resetZoom():r==="l"?o.alignSelected("left"):r==="r"?o.alignSelected("right"):r==="e"?o.alignSelected("vertical"):r==="t"?o.alignSelected("top"):r==="b"?o.alignSelected("bottom"):r==="0"&&this.fire("fit-window"))}}function Pi(t="print-designer"){return customElements.get(t)||customElements.define(t,we),t}function _l(){return Pi()}exports.DesignerStore=ui;exports.PrintDesignerElement=we;exports.TILING_SINGLE_PAGE_TIP=fo;exports.createDefaultTemplate=dt;exports.definePrintDesigner=Pi;exports.registerAll=_l;exports.serializePage=pi;exports.toRuntimePool=Eo;
758
+ `},to=[Sl,Tl,El,kl,Cl],Kn="worm-print-help-tab",Al="getting-started";function un(o){return to.some(e=>e.id===o)?String(o):""}function Dl(o){let e=null;try{e=window.localStorage.getItem(Kn)}catch{e=null}return un(e)||un(o)||Al}function Ml(o){const e=Dl(o.initialTab),t=(i,n)=>{const r=i.currentTarget,s=r.closest(".help-modal");if(!s)return;for(const c of Array.from(s.querySelectorAll(".help-tab")))c.classList.toggle("active",c===r);const l=s.querySelector(".help-content");l&&(l.innerHTML=to.find(c=>c.id===n)?.content??"");try{window.localStorage.setItem(Kn,n)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:i=>{i.target===i.currentTarget&&o.onClose()},onKeydown:i=>{i.key==="Escape"&&o.onClose()}},[a("div",{class:"help-modal"},[a("div",{class:"help-modal-header"},[a("div",{class:"help-modal-title-wrap"},[a("h2",{class:"help-modal-title",text:"帮助文档"}),a("span",{class:"help-modal-project",text:"worm-vue3-print"})]),a("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"help-modal-body"},[a("div",{class:"help-modal-sidebar"},to.map(i=>a("button",{type:"button",class:`help-tab${i.id===e?" active":""}`,text:i.title,onClick:n=>t(n,i.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:to.find(i=>i.id===e)?.content??""})])])])])}function _l(o,e){const t=fe(Ml(e),o),i=n=>{n.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",i),t.focus?.(),()=>{document.removeEventListener("keydown",i),t.remove()}}const Rl=2,zl=74,Yo=[{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 Pl(o){const e=!!o.state.openMore,t=Yo.slice().sort((i,n)=>i.order-n.order).map(i=>a("div",{class:"tb-more-item",dataset:{unit:i.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:i.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${i.id}`,dataset:{unit:i.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{o.state.openMore=!e,o.repaint()},html:`${ve("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ve("ChevronDown",12,"tb-dd-arrow")}`}),a("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[a("div",{class:"tb-menu tb-more-menu"},t)])])])}const hn=new WeakMap;function fn(o){const e=o.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const t=getComputedStyle(e),i=Number.parseFloat(t.gap)||Rl,n=Number.parseFloat(t.paddingLeft)||0,r=Number.parseFloat(t.paddingRight)||0,s=new Map;for(const w of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const T=w.parentElement;T&&!T.classList.contains("tb-more-slot")&&hn.set(w,{parent:T,next:w.nextSibling}),s.set(w.dataset.unit,w)}for(const w of s.values()){const T=hn.get(w);!T||w.parentElement===T.parent||(T.next?.parentElement===T.parent?T.parent.insertBefore(w,T.next):T.parent.appendChild(w))}let l=0;for(const w of Array.from(e.children)){if(w.classList.contains("tb-spacer")||w.classList.contains("tb-more-group"))continue;const T=Math.max(w.offsetWidth,w.scrollWidth);T<=0||(l+=T+i)}const c=new Map;for(const[w,T]of s){const k=T.offsetWidth;k>0&&c.set(w,k)}const u=Yo.map(w=>({id:w.id,order:w.order,width:c.get(w.id)??0})),h=u.reduce((w,T)=>w-T.width-i,l),m=e.clientWidth-n-r,{movedIds:g,overflowRemains:v}=p.resolveToolbarOverflow({available:m,pinned:h,moreTriggerWidth:zl,gap:i,units:u});for(const w of Yo){const T=e.querySelector(`.tb-more-item[data-unit="${w.id}"]`),k=e.querySelector(`#tb-more-slot-${w.id}`),z=s.get(w.id);if(!T||!k||!z)continue;const W=g.includes(w.id);W&&z.parentElement!==k&&k.appendChild(z),T.style.display=W?"":"none"}const b=e.querySelector(".tb-more-group");return b&&(b.style.display=g.length>0?"":"none"),e.classList.toggle("is-tight",v),{movedIds:g,overflowRemains:v}}function Fl(o,e){const t=o.store,i=t.selectedIds.size>0,n=t.selectedIds.size>1,r=t.selectedElement,s=!i,l=o.isEdit?"编辑模板":"新建模板",c=[a("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[a("div",{class:"tb-menu-label",text:"对齐 / 分布"}),a("div",{class:"tb-menu-grid"},[J(o,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!n}),J(o,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!n}),J(o,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!n}),J(o,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!n}),J(o,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!n}),J(o,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!n}),J(o,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!n}),J(o,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!n})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[J(o,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!i}),J(o,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!i}),J(o,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!i}),J(o,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!i})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[J(o,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!n}),J(o,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],u=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[h("标尺",t.showRuler,"toggle-ruler","显示/隐藏标尺"),h("网格",t.showGrid,"toggle-grid","显示/隐藏网格背景"),h("虚框",t.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),h("吸附",t.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function h(m,g,v,b){return a("button",{type:"button",class:`tb-btn tb-menu-row${g?" on":""}`,dataset:{tip:b},onClick:()=>o.fire(v)},[a("span",{class:"dot"}),m])}return a("div",{class:"designer-toolbar"},[a("div",{class:"tb-group tb-brand"},[a("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>'}),a("div",{class:"tb-title"},[a("span",{class:"tb-title-name",text:l}),a("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),a("div",{class:"tb-group"},[J(o,"Undo2","undo",{tip:"撤销",disabled:!t.canUndo}),J(o,"Redo2","redo",{tip:"重做",disabled:!t.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[no(o,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),no(o,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},u)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[J(o,"Maximize","fit-window",{tip:"适应窗口"}),J(o,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${t.scale}%`}),J(o,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[J(o,"Copy","copy",{tip:s?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:s,test:"copy"}),J(o,"ClipboardPaste","paste",{tip:s?"粘贴 (Ctrl+V),需选中元素":t.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:s||!t.hasClipboard,test:"paste"}),J(o,"Trash2","delete",{tip:s?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:s,danger:!0,test:"delete"})]),Pl(o),a("div",{class:"tb-spacer"}),o.showHelp?a("div",{class:"tb-group"},[a("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>o.fire("help")},[a("span",{class:"help-icon",text:"?"})])]):"",a("div",{class:"tb-group"},[a("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>o.fire("preview")}),a("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>o.fire("save")})])].filter(Boolean))}function Oo(o,e,t){for(const i of e){const n=o.getPropertyValue(i).trim();if(n)return n}return t}function Ll(o,e){const t=e.orientation==="horizontal",i=e.geom,n=t?i.viewW:i.viewH;o.style.width=`${t?n:p.RULER_THICKNESS}px`,o.style.height=`${t?p.RULER_THICKNESS:n}px`;const r=o.getContext("2d");if(!r)return;const s=window.devicePixelRatio||1,l=Math.max(0,Math.round(n)),c=p.RULER_THICKNESS;o.width=(t?l:c)*s,o.height=(t?c:l)*s,r.setTransform(s,0,0,s,0,0);const u=getComputedStyle(o),h=Oo(u,["--pd-ruler-bg"],"#F8F9FC"),m=Oo(u,["--pd-ruler"],"#9AA1AF"),g=Oo(u,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=h,r.fillRect(0,0,t?l:c,t?c:l);const v=e.scale>0?e.scale:i.paperScale>0?i.paperScale:1,b=p.mmToPx(1)*v;if(b<=0)return;const w={ctx:r,horizontal:t,viewportPx:n,thickness:c,originPx:t?i.originX:i.originY,pxPerMM:b,paperLengthMM:e.paperLengthMM},T=-w.originPx/b,k=(l-w.originPx)/b,z=p.chooseMajorStepMM(v),W=p.buildRulerTicks(T,k,z);mn(w,W,m,!0),mn(w,W,m,!1),gn(w,0,g),gn(w,e.paperLengthMM,g);const P=e.cursorPx??null;if(P!==null&&P>=0&&P<=l){if(r.strokeStyle=g,r.lineWidth=1.5,r.beginPath(),t){const ne=Math.round(P)+.5;r.moveTo(ne,0),r.lineTo(ne,c)}else{const ne=Math.round(P)+.5;r.moveTo(0,ne),r.lineTo(c,ne)}r.stroke()}}function jn(o,e){return Math.round(o.originPx+e*o.pxPerMM)+.5}function mn(o,e,t,i){const{ctx:n,horizontal:r,paperLengthMM:s}=o;n.strokeStyle=t,n.fillStyle=t,n.globalAlpha=i?.32:1,n.lineWidth=1,n.font="9px ui-monospace, Menlo, monospace",n.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>s)!==i)continue;const u=jn(o,l.mm),h=l.major?8:4;n.beginPath(),r?(n.moveTo(u,0),n.lineTo(u,h)):(n.moveTo(0,u),n.lineTo(h,u)),n.stroke(),l.major&&l.label&&(r?n.fillText(l.label,u+2,11):(n.save(),n.translate(11,u+2),n.rotate(-Math.PI/2),n.fillText(l.label,0,0),n.restore()))}n.globalAlpha=1}function gn(o,e,t){const{ctx:i,horizontal:n,thickness:r,viewportPx:s}=o,l=jn(o,e);l<=0||l>=s||(i.strokeStyle=t,i.globalAlpha=.55,i.lineWidth=1,i.beginPath(),n?(i.moveTo(l,0),i.lineTo(l,r)):(i.moveTo(0,l),i.lineTo(r,l)),i.stroke(),i.globalAlpha=1)}const Il=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Jt=20,Ol=".page-tabs, .field-tree-panel",Nl=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),$l={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},bn="print-studio:left",xn="print-studio:right";function vn(o){try{return localStorage.getItem(o)==="1"}catch{return!1}}function yn(o,e){try{localStorage.setItem(o,e?"1":"0")}catch{}}class Oe extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Il,this.root.appendChild(e),fe(a("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(e){this.applyTemplate(e)}get template(){return this.store?.getTemplateJson()}set fields(e){this.store.fields=(typeof e=="string"?JSON.parse(e):e)??[],this.repaint()}set isEdit(e){this.setAttribute("is-edit",String(e)),this.repaint()}set showHelp(e){this.setAttribute("show-help",String(e)),e||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(e,t,i){if(!i)return;if(e==="name"){this.repaint();return}let n;try{n=JSON.parse(i)}catch{return}e==="template"?this.applyTemplate(n):e==="fields"?(this.store.fields=n,this.repaint()):e==="fonts"&&Array.isArray(n)&&(this.fonts=n)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},t=this.getAttribute("template");if(t)try{e.initialTemplate=JSON.parse(t)}catch{}const i=this.getAttribute("fields");if(i)try{e.initialFields=JSON.parse(i)}catch{}this.store=new kn(e),this.format=new xr(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=vn(bn),this.state.propCollapsed=vn(xn),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const e=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;e!==this.chromeKey&&(this.chromeKey=e,yn(bn,this.state.leftCollapsed),yn(xn,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Oe.active===this&&(Oe.active=null),On(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=A.buildFontFaceCss(this._fonts);if(!e){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=e,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=e}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),t=this.fonts;if(!t?.length)return e;if(Array.isArray(e.pages)){const i=e;return{...i,pages:i.pages.map(n=>({...n,fonts:[...t]}))}}return{...e,fonts:[...t]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const t=this.getGeometryWarnings();t.length&&window.alert(`出纸提示(不影响保存):
759
+ ${t.join(`
760
+ `)}`);const i=this.templateJsonWithFonts();if(Array.isArray(i.pages))try{A.normalizeTemplate(i)}catch(r){window.alert(r instanceof Error?r.message:String(r));return}const n=JSON.stringify(i);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?A.validateTiling(e):[]}getGeometryWarnings(){return A.collectPrintWarnings(this.store.templateData)}applyTemplate(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(t):this.setAttribute("template",JSON.stringify(t))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(i=>i.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(i=>i.remove());const t=this.exprTarget;fe(wl({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:i=>this.applyExpression(t,i)},t),this.root),this.exprMountedFor=t}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const e=this.helpVisible&&this.getAttribute("show-help")!=="false";if(e&&!this.unmountHelp)this.unmountHelp=_l(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const t=this.unmountHelp;this.unmountHelp=null,t()}}applyExpression(e,t){const i=t.formatter??"",n=e.targetPath;if(n.startsWith("options.")){if(n.includes("[")){const s=this.store.elements.find(l=>l.id===e.elementId);s&&si(this.store,s,n,i);return}const r={[n.slice(8)]:i||void 0};t.title!==void 0&&(r.title=t.title),this.store.updateElement(e.elementId,r);return}if(n==="watermark.content"){const r={...this.store.templateData.watermark};Ko(i)?Object.assign(r,{mode:"binding",binding:i,content:""}):Object.assign(r,{mode:"fixed",content:i,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const t=this.store.elements.find(n=>n.id===e);if(!t||(this.store.selectOne(e),this.state.propTab="element",t.options.locked))return;const i=$l[t.printElementType.type];i&&this.openExpression({elementId:t.id,targetPath:`options.${i}`,value:String(t.options[i]??"")})}dblEditCell(e){const t=this.store.elements.find(l=>l.id===e.elementId);if(!t||(this.store.selectOne(t.id),this.state.propTab="element",t.options.locked))return;const i=t.options.tableRows??[],n=p.findMainCell(i,e.r,e.c),s=i[n.r]?.cells[n.c];s&&this.openExpression({elementId:t.id,targetPath:`options.tableRows[${n.r}].cells[${n.c}].formatter`,value:s.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(e,t)=>this.fire(e,t),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const e=[...this.store.selectedIds].join(",");e!==this.lastSelKey&&(this.lastSelKey=e,this.state.propTab=e?"element":"page");const t=this.root.querySelector(".designer-container");t.classList.toggle("format-painting",this.format.painterActive),Tn(t);const i=this.ctx;fe(Fl(i,Ts(i)),t),fe(_s(i),t),fe(a("div",{class:"designer-body"},[Cs(i),ns(i,this.canvasUi()),cl(i)]),t),fe(Rs(i),t),fn(t),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>fn(t)),this.toolbarRo.observe(t));const n=Fa(this.store,(r,s)=>this.fire(r,s),this.tableMenu);n&&fe(n,t),sa(this.root,this.store.elements),Wn(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Vo.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const t=e.getAttribute("data-fit-base");t?e.style.fontSize=`${t}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),t=this.root.querySelector(".hiprint-printPaper");if(!e||!t)return;const i=e.getBoundingClientRect(),n=t.getBoundingClientRect(),r=(this.store.scale||100)/100,s=n.width/p.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(s-r)<.002?r:s,originX:n.left-i.left-Jt+this.scrollPos.x,originY:n.top-i.top-Jt+this.scrollPos.y,viewW:e.clientWidth-Jt,viewH:e.clientHeight-Jt},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,t=p.getPaperDimensions(e),i=this.geom.paperScale;for(const n of Array.from(this.root.querySelectorAll(".pd-ruler"))){const r=n.dataset.ruler==="vertical"?"vertical":"horizontal";Ll(n,{orientation:r,geom:this.geom,scale:i,paperLengthMM:r==="horizontal"?t.width:t.height})}}patchElementDom(){for(const i of this.store.elements){const n=this.root.querySelector(`[data-el-id="${CSS.escape(i.id)}"]`);n&&(n.style.left=`${i.options.left}mm`,n.style.top=`${i.options.top}mm`,n.style.width=`${i.options.width}mm`,n.style.height=`${i.options.height}mm`)}const e=this.root.querySelector(".position-label"),t=this.store.selectedElement;e&&t&&!this.drag&&(e.textContent=Nn(t.options))}fire(e,t){const i=this.store;switch(e){case"undo":i.undo();break;case"redo":i.redo();break;case"align":i.alignSelected(t);break;case"move-layer":i.moveLayer(t);break;case"group":i.groupSelected();break;case"ungroup":i.ungroupSelected();break;case"copy":i.copy();break;case"cut":i.cutSelected();break;case"paste":i.paste();break;case"paste-at":i.paste();break;case"delete":i.deleteSelected();break;case"delete-page":i.deletePage(i.activePageIndex);break;case"add-page":i.addPage();break;case"duplicate-page":i.duplicatePage(i.activePageIndex);break;case"move-page":i.movePage(i.activePageIndex,i.activePageIndex+t);break;case"select-all":i.selectAll();break;case"clear-selection":i.clearSelection();break;case"toggle-ruler":i.showRuler=!i.showRuler,this.repaint();break;case"toggle-grid":i.showGrid=!i.showGrid,this.repaint();break;case"toggle-snap":i.snapToGrid=!i.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":i.showTableGhostBorder=!i.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(t>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":i.removeGuide(t);break;case"resize-start":this.beginResize(t);break;case"element-mousedown":{const n=t;n.event.button===0&&this.isDoubleTap(`el:${n.id}`,n.event)&&this.fire("element-dblclick",{event:n.event,id:n.id}),this.beginDrag(n);break}case"table-cell-mousedown":{const n=t;this.isDoubleTap(`cell:${n.elementId}:${n.r}:${n.c}`,n.event)&&(this.taps.delete(`el:${n.elementId}`),this.fire("table-cell-dblclick",{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId}));break}case"zone-resize":this.beginZoneResize(t);break;case"guide-mousedown":this.beginGuideDrag(t);break;case"ruler-mousedown":this.beginRulerGuide(t);break;case"canvas-mousedown":this.onCanvasMouseDown(t);break;case"canvas-mousemove":this.onCanvasMouseMove(t);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(t);break;case"contextmenu":this.onElementContextMenu(t);break;case"element-dblclick":{const{id:n}=t;this.dblEditElement(n),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:n,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const n=t;this.dblEditCell(n),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(t);break;case"drop":this.onDrop(t);break;case"wheel":this.onWheel(t);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const t=e.dataTransfer,i=t?.getData("elementType"),n=t?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const s={x:r.left,y:r.top};if(i)this.store.addElement(i,{},s);else if(n){const l=this.store.fields.find(c=>c.fieldKey===n);l&&this.store.addFieldElement(l,{},s)}}pointToPaperMm(e){const t=this.root.querySelector(".hiprint-printPaper");if(!t)return null;const i=t.getBoundingClientRect(),n=(this.store.scale||100)/100,r=p.pxToMm((e.clientX-i.left)/n),s=p.pxToMm((e.clientY-i.top)/n);return r<0||s<0?null:{left:r,top:s}}onCanvasMouseDown(e){const t=e.target;(t===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(n=>t.classList.contains(n)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const t=this.pointToPaperMm(e),i=this.root.querySelector("[data-coord]");if(i){if(!t){i.style.display="none";return}i.style.display="",i.textContent=`x:${(t.left-this.store.templateData.margins.left).toFixed(1)} y:${(t.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,t){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=t,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const i=this.root.querySelector(".context-menu");if(!i)return;const n=i.getBoundingClientRect();this.menu.flipX=n.right>window.innerWidth?window.innerWidth-n.right-8:0,this.menu.flipY=n.bottom>window.innerHeight?window.innerHeight-n.bottom-8:0,this.paint()})}startMarquee(e){const t={x:e.clientX,y:e.clientY},i=r=>{this.marquee={visible:!0,x:Math.min(t.x,r.clientX),y:Math.min(t.y,r.clientY),w:Math.abs(r.clientX-t.x),h:Math.abs(r.clientY-t.y)},this.paint()},n=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const s=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const u=c.getBoundingClientRect();return u.left<r.x+r.w&&u.right>r.x&&u.top<r.y+r.h&&u.bottom>r.y});this.store.select(new Set(s.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}taps=new Map;isDoubleTap(e,t){const i=this.taps.get(e);return this.taps.set(e,{t:t.timeStamp,x:t.clientX,y:t.clientY}),!i||t.timeStamp-i.t>=500||Math.abs(t.clientX-i.x)>6||Math.abs(t.clientY-i.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const t=e.event;if(t.button!==0)return;const i=this.store;t.stopPropagation();const n=i.elements.find(l=>l.id===e.id);if(!n||(i.selectElement(n.id,t.ctrlKey||t.metaKey),n.options.locked))return;const r=t.altKey?[n.id]:i.dragIds(n.id),s=new Map;for(const l of r){const c=i.elements.find(u=>u.id===l);c&&s.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:r,primary:n.id,altKey:t.altKey,movedPositions:new Map,startX:t.clientX,startY:t.clientY,origin:s,zone:n.zone||"content",moved:!1},i.draggingIds=new Set(r),i.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const t of Array.from(this.root.querySelectorAll(".print-element"))){const i=e.has(t.dataset.elId??"");t.classList.toggle("drag-ghost",i);const n=t.querySelector(":scope > .drag-preview");i&&!n?fe(a("div",{class:"drag-preview"}),t):!i&&n&&n.remove()}}finishAltClone(e){const t=this.store;t.adsorbGuides=[];const i=t.elements.find(s=>s.id===e.primary),n=e.movedPositions.get(e.primary);if(t.discardLive(),!i||!n)return;const r=JSON.parse(JSON.stringify(i));r.id=p.generateId(),r.options.left=n.left,r.options.top=n.top,r.options.groupId=void 0,t.cloneElement(r)}flashSnapIndicator(e,t){const i=this.root.querySelector(".hiprint-printPaper-content");i&&(i.querySelector(".snap-indicator")?.remove(),fe(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${t}mm`}}),i),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{i.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const t=e.event;t.stopPropagation();const i=this.store.elements.find(n=>n.id===e.id);!i||i.options.locked||(this.resize={id:e.id,point:e.point,startX:t.clientX,startY:t.clientY,origin:{left:i.options.left,top:i.options.top,width:i.options.width,height:i.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const t=e.event.clientY,i=this.store.templateData,n=e.zone==="header"?i.header.height:i.footer.height,r=(this.store.scale||100)/100,s=c=>{const u=p.pxToMm((c.clientY-t)/r),h=Math.max(0,Math.round((n+(e.zone==="header"?u:-u))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...i.header,height:h}}):this.store.updateTemplateData({footer:{...i.footer,height:h}}),this.paint()},l=()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",s),window.addEventListener("mouseup",l)}beginGuideDrag(e){const t=(this.store.templateData.guides??[]).find(h=>h.id===e.id);if(!t)return;const i=p.getPaperDimensions(this.store.templateData),n=t.type==="vertical"?i.width:i.height,r=e.event.clientX,s=e.event.clientY,l=(this.store.scale||100)/100,c=h=>{const m=p.pxToMm((t.type==="vertical"?h.clientX-r:h.clientY-s)/l);this.store.moveGuide(t.id,Math.min(n,Math.max(0,t.position+m))),this.paint()},u=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",u),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",u)}beginRulerGuide(e){const t=e.orientation==="horizontal"?"vertical":"horizontal",i=r=>{this.guidePreview={type:t,position:t==="vertical"?r.clientX:r.clientY},this.paint()},n=r=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const s=this.rulerPointToMM(r,t);this.guidePreview=null,s!==null?this.store.addGuide(t,s):this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}rulerPointToMM(e,t){const i=this.root.querySelector(".hiprint-printPaper");if(!i)return null;const n=i.getBoundingClientRect(),r=p.mmToPx(1)*(this.geom.paperScale||1),s=t==="vertical"?(e.clientX-n.left)/r:(e.clientY-n.top)/r,l=p.getPaperDimensions(this.store.templateData),c=t==="vertical"?l.width:l.height;return s<0||s>c?null:s}applyZoom(e,t,i,n){const r=this.root.querySelector(".canvas-area");if(!r)return;const s=Math.round(this.store.scale),l=Math.max(n,Math.round(e));if(l===s)return;const c=getComputedStyle(r),u=parseFloat(c.paddingLeft)||0,h=parseFloat(c.paddingTop)||0,m=r.scrollLeft+t-u,g=r.scrollTop+i-h,v=l/s;this.store.setScale(l,n),r.scrollLeft=m*v-t+u,r.scrollTop=g*v-i+h}zoomByStep(e){const t=this.root.querySelector(".canvas-area");t&&this.applyZoom(p.nextWheelScale(this.store.scale,e),t.clientWidth/2,t.clientHeight/2,p.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const t=getComputedStyle(e),i=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0),n=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0),r=p.getPaperDimensions(this.store.templateData),s=p.computeFitScale(e.clientWidth-i,e.clientHeight-n,p.mmToPx(r.width),p.mmToPx(r.height));this.applyZoom(s,e.clientWidth/2,e.clientHeight/2,p.FIT_SCALE_MIN_PERCENT)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=this.root.querySelector(".canvas-area");if(!t)return;const i=Math.round(this.store.scale),n=p.nextWheelScale(i,e.deltaY>0?-1:1);if(n===i)return;const r=t.getBoundingClientRect();this.applyZoom(n,e.clientX-r.left,e.clientY-r.top,p.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const t=this.store;if(!t)return;const n=((t.scale||100)/100||1)*p.mmToPx(1),r=(s,l)=>({dx:s/n,dy:l/n});if(this.drag){const{dx:s,dy:l}=r(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(s)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=t.elements.find(b=>b.id===this.drag.primary),u=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+s,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let h=null;if(u&&t.snapToGrid!==!1){const b=t.elements.filter(k=>!this.drag.ids.includes(k.id)&&(k.zone||"content")===this.drag.zone).map(k=>({id:k.id,left:k.options.left,top:k.options.top,width:k.options.width,height:k.options.height})),w=Uo(t.templateData,t.paperSize)[this.drag.zone],T=p.computeAdsorb(u,b,this.manualGuides());h={left:T.left,top:T.top},t.adsorbGuides=(T.lines??[]).filter(k=>k.position>=0&&k.position<=(k.type==="vertical"?w.width:w.height)),(h.left!==u.left||h.top!==u.top)&&this.flashSnapIndicator(h.left+u.width/2,h.top+u.height/2)}else t.adsorbGuides=[];const m=c?this.drag.origin.get(c.id):void 0,g=h&&m?h.left-m.left:s,v=h&&m?h.top-m.top:l;for(const b of this.drag.ids){const w=this.drag.origin.get(b);if(!w)continue;const T={left:w.left+g,top:w.top+v};this.drag.movedPositions.set(b,T),t.livePatch(b,T)}this.patchElementDom(),t.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:s,dy:l}=r(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=p.calcResizeRect(this.resize.point,this.resize.origin,s,l,3.5,3.5);t.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const e=!!this.drag,t=this.drag;if(t?.moved&&t.altKey){this.finishAltClone(t),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),e&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",e=>{const t=e.composedPath(),i=t.some(r=>r.classList?.contains("tb-dd"));this.state.openDd&&!i&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!i&&(this.state.openMore=!1,this.repaint());const n=t.some(r=>r.classList?.contains("context-menu"));this.menu.visible&&!n&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const i=e.target?.closest?.("[data-tip]");!i||!i.closest(Ol)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(i),300))}),this.root.addEventListener("mouseout",e=>{const t=e,i=t.target?.closest?.("[data-tip]");i&&t.relatedTarget?.closest?.("[data-tip]")!==i&&this.hideHoverTip()})}showHoverTip(e){const t=e.dataset.tip;if(!t)return;this.hideHoverTip();const i=e.getBoundingClientRect(),n=i.left+i.width/2;this.hoverTipEl=fe(a("div",{class:"pd-hover-tip",style:{left:`${n}px`,top:`${i.bottom+6}px`},text:t}),this.root);const r=this.hoverTipEl.offsetWidth/2;if(!r)return;const s=r+8,l=Math.max(window.innerWidth-r-8,s);this.hoverTipEl.style.left=`${Math.min(Math.max(n,s),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const e=[],t=[];for(const i of this.store.templateData.guides??[])i.type==="vertical"?e.push(i.position):t.push(i.position);return{vertical:e,horizontal:t}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const i of Array.from(e.querySelectorAll(".adsorb-guide")))i.remove();const t=this.store.paperSize;Uo(this.store.templateData,t);for(const i of this.store.adsorbGuides){const n=document.createElement("div");n.className=`adsorb-guide guide-${i.type}`,i.type==="vertical"?n.style.cssText=`left:${i.position}mm;top:0;height:${t.height}mm;border-left-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`:n.style.cssText=`top:${i.position}mm;left:0;width:${t.width}mm;border-top-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(n)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{Oe.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),Oe.active||(Oe.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null)}onGlobalKeydown(e){const t=this.store;if(!t||Oe.active!==this)return;const n=e.composedPath()[0]?.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const s=e.shiftKey?10:e.ctrlKey?.5:1,l=e.key==="ArrowLeft"?-s:e.key==="ArrowRight"?s:0,c=e.key==="ArrowUp"?-s:e.key==="ArrowDown"?s:0;t.moveSelected(l,c);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),t.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const r=e.key.toLowerCase();Nl.has(r)&&(e.preventDefault(),r==="z"?e.shiftKey?t.redo():t.undo():r==="y"?t.redo():r==="a"?t.selectAll():r==="c"?t.copy():r==="x"?t.cutSelected():r==="v"?t.paste():r==="d"?t.duplicateSelected():r==="g"?e.shiftKey?t.ungroupSelected():t.groupSelected():r==="1"?t.resetZoom():r==="l"?t.alignSelected("left"):r==="r"?t.alignSelected("right"):r==="e"?t.alignSelected("vertical"):r==="t"?t.alignSelected("top"):r==="b"?t.alignSelected("bottom"):r==="0"&&this.fire("fit-window"))}}function Yn(o="print-designer"){return customElements.get(o)||customElements.define(o,Oe),o}function Bl(){return Yn()}exports.DesignerStore=kn;exports.PrintDesignerElement=Oe;exports.TILING_SINGLE_PAGE_TIP=No;exports.createDefaultTemplate=Rt;exports.definePrintDesigner=Yn;exports.registerAll=Bl;exports.serializePage=En;exports.toRuntimePool=Xo;