@worm-vue3-print/common 0.0.0-stage → 1.3.7-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +99 -2
- package/dist/browser-bundle.d.ts +12 -0
- package/dist/common.css +462 -0
- package/dist/common.js +910 -0
- package/dist/core/default-template.d.ts +9 -0
- package/dist/core/font-catalog.d.ts +30 -0
- package/dist/core/format.d.ts +102 -0
- package/dist/core/h.d.ts +22 -0
- package/dist/core/icons.d.ts +10 -0
- package/dist/core/store.d.ts +163 -0
- package/dist/index.cjs +657 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7058 -0
- package/dist/print-designer.d.ts +182 -0
- package/dist/shell/binding.d.ts +21 -0
- package/dist/shell/canvas.d.ts +59 -0
- package/dist/shell/code.d.ts +11 -0
- package/dist/shell/color-picker.d.ts +44 -0
- package/dist/shell/controls.d.ts +101 -0
- package/dist/shell/elements.d.ts +27 -0
- package/dist/shell/expression-editor.d.ts +33 -0
- package/dist/shell/font-select.d.ts +24 -0
- package/dist/shell/format-bar.d.ts +15 -0
- package/dist/shell/help-content/changelog.d.ts +12 -0
- package/dist/shell/help-content/faq.d.ts +12 -0
- package/dist/shell/help-content/features.d.ts +12 -0
- package/dist/shell/help-content/getting-started.d.ts +12 -0
- package/dist/shell/help-content/index.d.ts +13 -0
- package/dist/shell/help-content/shortcuts.d.ts +12 -0
- package/dist/shell/help-modal.d.ts +19 -0
- package/dist/shell/page-extras.d.ts +10 -0
- package/dist/shell/panels.d.ts +17 -0
- package/dist/shell/prop-group.d.ts +11 -0
- package/dist/shell/property-panel.d.ts +14 -0
- package/dist/shell/property-search.d.ts +32 -0
- package/dist/shell/ruler.d.ts +29 -0
- package/dist/shell/table-props.d.ts +17 -0
- package/dist/shell/table.d.ts +22 -0
- package/dist/shell/toolbar-overflow.d.ts +28 -0
- package/dist/shell/toolbar.d.ts +8 -0
- package/dist/shell/watermark.d.ts +10 -0
- package/package.json +57 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,657 @@
|
|
|
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"&<()},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:`
|
|
4
|
+
<h2>界面布局</h2>
|
|
5
|
+
<p>打印模板设计器采用三栏布局:</p>
|
|
6
|
+
<ul>
|
|
7
|
+
<li><strong>左侧面板</strong>:字段树和图层管理,用于查看和管理画布上的元素</li>
|
|
8
|
+
<li><strong>中间画布</strong>:设计区域,支持标尺、参考线、网格显示</li>
|
|
9
|
+
<li><strong>右侧面板</strong>:属性设置和模板配置</li>
|
|
10
|
+
<li><strong>顶部工具栏</strong>:常用操作按钮</li>
|
|
11
|
+
<li><strong>底部状态栏</strong>:显示坐标、缩放比例、元素数量</li>
|
|
12
|
+
</ul>
|
|
13
|
+
|
|
14
|
+
<h2>添加第一个元素</h2>
|
|
15
|
+
<ol>
|
|
16
|
+
<li>从左侧面板选择元素类型(文本、图片、条码等)</li>
|
|
17
|
+
<li>拖拽到画布上松开</li>
|
|
18
|
+
<li>选中元素后,通过拖拽调整位置</li>
|
|
19
|
+
<li>拖拽元素边角手柄调整大小</li>
|
|
20
|
+
</ol>
|
|
21
|
+
|
|
22
|
+
<h2>数据绑定基础</h2>
|
|
23
|
+
<p>使用花括号 <code>{field.path}</code> 语法绑定数据字段:</p>
|
|
24
|
+
<pre><code>供应商:{supplier.name}
|
|
25
|
+
日期:{order.date}
|
|
26
|
+
金额:{MONEY(order.total)}
|
|
27
|
+
合计:{ROUND(qty * price, 2)}</code></pre>
|
|
28
|
+
<p>花括号内可直接写四则运算(<code>{qty * price}</code>),也可用 <code>ADD</code> / <code>SUB</code> / <code>MUL</code> / <code>DIV</code> 函数;
|
|
29
|
+
需要保留几位小数时用 <code>ROUND</code>(四舍五入)、<code>ROUNDUP</code>(进一)、<code>ROUNDDOWN</code>(去尾)或 <code>ROUNDBANK</code>(四舍六入五成双)。</p>
|
|
30
|
+
<p>双击元素可打开表达式编辑器配置绑定。</p>
|
|
31
|
+
|
|
32
|
+
<h2>保存与预览</h2>
|
|
33
|
+
<ul>
|
|
34
|
+
<li>点击工具栏"保存"按钮,模板以 JSON 格式导出</li>
|
|
35
|
+
<li>点击"预览"按钮查看打印效果</li>
|
|
36
|
+
<li>模板数据包含页面设置、元素定义、样式配置</li>
|
|
37
|
+
</ul>
|
|
38
|
+
|
|
39
|
+
<h2>关于项目</h2>
|
|
40
|
+
<p><strong>项目名称:</strong>worm-vue3-print</p>
|
|
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
|
+
<p>基于 Vue 3 的可视化打印模板设计器,支持拖拽式模板编辑、表达式数据绑定和浏览器端打印预览。</p>
|
|
43
|
+
`},fl={id:"features",title:"功能说明",content:`
|
|
44
|
+
<h2>元素类型</h2>
|
|
45
|
+
<table>
|
|
46
|
+
<thead>
|
|
47
|
+
<tr><th>类型</th><th>说明</th></tr>
|
|
48
|
+
</thead>
|
|
49
|
+
<tbody>
|
|
50
|
+
<tr><td>文本</td><td>静态或动态文本,支持表达式绑定</td></tr>
|
|
51
|
+
<tr><td>长文本</td><td>多行文本,支持自动换行</td></tr>
|
|
52
|
+
<tr><td>数据表格</td><td>动态行列,支持分页、表头重复、序号/小计/汇总</td></tr>
|
|
53
|
+
<tr><td>条形码</td><td>支持 code128 等多种码制</td></tr>
|
|
54
|
+
<tr><td>二维码</td><td>支持 L/M/Q/H 纠错级别;「静区 (模块)」控制四周白边(0~8,默认 0=码面等比铺满元素框),需 ISO 推荐静区时填 4</td></tr>
|
|
55
|
+
<tr><td>图片</td><td>静态或动态图片</td></tr>
|
|
56
|
+
<tr><td>线条</td><td>水平线或垂直线</td></tr>
|
|
57
|
+
<tr><td>形状</td><td>矩形、椭圆,支持边框和背景色</td></tr>
|
|
58
|
+
<tr><td>HTML</td><td>自定义 HTML 内容</td></tr>
|
|
59
|
+
<tr><td>页码</td><td>自动页码显示</td></tr>
|
|
60
|
+
</tbody>
|
|
61
|
+
</table>
|
|
62
|
+
|
|
63
|
+
<h2>表达式编辑器</h2>
|
|
64
|
+
<h3>基础语法</h3>
|
|
65
|
+
<p>使用花括号 <code>{}</code> 包裹表达式,花括号外为字面文本。</p>
|
|
66
|
+
|
|
67
|
+
<h3>内置函数</h3>
|
|
68
|
+
<table>
|
|
69
|
+
<thead>
|
|
70
|
+
<tr><th>函数</th><th>说明</th><th>示例</th></tr>
|
|
71
|
+
</thead>
|
|
72
|
+
<tbody>
|
|
73
|
+
<tr><td><code>MONEY(value)</code></td><td>金额格式化(千分位+两位小数)</td><td><code>{MONEY(order.total)}</code> -> "69,543.75"</td></tr>
|
|
74
|
+
<tr><td><code>DATE(value, format)</code></td><td>日期格式化</td><td><code>{DATE(order.date, 'YYYY-MM-DD')}</code></td></tr>
|
|
75
|
+
<tr><td><code>UPPER(value)</code></td><td>数字转大写金额</td><td><code>{UPPER(order.total)}</code> -> "陆万玖仟伍佰肆拾叁元柒角伍分"</td></tr>
|
|
76
|
+
<tr><td><code>IF(cond, true, false)</code></td><td>条件判断</td><td><code>{IF(qty > 100, '大量', '少量')}</code></td></tr>
|
|
77
|
+
<tr><td><code>CONCAT(str1, str2, ...)</code></td><td>字符串拼接</td><td><code>{CONCAT(name, '-', spec)}</code></td></tr>
|
|
78
|
+
<tr><td><code>IFEMPTY(value, default)</code></td><td>空值默认</td><td><code>{IFEMPTY(remark, '无')}</code></td></tr>
|
|
79
|
+
<tr><td><code>ROUND(num, decimals)</code></td><td>四舍五入(位数缺省 2)</td><td><code>{ROUND(price, 2)}</code></td></tr>
|
|
80
|
+
<tr><td><code>ROUNDUP(n, d)</code> / <code>CEIL(n, d)</code></td><td>进一法(远离零)</td><td><code>{ROUNDUP(price, 2)}</code></td></tr>
|
|
81
|
+
<tr><td><code>ROUNDDOWN(n, d)</code> / <code>FLOOR(n, d)</code></td><td>去尾法(朝零)</td><td><code>{ROUNDDOWN(price, 2)}</code></td></tr>
|
|
82
|
+
<tr><td><code>ROUNDBANK(n, d)</code></td><td>四舍六入五成双(GB/T 8170)</td><td><code>{ROUNDBANK(price, 2)}</code></td></tr>
|
|
83
|
+
<tr><td><code>ADD(a, b, ...)</code></td><td>相加(变参)</td><td><code>{ADD(qty, 1)}</code></td></tr>
|
|
84
|
+
<tr><td><code>SUB(a, b, ...)</code></td><td>相减</td><td><code>{SUB(total, discount)}</code></td></tr>
|
|
85
|
+
<tr><td><code>MUL(a, b, ...)</code></td><td>相乘(变参)</td><td><code>{MUL(qty, price)}</code></td></tr>
|
|
86
|
+
<tr><td><code>DIV(a, b)</code></td><td>相除(除数为 0 返回 0)</td><td><code>{DIV(total, qty)}</code></td></tr>
|
|
87
|
+
<tr><td><code>NOW()</code></td><td>当前日期</td><td><code>{NOW()}</code></td></tr>
|
|
88
|
+
<tr><td><code>SUBSTR(str, start, len)</code></td><td>子字符串</td><td><code>{SUBSTR(name, 0, 3)}</code></td></tr>
|
|
89
|
+
<tr><td><code>LEN(str)</code></td><td>字符串长度</td><td><code>{LEN(name)}</code></td></tr>
|
|
90
|
+
<tr><td><code>PAD(value, len, char)</code></td><td>左侧补位</td><td><code>{PAD(qty, 5, '0')}</code></td></tr>
|
|
91
|
+
</tbody>
|
|
92
|
+
</table>
|
|
93
|
+
|
|
94
|
+
<h3>聚合函数(表格小计/汇总行使用)</h3>
|
|
95
|
+
<table>
|
|
96
|
+
<thead>
|
|
97
|
+
<tr><th>函数</th><th>说明</th></tr>
|
|
98
|
+
</thead>
|
|
99
|
+
<tbody>
|
|
100
|
+
<tr><td><code>SUM(field)</code></td><td>求和</td></tr>
|
|
101
|
+
<tr><td><code>AVG(field)</code></td><td>平均值</td></tr>
|
|
102
|
+
<tr><td><code>COUNT(field)</code></td><td>计数</td></tr>
|
|
103
|
+
<tr><td><code>MIN(field)</code></td><td>最小值</td></tr>
|
|
104
|
+
<tr><td><code>MAX(field)</code></td><td>最大值</td></tr>
|
|
105
|
+
</tbody>
|
|
106
|
+
</table>
|
|
107
|
+
|
|
108
|
+
<h3>系统变量</h3>
|
|
109
|
+
<table>
|
|
110
|
+
<thead>
|
|
111
|
+
<tr><th>变量</th><th>说明</th></tr>
|
|
112
|
+
</thead>
|
|
113
|
+
<tbody>
|
|
114
|
+
<tr><td><code>pageIndex</code></td><td>当前页码</td></tr>
|
|
115
|
+
<tr><td><code>totalPages</code></td><td>总页数</td></tr>
|
|
116
|
+
<tr><td><code>printDate</code></td><td>打印日期 (YYYY-MM-DD)</td></tr>
|
|
117
|
+
<tr><td><code>printTime</code></td><td>打印时间戳</td></tr>
|
|
118
|
+
</tbody>
|
|
119
|
+
</table>
|
|
120
|
+
|
|
121
|
+
<h2>数据表格配置</h2>
|
|
122
|
+
<h3>行类型</h3>
|
|
123
|
+
<ul>
|
|
124
|
+
<li><strong>标题行 (header)</strong>:可设置每页重复显示</li>
|
|
125
|
+
<li><strong>数据行 (data)</strong>:绑定列表数据源迭代显示</li>
|
|
126
|
+
<li><strong>小计行 (subtotal)</strong>:当前页末尾显示汇总</li>
|
|
127
|
+
<li><strong>汇总行 (summary)</strong>:仅最后一页显示</li>
|
|
128
|
+
</ul>
|
|
129
|
+
|
|
130
|
+
<h3>表格操作</h3>
|
|
131
|
+
<ul>
|
|
132
|
+
<li>在单元格上右键即可打开表格菜单(无需先选中表格,右键时会自动选中该表格),支持插入/删除行和列、合并/拆分单元格、切换行类型</li>
|
|
133
|
+
<li>拖选多个单元格后可合并;合并后在任一成员单元格上右键可拆分</li>
|
|
134
|
+
<li>支持单元格合并/拆分</li>
|
|
135
|
+
<li>支持边框预设:全部/外边框/内边框/无</li>
|
|
136
|
+
<li>无边框表格设计态显示虚拟虚线</li>
|
|
137
|
+
<li><strong>调整列宽</strong>:需要先在左侧面板的图层中选中对应的表格元素,然后才能在画布上拖动列宽分隔线</li>
|
|
138
|
+
<li><strong>调整表格属性</strong>:必须确保当前没有任何单元格被选中。如有选中的单元格,先点击画布空白区域取消选中,再在图层中选择表格元素</li>
|
|
139
|
+
<li><strong>单元格图片处理</strong>:若单元格中图片无法缩小,请将图片处理方式设置为"缩小保持比例"</li>
|
|
140
|
+
</ul>
|
|
141
|
+
|
|
142
|
+
<h2>格式工具栏与格式刷</h2>
|
|
143
|
+
<h3>格式工具栏</h3>
|
|
144
|
+
<ul>
|
|
145
|
+
<li>位于顶部工具栏,选中元素或表格单元格后可用;不适用的按钮置灰,悬停可见原因</li>
|
|
146
|
+
<li>可设置:字体、字号、加粗 / 下划线 / 删除线、文字颜色、背景颜色、水平与垂直对齐、边框</li>
|
|
147
|
+
<li>多选时样式不一致的项目显示「混合」,重新设置后统一为所选值</li>
|
|
148
|
+
<li>边框面板提供「所有 / 外侧 / 内部 / 无」预设与上、下、左、右逐边开关,可指定线型、线宽、颜色;「内部」仅表格单元格可用</li>
|
|
149
|
+
<li>矩形、椭圆、线条本身用边框绘制,表格走单元格边框,因此不提供元素级边框</li>
|
|
150
|
+
</ul>
|
|
151
|
+
<h3>格式刷</h3>
|
|
152
|
+
<ul>
|
|
153
|
+
<li>先选中<strong>单个</strong>元素作为格式来源,点击格式刷(双击为连续刷)</li>
|
|
154
|
+
<li>再点选或框选目标元素即完成刷取;单击模式刷一次后自动退出</li>
|
|
155
|
+
<li>按 <code>Esc</code>、取消选中或再次点击格式刷按钮均可退出待刷态</li>
|
|
156
|
+
<li>按目标类型自动过滤:字体等文本样式只刷给文本 / 长文本,边框只刷给支持元素级边框的类型,背景颜色对所有元素生效</li>
|
|
157
|
+
<li>锁定元素不会被刷;源元素自身不会被改写</li>
|
|
158
|
+
</ul>
|
|
159
|
+
|
|
160
|
+
<h2>对齐与吸附</h2>
|
|
161
|
+
<h3>自动对齐</h3>
|
|
162
|
+
<p>拖拽元素时自动显示对齐引导线:</p>
|
|
163
|
+
<ul>
|
|
164
|
+
<li>蓝色:左/顶对齐</li>
|
|
165
|
+
<li>绿色:居中对齐</li>
|
|
166
|
+
<li>橙色:右/底对齐</li>
|
|
167
|
+
</ul>
|
|
168
|
+
|
|
169
|
+
<h3>网格吸附</h3>
|
|
170
|
+
<p>开启吸附功能后,元素自动吸附到网格点。</p>
|
|
171
|
+
|
|
172
|
+
<h3>手动参考线</h3>
|
|
173
|
+
<p>通过标尺区域拖拽添加参考线,参考线参与吸附检测。</p>
|
|
174
|
+
|
|
175
|
+
<h2>图层管理</h2>
|
|
176
|
+
<ul>
|
|
177
|
+
<li>调整元素显示顺序(置顶/置底/上移/下移)</li>
|
|
178
|
+
<li>显示/隐藏元素</li>
|
|
179
|
+
<li>锁定/解锁元素(锁定后不可编辑)</li>
|
|
180
|
+
</ul>
|
|
181
|
+
|
|
182
|
+
<h3>组合</h3>
|
|
183
|
+
<p>选中多个元素后(Ctrl/⌘+点击或空白处框选),可通过工具栏按钮、图层面板按钮或 <code>Ctrl + G</code> 将它们组合为一组;取消组合用 <code>Ctrl + Shift + G</code>。组合后:</p>
|
|
184
|
+
<ul>
|
|
185
|
+
<li>点击任一成员即选中整组,拖动任一成员整组跟动</li>
|
|
186
|
+
<li><strong>打印时整组强制在同一页</strong>,不会跨页拆分</li>
|
|
187
|
+
</ul>
|
|
188
|
+
<p><strong>注意:</strong>组内元素的总高度不能超过纸张内容区,否则整组移到新页后,超出部分仍会被裁掉。组太高时请拆分为多个小组或取消组合。</p>
|
|
189
|
+
|
|
190
|
+
<h3>右键菜单</h3>
|
|
191
|
+
<ul>
|
|
192
|
+
<li><strong>在元素上右键</strong>:复制 / 剪切 / 粘贴 / 删除 / 置顶 / 上移 / 下移 / 置底。右键的元素若不在当前选中范围内,会自动改为只选中它,菜单动作即作用于该元素;若它已属于当前多选,则不打断多选</li>
|
|
193
|
+
<li><strong>在空白处右键</strong>:粘贴 / 全选 / 取消选择</li>
|
|
194
|
+
<li>粘贴项在没有可粘贴内容时置灰</li>
|
|
195
|
+
</ul>
|
|
196
|
+
|
|
197
|
+
<h2>三区布局</h2>
|
|
198
|
+
<p>页面分为三个区域:</p>
|
|
199
|
+
<ul>
|
|
200
|
+
<li><strong>页眉 (header)</strong>:顶部区域</li>
|
|
201
|
+
<li><strong>内容区 (content)</strong>:主体区域</li>
|
|
202
|
+
<li><strong>页脚 (footer)</strong>:底部区域</li>
|
|
203
|
+
</ul>
|
|
204
|
+
<p>页眉/页脚支持的元素类型:文本、图片、线条、形状、条形码、二维码</p>
|
|
205
|
+
|
|
206
|
+
<h2>水印配置</h2>
|
|
207
|
+
<ul>
|
|
208
|
+
<li>水印内容用统一的「水印表达式」输入:直接输入文字即为静态水印;写成 <code>{order.no}</code>、<code>CONCAT(...)</code> 等即按表达式解析</li>
|
|
209
|
+
<li>点击「编辑表达式」(或双击输入框)打开表达式弹框,可直接选择业务字段与系统变量:打印日期 <code>{printDate}</code>、打印时间 <code>{printTime}</code>、当前页码 <code>{pageIndex}</code>、总页数 <code>{totalPages}</code>;表达式取不到值时回退到测试值</li>
|
|
210
|
+
<li>可设置旋转角度(-90°~90°)、颜色与透明度</li>
|
|
211
|
+
<li>支持调节水印密度(密/中/疏/自定义瓦片尺寸),以及设置水印颜色</li>
|
|
212
|
+
<li>水印在画布、浏览器预览、服务端 PDF、静默打印四端渲染一致</li>
|
|
213
|
+
</ul>
|
|
214
|
+
`},ml={id:"shortcuts",title:"快捷键",content:`
|
|
215
|
+
<h2>常用操作</h2>
|
|
216
|
+
<table>
|
|
217
|
+
<thead>
|
|
218
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
219
|
+
</thead>
|
|
220
|
+
<tbody>
|
|
221
|
+
<tr><td><code>Ctrl + C</code></td><td>复制选中元素</td></tr>
|
|
222
|
+
<tr><td><code>Ctrl + V</code></td><td>粘贴元素(偏移 10mm)</td></tr>
|
|
223
|
+
<tr><td><code>Ctrl + D</code></td><td>原地复制(偏移 5mm, 5mm)</td></tr>
|
|
224
|
+
<tr><td><code>Ctrl + A</code></td><td>全选元素</td></tr>
|
|
225
|
+
<tr><td><code>Ctrl / ⌘ + 点击</code></td><td>在画布或图层面板中逐个加选/取消选择元素</td></tr>
|
|
226
|
+
<tr><td><code>空白处拖拽框选</code></td><td>左上→右下为相交命中;右下→左上为完全包围才命中</td></tr>
|
|
227
|
+
<tr><td><code>Delete / Backspace</code></td><td>删除选中元素</td></tr>
|
|
228
|
+
<tr><td><code>Ctrl + Z</code></td><td>撤销</td></tr>
|
|
229
|
+
<tr><td><code>Ctrl + Shift + Z</code> / <code>Ctrl + Y</code></td><td>重做</td></tr>
|
|
230
|
+
</tbody>
|
|
231
|
+
</table>
|
|
232
|
+
|
|
233
|
+
<h2>元素移动</h2>
|
|
234
|
+
<table>
|
|
235
|
+
<thead>
|
|
236
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
237
|
+
</thead>
|
|
238
|
+
<tbody>
|
|
239
|
+
<tr><td><code>方向键</code></td><td>移动 1mm</td></tr>
|
|
240
|
+
<tr><td><code>Shift + 方向键</code></td><td>移动 10mm</td></tr>
|
|
241
|
+
<tr><td><code>Ctrl + 方向键</code></td><td>移动 0.5mm</td></tr>
|
|
242
|
+
</tbody>
|
|
243
|
+
</table>
|
|
244
|
+
|
|
245
|
+
<h2>缩放控制</h2>
|
|
246
|
+
<table>
|
|
247
|
+
<thead>
|
|
248
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
249
|
+
</thead>
|
|
250
|
+
<tbody>
|
|
251
|
+
<tr><td><code>Ctrl + 1</code></td><td>重置缩放至 100%</td></tr>
|
|
252
|
+
<tr><td><code>Ctrl + 0</code></td><td>适应窗口</td></tr>
|
|
253
|
+
</tbody>
|
|
254
|
+
</table>
|
|
255
|
+
|
|
256
|
+
<h2>对齐操作(多选时)</h2>
|
|
257
|
+
<table>
|
|
258
|
+
<thead>
|
|
259
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
260
|
+
</thead>
|
|
261
|
+
<tbody>
|
|
262
|
+
<tr><td><code>Ctrl + L</code></td><td>左对齐</td></tr>
|
|
263
|
+
<tr><td><code>Ctrl + R</code></td><td>右对齐</td></tr>
|
|
264
|
+
<tr><td><code>Ctrl + E</code></td><td>水平居中</td></tr>
|
|
265
|
+
<tr><td><code>Ctrl + T</code></td><td>顶对齐</td></tr>
|
|
266
|
+
<tr><td><code>Ctrl + B</code></td><td>底对齐</td></tr>
|
|
267
|
+
</tbody>
|
|
268
|
+
</table>
|
|
269
|
+
|
|
270
|
+
<h2>组合操作</h2>
|
|
271
|
+
<table>
|
|
272
|
+
<thead>
|
|
273
|
+
<tr><th>快捷键</th><th>功能</th></tr>
|
|
274
|
+
</thead>
|
|
275
|
+
<tbody>
|
|
276
|
+
<tr><td><code>Ctrl + G</code></td><td>组合选中元素(打印时整组强制同页)</td></tr>
|
|
277
|
+
<tr><td><code>Ctrl + Shift + G</code></td><td>取消组合</td></tr>
|
|
278
|
+
</tbody>
|
|
279
|
+
</table>
|
|
280
|
+
|
|
281
|
+
<blockquote>
|
|
282
|
+
<p><strong>注意</strong>:当焦点在输入框、文本框、下拉框内时,快捷键不生效。</p>
|
|
283
|
+
</blockquote>
|
|
284
|
+
`},gl={id:"faq",title:"常见问题",content:`
|
|
285
|
+
<h2>如何调整纸张大小?</h2>
|
|
286
|
+
<ol>
|
|
287
|
+
<li>在右侧面板选择"页面设置"</li>
|
|
288
|
+
<li>选择预设纸张:常用纸张(A4、A3、A5、Letter、Legal)、针式打印纸(全等分 / 二等分 / 三等分)、标签纸(80×60、60×40、40×30)、小票纸(57 / 80 / 110mm)</li>
|
|
289
|
+
<li>或选择"自定义"输入宽度和高度(mm);"连续纸"可自定义纸宽,出纸高度按内容自动推导</li>
|
|
290
|
+
<li>设置方向:纵向(portrait)或横向(landscape);切换即交换纸张长宽,设计稿内容随之铺在该尺寸上。连续纸与小票纸固定纵向</li>
|
|
291
|
+
<li>内容旋转角度:0° / 90° / 180° / 270°,整页内容旋转对应角度出纸。90° / 270° 时纸张长宽互换以贴合旋转后的内容,设计稿内容保持原方向、不变形不裁切;0° 为不旋转(默认)。连续纸与小票纸固定纵向、无旋转概念</li>
|
|
292
|
+
</ol>
|
|
293
|
+
|
|
294
|
+
<h2>如何处理分页?</h2>
|
|
295
|
+
<p>数据表格支持自动分页:</p>
|
|
296
|
+
<ol>
|
|
297
|
+
<li>在表格属性中设置"每页显示行数"</li>
|
|
298
|
+
<li>启用"表头重复"确保跨页时显示标题行</li>
|
|
299
|
+
<li>添加小计行显示每页小计</li>
|
|
300
|
+
<li>添加汇总行显示整表合计</li>
|
|
301
|
+
<li>文本、图片等非表格元素按位置整体移页,不会拆开;已组合的元素整组强制同页,组过高会被裁切(见"如何组合多个元素")</li>
|
|
302
|
+
</ol>
|
|
303
|
+
|
|
304
|
+
<h2>如何导入外部数据?</h2>
|
|
305
|
+
<p>通过组件 props 传入数据:</p>
|
|
306
|
+
<ul>
|
|
307
|
+
<li><code>fields</code>:字段定义数组,用于字段树显示</li>
|
|
308
|
+
<li><code>initialTemplate</code>:初始模板数据</li>
|
|
309
|
+
</ul>
|
|
310
|
+
<p>模板加载 / 重置(如「加载默认布局」)由宿主实现:把新的模板数据赋给 <code>initialTemplate</code> 即可重载画布。</p>
|
|
311
|
+
|
|
312
|
+
<h2>如何使用表达式绑定字段?</h2>
|
|
313
|
+
<ol>
|
|
314
|
+
<li>双击元素打开表达式编辑器</li>
|
|
315
|
+
<li>使用 <code>{field.path}</code> 语法绑定字段</li>
|
|
316
|
+
<li>使用内置函数格式化数据(如 <code>{MONEY(price)}</code>)</li>
|
|
317
|
+
<li>点击确认保存</li>
|
|
318
|
+
</ol>
|
|
319
|
+
|
|
320
|
+
<h2>如何调整元素层级?</h2>
|
|
321
|
+
<ol>
|
|
322
|
+
<li>选中一个或多个元素</li>
|
|
323
|
+
<li>点击工具栏的层级按钮(带上下箭头图标):
|
|
324
|
+
<ul>
|
|
325
|
+
<li>置顶(箭头到顶线)</li>
|
|
326
|
+
<li>上移一层(向上箭头)</li>
|
|
327
|
+
<li>下移一层(向下箭头)</li>
|
|
328
|
+
<li>置底(箭头到底线)</li>
|
|
329
|
+
</ul>
|
|
330
|
+
</li>
|
|
331
|
+
</ol>
|
|
332
|
+
<p>或使用快捷键在图层面板中调整。</p>
|
|
333
|
+
|
|
334
|
+
<h2>如何选择多个元素?</h2>
|
|
335
|
+
<ol>
|
|
336
|
+
<li>按住 Ctrl(Mac 为 ⌘)在画布或左侧图层面板中逐个点击元素,逐个加入/移出选择</li>
|
|
337
|
+
<li>在画布<strong>空白区域</strong>按下并拖动进行框选(起点落在元素上时会变为选中或拖动该元素,不会启动框选):
|
|
338
|
+
<ul>
|
|
339
|
+
<li>从左上向右下拖动:与选框<strong>相交</strong>的元素即被选中</li>
|
|
340
|
+
<li>从右下向左上拖动:仅<strong>完全包围</strong>的元素被选中</li>
|
|
341
|
+
</ul>
|
|
342
|
+
</li>
|
|
343
|
+
<li>按 <code>Ctrl + A</code> 全选当前页元素</li>
|
|
344
|
+
</ol>
|
|
345
|
+
|
|
346
|
+
<h2>如何组合多个元素?</h2>
|
|
347
|
+
<ol>
|
|
348
|
+
<li>按住 Ctrl(Mac 为 ⌘)逐个点击,或用空白处框选选中多个元素</li>
|
|
349
|
+
<li>点击工具栏"组合"按钮、图层面板底部的组合按钮,或按 <code>Ctrl + G</code></li>
|
|
350
|
+
<li>组合后点击任一成员可选中整组;拖动任一成员整组跟动;打印时整组强制同页</li>
|
|
351
|
+
<li>取消组合:选中组内任一成员后点击"取消组合"(工具栏或图层面板),或按 <code>Ctrl + Shift + G</code></li>
|
|
352
|
+
</ol>
|
|
353
|
+
<p><strong>注意:</strong>组合元素会强制打印在同一页,引擎不会为它跨页拆分。组合前请确认组内元素的总高度(从最高点到最低点)不超过纸张内容区,否则整组虽会移到新的一页,超出页面的部分仍会被裁掉。组太高时请拆分为多个小组,或取消组合。</p>
|
|
354
|
+
|
|
355
|
+
<h2>如何使用参考线?</h2>
|
|
356
|
+
<ol>
|
|
357
|
+
<li>在标尺区域拖拽添加参考线</li>
|
|
358
|
+
<li>参考线自动参与吸附检测</li>
|
|
359
|
+
<li>拖拽参考线可调整位置</li>
|
|
360
|
+
<li>双击参考线可删除</li>
|
|
361
|
+
</ol>
|
|
362
|
+
|
|
363
|
+
<h2>如何预览打印效果?</h2>
|
|
364
|
+
<ol>
|
|
365
|
+
<li>点击工具栏"预览"按钮</li>
|
|
366
|
+
<li>预览使用同构渲染管线,确保与实际打印一致</li>
|
|
367
|
+
</ol>
|
|
368
|
+
|
|
369
|
+
<h2>模板数据格式是什么?</h2>
|
|
370
|
+
<p>模板以 JSON 格式存储,包含:</p>
|
|
371
|
+
<ul>
|
|
372
|
+
<li><code>paperSize</code>:纸张大小</li>
|
|
373
|
+
<li><code>orientation</code>:方向</li>
|
|
374
|
+
<li><code>margins</code>:页边距</li>
|
|
375
|
+
<li><code>header</code>:页眉配置</li>
|
|
376
|
+
<li><code>footer</code>:页脚配置</li>
|
|
377
|
+
<li><code>elements</code>:元素数组</li>
|
|
378
|
+
<li><code>watermark</code>:水印配置</li>
|
|
379
|
+
</ul>
|
|
380
|
+
|
|
381
|
+
<h2>如何调整表格列宽?</h2>
|
|
382
|
+
<ol>
|
|
383
|
+
<li>在左侧面板的图层列表中,点击选中对应的表格元素</li>
|
|
384
|
+
<li>此时画布上的表格会显示列宽分隔线</li>
|
|
385
|
+
<li>拖动列宽分隔线即可调整列宽</li>
|
|
386
|
+
</ol>
|
|
387
|
+
<blockquote>
|
|
388
|
+
<p><strong>注意</strong>:必须先选中表格元素,才能激活列宽拖动功能。</p>
|
|
389
|
+
</blockquote>
|
|
390
|
+
|
|
391
|
+
<h2>如何调整表格属性?</h2>
|
|
392
|
+
<ol>
|
|
393
|
+
<li>确保当前没有任何单元格被选中(如有选中,点击画布空白区域取消选中)</li>
|
|
394
|
+
<li>在左侧面板的图层列表中,点击选中对应的表格元素</li>
|
|
395
|
+
<li>右侧面板会显示表格属性设置</li>
|
|
396
|
+
</ol>
|
|
397
|
+
<blockquote>
|
|
398
|
+
<p><strong>注意</strong>:如果存在选中的单元格,右侧面板将显示单元格属性而非表格属性。</p>
|
|
399
|
+
</blockquote>
|
|
400
|
+
|
|
401
|
+
<h2>为什么部分页面有水印、部分页面没有?</h2>
|
|
402
|
+
<ol>
|
|
403
|
+
<li>水印是<strong>按模板</strong>独立设置的,每一个设计的模板都需要单独配置自己的水印信息,不会自动继承其他模板。</li>
|
|
404
|
+
<li>如果出现部分页面存在水印、部分页面没有水印的情况,说明该页面所在的模板没有为自身设置水印。</li>
|
|
405
|
+
<li>为模板添加水印:进入该模板专属页面,在右侧的"页面属性"中找到"水印"配置项进行设计即可。</li>
|
|
406
|
+
</ol>
|
|
407
|
+
<blockquote>
|
|
408
|
+
<p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
|
|
409
|
+
</blockquote>
|
|
410
|
+
`},bl={id:"changelog",title:"更新记录",content:`
|
|
411
|
+
<h2>V1.3.7<small>(2026-10-19)</small></h2>
|
|
412
|
+
|
|
413
|
+
<h3>新增</h3>
|
|
414
|
+
<ul>
|
|
415
|
+
<li><strong>两端对齐</strong>:文本元素和表格单元格都能选「两端」,一行字会均匀铺开、左右两头都贴齐边界(含最后一行)。想撑满列宽的表头、签字栏不必再手动加空格。</li>
|
|
416
|
+
<li><strong>长文本首行缩进</strong>:按「字符」填写,2 就是常规的「缩进两个字符」,字号变小时缩进也跟着变窄。</li>
|
|
417
|
+
<li><strong>图片缩放模式与裁剪锚点</strong>:可拉伸铺满或等比裁切,并指定保住哪一侧(证件照保住头顶);表格里的图片单元格同样能设锚点。</li>
|
|
418
|
+
<li><strong>二维码静区(模块)</strong>:可填 0~8 控制码面四周留白,0 即码面等比铺满元素框;需要扫码合规白边时填 4。</li>
|
|
419
|
+
<li><strong>工具栏自适应收纳</strong>:窗口变窄放不下时按钮组自动收进「更多」下拉,分组标题与图标形态都保留,不再出现按钮文字竖排压住画布。</li>
|
|
420
|
+
</ul>
|
|
421
|
+
|
|
422
|
+
<h3>修复</h3>
|
|
423
|
+
<ul>
|
|
424
|
+
<li><strong>二维码不再小一圈</strong>:此前二维码按固定尺寸出图,元素框一旦偏大就明显填不满,缩放框体也没用(24mm 框看不出来,60mm 框只画约三分之二)。现在等比铺满元素框与单元格,反复改框大小也不会重画发虚。</li>
|
|
425
|
+
<li><strong>图片缩放模式出纸时生效</strong>:以前只有画布按所选模式显示,预览、导出 PDF 与桌面客户端出纸都被固定成「完整显示」,现在四条链路一致。</li>
|
|
426
|
+
<li><strong>桌面客户端出纸更准</strong>:改走与浏览器打印同一条通路,纸张按设计器算出的实际毫米下发(60×40 / 80×60 / 100×80 mm 实测落盘尺寸精确一致、内容正立),Windows 不再需要额外安装外部打印工具。</li>
|
|
427
|
+
<li><strong>属性台控件跟随主题</strong>:输入框、下拉、弹层、右键菜单与滚动条统一接入主题变量,浅色外观逐像素不变,换深色不再出现白色死角;说明气泡在部分宿主下被拉成超宽长条,已修正。</li>
|
|
428
|
+
</ul>
|
|
429
|
+
|
|
430
|
+
<h3>注意</h3>
|
|
431
|
+
<ul>
|
|
432
|
+
<li><strong>二维码留白变少</strong>:静区缺省由固定 4 模块改为 0,既有模板的码面占框比例会变大(铺满元素框)。要保留原来的白边,请把「静区 (模块)」填成 4。</li>
|
|
433
|
+
<li><strong>桌面客户端设置项调整</strong>:「出纸方式」配置项已取消,出纸固定走新通路;Windows / Linux 不再显示顶部应用菜单(文本框里的复制粘贴快捷键不受影响)。</li>
|
|
434
|
+
</ul>
|
|
435
|
+
|
|
436
|
+
<h2>V1.3.6<small>(2026-10-16)</small></h2>
|
|
437
|
+
|
|
438
|
+
<h3>修复</h3>
|
|
439
|
+
<ul>
|
|
440
|
+
<li><strong>桌面客户端打印标签不再被转 90°</strong>:宽大于高的标签(如 100×75 mm)经桌面客户端静默打印时,纸上内容会被整体旋转 90°(导出的 PDF 本身是正的)。Windows 上出纸交给 SumatraPDF,它默认会给「宽 > 高」的页面加 90°,现已按页面自身长宽比显式声明方向;macOS / Linux 上此前的纸张声明因出纸参数漏传从未真正下发,现已一并修复,横向单据(横向 A4、宽幅自定义纸)在 macOS 与 Linux 上也都不再被打印系统转 90°。</li>
|
|
441
|
+
</ul>
|
|
442
|
+
|
|
443
|
+
<h2>V1.3.5<small>(2026-10-05)</small></h2>
|
|
444
|
+
|
|
445
|
+
<h3>移除</h3>
|
|
446
|
+
<ul>
|
|
447
|
+
<li><strong>「首页专属」按钮与首页叠加区</strong>:不再提供只在首页出现的额外叠加区域。此前在该区域放过内容的模板,叠加内容不再输出,首页可用高度相应增大,请按新口径复核版式。</li>
|
|
448
|
+
<li><strong>「叠层对比」按钮</strong>:画布上的渲染截图叠层比对已下线,改用「预览」核对出纸效果。</li>
|
|
449
|
+
</ul>
|
|
450
|
+
|
|
451
|
+
<h3>修复</h3>
|
|
452
|
+
<ul>
|
|
453
|
+
<li><strong>右键菜单终于能用了</strong>:此前在画布上右键能弹出菜单,但菜单里的每一项(复制、粘贴、删除、置顶 / 上移 / 下移 / 置底等)点了都没有反应。现在每一项都会正常执行。</li>
|
|
454
|
+
<li><strong>表格右键不再要求先选中</strong>:直接在表格单元格上按右键就能打开表格菜单,不用再先点一下表格。</li>
|
|
455
|
+
<li><strong>右键会自动选中目标</strong>:在没有选中任何东西时右键某个元素,会先把该元素选中再弹菜单,复制、删除这类操作不会再「静默无效」。已经框选好的多个元素不受影响。</li>
|
|
456
|
+
</ul>
|
|
457
|
+
|
|
458
|
+
<h3>改进</h3>
|
|
459
|
+
<ul>
|
|
460
|
+
<li><strong>安装体积更小</strong>:安装包补上了许可证与作者信息,代码文件带版权说明,并且不再附带可阅读的原始代码,包体积约缩小三分之二。</li>
|
|
461
|
+
</ul>
|
|
462
|
+
|
|
463
|
+
<h2>V1.3.4<small>(2026-09-27)</small></h2>
|
|
464
|
+
|
|
465
|
+
<h3>修复</h3>
|
|
466
|
+
<ul>
|
|
467
|
+
<li><strong>页脚打印位置与设计台一致</strong>:此前页脚内容打印或导出 PDF 时会整体左移一个「左边距」的宽度(设计台上看着正常)。现在浏览器打印、服务端 PDF、桌面客户端静默打印三条出纸方式都与设计台所见一致,纸张旋转出纸与连续纸同样生效。</li>
|
|
468
|
+
</ul>
|
|
469
|
+
|
|
470
|
+
<h3>注意</h3>
|
|
471
|
+
<ul>
|
|
472
|
+
<li>如果此前为补偿这个偏移、手动把页脚元素的「左位置」调大过,升级后会变成双重偏移,请在设计台上把它调回想要的位置。</li>
|
|
473
|
+
</ul>
|
|
474
|
+
|
|
475
|
+
<h2>V1.3.3<small>(2026-09-27)</small></h2>
|
|
476
|
+
|
|
477
|
+
<h3>新增</h3>
|
|
478
|
+
<ul>
|
|
479
|
+
<li><strong>格式工具栏</strong>:顶部工具栏新增常用排版控件——字体、字号、加粗 / 下划线 / 删除线、文字颜色、背景颜色、对齐方式、边框。选中多个元素或多个单元格后可一次性批量设置;样式不一致时显示「混合」,用法与 Word 一致。</li>
|
|
480
|
+
<li><strong>边框可以只加某几条边</strong>:边框面板提供「所有 / 外侧 / 内部 / 无」预设和上、下、左、右单独开关,并可指定线型、线宽与颜色。文本、长文本、图片、条码、二维码、HTML、页码等元素现在也能加边框(矩形、椭圆、线条、表格仍按各自原有方式绘制)。</li>
|
|
481
|
+
<li><strong>格式刷</strong>:选中一个元素后点格式刷,再点选或框选目标即可把格式刷过去。单击刷一次后自动退出,双击可连续刷,按 <code>Esc</code> 或点空白处取消;鼠标变成「复制」样式即表示正在待刷。</li>
|
|
482
|
+
</ul>
|
|
483
|
+
|
|
484
|
+
<h3>改进</h3>
|
|
485
|
+
<ul>
|
|
486
|
+
<li><strong>工具栏不再跳动</strong>:排版控件收进顶部一行,次要分组改为下拉;用不上的按钮改为置灰,悬停可以看到具体原因。</li>
|
|
487
|
+
</ul>
|
|
488
|
+
|
|
489
|
+
<h3>注意</h3>
|
|
490
|
+
<ul>
|
|
491
|
+
<li>以前给文本、图片等元素设置过边框但看不见效果的老模板,升级后边框会真的显示出来(画布与打印一致)。如不需要,把边框宽度改成 0 或选「无」即可。</li>
|
|
492
|
+
</ul>
|
|
493
|
+
|
|
494
|
+
<h2>V1.3.2<small>(2026-09-26)</small></h2>
|
|
495
|
+
|
|
496
|
+
<h3>修复</h3>
|
|
497
|
+
<ul>
|
|
498
|
+
<li><strong>表格下方间距不再变大</strong>:放在表格下方的元素(合计行、签名栏等),此前打印到纸上时间距会被莫名拉大(设计台上看着正常)。现在以设计台上看到的表格底部为准,出纸与所见一致。</li>
|
|
499
|
+
<li><strong>翻页后不再互相叠压</strong>:表格断页续到新一页后,页尾的组合元素此前会和续排内容叠在一起。现在换页后各元素从上到下顺排,组合依然整组同页、放不下就整组移到下一页。</li>
|
|
500
|
+
</ul>
|
|
501
|
+
|
|
502
|
+
<h3>改进</h3>
|
|
503
|
+
<ul>
|
|
504
|
+
<li><strong>组合与多选更好用</strong>:画布和图层面板都支持 Ctrl/⌘ 点击加选;只要选中内容里有组成员,「取消组合」就会出现;组合/取消组合可在工具栏、图层面板底部按钮或 <code>Ctrl+G</code> / <code>Ctrl+Shift+G</code> 完成。帮助文档补充了框选规则与组合说明。</li>
|
|
505
|
+
<li><strong>图标焕新</strong>:工具栏与图层面板图标统一为新风格,全部带悬停提示;组合/取消组合使用专属图标。</li>
|
|
506
|
+
</ul>
|
|
507
|
+
|
|
508
|
+
<h2>V1.3.1<small>(2026-09-21)</small></h2>
|
|
509
|
+
|
|
510
|
+
<h3>新增</h3>
|
|
511
|
+
<ul>
|
|
512
|
+
<li><strong>数值运算与修约</strong>:表达式新增四则函数 <code>ADD</code> / <code>SUB</code> / <code>MUL</code> / <code>DIV</code>,以及修约函数 <code>ROUND</code>(四舍五入)、<code>ROUNDUP</code>(进一)、<code>ROUNDDOWN</code>(去尾)、<code>ROUNDBANK</code>(四舍六入五成双)。位数可省略(默认两位),写负数则修约到整十/整百。表达式编辑器「函数」页新增「数值运算」分组,双击即可插入。</li>
|
|
513
|
+
<li><strong>四则运算更准</strong>:直接写 <code>{qty * price}</code> 时,数字字符串按数值参与运算、不再出现 <code>0.30000000000000004</code> 这类浮点尾巴、除以 0 不再印出 <code>Infinity</code>。</li>
|
|
514
|
+
<li><strong>在线示例更好上手</strong>:示例库新增「综合示例模板」(多级表头 + 表格内图片 / 条形码 / 二维码混排),进入页面即自动载入;新增「自定义字段与数据」弹窗,可直接在页面上增删字段、编辑多份打印数据。在线预览已支持静态托管,可直接打开网页体验。</li>
|
|
515
|
+
</ul>
|
|
516
|
+
|
|
517
|
+
<h3>变更</h3>
|
|
518
|
+
<ul>
|
|
519
|
+
<li><strong>静默打印 SDK 并入 core</strong>:原 <code>@worm-vue3-print/client</code> 不再单独安装,改为从 <code>@worm-vue3-print/core/client</code> 导入;<code>PrintClient</code> 等能力保持不变,core 也不会因此增加依赖。</li>
|
|
520
|
+
</ul>
|
|
521
|
+
|
|
522
|
+
<h3>修复</h3>
|
|
523
|
+
<ul>
|
|
524
|
+
<li><code>ROUND(1.005, 2)</code> 此前得到 <code>1</code>(应为 <code>1.01</code>)、<code>ROUND(2.675, 2)</code> 得到 <code>2.67</code>(应为 <code>2.68</code>)——改为按十进制精确修约。</li>
|
|
525
|
+
<li>页码、打印日期此前只能在花括号里单独使用(<code>{pageIndex}</code>),一旦参与运算或函数(<code>{pageIndex + 1}</code>、<code>{ADD(pageIndex,1)}</code>、<code>{DATE(printDate,'YYYY')}</code>)就会被原样印出。现在这些写法都会按所在页真实求值,页眉/页脚、表格单元格同样生效。</li>
|
|
526
|
+
<li><strong>多级表头跨页不再丢层级</strong>:表头有好几层时,翻页后第二层往下曾经整段消失(只重复了最上面一行)。现在「表头每页重复」按整个表头区生效——表头里任意一层勾了,每一页都会完整印出全部层级;新增表头行也会自动跟随同一设置,不用担心漏勾。</li>
|
|
527
|
+
</ul>
|
|
528
|
+
|
|
529
|
+
<h2>V1.3.0<small>(2026-09-20)</small></h2>
|
|
530
|
+
|
|
531
|
+
<h3>新增</h3>
|
|
532
|
+
<ul>
|
|
533
|
+
<li><strong>多页面模板</strong>:一份文书可以由版式不同的多个页面按固定顺序组成(如「封面 + 正文 + 条款」),各页绑定同一份数据,下一次出纸就是完整的一份文档。顶部页面栏支持新增、复制、删除、前移/后移、双击重命名与点击切换;删到只剩一页时自动回到单页模式。</li>
|
|
534
|
+
<li><strong>内容旋转角度</strong>:页面属性新增「内容旋转角度」(0° / 90° / 180° / 270°),支持横版设计、竖版出纸——内容整体旋转填满出纸版面,不缩放也不裁切。</li>
|
|
535
|
+
<li><strong>设计背景(套打底图)</strong>:页面属性支持上传、90° 步进旋转与移除底图,照着现成单据排版更省力。底图只在设计画布显示,预览与打印都不会输出。</li>
|
|
536
|
+
</ul>
|
|
537
|
+
|
|
538
|
+
<h3>变更</h3>
|
|
539
|
+
<ul>
|
|
540
|
+
<li><strong>条码尺寸</strong>:条形码(元素与表格单元格)不再拉伸填满元素框,改为按「条宽 → 打印机分辨率 → 等比缩小」结算:默认条宽下每模块 0.25mm,装得下就按原尺寸落纸;设置了「打印机分辨率」(203/300/600)时吸附到整数打印点;宽度不足时整体等比缩小。要更大的条码请调大「条宽」,需要上限请用「最大宽高」——条形码不再提供「缩放模式」。<strong>同一份旧模板的条码会变小</strong>,这是让出纸条宽保持稳定所必需的。</li>
|
|
541
|
+
<li><strong>文字溢出</strong>:文本元素与表格单元格支持「截断 / 自动缩小 / 自适应行高」三种显示形式(属性面板「文字溢出」),缺省值与原有行为一致,存量模板不受影响。</li>
|
|
542
|
+
<li><strong>标签纸</strong>:纸张切到标签纸(80×60 / 60×40 / 40×30mm)时默认取消页边距与页眉页脚,整张纸都给内容区;只在切换纸型时套用一次,之后仍可自行改回,存量模板不会被改写。</li>
|
|
543
|
+
<li><strong>多页面约束</strong>:纸张设置对所有页生效,页边距、页眉页脚、首页叠加、水印与内容元素则按页各自独立;多页模式下隐藏拼版配置、禁用连续纸。</li>
|
|
544
|
+
</ul>
|
|
545
|
+
|
|
546
|
+
<h3>修复</h3>
|
|
547
|
+
<ul>
|
|
548
|
+
<li>多页面模板页面重排后页签名漂移、删除页面后再新增出现重名。</li>
|
|
549
|
+
<li>条形码经热敏打印机出纸条宽忽宽忽窄、边缘发灰;条宽倍率在不同模式下视觉不一致。</li>
|
|
550
|
+
<li>元素堆叠与显式组合在分页时被拆散;单击组合内的任一成员改为选中整组。</li>
|
|
551
|
+
<li>水印经真实打印机出纸被放大约 3 倍、位置偏移、平铺错乱(改为逐块矢量瓦片渲染)。</li>
|
|
552
|
+
<li>小纸张模板(如 80×60mm 自定义纸)输出多出一张空白首页。</li>
|
|
553
|
+
</ul>
|
|
554
|
+
|
|
555
|
+
<h2>V1.2.2<small>(2026-09-11)</small></h2>
|
|
556
|
+
|
|
557
|
+
<h3>变更</h3>
|
|
558
|
+
<ul>
|
|
559
|
+
<li><code>@worm-vue3-print/core</code> 新增子路径 <code>/designer</code>:框架无关的设计器内核,包含完整模板模型类型、通用工具(元素工厂、表格矩阵、单位换算、模板迁移、标尺等)与纯交互逻辑(对齐、分组、键盘、缩放、吸附计算),不依赖 Vue/React。</li>
|
|
560
|
+
<li><code>@worm-vue3-print/core</code> 新增子路径 <code>/browser</code>:浏览器侧渲染适配器(<code>renderHtmlPages</code> 两遍分页渲染、条形码/二维码渲染器)。</li>
|
|
561
|
+
<li>设计器模型、工具与纯逻辑下沉至 core 子路径,canvas 仅保留 Vue 适配层;公共 API 保持不变,core 主入口仍为零运行时依赖,为后续多框架适配打下基础。</li>
|
|
562
|
+
</ul>
|
|
563
|
+
|
|
564
|
+
<h3>修复</h3>
|
|
565
|
+
<ul>
|
|
566
|
+
<li>修复工具栏放大/缩小按钮直接线性改缩放比例、未做滚动锚点校正导致画面漂移的问题;按钮缩放改为与 Ctrl+滚轮一致的乘性步进,并以视口中心为锚点(与「适应窗口」同一缩放管线)。</li>
|
|
567
|
+
</ul>
|
|
568
|
+
|
|
569
|
+
<h2>V1.2.1<small>(2026-09-11)</small></h2>
|
|
570
|
+
|
|
571
|
+
<h3>变更</h3>
|
|
572
|
+
<ul>
|
|
573
|
+
<li>工具栏编辑区/层级区/视图区图标按钮统一使用 data-tip 自定义悬浮提示,补齐「网格」「吸附」缺失提示;提升提示层级,不再被画布顶部标尺遮挡。</li>
|
|
574
|
+
<li>优化「适应窗口」:以视口中心为锚点一步缩放到位(与 Ctrl+滚轮同一缩放换算管线),缩放平滑过渡;允许低于交互缩放下限(最小可至 5%),超大纸张也能整版容纳,纸张在画布视口内水平垂直居中。</li>
|
|
575
|
+
<li>新增 <code>showHelp</code> 配置:控制帮助入口(帮助按钮与帮助弹框)显示,默认开启,传入 <code>false</code> 即可隐藏。</li>
|
|
576
|
+
</ul>
|
|
577
|
+
|
|
578
|
+
<h3>修复</h3>
|
|
579
|
+
<ul>
|
|
580
|
+
<li>工具栏悬浮提示气泡被画布顶部固定标尺遮挡无法显示。</li>
|
|
581
|
+
<li>「适应窗口」后超大纸张仍残留滚动条、纸张未在画布视口居中(垂直偏上)。</li>
|
|
582
|
+
</ul>
|
|
583
|
+
|
|
584
|
+
<h3>文档</h3>
|
|
585
|
+
<ul>
|
|
586
|
+
<li>新增打印设计工作台布局线框图文档(<code>docs/中文/打印设计工作台-布局线框图.md</code>),标注各区域名称、功能与对应组件文件。</li>
|
|
587
|
+
</ul>
|
|
588
|
+
|
|
589
|
+
<h2>V1.2.0<small>(2026-09-10)</small></h2>
|
|
590
|
+
|
|
591
|
+
<h3>新增</h3>
|
|
592
|
+
<ul>
|
|
593
|
+
<li>帮助文档模态框(HelpModal):内置功能介绍、快捷键一览、常见问题与更新记录,按 Esc 或点击遮罩关闭。</li>
|
|
594
|
+
<li>标尺参考线增强:支持从标尺拖拽添加参考线、双击编辑、删除,参考线对齐吸附实时显示。</li>
|
|
595
|
+
<li>表格列宽拖拽新增末列右边界手柄:可直接拖拽末列右边界调整末列宽,受打印范围宽度与最小列宽 5mm 钳制。</li>
|
|
596
|
+
</ul>
|
|
597
|
+
|
|
598
|
+
<h3>变更</h3>
|
|
599
|
+
<ul>
|
|
600
|
+
<li>优化缩放逻辑:取消放大上限,支持滚轮乘性步进缩放,修复缩放锚点漂移问题。</li>
|
|
601
|
+
<li>移除设计态元素左上角的 fx 绑定标签提示,简化元素视觉呈现。</li>
|
|
602
|
+
</ul>
|
|
603
|
+
|
|
604
|
+
<h3>文档</h3>
|
|
605
|
+
<ul>
|
|
606
|
+
<li>仓库根目录新增 <code>AGENTS.md</code>:AI 代理行为规范,明确代理在本仓库工作时的语言、专家态度、协作约定等强制要求。</li>
|
|
607
|
+
<li>新增 <code>worm-vue3-print</code> 集成支持 skill:包含安装指南、集成 API、故障排查等参考文档。</li>
|
|
608
|
+
</ul>
|
|
609
|
+
|
|
610
|
+
<h3>修复</h3>
|
|
611
|
+
<ul>
|
|
612
|
+
<li>表格列宽拖拽存在的多个缺陷:
|
|
613
|
+
<ul>
|
|
614
|
+
<li>内部列边界向左拖时左列宽度不变,导致边界线不跟随光标。</li>
|
|
615
|
+
<li>px → mm 单位换算缺失,拖拽距离存在约 3.78 倍偏差。</li>
|
|
616
|
+
<li><code>table-layout: fixed</code> 下拖拽过程中表格 CSS <code>width(100%)</code> 与列宽和失配,导致浏览器按比例拉伸列,使边界线与右侧内容偏离光标。</li>
|
|
617
|
+
<li>删除 <code>onColResizeStart</code> 中残留的 <code>document.title</code> 调试代码。</li>
|
|
618
|
+
</ul>
|
|
619
|
+
</li>
|
|
620
|
+
</ul>
|
|
621
|
+
|
|
622
|
+
<h2>V1.1.0<small>(2026-09-06)</small></h2>
|
|
623
|
+
|
|
624
|
+
<h3>新增</h3>
|
|
625
|
+
<ul>
|
|
626
|
+
<li>表格元素支持列宽拖拽:设计态选中表格后,在列边界悬停并拖动即可调整该列宽(左侧列),实时更新画布与元素尺寸;受打印范围宽度与最小列宽 5mm 钳制,拖拽结束后计入一次撤销历史。属性面板的列宽数值输入保留作为精确输入兜底。</li>
|
|
627
|
+
<li>表格单元格支持图片类型:单元格可切换为图片类型,设计态支持选择图片与设置 fit/maxWidth/maxHeight,预览与打印输出完整渲染。</li>
|
|
628
|
+
<li>条形码与二维码单元格支持 fit/maxWidth/maxHeight 属性。</li>
|
|
629
|
+
<li>属性面板位置尺寸改用 StepperInput 控件:支持按钮微调数值;StepperInput 支持可选值列表和小数步进。</li>
|
|
630
|
+
<li>新增统一颜色选择器并重构属性面板字段分组。</li>
|
|
631
|
+
<li>支持页面(纸张)背景色 <code>pageBackground</code>,预览与打印/PDF 输出一致。</li>
|
|
632
|
+
<li>支持 canvas 库模式构建与 npm 发布。</li>
|
|
633
|
+
</ul>
|
|
634
|
+
|
|
635
|
+
<h3>修复</h3>
|
|
636
|
+
<ul>
|
|
637
|
+
<li>打印/导出 PDF 保留元素背景色(<code>print-color-adjust: exact</code>)。</li>
|
|
638
|
+
<li>打印预览保留元素重叠,表格下方跟随元素按设计坐标绝对定位并透传层级 z-index。</li>
|
|
639
|
+
<li>打印页眉页脚区域贴页面底部,修复页边距失效。</li>
|
|
640
|
+
<li>条形码渲染缺少 <code>object-fit: contain</code>。</li>
|
|
641
|
+
<li>修复 canvas 测试在 vitest v4 + happy-dom 环境下 <code>localStorage</code> 未定义的问题,补充 mock 以兼容测试环境。</li>
|
|
642
|
+
</ul>
|
|
643
|
+
|
|
644
|
+
<h2>V1.0.0<small>(2026-09-02)</small></h2>
|
|
645
|
+
|
|
646
|
+
<h3>新增</h3>
|
|
647
|
+
<ul>
|
|
648
|
+
<li>首次开源发布。</li>
|
|
649
|
+
<li><code>@worm-vue3-print/core</code>:模板表达式引擎与同构渲染管线(HTML 生成 / 分页 / 数据绑定)。</li>
|
|
650
|
+
<li><code>@worm-vue3-print/canvas</code>:Vue 3 可视化打印模板设计器画布。</li>
|
|
651
|
+
<li>渲染微服务拆分为独立仓库 <code>worm-vue3-print-render</code>(仅 Docker 部署,不上 npm)。</li>
|
|
652
|
+
</ul>
|
|
653
|
+
|
|
654
|
+
<blockquote>
|
|
655
|
+
<p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
|
|
656
|
+
</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;
|