@worm-vue3-print/common 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +2 -2
  2. package/dist/browser-bundle.d.ts +1 -1
  3. package/dist/common.css +1 -1
  4. package/dist/common.js +122 -88
  5. package/dist/core/default-template.d.ts +1 -1
  6. package/dist/core/format.d.ts +1 -1
  7. package/dist/core/h.d.ts +1 -1
  8. package/dist/core/icons.d.ts +1 -1
  9. package/dist/core/store.d.ts +1 -1
  10. package/dist/index.cjs +33 -11
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js +2869 -2697
  13. package/dist/print-designer.d.ts +2 -1
  14. package/dist/shell/binding.d.ts +1 -1
  15. package/dist/shell/canvas.d.ts +3 -1
  16. package/dist/shell/code.d.ts +1 -1
  17. package/dist/shell/color-picker.d.ts +1 -1
  18. package/dist/shell/controls.d.ts +1 -1
  19. package/dist/shell/crop-anchor.d.ts +1 -1
  20. package/dist/shell/elements.d.ts +1 -1
  21. package/dist/shell/expression-editor.d.ts +1 -1
  22. package/dist/shell/flow-list.d.ts +3 -2
  23. package/dist/shell/font-select.d.ts +1 -1
  24. package/dist/shell/format-bar.d.ts +1 -1
  25. package/dist/shell/help-content/changelog.d.ts +1 -1
  26. package/dist/shell/help-content/faq.d.ts +1 -1
  27. package/dist/shell/help-content/features.d.ts +1 -1
  28. package/dist/shell/help-content/getting-started.d.ts +1 -1
  29. package/dist/shell/help-content/index.d.ts +1 -1
  30. package/dist/shell/help-content/shortcuts.d.ts +1 -1
  31. package/dist/shell/help-modal.d.ts +1 -1
  32. package/dist/shell/page-extras.d.ts +1 -1
  33. package/dist/shell/panels.d.ts +1 -1
  34. package/dist/shell/prop-group.d.ts +1 -1
  35. package/dist/shell/property-panel.d.ts +1 -1
  36. package/dist/shell/property-search.d.ts +1 -1
  37. package/dist/shell/ruler.d.ts +1 -1
  38. package/dist/shell/table-props.d.ts +1 -1
  39. package/dist/shell/table.d.ts +1 -1
  40. package/dist/shell/toolbar-overflow.d.ts +1 -1
  41. package/dist/shell/toolbar.d.ts +1 -1
  42. package/dist/shell/watermark.d.ts +1 -1
  43. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@worm-vue3-print/core/designer"),D=require("@worm-vue3-print/core"),Vo=require("@worm-vue3-print/core/browser"),wn=require("jsbarcode");function a(o,e={},t=[]){return{tag:o,props:e,children:t}}const Sn="http://www.w3.org/2000/svg",pr=new Set(["draggable","contenteditable","spellcheck"]),ur=new Set(["indeterminate"]);function hr(o){return o==="svg"||o==="path"||o==="circle"||o==="rect"||o==="line"||o==="g"}function me(o,e){if(typeof o=="string"){const l=document.createTextNode(o);return e.appendChild(l),l}if(o instanceof Node)return e.appendChild(o),o;const{tag:t,props:i,children:n}=o,r=hr(t)?document.createElementNS(Sn,t):document.createElement(t);for(const[l,s]of Object.entries(i))if(!(s==null||s===!1))if(l==="class")r.setAttribute("class",String(s));else if(l==="style")typeof s=="string"?r.style.cssText=s:Object.assign(r.style,s);else if(l==="html")r.innerHTML=String(s);else if(l==="text")r.textContent=String(s);else if(l.startsWith("on")&&typeof s=="function")r.addEventListener(l.slice(2).toLowerCase(),s);else if(l==="dataset")for(const[c,u]of Object.entries(s))r.dataset[c]=u;else ur.has(l)?r[l]=!0:typeof s=="boolean"?s&&r.setAttribute(l,pr.has(l)?"true":""):r.setAttribute(l,String(s));for(const l of n)me(l,r);return e.appendChild(r),r}function Tn(o){for(;o.firstChild;)o.removeChild(o.firstChild)}const fr=Sn;function Rt(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const No="开启拼版后只能有一个设计页面";function Xo(o){const e=(t,i)=>(t??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&p.syncTableElementSize(r),{id:n.id||p.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...o,margins:{...o.margins},header:{height:o.header?.height??10,elements:[]},footer:{height:o.footer?.height??10,elements:[]},guides:[...o.guides??[]],elements:[...e(o.elements??[],"content"),...e(o.header?.elements??[],"header"),...e(o.footer?.elements??[],"footer")]}}function En(o){const e=o.elements,t=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...o,header:{...o.header,elements:t("header")},footer:{...o.footer,elements:t("footer")},elements:t("content"),guides:[...o.guides??[]]}}function Ri(o){const e=(i,n)=>{const r=Xo(p.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!o)return[e(Rt(),0)];const t=Array.isArray(o.pages)?o.pages:[o];return t.length?t.map(e):[e(Rt(),0)]}const pt=o=>JSON.parse(JSON.stringify(o));class kn{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=p.useAlign();group=p.useGroup();constructor(e={}){if(this.pages=Ri(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const t=this.pages[0];t.elements=[...t.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const t of[...this.listeners])t()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const e=this.pages[this.activePageIndex]??Rt();this.pages.push(Xo({...Rt(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let t=this.pages.length+1;for(;e.has(`页面 ${t}`);)t++;return`页面 ${t}`}duplicatePage(e){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const t=pt(this.pages[e]);t.name=`${t.name??`页面 ${e+1}`} 副本`,t.elements=t.elements.map(i=>({...i,id:p.generateId()})),this.pages.splice(e+1,0,t),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,t){this.recordHistory(),this.pages[e].name=t,this.emit()}movePage(e,t){if(t<0||t>=this.pages.length||e===t)return;this.recordHistory();const[i]=this.pages.splice(e,1);this.pages.splice(t,0,i),this.activePageIndex=t,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,t=!1){if(t){const i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,t=!1){if(t){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(t=>t.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=[...i,{id:p.generateId(),type:e,position:Math.round(t*10)/10}],this.emit()}moveGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(t*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(t=>t.id!==e),this.emit()}addElement(e,t={},i){const n=p.createRuntimeElement(e,t);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,t={},i,n=!1){const r=n?p.createFieldLabelElement(e):p.createFieldElement(e);return Object.assign(r.options,t),i&&!this.placeAtDropPoint(r,i)||(this.recordHistory(),this.templateData.elements.push(r),this.select(new Set([r.id])),this.emit()),r}placeAtDropPoint(e,t){const i=this.templateData,n=p.zoneFromPaperPoint(i,t.x,t.y);if(n!=="content"&&!p.ZONE_ALLOWED_TYPES.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=p.getZoneRects(i)[n];return e.zone=n,e.options.left=t.x-r.left,e.options.top=t.y-r.top,n!=="content"&&p.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,t){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...t}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[t,i]of this.live){const n=e.find(r=>r.id===t);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const t=this.templateData.elements.find(i=>i.id===e);return!t||t.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let t=!1;for(const i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||p.finalizeElementZone(i,this.templateData).rejected&&(t=!0)}t&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,t,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,t),n.printElementType.type==="table"&&p.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const t=this.templateData.elements,i=t.filter(r=>this.selectedIds.has(r.id)),n=t.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=t.findIndex(c=>this.selectedIds.has(c.id)),l=e==="up"?r+1:r-1;if(l<0||l>=t.length)return;const s=[...t];[s[r],s[l]]=[s[l],s[r]],this.templateData.elements=s}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(t=>this.selectedIds.has(t.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=pt(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const t=new Map;for(const r of this.clipboard){const l=r.options.groupId;l&&t.set(l,(t.get(l)??0)+1)}const i=new Map;for(const[r,l]of t)i.set(r,l>=2?p.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const l=pt(r);l.id=p.generateId(),l.options.left+=e,l.options.top+=e,l.options.groupId=l.options.groupId?i.get(l.options.groupId):void 0,n.push(l)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,t){const i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=t;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();e&&(this.redoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,t=p.MIN_SCALE_PERCENT){this.scale=Math.max(t,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(En),t=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(t)}loadTemplate(e){this.pages=Ri(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return p.getPaperDimensions(this.templateData)}}const Qe=Symbol("mixed"),Eo=new Set(["text","longText"]),mr=["top","right","bottom","left"],gr={on:!0,off:!1,mixed:Qe};function zi(o){const e=p.resolveBorderEdgeStates(o),t={};for(const i of mr)t[i]=gr[e[i]];return t}const br=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class xr{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(t=>t.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return[];const i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const l=t[n]?.cells[r];l&&!l.merged&&i.push(l)}return i}get textTargets(){return this.selectedElements.filter(e=>Eo.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const t=e[0];return e.every(i=>i===t)?t:Qe}hasToken(e,t){return(e??"").split(/\s+/).includes(t)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const t=e.map(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:t.every(Boolean)?!0:t.some(Boolean)?Qe:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?Qe:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?Qe:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const t=this.targetCells;t.length&&(t.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(s=>{"fontFamily"in e&&(s.fontFamily=e.fontFamily),"fontSize"in e&&(s.fontSize=e.fontSize),"color"in e&&(s.color=e.color),"backgroundColor"in e&&(s.backgroundColor=e.backgroundColor),"textAlign"in e&&(s.align=e.textAlign),"verticalAlign"in e&&(s.valign=e.verticalAlign)});return}const t=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(s=>s in e),l="backgroundColor"in e;!(t.length&&r)&&!(i.length&&l)||(t.forEach(s=>{const c=s.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)}),l&&i.forEach(s=>{s.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const i=this.values.bold!==!0;this.writeCells(n=>{n.fontWeight=i?"bold":void 0});return}const e=this.values.bold!==!0,t=this.textTargets;t.length&&(t.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const t=this.textTargets;if(!t.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;t.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),l=r.indexOf(e);i&&l<0&&r.push(e),!i&&l>=0&&r.splice(l,1),n.options.textDecoration=r.length?r.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,p.resolveCellGroupMode(t,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=p.resolveCellBorderDisplay(t,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const t=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=t,t===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,t){const i=this.selectedElements;i.length&&(i.forEach(n=>{p.applyElementBorderPreset(n.options,e,t)}),this.commit())}applyCellBorderPreset(e,t){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(p.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,t),this.commit())}applyCellBorderEdges(e,t,i){this.writeCells(n=>{for(const r of e)p.setCellBorderEdge(n,r,i?t:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?zi(e.map(t=>t.borders)):null}toggleCellEdge(e,t){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],t,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?zi(e.map(t=>p.elementVisibleBorders(t.options))):null}toggleElementEdge(e,t){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>p.setElementBorderEdgeVisible(r.options,e,n,t)),this.commit()}applyBorderPreset(e){const t=this.borderStyle===null;if(this.context==="cells"){const i=t&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(t||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const t=this.selectedElements;t.length&&(t.forEach(i=>p.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const t={};for(const i of p.ELEMENT_BORDER_SIDES){const n=e[i];n&&(t[i]={...n})}return t}pickPainterSource(e=!1){const t=this.selectedElements[0];if(!t)return!1;const i=t.options,n=t.printElementType.type;return this.painterSnapshot={text:Eo.has(n)?Object.fromEntries(br.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:p.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=t.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const t=this.painterSnapshot;if(!t||e.options.locked||e.id===this.painterSource)return!1;const i=e.options,n=e.printElementType.type;return t.text&&Eo.has(n)&&Object.assign(i,t.text),i.backgroundColor=t.backgroundColor,t.border&&p.acceptsElementBorder(n)&&(i.borderWidth=t.border.borderWidth,i.borderStyle=t.border.borderStyle,i.borderColor=t.border.borderColor,i.borders=this.clonePainterBorders(t.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let t=!1;e.forEach(i=>{t=this.applyPainter(i)||t}),t&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const t=e.target?.tagName;t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||this.cancelPainter()}}function Fi(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,i=Array(e);t<e;t++)i[t]=o[t];return i}function vr(o){if(Array.isArray(o))return o}function yr(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var i,n,r,l,s=[],c=!0,u=!1;try{if(r=(t=t.call(o)).next,e!==0)for(;!(c=(i=r.call(t)).done)&&(s.push(i.value),s.length!==e);c=!0);}catch(h){u=!0,n=h}finally{try{if(!c&&t.return!=null&&(l=t.return(),Object(l)!==l))return}finally{if(u)throw n}}return s}}function wr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sr(o,e){return vr(o)||yr(o,e)||Tr(o,e)||wr()}function Tr(o,e){if(o){if(typeof o=="string")return Fi(o,e);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Fi(o,e):void 0}}const Cn=Object.entries,Pi=Object.setPrototypeOf,Er=Object.isFrozen,kr=Object.getPrototypeOf,Cr=Object.getOwnPropertyDescriptor;let re=Object.freeze,le=Object.seal,ft=Object.create,An=typeof Reflect<"u"&&Reflect,$o=An.apply,Bo=An.construct;re||(re=function(e){return e});le||(le=function(e){return e});$o||($o=function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(t,n)});Bo||(Bo=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return new e(...i)});const Xe=ne(Array.prototype.forEach),Ar=ne(Array.prototype.lastIndexOf),Li=ne(Array.prototype.pop),Tt=ne(Array.prototype.push),Dr=ne(Array.prototype.splice),gt=Array.isArray,Mt=ne(String.prototype.toLowerCase),ko=ne(String.prototype.toString),Ii=ne(String.prototype.match),Et=ne(String.prototype.replace),Oi=ne(String.prototype.indexOf),Mr=ne(String.prototype.trim),_r=ne(Number.prototype.toString),Rr=ne(Boolean.prototype.toString),Ni=typeof BigInt>"u"?null:ne(BigInt.prototype.toString),$i=typeof Symbol>"u"?null:ne(Symbol.prototype.toString),ve=ne(Object.prototype.hasOwnProperty),kt=ne(Object.prototype.toString),de=ne(RegExp.prototype.test),Ve=zr(TypeError);function ne(o){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return $o(o,e,i)}}function zr(o){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Bo(o,t)}}function B(o,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(Pi&&Pi(o,null),!gt(e))return o;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=t(n);r!==n&&(Er(e)||(e[i]=r),n=r)}o[n]=!0}return o}function Fr(o){for(let e=0;e<o.length;e++)ve(o,e)||(o[e]=null);return o}function ke(o){const e=ft(null);for(const i of Cn(o)){var t=Sr(i,2);const n=t[0],r=t[1];ve(o,n)&&(gt(r)?e[n]=Fr(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ke(r):e[n]=r)}return e}function Pr(o){switch(typeof o){case"string":return o;case"number":return _r(o);case"boolean":return Rr(o);case"bigint":return Ni?Ni(o):"0";case"symbol":return $i?$i(o):"Symbol()";case"undefined":return kt(o);case"function":case"object":{if(o===null)return kt(o);const e=o,t=_e(e,"toString");if(typeof t=="function"){const i=t(e);return typeof i=="string"?i:kt(i)}return kt(o)}default:return kt(o)}}function _e(o,e){for(;o!==null;){const i=Cr(o,e);if(i){if(i.get)return ne(i.get);if(typeof i.value=="function")return ne(i.value)}o=kr(o)}function t(){return null}return t}function Lr(o){try{return de(o,""),!0}catch{return!1}}const Bi=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Co=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ao=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ir=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Do=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Or=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hi=re(["#text"]),Wi=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Mo=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ui=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Nr=le(/{{[\w\W]*|^[\w\W]*}}/g),$r=le(/<%[\w\W]*|^[\w\W]*%>/g),Br=le(/\${[\w\W]*/g),Hr=le(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wr=le(/^aria-[\-\w]+$/),Gi=le(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ur=le(/^(?:\w+script|data):/i),Gr=le(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qr=le(/^html$/i),Kr=le(/^[a-z][.\w]*(-[.\w]+)+$/i),qi=le(/<[/\w!]/g),Ki=le(/<[/\w]/g),jr=le(/<\/no(script|embed|frames)/i),Yr=le(/\/>/i),Ee={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Dn=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Vr=re(B({},Dn)),Xr=(function(){const o={};return Xe(Dn,e=>{o[e]=le(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),re(o)})(),Zr=function(){return typeof window>"u"?null:window},Qr=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},ji=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},He=function(e,t,i,n){return ve(e,t)&&gt(e[t])?B(n.base?ke(n.base):{},e[t],n.transform):i},_o=function(e,t,i){const n=ve(e,t)?e[t]:void 0;return n&&typeof n=="object"?ke(n):i()};function Mn(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zr();const e=k=>Mn(k);if(e.version="3.4.14",e.removed=[],!o||!o.document||o.document.nodeType!==Ee.document||!o.Element)return e.isSupported=!1,e;let t=o.document;const i=t,n=i.currentScript;o.DocumentFragment;const r=o.HTMLTemplateElement,l=o.Node,s=o.Element,c=o.NodeFilter,u=o.NamedNodeMap;u===void 0&&(o.NamedNodeMap||o.MozNamedAttrMap),o.HTMLFormElement;const h=o.DOMParser,m=o.trustedTypes,g=s.prototype,v=_e(g,"cloneNode"),S=_e(g,"remove"),b=_e(g,"nextSibling"),T=_e(g,"childNodes"),E=_e(g,"parentNode"),A=_e(g,"shadowRoot"),P=_e(g,"attributes"),F=l&&l.prototype?_e(l.prototype,"nodeType"):null,U=l&&l.prototype?_e(l.prototype,"nodeName"):null,se=l&&l.prototype?_e(l.prototype,"ownerDocument"):null,V=function(d){return F?F(d):d.nodeType},L=function(d){return U?U(d):d.nodeName};if(typeof r=="function"){const k=t.createElement("template");k.content&&k.content.ownerDocument&&(t=k.content.ownerDocument)}let _,q="",X,pe=!1,Q=0;const y=function(){if(Q>0)throw Ve('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.')},W=function(d){y(),Q++;try{return _.createHTML(d)}finally{Q--}},ae=function(d){y(),Q++;try{return _.createScriptURL(d)}finally{Q--}},Pe=function(){return pe||(X=Qr(m,n),pe=!0),X},I=t,te=I.implementation,qe=I.createNodeIterator,ue=I.createDocumentFragment,Ke=I.getElementsByTagName,ot=i.importNode;let G=ji();e.isSupported=typeof Cn=="function"&&typeof E=="function"&&te&&te.createHTMLDocument!==void 0;const co=Nr,Pt=$r,Lt=Br,po=Hr,je=Wr,we=Ur,Se=Gr,uo=Kr;let It=Gi,K=null;const xt=B({},[...Bi,...Co,...Ao,...Do,...Hi]);let j=null;const it=B({},[...Wi,...Mo,...Ui,...Xt]);let he=Object.seal(ft(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ot=null;const $=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let vt=!0,nt=!0,x=!1,N=!0,J=!1,oe=!0,De=!1,yt=!1,Nt=null,$t=null,ho=!1,rt=!1,Bt=!1,Ht=!1,si=!0,di=!1;const ci="user-content-";let fo=!0,mo=!1,at={},lt=null;const pi=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let ui=null;const hi=B({},["audio","video","img","source","image","track"]);let fi=null;const mi=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Wt="http://www.w3.org/1998/Math/MathML",Ut="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let st=Re,go=!1,bo=null;const Vn=B({},[Wt,Ut,Re],ko),gi=re(["mi","mo","mn","ms","mtext"]);let xo=B({},gi);const bi=re(["annotation-xml"]);let vo=B({},bi);const Xn=B({},["title","style","font","a","script"]);let wt=null;const Zn=["application/xhtml+xml","text/html"],Qn="text/html";let ie=null,dt=null;const Jn=t.createElement("form"),xi=function(d){return d instanceof RegExp||d instanceof Function},yo=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(dt&&dt===d)return;(!d||typeof d!="object")&&(d={}),d=ke(d),wt=Zn.indexOf(d.PARSER_MEDIA_TYPE)===-1?Qn:d.PARSER_MEDIA_TYPE,ie=wt==="application/xhtml+xml"?ko:Mt,K=He(d,"ALLOWED_TAGS",xt,{transform:ie}),j=He(d,"ALLOWED_ATTR",it,{transform:ie}),bo=He(d,"ALLOWED_NAMESPACES",Vn,{transform:ko}),fi=He(d,"ADD_URI_SAFE_ATTR",mi,{transform:ie,base:mi}),ui=He(d,"ADD_DATA_URI_TAGS",hi,{transform:ie,base:hi}),lt=He(d,"FORBID_CONTENTS",pi,{transform:ie}),Te=He(d,"FORBID_TAGS",ke({}),{transform:ie}),Ot=He(d,"FORBID_ATTR",ke({}),{transform:ie}),at=ve(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?ke(d.USE_PROFILES):d.USE_PROFILES:!1,vt=d.ALLOW_ARIA_ATTR!==!1,nt=d.ALLOW_DATA_ATTR!==!1,x=d.ALLOW_UNKNOWN_PROTOCOLS||!1,N=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,J=d.SAFE_FOR_TEMPLATES||!1,oe=d.SAFE_FOR_XML!==!1,De=d.WHOLE_DOCUMENT||!1,rt=d.RETURN_DOM||!1,Bt=d.RETURN_DOM_FRAGMENT||!1,Ht=d.RETURN_TRUSTED_TYPE||!1,ho=d.FORCE_BODY||!1,si=d.SANITIZE_DOM!==!1,di=d.SANITIZE_NAMED_PROPS||!1,fo=d.KEEP_CONTENT!==!1,mo=d.IN_PLACE||!1,It=Lr(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Gi,st=typeof d.NAMESPACE=="string"?d.NAMESPACE:Re,xo=_o(d,"MATHML_TEXT_INTEGRATION_POINTS",()=>B({},gi)),vo=_o(d,"HTML_INTEGRATION_POINTS",()=>B({},bi));const f=_o(d,"CUSTOM_ELEMENT_HANDLING",()=>ft(null));if(he=ft(null),ve(f,"tagNameCheck")&&xi(f.tagNameCheck)&&(he.tagNameCheck=f.tagNameCheck),ve(f,"attributeNameCheck")&&xi(f.attributeNameCheck)&&(he.attributeNameCheck=f.attributeNameCheck),ve(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(he.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),le(he),J&&(nt=!1),Bt&&(rt=!0),at&&(K=B({},Hi),j=ft(null),at.html===!0&&(B(K,Bi),B(j,Wi)),at.svg===!0&&(B(K,Co),B(j,Mo),B(j,Xt)),at.svgFilters===!0&&(B(K,Ao),B(j,Mo),B(j,Xt)),at.mathMl===!0&&(B(K,Do),B(j,Ui),B(j,Xt))),$.tagCheck=null,$.attributeCheck=null,ve(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?$.tagCheck=d.ADD_TAGS:gt(d.ADD_TAGS)&&(K===xt&&(K=ke(K)),B(K,d.ADD_TAGS,ie))),ve(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?$.attributeCheck=d.ADD_ATTR:gt(d.ADD_ATTR)&&(j===it&&(j=ke(j)),B(j,d.ADD_ATTR,ie))),ve(d,"ADD_FORBID_CONTENTS")&&gt(d.ADD_FORBID_CONTENTS)&&(lt===pi&&(lt=ke(lt)),B(lt,d.ADD_FORBID_CONTENTS,ie)),fo&&(K["#text"]=!0),De&&B(K,["html","head","body"]),K.table&&(B(K,["tbody"]),delete Te.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ve('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ve('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const w=_;_=d.TRUSTED_TYPES_POLICY;try{q=W("")}catch(C){throw _=w,C}}else d.TRUSTED_TYPES_POLICY===null?(_=void 0,q=""):(_===void 0&&(_=Pe()),_&&typeof q=="string"&&(q=W("")));re&&re(d),dt=d},vi=B({},[...Co,...Ao,...Ir]),yi=B({},[...Do,...Or]),er=function(d,f,w){return f.namespaceURI===Re?d==="svg":f.namespaceURI===Wt?d==="svg"&&(w==="annotation-xml"||xo[w]):!!vi[d]},tr=function(d,f,w){return f.namespaceURI===Re?d==="math":f.namespaceURI===Ut?d==="math"&&vo[w]:!!yi[d]},or=function(d,f,w){return f.namespaceURI===Ut&&!vo[w]||f.namespaceURI===Wt&&!xo[w]?!1:!yi[d]&&(Xn[d]||!vi[d])},ir=function(d){let f=E(d);(!f||!f.tagName)&&(f={namespaceURI:st,tagName:"template"});const w=Mt(d.tagName),C=Mt(f.tagName);return bo[d.namespaceURI]?d.namespaceURI===Ut?er(w,f,C):d.namespaceURI===Wt?tr(w,f,C):d.namespaceURI===Re?or(w,f,C):!!(wt==="application/xhtml+xml"&&bo[d.namespaceURI]):!1},Be=function(d){Tt(e.removed,{element:d});try{E(d).removeChild(d)}catch{if(S(d),!E(d))throw Ve("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},wi=function(d,f,w){try{d.removeAttributeNode(f)}catch{try{d.removeAttribute(w)}catch{}}},Gt=function(d){qt(d);const f=T(d);if(f){const C=[];Xe(f,M=>{Tt(C,M)}),Xe(C,M=>{try{S(M)}catch{}})}const w=P(d);if(w)for(let C=w.length-1;C>=0;--C){const M=w[C],z=M&&M.name;typeof z=="string"&&wi(d,M,z)}},Ye=function(d,f,w){if(!w)try{w=f.getAttributeNode(d)}catch{w=null}Tt(e.removed,{attribute:w||null,from:f});try{w?f.removeAttributeNode(w):f.removeAttribute(d)}catch{try{f.removeAttribute(d)}catch{}}if(d==="is")if(rt||Bt)try{Be(f)}catch{}else try{f.setAttribute(d,"")}catch{}},nr=function(d){const f=P(d);if(f)for(let w=f.length-1;w>=0;--w){const C=f[w],M=C&&C.name;typeof M!="string"||j[ie(M)]||wi(d,C,M)}},qt=function(d){const f=[d];for(;f.length>0;){const w=f.pop();V(w)===Ee.element&&nr(w);const M=T(w);if(M)for(let z=M.length-1;z>=0;--z)f.push(M[z])}},Si=function(d,f){return oe?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},rr=function(d){if(!oe)return;const f=[d];for(;f.length>0;){const w=f.pop(),C=V(w);if(C===Ee.processingInstruction||C===Ee.comment&&de(Ki,w.data)){try{S(w)}catch{}continue}if(C===Ee.element){const z=w,Y=ie(L(w));try{z.hasAttribute&&z.hasAttribute("patchsrc")&&z.removeAttribute("patchsrc"),z.hasAttribute&&z.hasAttribute("for")&&Si("for",Y)&&z.removeAttribute("for")}catch{}}const M=T(w);if(M)for(let z=M.length-1;z>=0;--z)f.push(M[z])}},Ti=function(d){let f=null,w=null;if(ho)d="<remove></remove>"+d;else{const z=Ii(d,/^[\r\n\t ]+/);w=z&&z[0]}wt==="application/xhtml+xml"&&st===Re&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const C=_?W(d):d;if(st===Re)try{f=new h().parseFromString(C,wt)}catch{}if(!f||!f.documentElement){f=te.createDocument(st,"template",null);try{f.documentElement.innerHTML=go?q:C}catch{}}const M=f.body||f.documentElement;return d&&w&&M.insertBefore(t.createTextNode(w),M.childNodes[0]||null),st===Re?Ke.call(f,De?"html":"body")[0]:De?f.documentElement:M},Ei=function(d){const f=se?se(d):d.ownerDocument;return qe.call(f||d,d,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(d){return d=Et(d,co," "),d=Et(d,Pt," "),d=Et(d,Lt," "),d},wo=function(d){var f;d.normalize();const w=se?se(d):d.ownerDocument,C=qe.call(w||d,d,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let M=C.nextNode();for(;M;)M.data=Kt(M.data),M=C.nextNode();const z=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");z&&Xe(z,Y=>{ct(Y.content)&&wo(Y.content)})},jt=function(d){const f=U?U(d):null;return typeof f!="string"||ie(f)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==P(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==F(d)||d.childNodes!==T(d)},ct=function(d){if(!F||typeof d!="object"||d===null)return!1;try{return F(d)===Ee.documentFragment}catch{return!1}},St=function(d){if(!F||typeof d!="object"||d===null)return!1;try{return typeof F(d)=="number"}catch{return!1}};function ze(k,d,f){k.length!==0&&Xe(k,w=>{w.call(e,d,f,dt)})}const ar=function(d,f){return!!(oe&&d.hasChildNodes()&&!St(d.firstElementChild)&&de(qi,d.textContent)&&de(qi,d.innerHTML)||oe&&d.namespaceURI===Re&&Vr[f]&&(St(d.firstElementChild)||typeof d.textContent=="string"&&de(Xr[f],d.textContent))||d.nodeType===Ee.processingInstruction||oe&&d.nodeType===Ee.comment&&de(Ki,d.data))},Yt=function(d,f){if(d instanceof RegExp)return de(d,f);if(d instanceof Function){for(var w=arguments.length,C=new Array(w>2?w-2:0),M=2;M<w;M++)C[M-2]=arguments[M];return!!d(f,...C)}return!1},lr=function(d,f,w){if(!Te[f]&&Mi(f)&&Yt(he.tagNameCheck,f))return!1;if(fo&&!lt[f]){const C=E(d),M=T(d);if(M&&C){const z=M.length;for(let Y=z-1;Y>=0;--Y){const Z=d===w?v(M[Y],!0):M[Y];C.insertBefore(Z,b(d))}}}return Be(d),!0},ki=function(d,f,w,C){return d.length===0?f:f===w||f===C?ke(f):f},Ci=function(d,f){return d===f||E(d)!==null?!1:(mo&&qt(d),!0)},Ai=function(d,f){if(ze(G.beforeSanitizeElements,d,null),Ci(d,f))return!0;if(jt(d))return Be(d),!0;const w=ie(L(d));if(K=ki(G.uponSanitizeElement,K,xt,Nt),ze(G.uponSanitizeElement,d,{tagName:w,allowedTags:K}),Ci(d,f))return!0;if(ar(d,w))return Be(d),!0;if(Te[w]||!($.tagCheck instanceof Function&&$.tagCheck(w))&&!K[w]){const M=lr(d,w,f);return M===!1&&ze(G.afterSanitizeElements,d,null),M}if(V(d)===Ee.element&&!ir(d)||(w==="noscript"||w==="noembed"||w==="noframes")&&de(jr,d.innerHTML))return Be(d),!0;if(J&&d.nodeType===Ee.text){const M=Kt(d.textContent);d.textContent!==M&&(Tt(e.removed,{element:d.cloneNode()}),d.textContent=M)}return ze(G.afterSanitizeElements,d,null),!1},Di=function(d,f,w){if(Ot[f]||Si(f,d)||si&&(f==="id"||f==="name")&&(w in t||w in Jn))return!1;const C=j[f]||$.attributeCheck instanceof Function&&$.attributeCheck(f,d);return nt&&de(po,f)||vt&&de(je,f)?!0:C?fi[f]||de(It,Et(w,Se,""))||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Oi(w,"data:")===0&&ui[d]||x&&!de(we,Et(w,Se,""))?!0:!w:Mi(d)&&Yt(he.tagNameCheck,d)&&Yt(he.attributeNameCheck,f,d)||f==="is"&&he.allowCustomizedBuiltInElements&&Yt(he.tagNameCheck,w)},sr=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Mi=function(d){return!sr[Mt(d)]&&de(uo,d)},dr=function(d,f,w,C){if(_&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!w)switch(m.getAttributeType(d,f)){case"TrustedHTML":return W(C);case"TrustedScriptURL":return ae(C)}return C},cr=function(d,f,w,C){try{w?d.setAttributeNS(w,f,C):d.setAttribute(f,C),jt(d)?Be(d):Li(e.removed)}catch{Ye(f,d)}},_i=function(d){ze(G.beforeSanitizeAttributes,d,null);const f=d.attributes;if(!f||jt(d))return;j=ki(G.uponSanitizeAttribute,j,it,$t);const w={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:j,forceKeepAttr:void 0};let C=f.length;const M=ie(d.nodeName);for(;C--;){const z=f[C],Y=z.name,Z=z.namespaceURI,be=z.value,xe=ie(Y),To=be;let fe=Y==="value"?To:Mr(To);if(w.attrName=xe,w.attrValue=fe,w.keepAttr=!0,w.forceKeepAttr=void 0,ze(G.uponSanitizeAttribute,d,w),fe=w.attrValue,di&&(xe==="id"||xe==="name")&&Oi(fe,ci)!==0&&(Ye(Y,d,z),fe=ci+fe),oe&&de(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,fe)){Ye(Y,d,z);continue}if(xe==="attributename"&&Ii(fe,"href")){Ye(Y,d,z);continue}if(!w.forceKeepAttr){if(!w.keepAttr){Ye(Y,d,z);continue}if(!N&&de(Yr,fe)){Ye(Y,d,z);continue}if(J&&(fe=Kt(fe)),!Di(M,xe,fe)){Ye(Y,d,z);continue}fe=dr(M,xe,Z,fe),fe!==To&&cr(d,Y,Z,fe)}}ze(G.afterSanitizeAttributes,d,null)},Vt=function(d){let f=null;const w=Ei(d);for(ze(G.beforeSanitizeShadowDOM,d,null);f=w.nextNode();)if(ze(G.uponSanitizeShadowNode,f,null),Ai(f,d),_i(f),ct(f.content)&&Vt(f.content),V(f)===Ee.element){const C=A(f);ct(C)&&(So(C),Vt(C))}ze(G.afterSanitizeShadowDOM,d,null)},So=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const w=f.pop();if(w.shadow){Vt(w.shadow);continue}const C=w.node,z=V(C)===Ee.element,Y=T(C);if(Y)for(let Z=Y.length-1;Z>=0;--Z)f.push({node:Y[Z],shadow:null});if(z){const Z=U?U(C):null;if(typeof Z=="string"&&ie(Z)==="template"){const be=C.content;ct(be)&&f.push({node:be,shadow:null})}}if(z){const Z=A(C);ct(Z)&&f.push({node:null,shadow:Z},{node:Z,shadow:null})}}};return e.sanitize=function(k){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,w=null,C=null,M=null;if(go=!k,go&&(k="<!-->"),typeof k!="string"&&!St(k)&&(k=Pr(k),typeof k!="string"))throw Ve("dirty is not a string, aborting");if(!e.isSupported)return k;yt?(K=Nt,j=$t):yo(d),(G.uponSanitizeElement.length>0||G.uponSanitizeAttribute.length>0)&&(K=ke(K)),G.uponSanitizeAttribute.length>0&&(j=ke(j)),e.removed=[];const z=mo&&typeof k!="string"&&St(k);if(z){rr(k);const be=L(k);if(typeof be=="string"){const xe=ie(be);if(!K[xe]||Te[xe])throw Gt(k),Ve("root node is forbidden and cannot be sanitized in-place")}if(jt(k))throw Gt(k),Ve("root node is clobbered and cannot be sanitized in-place");try{So(k)}catch(xe){throw Gt(k),xe}}else if(St(k))f=Ti("<!---->"),w=f.ownerDocument.importNode(k,!0),w.nodeType===Ee.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?f=w:f.appendChild(w),So(w);else{if(!rt&&!J&&!De&&k.indexOf("<")===-1)return _&&Ht?W(k):k;if(f=Ti(k),!f)return rt?null:Ht?q:""}f&&ho&&Be(f.firstChild);const Y=z?k:f;try{const be=Ei(Y);for(;C=be.nextNode();)Ai(C,Y),_i(C),ct(C.content)&&Vt(C.content)}catch(be){throw z&&(Gt(k),Xe(e.removed,xe=>{xe.element&&qt(xe.element)})),be}if(z)return Xe(e.removed,be=>{be.element&&qt(be.element)}),J&&wo(k),k;if(rt){if(J&&wo(f),Bt)for(M=ue.call(f.ownerDocument);f.firstChild;)M.appendChild(f.firstChild);else M=f;return(j.shadowroot||j.shadowrootmode)&&(M=ot.call(i,M,!0)),M}let Z=De?f.outerHTML:f.innerHTML;return De&&K["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&de(qr,f.ownerDocument.doctype.name)&&(Z="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
3
- `+Z),J&&(Z=Kt(Z)),_&&Ht?W(Z):Z},e.setConfig=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yo(k),yt=!0,Nt=K,$t=j},e.clearConfig=function(){dt=null,yt=!1,Nt=null,$t=null,_=X,q=""},e.isValidAttribute=function(k,d,f){dt||yo({});const w=ie(k),C=ie(d);return Di(w,C,f)},e.addHook=function(k,d){typeof d=="function"&&ve(G,k)&&Tt(G[k],d)},e.removeHook=function(k,d){if(ve(G,k)){if(d!==void 0){const f=Ar(G[k],d);return f===-1?void 0:Dr(G[k],f,1)[0]}return Li(G[k])}},e.removeHooks=function(k){ve(G,k)&&(G[k]=[])},e.removeAllHooks=function(){G=ji()},e}var Jr=Mn();const ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ta(o){const e=o.options;return p.resolveBarcodeDesignValue(e.formatter,void 0,String(e.testData||e.title||""))||"条码"}function oa(o){return a("div",{class:"print-qrcode",dataset:{codeId:o.id,codeKind:"qrcode"}})}function ia(o){const e=o.options;return a("div",{class:"print-barcode",dataset:{codeId:o.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:ea[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function na(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}function ra(o,e){const t=o.options,i=p.barcodeUnitsPerModule(t.barWidth),n=p.barcodeQuietZoneModules(t.barQuietZone),r=l=>{wn(e,ta(o),{format:String(t.barcodeType||"CODE128"),width:i,height:l*i,displayValue:!t.hideTitle,fontSize:(t.fontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*i,margin:0,marginLeft:n*i,marginRight:n*i,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*i});const s=na(e);return s?{widthUnits:s.width,heightUnits:s.height}:null};try{const l=p.layoutBarcodeSize({barHeightMm:t.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(t.width,t.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(t.height,t.maxHeight),dpi:t.printerDpi,barWidth:t.barWidth,measure:r});e.style.width=l.size?`${l.size.widthMm}mm`:"",e.style.height=l.size?`${l.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function aa(o,e){const t=o.options,i=p.resolveBarcodeDesignValue(t.formatter,void 0,String(t.testData||t.title||""))||"二维码";e.replaceChildren();try{const n=Vo.browserCodeRenderer.render(i,"qrcode",{qrCodeLevel:String(t.qrCodeLevel??"M"),qrQuietZone:typeof t.qrQuietZone=="number"?t.qrQuietZone:void 0}),r=document.createElement("img");r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,r.alt="qrcode",r.style.width="100%",r.style.height="100%",r.style.objectFit=String(t.fit||"contain"),r.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",r.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",e.appendChild(r)}catch{}}function la(o,e){for(const t of Array.from(o.querySelectorAll("[data-code-kind]"))){const i=t.dataset.codeId,n=e.find(r=>r.id===i);if(n)if(t.dataset.codeKind==="barcode"){const r=t.querySelector("svg");r&&ra(n,r)}else aa(n,t)}}const sa={header:"题",data:"数",subtotal:"小",summary:"汇"},da=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],eo=3.7795275591,ca=.1,Ho=o=>JSON.parse(JSON.stringify(o)),Yi=new WeakMap;function $e(o){let e=Yi.get(o);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Yi.set(o,e)),e}function Ft(o,e){return o.templateData.elements.find(t=>t.id===e)??null}function pa(o,e){const t=o.tableSelection;return!t||t.elementId!==e.id?null:o.selectedElement?.id!==e.id?(o.tableSelection=null,null):t}function _n(o,e,t){const i=Ft(o,t.id);if(!i)return null;const n=t.options;return{store:o,fire:e,el:t,real:i,options:n,rows:n.tableRows??[],colWidths:n.tableColWidths??[],isSelected:o.selectedIds.has(t.id),selection:pa(o,t),maxTableWidth:Rn(o)}}function Rn(o){return o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right}function Zo(o){return o.options.tableDefaultFontSize??10}function zn(o){return o.options.tableDefaultColor??"#333333"}function ua(o,e){let t=0;for(let i=0;i<e;i++)t+=o.rows[i].height;return t}function ha(o,e){return $e(o.store).layouts.get(o.el.id)?.[e]?.top??ua(o,e)}function fa(o,e){return $e(o.store).layouts.get(o.el.id)?.[e]?.height??o.rows[e]?.height??0}function ma(o){const e=o.options.dataSource;if(e&&Array.isArray(p.DEFAULT_DEMO_DATA[e]))return p.DEFAULT_DEMO_DATA[e];for(const t of Object.values(p.DEFAULT_DEMO_DATA))if(Array.isArray(t))return t}function Fn(o){return o.cellType==="barcode"||o.cellType==="qrcode"}function Pn(o,e){return Fn(e)?p.resolveBarcodeDesignValue(e.formatter,ma(o)):e.formatter||""}function ga(o,e){const t={designMode:!0,showGhostBorder:o.store.showTableGhostBorder};return{fontFamily:D.resolveCanvasFontFamily(e.fontFamily??o.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??Zo(o))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??zn(o),backgroundColor:e.backgroundColor??"transparent",borderTop:p.resolveCellBorderCss(e.borders?.top,t),borderRight:p.resolveCellBorderCss(e.borders?.right,t),borderBottom:p.resolveCellBorderCss(e.borders?.bottom,t),borderLeft:p.resolveCellBorderCss(e.borders?.left,t),padding:(e.padding??o.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ba(o,e,t){const i=o.selection;return[!!i&&e>=i.r1&&e<=i.r2&&t>=i.c1&&t<=i.c2?"cell-selected":"",o.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Ln(o){return p.resolveCellTextFit(o)}function xa(o){return Ln(o)!=="autoHeight"}function va(o,e){return e.fontSize??Zo(o)}function ro(o,e,t){return p.cellFitCapMm(o.rows,e,t,o.options.tableDefaultPadding??1)}function ya(o,e,t){return p.cellFitWidthMm(o.colWidths,e,t,o.options.tableDefaultPadding??1)}function wa(o,e,t){return{maxHeight:ro(o,t,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Sa(o,e,t){const i={fitBase:String(va(o,e)),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(ro(o,t,e))};return Ln(e)==="shrink"&&(i.fit="shrink"),i}function Ta(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}const Ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ka(o,e,t,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(fr,"svg");n.appendChild(r);const l=Pn(o,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Ea[i.fit||"contain"]??"xMidYMid meet");const s=p.barcodeUnitsPerModule(i.barWidth),c=p.barcodeQuietZoneModules(i.barQuietZone),u=g=>{wn(r,l,{format:i.barcodeType||"CODE128",width:s,height:g*s,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*s,margin:0,marginLeft:c*s,marginRight:c*s,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*s});const v=Ta(r);return v?{widthUnits:v.width,heightUnits:v.height}:null};let h=null;try{h=p.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(ya(o,t,i),i.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(ro(o,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=l||"条码",n.appendChild(g),n}const m=h.size;return m?(r.style.width=`${m.widthMm}mm`,r.style.height=`${m.heightMm}mm`):(r.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",r.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),n}if(r.style.display="none",!l)return n;try{const s=Vo.browserCodeRenderer.render(l,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=i.fit||"contain",i.objectPosition&&(c.style.objectPosition=i.objectPosition),c.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",c.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(c)}catch{}return n}function Vi(){const o=document.createElement("div");return o.className="image-placeholder",o.textContent="图片",o}function Ca(o){const e=o.formatter||"";return e?e.includes("{")?p.evaluateTemplate(e,p.DEFAULT_DEMO_DATA):e:""}function Aa(o,e,t){const i=document.createElement("div");i.className="cell-image";const n=p.cellImageBoxMm(t.fit,ro(o,e,t));n!==void 0&&(i.style.height=`${n}mm`);const r=Ca(t);if(!r)return i.appendChild(Vi()),i;const l=document.createElement("img");l.setAttribute("src",r),n!==void 0&&(l.style.width="100%",l.style.height="100%"),l.style.objectFit=t.fit||"contain";for(const[s,c]of Object.entries(p.cropStyleDeclarations(t.fit,t.fitScale,t.objectPosition)))l.style[s]=c;return l.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",l.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",l.addEventListener("error",()=>{l.remove(),i.appendChild(Vi())},{once:!0}),i.appendChild(l),i}function Da(o,e,t,i,n){if(Fn(n))return ka(o,t,i,n);if(n.cellType==="image")return Aa(o,t,n);const r=Pn(o,n),l=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return xa(n)?a("div",{class:"cell-fit",style:wa(o,n,t),dataset:Sa(o,n,t)},[l()]):l()}function oo(o,e,t){const i={elementId:o.el.id,...p.normalizeSelection(o.rows,e,t)};o.store.setTableSelection(i),o.fire("table-selection-change",{elementId:o.el.id,selection:i})}function Ma(o,e,t,i,n){if(n.button!==0||(o.fire("table-cell-mousedown",{elementId:o.el.id,r:e,c:t,cellId:i,event:n}),!o.isSelected))return;n.stopPropagation();const r=$e(o.store);n.shiftKey&&o.selection?oo(o,{r:o.selection.r1,c:o.selection.c1},{r:e,c:t}):(r.anchor={r:e,c:t},oo(o,{r:e,c:t},{r:e,c:t})),document.addEventListener("mouseup",()=>{$e(o.store).anchor=null},{once:!0})}function _a(o,e,t){const i=$e(o.store).anchor;i&&oo(o,i,{r:e,c:t})}function In(o,e){const t=$e(o);t.menu?.visible&&(t.menu.visible=!1,e("table-menu-close",{elementId:t.menuElId}),o.emit(!1))}function Ra(o,e,t,i){i.preventDefault(),i.stopPropagation(),o.isSelected||o.store.selectOne(o.el.id);const n=o.selection;n&&e>=n.r1&&e<=n.r2&&t>=n.c1&&t<=n.c2||oo(o,{r:e,c:t},{r:e,c:t});const l=$e(o.store);l.menuElId=o.el.id,l.menu&&(l.menu.x=i.clientX,l.menu.y=i.clientY,l.menu.visible=!0),o.fire("table-cell-contextmenu",{elementId:o.el.id,r:e,c:t,clientX:i.clientX,clientY:i.clientY}),o.store.emit(!1),document.addEventListener("mousedown",()=>In(o.store,o.fire),{once:!0})}function Xi(o,e,t){const i=o.reduce((n,r)=>n+r,0)+(o[e]??0);return i>t?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${t}mm,请先缩小列宽`:null}function za(o,e){const t=o.real.options.tableRows??[],i=o.real.options.tableColWidths??[],n=e(Ho(t),Ho(i));return n?(window.alert(n),!1):(o.store.recordHistory(),e(t,i),o.store.setTableSelection(null),p.syncTableElementSize(o.real.options),o.store.emit(),!0)}function Le(o,e,t){In(o.store,o.fire);const i=o.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(p.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(p.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>p.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,l)=>{const s=Xi(l,i.c1,o.maxTableWidth);return s||(p.insertCol(r,l,i.c1,"left"),null)};break;case"insert-col-right":n=(r,l)=>{const s=Xi(l,i.c2,o.maxTableWidth);return s||(p.insertCol(r,l,i.c2,"right"),null)};break;case"delete-col":n=(r,l)=>p.deleteCol(r,l,i.c1);break;case"merge":n=r=>(p.mergeCells(r,i),null);break;case"split":n=r=>(p.splitCells(r,i),null);break;case"set-row-type":n=r=>t?p.setRowType(r,i.r1,t):"未指定行类型";break}n&&za(o,n)&&o.fire(`table-${e}`,{elementId:o.el.id,...t?{type:t}:{}})}function Fa(o){const e=o.selection;if(!e)return!1;for(let t=e.r1;t<=e.r2;t++)for(let i=e.c1;i<=e.c2;i++){const n=o.rows[t]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function Zi(o,e){const t=o.selection;return t?t.r1!==t.r2?"行类型仅支持单行设置":p.setRowType(Ho(o.rows),t.r1,e):"未选择单元格"}function Ie(o,e,t={}){return a("div",{class:`menu-item${t.disabled?" disabled":""}${t.active?" active":""}`,title:t.title||"",text:o,onClick:()=>{t.disabled||e()}})}const Ro=()=>a("div",{class:"menu-divider"});function Pa(o,e,t){const i=$e(o);if(i.menu=t,!t.visible||!i.menuElId)return"";const n=Ft(o,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=_n(o,e,n);if(!r)return"";const l=r.selection?p.canMergeReason(r.rows,r.selection):"未选择单元格",s=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:t.x+"px",top:t.y+"px"},onMousedown:c=>c.stopPropagation()},[Ie("在上方插入行",()=>Le(r,"insert-row-above")),Ie("在下方插入行",()=>Le(r,"insert-row-below")),Ie("删除行",()=>Le(r,"delete-row"),{disabled:r.rows.length<=1}),Ro(),Ie("在左侧插入列",()=>Le(r,"insert-col-left")),Ie("在右侧插入列",()=>Le(r,"insert-col-right")),Ie("删除列",()=>Le(r,"delete-col"),{disabled:r.colWidths.length<=1}),Ro(),Ie("合并单元格",()=>Le(r,"merge"),{disabled:!!l,title:l||""}),Ie("拆分单元格",()=>Le(r,"split"),{disabled:!Fa(r)}),Ro(),a("div",{class:"menu-group-title",text:"行类型"}),...da.map(c=>Ie(c.label,()=>Le(r,"set-row-type",c.value),{disabled:!!Zi(r,c.value),title:Zi(r,c.value)||"",active:s===c.value}))])}let et=null;function On(){et&&(document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo),et.handle.classList.remove("dragging"),et=null)}function La(o,e){const t=o.closest(".hiprint-printPaper");return(t&&t.offsetWidth>0?t.getBoundingClientRect().width/t.offsetWidth:0)||(e.scale||100)/100}function Ia(o,e,t){if(t.button!==0)return;const i=t.currentTarget,n=i.closest(".print-table");if(!n)return;On();const r=o.real.options.tableColWidths??[];et={store:o.store,fire:o.fire,elId:o.real.id,boundary:e,startX:t.clientX,startWidth:r[e-1]??0,scale:La(n,o.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),o.store.recordHistory(),document.addEventListener("mousemove",Qo),document.addEventListener("mouseup",Jo)}function Qo(o){const e=et;if(!e)return;const t=Ft(e.store,e.elId),i=t?.options.tableColWidths;if(!t||!i)return;const n=(o.clientX-e.startX)/(e.scale*eo),r=e.boundary-1;i[r]=p.clampResizedColumnWidth(i,r,e.startWidth+n,Rn(e.store)),p.syncTableElementSize(t.options),i.forEach((l,s)=>{const c=e.root.querySelector(`colgroup col:nth-child(${s+1})`);c&&(c.style.width=`${l}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((l,s)=>{l.style.left=`${i.slice(0,s+1).reduce((c,u)=>c+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${t.options.width}mm`,e.wrapper.style.height=`${t.options.height}mm`)}function Jo(){document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo);const o=et;if(!o)return;et=null,o.handle.classList.remove("dragging");const e=Ft(o.store,o.elId);e&&p.syncTableElementSize(e.options),o.store.emit(),o.fire("table-col-resize-end",{elementId:o.elId})}function Oa(o,e,t){const i=t.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Ft(o,e);if(!r)return;let l=!1;const s=n/eo;Math.abs(s-(r.options.height??0))>ca&&(r.options.height=Math.round(s*100)/100,l=!0);const c=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-c)/eo,height:m.offsetHeight/eo})),h=$e(o);Na(h.layouts.get(e),u)||(h.layouts.set(e,u),l=!0),l&&o.emit(!1)}function Na(o,e){return!o||o.length!==e.length?!1:e.every((t,i)=>{const n=o[i];return Math.round(t.top*10)===Math.round(n.top*10)&&Math.round(t.height*10)===Math.round(n.height*10)})}function $a(o,e){const t=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!t.isConnected)return;const i=t.parentElement;i&&Oa(o,e,i)}),t}function Ba(o){return o.isSelected&&!o.real.options.locked&&o.colWidths.length>=1}function Ha(o){return Array.from({length:o.colWidths.length},(e,t)=>t+1)}function Wa(o,e){return o.colWidths.slice(0,e).reduce((t,i)=>t+i,0)}function Ua(o,e,t){const i=_n(e,t,o);if(!i)return a("div",{class:"print-table"});const n=[a("table",{style:{fontSize:`${Zo(i)}pt`,color:zn(i)}},[a("colgroup",{},i.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},i.rows.map((r,l)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((s,c)=>s.merged?"":a("td",{rowspan:s.rowspan||1,colspan:s.colspan||1,class:ba(i,l,c),style:ga(i,s),onMousedown:u=>Ma(i,l,c,s.id,u),onMouseenter:()=>_a(i,l,c),onContextmenu:u=>Ra(i,l,c,u)},[Da(i,r,l,c,s)])).filter(Boolean))))])];return Ba(i)&&n.push(a("div",{class:"col-resize-layer"},Ha(i).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:Wa(i,r)+"mm"},onMousedown:l=>{l.stopPropagation(),l.preventDefault(),Ia(i,r,l)}})))),i.isSelected&&n.push(a("div",{class:"row-badges"},i.rows.map((r,l)=>a("span",{class:"row-badge",style:{top:ha(i,l)+"mm",height:fa(i,l)+"mm"},text:sa[r.type]})))),n.push($a(e,o.id)),a("div",{class:"print-table design-mode",dataset:{tableId:o.id},onContextmenu:r=>r.preventDefault()},n)}const Ga=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function Wo(o){return Array.isArray(o)&&o.length>0?o:[]}function qa(o,e){const t=p.detectFlowListKey(o,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(t)return Wo(e?.[t]);const i=p.detectFlowListKey(o,p.DEFAULT_DEMO_DATA);return i?Wo(p.DEFAULT_DEMO_DATA[i]):[]}function Ka(o,e){const t=o.options,i=typeof t.formatter=="string"?t.formatter:"",n=Wo(e)[0],r=qa(i,n);if(r.length===0)return[...Ga];if(!i)return r.map(c=>String(c?.name??JSON.stringify(c)));const l=n??{},s=p.detectFlowListKey(i,l)??Object.keys(l).find(c=>Array.isArray(l[c]));return r.map(c=>{try{return p.evaluateTemplate(i,{...l,...c,...s?{[s]:c}:{}})}catch{return i}})}function ja(o,e){const t=o.options,i=p.resolveFlowColumns(t.flowColumns),n=p.resolveFlowGapX(t.flowGapX),r=p.resolveFlowRowHeight(t.flowRowHeight),l={display:"grid",gridTemplateColumns:`repeat(${i},minmax(0,1fr))`,columnGap:`${n}mm`,gridAutoRows:`minmax(${r}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${t.fontSize||12}pt`,fontWeight:t.fontWeight||"normal",color:t.color||"#333",boxSizing:"border-box"};return t.fontFamily&&(l.fontFamily=String(t.fontFamily)),t.backgroundColor&&(l.backgroundColor=String(t.backgroundColor)),a("div",{class:"print-flowlist",style:l},Ka(o,e).map(s=>a("div",{class:"print-flow-cell",text:s})))}const Qi={top:"flex-start",middle:"center",bottom:"flex-end"},Ya={left:"flex-start",center:"center",right:"flex-end"};function Va(o,e){const t=o.options,i=p.resolveElementBorder(o.printElementType.type,t),n={};if(i?.all&&(n.border=`${i.all.borderWidth} ${i.all.borderStyle} ${i.all.borderColor}`),i)for(const r of p.ELEMENT_BORDER_SIDES){const l=i.edges[r];l&&(n[`border${r.charAt(0).toUpperCase()}${r.slice(1)}`]=`${l.borderWidth} ${l.borderStyle} ${l.borderColor}`)}return{position:"absolute",left:`${t.left}mm`,top:`${t.top}mm`,width:`${t.width}mm`,height:`${t.height}mm`,zIndex:String(t.zIndex||"auto"),...n,...Xa(o,e)}}function Xa(o,e){if(e?.has(o.id))return{};const t=p.resolveElementRotation(o.printElementType.type,o.options);return t===void 0?{}:{rotate:`${t}deg`}}function Ji(o){const e=o.options,t=o.printElementType.type==="longText",i=p.resolveElementTextFit(o.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",l={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:D.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:t?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...t?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};p.resolveElementNowrap(e)&&(l.whiteSpace="nowrap",l.textOverflow="ellipsis");const s=p.resolveElementWhiteSpace(e);return s&&(l.whiteSpace=s),e.verticalAlign&&(l.display="flex",e.textAlign==="justify"?(l.flexDirection="column",l.justifyContent=Qi[e.verticalAlign]??"flex-start"):(l.alignItems=Qi[e.verticalAlign]??"flex-start",l.justifyContent=Ya[e.textAlign||"left"]??"flex-start")),{style:l,fit:i}}function Za(o){const e=o.options,t=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return o.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${t} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${t} ${i} ${n}`,boxSizing:"border-box"}}function Qa(o){const e=o.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:o.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ja(o){const e=o.options;return{objectFit:e.fit||"contain",...p.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function en(o){const e=o.options,t={fitBase:String(e.fontSize||12),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return p.resolveElementTextFit(o.printElementType.type,e)==="shrink"&&(t.fit="shrink"),t}function el(o,e,t){const i=o.printElementType.type,n=o.options;switch(i){case"text":{const{style:r}=Ji(o);return a("div",{class:"print-text",style:r,dataset:en(o),text:String(n.testData||n.formatter||"")||"文本"})}case"longText":{const{style:r}=Ji(o);return a("div",{class:"print-longtext",style:r,dataset:en(o),text:String(n.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:Za(o)});case"rect":case"oval":return a("div",{class:"print-shape",style:Qa(o)});case"image":{const r=String(n.src??""),l=r.includes("{")?p.evaluateTemplate(r,p.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[l?a("img",{src:l,style:Ja(o)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return oa(o);case"barcode":return ia(o);case"html":{const r=String(n.formatter??""),l=r?Jr.sanitize(p.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:l})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:D.resolveCanvasFontFamily(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:n.title||"{pageIndex}/{totalPages}"});case"table":return t?Ua(o,t.store,t.fire):a("div",{class:"print-table"});case"flowList":return ja(o);default:return a("div",{text:i})}}function Nn(o){return`x:${Math.round(o.left)} y:${Math.round(o.top)} ${Math.round(o.width)}×${Math.round(o.height)}mm`}function tl(o,e,t){const i=o.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),l=e.options,s=e.zone||"content",c=[el(e,!0,{store:i,fire:o.fire})];return i.draggingIds.has(e.id)&&c.push(a("div",{class:"drag-preview"})),n&&(c.push(a("div",{class:"resize-handles"},p.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>o.fire("resize-start",{event:h,id:e.id,point:u})})))),c.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Nn(l)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${s}`,n?"selected":"",r?"previewed":"",i.draggingIds.has(e.id)?"drag-ghost":"","design-mode",l.locked?"locked":"",l.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Va(e,t),dataset:{elId:e.id},onMousedown:u=>o.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),o.fire("contextmenu",{event:u,id:e.id})}},c)}function Uo(o,e){const t=o.margins,i=o.header?.height??10,n=o.footer?.height??10,r=e.width-t.left-t.right;return{header:{left:t.left,top:t.top,width:r,height:i},content:{left:t.left,top:t.top+i,width:r,height:e.height-t.top-t.bottom-i-n},footer:{left:t.left,top:e.height-t.bottom-n,width:r,height:n}}}const ol='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>';function tn(o,e){return o.type==="vertical"?{left:`${o.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${o.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}}function il(o,e){const t=D.resolveWatermarkLayout(o.watermark,[],e);return t?a("div",{class:"watermark-layer",style:{opacity:String(t.opacity)}},t.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${t.tileWidthPx} ${t.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(t.tileWidthPx/2),y:String(t.tileHeightPx/2),"font-size":String(t.fontSizePx),fill:t.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${t.rotate},${t.tileWidthPx/2},${t.tileHeightPx/2})`,text:t.text})]))):""}function zo(o,e,t,i,n,r){const l=o.store,s=[];t!=="content"&&s.push(a("span",{class:"zone-label",text:t==="header"?"页眉":"页脚"}));const c=t==="content"?D.collectFollowMemberIds(n):void 0;if(s.push(...n.map(u=>tl(o,u,c))),t!=="content"){const u=t==="header"?"bottom":"top";s.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:t},onMousedown:h=>o.fire("zone-resize",{event:h,zone:t})},[e.zoneResizing===t?a("div",{class:"zone-height-tip",text:`${(t==="header"?l.templateData.header.height:l.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${t} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:t,paperWidth:String(r.width),paperHeight:String(r.height)}},s.filter(Boolean))}function nl(o,e){const t=o.store,i=t.templateData,n=D.getPaperDimensions(i),r=(t.scale||100)/100,l=Uo(i,n),s=m=>t.elements.filter(g=>(g.zone||"content")===m),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[t.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(ol)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[il(i,n)]:[],zo(o,e,"header",l.header,s("header"),n),zo(o,e,"content",l.content,s("content"),n),zo(o,e,"footer",l.footer,s("footer"),n),...t.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:tn(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...tn(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>o.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),o.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],c]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${D.mmToPx(n.width)*r}px`,height:`${D.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(t.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Me(o,m,"复制","copy"),Me(o,m,"剪切","cut"),Me(o,m,"粘贴","paste",!t.hasClipboard),Me(o,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Me(o,m,"置顶","move-layer",!1,"top"),Me(o,m,"上移","move-layer",!1,"up"),Me(o,m,"下移","move-layer",!1,"down"),Me(o,m,"置底","move-layer",!1,"bottom")]:[Me(o,m,"粘贴","paste-at",!t.hasClipboard),Me(o,m,"全选","select-all"),Me(o,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>m.preventDefault(),onDrop:m=>o.fire("drop",m),onMousedown:m=>o.fire("canvas-mousedown",m),onMousemove:m=>o.fire("canvas-mousemove",m),onMouseleave:()=>o.fire("canvas-mouseleave"),onWheel:m=>o.fire("wheel",m),onScroll:m=>o.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),o.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Me(o,e,t,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:t,onClick:()=>{e.visible=!1,n||o.fire(i,r),o.repaint()}})}const rl={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" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function ge(o,e=15,t){const i=rl[o];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${t?` class="${t}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let Je=null;function ei(o){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(o.trim());if(!e)return null;const t=e[1],i=t.length===3?t.split("").map(n=>n+n).join(""):t;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function ti(o){const e=ei(o);return e?$n(e):"#000000"}function $n({r:o,g:e,b:t}){return`#${[o,e,t].map(i=>Math.round(zt(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function al(o,e,t){const i=o/255,n=e/255,r=t/255,l=Math.max(i,n,r),s=Math.min(i,n,r),c=l-s;let u=0;return c!==0&&(l===i?u=(n-r)/c%6:l===n?u=(r-i)/c+2:u=(i-n)/c+4,u*=60,u<0&&(u+=360)),{h:u,s:l===0?0:c/l,v:l}}function ll(o,e,t){const i=t*e,n=(o%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[l,s,c]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=t-i;return{r:(l+u)*255,g:(s+u)*255,b:(c+u)*255}}function sl(o){return((Number.isFinite(o)?o:0)%360+360)%360}function zt(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function dl(o){const e=o.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${o.triggerClass?` ${o.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:t=>{const i=t.currentTarget??t.target,n=i.getRootNode();if(!!Je&&Je.root===n&&Je.title===e&&Je.trigger===i){_t();return}_t(),cl(i,o)}},[a("span",{class:"preset-color-swatch",style:o.value?{background:o.value}:{background:"transparent"}})])}function _t(){const o=Je;o&&(Je=null,o.teardowns.forEach(e=>e()),o.trigger.setAttribute("aria-expanded","false"),o.panel.remove())}function cl(o,e){const t=o.getRootNode(),i=t instanceof ShadowRoot?t:document.body,n={root:t,title:e.title??"颜色选择",trigger:o,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&ii(n,e.value)?n.hexText=ti(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=me(fl(n),i),n.current=n.panel.querySelector(".picker-current"),n.hex=n.panel.querySelector(".picker-hex"),n.area=n.panel.querySelector(".picker-area"),n.handle=n.panel.querySelector(".picker-handle"),n.hueRange=n.panel.querySelector(".picker-hue"),n.clearBtn=n.panel.querySelector(".picker-clear"),n.items=Array.from(n.panel.querySelectorAll(".preset-color-item")).map((r,l)=>({el:r,color:p.PRESET_COLORS[l]})),ao(n),pl(n),ul(n),Je=n,o.setAttribute("aria-expanded","true")}function pl(o){const e=o.trigger.getBoundingClientRect(),t=190,i=o.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-t-n)),l=e.bottom+6,s=l+i>window.innerHeight-n?Math.max(n,e.top-i-6):l;o.panel.style.left=`${r}px`,o.panel.style.top=`${s}px`}function ul(o){const e=n=>{const r=hl(n);r.includes(o.trigger)||r.includes(o.panel)||_t()},t=n=>{n.key==="Escape"&&_t()},i=()=>_t();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),o.root.addEventListener("scroll",i,!0),o.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",t),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>o.root.removeEventListener("scroll",i,!0))}function hl(o){const e=typeof o.composedPath=="function"?o.composedPath():[];return e.length?e:[o.target]}function fl(o){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>gl(o,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>bl(o,e),onKeydown:e=>xl(o,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>vl(o,Number(e.target.value)),onChange:()=>ni(o)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),o.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>io(o,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},p.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ml(o,e)})))])}function oi(o){return $n(ll(o.hue,o.saturation,o.value_))}function ao(o){const e=oi(o);o.hex.value!==o.hexText&&(o.hex.value=o.hexText),o.current.className=o.model?"picker-current":"picker-current is-empty",o.model?o.current.style.background=e:o.current.style.removeProperty("background"),o.area.style.setProperty("--picker-hue",`${Math.round(o.hue)}deg`),o.handle.style.left=`${o.saturation*100}%`,o.handle.style.top=`${(1-o.value_)*100}%`,o.handle.style.background=e;const t=String(Math.round(o.hue));o.hueRange.value!==t&&(o.hueRange.value=t),o.clearBtn&&(o.clearBtn.disabled=!o.model);for(const i of o.items)i.el.className=o.model&&i.color.toLowerCase()===o.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ii(o,e){const t=ei(e);if(!t)return!1;const i=al(t.r,t.g,t.b);return o.hue=i.h,o.saturation=i.s,o.value_=i.v,o.hexText=ti(e).toUpperCase(),!0}function mt(o,e,t,i){o.hue=sl(e),o.saturation=zt(t),o.value_=zt(i),o.hexText=oi(o).toUpperCase(),ao(o)}function ni(o){const e=oi(o);o.model=e,ao(o),o.onChange(e)}function io(o,e){o.model=e,e||(o.hexText=""),ao(o),o.onChange(e)}function ml(o,e){ii(o,e),io(o,e)}function gl(o,e){const t=e.trim();if(!t){o.clearable&&io(o,void 0);return}ei(t)&&(ii(o,t),io(o,ti(t)))}function bl(o,e){o.dragging=!0,on(o,e);const t=n=>{o.dragging&&on(o,n)},i=()=>{o.dragging&&(o.dragging=!1,document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),ni(o))};document.addEventListener("pointermove",t),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function on(o,e){const t=o.area.getBoundingClientRect();if(!t.width||!t.height)return;const i=zt((e.clientX-t.left)/t.width),n=zt(1-(e.clientY-t.top)/t.height);mt(o,o.hue,i,n)}function xl(o,e){const t=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?mt(o,o.hue,o.saturation-t,o.value_):e.key==="ArrowRight"?mt(o,o.hue,o.saturation+t,o.value_):e.key==="ArrowUp"?mt(o,o.hue,o.saturation,o.value_+t):e.key==="ArrowDown"?mt(o,o.hue,o.saturation,o.value_-t):i=!1,i&&(e.preventDefault(),ni(o))}function vl(o,e){mt(o,e,o.saturation,o.value_)}function ee(o,e,t,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>o.fire(t,i.arg),html:ge(e)})}function no(o,e,t,i){const n=o.state.openDd===e,r=()=>{o.state.openDd=n?null:e,o.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!t.disabled,dataset:{test:t.testId??e,tip:t.tip},onClick:r,html:`${t.icon?ge(t.icon):""}${t.text?`<span class="${t.textClass??"tb-btn-text"}">${t.text}</span>`:""}${ge("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${t.panelClass?` ${t.panelClass}`:""}`},i):""].filter(Boolean))}function O(o){const e=o.step??1,t=String(e),i=t.indexOf("."),n=i===-1?0:t.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,l=m=>{let g=r(m);return o.min!==void 0&&g<o.min&&(g=o.min),o.max!==void 0&&g>o.max&&(g=o.max),g},s=o.value===void 0||o.value===null||!Number.isFinite(o.value)?void 0:r(o.value),c=s??o.min??0,u=m=>{m!==s&&o.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:s===void 0?"":String(s),min:o.min,max:o.max,step:e,placeholder:o.placeholder,disabled:!!o.disabled,onChange:m=>{const g=m.target,v=(g.value??"").trim();if(v===""){s!==void 0&&(g.value=String(s));return}const S=Number(v);if(!Number.isFinite(S)){g.value=s===void 0?"":String(s);return}const b=l(S);g.value=String(b),u(b)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!o.disabled||c<=(o.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(l(c-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!o.disabled||c>=(o.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(l(c+e))})])}function H(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),i??""]),e,t?a("p",{class:"pd-hint",text:t}):""].filter(Boolean))}const Go=o=>a("button",{class:"pd-help",type:"button","data-tip":o,"aria-label":"字段说明"});function Ce(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[o,Go(t)]),i??""]),e])}function tt(o){const e=o.base?.[o.propKey],t=o.target?.[o.propKey]!==e,i=o.force===!0||t,n=o.tipOverride??(o.tipValue===void 0?"恢复默认值":`恢复默认值(${o.tipValue}${o.tipUnit?" "+o.tipUnit:""})`),r=o.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${t&&!o.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ge("RotateCcw",13),onClick:()=>{i&&(o.write?o.write(e):o.target[o.propKey]=e,o.onReset?.())}})}const Fe=o=>a("h3",{class:"pd-divider",text:o});function Ae(o,e,t="颜色选择",i){return dl({value:o,title:t,triggerClass:i,onChange:n=>e(n)})}function Ge(o,e,t,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:o,value:r.value,checked:t===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Bn(o,e,t,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const l=document.createElement("option");l.value=r.value,l.textContent=r.label,r.disabled&&(l.disabled=!0),n.appendChild(l)}return n.value=o,e.some(r=>r.value===o)||(n.selectedIndex=-1),n.addEventListener("change",()=>t(n.value)),n}function yl(o){const e=window.innerHeight;for(let t=o.parentElement;t&&t!==document.body;t=t.parentElement){const i=getComputedStyle(t).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=t.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function lo(o){const e=D.normalizeFontCatalog(o.fonts),t=o.placeholder??"默认",i=`font-select-list-${o.id}`,n=L=>{const _=L?.trim();return _?D.findFontOption(e,_)?.label??_:""},r=L=>{const _=D.normalizeFontQuery(L);return e.find(X=>X.label&&D.normalizeFontQuery(X.label)===_)?.family??L},l=()=>{const L=o.value?.trim();return L?D.findFontOption(e,L)?"":L:""},s=L=>{const _=(o.value??"").trim(),q=(Q,y,W,ae)=>({kind:Q,key:y,label:W,value:ae,selected:(ae??"")===_}),X=L.trim();if(!X){const Q=[q("clear","__clear__",t)],y=l();y&&Q.push(q("unknown","__unknown__",`${y}(未知)`,y));for(const W of e)Q.push(q("font",W.family,D.fontOptionLabel(W),W.family));return Q}const pe=D.filterFontOptions(e,X).map(Q=>q("font",Q.family,D.fontOptionLabel(Q),Q.family));if(!pe.length){const Q=r(X);pe.push(q("free","__free__",`使用「${Q}」`,Q))}return pe},c=document.createElement("div");c.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=t,u.disabled=!!o.disabled,u.value=n(o.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=o.state.fontOpen?.id===o.id?o.state.fontOpen:null,g={open:!!m&&!o.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const v=()=>{o.state.fontOpen=g.open?{id:o.id,query:g.query,highlighted:g.highlighted}:null};v();const S=()=>{const L=(o.value??"").trim();return s(g.query).findIndex(_=>(_.value??"")===L)},b=()=>{const L=u.getBoundingClientRect(),_=yl(u);h.classList.toggle("is-up",p.resolveOverlayPlacement({triggerTop:L.top,triggerBottom:L.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:_.top,boundaryBottom:_.bottom})==="up")},T=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||c.appendChild(h);const L=s(g.query);h.replaceChildren(...L.map((_,q)=>{const X=document.createElement("li");return X.id=`${i}-${q}`,X.className="font-select-option"+(q===g.highlighted?" is-active":"")+(_.kind==="unknown"||_.kind==="free"?" is-muted":""),X.setAttribute("role","option"),X.setAttribute("aria-selected",String(_.selected)),X.textContent=_.label,X.addEventListener("mousedown",pe=>{pe.preventDefault(),se(_)}),X})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),b()},E=()=>{g.open||o.disabled||(g.open=!0,g.query="",g.highlighted=S(),v(),T())},A=()=>{g.open||E()},P=()=>{g.open=!0,g.query=u.value,g.highlighted=s(g.query).length?0:-1,v(),T()},F=L=>{if(!g.open){E();return}const _=s(g.query).length-1;if(_<0)return;g.highlighted=Math.min(Math.max(g.highlighted+L,0),_),v(),T(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},U=()=>{if(!g.open)return;const L=s(g.query)[g.highlighted];if(L){se(L);return}const _=g.query.trim();if(_){const q=r(_);se({value:q})}},se=L=>{g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(L.value),T(),o.onChange(L.value)},V=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(o.value),T())};return u.addEventListener("focus",E),u.addEventListener("click",A),u.addEventListener("input",P),u.addEventListener("blur",V),u.addEventListener("keydown",L=>{const _=L;_.key==="ArrowDown"?(_.preventDefault(),F(1)):_.key==="ArrowUp"?(_.preventDefault(),F(-1)):_.key==="Enter"?(_.preventDefault(),U()):_.key==="Escape"&&(_.preventDefault(),V())}),c.append(u),T(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),c}const wl=[{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"}],Sl={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function We(o,e,t,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:o,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${t}</svg>`})}const ut='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',nn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Tl(o){const e=o.format;e.syncBorderDraft();const t=e.values,i=!e.fontEditable,n=i||e.context==="cells",r=e.context==="none",l=e.context==="cells",s=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",u=g=>i?`${g}(需选中文本元素)`:g,h=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[We("preset-none","无边框",`${ut}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),We("preset-all","所有边框",`${nn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),We("preset-outer","外侧边框",nn,()=>e.applyBorderPreset("outer")),We("preset-inner",l?"内部边框":"内部边框(仅表格单元格可用)",`${ut}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!l}),We("edge-top","上边框",`${ut}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),We("edge-bottom","下边框",`${ut}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),We("edge-left","左边框",`${ut}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),We("edge-right","右边框",`${ut}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),a("div",{class:"ft-style-row"},wl.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),o.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[O({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),o.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Ae(e.borderColor,g=>{e.setBorderColor(g),o.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,v,S])=>a("button",{type:"button",class:`ft-cell-btn${t.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ge(S)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,v,S])=>a("button",{type:"button",class:`ft-cell-btn${t.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ge(S)})))])];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:s,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),o.repaint()},onDblclick:()=>{e.pickPainterSource(!0),o.repaint()},html:ge("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[lo({id:"ft-font",state:o.state,fonts:o.host.fonts,value:typeof t.fontFamily=="string"?t.fontFamily:void 0,placeholder:t.fontFamily===Qe?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[O({value:typeof t.fontSize=="number"?t.fontSize:void 0,min:5,max:72,disabled:i,placeholder:t.fontSize===Qe?"混合":"默认",onCommit:g=>e.applyStyle({fontSize:g})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([g,v,S,b])=>a("button",{type:"button",class:`ft-btn${t[g]===!0?" on":""}`,dataset:{test:g,tip:u(S)},disabled:g==="bold"?i:n,onClick:b,html:ge(v)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Ae(typeof t.color=="string"?t.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Ae(typeof t.backgroundColor=="string"?t.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ge("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[no(o,"align",{icon:Sl[String(t.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[no(o,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const El=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",label:"流式列表",icon:"⊟"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],kl={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Cl(o){const e=o.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[rn("»","展开素材台",()=>{e.leftCollapsed=!1,o.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,text:r,onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,o.repaint()}}))])]);const t=(i,n)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),rn("«","收起素材台",()=>{e.leftCollapsed=!0,o.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,o.repaint()}}))]),t("elements",Al()),t("fields",[Dl(o)]),t("layers",[Ml(o)])])])}function rn(o,e,t){return a("button",{type:"button",class:"collapse-btn",title:e,text:o,onClick:t})}function Al(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...El.map(o=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${o.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",o.type)},[a("span",{class:"material-icon",text:o.icon}),a("span",{class:"material-label",text:o.label})]))]}function Dl(o){const e=o.state,t=p.groupFields(o.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?t.map(r=>({...r,fields:r.fields.filter(l=>`${l.fieldLabel}${l.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):t;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>o.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const l=e.collapsedGroups.has(r.key)&&!i,s=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{l?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),o.repaint()}},[a("span",{class:"expand-icon",text:l?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",c=l?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey}) · 单击复制字段名 · Ctrl/⌘+拖动插入字段名`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{h.dataTransfer?.setData("fieldKey",u.fieldKey)},onClick:()=>{p.copyTextToClipboard(u.fieldLabel||u.fieldKey).then(h=>{h&&(e.copiedFieldKey=u.fieldKey,o.repaint(),setTimeout(()=>{e.copiedFieldKey===u.fieldKey&&(e.copiedFieldKey="",o.repaint())},1200))})}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})]),e.copiedFieldKey===u.fieldKey?a("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[s,a("div",{},c.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function Ml(o){const e=o.store,t=[...e.elements].sort((s,c)=>(c.options.zIndex??0)-(s.options.zIndex??0)),i=e.elements.filter(s=>e.selectedIds.has(s.id)),n=i.length>=2,r=i.some(s=>!!s.options.groupId),l=s=>s.zone==="header"?"页眉":s.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...t.map(s=>a("div",{class:`layer-item${e.selectedIds.has(s.id)?" active":""}`,onClick:c=>e.selectElement(s.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:kl[s.printElementType.type]||"?"}),a("span",{class:"layer-name",text:s.options.title||s.printElementType.title||s.printElementType.type}),l(s)?a("span",{class:"layer-zone",text:l(s)}):"",a("span",{class:"layer-zindex",text:`z:${s.options.zIndex??0}`})].filter(Boolean))),t.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([s,c,u])=>a("button",{type:"button",class:"pd-button small",title:c,html:ge(u,14),onClick:()=>o.fire("move-layer",s)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ge("Group",14),onClick:()=>o.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ge("Ungroup",14),onClick:()=>o.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function _l(o){const e=o.store,t=o.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((s,c)=>t.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:t.renameText??"",onInput:u=>{t.renameText=u.target.value},onBlur:()=>l(),onKeydown:u=>{const h=u;if(h.key==="Enter"){l();return}h.key==="Escape"&&(t.renamingPage=null,o.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:s.name?`${s.name}(双击重命名)`:"双击重命名"},text:s.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{t.renamingPage=c,t.renameText=s.name??"",o.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>o.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>o.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>o.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>o.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>o.fire("move-page",1)})])]);function l(){const s=(t.renameText??"").trim();t.renamingPage!==null&&s&&e.renamePage(t.renamingPage,s),t.renamingPage=null,o.repaint()}}function Rl(o){const e=o.store,t=e.templateData,i=p.getPaperDimensions(t),n=t.orientation==="landscape"?"横向":"纵向",r=p.PAPER_PRESETS[t.paperSize]?.label??t.paperSize,l=t.outputRotation,s=`${r} ${n} ${Math.round(i.width)}×${Math.round(i.height)}mm${l?`(旋转${l}°)`:""}`;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:s})])}const zl=Object.keys(p.PAPER_PRESETS).filter(o=>o!=="CUSTOM"&&!p.PAPER_PRESETS[o]?.continuous);function Fl(o){const e=document.createElement("label");e.className="pd-button small upload-label";const t=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(t,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const l=o.host.uploadDesignBackground;if(!l){alert("设计背景上传能力未配置"),i.value="";return}n(!0),t.textContent="上传中...";try{const s=await l(r);s?o.store.updateTemplateData({designBackground:{src:s,rotation:0}}):alert("设计背景上传失败")}catch(s){alert(s instanceof Error?s.message:"设计背景上传失败")}finally{t.textContent="上传背景图",n(!o.host.uploadDesignBackground),i.value=""}}),o.host.uploadDesignBackground||n(!0),e}function Pl(o){const t=o.store.templateData.designBackground,i=t?.rotation??0;return a("div",{class:"design-background-config"},[Fe("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),t?.src?[a("div",{class:"design-background-path",title:t.src,text:t.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>o.store.updateTemplateData({designBackground:{...t,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>o.store.updateTemplateData({designBackground:void 0})})])]:Fl(o)].flat())}function Ll(o){const e=o.store,t=e.templateData,i=t.tiling,n={...D.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{...D.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=p.isContinuousPaperSize(t.paperSize),l=S=>e.updateTemplateData({tiling:{...n,...S}}),s=S=>tt({target:n,base:D.TILE_DEFAULTS,propKey:S,write:()=>l({[S]:D.TILE_DEFAULTS[S]})}),c=S=>tt({target:n.sheetMargin,base:D.TILE_DEFAULTS.sheetMargin,propKey:S,write:()=>u(S,D.TILE_DEFAULTS.sheetMargin[S])}),u=(S,b)=>l({sheetMargin:{...n.sheetMargin,[S]:b??0}}),h={...t,tiling:n},m=D.validateTiling(h),g=Math.max(D.computeMaxColumns(h),1);let v="";if(!m.length)try{const S=D.computeTileLayout(h),b=D.resolveSheetMm(h),T=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",E=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";v=`目标纸 ${T}${E} ${b.width}×${b.height}mm · ${S.columns} 列 × ${S.rows} 行 = 每张 ${S.perSheet} 格 · 每格 ${S.tile.width}×${S.tile.height}mm`}catch{v=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Fe("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:n.enabled===!0,disabled:r,onChange:S=>{if(!S.target.checked){l({enabled:!1});return}l({...D.TILE_DEFAULTS,columns:Math.min(D.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[H("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:S=>{const b=S.target.value;if(b!=="CUSTOM"){l({sheetPaperSize:b});return}const T=D.resolveSheetMm(h);l({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??T.width,sheetCustomHeight:n.sheetCustomHeight??T.height})}},[...zl.map(S=>a("option",{value:S,text:p.PAPER_PRESETS[S]?.label??S,selected:(n.sheetPaperSize??"A4")===S})),a("option",{value:"CUSTOM",text:"自定义",selected:n.sheetPaperSize==="CUSTOM"})]),void 0,s("sheetPaperSize")),n.sheetPaperSize==="CUSTOM"?H("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[O({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:S=>l({sheetCustomWidth:S})}),a("span",{class:"custom-size-x",text:"×"}),O({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:S=>l({sheetCustomHeight:S})})])):H("目标纸方向",Ge("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",S=>l({sheetOrientation:S})),void 0,s("sheetOrientation")),Fe("拼版留白 (mm)"),a("div",{class:"margin-grid"},[H("上",O({value:n.sheetMargin.top??0,min:0,max:100,onCommit:S=>u("top",S)}),void 0,c("top")),H("下",O({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:S=>u("bottom",S)}),void 0,c("bottom")),H("左",O({value:n.sheetMargin.left??0,min:0,max:100,onCommit:S=>u("left",S)}),void 0,c("left")),H("右",O({value:n.sheetMargin.right??0,min:0,max:100,onCommit:S=>u("right",S)}),void 0,c("right"))]),Fe("格间距与列数"),H("横向间距",O({value:n.gapX??0,min:0,max:50,onCommit:S=>l({gapX:S??0})}),void 0,s("gapX")),H("纵向间距",O({value:n.gapY??0,min:0,max:50,onCommit:S=>l({gapY:S??0})}),void 0,s("gapY")),H("列数",O({value:n.columns??1,min:1,max:g,onCommit:S=>l({columns:S||1})})),...m.map(S=>a("p",{class:"pd-hint tiling-error",text:S.message})),!m.length&&v?a("p",{class:"pd-hint tiling-summary",text:v}):""]:""].flat().filter(Boolean))}const Il=new Set(p.PROPERTY_REGISTRY.map(o=>o.group)),Ol={"table-settings":"content"},an=new Map;function ri(o){const e=o??"";let t=an.get(e);if(!t){const{groups:i,itemKeys:n}=p.searchProperties(e);t={groups:i,keys:n,searching:!!e.trim()},an.set(e,t)}return t}function ai(o){const e=Ol[o]??o;return Il.has(e)?e:""}function Nl(o,e){const t=ri(o.state.propSearch);if(!t.searching)return!0;const i=ai(e);return!i||t.groups.includes(i)}function $l(o,e){const t=ri(o.state.propSearch);return!t.searching||t.keys.has(e)}function Hn(o,e){const t=o.props.style??{};return o.props.style={...t,display:e?"":"none"},o}function R(o,e,t){const i=t.props.dataset??{};return t.props.dataset={...i,propKey:e},Hn(t,$l(o,e))}function Bl(o,e,t){const i=ai(e);if(!i)return t;const n=t.props.dataset??{};return t.props.dataset={...n,propGroup:i},Hn(t,Nl(o,e))}function Wn(o,e){const t=ri(e);for(const i of Array.from(o.querySelectorAll("[data-prop-group]"))){const n=ai(i.dataset.propGroup??"");i.style.display=!t.searching||!n||t.groups.includes(n)?"":"none"}for(const i of Array.from(o.querySelectorAll("[data-prop-key]")))i.style.display=!t.searching||t.keys.has(i.dataset.propKey??"")?"":"none"}function Hl(o){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:o.state.propSearch??"",onInput:e=>{const t=e.target,i=t.value;o.state.propSearch=i,Wn(t.getRootNode(),i)}})])}const Wl={Document:"≡",Brush:"◧",Setting:"⚙"};function Ul(o,e){try{const t=window.localStorage.getItem(`property-group-${o}`);return t===null?e:t==="true"}catch{return e}}function Gl(o,e){try{window.localStorage.setItem(`property-group-${o}`,String(e))}catch{}}function ye(o,e,t,i,n,r=!0){const l=Ul(e,r);return Bl(o,e,a("div",{class:`property-group${l?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{Gl(e,!l),o.repaint()}},[a("span",{class:"group-icon",text:Wl[i]||"•"}),a("span",{class:"group-title",text:t}),a("span",{class:"expand-icon",text:l?"▾":"▸"})]),a("div",{class:"group-content",style:l?"":{display:"none"}},n.filter(Boolean))]))}function so(o){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},o.filter(Boolean))}function Un(o){return o.split(".").flatMap(e=>{const t=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!t)return[e];const i=t[1],n=[...t[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function ln(o,e){return Un(e).reduce((n,r)=>n==null?"":n[r],o)??""}function li(o,e,t,i){const n=Un(t),r=n.pop(),l=n.reduce((s,c)=>((s[c]===void 0||s[c]===null)&&(s[c]={}),s[c]),e);l[r]=i||void 0,o.recordHistory(),o.emit()}function ql(o,e){const t=o.store;if(e.printElementType.type==="table"&&t.tableSelection?.elementId===e.id){const{r1:i,c1:n}=t.tableSelection,r=(e.options.tableRows??[])[i];if(r)return p.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return p.getElementBindings(e)}function Kl(o,e){const t=document.createElement("label");t.className="pd-button small upload-label",me(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),t);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",t.append(i,n);const r=c=>{t.className=`pd-button small upload-label${c?" disabled":""}`,n.disabled=c};n.addEventListener("change",async()=>{const c=n.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=o.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(c);h?li(o.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!o.host.uploadImage),n.value=""}}),o.host.uploadImage||r(!0);const l=document.createElement("div");l.className="image-content-upload";const s=document.createElement("p");return s.className="upload-tip",s.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",l.append(t,s),l}function jl(o,e){const t=i=>o.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:ln(e,i.targetPath)});return ye(o,"binding","内容","Document",[...ql(o,e).map(i=>H(i.label,a("input",{class:"pd-input",type:"text",value:ln(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>li(o.store,e,i.targetPath,n.target.value),onDblclick:()=>t(i)}))),e.printElementType.type==="image"?Kl(o,e):""].filter(Boolean))}const Ct=new Map;function Zt(o){return`${Math.round(o*1e4)/1e4}%`}function Gn(o,e){const t=p.parseCropAnchor(e.value),i=t.kind==="custom",n=t.kind==="axes"?t.x:50,r=t.kind==="axes"?t.y:50,l=p.resolveCropPreview(e.src),s=Ct.get(l.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:s?.width,naturalHeight:s?.height,fit:e.fit,scalePct:e.scale},u=p.resolveCropTravel(c),h=p.cropWindow(c,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const b of p.cropPresetOptions(u,n,r)){const T=document.createElement("option");T.value=b.value,T.textContent=b.label,m.appendChild(T)}if(i){const b=document.createElement("option");b.value="custom",b.textContent="自定义(保留原值)",m.appendChild(b)}m.value=i?"custom":`${n},${r}`,m.selectedIndex<0&&(m.selectedIndex=i?m.options.length-1:0),m.addEventListener("change",()=>{if(m.value==="custom")return;const[b,T]=m.value.split(",").map(Number);e.onCommit(p.buildCropAnchor(b,T))});const g=p.propertyTip(e.fieldKey),v=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,Go(g)]),e.resetAnchor??""].filter(Boolean)),m])];v.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[p.CROP_SCALE_LABEL,Go(p.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),O({value:e.scale,min:p.CROP_SCALE_MIN,max:p.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:b=>e.onScaleCommit(b>p.CROP_SCALE_MIN?b:void 0)})]));for(const b of p.cropAxisFields(u,n,r))v.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:b.label}),O({value:b.value,min:0,max:100,step:1,onCommit:T=>e.onCommit(p.buildCropAnchor(b.name==="horizontal"?T:n,b.name==="vertical"?T:r))})]));const S=p.cropAxisNote(u,i);return S&&v.push(a("p",{class:"pd-crop-note",text:S})),l.isSample&&v.push(a("p",{class:"pd-crop-note",text:p.CROP_SAMPLE_NOTE})),v.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:l.src,alt:l.isSample?"示例图":"原图",onLoad:b=>{const T=b.target;if(!(T.naturalWidth>0&&T.naturalHeight>0))return;const E=Ct.get(l.src);E&&E.width===T.naturalWidth&&E.height===T.naturalHeight||(Ct.set(l.src,{width:T.naturalWidth,height:T.naturalHeight}),o.repaint())},onError:()=>{Ct.has(l.src)&&(Ct.delete(l.src),o.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:Zt(h.leftPct),top:Zt(h.topPct),width:Zt(h.widthPct),height:Zt(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},v)}const Ze=o=>Number(o??0),qo=o=>o||void 0;function bt(o,e,t,i,n){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:o}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:r=>t(r.target.checked)})])}function qn(o,e,t,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:l=>i(l.target.value)},t.map(l=>a("option",{value:l.value,text:l.label,selected:l.value===e})))])}function At(o,e,t,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),n.reset??""].filter(Boolean)),Bn(e,t,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Dt=o=>a("p",{class:"pd-hint",text:o}),Yl="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Vl=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Xl=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Zl=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Ql=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Jl={value:"__multi__",label:"多选",disabled:!0};function es(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return ye(o,"table-row","行属性","Grid",[]);const l=s=>t.updateElement(e.id,s);return ye(o,"table-row","行属性","Grid",[so([qn("行类型",r.type,Vl,s=>{const c=p.setRowType(n,i.r1,s);if(c){window.alert(c);return}l({tableRows:n})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),O({value:r.height,min:3,max:100,step:.5,onCommit:s=>{r.height=s,l({tableRows:n})}})]),r.type==="header"?bt("表头每页重复",r.repeatOnPage??!1,s=>{p.setHeaderRepeat(n,s),l({tableRows:n})},Yl):""])])}function ts(o,e){const t=o.store,i=e.options,n=h=>t.updateElement(e.id,h),r=i.tableColWidths??[],l=t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right,s=t.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),c=p.createDefaultOptions("table"),u=h=>tt({target:i,base:c,propKey:h,write:()=>n({[h]:c[h]})});return ye(o,"table-settings","表格设置","Grid",[so([qn("列表数据源字段",i.dataSource??"",s,h=>n({dataSource:h||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字体"}),u("tableDefaultFontFamily")]),lo({id:"table-default-font",state:o.state,fonts:o.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),O({value:Ze(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Ae(i.tableDefaultColor,h=>n({tableDefaultColor:h}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),u("tableDefaultPadding")]),O({value:Ze(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((h,m)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${m+1}`}),O({value:h,min:5,max:200,onCommit:g=>{const v=r.reduce((S,b,T)=>T===m?S:S+b,0);if(v+g>l){const S=Math.max(5,Math.round((l-v)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${l}mm,列${m+1} 已调整为 ${S}mm`),r[m]=S}else r[m]=g;n({tableColWidths:r})}})]))])])])}function os(o,e){const t=o.store,i=e.options,n=e.printElementType.type==="table",r=s=>t.updateElement(e.id,s),l=[];if(n)l.push(R(o,"pg-enabled",bt("启用分页",i.tablePagination?.enabled??!0,s=>r({tablePagination:{enabled:s}}))));else{const s=i.pagination?.pageable??!0,c=i.pagination?.keepWithNext??!1;l.push(R(o,"pg-pageable",bt("参与分页",s,u=>r({pagination:{pageable:u,keepWithNext:c}})))),l.push(R(o,"pg-keep-with-next",bt("与下元素同页",c,u=>r({pagination:{pageable:s,keepWithNext:u}}))))}return ye(o,"pagination","分页配置","Document",[so(l)],!1)}const Fo=new WeakMap,sn=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function is(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[];if(!i)return ye(o,"table-cell","单元格","Menu",[]);const r=p.findMainCell(n,i.r1,i.c1),l=n[r.r]?.cells[r.c];if(!l)return ye(o,"table-cell","单元格","Menu",[]);const s=()=>p.collectWritableCells(n,i),c=p.resolveCellGroupMode(n,i),u=c.count,h=c.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=Fo.get(t),v=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&Fo.set(t,v);const S=x=>{Fo.set(t,{key:m,border:x.border??v.border,values:x.values??v.values,edges:x.edges??v.edges})},b=(x,N)=>{S({border:{...v.border,[x]:N}}),o.repaint()},T=(x,N)=>{s().forEach(x),h&&N&&S({values:{...v.values,...N}}),t.updateElement(e.id,{tableRows:n})},E=(x,N)=>{T(J=>{J[x]=N},{[x]:N})},A=x=>h?v.values[x]:l[x],P=x=>h&&x in v.values,F=h?{width:void 0,style:void 0,color:void 0}:p.resolveCellBorderDisplay(n,i),U=!h&&s().some(x=>!!x.borders&&!!(x.borders.top||x.borders.right||x.borders.bottom||x.borders.left)),se=!h&&!U,V={width:se?0:typeof F.width=="number"?F.width:p.DEFAULT_BORDER.width,style:se?"none":typeof F.style=="string"&&F.style!=="mixed"?F.style:p.DEFAULT_BORDER.style,color:typeof F.color=="string"&&F.color!=="mixed"?F.color:p.DEFAULT_BORDER.color,...v.border},L="__mixed__",_={style:!h&&F.style==="mixed",width:!h&&F.width==="mixed",color:!h&&F.color==="mixed"},q=_.style&&!("style"in v.border),X=_.width&&!("width"in v.border),pe=_.color&&!("color"in v.border),Q=q||X||pe,y=q?L:V.style,W=X?void 0:V.width,ae=pe?void 0:V.color,Pe=x=>{const N={style:x};x!=="none"&&W===0?N.width=p.DEFAULT_BORDER.width:x==="none"&&!U&&(N.width=0),S({border:{...v.border,...N}}),o.repaint()},I=()=>({...V}),te=h?sn.reduce((x,N)=>(x[N.value]=v.edges[N.value]?"on":"off",x),{}):p.resolveBorderEdgeStates(s().map(x=>x.borders)),qe=h?"cellType"in v.values?v.values.cellType??"text":p.resolveSharedCellType(n,i):l.cellType??"text",ue=qe==="barcode",Ke=qe==="qrcode",ot=qe==="image",G=qe==="text",co=ue&&!!A("printerDpi"),Pt=p.barcodeBarWidthRecommendText(A("printerDpi"),A("barWidth")),Lt=h?v.values.textFit:p.resolveCellTextFit(l),po=h?"cellType"in v.values?v.values.cellType??"text":"":l.cellType||"text",je=x=>h?[Jl,...x]:x,we=x=>h?"多选":x,Se=(x,N)=>h?v.values[x]:N,uo=h?A("barcodeType")??"__multi__":l.barcodeType||"CODE128",It=h?P("printerDpi")?A("printerDpi")?String(A("printerDpi")):"":"__multi__":l.printerDpi?String(l.printerDpi):"",K=h?A("qrCodeLevel")??"__multi__":l.qrCodeLevel||"M",xt=h?A("fit")??"__multi__":l.fit||"contain",j=Lt??"__multi__",it=p.canMergeReason(n,i);let he=!1;for(let x=i.r1;x<=i.r2&&!he;x++)for(let N=i.c1;N<=i.c2&&!he;N++){const J=n[x]?.cells[N];J&&!J.merged&&((J.rowspan??1)>1||(J.colspan??1)>1)&&(he=!0)}const Te=(x,N,J,oe={},De)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:x}),De??""].filter(Boolean)),O({value:N,...oe,onCommit:yt=>E(J,qo(yt))})]),Ot="恢复默认值(跟随表格默认)",$=x=>tt({target:l,base:{},propKey:x,tipOverride:Ot,force:h,write:()=>E(x,void 0)}),vt=e.options.tableDefaultPadding??1,nt={width:p.cellFitWidthMm(e.options.tableColWidths??[],r.c,l,vt),height:p.cellFitCapMm(n,r.r,l,vt)};return ye(o,"table-cell","单元格","Menu",[so([h?Dt(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),Ge("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],po,x=>{const N=x==="text"?void 0:x,J={cellType:x};x!=="barcode"&&Object.assign(J,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),x!=="qrcode"&&Object.assign(J,{qrCodeLevel:void 0,qrQuietZone:void 0}),T(oe=>{oe.cellType=N,x!=="barcode"&&(oe.barcodeType=void 0,oe.showBarcodeText=void 0,oe.printerDpi=void 0,oe.barQuietZone=void 0,oe.barHeight=void 0),x!=="qrcode"&&(oe.qrCodeLevel=void 0,oe.qrQuietZone=void 0)},J)})]),ue?At("码制",uo,je(Xl),x=>{x!=="__multi__"&&E("barcodeType",x||void 0)}):"",ue?bt("显示文本",h?v.values.showBarcodeText===!0:l.showBarcodeText!==!1,x=>E("showBarcodeText",x),void 0,$("showBarcodeText")):"",ue?Te("条宽(倍率)",Se("barWidth",l.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:we("")},$("barWidth")):"",ue?Dt((co?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Pt?`。${Pt}`:"")):"",ue?Ce("静区 (模块)",O({value:Se("barQuietZone",l.barQuietZone),min:0,max:20,placeholder:we("默认 10"),onCommit:x=>E("barQuietZone",x)}),p.propertyTip("cd-bar-quiet-zone"),$("barQuietZone")):"",ue?Ce("条高 (mm)",O({value:Se("barHeight",l.barHeight),min:1,max:100,placeholder:we("默认 30 模块"),onCommit:x=>E("barHeight",x??void 0)}),p.propertyTip("cd-bar-height"),$("barHeight")):"",ue?Te("文本字号(相对条高,条高为 30)",Se("barFontSize",l.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:we("默认 10")},$("barFontSize")):"",ue?At("打印机分辨率",It,je([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),x=>{if(x==="__multi__")return;const N=Number(x);E("printerDpi",N>0?N:void 0)},{reset:$("printerDpi")}):"",ue?Dt("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",Ke?At("纠错级别",K,je(Zl),x=>{x!=="__multi__"&&E("qrCodeLevel",x||void 0)},{reset:$("qrCodeLevel")}):"",Ke?Ce("静区 (模块)",O({value:Se("qrQuietZone",l.qrQuietZone),min:0,max:8,placeholder:we("默认 0"),onCommit:x=>E("qrQuietZone",x)}),p.propertyTip("cd-quiet-zone"),$("qrQuietZone")):"",ue?Dt("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",Ke||ot?At("缩放模式",xt,je(p.IMAGE_FIT_OPTIONS),x=>{x!=="__multi__"&&E("fit",x)},{reset:$("fit")}):"",ot&&!h&&l.fit==="cover"?Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(l.formatter),fit:l.fit,containerClass:"pd-cell-anchor",widthMm:nt.width,heightMm:nt.height,scale:l.fitScale,value:l.objectPosition,onCommit:x=>E("objectPosition",x),onScaleCommit:x=>E("fitScale",x),resetAnchor:$("objectPosition"),resetScale:$("fitScale")}):"",ue||Ke||ot?Te("最大宽度 (mm)",Se("maxWidth",Ze(l.maxWidth)),"maxWidth",{min:0,max:200,placeholder:we("默认")},$("maxWidth")):"",ue||Ke||ot?Te("最大高度 (mm)",Se("maxHeight",Ze(l.maxHeight)),"maxHeight",{min:0,max:200,placeholder:we("默认")},$("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?A("formatter")??"":l.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:x=>E("formatter",x.target.value||void 0),onDblclick:()=>o.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:l.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),$("align")]),Ge("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?v.values.align??"":l.align||"left",x=>E("align",x))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),$("valign")]),Ge("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?v.values.valign??"":l.valign||"top",x=>E("valign",x))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"字体"}),$("fontFamily")]),lo({id:"cell-font",state:o.state,fonts:o.host.fonts,value:h?A("fontFamily"):l.fontFamily,placeholder:we("继承默认"),onChange:x=>E("fontFamily",x)})]),Te("字号 (pt)",Se("fontSize",Ze(l.fontSize)),"fontSize",{min:0,max:72,placeholder:we("默认")},$("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),$("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?v.values.fontWeight==="bold":l.fontWeight==="bold",onChange:x=>E("fontWeight",x.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),$("color")]),Ae(h?A("color"):l.color,x=>E("color",x),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),$("backgroundColor")]),Ae(h?A("backgroundColor"):l.backgroundColor,x=>E("backgroundColor",x),"背景颜色")])]),Fe("边框"),a("div",{class:"border-style-row"},[Bn(y,[...q?[{value:L,label:"混合",disabled:!0}]:[],...p.BORDER_LINE_STYLES],x=>{x!==L&&Pe(x)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[O({value:W,min:.25,max:5,step:.25,placeholder:h?"多选":X?"混合":void 0,onCommit:x=>b("width",x)})]),Ae(ae,x=>b("color",x),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([x,N])=>a("button",{type:"button",class:"pd-button small",text:N,onClick:()=>{p.applyBorderPreset(n,i,V.style==="none"?"none":x,I()),t.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},sn.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:x.value,checked:te[x.value]==="on",indeterminate:te[x.value]==="mixed",onChange:N=>{const oe=N.target.checked&&V.style!=="none";h&&S({edges:{...v.edges,[x.value]:oe}}),T(De=>{p.setCellBorderEdge(De,x.value,oe?I():null)})}}),a("span",{text:x.label})]))),Dt(h?p.CELL_BORDER_APPLY_HINT_MULTI:Q?p.CELL_BORDER_APPLY_HINT_MIXED:p.CELL_BORDER_APPLY_HINT),Te("内边距 (mm)",Se("padding",Ze(l.padding)),"padding",{min:0,max:10,step:.5,placeholder:we("默认")},$("padding")),bt("自动换行",h?v.values.wordWrap===!0:l.wordWrap??!0,x=>E("wordWrap",x),void 0,$("wordWrap")),G?At("文字溢出",j,je(Ql),x=>{x!=="__multi__"&&E("textFit",x)},{full:!0,reset:$("textFit")}):"",G&&Lt==="shrink"?Te("最小字号 (pt)",Se("shrinkMinFontSize",Ze(l.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:we("默认 6")},$("shrinkMinFontSize")):"",a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!it,title:it||"",onClick:()=>{p.mergeCells(n,i),t.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!he,onClick:()=>{p.splitCells(n,i),t.updateElement(e.id,{tableRows:n})}})])])])}const Po=D.WATERMARK_DENSITY_PRESETS;function Ko(o){const e=o.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function ns(o){return o?o.mode==="binding"?o.binding??"":o.content??"":""}function rs(o){const e=o.store.templateData.watermark,t=ns(e),i=e?.mode==="binding"||t!==""&&Ko(t),n=(()=>{const u=e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(Po))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={testData:e?.testData??"",rotate:e?.rotate??D.WATERMARK_DEFAULTS.rotate,color:e?.color||D.WATERMARK_DEFAULTS.color,opacity:e?.opacity??D.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};o.store.updateTemplateData({watermark:{...h,...u}})},l=()=>o.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:t}),s={rotate:e?.rotate??D.WATERMARK_DEFAULTS.rotate,color:e?.color||D.WATERMARK_DEFAULTS.color,opacity:e?.opacity??D.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight},c=u=>tt({target:s,base:D.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:D.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[Fe("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:t,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(Ko(h)?{mode:"binding",binding:h,content:""}:{mode:"fixed",content:h,binding:""})},onDblclick:l}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:l})]),i?H("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??D.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??D.WATERMARK_DEFAULTS.rotate}°`})]),H("颜色",Ae(e?.color||D.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,c("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??D.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??D.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const h=u.target.value,m=Po[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(Po).map(([u,h])=>a("option",{value:u,text:`${h.label}(${h.width}×${h.height})`,selected:n===u})),a("option",{value:"custom",text:"自定义",selected:n==="custom"})])]),n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),a("input",{type:"number",class:"pd-input",min:D.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth),onChange:u=>r({tileWidth:Number(u.target.value)})})]):"",n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),a("input",{type:"number",class:"pd-input",min:D.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function ce(o,e,t,i,n={},r){return H(e,O({value:t,...n,onCommit:i}),void 0,r)}function Ue(o,e,t,i,n,r,l){const s=document.createElement("select");s.className="pd-select",s.addEventListener("change",()=>n(s.value));for(const c of i){const u=document.createElement("option");u.value=c.value,u.textContent=c.label,s.appendChild(u)}return s.value=t,i.some(c=>c.value===t)||(s.selectedIndex=-1),r?Ce(e,s,r,l):H(e,s,void 0,l)}function ht(o,e,t,i,n){return H(e,a("input",{type:"checkbox",class:"pd-switch",checked:t,onChange:r=>i(r.target.checked)}),void 0,n)}const as=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],ls=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function ss(o,e){const t=o.store,i=e.options,n=e.printElementType.type,r=y=>t.updateElement(e.id,y),l=n==="text"||n==="longText",s=n==="barcode"||n==="qrcode",c=n==="table",u=c&&t.tableSelection?.elementId===e.id,h=u&&p.resolveCellGroupMode(e.options.tableRows??[],t.tableSelection).mode==="multi",m=[];h||m.push(jl(o,e)),u||m.push(ye(o,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"position-grid"},[R(o,"ps-left",ce(o,"X",i.left,y=>r({left:y}),{min:0})),R(o,"ps-top",ce(o,"Y",i.top,y=>r({top:y}),{min:0})),R(o,"ps-width",ce(o,"W",i.width,y=>r({width:y}),{min:4})),R(o,"ps-height",ce(o,"H",i.height,y=>r({height:y}),{min:4}))])])]));const g=p.createDefaultOptions(n),v=(y,W)=>{const ae=p.propertyDefault(W);return tt({target:i,base:g,propKey:y,tipValue:ae?.value,tipUnit:ae?.unit,write:()=>r({[y]:g[y]})})},S=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?p.normalizeRotationAngle(i.rotate):void 0,b=y=>r({rotate:y===void 0||y===0?void 0:p.normalizeRotationAngle(y)}),T=p.isFreeAngleEditable(n,i),E=p.isRotationExcludedType(n)||p.collectFollowMemberIds(t.elements).has(e.id),A=E?"":R(o,"ap-rotate",Ce("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>b((S??0)-90)}),a("div",{class:"pd-rotate-stepper"},[O({value:S,min:0,max:359,placeholder:"0",disabled:!T,onCommit:y=>b(y)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>b((S??0)+90)})]),p.propertyTip("ap-rotate"),v("rotate","ap-rotate"))),P=E||T?"":a("p",{class:"pd-hint pd-rotate-note",text:p.CODE_OBLIQUE_NOTE});if(m.push(ye(o,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},l?[R(o,"ap-font-family",H("字体",lo({id:"prop-font",state:o.state,fonts:o.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:y=>r({fontFamily:y})}),void 0,v("fontFamily","ap-font-family"))),R(o,"ap-font-size",ce(o,"字体大小",i.fontSize,y=>r({fontSize:y}),{min:8,max:72},v("fontSize","ap-font-size"))),R(o,"ap-font-weight",Ue(o,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],y=>r({fontWeight:y}),void 0,v("fontWeight","ap-font-weight"))),R(o,"ap-align",H("对齐",Ge("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",y=>r({textAlign:y})),void 0,v("textAlign","ap-align"))),R(o,"ap-vertical-align",H("垂直对齐",Ge("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",y=>r({verticalAlign:y})),void 0,v("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[R(o,"ap-color",H("颜色",Ae(i.color,y=>r({color:y}),"字体颜色"),void 0,v("color","ap-color"))),R(o,"ap-bg-color",H("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","ap-bg-color")))]),R(o,"ap-line-height",ce(o,"行高",i.lineHeight,y=>r({lineHeight:y||void 0}),{min:0,max:100},v("lineHeight","ap-line-height"))),R(o,"ap-letter-spacing",ce(o,"字间距",i.letterSpacing,y=>r({letterSpacing:y||void 0}),{min:0,max:20,step:.5},v("letterSpacing","ap-letter-spacing"))),R(o,"ap-text-fit",Ue(o,"文字溢出",p.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],y=>r({textFit:y}),void 0,v("textFit","ap-text-fit"))),i.textFit==="shrink"?R(o,"ap-shrink-min",H("最小字号 (pt)",O({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:y=>r({shrinkMinFontSize:y||void 0})}),void 0,v("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?R(o,"ap-long-text-indent",Ce("首行缩进 (字符)",O({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:y=>r({longTextIndent:y||void 0})}),p.propertyTip("ap-long-text-indent"),v("longTextIndent","ap-long-text-indent"))):"",R(o,"ap-word-wrap",ht(o,"自动换行",i.wordWrap!==!1,y=>r({wordWrap:y?void 0:!1}),v("wordWrap","ap-word-wrap"))),R(o,"ap-keep-line-breaks",ht(o,"保留换行符",i.keepLineBreaks===!0,y=>r({keepLineBreaks:y?!0:void 0}),v("keepLineBreaks","ap-keep-line-breaks"))),A,P]:[n==="image"?R(o,"ap-img-fit",Ue(o,"缩放模式",String(i.fit??"contain"),p.IMAGE_FIT_OPTIONS,y=>r({fit:y}),p.propertyTip("ap-img-fit"),v("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?R(o,"ap-img-object-position",Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(i.src),widthMm:Number(i.width)||0,heightMm:Number(i.height)||0,fit:i.fit,scale:i.fitScale,value:i.objectPosition===void 0?void 0:String(i.objectPosition),onCommit:y=>r({objectPosition:y}),onScaleCommit:y=>r({fitScale:y}),resetAnchor:v("objectPosition","ap-img-object-position"),resetScale:v("fitScale","ap-img-fit-scale")})):"",A,P,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),s){const y=n==="barcode",W=String(i.barcodeType||"CODE128").toUpperCase(),ae=i.printerDpi?String(i.printerDpi):"",Pe=p.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);m.push(ye(o,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:I=>I.preventDefault()},[y?[R(o,"cd-type",Ue(o,"码制",W,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],I=>r({barcodeType:I==="CODE128"?void 0:I}))),R(o,"cd-dpi",Ue(o,"打印机分辨率",ae,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],I=>r({printerDpi:Number(I)>0?Number(I):void 0}),void 0,v("printerDpi","cd-dpi"))),R(o,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),R(o,"cd-bar-width",ce(o,"条宽(倍率)",i.barWidth??2,I=>r({barWidth:I}),{min:2,max:8,step:.5},v("barWidth","cd-bar-width"))),R(o,"cd-bar-width",a("p",{class:"pd-hint",text:(ae?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Pe?`。${Pe}`:"")})),R(o,"cd-bar-quiet-zone",Ce("静区 (模块)",O({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:I=>r({barQuietZone:I})}),p.propertyTip("cd-bar-quiet-zone"),v("barQuietZone","cd-bar-quiet-zone"))),R(o,"cd-bar-height",Ce("条高 (mm)",O({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:I=>r({barHeight:I??void 0})}),p.propertyTip("cd-bar-height"),v("barHeight","cd-bar-height"))),R(o,"cd-show-text",ht(o,"显示文本",i.hideTitle!==!0,I=>r({hideTitle:I?void 0:!0}),v("hideTitle","cd-show-text"))),R(o,"cd-font-size",H("文本字号(相对条高,条高为 30)",O({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:I=>r({fontSize:I||void 0})}),void 0,v("fontSize","cd-font-size")))]:[R(o,"cd-ec-level",Ue(o,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],I=>r({qrCodeLevel:I}),void 0,v("qrCodeLevel","cd-ec-level"))),R(o,"cd-quiet-zone",Ce("静区 (模块)",O({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:I=>r({qrQuietZone:I})}),p.propertyTip("cd-quiet-zone"),v("qrQuietZone","cd-quiet-zone")))],Fe("自定义设置"),y?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",y?"":R(o,"cd-fit",Ue(o,"缩放模式",String(i.fit||"contain"),p.IMAGE_FIT_OPTIONS,I=>r({fit:I||void 0}),void 0,v("fit","cd-fit"))),R(o,"cd-max-width",H("最大宽度 (mm)",O({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:I=>r({maxWidth:I||void 0})}),void 0,v("maxWidth","cd-max-width"))),R(o,"cd-max-height",H("最大高度 (mm)",O({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:I=>r({maxHeight:I||void 0})}),void 0,v("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(u&&(m.push(es(o,e)),m.push(is(o,e))),c&&m.push(ts(o,e)),n==="flowList"){const y=p.resolveFlowColumns(i.flowColumns),W=p.resolveFlowRowHeight(i.flowRowHeight),ae=p.resolveFlowGapX(i.flowGapX),Pe=p.resolveFlowMaxSpan(i.flowMaxSpan,y),I=p.suggestFlowColumns(i.width??0,ae,i.fontSize??12);m.push(ye(o,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:te=>te.preventDefault()},[R(o,"fl-columns",Ce("每行列数",O({value:y,min:1,max:12,onCommit:te=>r({flowColumns:p.resolveFlowColumns(te),flowMaxSpan:p.resolveFlowMaxSpan(i.flowMaxSpan,p.resolveFlowColumns(te))})}),p.propertyTip("fl-columns"))),R(o,"fl-row-height",Ce("行高 (mm)",O({value:W,min:3,max:100,step:.5,onCommit:te=>r({flowRowHeight:p.resolveFlowRowHeight(te)})}),p.propertyTip("fl-row-height"))),R(o,"fl-gap-x",Ce("单元横向间距 (mm)",O({value:ae,min:0,max:50,step:.5,onCommit:te=>r({flowGapX:p.resolveFlowGapX(te)})}),p.propertyTip("fl-gap-x"))),R(o,"fl-auto-span",ht(o,"内容过长时跨列",i.flowAutoSpan===!0,te=>{r(te?{flowAutoSpan:te,flowMaxSpan:Pe}:{flowAutoSpan:te})})),i.flowAutoSpan===!0?R(o,"fl-max-span",Ce("最多跨几列",O({value:Pe,min:1,max:y,onCommit:te=>r({flowMaxSpan:p.resolveFlowMaxSpan(te,y)})}),p.propertyTip("fl-max-span"))):"",y>I?a("p",{class:"pd-hint",text:`按当前字号与框宽,${y} 列偏挤(可放约 ${I} 列)。数值保持不变,出纸按 ${y} 列排。`}):""].flat().filter(Boolean))]))}const F=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),U=y=>{const W=F();p.applyElementBorderPreset(W,y,p.effectiveElementBorderSpec(W)),r(W)},se=y=>{const W=F();p.setElementBorderEdgeVisible(W,y,!p.elementBorderEdgeVisible(W,y)),r(W)},V=p.resolveElementBorderDisplay(i),L=V.style==="mixed",_=typeof V.width=="number"?V.width:void 0,q=L||V.style===void 0?"":V.style,X=typeof V.color=="string"?V.color:void 0,pe=(y,W)=>{const ae=F();p.setElementBorderField(ae,y,W),r(ae)},Q=L?[{value:"",label:"混合"},...p.BORDER_LINE_STYLES]:[...p.BORDER_LINE_STYLES];return m.push(ye(o,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[R(o,"bb-border-style",Ue(o,"线型",q,Q,y=>pe("borderStyle",y))),a("div",{class:"border-row"},[R(o,"bb-border-width",ce(o,"边框宽度",_,y=>pe("borderWidth",y),{min:0,max:20,step:.25,placeholder:V.width==="mixed"?"混合":void 0},v("borderWidth","bb-border-width"))),R(o,"bb-border-color",H("边框颜色",Ae(X,y=>pe("borderColor",y),"边框颜色"),void 0,v("borderColor","bb-border-color")))]),...p.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},as.map(y=>a("button",{type:"button",class:"pd-button small",text:y.label,disabled:y.value==="inner",onClick:()=>U(y.value)}))),a("div",{class:"pd-checkbox-group"},ls.map(y=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:p.elementBorderEdgeVisible(i,y.value),onChange:()=>se(y.value)}),a("span",{text:y.label})]))),a("p",{class:"pd-hint",text:p.ELEMENT_BORDER_APPLY_HINT})]:[],R(o,"bb-bg-color",H("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","bb-bg-color")))])])),m.push(os(o,e)),m.push(ye(o,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"advanced-row"},[R(o,"ad-locked",ht(o,"锁定",!!i.locked,y=>r({locked:y}),v("locked","ad-locked"))),R(o,"ad-fixed",ht(o,"每页重复",!!i.fixed,y=>r({fixed:y}),v("fixed","ad-fixed")))]),R(o,"ad-z-index",ce(o,"层级",i.zIndex,y=>r({zIndex:y}),{min:0,max:999},v("zIndex","ad-z-index"))),R(o,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>t.deleteSelected()})]))])],!1)),a("div",{class:"property-content"},m)}function ds(o){const e=o.store,t=e.templateData,i=c=>e.updateTemplateData(c),n=c=>{const u=t.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(c)!==h(t.outputRotation)){const m=D.computeMaxColumns({...t,outputRotation:c});i({outputRotation:c,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:c})},r=[];for(const[c,u]of Object.entries(p.PAPER_PRESETS)){const h=u.group??"其他";let m=r.find(g=>g.group===h);m||(m={group:h,items:[]},r.push(m)),m.items.push({key:c,label:u.label??c})}const l=!p.PAPER_PRESETS[t.paperSize],s=p.isContinuousPaperSize(t.paperSize);return a("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Fe("纸张设置"),H("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:c=>i({paperSize:c.target.value})},[...r.map(c=>a("optgroup",{label:c.group},c.items.map(u=>a("option",{value:u.key,text:u.label,selected:t.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:l})])),s||l?H(s?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[O({value:Number(t.customWidth??0),min:25,max:2e3,onCommit:c=>i({customWidth:c})}),...l?[a("span",{class:"custom-size-x",text:"×"}),O({value:Number(t.customHeight??0),min:25,max:2e3,onCommit:c=>i({customHeight:c})})]:[]])):"",s?"":H("纸张方向",Ge("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],t.orientation==="landscape"?"landscape":"portrait",c=>i({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),s?"":H("内容旋转角度",Ge("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(t.outputRotation??0),c=>n(Number(c)),!0),t.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),H("页面背景色",a("div",{class:"page-bg-row"},[Ae(t.pageBackground,c=>i({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,tt({target:t,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),Pl(o),e.pages.length>1?"":Ll(o),Fe("页边距 (mm)"),a("div",{class:"margin-grid"},[ce(o,"上",t.margins.top,c=>i({margins:{...t.margins,top:c}}),{min:0,max:50}),ce(o,"下",t.margins.bottom,c=>i({margins:{...t.margins,bottom:c}}),{min:0,max:100}),ce(o,"左",t.margins.left,c=>i({margins:{...t.margins,left:c}}),{min:0,max:50}),ce(o,"右",t.margins.right,c=>i({margins:{...t.margins,right:c}}),{min:0,max:50})]),Fe("页眉/页脚高度 (mm)"),ce(o,"页眉高度",t.header.height??10,c=>i({header:{...t.header,height:c}}),{min:0,max:100,step:.1}),ce(o,"页脚高度",t.footer.height??10,c=>i({footer:{...t.footer,height:c}}),{min:0,max:100,step:.1}),rs(o)].filter(Boolean))}function cs(o){const e=o.store,t=o.state,i=e.selectedElement;if(t.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{t.propCollapsed=!1,o.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([r,l,s])=>a("button",{type:"button",class:`pc-btn${t.propTab===r?" on":""}`,title:l,text:s,onClick:()=>{t.propTab=r,t.propCollapsed=!1,o.repaint()}}))])]);const n=i?t.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{t.propCollapsed=!0,o.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[a("button",{type:"button",class:`pd-tab${n==="element"?" active":""}`,text:"元素属性",onClick:()=>{t.propTab="element",o.repaint()}}),a("button",{type:"button",class:`pd-tab${n==="page"?" active":""}`,text:"页面属性",onClick:()=>{t.propTab="page",o.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="element"?"":{display:"none"}},i?[Hl(o),ss(o,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="page"?"":{display:"none"}},[ds(o)])])])}const Lo=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],dn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},ps=[{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()"}],us=[{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()"}],hs=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],fs=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],ms=[{title:"聚合函数",items:ps},{title:"数值运算",items:us},{title:"格式化函数",items:hs}],gs="(输入表达式后预览)",bs="(无法计算)",jo="(表达式错误)";function cn(o,e){if(!o.trim())return gs;try{const t={...p.DEFAULT_DEMO_DATA,...e??{},...D.resolveSystemVariables()},i=p.evaluateTemplate(o,t);return i==null?bs:String(i)}catch{return jo}}function pn(o,e){const t=e.trim().toLowerCase();return t?o.filter(i=>i.label.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):o}function xs(o,e){const t=o.substring(0,e),i=t.lastIndexOf("{"),n=i!==-1&&!t.slice(i+1).includes("}"),r=t.lastIndexOf("("),l=r!==-1&&!t.slice(r+1).includes(")");return{insideBlock:n,insideParens:l}}function vs(o,e){const t=/^\{\s*([^{}]+?)\s*\}$/.exec(o.trim());if(!t)return null;const i=t[1]??"";return e.find(n=>n.fieldKey===i)??null}function Io(o,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:o}),a("span",{class:"ee-item-key",text:e})])}function Oe(o){return o.currentTarget.getRootNode()}function Qt(o,e,t){const i=[];return t.forEach((n,r)=>{i.push(n),r<t.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${o}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function ys(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Qt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","按住 Ctrl(Mac 为 ⌘)双击字段插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Qt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Qt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Qt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function ws(o,e){const t={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding,copiedFieldKey:""},i=(b,T)=>b.querySelector(T),n=b=>{const T=i(b,".ee-preview");if(!T)return;const E=cn(t.expression,o.demoData);T.textContent=E,T.classList.toggle("ee-preview-error",E===jo)},r=()=>{if(t.activeTab==="variable")return pn(fs,t.searchText).map(E=>a("div",{class:"ee-list-item",onDblclick:A=>{const{insideParens:P}=c(A);u(Oe(A),P?E.template.replace(/^\{|\}$/g,""):E.template)}},[Io(E.label,E.template)]));if(t.activeTab==="function")return ms.map(E=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:E.title}),...pn(E.items,t.searchText).map(A=>a("div",{class:"ee-list-item",onDblclick:P=>{const{insideBlock:F}=c(P),U=F?A.template:`{${A.template}}`;u(Oe(P),U,U.indexOf("(")+1)}},[Io(A.label,`${A.name}()`)]))]));const b=p.filterGroups(p.groupFields(o.fields??[]),t.searchText);if(!b.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const T=[];for(const E of b){E.key&&T.push(a("div",{class:`ee-field-group${E.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:E.isList?"📋":"📁"}),a("span",{text:E.label})]));for(const A of E.fields)T.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:E.key?"22px":"10px"},onDblclick:P=>{const{insideParens:F}=c(P),U=P;if(U.ctrlKey||U.metaKey){const se=A.fieldLabel||A.fieldKey;u(Oe(P),F?`"${se}"`:se);return}u(Oe(P),F?A.fieldKey:`{${A.fieldKey}}`)}},[Io(A.fieldLabel,A.fieldKey),a("button",{type:"button",class:`ee-copy-btn${t.copiedFieldKey===A.fieldKey?" is-copied":""}`,"data-tip":t.copiedFieldKey===A.fieldKey?"已复制":`复制字段名「${A.fieldLabel}」`,"aria-label":`复制字段名 ${A.fieldLabel}`,html:ge(t.copiedFieldKey===A.fieldKey?"Check":"Copy",13),onClick:P=>{P.stopPropagation(),s(P,A)},onDblclick:P=>P.stopPropagation()})]))}return T},l=b=>{Array.from(b.querySelectorAll(".ee-nav-tab")).forEach((F,U)=>F.classList.toggle("active",Lo[U]?.key===t.activeTab));const E=i(b,".ee-content-search .pd-input");if(E){const F=dn[t.activeTab];E.placeholder!==F&&(E.placeholder=F),E.value!==t.searchText&&(E.value=t.searchText)}const A=i(b,".ee-textarea");A&&A.value!==t.expression&&(A.value=t.expression);const P=i(b,".ee-content-list");if(P){Tn(P);for(const F of r())me(F,P)}n(b)};function s(b,T){const E=Oe(b);p.copyTextToClipboard(T.fieldLabel||T.fieldKey).then(A=>{A&&(t.copiedFieldKey=T.fieldKey,l(E),setTimeout(()=>{t.copiedFieldKey===T.fieldKey&&(t.copiedFieldKey="",l(E))},1200))})}const c=b=>{const E=i(Oe(b),".ee-textarea")?.selectionStart??t.expression.length;return xs(t.expression,E)},u=(b,T,E=T.length)=>{const A=i(b,".ee-textarea");if(!A){t.expression+=T,n(b);return}const P=A.selectionStart??t.expression.length,F=A.selectionEnd??P;t.expression=t.expression.substring(0,P)+T+t.expression.substring(F);const U=P+E;A.value=t.expression,A.focus(),A.selectionStart=A.selectionEnd=U,n(b)},h=()=>{const b=t.expression;if(t.binding===void 0){o.onApply({formatter:b}),o.onClose();return}const T=vs(b,o.fields??[]);o.onApply(T?{formatter:b,binding:T.fieldKey,title:T.fieldLabel}:{formatter:b}),o.onClose()},m=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},Lo.map((b,T)=>a("div",{class:`ee-nav-tab${t.activeTab===b.key?" active":""}`,text:b.text,onClick:E=>{t.activeTab=Lo[T].key,l(Oe(E))}})))]),g=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:dn[t.activeTab],onInput:b=>{t.searchText=b.target.value,l(Oe(b))}})]),a("div",{class:"ee-content-list"},r())]),v=cn(t.expression,o.demoData),S=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:"双击左侧字段/变量/函数插入,Ctrl/⌘+双击字段插入字段名,或直接输入静态内容",text:t.expression,onInput:b=>{t.expression=b.target.value,n(Oe(b))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${v===jo?" ee-preview-error":""}`,text:v})]),ys()]);return a("div",{class:"pd-dialog-overlay",onKeydown:b=>{b.key==="Escape"&&o.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"expression-editor"},[m,g,S]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>o.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>h()})])])])}const Ss={id:"getting-started",title:"快速入门",content:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@worm-vue3-print/core/designer"),D=require("@worm-vue3-print/core"),Vo=require("@worm-vue3-print/core/browser"),Tn=require("jsbarcode");function a(t,e={},o=[]){return{tag:t,props:e,children:o}}const En="http://www.w3.org/2000/svg",hr=new Set(["draggable","contenteditable","spellcheck"]),fr=new Set(["indeterminate"]);function mr(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function be(t,e){if(typeof t=="string"){const l=document.createTextNode(t);return e.appendChild(l),l}if(t instanceof Node)return e.appendChild(t),t;const{tag:o,props:i,children:n}=t,r=mr(o)?document.createElementNS(En,o):document.createElement(o);for(const[l,s]of Object.entries(i))if(!(s==null||s===!1))if(l==="class")r.setAttribute("class",String(s));else if(l==="style")typeof s=="string"?r.style.cssText=s:Object.assign(r.style,s);else if(l==="html")r.innerHTML=String(s);else if(l==="text")r.textContent=String(s);else if(l.startsWith("on")&&typeof s=="function")r.addEventListener(l.slice(2).toLowerCase(),s);else if(l==="dataset")for(const[c,u]of Object.entries(s))r.dataset[c]=u;else fr.has(l)?r[l]=!0:typeof s=="boolean"?s&&r.setAttribute(l,hr.has(l)?"true":""):r.setAttribute(l,String(s));for(const l of n)be(l,r);return e.appendChild(r),r}function kn(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const gr=En;function Ft(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const No="开启拼版后只能有一个设计页面";function Xo(t){const e=(o,i)=>(o??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&p.syncTableElementSize(r),{id:n.id||p.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...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 Cn(t){const e=t.elements,o=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...t,header:{...t.header,elements:o("header")},footer:{...t.footer,elements:o("footer")},elements:o("content"),guides:[...t.guides??[]]}}function zi(t){const e=(i,n)=>{const r=Xo(p.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!t)return[e(Ft(),0)];const o=Array.isArray(t.pages)?t.pages:[t];return o.length?o.map(e):[e(Ft(),0)]}const ft=t=>JSON.parse(JSON.stringify(t));class An{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=p.useAlign();group=p.useGroup();constructor(e={}){if(this.pages=zi(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(No);return}this.recordHistory();const e=this.pages[this.activePageIndex]??Ft();this.pages.push(Xo({...Ft(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let o=this.pages.length+1;for(;e.has(`页面 ${o}`);)o++;return`页面 ${o}`}duplicatePage(e){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const o=ft(this.pages[e]);o.name=`${o.name??`页面 ${e+1}`} 副本`,o.elements=o.elements.map(i=>({...i,id:p.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[i]=this.pages.splice(e,1);this.pages.splice(o,0,i),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 i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,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 i=this.templateData.guides??[];this.templateData.guides=[...i,{id:p.generateId(),type:e,position:Math.round(o*10)/10}],this.emit()}moveGuide(e,o){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(o*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(o=>o.id!==e),this.emit()}addElement(e,o={},i){const n=p.createRuntimeElement(e,o);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,o={},i,n=!1){const r=n?p.createFieldLabelElement(e):p.createFieldElement(e);return Object.assign(r.options,o),i&&!this.placeAtDropPoint(r,i)||(this.recordHistory(),this.templateData.elements.push(r),this.select(new Set([r.id])),this.emit()),r}placeAtDropPoint(e,o){const i=this.templateData,n=p.zoneFromPaperPoint(i,o.x,o.y);if(n!=="content"&&!p.ZONE_ALLOWED_TYPES.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=p.getZoneRects(i)[n];return e.zone=n,e.options.left=o.x-r.left,e.options.top=o.y-r.top,n!=="content"&&p.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,o){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...o}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[o,i]of this.live){const n=e.find(r=>r.id===o);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const o=this.templateData.elements.find(i=>i.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 i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||p.finalizeElementZone(i,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,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,o),n.printElementType.type==="table"&&p.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const o=this.templateData.elements,i=o.filter(r=>this.selectedIds.has(r.id)),n=o.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=o.findIndex(c=>this.selectedIds.has(c.id)),l=e==="up"?r+1:r-1;if(l<0||l>=o.length)return;const s=[...o];[s[r],s[l]]=[s[l],s[r]],this.templateData.elements=s}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=ft(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 l=r.options.groupId;l&&o.set(l,(o.get(l)??0)+1)}const i=new Map;for(const[r,l]of o)i.set(r,l>=2?p.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const l=ft(r);l.id=p.generateId(),l.options.left+=e,l.options.top+=e,l.options.groupId=l.options.groupId?i.get(l.options.groupId):void 0,n.push(l)}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 i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=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:ft(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:ft(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:ft(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=p.MIN_SCALE_PERCENT){this.scale=Math.max(o,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(Cn),o=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(o)}loadTemplate(e){this.pages=zi(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return p.getPaperDimensions(this.templateData)}}const tt=Symbol("mixed"),Eo=new Set(["text","longText"]),br=["top","right","bottom","left"],xr={on:!0,off:!1,mixed:tt};function Fi(t){const e=p.resolveBorderEdgeStates(t),o={};for(const i of br)o[i]=xr[e[i]];return o}const vr=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class yr{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(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 i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const l=o[n]?.cells[r];l&&!l.merged&&i.push(l)}return i}get textTargets(){return this.selectedElements.filter(e=>Eo.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const o=e[0];return e.every(i=>i===o)?o:tt}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(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:o.every(Boolean)?!0:o.some(Boolean)?tt:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?tt:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?tt:!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(s=>{"fontFamily"in e&&(s.fontFamily=e.fontFamily),"fontSize"in e&&(s.fontSize=e.fontSize),"color"in e&&(s.color=e.color),"backgroundColor"in e&&(s.backgroundColor=e.backgroundColor),"textAlign"in e&&(s.align=e.textAlign),"verticalAlign"in e&&(s.valign=e.verticalAlign)});return}const o=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(s=>s in e),l="backgroundColor"in e;!(o.length&&r)&&!(i.length&&l)||(o.forEach(s=>{const c=s.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)}),l&&i.forEach(s=>{s.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const i=this.values.bold!==!0;this.writeCells(n=>{n.fontWeight=i?"bold":void 0});return}const e=this.values.bold!==!0,o=this.textTargets;o.length&&(o.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const o=this.textTargets;if(!o.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;o.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),l=r.indexOf(e);i&&l<0&&r.push(e),!i&&l>=0&&r.splice(l,1),n.options.textDecoration=r.length?r.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const e=this.store.tableSelection,o=this.tableElement?.options.tableRows;if(!e||!o)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,p.resolveCellGroupMode(o,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=p.resolveCellBorderDisplay(o,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const o=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=o,o===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,o){const i=this.selectedElements;i.length&&(i.forEach(n=>{p.applyElementBorderPreset(n.options,e,o)}),this.commit())}applyCellBorderPreset(e,o){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(p.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,o),this.commit())}applyCellBorderEdges(e,o,i){this.writeCells(n=>{for(const r of e)p.setCellBorderEdge(n,r,i?o:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?Fi(e.map(o=>o.borders)):null}toggleCellEdge(e,o){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],o,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?Fi(e.map(o=>p.elementVisibleBorders(o.options))):null}toggleElementEdge(e,o){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>p.setElementBorderEdgeVisible(r.options,e,n,o)),this.commit()}applyBorderPreset(e){const o=this.borderStyle===null;if(this.context==="cells"){const i=o&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(o||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const o=this.selectedElements;o.length&&(o.forEach(i=>p.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const o={};for(const i of p.ELEMENT_BORDER_SIDES){const n=e[i];n&&(o[i]={...n})}return o}pickPainterSource(e=!1){const o=this.selectedElements[0];if(!o)return!1;const i=o.options,n=o.printElementType.type;return this.painterSnapshot={text:Eo.has(n)?Object.fromEntries(vr.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:p.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=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 i=e.options,n=e.printElementType.type;return o.text&&Eo.has(n)&&Object.assign(i,o.text),i.backgroundColor=o.backgroundColor,o.border&&p.acceptsElementBorder(n)&&(i.borderWidth=o.border.borderWidth,i.borderStyle=o.border.borderStyle,i.borderColor=o.border.borderColor,i.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(i=>{o=this.applyPainter(i)||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 Pi(t,e){(e==null||e>t.length)&&(e=t.length);for(var o=0,i=Array(e);o<e;o++)i[o]=t[o];return i}function wr(t){if(Array.isArray(t))return t}function Sr(t,e){var o=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(o!=null){var i,n,r,l,s=[],c=!0,u=!1;try{if(r=(o=o.call(t)).next,e!==0)for(;!(c=(i=r.call(o)).done)&&(s.push(i.value),s.length!==e);c=!0);}catch(h){u=!0,n=h}finally{try{if(!c&&o.return!=null&&(l=o.return(),Object(l)!==l))return}finally{if(u)throw n}}return s}}function Tr(){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 Er(t,e){return wr(t)||Sr(t,e)||kr(t,e)||Tr()}function kr(t,e){if(t){if(typeof t=="string")return Pi(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)?Pi(t,e):void 0}}const Dn=Object.entries,Li=Object.setPrototypeOf,Cr=Object.isFrozen,Ar=Object.getPrototypeOf,Dr=Object.getOwnPropertyDescriptor;let re=Object.freeze,le=Object.seal,xt=Object.create,Mn=typeof Reflect<"u"&&Reflect,$o=Mn.apply,Bo=Mn.construct;re||(re=function(e){return e});le||(le=function(e){return e});$o||($o=function(e,o){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(o,n)});Bo||(Bo=function(e){for(var o=arguments.length,i=new Array(o>1?o-1:0),n=1;n<o;n++)i[n-1]=arguments[n];return new e(...i)});const Je=ne(Array.prototype.forEach),Mr=ne(Array.prototype.lastIndexOf),Ii=ne(Array.prototype.pop),Ct=ne(Array.prototype.push),_r=ne(Array.prototype.splice),yt=Array.isArray,Rt=ne(String.prototype.toLowerCase),ko=ne(String.prototype.toString),Oi=ne(String.prototype.match),At=ne(String.prototype.replace),Ni=ne(String.prototype.indexOf),Rr=ne(String.prototype.trim),zr=ne(Number.prototype.toString),Fr=ne(Boolean.prototype.toString),$i=typeof BigInt>"u"?null:ne(BigInt.prototype.toString),Bi=typeof Symbol>"u"?null:ne(Symbol.prototype.toString),we=ne(Object.prototype.hasOwnProperty),Dt=ne(Object.prototype.toString),ue=ne(RegExp.prototype.test),Qe=Pr(TypeError);function ne(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var o=arguments.length,i=new Array(o>1?o-1:0),n=1;n<o;n++)i[n-1]=arguments[n];return $o(t,e,i)}}function Pr(t){return function(){for(var e=arguments.length,o=new Array(e),i=0;i<e;i++)o[i]=arguments[i];return Bo(t,o)}}function B(t,e){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Rt;if(Li&&Li(t,null),!yt(e))return t;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=o(n);r!==n&&(Cr(e)||(e[i]=r),n=r)}t[n]=!0}return t}function Lr(t){for(let e=0;e<t.length;e++)we(t,e)||(t[e]=null);return t}function Ce(t){const e=xt(null);for(const i of Dn(t)){var o=Er(i,2);const n=o[0],r=o[1];we(t,n)&&(yt(r)?e[n]=Lr(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=Ce(r):e[n]=r)}return e}function Ir(t){switch(typeof t){case"string":return t;case"number":return zr(t);case"boolean":return Fr(t);case"bigint":return $i?$i(t):"0";case"symbol":return Bi?Bi(t):"Symbol()";case"undefined":return Dt(t);case"function":case"object":{if(t===null)return Dt(t);const e=t,o=_e(e,"toString");if(typeof o=="function"){const i=o(e);return typeof i=="string"?i:Dt(i)}return Dt(t)}default:return Dt(t)}}function _e(t,e){for(;t!==null;){const i=Dr(t,e);if(i){if(i.get)return ne(i.get);if(typeof i.value=="function")return ne(i.value)}t=Ar(t)}function o(){return null}return o}function Or(t){try{return ue(t,""),!0}catch{return!1}}const Hi=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Co=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ao=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Nr=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Do=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),$r=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Wi=re(["#text"]),Ui=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Mo=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Gi=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Br=le(/{{[\w\W]*|^[\w\W]*}}/g),Hr=le(/<%[\w\W]*|^[\w\W]*%>/g),Wr=le(/\${[\w\W]*/g),Ur=le(/^data-[\-\w.\u00B7-\uFFFF]+$/),Gr=le(/^aria-[\-\w]+$/),qi=le(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),qr=le(/^(?:\w+script|data):/i),Kr=le(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),jr=le(/^html$/i),Yr=le(/^[a-z][.\w]*(-[.\w]+)+$/i),Ki=le(/<[/\w!]/g),ji=le(/<[/\w]/g),Vr=le(/<\/no(script|embed|frames)/i),Xr=le(/\/>/i),ke={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_n=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Zr=re(B({},_n)),Qr=(function(){const t={};return Je(_n,e=>{t[e]=le(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),re(t)})(),Jr=function(){return typeof window>"u"?null:window},ea=function(e,o){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";o&&o.hasAttribute(n)&&(i=o.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(l){return l},createScriptURL(l){return l}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},Yi=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},qe=function(e,o,i,n){return we(e,o)&&yt(e[o])?B(n.base?Ce(n.base):{},e[o],n.transform):i},_o=function(e,o,i){const n=we(e,o)?e[o]:void 0;return n&&typeof n=="object"?Ce(n):i()};function Rn(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jr();const e=k=>Rn(k);if(e.version="3.4.14",e.removed=[],!t||!t.document||t.document.nodeType!==ke.document||!t.Element)return e.isSupported=!1,e;let o=t.document;const i=o,n=i.currentScript;t.DocumentFragment;const r=t.HTMLTemplateElement,l=t.Node,s=t.Element,c=t.NodeFilter,u=t.NamedNodeMap;u===void 0&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const h=t.DOMParser,m=t.trustedTypes,g=s.prototype,v=_e(g,"cloneNode"),S=_e(g,"remove"),x=_e(g,"nextSibling"),T=_e(g,"childNodes"),E=_e(g,"parentNode"),A=_e(g,"shadowRoot"),L=_e(g,"attributes"),F=l&&l.prototype?_e(l.prototype,"nodeType"):null,G=l&&l.prototype?_e(l.prototype,"nodeName"):null,ce=l&&l.prototype?_e(l.prototype,"ownerDocument"):null,X=function(d){return F?F(d):d.nodeType},O=function(d){return G?G(d):d.nodeName};if(typeof r=="function"){const k=o.createElement("template");k.content&&k.content.ownerDocument&&(o=k.content.ownerDocument)}let R,K="",Z,fe=!1,J=0;const y=function(){if(J>0)throw Qe('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.')},U=function(d){y(),J++;try{return R.createHTML(d)}finally{J--}},ae=function(d){y(),J++;try{return R.createScriptURL(d)}finally{J--}},Le=function(){return fe||(Z=ea(m,n),fe=!0),Z},N=o,Ie=N.implementation,Oe=N.createNodeIterator,ie=N.createDocumentFragment,De=N.getElementsByTagName,$=i.importNode;let H=Yi();e.isSupported=typeof Dn=="function"&&typeof E=="function"&&Ie&&Ie.createHTMLDocument!==void 0;const co=Br,It=Hr,Ot=Wr,po=Ur,Ye=Gr,Te=qr,Ee=Kr,uo=Yr;let Nt=qi,j=null;const wt=B({},[...Hi,...Co,...Ao,...Do,...Wi]);let Y=null;const at=B({},[...Ui,...Mo,...Gi,...Xt]);let me=Object.seal(xt(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}})),Ve=null,Xe=null;const pe=Object.seal(xt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let $t=!0,q=!0,St=!1,Tt=!0,b=!1,I=!0,te=!1,se=!1,Ue=null,lt=null,ho=!1,st=!1,Bt=!1,Ht=!1,di=!0,ci=!1;const pi="user-content-";let fo=!0,mo=!1,dt={},ct=null;const ui=B({},["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 hi=null;const fi=B({},["audio","video","img","source","image","track"]);let mi=null;const gi=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Wt="http://www.w3.org/1998/Math/MathML",Ut="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let pt=Re,go=!1,bo=null;const Zn=B({},[Wt,Ut,Re],ko),bi=re(["mi","mo","mn","ms","mtext"]);let xo=B({},bi);const xi=re(["annotation-xml"]);let vo=B({},xi);const Qn=B({},["title","style","font","a","script"]);let Et=null;const Jn=["application/xhtml+xml","text/html"],er="text/html";let oe=null,ut=null;const tr=o.createElement("form"),vi=function(d){return d instanceof RegExp||d instanceof Function},yo=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ut&&ut===d)return;(!d||typeof d!="object")&&(d={}),d=Ce(d),Et=Jn.indexOf(d.PARSER_MEDIA_TYPE)===-1?er:d.PARSER_MEDIA_TYPE,oe=Et==="application/xhtml+xml"?ko:Rt,j=qe(d,"ALLOWED_TAGS",wt,{transform:oe}),Y=qe(d,"ALLOWED_ATTR",at,{transform:oe}),bo=qe(d,"ALLOWED_NAMESPACES",Zn,{transform:ko}),mi=qe(d,"ADD_URI_SAFE_ATTR",gi,{transform:oe,base:gi}),hi=qe(d,"ADD_DATA_URI_TAGS",fi,{transform:oe,base:fi}),ct=qe(d,"FORBID_CONTENTS",ui,{transform:oe}),Ve=qe(d,"FORBID_TAGS",Ce({}),{transform:oe}),Xe=qe(d,"FORBID_ATTR",Ce({}),{transform:oe}),dt=we(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?Ce(d.USE_PROFILES):d.USE_PROFILES:!1,$t=d.ALLOW_ARIA_ATTR!==!1,q=d.ALLOW_DATA_ATTR!==!1,St=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Tt=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,b=d.SAFE_FOR_TEMPLATES||!1,I=d.SAFE_FOR_XML!==!1,te=d.WHOLE_DOCUMENT||!1,st=d.RETURN_DOM||!1,Bt=d.RETURN_DOM_FRAGMENT||!1,Ht=d.RETURN_TRUSTED_TYPE||!1,ho=d.FORCE_BODY||!1,di=d.SANITIZE_DOM!==!1,ci=d.SANITIZE_NAMED_PROPS||!1,fo=d.KEEP_CONTENT!==!1,mo=d.IN_PLACE||!1,Nt=Or(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:qi,pt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Re,xo=_o(d,"MATHML_TEXT_INTEGRATION_POINTS",()=>B({},bi)),vo=_o(d,"HTML_INTEGRATION_POINTS",()=>B({},xi));const f=_o(d,"CUSTOM_ELEMENT_HANDLING",()=>xt(null));if(me=xt(null),we(f,"tagNameCheck")&&vi(f.tagNameCheck)&&(me.tagNameCheck=f.tagNameCheck),we(f,"attributeNameCheck")&&vi(f.attributeNameCheck)&&(me.attributeNameCheck=f.attributeNameCheck),we(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(me.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),le(me),b&&(q=!1),Bt&&(st=!0),dt&&(j=B({},Wi),Y=xt(null),dt.html===!0&&(B(j,Hi),B(Y,Ui)),dt.svg===!0&&(B(j,Co),B(Y,Mo),B(Y,Xt)),dt.svgFilters===!0&&(B(j,Ao),B(Y,Mo),B(Y,Xt)),dt.mathMl===!0&&(B(j,Do),B(Y,Gi),B(Y,Xt))),pe.tagCheck=null,pe.attributeCheck=null,we(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?pe.tagCheck=d.ADD_TAGS:yt(d.ADD_TAGS)&&(j===wt&&(j=Ce(j)),B(j,d.ADD_TAGS,oe))),we(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?pe.attributeCheck=d.ADD_ATTR:yt(d.ADD_ATTR)&&(Y===at&&(Y=Ce(Y)),B(Y,d.ADD_ATTR,oe))),we(d,"ADD_FORBID_CONTENTS")&&yt(d.ADD_FORBID_CONTENTS)&&(ct===ui&&(ct=Ce(ct)),B(ct,d.ADD_FORBID_CONTENTS,oe)),fo&&(j["#text"]=!0),te&&B(j,["html","head","body"]),j.table&&(B(j,["tbody"]),delete Ve.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Qe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const w=R;R=d.TRUSTED_TYPES_POLICY;try{K=U("")}catch(C){throw R=w,C}}else d.TRUSTED_TYPES_POLICY===null?(R=void 0,K=""):(R===void 0&&(R=Le()),R&&typeof K=="string"&&(K=U("")));re&&re(d),ut=d},yi=B({},[...Co,...Ao,...Nr]),wi=B({},[...Do,...$r]),or=function(d,f,w){return f.namespaceURI===Re?d==="svg":f.namespaceURI===Wt?d==="svg"&&(w==="annotation-xml"||xo[w]):!!yi[d]},ir=function(d,f,w){return f.namespaceURI===Re?d==="math":f.namespaceURI===Ut?d==="math"&&vo[w]:!!wi[d]},nr=function(d,f,w){return f.namespaceURI===Ut&&!vo[w]||f.namespaceURI===Wt&&!xo[w]?!1:!wi[d]&&(Qn[d]||!yi[d])},rr=function(d){let f=E(d);(!f||!f.tagName)&&(f={namespaceURI:pt,tagName:"template"});const w=Rt(d.tagName),C=Rt(f.tagName);return bo[d.namespaceURI]?d.namespaceURI===Ut?or(w,f,C):d.namespaceURI===Wt?ir(w,f,C):d.namespaceURI===Re?nr(w,f,C):!!(Et==="application/xhtml+xml"&&bo[d.namespaceURI]):!1},Ge=function(d){Ct(e.removed,{element:d});try{E(d).removeChild(d)}catch{if(S(d),!E(d))throw Qe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Si=function(d,f,w){try{d.removeAttributeNode(f)}catch{try{d.removeAttribute(w)}catch{}}},Gt=function(d){qt(d);const f=T(d);if(f){const C=[];Je(f,M=>{Ct(C,M)}),Je(C,M=>{try{S(M)}catch{}})}const w=L(d);if(w)for(let C=w.length-1;C>=0;--C){const M=w[C],z=M&&M.name;typeof z=="string"&&Si(d,M,z)}},Ze=function(d,f,w){if(!w)try{w=f.getAttributeNode(d)}catch{w=null}Ct(e.removed,{attribute:w||null,from:f});try{w?f.removeAttributeNode(w):f.removeAttribute(d)}catch{try{f.removeAttribute(d)}catch{}}if(d==="is")if(st||Bt)try{Ge(f)}catch{}else try{f.setAttribute(d,"")}catch{}},ar=function(d){const f=L(d);if(f)for(let w=f.length-1;w>=0;--w){const C=f[w],M=C&&C.name;typeof M!="string"||Y[oe(M)]||Si(d,C,M)}},qt=function(d){const f=[d];for(;f.length>0;){const w=f.pop();X(w)===ke.element&&ar(w);const M=T(w);if(M)for(let z=M.length-1;z>=0;--z)f.push(M[z])}},Ti=function(d,f){return I?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},lr=function(d){if(!I)return;const f=[d];for(;f.length>0;){const w=f.pop(),C=X(w);if(C===ke.processingInstruction||C===ke.comment&&ue(ji,w.data)){try{S(w)}catch{}continue}if(C===ke.element){const z=w,V=oe(O(w));try{z.hasAttribute&&z.hasAttribute("patchsrc")&&z.removeAttribute("patchsrc"),z.hasAttribute&&z.hasAttribute("for")&&Ti("for",V)&&z.removeAttribute("for")}catch{}}const M=T(w);if(M)for(let z=M.length-1;z>=0;--z)f.push(M[z])}},Ei=function(d){let f=null,w=null;if(ho)d="<remove></remove>"+d;else{const z=Oi(d,/^[\r\n\t ]+/);w=z&&z[0]}Et==="application/xhtml+xml"&&pt===Re&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const C=R?U(d):d;if(pt===Re)try{f=new h().parseFromString(C,Et)}catch{}if(!f||!f.documentElement){f=Ie.createDocument(pt,"template",null);try{f.documentElement.innerHTML=go?K:C}catch{}}const M=f.body||f.documentElement;return d&&w&&M.insertBefore(o.createTextNode(w),M.childNodes[0]||null),pt===Re?De.call(f,te?"html":"body")[0]:te?f.documentElement:M},ki=function(d){const f=ce?ce(d):d.ownerDocument;return Oe.call(f||d,d,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(d){return d=At(d,co," "),d=At(d,It," "),d=At(d,Ot," "),d},wo=function(d){var f;d.normalize();const w=ce?ce(d):d.ownerDocument,C=Oe.call(w||d,d,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let M=C.nextNode();for(;M;)M.data=Kt(M.data),M=C.nextNode();const z=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");z&&Je(z,V=>{ht(V.content)&&wo(V.content)})},jt=function(d){const f=G?G(d):null;return typeof f!="string"||oe(f)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==L(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==F(d)||d.childNodes!==T(d)},ht=function(d){if(!F||typeof d!="object"||d===null)return!1;try{return F(d)===ke.documentFragment}catch{return!1}},kt=function(d){if(!F||typeof d!="object"||d===null)return!1;try{return typeof F(d)=="number"}catch{return!1}};function ze(k,d,f){k.length!==0&&Je(k,w=>{w.call(e,d,f,ut)})}const sr=function(d,f){return!!(I&&d.hasChildNodes()&&!kt(d.firstElementChild)&&ue(Ki,d.textContent)&&ue(Ki,d.innerHTML)||I&&d.namespaceURI===Re&&Zr[f]&&(kt(d.firstElementChild)||typeof d.textContent=="string"&&ue(Qr[f],d.textContent))||d.nodeType===ke.processingInstruction||I&&d.nodeType===ke.comment&&ue(ji,d.data))},Yt=function(d,f){if(d instanceof RegExp)return ue(d,f);if(d instanceof Function){for(var w=arguments.length,C=new Array(w>2?w-2:0),M=2;M<w;M++)C[M-2]=arguments[M];return!!d(f,...C)}return!1},dr=function(d,f,w){if(!Ve[f]&&_i(f)&&Yt(me.tagNameCheck,f))return!1;if(fo&&!ct[f]){const C=E(d),M=T(d);if(M&&C){const z=M.length;for(let V=z-1;V>=0;--V){const Q=d===w?v(M[V],!0):M[V];C.insertBefore(Q,x(d))}}}return Ge(d),!0},Ci=function(d,f,w,C){return d.length===0?f:f===w||f===C?Ce(f):f},Ai=function(d,f){return d===f||E(d)!==null?!1:(mo&&qt(d),!0)},Di=function(d,f){if(ze(H.beforeSanitizeElements,d,null),Ai(d,f))return!0;if(jt(d))return Ge(d),!0;const w=oe(O(d));if(j=Ci(H.uponSanitizeElement,j,wt,Ue),ze(H.uponSanitizeElement,d,{tagName:w,allowedTags:j}),Ai(d,f))return!0;if(sr(d,w))return Ge(d),!0;if(Ve[w]||!(pe.tagCheck instanceof Function&&pe.tagCheck(w))&&!j[w]){const M=dr(d,w,f);return M===!1&&ze(H.afterSanitizeElements,d,null),M}if(X(d)===ke.element&&!rr(d)||(w==="noscript"||w==="noembed"||w==="noframes")&&ue(Vr,d.innerHTML))return Ge(d),!0;if(b&&d.nodeType===ke.text){const M=Kt(d.textContent);d.textContent!==M&&(Ct(e.removed,{element:d.cloneNode()}),d.textContent=M)}return ze(H.afterSanitizeElements,d,null),!1},Mi=function(d,f,w){if(Xe[f]||Ti(f,d)||di&&(f==="id"||f==="name")&&(w in o||w in tr))return!1;const C=Y[f]||pe.attributeCheck instanceof Function&&pe.attributeCheck(f,d);return q&&ue(po,f)||$t&&ue(Ye,f)?!0:C?mi[f]||ue(Nt,At(w,Ee,""))||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Ni(w,"data:")===0&&hi[d]||St&&!ue(Te,At(w,Ee,""))?!0:!w:_i(d)&&Yt(me.tagNameCheck,d)&&Yt(me.attributeNameCheck,f,d)||f==="is"&&me.allowCustomizedBuiltInElements&&Yt(me.tagNameCheck,w)},cr=B({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),_i=function(d){return!cr[Rt(d)]&&ue(uo,d)},pr=function(d,f,w,C){if(R&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!w)switch(m.getAttributeType(d,f)){case"TrustedHTML":return U(C);case"TrustedScriptURL":return ae(C)}return C},ur=function(d,f,w,C){try{w?d.setAttributeNS(w,f,C):d.setAttribute(f,C),jt(d)?Ge(d):Ii(e.removed)}catch{Ze(f,d)}},Ri=function(d){ze(H.beforeSanitizeAttributes,d,null);const f=d.attributes;if(!f||jt(d))return;Y=Ci(H.uponSanitizeAttribute,Y,at,lt);const w={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Y,forceKeepAttr:void 0};let C=f.length;const M=oe(d.nodeName);for(;C--;){const z=f[C],V=z.name,Q=z.namespaceURI,ve=z.value,ye=oe(V),To=ve;let ge=V==="value"?To:Rr(To);if(w.attrName=ye,w.attrValue=ge,w.keepAttr=!0,w.forceKeepAttr=void 0,ze(H.uponSanitizeAttribute,d,w),ge=w.attrValue,ci&&(ye==="id"||ye==="name")&&Ni(ge,pi)!==0&&(Ze(V,d,z),ge=pi+ge),I&&ue(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ge)){Ze(V,d,z);continue}if(ye==="attributename"&&Oi(ge,"href")){Ze(V,d,z);continue}if(!w.forceKeepAttr){if(!w.keepAttr){Ze(V,d,z);continue}if(!Tt&&ue(Xr,ge)){Ze(V,d,z);continue}if(b&&(ge=Kt(ge)),!Mi(M,ye,ge)){Ze(V,d,z);continue}ge=pr(M,ye,Q,ge),ge!==To&&ur(d,V,Q,ge)}}ze(H.afterSanitizeAttributes,d,null)},Vt=function(d){let f=null;const w=ki(d);for(ze(H.beforeSanitizeShadowDOM,d,null);f=w.nextNode();)if(ze(H.uponSanitizeShadowNode,f,null),Di(f,d),Ri(f),ht(f.content)&&Vt(f.content),X(f)===ke.element){const C=A(f);ht(C)&&(So(C),Vt(C))}ze(H.afterSanitizeShadowDOM,d,null)},So=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const w=f.pop();if(w.shadow){Vt(w.shadow);continue}const C=w.node,z=X(C)===ke.element,V=T(C);if(V)for(let Q=V.length-1;Q>=0;--Q)f.push({node:V[Q],shadow:null});if(z){const Q=G?G(C):null;if(typeof Q=="string"&&oe(Q)==="template"){const ve=C.content;ht(ve)&&f.push({node:ve,shadow:null})}}if(z){const Q=A(C);ht(Q)&&f.push({node:null,shadow:Q},{node:Q,shadow:null})}}};return e.sanitize=function(k){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,w=null,C=null,M=null;if(go=!k,go&&(k="<!-->"),typeof k!="string"&&!kt(k)&&(k=Ir(k),typeof k!="string"))throw Qe("dirty is not a string, aborting");if(!e.isSupported)return k;se?(j=Ue,Y=lt):yo(d),(H.uponSanitizeElement.length>0||H.uponSanitizeAttribute.length>0)&&(j=Ce(j)),H.uponSanitizeAttribute.length>0&&(Y=Ce(Y)),e.removed=[];const z=mo&&typeof k!="string"&&kt(k);if(z){lr(k);const ve=O(k);if(typeof ve=="string"){const ye=oe(ve);if(!j[ye]||Ve[ye])throw Gt(k),Qe("root node is forbidden and cannot be sanitized in-place")}if(jt(k))throw Gt(k),Qe("root node is clobbered and cannot be sanitized in-place");try{So(k)}catch(ye){throw Gt(k),ye}}else if(kt(k))f=Ei("<!---->"),w=f.ownerDocument.importNode(k,!0),w.nodeType===ke.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?f=w:f.appendChild(w),So(w);else{if(!st&&!b&&!te&&k.indexOf("<")===-1)return R&&Ht?U(k):k;if(f=Ei(k),!f)return st?null:Ht?K:""}f&&ho&&Ge(f.firstChild);const V=z?k:f;try{const ve=ki(V);for(;C=ve.nextNode();)Di(C,V),Ri(C),ht(C.content)&&Vt(C.content)}catch(ve){throw z&&(Gt(k),Je(e.removed,ye=>{ye.element&&qt(ye.element)})),ve}if(z)return Je(e.removed,ve=>{ve.element&&qt(ve.element)}),b&&wo(k),k;if(st){if(b&&wo(f),Bt)for(M=ie.call(f.ownerDocument);f.firstChild;)M.appendChild(f.firstChild);else M=f;return(Y.shadowroot||Y.shadowrootmode)&&(M=$.call(i,M,!0)),M}let Q=te?f.outerHTML:f.innerHTML;return te&&j["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&ue(jr,f.ownerDocument.doctype.name)&&(Q="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
3
+ `+Q),b&&(Q=Kt(Q)),R&&Ht?U(Q):Q},e.setConfig=function(){let k=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yo(k),se=!0,Ue=j,lt=Y},e.clearConfig=function(){ut=null,se=!1,Ue=null,lt=null,R=Z,K=""},e.isValidAttribute=function(k,d,f){ut||yo({});const w=oe(k),C=oe(d);return Mi(w,C,f)},e.addHook=function(k,d){typeof d=="function"&&we(H,k)&&Ct(H[k],d)},e.removeHook=function(k,d){if(we(H,k)){if(d!==void 0){const f=Mr(H[k],d);return f===-1?void 0:_r(H[k],f,1)[0]}return Ii(H[k])}},e.removeHooks=function(k){we(H,k)&&(H[k]=[])},e.removeAllHooks=function(){H=Yi()},e}var ta=Rn();const oa={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ia(t){const e=t.options;return p.resolveBarcodeDesignValue(e.formatter,void 0,String(e.testData||e.title||""))||"条码"}function na(t){return a("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function ra(t){const e=t.options;return a("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:oa[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function aa(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 la(t,e){const o=t.options,i=p.barcodeUnitsPerModule(o.barWidth),n=p.barcodeQuietZoneModules(o.barQuietZone),r=l=>{Tn(e,ia(t),{format:String(o.barcodeType||"CODE128"),width:i,height:l*i,displayValue:!o.hideTitle,fontSize:(o.fontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*i,margin:0,marginLeft:n*i,marginRight:n*i,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*i});const s=aa(e);return s?{widthUnits:s.width,heightUnits:s.height}:null};try{const l=p.layoutBarcodeSize({barHeightMm:o.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(o.width,o.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(o.height,o.maxHeight),dpi:o.printerDpi,barWidth:o.barWidth,measure:r});e.style.width=l.size?`${l.size.widthMm}mm`:"",e.style.height=l.size?`${l.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function sa(t,e){const o=t.options,i=p.resolveBarcodeDesignValue(o.formatter,void 0,String(o.testData||o.title||""))||"二维码";e.replaceChildren();try{const n=Vo.browserCodeRenderer.render(i,"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(n)}`,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 da(t,e){for(const o of Array.from(t.querySelectorAll("[data-code-kind]"))){const i=o.dataset.codeId,n=e.find(r=>r.id===i);if(n)if(o.dataset.codeKind==="barcode"){const r=o.querySelector("svg");r&&la(n,r)}else sa(n,o)}}const ca={header:"题",data:"数",subtotal:"小",summary:"汇"},pa=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],eo=3.7795275591,ua=.1,Ho=t=>JSON.parse(JSON.stringify(t)),Vi=new WeakMap;function We(t){let e=Vi.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Vi.set(t,e)),e}function Lt(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function ha(t,e){const o=t.tableSelection;return!o||o.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):o}function zn(t,e,o){const i=Lt(t,o.id);if(!i)return null;const n=o.options;return{store:t,fire:e,el:o,real:i,options:n,rows:n.tableRows??[],colWidths:n.tableColWidths??[],isSelected:t.selectedIds.has(o.id),selection:ha(t,o),maxTableWidth:Fn(t)}}function Fn(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function Zo(t){return t.options.tableDefaultFontSize??10}function Pn(t){return t.options.tableDefaultColor??"#333333"}function fa(t,e){let o=0;for(let i=0;i<e;i++)o+=t.rows[i].height;return o}function ma(t,e){return We(t.store).layouts.get(t.el.id)?.[e]?.top??fa(t,e)}function ga(t,e){return We(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function ba(t){const e=t.options.dataSource;if(e&&Array.isArray(p.DEFAULT_DEMO_DATA[e]))return p.DEFAULT_DEMO_DATA[e];for(const o of Object.values(p.DEFAULT_DEMO_DATA))if(Array.isArray(o))return o}function Ln(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function In(t,e){return Ln(e)?p.resolveBarcodeDesignValue(e.formatter,ba(t)):e.formatter||""}function xa(t,e){const o={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:D.resolveCanvasFontFamily(e.fontFamily??t.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??Zo(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??Pn(t),backgroundColor:e.backgroundColor??"transparent",borderTop:p.resolveCellBorderCss(e.borders?.top,o),borderRight:p.resolveCellBorderCss(e.borders?.right,o),borderBottom:p.resolveCellBorderCss(e.borders?.bottom,o),borderLeft:p.resolveCellBorderCss(e.borders?.left,o),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function va(t,e,o){const i=t.selection;return[!!i&&e>=i.r1&&e<=i.r2&&o>=i.c1&&o<=i.c2?"cell-selected":"",t.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function On(t){return p.resolveCellTextFit(t)}function ya(t){return On(t)!=="autoHeight"}function wa(t,e){return e.fontSize??Zo(t)}function ro(t,e,o){return p.cellFitCapMm(t.rows,e,o,t.options.tableDefaultPadding??1)}function Sa(t,e,o){return p.cellFitWidthMm(t.colWidths,e,o,t.options.tableDefaultPadding??1)}function Ta(t,e,o){return{maxHeight:ro(t,o,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Ea(t,e,o){const i={fitBase:String(wa(t,e)),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(ro(t,o,e))};return On(e)==="shrink"&&(i.fit="shrink"),i}function ka(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 Ca={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Aa(t,e,o,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(gr,"svg");n.appendChild(r);const l=In(t,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Ca[i.fit||"contain"]??"xMidYMid meet");const s=p.barcodeUnitsPerModule(i.barWidth),c=p.barcodeQuietZoneModules(i.barQuietZone),u=g=>{Tn(r,l,{format:i.barcodeType||"CODE128",width:s,height:g*s,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*s,margin:0,marginLeft:c*s,marginRight:c*s,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*s});const v=ka(r);return v?{widthUnits:v.width,heightUnits:v.height}:null};let h=null;try{h=p.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(Sa(t,o,i),i.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(ro(t,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=l||"条码",n.appendChild(g),n}const m=h.size;return m?(r.style.width=`${m.widthMm}mm`,r.style.height=`${m.heightMm}mm`):(r.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",r.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),n}if(r.style.display="none",!l)return n;try{const s=Vo.browserCodeRenderer.render(l,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=i.fit||"contain",i.objectPosition&&(c.style.objectPosition=i.objectPosition),c.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",c.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(c)}catch{}return n}function Xi(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function Da(t){const e=t.formatter||"";return e?e.includes("{")?p.evaluateTemplate(e,p.DEFAULT_DEMO_DATA):e:""}function Ma(t,e,o){const i=document.createElement("div");i.className="cell-image";const n=p.cellImageBoxMm(o.fit,ro(t,e,o));n!==void 0&&(i.style.height=`${n}mm`);const r=Da(o);if(!r)return i.appendChild(Xi()),i;const l=document.createElement("img");l.setAttribute("src",r),n!==void 0&&(l.style.width="100%",l.style.height="100%"),l.style.objectFit=o.fit||"contain";for(const[s,c]of Object.entries(p.cropStyleDeclarations(o.fit,o.fitScale,o.objectPosition)))l.style[s]=c;return l.style.maxWidth=o.maxWidth?`${o.maxWidth}mm`:"100%",l.style.maxHeight=o.maxHeight?`${o.maxHeight}mm`:"100%",l.addEventListener("error",()=>{l.remove(),i.appendChild(Xi())},{once:!0}),i.appendChild(l),i}function _a(t,e,o,i,n){if(Ln(n))return Aa(t,o,i,n);if(n.cellType==="image")return Ma(t,o,n);const r=In(t,n),l=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return ya(n)?a("div",{class:"cell-fit",style:Ta(t,n,o),dataset:Ea(t,n,o)},[l()]):l()}function oo(t,e,o){const i={elementId:t.el.id,...p.normalizeSelection(t.rows,e,o)};t.store.setTableSelection(i),t.fire("table-selection-change",{elementId:t.el.id,selection:i})}function Ra(t,e,o,i,n){if(n.button!==0||(t.fire("table-cell-mousedown",{elementId:t.el.id,r:e,c:o,cellId:i,event:n}),!t.isSelected))return;n.stopPropagation();const r=We(t.store);n.shiftKey&&t.selection?oo(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:o}):(r.anchor={r:e,c:o},oo(t,{r:e,c:o},{r:e,c:o})),document.addEventListener("mouseup",()=>{We(t.store).anchor=null},{once:!0})}function za(t,e,o){const i=We(t.store).anchor;i&&oo(t,i,{r:e,c:o})}function Qo(t,e){const o=We(t);o.menu?.visible&&(o.menu.visible=!1,e("table-menu-close",{elementId:o.menuElId}),t.emit(!1))}function Fa(t,e,o,i){i.preventDefault(),i.stopPropagation(),t.isSelected||t.store.selectOne(t.el.id);const n=t.selection;n&&e>=n.r1&&e<=n.r2&&o>=n.c1&&o<=n.c2||oo(t,{r:e,c:o},{r:e,c:o});const l=We(t.store);l.menuElId=t.el.id,l.menu&&(l.menu.x=i.clientX,l.menu.y=i.clientY,l.menu.visible=!0),t.fire("table-cell-contextmenu",{elementId:t.el.id,r:e,c:o,clientX:i.clientX,clientY:i.clientY}),t.store.emit(!1),document.addEventListener("mousedown",()=>Qo(t.store,t.fire),{once:!0})}function Zi(t,e,o){const i=t.reduce((n,r)=>n+r,0)+(t[e]??0);return i>o?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${o}mm,请先缩小列宽`:null}function Pa(t,e){const o=t.real.options.tableRows??[],i=t.real.options.tableColWidths??[],n=e(Ho(o),Ho(i));return n?(window.alert(n),!1):(t.store.recordHistory(),e(o,i),t.store.setTableSelection(null),p.syncTableElementSize(t.real.options),t.store.emit(),!0)}function Ne(t,e,o){Qo(t.store,t.fire);const i=t.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(p.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(p.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>p.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,l)=>{const s=Zi(l,i.c1,t.maxTableWidth);return s||(p.insertCol(r,l,i.c1,"left"),null)};break;case"insert-col-right":n=(r,l)=>{const s=Zi(l,i.c2,t.maxTableWidth);return s||(p.insertCol(r,l,i.c2,"right"),null)};break;case"delete-col":n=(r,l)=>p.deleteCol(r,l,i.c1);break;case"merge":n=r=>(p.mergeCells(r,i),null);break;case"split":n=r=>(p.splitCells(r,i),null);break;case"set-row-type":n=r=>o?p.setRowType(r,i.r1,o):"未指定行类型";break}n&&Pa(t,n)&&t.fire(`table-${e}`,{elementId:t.el.id,...o?{type:o}:{}})}function La(t){const e=t.selection;if(!e)return!1;for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const n=t.rows[o]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function Ia(t){const e=t.selection;if(!e)return;const o=p.findMainCell(t.rows,e.r1,e.c1),i=!t.rows[o.r]?.cells[o.c]?.mergeSameValue;for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const l=t.rows[n]?.cells[r];l&&!l.merged&&(l.mergeSameValue=i)}t.store.updateElement(t.el.id,{tableRows:t.rows}),Qo(t.store,t.fire)}function Qi(t){const e=t.selection;if(!e)return"未选择单元格";for(let o=e.r1;o<=e.r2;o++)if(t.rows[o]?.type!=="data")return"仅数据行(明细行)支持按值合并";return null}function Ji(t,e){const o=t.selection;return o?o.r1!==o.r2?"行类型仅支持单行设置":p.setRowType(Ho(t.rows),o.r1,e):"未选择单元格"}function Fe(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 Ro=()=>a("div",{class:"menu-divider"});function Oa(t,e,o){const i=We(t);if(i.menu=o,!o.visible||!i.menuElId)return"";const n=Lt(t,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=zn(t,e,n);if(!r)return"";const l=r.selection?p.canMergeReason(r.rows,r.selection):"未选择单元格",s=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()},[Fe("在上方插入行",()=>Ne(r,"insert-row-above")),Fe("在下方插入行",()=>Ne(r,"insert-row-below")),Fe("删除行",()=>Ne(r,"delete-row"),{disabled:r.rows.length<=1}),Ro(),Fe("在左侧插入列",()=>Ne(r,"insert-col-left")),Fe("在右侧插入列",()=>Ne(r,"insert-col-right")),Fe("删除列",()=>Ne(r,"delete-col"),{disabled:r.colWidths.length<=1}),Ro(),Fe("合并单元格",()=>Ne(r,"merge"),{disabled:!!l,title:l||""}),Fe("拆分单元格",()=>Ne(r,"split"),{disabled:!La(r)}),Fe("按值合并",()=>Ia(r),{disabled:!!Qi(r),title:Qi(r)||"",active:(()=>{const c=r.selection;if(!c)return!1;const u=p.findMainCell(r.rows,c.r1,c.c1);return r.rows[u.r]?.cells[u.c]?.mergeSameValue===!0})()}),Ro(),a("div",{class:"menu-group-title",text:"行类型"}),...pa.map(c=>Fe(c.label,()=>Ne(r,"set-row-type",c.value),{disabled:!!Ji(r,c.value),title:Ji(r,c.value)||"",active:s===c.value}))])}let it=null;function Nn(){it&&(document.removeEventListener("mousemove",Jo),document.removeEventListener("mouseup",ei),it.handle.classList.remove("dragging"),it=null)}function Na(t,e){const o=t.closest(".hiprint-printPaper");return(o&&o.offsetWidth>0?o.getBoundingClientRect().width/o.offsetWidth:0)||(e.scale||100)/100}function $a(t,e,o){if(o.button!==0)return;const i=o.currentTarget,n=i.closest(".print-table");if(!n)return;Nn();const r=t.real.options.tableColWidths??[];it={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:o.clientX,startWidth:r[e-1]??0,scale:Na(n,t.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",Jo),document.addEventListener("mouseup",ei)}function Jo(t){const e=it;if(!e)return;const o=Lt(e.store,e.elId),i=o?.options.tableColWidths;if(!o||!i)return;const n=(t.clientX-e.startX)/(e.scale*eo),r=e.boundary-1;i[r]=p.clampResizedColumnWidth(i,r,e.startWidth+n,Fn(e.store)),p.syncTableElementSize(o.options),i.forEach((l,s)=>{const c=e.root.querySelector(`colgroup col:nth-child(${s+1})`);c&&(c.style.width=`${l}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((l,s)=>{l.style.left=`${i.slice(0,s+1).reduce((c,u)=>c+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${o.options.width}mm`,e.wrapper.style.height=`${o.options.height}mm`)}function ei(){document.removeEventListener("mousemove",Jo),document.removeEventListener("mouseup",ei);const t=it;if(!t)return;it=null,t.handle.classList.remove("dragging");const e=Lt(t.store,t.elId);e&&p.syncTableElementSize(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function Ba(t,e,o){const i=o.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Lt(t,e);if(!r)return;let l=!1;const s=n/eo;Math.abs(s-(r.options.height??0))>ua&&(r.options.height=Math.round(s*100)/100,l=!0);const c=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-c)/eo,height:m.offsetHeight/eo})),h=We(t);Ha(h.layouts.get(e),u)||(h.layouts.set(e,u),l=!0),l&&t.emit(!1)}function Ha(t,e){return!t||t.length!==e.length?!1:e.every((o,i)=>{const n=t[i];return Math.round(o.top*10)===Math.round(n.top*10)&&Math.round(o.height*10)===Math.round(n.height*10)})}function Wa(t,e){const o=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const i=o.parentElement;i&&Ba(t,e,i)}),o}function Ua(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function Ga(t){return Array.from({length:t.colWidths.length},(e,o)=>o+1)}function qa(t,e){return t.colWidths.slice(0,e).reduce((o,i)=>o+i,0)}function Ka(t,e,o){const i=zn(e,o,t);if(!i)return a("div",{class:"print-table"});const n=[a("table",{style:{fontSize:`${Zo(i)}pt`,color:Pn(i)}},[a("colgroup",{},i.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},i.rows.map((r,l)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((s,c)=>s.merged?"":a("td",{rowspan:s.rowspan||1,colspan:s.colspan||1,class:va(i,l,c),style:xa(i,s),onMousedown:u=>Ra(i,l,c,s.id,u),onMouseenter:()=>za(i,l,c),onContextmenu:u=>Fa(i,l,c,u)},[_a(i,r,l,c,s)])).filter(Boolean))))])];return Ua(i)&&n.push(a("div",{class:"col-resize-layer"},Ga(i).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:qa(i,r)+"mm"},onMousedown:l=>{l.stopPropagation(),l.preventDefault(),$a(i,r,l)}})))),i.isSelected&&n.push(a("div",{class:"row-badges"},i.rows.map((r,l)=>a("span",{class:"row-badge",style:{top:ma(i,l)+"mm",height:ga(i,l)+"mm"},text:ca[r.type]})))),n.push(Wa(e,t.id)),a("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:r=>r.preventDefault()},n)}const ja=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function Wo(t){return Array.isArray(t)&&t.length>0?t:[]}function Ya(t,e){const o=p.detectFlowListKey(t,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(o)return Wo(e?.[o]);const i=p.detectFlowListKey(t,p.DEFAULT_DEMO_DATA);return i?Wo(p.DEFAULT_DEMO_DATA[i]):[]}function Va(t,e){const o=t.options,i=typeof o.formatter=="string"?o.formatter:"",n=Wo(e)[0],r=Ya(i,n);if(r.length===0)return[...ja];if(!i)return r.map(c=>String(c?.name??JSON.stringify(c)));const l=n??{},s=p.detectFlowListKey(i,l)??Object.keys(l).find(c=>Array.isArray(l[c]));return r.map(c=>{try{return p.evaluateTemplate(i,{...l,...c,...s?{[s]:c}:{}})}catch{return i}})}const Xa=3.7795275591,Za=.1;function Qa(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function Ja(t){const e=t.parentElement;if(!e?.classList.contains("print-element"))return 0;const o=getComputedStyle(e);return(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0)}function el(t,e,o){const i=o.offsetHeight+Ja(o);if(i<=0)return;const n=Qa(t,e);if(!n)return;const r=i/Xa;Math.abs(r-(n.options.height??0))>Za&&(n.options.height=Math.round(r*100)/100,t.emit(!1))}function tl(t,e){const o=document.createComment("pd-flowlist-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const i=o.parentElement;i&&el(t,e,i)}),o}function ol(t,e,o){const i=t.options,n=p.resolveFlowColumns(i.flowColumns),r=p.resolveFlowGapX(i.flowGapX),l=p.resolveFlowRowHeight(i.flowRowHeight),s=p.resolveFlowLayoutMode(i.flowLayoutMode)==="dynamic",c=p.resolveFlowPadding(i),u={display:"grid",gridTemplateColumns:`repeat(${n},minmax(0,1fr))`,columnGap:`${r}mm`,gridAutoRows:`minmax(${l}mm,auto)`,width:"100%",...s?{padding:`${c.top}mm ${c.right}mm ${c.bottom}mm ${c.left}mm`,height:"auto",overflow:"visible"}:{height:"100%",overflow:"hidden"},fontSize:`${i.fontSize||12}pt`,fontWeight:i.fontWeight||"normal",color:i.color||"#333",boxSizing:"border-box"};i.fontFamily&&(u.fontFamily=String(i.fontFamily)),i.backgroundColor&&(u.backgroundColor=String(i.backgroundColor));const h=Va(t,e).map(m=>a("div",{class:"print-flow-cell",text:m}));return s&&o&&h.push(tl(o,t.id)),a("div",{class:"print-flowlist",style:u},h)}const en={top:"flex-start",middle:"center",bottom:"flex-end"},il={left:"flex-start",center:"center",right:"flex-end"};function nl(t,e){const o=t.options,i=p.resolveElementBorder(t.printElementType.type,o),n={};if(i?.all&&(n.border=`${i.all.borderWidth} ${i.all.borderStyle} ${i.all.borderColor}`),i)for(const r of p.ELEMENT_BORDER_SIDES){const l=i.edges[r];l&&(n[`border${r.charAt(0).toUpperCase()}${r.slice(1)}`]=`${l.borderWidth} ${l.borderStyle} ${l.borderColor}`)}return{position:"absolute",left:`${o.left}mm`,top:`${o.top}mm`,width:`${o.width}mm`,height:`${o.height}mm`,zIndex:String(o.zIndex||"auto"),...n,...rl(t,e)}}function rl(t,e){if(e?.has(t.id))return{};const o=p.resolveElementRotation(t.printElementType.type,t.options);return o===void 0?{}:{rotate:`${o}deg`}}function tn(t){const e=t.options,o=t.printElementType.type==="longText",i=p.resolveElementTextFit(t.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",l={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:D.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`: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`}};p.resolveElementNowrap(e)&&(l.whiteSpace="nowrap",l.textOverflow="ellipsis");const s=p.resolveElementWhiteSpace(e);return s&&(l.whiteSpace=s),e.verticalAlign&&(l.display="flex",e.textAlign==="justify"?(l.flexDirection="column",l.justifyContent=en[e.verticalAlign]??"flex-start"):(l.alignItems=en[e.verticalAlign]??"flex-start",l.justifyContent=il[e.textAlign||"left"]??"flex-start")),{style:l,fit:i}}function al(t){const e=t.options,o=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return t.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${o} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${o} ${i} ${n}`,boxSizing:"border-box"}}function ll(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 sl(t){const e=t.options;return{objectFit:e.fit||"contain",...p.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function on(t){const e=t.options,o={fitBase:String(e.fontSize||12),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return p.resolveElementTextFit(t.printElementType.type,e)==="shrink"&&(o.fit="shrink"),o}function dl(t,e,o){const i=t.printElementType.type,n=t.options;switch(i){case"text":{const{style:r}=tn(t);return a("div",{class:"print-text",style:r,dataset:on(t),text:String(n.testData||n.formatter||"")||"文本"})}case"longText":{const{style:r}=tn(t);return a("div",{class:"print-longtext",style:r,dataset:on(t),text:String(n.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:al(t)});case"rect":case"oval":return a("div",{class:"print-shape",style:ll(t)});case"image":{const r=String(n.src??""),l=r.includes("{")?p.evaluateTemplate(r,p.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[l?a("img",{src:l,style:sl(t)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return na(t);case"barcode":return ra(t);case"html":{const r=String(n.formatter??""),l=r?ta.sanitize(p.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:l})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:D.resolveCanvasFontFamily(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:n.title||"{pageIndex}/{totalPages}"});case"table":return o?Ka(t,o.store,o.fire):a("div",{class:"print-table"});case"flowList":return ol(t,void 0,o?.store);default:return a("div",{text:i})}}function $n(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function cl(t,e,o){const i=t.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),l=e.options,s=e.zone||"content",c=[dl(e,!0,{store:i,fire:t.fire})];return i.draggingIds.has(e.id)&&c.push(a("div",{class:"drag-preview"})),n&&(c.push(a("div",{class:"resize-handles"},p.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>t.fire("resize-start",{event:h,id:e.id,point:u})})))),c.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:$n(l)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${s}`,n?"selected":"",r?"previewed":"",i.draggingIds.has(e.id)?"drag-ghost":"","design-mode",l.locked?"locked":"",l.visible===!1?"hidden":""].filter(Boolean).join(" "),style:nl(e,o),dataset:{elId:e.id},onMousedown:u=>t.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),t.fire("contextmenu",{event:u,id:e.id})}},c)}function Uo(t,e){const o=t.margins,i=t.header?.height??10,n=t.footer?.height??10,r=e.width-o.left-o.right;return{header:{left:o.left,top:o.top,width:r,height:i},content:{left:o.left,top:o.top+i,width:r,height:e.height-o.top-o.bottom-i-n},footer:{left:o.left,top:e.height-o.bottom-n,width:r,height:n}}}const pl='<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 nn(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 ul(t,e){const o=D.resolveWatermarkLayout(t.watermark,[],e);return o?a("div",{class:"watermark-layer",style:{opacity:String(o.opacity)}},o.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${o.tileWidthPx} ${o.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.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 zo(t,e,o,i,n,r){const l=t.store,s=[];o!=="content"&&s.push(a("span",{class:"zone-label",text:o==="header"?"页眉":"页脚"}));const c=o==="content"?D.collectFollowMemberIds(n):void 0;if(s.push(...n.map(u=>cl(t,u,c))),o!=="content"){const u=o==="header"?"bottom":"top";s.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:o},onMousedown:h=>t.fire("zone-resize",{event:h,zone:o})},[e.zoneResizing===o?a("div",{class:"zone-height-tip",text:`${(o==="header"?l.templateData.header.height:l.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${o} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:o,paperWidth:String(r.width),paperHeight:String(r.height)}},s.filter(Boolean))}function hl(t){const e=t.currentTarget,o=t.dataTransfer?.types??[],i=o.includes("fieldkey"),n=o.includes("elementtype");if(!i&&!n){e.querySelector(".drop-hint")?.remove();return}i&&(t.ctrlKey||t.metaKey)&&(e.dataset.dropLabelIntent="1");const r=n?"+ 元素":e.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let l=e.querySelector(".drop-hint");l||(l=document.createElement("div"),l.className="drop-hint",e.appendChild(l)),l.textContent=r,l.style.left=`${t.clientX+14}px`,l.style.top=`${t.clientY+18}px`}function Bn(t){t&&(t.querySelector(".drop-hint")?.remove(),delete t.dataset.dropLabelIntent)}function fl(t,e){const o=t.store,i=o.templateData,n=D.getPaperDimensions(i),r=(o.scale||100)/100,l=Uo(i,n),s=m=>o.elements.filter(g=>(g.zone||"content")===m),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[o.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(pl)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[ul(i,n)]:[],zo(t,e,"header",l.header,s("header"),n),zo(t,e,"content",l.content,s("content"),n),zo(t,e,"footer",l.footer,s("footer"),n),...o.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:nn(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...nn(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>t.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),t.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],c]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${D.mmToPx(n.width)*r}px`,height:`${D.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(o.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>t.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>t.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Me(t,m,"复制","copy"),Me(t,m,"剪切","cut"),Me(t,m,"粘贴","paste",!o.hasClipboard),Me(t,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Me(t,m,"置顶","move-layer",!1,"top"),Me(t,m,"上移","move-layer",!1,"up"),Me(t,m,"下移","move-layer",!1,"down"),Me(t,m,"置底","move-layer",!1,"bottom")]:[Me(t,m,"粘贴","paste-at",!o.hasClipboard),Me(t,m,"全选","select-all"),Me(t,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>{const g=m;g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"),hl(g)},onDragleave:m=>{const g=m.currentTarget,v=m.relatedTarget;(!v||!g.contains(v))&&g.querySelector(".drop-hint")?.remove()},onDrop:m=>{const g=m,v=m.currentTarget,S=v.dataset.dropLabelIntent==="1";Bn(v),S&&(g.labelIntent=!0),t.fire("drop",g)},onMousedown:m=>t.fire("canvas-mousedown",m),onMousemove:m=>t.fire("canvas-mousemove",m),onMouseleave:()=>t.fire("canvas-mouseleave"),onWheel:m=>t.fire("wheel",m),onScroll:m=>t.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),t.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Me(t,e,o,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:o,onClick:()=>{e.visible=!1,n||t.fire(i,r),t.repaint()}})}const ml={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" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function xe(t,e=15,o){const i=ml[t];return i?`<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">${i}</svg>`:""}let ot=null;function ti(t){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return null;const o=e[1],i=o.length===3?o.split("").map(n=>n+n).join(""):o;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function oi(t){const e=ti(t);return e?Hn(e):"#000000"}function Hn({r:t,g:e,b:o}){return`#${[t,e,o].map(i=>Math.round(Pt(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function gl(t,e,o){const i=t/255,n=e/255,r=o/255,l=Math.max(i,n,r),s=Math.min(i,n,r),c=l-s;let u=0;return c!==0&&(l===i?u=(n-r)/c%6:l===n?u=(r-i)/c+2:u=(i-n)/c+4,u*=60,u<0&&(u+=360)),{h:u,s:l===0?0:c/l,v:l}}function bl(t,e,o){const i=o*e,n=(t%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[l,s,c]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=o-i;return{r:(l+u)*255,g:(s+u)*255,b:(c+u)*255}}function xl(t){return((Number.isFinite(t)?t:0)%360+360)%360}function Pt(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function vl(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 i=o.currentTarget??o.target,n=i.getRootNode();if(!!ot&&ot.root===n&&ot.title===e&&ot.trigger===i){zt();return}zt(),yl(i,t)}},[a("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function zt(){const t=ot;t&&(ot=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function yl(t,e){const o=t.getRootNode(),i=o instanceof ShadowRoot?o:document.body,n={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&&ni(n,e.value)?n.hexText=oi(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=be(El(n),i),n.current=n.panel.querySelector(".picker-current"),n.hex=n.panel.querySelector(".picker-hex"),n.area=n.panel.querySelector(".picker-area"),n.handle=n.panel.querySelector(".picker-handle"),n.hueRange=n.panel.querySelector(".picker-hue"),n.clearBtn=n.panel.querySelector(".picker-clear"),n.items=Array.from(n.panel.querySelectorAll(".preset-color-item")).map((r,l)=>({el:r,color:p.PRESET_COLORS[l]})),ao(n),wl(n),Sl(n),ot=n,t.setAttribute("aria-expanded","true")}function wl(t){const e=t.trigger.getBoundingClientRect(),o=190,i=t.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-o-n)),l=e.bottom+6,s=l+i>window.innerHeight-n?Math.max(n,e.top-i-6):l;t.panel.style.left=`${r}px`,t.panel.style.top=`${s}px`}function Sl(t){const e=n=>{const r=Tl(n);r.includes(t.trigger)||r.includes(t.panel)||zt()},o=n=>{n.key==="Escape"&&zt()},i=()=>zt();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",o),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),t.root.addEventListener("scroll",i,!0),t.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",o),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>t.root.removeEventListener("scroll",i,!0))}function Tl(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function El(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=>Cl(t,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>Al(t,e),onKeydown:e=>Dl(t,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>Ml(t,Number(e.target.value)),onChange:()=>ri(t)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),t.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>io(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"},p.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>kl(t,e)})))])}function ii(t){return Hn(bl(t.hue,t.saturation,t.value_))}function ao(t){const e=ii(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 i of t.items)i.el.className=t.model&&i.color.toLowerCase()===t.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ni(t,e){const o=ti(e);if(!o)return!1;const i=gl(o.r,o.g,o.b);return t.hue=i.h,t.saturation=i.s,t.value_=i.v,t.hexText=oi(e).toUpperCase(),!0}function vt(t,e,o,i){t.hue=xl(e),t.saturation=Pt(o),t.value_=Pt(i),t.hexText=ii(t).toUpperCase(),ao(t)}function ri(t){const e=ii(t);t.model=e,ao(t),t.onChange(e)}function io(t,e){t.model=e,e||(t.hexText=""),ao(t),t.onChange(e)}function kl(t,e){ni(t,e),io(t,e)}function Cl(t,e){const o=e.trim();if(!o){t.clearable&&io(t,void 0);return}ti(o)&&(ni(t,o),io(t,oi(o)))}function Al(t,e){t.dragging=!0,rn(t,e);const o=n=>{t.dragging&&rn(t,n)},i=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),ri(t))};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function rn(t,e){const o=t.area.getBoundingClientRect();if(!o.width||!o.height)return;const i=Pt((e.clientX-o.left)/o.width),n=Pt(1-(e.clientY-o.top)/o.height);vt(t,t.hue,i,n)}function Dl(t,e){const o=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?vt(t,t.hue,t.saturation-o,t.value_):e.key==="ArrowRight"?vt(t,t.hue,t.saturation+o,t.value_):e.key==="ArrowUp"?vt(t,t.hue,t.saturation,t.value_+o):e.key==="ArrowDown"?vt(t,t.hue,t.saturation,t.value_-o):i=!1,i&&(e.preventDefault(),ri(t))}function Ml(t,e){vt(t,e,t.saturation,t.value_)}function ee(t,e,o,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>t.fire(o,i.arg),html:xe(e)})}function no(t,e,o,i){const n=t.state.openDd===e,r=()=>{t.state.openDd=n?null:e,t.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!o.disabled,dataset:{test:o.testId??e,tip:o.tip},onClick:r,html:`${o.icon?xe(o.icon):""}${o.text?`<span class="${o.textClass??"tb-btn-text"}">${o.text}</span>`:""}${xe("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${o.panelClass?` ${o.panelClass}`:""}`},i):""].filter(Boolean))}function P(t){const e=t.step??1,o=String(e),i=o.indexOf("."),n=i===-1?0:o.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,l=m=>{let g=r(m);return t.min!==void 0&&g<t.min&&(g=t.min),t.max!==void 0&&g>t.max&&(g=t.max),g},s=t.value===void 0||t.value===null||!Number.isFinite(t.value)?void 0:r(t.value),c=s??t.min??0,u=m=>{m!==s&&t.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:s===void 0?"":String(s),min:t.min,max:t.max,step:e,placeholder:t.placeholder,disabled:!!t.disabled,onChange:m=>{const g=m.target,v=(g.value??"").trim();if(v===""){s!==void 0&&(g.value=String(s));return}const S=Number(v);if(!Number.isFinite(S)){g.value=s===void 0?"":String(s);return}const x=l(S);g.value=String(x),u(x)}});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:()=>u(l(c-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!t.disabled||c>=(t.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(l(c+e))})])}function W(t,e,o,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),i??""]),e,o?a("p",{class:"pd-hint",text:o}):""].filter(Boolean))}const Go=t=>a("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function de(t,e,o,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[t,Go(o)]),i??""]),e])}function rt(t){const e=t.base?.[t.propKey],o=t.target?.[t.propKey]!==e,i=t.force===!0||o,n=t.tipOverride??(t.tipValue===void 0?"恢复默认值":`恢复默认值(${t.tipValue}${t.tipUnit?" "+t.tipUnit:""})`),r=t.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${o&&!t.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:xe("RotateCcw",13),onClick:()=>{i&&(t.write?t.write(e):t.target[t.propKey]=e,t.onReset?.())}})}const Pe=t=>a("h3",{class:"pd-divider",text:t});function Ae(t,e,o="颜色选择",i){return vl({value:t,title:o,triggerClass:i,onChange:n=>e(n)})}function je(t,e,o,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:t,value:r.value,checked:o===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Wn(t,e,o,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const l=document.createElement("option");l.value=r.value,l.textContent=r.label,r.disabled&&(l.disabled=!0),n.appendChild(l)}return n.value=t,e.some(r=>r.value===t)||(n.selectedIndex=-1),n.addEventListener("change",()=>o(n.value)),n}function _l(t){const e=window.innerHeight;for(let o=t.parentElement;o&&o!==document.body;o=o.parentElement){const i=getComputedStyle(o).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=o.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function lo(t){const e=D.normalizeFontCatalog(t.fonts),o=t.placeholder??"默认",i=`font-select-list-${t.id}`,n=O=>{const R=O?.trim();return R?D.findFontOption(e,R)?.label??R:""},r=O=>{const R=D.normalizeFontQuery(O);return e.find(Z=>Z.label&&D.normalizeFontQuery(Z.label)===R)?.family??O},l=()=>{const O=t.value?.trim();return O?D.findFontOption(e,O)?"":O:""},s=O=>{const R=(t.value??"").trim(),K=(J,y,U,ae)=>({kind:J,key:y,label:U,value:ae,selected:(ae??"")===R}),Z=O.trim();if(!Z){const J=[K("clear","__clear__",o)],y=l();y&&J.push(K("unknown","__unknown__",`${y}(未知)`,y));for(const U of e)J.push(K("font",U.family,D.fontOptionLabel(U),U.family));return J}const fe=D.filterFontOptions(e,Z).map(J=>K("font",J.family,D.fontOptionLabel(J),J.family));if(!fe.length){const J=r(Z);fe.push(K("free","__free__",`使用「${J}」`,J))}return fe},c=document.createElement("div");c.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=o,u.disabled=!!t.disabled,u.value=n(t.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=t.state.fontOpen?.id===t.id?t.state.fontOpen:null,g={open:!!m&&!t.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const v=()=>{t.state.fontOpen=g.open?{id:t.id,query:g.query,highlighted:g.highlighted}:null};v();const S=()=>{const O=(t.value??"").trim();return s(g.query).findIndex(R=>(R.value??"")===O)},x=()=>{const O=u.getBoundingClientRect(),R=_l(u);h.classList.toggle("is-up",p.resolveOverlayPlacement({triggerTop:O.top,triggerBottom:O.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:R.top,boundaryBottom:R.bottom})==="up")},T=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||c.appendChild(h);const O=s(g.query);h.replaceChildren(...O.map((R,K)=>{const Z=document.createElement("li");return Z.id=`${i}-${K}`,Z.className="font-select-option"+(K===g.highlighted?" is-active":"")+(R.kind==="unknown"||R.kind==="free"?" is-muted":""),Z.setAttribute("role","option"),Z.setAttribute("aria-selected",String(R.selected)),Z.textContent=R.label,Z.addEventListener("mousedown",fe=>{fe.preventDefault(),ce(R)}),Z})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),x()},E=()=>{g.open||t.disabled||(g.open=!0,g.query="",g.highlighted=S(),v(),T())},A=()=>{g.open||E()},L=()=>{g.open=!0,g.query=u.value,g.highlighted=s(g.query).length?0:-1,v(),T()},F=O=>{if(!g.open){E();return}const R=s(g.query).length-1;if(R<0)return;g.highlighted=Math.min(Math.max(g.highlighted+O,0),R),v(),T(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},G=()=>{if(!g.open)return;const O=s(g.query)[g.highlighted];if(O){ce(O);return}const R=g.query.trim();if(R){const K=r(R);ce({value:K})}},ce=O=>{g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(O.value),T(),t.onChange(O.value)},X=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(t.value),T())};return u.addEventListener("focus",E),u.addEventListener("click",A),u.addEventListener("input",L),u.addEventListener("blur",X),u.addEventListener("keydown",O=>{const R=O;R.key==="ArrowDown"?(R.preventDefault(),F(1)):R.key==="ArrowUp"?(R.preventDefault(),F(-1)):R.key==="Enter"?(R.preventDefault(),G()):R.key==="Escape"&&(R.preventDefault(),X())}),c.append(u),T(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),c}const Rl=[{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"}],zl={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function Ke(t,e,o,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:t,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${o}</svg>`})}const mt='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',an='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Fl(t){const e=t.format;e.syncBorderDraft();const o=e.values,i=!e.fontEditable,n=i||e.context==="cells",r=e.context==="none",l=e.context==="cells",s=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",u=g=>i?`${g}(需选中文本元素)`:g,h=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[Ke("preset-none","无边框",`${mt}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),Ke("preset-all","所有边框",`${an}<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")),Ke("preset-outer","外侧边框",an,()=>e.applyBorderPreset("outer")),Ke("preset-inner",l?"内部边框":"内部边框(仅表格单元格可用)",`${mt}<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:!l}),Ke("edge-top","上边框",`${mt}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),Ke("edge-bottom","下边框",`${mt}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),Ke("edge-left","左边框",`${mt}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),Ke("edge-right","右边框",`${mt}<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"},Rl.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),t.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[P({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),t.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Ae(e.borderColor,g=>{e.setBorderColor(g),t.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,v,S])=>a("button",{type:"button",class:`ft-cell-btn${o.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:xe(S)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,v,S])=>a("button",{type:"button",class:`ft-cell-btn${o.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:xe(S)})))])];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:s,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),t.repaint()},onDblclick:()=>{e.pickPainterSource(!0),t.repaint()},html:xe("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[lo({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof o.fontFamily=="string"?o.fontFamily:void 0,placeholder:o.fontFamily===tt?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[P({value:typeof o.fontSize=="number"?o.fontSize:void 0,min:5,max:72,disabled:i,placeholder:o.fontSize===tt?"混合":"默认",onCommit:g=>e.applyStyle({fontSize:g})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([g,v,S,x])=>a("button",{type:"button",class:`ft-btn${o[g]===!0?" on":""}`,dataset:{test:g,tip:u(S)},disabled:g==="bold"?i:n,onClick:x,html:xe(v)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Ae(typeof o.color=="string"?o.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Ae(typeof o.backgroundColor=="string"?o.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:xe("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[no(t,"align",{icon:zl[String(o.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[no(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const Pl=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",label:"流式列表",icon:"⊟"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],Ll={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Il(t){const e=t.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[ln("»","展开素材台",()=>{e.leftCollapsed=!1,t.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,text:r,onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,t.repaint()}}))])]);const o=(i,n)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),ln("«","收起素材台",()=>{e.leftCollapsed=!0,t.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,t.repaint()}}))]),o("elements",Ol()),o("fields",[Nl(t)]),o("layers",[$l(t)])])])}function ln(t,e,o){return a("button",{type:"button",class:"collapse-btn",title:e,text:t,onClick:o})}function Ol(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...Pl.map(t=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${t.type}`},onDragstart:e=>{const o=e.dataTransfer;o?.setData("elementType",t.type),o&&(o.effectAllowed="all")}},[a("span",{class:"material-icon",text:t.icon}),a("span",{class:"material-label",text:t.label})]))]}function Nl(t){const e=t.state,o=p.groupFields(t.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?o.map(r=>({...r,fields:r.fields.filter(l=>`${l.fieldLabel}${l.fieldKey}`.toLowerCase().includes(i))})).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"},n.flatMap(r=>{const l=e.collapsedGroups.has(r.key)&&!i,s=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{l?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),t.repaint()}},[a("span",{class:"expand-icon",text:l?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",c=l?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{const m=h.dataTransfer;m?.setData("fieldKey",u.fieldKey),m&&(m.effectAllowed="all")},onClick:()=>{p.copyTextToClipboard(u.fieldLabel||u.fieldKey).then(h=>{h&&(e.copiedFieldKey=u.fieldKey,t.repaint(),setTimeout(()=>{e.copiedFieldKey===u.fieldKey&&(e.copiedFieldKey="",t.repaint())},1200))})}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})]),e.copiedFieldKey===u.fieldKey?a("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[s,a("div",{},c.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function $l(t){const e=t.store,o=[...e.elements].sort((s,c)=>(c.options.zIndex??0)-(s.options.zIndex??0)),i=e.elements.filter(s=>e.selectedIds.has(s.id)),n=i.length>=2,r=i.some(s=>!!s.options.groupId),l=s=>s.zone==="header"?"页眉":s.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...o.map(s=>a("div",{class:`layer-item${e.selectedIds.has(s.id)?" active":""}`,onClick:c=>e.selectElement(s.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:Ll[s.printElementType.type]||"?"}),a("span",{class:"layer-name",text:s.options.title||s.printElementType.title||s.printElementType.type}),l(s)?a("span",{class:"layer-zone",text:l(s)}):"",a("span",{class:"layer-zindex",text:`z:${s.options.zIndex??0}`})].filter(Boolean))),o.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([s,c,u])=>a("button",{type:"button",class:"pd-button small",title:c,html:xe(u,14),onClick:()=>t.fire("move-layer",s)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:xe("Group",14),onClick:()=>t.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:xe("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function Bl(t){const e=t.store,o=t.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((s,c)=>o.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:o.renameText??"",onInput:u=>{o.renameText=u.target.value},onBlur:()=>l(),onKeydown:u=>{const h=u;if(h.key==="Enter"){l();return}h.key==="Escape"&&(o.renamingPage=null,t.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:s.name?`${s.name}(双击重命名)`:"双击重命名"},text:s.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{o.renamingPage=c,o.renameText=s.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?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>t.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>t.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>t.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>t.fire("move-page",1)})])]);function l(){const s=(o.renameText??"").trim();o.renamingPage!==null&&s&&e.renamePage(o.renamingPage,s),o.renamingPage=null,t.repaint()}}function Hl(t){const e=t.store,o=e.templateData,i=p.getPaperDimensions(o),n=o.orientation==="landscape"?"横向":"纵向",r=p.PAPER_PRESETS[o.paperSize]?.label??o.paperSize,l=o.outputRotation,s=`${r} ${n} ${Math.round(i.width)}×${Math.round(i.height)}mm${l?`(旋转${l}°)`:""}`;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:s})])}const Wl=Object.keys(p.PAPER_PRESETS).filter(t=>t!=="CUSTOM"&&!p.PAPER_PRESETS[t]?.continuous);function Ul(t){const e=document.createElement("label");e.className="pd-button small upload-label";const o=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(o,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const l=t.host.uploadDesignBackground;if(!l){alert("设计背景上传能力未配置"),i.value="";return}n(!0),o.textContent="上传中...";try{const s=await l(r);s?t.store.updateTemplateData({designBackground:{src:s,rotation:0}}):alert("设计背景上传失败")}catch(s){alert(s instanceof Error?s.message:"设计背景上传失败")}finally{o.textContent="上传背景图",n(!t.host.uploadDesignBackground),i.value=""}}),t.host.uploadDesignBackground||n(!0),e}function Gl(t){const o=t.store.templateData.designBackground,i=o?.rotation??0;return a("div",{class:"design-background-config"},[Pe("设计背景"),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:`旋转(${(i+90)%360}°)`,onClick:()=>t.store.updateTemplateData({designBackground:{...o,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>t.store.updateTemplateData({designBackground:void 0})})])]:Ul(t)].flat())}function ql(t){const e=t.store,o=e.templateData,i=o.tiling,n={...D.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{...D.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=p.isContinuousPaperSize(o.paperSize),l=S=>e.updateTemplateData({tiling:{...n,...S}}),s=S=>rt({target:n,base:D.TILE_DEFAULTS,propKey:S,write:()=>l({[S]:D.TILE_DEFAULTS[S]})}),c=S=>rt({target:n.sheetMargin,base:D.TILE_DEFAULTS.sheetMargin,propKey:S,write:()=>u(S,D.TILE_DEFAULTS.sheetMargin[S])}),u=(S,x)=>l({sheetMargin:{...n.sheetMargin,[S]:x??0}}),h={...o,tiling:n},m=D.validateTiling(h),g=Math.max(D.computeMaxColumns(h),1);let v="";if(!m.length)try{const S=D.computeTileLayout(h),x=D.resolveSheetMm(h),T=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",E=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";v=`目标纸 ${T}${E} ${x.width}×${x.height}mm · ${S.columns} 列 × ${S.rows} 行 = 每张 ${S.perSheet} 格 · 每格 ${S.tile.width}×${S.tile.height}mm`}catch{v=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Pe("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:n.enabled===!0,disabled:r,onChange:S=>{if(!S.target.checked){l({enabled:!1});return}l({...D.TILE_DEFAULTS,columns:Math.min(D.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[W("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:S=>{const x=S.target.value;if(x!=="CUSTOM"){l({sheetPaperSize:x});return}const T=D.resolveSheetMm(h);l({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??T.width,sheetCustomHeight:n.sheetCustomHeight??T.height})}},[...Wl.map(S=>a("option",{value:S,text:p.PAPER_PRESETS[S]?.label??S,selected:(n.sheetPaperSize??"A4")===S})),a("option",{value:"CUSTOM",text:"自定义",selected:n.sheetPaperSize==="CUSTOM"})]),void 0,s("sheetPaperSize")),n.sheetPaperSize==="CUSTOM"?W("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[P({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:S=>l({sheetCustomWidth:S})}),a("span",{class:"custom-size-x",text:"×"}),P({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:S=>l({sheetCustomHeight:S})})])):W("目标纸方向",je("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",S=>l({sheetOrientation:S})),void 0,s("sheetOrientation")),Pe("拼版留白 (mm)"),a("div",{class:"margin-grid"},[W("上",P({value:n.sheetMargin.top??0,min:0,max:100,onCommit:S=>u("top",S)}),void 0,c("top")),W("下",P({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:S=>u("bottom",S)}),void 0,c("bottom")),W("左",P({value:n.sheetMargin.left??0,min:0,max:100,onCommit:S=>u("left",S)}),void 0,c("left")),W("右",P({value:n.sheetMargin.right??0,min:0,max:100,onCommit:S=>u("right",S)}),void 0,c("right"))]),Pe("格间距与列数"),W("横向间距",P({value:n.gapX??0,min:0,max:50,onCommit:S=>l({gapX:S??0})}),void 0,s("gapX")),W("纵向间距",P({value:n.gapY??0,min:0,max:50,onCommit:S=>l({gapY:S??0})}),void 0,s("gapY")),W("列数",P({value:n.columns??1,min:1,max:g,onCommit:S=>l({columns:S||1})})),...m.map(S=>a("p",{class:"pd-hint tiling-error",text:S.message})),!m.length&&v?a("p",{class:"pd-hint tiling-summary",text:v}):""]:""].flat().filter(Boolean))}const Kl=new Set(p.PROPERTY_REGISTRY.map(t=>t.group)),jl={"table-settings":"content"},sn=new Map;function ai(t){const e=t??"";let o=sn.get(e);if(!o){const{groups:i,itemKeys:n}=p.searchProperties(e);o={groups:i,keys:n,searching:!!e.trim()},sn.set(e,o)}return o}function li(t){const e=jl[t]??t;return Kl.has(e)?e:""}function Yl(t,e){const o=ai(t.state.propSearch);if(!o.searching)return!0;const i=li(e);return!i||o.groups.includes(i)}function Vl(t,e){const o=ai(t.state.propSearch);return!o.searching||o.keys.has(e)}function Un(t,e){const o=t.props.style??{};return t.props.style={...o,display:e?"":"none"},t}function _(t,e,o){const i=o.props.dataset??{};return o.props.dataset={...i,propKey:e},Un(o,Vl(t,e))}function Xl(t,e,o){const i=li(e);if(!i)return o;const n=o.props.dataset??{};return o.props.dataset={...n,propGroup:i},Un(o,Yl(t,e))}function Gn(t,e){const o=ai(e);for(const i of Array.from(t.querySelectorAll("[data-prop-group]"))){const n=li(i.dataset.propGroup??"");i.style.display=!o.searching||!n||o.groups.includes(n)?"":"none"}for(const i of Array.from(t.querySelectorAll("[data-prop-key]")))i.style.display=!o.searching||o.keys.has(i.dataset.propKey??"")?"":"none"}function Zl(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,i=o.value;t.state.propSearch=i,Gn(o.getRootNode(),i)}})])}const Ql={Document:"≡",Brush:"◧",Setting:"⚙"};function Jl(t,e){try{const o=window.localStorage.getItem(`property-group-${t}`);return o===null?e:o==="true"}catch{return e}}function es(t,e){try{window.localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function Se(t,e,o,i,n,r=!0){const l=Jl(e,r);return Xl(t,e,a("div",{class:`property-group${l?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{es(e,!l),t.repaint()}},[a("span",{class:"group-icon",text:Ql[i]||"•"}),a("span",{class:"group-title",text:o}),a("span",{class:"expand-icon",text:l?"▾":"▸"})]),a("div",{class:"group-content",style:l?"":{display:"none"}},n.filter(Boolean))]))}function so(t){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function qn(t){return t.split(".").flatMap(e=>{const o=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!o)return[e];const i=o[1],n=[...o[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function dn(t,e){return qn(e).reduce((n,r)=>n==null?"":n[r],t)??""}function si(t,e,o,i){const n=qn(o),r=n.pop(),l=n.reduce((s,c)=>((s[c]===void 0||s[c]===null)&&(s[c]={}),s[c]),e);l[r]=i||void 0,t.recordHistory(),t.emit()}function ts(t,e){const o=t.store;if(e.printElementType.type==="table"&&o.tableSelection?.elementId===e.id){const{r1:i,c1:n}=o.tableSelection,r=(e.options.tableRows??[])[i];if(r)return p.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return p.getElementBindings(e)}function os(t,e){const o=document.createElement("label");o.className="pd-button small upload-label",be(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 i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",o.append(i,n);const r=c=>{o.className=`pd-button small upload-label${c?" disabled":""}`,n.disabled=c};n.addEventListener("change",async()=>{const c=n.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=t.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(c);h?si(t.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!t.host.uploadImage),n.value=""}}),t.host.uploadImage||r(!0);const l=document.createElement("div");l.className="image-content-upload";const s=document.createElement("p");return s.className="upload-tip",s.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",l.append(o,s),l}function is(t,e){const o=i=>t.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:dn(e,i.targetPath)});return Se(t,"binding","内容","Document",[...ts(t,e).map(i=>W(i.label,a("input",{class:"pd-input",type:"text",value:dn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>si(t.store,e,i.targetPath,n.target.value),onDblclick:()=>o(i)}))),e.printElementType.type==="image"?os(t,e):""].filter(Boolean))}const Mt=new Map;function Zt(t){return`${Math.round(t*1e4)/1e4}%`}function Kn(t,e){const o=p.parseCropAnchor(e.value),i=o.kind==="custom",n=o.kind==="axes"?o.x:50,r=o.kind==="axes"?o.y:50,l=p.resolveCropPreview(e.src),s=Mt.get(l.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:s?.width,naturalHeight:s?.height,fit:e.fit,scalePct:e.scale},u=p.resolveCropTravel(c),h=p.cropWindow(c,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const x of p.cropPresetOptions(u,n,r)){const T=document.createElement("option");T.value=x.value,T.textContent=x.label,m.appendChild(T)}if(i){const x=document.createElement("option");x.value="custom",x.textContent="自定义(保留原值)",m.appendChild(x)}m.value=i?"custom":`${n},${r}`,m.selectedIndex<0&&(m.selectedIndex=i?m.options.length-1:0),m.addEventListener("change",()=>{if(m.value==="custom")return;const[x,T]=m.value.split(",").map(Number);e.onCommit(p.buildCropAnchor(x,T))});const g=p.propertyTip(e.fieldKey),v=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,Go(g)]),e.resetAnchor??""].filter(Boolean)),m])];v.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[p.CROP_SCALE_LABEL,Go(p.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),P({value:e.scale,min:p.CROP_SCALE_MIN,max:p.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:x=>e.onScaleCommit(x>p.CROP_SCALE_MIN?x:void 0)})]));for(const x of p.cropAxisFields(u,n,r))v.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:x.label}),P({value:x.value,min:0,max:100,step:1,onCommit:T=>e.onCommit(p.buildCropAnchor(x.name==="horizontal"?T:n,x.name==="vertical"?T:r))})]));const S=p.cropAxisNote(u,i);return S&&v.push(a("p",{class:"pd-crop-note",text:S})),l.isSample&&v.push(a("p",{class:"pd-crop-note",text:p.CROP_SAMPLE_NOTE})),v.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:l.src,alt:l.isSample?"示例图":"原图",onLoad:x=>{const T=x.target;if(!(T.naturalWidth>0&&T.naturalHeight>0))return;const E=Mt.get(l.src);E&&E.width===T.naturalWidth&&E.height===T.naturalHeight||(Mt.set(l.src,{width:T.naturalWidth,height:T.naturalHeight}),t.repaint())},onError:()=>{Mt.has(l.src)&&(Mt.delete(l.src),t.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:Zt(h.leftPct),top:Zt(h.topPct),width:Zt(h.widthPct),height:Zt(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},v)}const et=t=>Number(t??0),qo=t=>t||void 0;function nt(t,e,o,i,n,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:t}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,...r?{disabled:!0}:{},onChange:l=>o(l.target.checked)})])}function jn(t,e,o,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:l=>i(l.target.value)},o.map(l=>a("option",{value:l.value,text:l.label,selected:l.value===e})))])}function _t(t,e,o,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),n.reset??""].filter(Boolean)),Wn(e,o,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const gt=t=>a("p",{class:"pd-hint",text:t}),ns="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",rs=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],as=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],ls=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],ss=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],ds={value:"__multi__",label:"多选",disabled:!0};function cs(t,e){const o=t.store,i=o.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return Se(t,"table-row","行属性","Grid",[]);const l=s=>o.updateElement(e.id,s);return Se(t,"table-row","行属性","Grid",[so([jn("行类型",r.type,rs,s=>{const c=p.setRowType(n,i.r1,s);if(c){window.alert(c);return}l({tableRows:n})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),P({value:r.height,min:3,max:100,step:.5,onCommit:s=>{r.height=s,l({tableRows:n})}})]),r.type==="header"?nt("表头每页重复",r.repeatOnPage??!1,s=>{p.setHeaderRepeat(n,s),l({tableRows:n})},ns):""])])}function ps(t,e){const o=t.store,i=e.options,n=h=>o.updateElement(e.id,h),r=i.tableColWidths??[],l=o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right,s=o.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),c=p.createDefaultOptions("table"),u=h=>rt({target:i,base:c,propKey:h,write:()=>n({[h]:c[h]})});return Se(t,"table-settings","表格设置","Grid",[so([jn("列表数据源字段",i.dataSource??"",s,h=>n({dataSource:h||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字体"}),u("tableDefaultFontFamily")]),lo({id:"table-default-font",state:t.state,fonts:t.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),P({value:et(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Ae(i.tableDefaultColor,h=>n({tableDefaultColor:h}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),u("tableDefaultPadding")]),P({value:et(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((h,m)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${m+1}`}),P({value:h,min:5,max:200,onCommit:g=>{const v=r.reduce((S,x,T)=>T===m?S:S+x,0);if(v+g>l){const S=Math.max(5,Math.round((l-v)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${l}mm,列${m+1} 已调整为 ${S}mm`),r[m]=S}else r[m]=g;n({tableColWidths:r})}})]))])])])}function us(t,e){const o=t.store,i=e.options,n=e.printElementType.type==="table",r=s=>o.updateElement(e.id,s),l=[];if(n)l.push(_(t,"pg-enabled",nt("启用分页",i.tablePagination?.enabled??!0,s=>r({tablePagination:{enabled:s}}))));else{const s=i.pagination?.pageable??!0,c=i.pagination?.keepWithNext??!1;l.push(_(t,"pg-pageable",nt("参与分页",s,u=>r({pagination:{pageable:u,keepWithNext:c}})))),l.push(_(t,"pg-keep-with-next",nt("与下元素同页",c,u=>r({pagination:{pageable:s,keepWithNext:u}}))))}return Se(t,"pagination","分页配置","Document",[so(l)],!1)}const Fo=new WeakMap,cn=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function hs(t,e){const o=t.store,i=o.tableSelection,n=e.options.tableRows??[];if(!i)return Se(t,"table-cell","单元格","Menu",[]);const r=p.findMainCell(n,i.r1,i.c1),l=n[r.r]?.cells[r.c];if(!l)return Se(t,"table-cell","单元格","Menu",[]);const s=()=>p.collectWritableCells(n,i),c=p.resolveCellGroupMode(n,i),u=c.count,h=c.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=Fo.get(o),v=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&Fo.set(o,v);const S=b=>{Fo.set(o,{key:m,border:b.border??v.border,values:b.values??v.values,edges:b.edges??v.edges})},x=(b,I)=>{S({border:{...v.border,[b]:I}}),t.repaint()},T=(b,I)=>{s().forEach(b),h&&I&&S({values:{...v.values,...I}}),o.updateElement(e.id,{tableRows:n})},E=(b,I)=>{T(te=>{te[b]=I},{[b]:I})},A=b=>h?v.values[b]:l[b],L=b=>h&&b in v.values,F=h?{width:void 0,style:void 0,color:void 0}:p.resolveCellBorderDisplay(n,i),G=!h&&s().some(b=>!!b.borders&&!!(b.borders.top||b.borders.right||b.borders.bottom||b.borders.left)),ce=!h&&!G,X={width:ce?0:typeof F.width=="number"?F.width:p.DEFAULT_BORDER.width,style:ce?"none":typeof F.style=="string"&&F.style!=="mixed"?F.style:p.DEFAULT_BORDER.style,color:typeof F.color=="string"&&F.color!=="mixed"?F.color:p.DEFAULT_BORDER.color,...v.border},O="__mixed__",R={style:!h&&F.style==="mixed",width:!h&&F.width==="mixed",color:!h&&F.color==="mixed"},K=R.style&&!("style"in v.border),Z=R.width&&!("width"in v.border),fe=R.color&&!("color"in v.border),J=K||Z||fe,y=K?O:X.style,U=Z?void 0:X.width,ae=fe?void 0:X.color,Le=b=>{const I={style:b};b!=="none"&&U===0?I.width=p.DEFAULT_BORDER.width:b==="none"&&!G&&(I.width=0),S({border:{...v.border,...I}}),t.repaint()},N=()=>({...X}),Ie=h?cn.reduce((b,I)=>(b[I.value]=v.edges[I.value]?"on":"off",b),{}):p.resolveBorderEdgeStates(s().map(b=>b.borders)),Oe=h?"cellType"in v.values?v.values.cellType??"text":p.resolveSharedCellType(n,i):l.cellType??"text",ie=Oe==="barcode",De=Oe==="qrcode",$=Oe==="image",H=Oe==="text",co=ie&&!!A("printerDpi"),It=p.barcodeBarWidthRecommendText(A("printerDpi"),A("barWidth")),Ot=h?v.values.textFit:p.resolveCellTextFit(l),po=h?"cellType"in v.values?v.values.cellType??"text":"":l.cellType||"text",Ye=b=>h?[ds,...b]:b,Te=b=>h?"多选":b,Ee=(b,I)=>h?v.values[b]:I,uo=h?A("barcodeType")??"__multi__":l.barcodeType||"CODE128",Nt=h?L("printerDpi")?A("printerDpi")?String(A("printerDpi")):"":"__multi__":l.printerDpi?String(l.printerDpi):"",j=h?A("qrCodeLevel")??"__multi__":l.qrCodeLevel||"M",wt=h?A("fit")??"__multi__":l.fit||"contain",Y=Ot??"__multi__",at=p.canMergeReason(n,i);let me=!0;for(let b=i.r1;b<=i.r2;b++)if(n[b]?.type!=="data"){me=!1;break}const Ve=me?"":"仅数据行(明细行)支持按值合并";let Xe=!1;for(let b=i.r1;b<=i.r2&&!Xe;b++)for(let I=i.c1;I<=i.c2&&!Xe;I++){const te=n[b]?.cells[I];te&&!te.merged&&((te.rowspan??1)>1||(te.colspan??1)>1)&&(Xe=!0)}const pe=(b,I,te,se={},Ue)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:b}),Ue??""].filter(Boolean)),P({value:I,...se,onCommit:lt=>E(te,qo(lt))})]),$t="恢复默认值(跟随表格默认)",q=b=>rt({target:l,base:{},propKey:b,tipOverride:$t,force:h,write:()=>E(b,void 0)}),St=e.options.tableDefaultPadding??1,Tt={width:p.cellFitWidthMm(e.options.tableColWidths??[],r.c,l,St),height:p.cellFitCapMm(n,r.r,l,St)};return Se(t,"table-cell","单元格","Menu",[so([h?gt(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),je("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],po,b=>{const I=b==="text"?void 0:b,te={cellType:b};b!=="barcode"&&Object.assign(te,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),b!=="qrcode"&&Object.assign(te,{qrCodeLevel:void 0,qrQuietZone:void 0}),T(se=>{se.cellType=I,b!=="barcode"&&(se.barcodeType=void 0,se.showBarcodeText=void 0,se.printerDpi=void 0,se.barQuietZone=void 0,se.barHeight=void 0),b!=="qrcode"&&(se.qrCodeLevel=void 0,se.qrQuietZone=void 0)},te)})]),ie?_t("码制",uo,Ye(as),b=>{b!=="__multi__"&&E("barcodeType",b||void 0)}):"",ie?nt("显示文本",h?v.values.showBarcodeText===!0:l.showBarcodeText!==!1,b=>E("showBarcodeText",b),void 0,q("showBarcodeText")):"",ie?pe("条宽(倍率)",Ee("barWidth",l.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:Te("")},q("barWidth")):"",ie?gt((co?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(It?`。${It}`:"")):"",ie?de("静区 (模块)",P({value:Ee("barQuietZone",l.barQuietZone),min:0,max:20,placeholder:Te("默认 10"),onCommit:b=>E("barQuietZone",b)}),p.propertyTip("cd-bar-quiet-zone"),q("barQuietZone")):"",ie?de("条高 (mm)",P({value:Ee("barHeight",l.barHeight),min:1,max:100,placeholder:Te("默认 30 模块"),onCommit:b=>E("barHeight",b??void 0)}),p.propertyTip("cd-bar-height"),q("barHeight")):"",ie?pe("文本字号(相对条高,条高为 30)",Ee("barFontSize",l.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:Te("默认 10")},q("barFontSize")):"",ie?_t("打印机分辨率",Nt,Ye([{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)"}]),b=>{if(b==="__multi__")return;const I=Number(b);E("printerDpi",I>0?I:void 0)},{reset:q("printerDpi")}):"",ie?gt("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",De?_t("纠错级别",j,Ye(ls),b=>{b!=="__multi__"&&E("qrCodeLevel",b||void 0)},{reset:q("qrCodeLevel")}):"",De?de("静区 (模块)",P({value:Ee("qrQuietZone",l.qrQuietZone),min:0,max:8,placeholder:Te("默认 0"),onCommit:b=>E("qrQuietZone",b)}),p.propertyTip("cd-quiet-zone"),q("qrQuietZone")):"",ie?gt("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",De||$?_t("缩放模式",wt,Ye(p.IMAGE_FIT_OPTIONS),b=>{b!=="__multi__"&&E("fit",b)},{reset:q("fit")}):"",$&&!h&&l.fit==="cover"?Kn(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(l.formatter),fit:l.fit,containerClass:"pd-cell-anchor",widthMm:Tt.width,heightMm:Tt.height,scale:l.fitScale,value:l.objectPosition,onCommit:b=>E("objectPosition",b),onScaleCommit:b=>E("fitScale",b),resetAnchor:q("objectPosition"),resetScale:q("fitScale")}):"",ie||De||$?pe("最大宽度 (mm)",Ee("maxWidth",et(l.maxWidth)),"maxWidth",{min:0,max:200,placeholder:Te("默认")},q("maxWidth")):"",ie||De||$?pe("最大高度 (mm)",Ee("maxHeight",et(l.maxHeight)),"maxHeight",{min:0,max:200,placeholder:Te("默认")},q("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?A("formatter")??"":l.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:b=>E("formatter",b.target.value||void 0),onDblclick:()=>t.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:l.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),q("align")]),je("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?v.values.align??"":l.align||"left",b=>E("align",b))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),q("valign")]),je("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?v.values.valign??"":l.valign||"top",b=>E("valign",b))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"字体"}),q("fontFamily")]),lo({id:"cell-font",state:t.state,fonts:t.host.fonts,value:h?A("fontFamily"):l.fontFamily,placeholder:Te("继承默认"),onChange:b=>E("fontFamily",b)})]),pe("字号 (pt)",Ee("fontSize",et(l.fontSize)),"fontSize",{min:0,max:72,placeholder:Te("默认")},q("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),q("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?v.values.fontWeight==="bold":l.fontWeight==="bold",onChange:b=>E("fontWeight",b.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),q("color")]),Ae(h?A("color"):l.color,b=>E("color",b),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),q("backgroundColor")]),Ae(h?A("backgroundColor"):l.backgroundColor,b=>E("backgroundColor",b),"背景颜色")])]),Pe("边框"),a("div",{class:"border-style-row"},[Wn(y,[...K?[{value:O,label:"混合",disabled:!0}]:[],...p.BORDER_LINE_STYLES],b=>{b!==O&&Le(b)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[P({value:U,min:.25,max:5,step:.25,placeholder:h?"多选":Z?"混合":void 0,onCommit:b=>x("width",b)})]),Ae(ae,b=>x("color",b),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([b,I])=>a("button",{type:"button",class:"pd-button small",text:I,onClick:()=>{p.applyBorderPreset(n,i,X.style==="none"?"none":b,N()),o.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},cn.map(b=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:b.value,checked:Ie[b.value]==="on",indeterminate:Ie[b.value]==="mixed",onChange:I=>{const se=I.target.checked&&X.style!=="none";h&&S({edges:{...v.edges,[b.value]:se}}),T(Ue=>{p.setCellBorderEdge(Ue,b.value,se?N():null)})}}),a("span",{text:b.label})]))),gt(h?p.CELL_BORDER_APPLY_HINT_MULTI:J?p.CELL_BORDER_APPLY_HINT_MIXED:p.CELL_BORDER_APPLY_HINT),pe("内边距 (mm)",Ee("padding",et(l.padding)),"padding",{min:0,max:10,step:.5,placeholder:Te("默认")},q("padding")),nt("自动换行",h?v.values.wordWrap===!0:l.wordWrap??!0,b=>E("wordWrap",b),void 0,q("wordWrap")),H?_t("文字溢出",Y,Ye(ss),b=>{b!=="__multi__"&&E("textFit",b)},{full:!0,reset:q("textFit")}):"",H&&Ot==="shrink"?pe("最小字号 (pt)",Ee("shrinkMinFontSize",et(l.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:Te("默认 6")},q("shrinkMinFontSize")):"",a("div",{class:"merge-card"},[a("div",{class:"merge-card-title",text:"单元格合并"}),a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!at,title:at||"",onClick:()=>{p.mergeCells(n,i),o.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Xe,onClick:()=>{p.splitCells(n,i),o.updateElement(e.id,{tableRows:n})}})]),a("div",{class:"merge-card-divider"}),nt("按值合并",h?v.values.mergeSameValue===!0:l.mergeSameValue===!0,b=>E("mergeSameValue",b),Ve||void 0,me?q("mergeSameValue"):void 0,!me),gt("明细相邻行同值时自动纵向合并;跨页时在该页内成段,续页首行重放该值")])])])}const Po=D.WATERMARK_DENSITY_PRESETS;function Ko(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 fs(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function ms(t){const e=t.store.templateData.watermark,o=fs(e),i=e?.mode==="binding"||o!==""&&Ko(o),n=(()=>{const u=e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(Po))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={testData:e?.testData??"",rotate:e?.rotate??D.WATERMARK_DEFAULTS.rotate,color:e?.color||D.WATERMARK_DEFAULTS.color,opacity:e?.opacity??D.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};t.store.updateTemplateData({watermark:{...h,...u}})},l=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:o}),s={rotate:e?.rotate??D.WATERMARK_DEFAULTS.rotate,color:e?.color||D.WATERMARK_DEFAULTS.color,opacity:e?.opacity??D.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight},c=u=>rt({target:s,base:D.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:D.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[Pe("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:o,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(Ko(h)?{mode:"binding",binding:h,content:""}:{mode:"fixed",content:h,binding:""})},onDblclick:l}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:l})]),i?W("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??D.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??D.WATERMARK_DEFAULTS.rotate}°`})]),W("颜色",Ae(e?.color||D.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,c("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??D.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??D.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const h=u.target.value,m=Po[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(Po).map(([u,h])=>a("option",{value:u,text:`${h.label}(${h.width}×${h.height})`,selected:n===u})),a("option",{value:"custom",text:"自定义",selected:n==="custom"})])]),n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),a("input",{type:"number",class:"pd-input",min:D.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??D.WATERMARK_DEFAULTS.tileWidth),onChange:u=>r({tileWidth:Number(u.target.value)})})]):"",n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),a("input",{type:"number",class:"pd-input",min:D.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??D.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function he(t,e,o,i,n={},r){return W(e,P({value:o,...n,onCommit:i}),void 0,r)}function $e(t,e,o,i,n,r,l){const s=document.createElement("select");s.className="pd-select",s.addEventListener("change",()=>n(s.value));for(const c of i){const u=document.createElement("option");u.value=c.value,u.textContent=c.label,s.appendChild(u)}return s.value=o,i.some(c=>c.value===o)||(s.selectedIndex=-1),r?de(e,s,r,l):W(e,s,void 0,l)}function bt(t,e,o,i,n){return W(e,a("input",{type:"checkbox",class:"pd-switch",checked:o,onChange:r=>i(r.target.checked)}),void 0,n)}const gs=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],bs=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function xs(t,e){const o=t.store,i=e.options,n=e.printElementType.type,r=y=>o.updateElement(e.id,y),l=n==="text"||n==="longText",s=n==="barcode"||n==="qrcode",c=n==="table",u=c&&o.tableSelection?.elementId===e.id,h=u&&p.resolveCellGroupMode(e.options.tableRows??[],o.tableSelection).mode==="multi",m=[];h||m.push(is(t,e)),u||m.push(Se(t,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"position-grid"},[_(t,"ps-left",he(t,"X",i.left,y=>r({left:y}),{min:0})),_(t,"ps-top",he(t,"Y",i.top,y=>r({top:y}),{min:0})),_(t,"ps-width",he(t,"W",i.width,y=>r({width:y}),{min:4})),_(t,"ps-height",he(t,"H",i.height,y=>r({height:y}),{min:4}))])])]));const g=p.createDefaultOptions(n),v=(y,U)=>{const ae=p.propertyDefault(U);return rt({target:i,base:g,propKey:y,tipValue:ae?.value,tipUnit:ae?.unit,write:()=>r({[y]:g[y]})})},S=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?p.normalizeRotationAngle(i.rotate):void 0,x=y=>r({rotate:y===void 0||y===0?void 0:p.normalizeRotationAngle(y)}),T=p.isFreeAngleEditable(n,i),E=p.isRotationExcludedType(n)||p.collectFollowMemberIds(o.elements).has(e.id),A=E?"":_(t,"ap-rotate",de("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>x((S??0)-90)}),a("div",{class:"pd-rotate-stepper"},[P({value:S,min:0,max:359,placeholder:"0",disabled:!T,onCommit:y=>x(y)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>x((S??0)+90)})]),p.propertyTip("ap-rotate"),v("rotate","ap-rotate"))),L=E||T?"":a("p",{class:"pd-hint pd-rotate-note",text:p.CODE_OBLIQUE_NOTE});if(m.push(Se(t,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},l?[_(t,"ap-font-family",W("字体",lo({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:y=>r({fontFamily:y})}),void 0,v("fontFamily","ap-font-family"))),_(t,"ap-font-size",he(t,"字体大小",i.fontSize,y=>r({fontSize:y}),{min:8,max:72},v("fontSize","ap-font-size"))),_(t,"ap-font-weight",$e(t,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],y=>r({fontWeight:y}),void 0,v("fontWeight","ap-font-weight"))),_(t,"ap-align",W("对齐",je("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",y=>r({textAlign:y})),void 0,v("textAlign","ap-align"))),_(t,"ap-vertical-align",W("垂直对齐",je("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",y=>r({verticalAlign:y})),void 0,v("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[_(t,"ap-color",W("颜色",Ae(i.color,y=>r({color:y}),"字体颜色"),void 0,v("color","ap-color"))),_(t,"ap-bg-color",W("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","ap-bg-color")))]),_(t,"ap-line-height",he(t,"行高",i.lineHeight,y=>r({lineHeight:y||void 0}),{min:0,max:100},v("lineHeight","ap-line-height"))),_(t,"ap-letter-spacing",he(t,"字间距",i.letterSpacing,y=>r({letterSpacing:y||void 0}),{min:0,max:20,step:.5},v("letterSpacing","ap-letter-spacing"))),_(t,"ap-text-fit",$e(t,"文字溢出",p.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],y=>r({textFit:y}),void 0,v("textFit","ap-text-fit"))),i.textFit==="shrink"?_(t,"ap-shrink-min",W("最小字号 (pt)",P({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:y=>r({shrinkMinFontSize:y||void 0})}),void 0,v("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?_(t,"ap-long-text-indent",de("首行缩进 (字符)",P({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:y=>r({longTextIndent:y||void 0})}),p.propertyTip("ap-long-text-indent"),v("longTextIndent","ap-long-text-indent"))):"",_(t,"ap-word-wrap",bt(t,"自动换行",i.wordWrap!==!1,y=>r({wordWrap:y?void 0:!1}),v("wordWrap","ap-word-wrap"))),_(t,"ap-keep-line-breaks",bt(t,"保留换行符",i.keepLineBreaks===!0,y=>r({keepLineBreaks:y?!0:void 0}),v("keepLineBreaks","ap-keep-line-breaks"))),A,L]:[n==="image"?_(t,"ap-img-fit",$e(t,"缩放模式",String(i.fit??"contain"),p.IMAGE_FIT_OPTIONS,y=>r({fit:y}),p.propertyTip("ap-img-fit"),v("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?_(t,"ap-img-object-position",Kn(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(i.src),widthMm:Number(i.width)||0,heightMm:Number(i.height)||0,fit:i.fit,scale:i.fitScale,value:i.objectPosition===void 0?void 0:String(i.objectPosition),onCommit:y=>r({objectPosition:y}),onScaleCommit:y=>r({fitScale:y}),resetAnchor:v("objectPosition","ap-img-object-position"),resetScale:v("fitScale","ap-img-fit-scale")})):"",A,L,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),s){const y=n==="barcode",U=String(i.barcodeType||"CODE128").toUpperCase(),ae=i.printerDpi?String(i.printerDpi):"",Le=p.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);m.push(Se(t,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:N=>N.preventDefault()},[y?[_(t,"cd-type",$e(t,"码制",U,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],N=>r({barcodeType:N==="CODE128"?void 0:N}))),_(t,"cd-dpi",$e(t,"打印机分辨率",ae,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],N=>r({printerDpi:Number(N)>0?Number(N):void 0}),void 0,v("printerDpi","cd-dpi"))),_(t,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),_(t,"cd-bar-width",he(t,"条宽(倍率)",i.barWidth??2,N=>r({barWidth:N}),{min:2,max:8,step:.5},v("barWidth","cd-bar-width"))),_(t,"cd-bar-width",a("p",{class:"pd-hint",text:(ae?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Le?`。${Le}`:"")})),_(t,"cd-bar-quiet-zone",de("静区 (模块)",P({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:N=>r({barQuietZone:N})}),p.propertyTip("cd-bar-quiet-zone"),v("barQuietZone","cd-bar-quiet-zone"))),_(t,"cd-bar-height",de("条高 (mm)",P({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:N=>r({barHeight:N??void 0})}),p.propertyTip("cd-bar-height"),v("barHeight","cd-bar-height"))),_(t,"cd-show-text",bt(t,"显示文本",i.hideTitle!==!0,N=>r({hideTitle:N?void 0:!0}),v("hideTitle","cd-show-text"))),_(t,"cd-font-size",W("文本字号(相对条高,条高为 30)",P({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:N=>r({fontSize:N||void 0})}),void 0,v("fontSize","cd-font-size")))]:[_(t,"cd-ec-level",$e(t,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],N=>r({qrCodeLevel:N}),void 0,v("qrCodeLevel","cd-ec-level"))),_(t,"cd-quiet-zone",de("静区 (模块)",P({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:N=>r({qrQuietZone:N})}),p.propertyTip("cd-quiet-zone"),v("qrQuietZone","cd-quiet-zone")))],Pe("自定义设置"),y?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",y?"":_(t,"cd-fit",$e(t,"缩放模式",String(i.fit||"contain"),p.IMAGE_FIT_OPTIONS,N=>r({fit:N||void 0}),void 0,v("fit","cd-fit"))),_(t,"cd-max-width",W("最大宽度 (mm)",P({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:N=>r({maxWidth:N||void 0})}),void 0,v("maxWidth","cd-max-width"))),_(t,"cd-max-height",W("最大高度 (mm)",P({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:N=>r({maxHeight:N||void 0})}),void 0,v("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(u&&(m.push(cs(t,e)),m.push(hs(t,e))),c&&m.push(ps(t,e)),n==="flowList"){const y=p.resolveFlowColumns(i.flowColumns),U=p.resolveFlowRowHeight(i.flowRowHeight),ae=p.resolveFlowGapX(i.flowGapX),Le=p.resolveFlowMaxSpan(i.flowMaxSpan,y),N=p.suggestFlowColumns(i.width??0,ae,i.fontSize??12),Ie=p.resolveFlowLayoutMode(i.flowLayoutMode),Oe=Ie==="dynamic",ie=p.resolveFlowPadding(i),De=($,H)=>{r({[$]:typeof H=="number"&&Number.isFinite(H)&&H>0?H:0})};m.push(Se(t,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:$=>$.preventDefault()},[_(t,"fl-layout-mode",$e(t,"布局模式",Ie,[{value:"fixed",label:"固定高度"},{value:"dynamic",label:"动态分页"}],$=>r({flowLayoutMode:$==="dynamic"?"dynamic":"fixed"}),p.propertyTip("fl-layout-mode"))),...Oe?[_(t,"fl-padding-top",de("上内边距 (mm)",P({value:ie.top,min:0,max:100,step:.5,onCommit:$=>De("flowPaddingTop",$)}),p.propertyTip("fl-padding-top"))),_(t,"fl-padding-right",de("右内边距 (mm)",P({value:ie.right,min:0,max:100,step:.5,onCommit:$=>De("flowPaddingRight",$)}),p.propertyTip("fl-padding-right"))),_(t,"fl-padding-bottom",de("下内边距 (mm)",P({value:ie.bottom,min:0,max:100,step:.5,onCommit:$=>De("flowPaddingBottom",$)}),p.propertyTip("fl-padding-bottom"))),_(t,"fl-padding-left",de("左内边距 (mm)",P({value:ie.left,min:0,max:100,step:.5,onCommit:$=>De("flowPaddingLeft",$)}),p.propertyTip("fl-padding-left")))]:[],_(t,"fl-columns",de("每行列数",P({value:y,min:1,max:12,onCommit:$=>r({flowColumns:p.resolveFlowColumns($),flowMaxSpan:p.resolveFlowMaxSpan(i.flowMaxSpan,p.resolveFlowColumns($))})}),p.propertyTip("fl-columns"))),_(t,"fl-row-height",de("行高 (mm)",P({value:U,min:3,max:100,step:.5,onCommit:$=>r({flowRowHeight:p.resolveFlowRowHeight($)})}),p.propertyTip("fl-row-height"))),_(t,"fl-gap-x",de("单元横向间距 (mm)",P({value:ae,min:0,max:50,step:.5,onCommit:$=>r({flowGapX:p.resolveFlowGapX($)})}),p.propertyTip("fl-gap-x"))),_(t,"fl-auto-span",bt(t,"内容过长时跨列",i.flowAutoSpan===!0,$=>{r($?{flowAutoSpan:$,flowMaxSpan:Le}:{flowAutoSpan:$})})),i.flowAutoSpan===!0?_(t,"fl-max-span",de("最多跨几列",P({value:Le,min:1,max:y,onCommit:$=>r({flowMaxSpan:p.resolveFlowMaxSpan($,y)})}),p.propertyTip("fl-max-span"))):"",y>N?a("p",{class:"pd-hint",text:`按当前字号与框宽,${y} 列偏挤(可放约 ${N} 列)。数值保持不变,出纸按 ${y} 列排。`}):""].flat().filter(Boolean))]))}const F=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),G=y=>{const U=F();p.applyElementBorderPreset(U,y,p.effectiveElementBorderSpec(U)),r(U)},ce=y=>{const U=F();p.setElementBorderEdgeVisible(U,y,!p.elementBorderEdgeVisible(U,y)),r(U)},X=p.resolveElementBorderDisplay(i),O=X.style==="mixed",R=typeof X.width=="number"?X.width:void 0,K=O||X.style===void 0?"":X.style,Z=typeof X.color=="string"?X.color:void 0,fe=(y,U)=>{const ae=F();p.setElementBorderField(ae,y,U),r(ae)},J=O?[{value:"",label:"混合"},...p.BORDER_LINE_STYLES]:[...p.BORDER_LINE_STYLES];return m.push(Se(t,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[_(t,"bb-border-style",$e(t,"线型",K,J,y=>fe("borderStyle",y))),a("div",{class:"border-row"},[_(t,"bb-border-width",he(t,"边框宽度",R,y=>fe("borderWidth",y),{min:0,max:20,step:.25,placeholder:X.width==="mixed"?"混合":void 0},v("borderWidth","bb-border-width"))),_(t,"bb-border-color",W("边框颜色",Ae(Z,y=>fe("borderColor",y),"边框颜色"),void 0,v("borderColor","bb-border-color")))]),...p.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},gs.map(y=>a("button",{type:"button",class:"pd-button small",text:y.label,disabled:y.value==="inner",onClick:()=>G(y.value)}))),a("div",{class:"pd-checkbox-group"},bs.map(y=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:p.elementBorderEdgeVisible(i,y.value),onChange:()=>ce(y.value)}),a("span",{text:y.label})]))),a("p",{class:"pd-hint",text:p.ELEMENT_BORDER_APPLY_HINT})]:[],_(t,"bb-bg-color",W("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","bb-bg-color")))])])),m.push(us(t,e)),m.push(Se(t,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"advanced-row"},[_(t,"ad-locked",bt(t,"锁定",!!i.locked,y=>r({locked:y}),v("locked","ad-locked"))),_(t,"ad-fixed",bt(t,"每页重复",!!i.fixed,y=>r({fixed:y}),v("fixed","ad-fixed")))]),_(t,"ad-z-index",he(t,"层级",i.zIndex,y=>r({zIndex:y}),{min:0,max:999},v("zIndex","ad-z-index"))),_(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"},m)}function vs(t){const e=t.store,o=e.templateData,i=c=>e.updateTemplateData(c),n=c=>{const u=o.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(c)!==h(o.outputRotation)){const m=D.computeMaxColumns({...o,outputRotation:c});i({outputRotation:c,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:c})},r=[];for(const[c,u]of Object.entries(p.PAPER_PRESETS)){const h=u.group??"其他";let m=r.find(g=>g.group===h);m||(m={group:h,items:[]},r.push(m)),m.items.push({key:c,label:u.label??c})}const l=!p.PAPER_PRESETS[o.paperSize],s=p.isContinuousPaperSize(o.paperSize);return a("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Pe("纸张设置"),W("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:c=>i({paperSize:c.target.value})},[...r.map(c=>a("optgroup",{label:c.group},c.items.map(u=>a("option",{value:u.key,text:u.label,selected:o.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:l})])),s||l?W(s?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[P({value:Number(o.customWidth??0),min:25,max:2e3,onCommit:c=>i({customWidth:c})}),...l?[a("span",{class:"custom-size-x",text:"×"}),P({value:Number(o.customHeight??0),min:25,max:2e3,onCommit:c=>i({customHeight:c})})]:[]])):"",s?"":W("纸张方向",je("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.orientation==="landscape"?"landscape":"portrait",c=>i({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),s?"":W("内容旋转角度",je("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(o.outputRotation??0),c=>n(Number(c)),!0),o.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),W("页面背景色",a("div",{class:"page-bg-row"},[Ae(o.pageBackground,c=>i({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,rt({target:o,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),Gl(t),e.pages.length>1?"":ql(t),Pe("页边距 (mm)"),a("div",{class:"margin-grid"},[he(t,"上",o.margins.top,c=>i({margins:{...o.margins,top:c}}),{min:0,max:50}),he(t,"下",o.margins.bottom,c=>i({margins:{...o.margins,bottom:c}}),{min:0,max:100}),he(t,"左",o.margins.left,c=>i({margins:{...o.margins,left:c}}),{min:0,max:50}),he(t,"右",o.margins.right,c=>i({margins:{...o.margins,right:c}}),{min:0,max:50})]),Pe("页眉/页脚高度 (mm)"),he(t,"页眉高度",o.header.height??10,c=>i({header:{...o.header,height:c}}),{min:0,max:100,step:.1}),he(t,"页脚高度",o.footer.height??10,c=>i({footer:{...o.footer,height:c}}),{min:0,max:100,step:.1}),ms(t)].filter(Boolean))}function ys(t){const e=t.store,o=t.state,i=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,l,s])=>a("button",{type:"button",class:`pc-btn${o.propTab===r?" on":""}`,title:l,text:s,onClick:()=>{o.propTab=r,o.propCollapsed=!1,t.repaint()}}))])]);const n=i?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${n==="element"?" active":""}`,text:"元素属性",onClick:()=>{o.propTab="element",t.repaint()}}),a("button",{type:"button",class:`pd-tab${n==="page"?" active":""}`,text:"页面属性",onClick:()=>{o.propTab="page",t.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="element"?"":{display:"none"}},i?[Zl(t),xs(t,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="page"?"":{display:"none"}},[vs(t)])])])}const Lo=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],pn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},ws=[{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()"}],Ss=[{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()"}],Ts=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],Es=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],ks=[{title:"聚合函数",items:ws},{title:"数值运算",items:Ss},{title:"格式化函数",items:Ts}],Cs="(输入表达式后预览)",As="(无法计算)",jo="(表达式错误)";function un(t,e){if(!t.trim())return Cs;try{const o={...p.DEFAULT_DEMO_DATA,...e??{},...D.resolveSystemVariables()},i=p.evaluateTemplate(t,o);return i==null?As:String(i)}catch{return jo}}function hn(t,e){const o=e.trim().toLowerCase();return o?t.filter(i=>i.label.toLowerCase().includes(o)||i.name.toLowerCase().includes(o)):t}function Ds(t,e){const o=t.substring(0,e),i=o.lastIndexOf("{"),n=i!==-1&&!o.slice(i+1).includes("}"),r=o.lastIndexOf("("),l=r!==-1&&!o.slice(r+1).includes(")");return{insideBlock:n,insideParens:l}}function Ms(t,e){const o=/^\{\s*([^{}]+?)\s*\}$/.exec(t.trim());if(!o)return null;const i=o[1]??"";return e.find(n=>n.fieldKey===i)??null}function Io(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 Be(t){return t.currentTarget.getRootNode()}function Qt(t,e,o){const i=[];return o.forEach((n,r)=>{i.push(n),r<o.length-1&&i.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"},i)])}function _s(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Qt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Qt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Qt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Qt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function Rs(t,e){const o={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding,copiedFieldKey:""},i=(x,T)=>x.querySelector(T),n=x=>{const T=i(x,".ee-preview");if(!T)return;const E=un(o.expression,t.demoData);T.textContent=E,T.classList.toggle("ee-preview-error",E===jo)},r=()=>{if(o.activeTab==="variable")return hn(Es,o.searchText).map(E=>a("div",{class:"ee-list-item",onDblclick:A=>{const{insideParens:L}=c(A);u(Be(A),L?E.template.replace(/^\{|\}$/g,""):E.template)}},[Io(E.label,E.template)]));if(o.activeTab==="function")return ks.map(E=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:E.title}),...hn(E.items,o.searchText).map(A=>a("div",{class:"ee-list-item",onDblclick:L=>{const{insideBlock:F}=c(L),G=F?A.template:`{${A.template}}`;u(Be(L),G,G.indexOf("(")+1)}},[Io(A.label,`${A.name}()`)]))]));const x=p.filterGroups(p.groupFields(t.fields??[]),o.searchText);if(!x.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const T=[];for(const E of x){E.key&&T.push(a("div",{class:`ee-field-group${E.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:E.isList?"📋":"📁"}),a("span",{text:E.label})]));for(const A of E.fields)T.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:E.key?"22px":"10px"},onDblclick:L=>{const{insideParens:F}=c(L),G=L;if(G.ctrlKey||G.metaKey){const ce=A.fieldLabel||A.fieldKey;u(Be(L),F?`"${ce}"`:ce);return}u(Be(L),F?A.fieldKey:`{${A.fieldKey}}`)}},[Io(A.fieldLabel,A.fieldKey),a("button",{type:"button",class:`ee-copy-btn${o.copiedFieldKey===A.fieldKey?" is-copied":""}`,"data-tip":o.copiedFieldKey===A.fieldKey?"已复制":`复制字段名「${A.fieldLabel}」`,"aria-label":`复制字段名 ${A.fieldLabel}`,html:xe(o.copiedFieldKey===A.fieldKey?"Check":"Copy",13),onClick:L=>{L.stopPropagation(),s(L,A)},onDblclick:L=>L.stopPropagation()})]))}return T},l=x=>{Array.from(x.querySelectorAll(".ee-nav-tab")).forEach((F,G)=>F.classList.toggle("active",Lo[G]?.key===o.activeTab));const E=i(x,".ee-content-search .pd-input");if(E){const F=pn[o.activeTab];E.placeholder!==F&&(E.placeholder=F),E.value!==o.searchText&&(E.value=o.searchText)}const A=i(x,".ee-textarea");A&&A.value!==o.expression&&(A.value=o.expression);const L=i(x,".ee-content-list");if(L){kn(L);for(const F of r())be(F,L)}n(x)};function s(x,T){const E=Be(x);p.copyTextToClipboard(T.fieldLabel||T.fieldKey).then(A=>{A&&(o.copiedFieldKey=T.fieldKey,l(E),setTimeout(()=>{o.copiedFieldKey===T.fieldKey&&(o.copiedFieldKey="",l(E))},1200))})}const c=x=>{const E=i(Be(x),".ee-textarea")?.selectionStart??o.expression.length;return Ds(o.expression,E)},u=(x,T,E=T.length)=>{const A=i(x,".ee-textarea");if(!A){o.expression+=T,n(x);return}const L=A.selectionStart??o.expression.length,F=A.selectionEnd??L;o.expression=o.expression.substring(0,L)+T+o.expression.substring(F);const G=L+E;A.value=o.expression,A.focus(),A.selectionStart=A.selectionEnd=G,n(x)},h=()=>{const x=o.expression;if(o.binding===void 0){t.onApply({formatter:x}),t.onClose();return}const T=Ms(x,t.fields??[]);t.onApply(T?{formatter:x,binding:T.fieldKey,title:T.fieldLabel}:{formatter:x}),t.onClose()},m=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},Lo.map((x,T)=>a("div",{class:`ee-nav-tab${o.activeTab===x.key?" active":""}`,text:x.text,onClick:E=>{o.activeTab=Lo[T].key,l(Be(E))}})))]),g=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:pn[o.activeTab],onInput:x=>{o.searchText=x.target.value,l(Be(x))}})]),a("div",{class:"ee-content-list"},r())]),v=un(o.expression,t.demoData),S=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:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:o.expression,onInput:x=>{o.expression=x.target.value,n(Be(x))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${v===jo?" ee-preview-error":""}`,text:v})]),_s()]);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"},[m,g,S]),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:()=>h()})])])])}const zs={id:"getting-started",title:"快速入门",content:`
4
4
  <h2>界面布局</h2>
5
5
  <p>打印模板设计器采用三栏布局:</p>
6
6
  <ul>
@@ -40,7 +40,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
40
40
  <p><strong>项目名称:</strong>worm-vue3-print</p>
41
41
  <p><strong>仓库地址:</strong><a href="https://gitee.com/liulong_oschina/worm-vue3-print" target="_blank" rel="noopener noreferrer">https://gitee.com/liulong_oschina/worm-vue3-print</a></p>
42
42
  <p>基于 Vue 3 的可视化打印模板设计器,支持拖拽式模板编辑、表达式数据绑定和浏览器端打印预览。</p>
43
- `},Ts={id:"features",title:"功能说明",content:`
43
+ `},Fs={id:"features",title:"功能说明",content:`
44
44
  <h2>元素类型</h2>
45
45
  <table>
46
46
  <thead>
@@ -211,7 +211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
211
211
  <li>支持调节水印密度(密/中/疏/自定义瓦片尺寸),以及设置水印颜色</li>
212
212
  <li>水印在画布、浏览器预览、服务端 PDF、静默打印四端渲染一致</li>
213
213
  </ul>
214
- `},Es={id:"shortcuts",title:"快捷键",content:`
214
+ `},Ps={id:"shortcuts",title:"快捷键",content:`
215
215
  <h2>常用操作</h2>
216
216
  <table>
217
217
  <thead>
@@ -281,7 +281,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
281
281
  <blockquote>
282
282
  <p><strong>注意</strong>:当焦点在输入框、文本框、下拉框内时,快捷键不生效。</p>
283
283
  </blockquote>
284
- `},ks={id:"faq",title:"常见问题",content:`
284
+ `},Ls={id:"faq",title:"常见问题",content:`
285
285
  <h2>如何调整纸张大小?</h2>
286
286
  <ol>
287
287
  <li>在右侧面板选择"页面设置"</li>
@@ -415,13 +415,35 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
415
415
  <blockquote>
416
416
  <p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
417
417
  </blockquote>
418
- `},Cs={id:"changelog",title:"更新记录",content:`
418
+ `},Is={id:"changelog",title:"更新记录",content:`
419
+ <h2>V1.4.4<small>(2026-11-04)</small></h2>
420
+
421
+ <h3>新增</h3>
422
+ <ul>
423
+ <li><strong>表格明细行按值纵向合并</strong>:数据行模板格打开「按值合并」后,相邻明细行该列文本相同即自动纵向合并(批次/类别/单位等重复值列),不再逐行重复显示。归并按页计算,跨页的合并段在页尾断开、下一页首行重新显示该值,分页与明细行数完全不受影响。空值与含页码的列不参与,各列独立归并,建议数据先按该列排序。</li>
424
+ <li><strong>流式列表支持动态分页容器</strong>:属性台「布局模式」选「动态」后,列表高度由内容撑开,满页后按真实文本行整行续页,文本与跨列单元不会拆行;可另设四边内边距,参与分页预算。缺省「固定」,旧模板无需迁移。本期动态块内仅支持文本。</li>
425
+ </ul>
426
+
427
+ <h3>修复</h3>
428
+ <ul>
429
+ <li><strong>明细行横向合并不再被归一误伤</strong>:数据行内单行横向合并(跨列)保持原有列数;dynamic 展开时模板上的纵向跨度不再逐行复制,表格不再错位。</li>
430
+ <li><strong>空条码在设计态显示可编码的示例值</strong>:内容与示例值都为空时,画布此前显示文字「条码」,画不出码面;现回退显示示例值 12345678,呈现真实条码图样。仅影响设计态,出纸不变。</li>
431
+ </ul>
432
+
433
+ <h2>V1.4.3<small>(2026-11-01)</small></h2>
434
+
435
+ <h3>修复</h3>
436
+ <ul>
437
+ <li><strong>导入旧模板不再带进「画布看得见、纸上却空白」的 HTML 元素</strong>:HTML 是占位类型,设计台上画得出来、纸上永远是空的。现在导入含这类元素的旧模板时,正文、页眉、页脚里的它们会被一并剥离,不再留下骗人的空位。素材台的「HTML」按钮本版仍保留,用它新建的元素照旧不会上纸,请改用文本或图片。</li>
438
+ <li><strong>拖动字段时的 Ctrl / ⌘ 切换在 Mac 与 Windows 上都能用了</strong>:此前按住修饰键拖动常常整次被系统判为无效(松手没反应),或复制徽标根本不出现。现在拖动途中任何时候按住 Ctrl(Mac 为 ⌘)就把本次切成「生成静态文本」,画布上跟着光标显示「+ 取值字段 / + 静态文本 / + 元素」的落点提示,看到什么就生成什么;表达式弹窗里双击字段同样支持途中按住切换。提示语也改成与实际一致的「拖动 / 双击途中按住」。</li>
439
+ </ul>
440
+
419
441
  <h2>V1.4.2<small>(2026-10-30)</small></h2>
420
442
 
421
443
  <h3>新增</h3>
422
444
  <ul>
423
445
  <li><strong>素材台单击字段复制中文名</strong>:单击素材台字段行复制字段名并提示「已复制」(拖拽起手不触发);表达式弹窗里每个字段行右侧新增复制图标,点击后短暂变对勾。字段名需要当静态文本复用时不用再手打。</li>
424
- <li><strong>字段名当静态文本的两条 Ctrl 入口</strong>:表达式弹窗里按住 Ctrl(Mac 为 ⌘)双击字段插入字段中文名,函数参数内自动加引号;素材台按住 Ctrl 拖动字段到画布,直接生成内容为字段中文名的文本元素。不按 Ctrl 仍是原来的取值绑定。</li>
446
+ <li><strong>字段名当静态文本的两条 Ctrl 入口</strong>:表达式弹窗里双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段中文名,函数参数内自动加引号;素材台拖动途中按住 Ctrl(Mac 为 ⌘)切换为生成内容为字段中文名的文本元素。不按 Ctrl 仍是原来的取值绑定。</li>
425
447
  </ul>
426
448
 
427
449
  <h3>变更</h3>
@@ -781,6 +803,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
781
803
  <blockquote>
782
804
  <p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
783
805
  </blockquote>
784
- `},to=[Ss,Ts,Es,ks,Cs],Kn="worm-print-help-tab",As="getting-started";function un(o){return to.some(e=>e.id===o)?String(o):""}function Ds(o){let e=null;try{e=window.localStorage.getItem(Kn)}catch{e=null}return un(e)||un(o)||As}function Ms(o){const e=Ds(o.initialTab),t=(i,n)=>{const r=i.currentTarget,l=r.closest(".help-modal");if(!l)return;for(const c of Array.from(l.querySelectorAll(".help-tab")))c.classList.toggle("active",c===r);const s=l.querySelector(".help-content");s&&(s.innerHTML=to.find(c=>c.id===n)?.content??"");try{window.localStorage.setItem(Kn,n)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:i=>{i.target===i.currentTarget&&o.onClose()},onKeydown:i=>{i.key==="Escape"&&o.onClose()}},[a("div",{class:"help-modal"},[a("div",{class:"help-modal-header"},[a("div",{class:"help-modal-title-wrap"},[a("h2",{class:"help-modal-title",text:"帮助文档"}),a("span",{class:"help-modal-project",text:"worm-vue3-print"})]),a("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"help-modal-body"},[a("div",{class:"help-modal-sidebar"},to.map(i=>a("button",{type:"button",class:`help-tab${i.id===e?" active":""}`,text:i.title,onClick:n=>t(n,i.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:to.find(i=>i.id===e)?.content??""})])])])])}function _s(o,e){const t=me(Ms(e),o),i=n=>{n.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",i),t.focus?.(),()=>{document.removeEventListener("keydown",i),t.remove()}}const Rs=2,zs=74,Yo=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function Fs(o){const e=!!o.state.openMore,t=Yo.slice().sort((i,n)=>i.order-n.order).map(i=>a("div",{class:"tb-more-item",dataset:{unit:i.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:i.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${i.id}`,dataset:{unit:i.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{o.state.openMore=!e,o.repaint()},html:`${ge("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ge("ChevronDown",12,"tb-dd-arrow")}`}),a("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[a("div",{class:"tb-menu tb-more-menu"},t)])])])}const hn=new WeakMap;function fn(o){const e=o.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const t=getComputedStyle(e),i=Number.parseFloat(t.gap)||Rs,n=Number.parseFloat(t.paddingLeft)||0,r=Number.parseFloat(t.paddingRight)||0,l=new Map;for(const b of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const T=b.parentElement;T&&!T.classList.contains("tb-more-slot")&&hn.set(b,{parent:T,next:b.nextSibling}),l.set(b.dataset.unit,b)}for(const b of l.values()){const T=hn.get(b);!T||b.parentElement===T.parent||(T.next?.parentElement===T.parent?T.parent.insertBefore(b,T.next):T.parent.appendChild(b))}let s=0;for(const b of Array.from(e.children)){if(b.classList.contains("tb-spacer")||b.classList.contains("tb-more-group"))continue;const T=Math.max(b.offsetWidth,b.scrollWidth);T<=0||(s+=T+i)}const c=new Map;for(const[b,T]of l){const E=T.offsetWidth;E>0&&c.set(b,E)}const u=Yo.map(b=>({id:b.id,order:b.order,width:c.get(b.id)??0})),h=u.reduce((b,T)=>b-T.width-i,s),m=e.clientWidth-n-r,{movedIds:g,overflowRemains:v}=p.resolveToolbarOverflow({available:m,pinned:h,moreTriggerWidth:zs,gap:i,units:u});for(const b of Yo){const T=e.querySelector(`.tb-more-item[data-unit="${b.id}"]`),E=e.querySelector(`#tb-more-slot-${b.id}`),A=l.get(b.id);if(!T||!E||!A)continue;const P=g.includes(b.id);P&&A.parentElement!==E&&E.appendChild(A),T.style.display=P?"":"none"}const S=e.querySelector(".tb-more-group");return S&&(S.style.display=g.length>0?"":"none"),e.classList.toggle("is-tight",v),{movedIds:g,overflowRemains:v}}function Ps(o,e){const t=o.store,i=t.selectedIds.size>0,n=t.selectedIds.size>1,r=t.selectedElement,l=!i,s=o.isEdit?"编辑模板":"新建模板",c=[a("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[a("div",{class:"tb-menu-label",text:"对齐 / 分布"}),a("div",{class:"tb-menu-grid"},[ee(o,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!n}),ee(o,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!n}),ee(o,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!n}),ee(o,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!n}),ee(o,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!n}),ee(o,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!n}),ee(o,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!n}),ee(o,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!n})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[ee(o,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!i}),ee(o,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!i}),ee(o,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!i}),ee(o,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!i})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[ee(o,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!n}),ee(o,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],u=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[h("标尺",t.showRuler,"toggle-ruler","显示/隐藏标尺"),h("网格",t.showGrid,"toggle-grid","显示/隐藏网格背景"),h("虚框",t.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),h("吸附",t.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function h(m,g,v,S){return a("button",{type:"button",class:`tb-btn tb-menu-row${g?" on":""}`,dataset:{tip:S},onClick:()=>o.fire(v)},[a("span",{class:"dot"}),m])}return a("div",{class:"designer-toolbar"},[a("div",{class:"tb-group tb-brand"},[a("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),a("div",{class:"tb-title"},[a("span",{class:"tb-title-name",text:s}),a("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),a("div",{class:"tb-group"},[ee(o,"Undo2","undo",{tip:"撤销",disabled:!t.canUndo}),ee(o,"Redo2","redo",{tip:"重做",disabled:!t.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[no(o,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),no(o,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},u)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[ee(o,"Maximize","fit-window",{tip:"适应窗口"}),ee(o,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${t.scale}%`}),ee(o,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[ee(o,"Copy","copy",{tip:l?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:l,test:"copy"}),ee(o,"ClipboardPaste","paste",{tip:l?"粘贴 (Ctrl+V),需选中元素":t.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:l||!t.hasClipboard,test:"paste"}),ee(o,"Trash2","delete",{tip:l?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:l,danger:!0,test:"delete"})]),Fs(o),a("div",{class:"tb-spacer"}),o.showHelp?a("div",{class:"tb-group"},[a("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>o.fire("help")},[a("span",{class:"help-icon",text:"?"})])]):"",a("div",{class:"tb-group"},[a("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>o.fire("preview")}),a("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>o.fire("save")})])].filter(Boolean))}function Oo(o,e,t){for(const i of e){const n=o.getPropertyValue(i).trim();if(n)return n}return t}function Ls(o,e){const t=e.orientation==="horizontal",i=e.geom,n=t?i.viewW:i.viewH;o.style.width=`${t?n:p.RULER_THICKNESS}px`,o.style.height=`${t?p.RULER_THICKNESS:n}px`;const r=o.getContext("2d");if(!r)return;const l=window.devicePixelRatio||1,s=Math.max(0,Math.round(n)),c=p.RULER_THICKNESS;o.width=(t?s:c)*l,o.height=(t?c:s)*l,r.setTransform(l,0,0,l,0,0);const u=getComputedStyle(o),h=Oo(u,["--pd-ruler-bg"],"#F8F9FC"),m=Oo(u,["--pd-ruler"],"#9AA1AF"),g=Oo(u,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=h,r.fillRect(0,0,t?s:c,t?c:s);const v=e.scale>0?e.scale:i.paperScale>0?i.paperScale:1,S=p.mmToPx(1)*v;if(S<=0)return;const b={ctx:r,horizontal:t,viewportPx:n,thickness:c,originPx:t?i.originX:i.originY,pxPerMM:S,paperLengthMM:e.paperLengthMM},T=-b.originPx/S,E=(s-b.originPx)/S,A=p.chooseMajorStepMM(v),P=p.buildRulerTicks(T,E,A);mn(b,P,m,!0),mn(b,P,m,!1),gn(b,0,g),gn(b,e.paperLengthMM,g);const F=e.cursorPx??null;if(F!==null&&F>=0&&F<=s){if(r.strokeStyle=g,r.lineWidth=1.5,r.beginPath(),t){const U=Math.round(F)+.5;r.moveTo(U,0),r.lineTo(U,c)}else{const U=Math.round(F)+.5;r.moveTo(0,U),r.lineTo(c,U)}r.stroke()}}function jn(o,e){return Math.round(o.originPx+e*o.pxPerMM)+.5}function mn(o,e,t,i){const{ctx:n,horizontal:r,paperLengthMM:l}=o;n.strokeStyle=t,n.fillStyle=t,n.globalAlpha=i?.32:1,n.lineWidth=1,n.font="9px ui-monospace, Menlo, monospace",n.textBaseline="top";for(const s of e){if((s.mm<0||s.mm>l)!==i)continue;const u=jn(o,s.mm),h=s.major?8:4;n.beginPath(),r?(n.moveTo(u,0),n.lineTo(u,h)):(n.moveTo(0,u),n.lineTo(h,u)),n.stroke(),s.major&&s.label&&(r?n.fillText(s.label,u+2,11):(n.save(),n.translate(11,u+2),n.rotate(-Math.PI/2),n.fillText(s.label,0,0),n.restore()))}n.globalAlpha=1}function gn(o,e,t){const{ctx:i,horizontal:n,thickness:r,viewportPx:l}=o,s=jn(o,e);s<=0||s>=l||(i.strokeStyle=t,i.globalAlpha=.55,i.lineWidth=1,i.beginPath(),n?(i.moveTo(s,0),i.lineTo(s,r)):(i.moveTo(0,s),i.lineTo(r,s)),i.stroke(),i.globalAlpha=1)}const Is=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Jt=20,Os=".page-tabs, .field-tree-panel, .pd-dialog-overlay",Ns=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),$s={text:"formatter",longText:"formatter",flowList:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},bn="print-studio:left",xn="print-studio:right";function vn(o){try{return localStorage.getItem(o)==="1"}catch{return!1}}function yn(o,e){try{localStorage.setItem(o,e?"1":"0")}catch{}}class Ne extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Is,this.root.appendChild(e),me(a("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(e){this.applyTemplate(e)}get template(){return this.store?.getTemplateJson()}set fields(e){this.store.fields=(typeof e=="string"?JSON.parse(e):e)??[],this.repaint()}set isEdit(e){this.setAttribute("is-edit",String(e)),this.repaint()}set showHelp(e){this.setAttribute("show-help",String(e)),e||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(e,t,i){if(!i)return;if(e==="name"){this.repaint();return}let n;try{n=JSON.parse(i)}catch{return}e==="template"?this.applyTemplate(n):e==="fields"?(this.store.fields=n,this.repaint()):e==="fonts"&&Array.isArray(n)&&(this.fonts=n)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},t=this.getAttribute("template");if(t)try{e.initialTemplate=JSON.parse(t)}catch{}const i=this.getAttribute("fields");if(i)try{e.initialFields=JSON.parse(i)}catch{}this.store=new kn(e),this.format=new xr(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=vn(bn),this.state.propCollapsed=vn(xn),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const e=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;e!==this.chromeKey&&(this.chromeKey=e,yn(bn,this.state.leftCollapsed),yn(xn,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Ne.active===this&&(Ne.active=null),On(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=D.buildFontFaceCss(this._fonts);if(!e){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=e,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=e}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),t=this.fonts;if(!t?.length)return e;if(Array.isArray(e.pages)){const i=e;return{...i,pages:i.pages.map(n=>({...n,fonts:[...t]}))}}return{...e,fonts:[...t]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const t=this.getGeometryWarnings();t.length&&window.alert(`出纸提示(不影响保存):
785
- ${t.join(`
786
- `)}`);const i=this.templateJsonWithFonts();if(Array.isArray(i.pages))try{D.normalizeTemplate(i)}catch(r){window.alert(r instanceof Error?r.message:String(r));return}const n=JSON.stringify(i);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?D.validateTiling(e):[]}getGeometryWarnings(){return D.collectPrintWarnings(this.store.templateData)}applyTemplate(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(t):this.setAttribute("template",JSON.stringify(t))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(i=>i.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(i=>i.remove());const t=this.exprTarget;me(ws({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:i=>this.applyExpression(t,i)},t),this.root),this.exprMountedFor=t}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const e=this.helpVisible&&this.getAttribute("show-help")!=="false";if(e&&!this.unmountHelp)this.unmountHelp=_s(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const t=this.unmountHelp;this.unmountHelp=null,t()}}applyExpression(e,t){const i=t.formatter??"",n=e.targetPath;if(n.startsWith("options.")){if(n.includes("[")){const l=this.store.elements.find(s=>s.id===e.elementId);l&&li(this.store,l,n,i);return}const r={[n.slice(8)]:i||void 0};t.title!==void 0&&(r.title=t.title),this.store.updateElement(e.elementId,r);return}if(n==="watermark.content"){const r={...this.store.templateData.watermark};Ko(i)?Object.assign(r,{mode:"binding",binding:i,content:""}):Object.assign(r,{mode:"fixed",content:i,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const t=this.store.elements.find(n=>n.id===e);if(!t||(this.store.selectOne(e),this.state.propTab="element",t.options.locked))return;const i=$s[t.printElementType.type];i&&this.openExpression({elementId:t.id,targetPath:`options.${i}`,value:String(t.options[i]??"")})}dblEditCell(e){const t=this.store.elements.find(s=>s.id===e.elementId);if(!t||(this.store.selectOne(t.id),this.state.propTab="element",t.options.locked))return;const i=t.options.tableRows??[],n=p.findMainCell(i,e.r,e.c),l=i[n.r]?.cells[n.c];l&&this.openExpression({elementId:t.id,targetPath:`options.tableRows[${n.r}].cells[${n.c}].formatter`,value:l.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(e,t)=>this.fire(e,t),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const e=[...this.store.selectedIds].join(",");e!==this.lastSelKey&&(this.lastSelKey=e,this.state.propTab=e?"element":"page");const t=this.root.querySelector(".designer-container");t.classList.toggle("format-painting",this.format.painterActive),Tn(t);const i=this.ctx;me(Ps(i,Tl(i)),t),me(_l(i),t),me(a("div",{class:"designer-body"},[Cl(i),nl(i,this.canvasUi()),cs(i)]),t),me(Rl(i),t),fn(t),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>fn(t)),this.toolbarRo.observe(t));const n=Pa(this.store,(r,l)=>this.fire(r,l),this.tableMenu);n&&me(n,t),la(this.root,this.store.elements),Wn(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Vo.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const t=e.getAttribute("data-fit-base");t?e.style.fontSize=`${t}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),t=this.root.querySelector(".hiprint-printPaper");if(!e||!t)return;const i=e.getBoundingClientRect(),n=t.getBoundingClientRect(),r=(this.store.scale||100)/100,l=n.width/p.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(l-r)<.002?r:l,originX:n.left-i.left-Jt+this.scrollPos.x,originY:n.top-i.top-Jt+this.scrollPos.y,viewW:e.clientWidth-Jt,viewH:e.clientHeight-Jt},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,t=p.getPaperDimensions(e),i=this.geom.paperScale;for(const n of Array.from(this.root.querySelectorAll(".pd-ruler"))){const r=n.dataset.ruler==="vertical"?"vertical":"horizontal";Ls(n,{orientation:r,geom:this.geom,scale:i,paperLengthMM:r==="horizontal"?t.width:t.height})}}patchElementDom(){for(const i of this.store.elements){const n=this.root.querySelector(`[data-el-id="${CSS.escape(i.id)}"]`);n&&(n.style.left=`${i.options.left}mm`,n.style.top=`${i.options.top}mm`,n.style.width=`${i.options.width}mm`,n.style.height=`${i.options.height}mm`)}const e=this.root.querySelector(".position-label"),t=this.store.selectedElement;e&&t&&!this.drag&&(e.textContent=Nn(t.options))}fire(e,t){const i=this.store;switch(e){case"undo":i.undo();break;case"redo":i.redo();break;case"align":i.alignSelected(t);break;case"move-layer":i.moveLayer(t);break;case"group":i.groupSelected();break;case"ungroup":i.ungroupSelected();break;case"copy":i.copy();break;case"cut":i.cutSelected();break;case"paste":i.paste();break;case"paste-at":i.paste();break;case"delete":i.deleteSelected();break;case"delete-page":i.deletePage(i.activePageIndex);break;case"add-page":i.addPage();break;case"duplicate-page":i.duplicatePage(i.activePageIndex);break;case"move-page":i.movePage(i.activePageIndex,i.activePageIndex+t);break;case"select-all":i.selectAll();break;case"clear-selection":i.clearSelection();break;case"toggle-ruler":i.showRuler=!i.showRuler,this.repaint();break;case"toggle-grid":i.showGrid=!i.showGrid,this.repaint();break;case"toggle-snap":i.snapToGrid=!i.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":i.showTableGhostBorder=!i.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(t>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":i.removeGuide(t);break;case"resize-start":this.beginResize(t);break;case"element-mousedown":{const n=t;n.event.button===0&&this.isDoubleTap(`el:${n.id}`,n.event)&&this.fire("element-dblclick",{event:n.event,id:n.id}),this.beginDrag(n);break}case"table-cell-mousedown":{const n=t;this.isDoubleTap(`cell:${n.elementId}:${n.r}:${n.c}`,n.event)&&(this.taps.delete(`el:${n.elementId}`),this.fire("table-cell-dblclick",{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId}));break}case"zone-resize":this.beginZoneResize(t);break;case"guide-mousedown":this.beginGuideDrag(t);break;case"ruler-mousedown":this.beginRulerGuide(t);break;case"canvas-mousedown":this.onCanvasMouseDown(t);break;case"canvas-mousemove":this.onCanvasMouseMove(t);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(t);break;case"contextmenu":this.onElementContextMenu(t);break;case"element-dblclick":{const{id:n}=t;this.dblEditElement(n),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:n,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const n=t;this.dblEditCell(n),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(t);break;case"drop":this.onDrop(t);break;case"wheel":this.onWheel(t);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const t=e.dataTransfer,i=t?.getData("elementType"),n=t?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const l={x:r.left,y:r.top};if(i)this.store.addElement(i,{},l);else if(n){const s=this.store.fields.find(c=>c.fieldKey===n);s&&this.store.addFieldElement(s,{},l,e.ctrlKey||e.metaKey)}}pointToPaperMm(e){const t=this.root.querySelector(".hiprint-printPaper");if(!t)return null;const i=t.getBoundingClientRect(),n=(this.store.scale||100)/100,r=p.pxToMm((e.clientX-i.left)/n),l=p.pxToMm((e.clientY-i.top)/n);return r<0||l<0?null:{left:r,top:l}}onCanvasMouseDown(e){const t=e.target;(t===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(n=>t.classList.contains(n)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const t=this.pointToPaperMm(e),i=this.root.querySelector("[data-coord]");if(i){if(!t){i.style.display="none";return}i.style.display="",i.textContent=`x:${(t.left-this.store.templateData.margins.left).toFixed(1)} y:${(t.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,t){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=t,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const i=this.root.querySelector(".context-menu");if(!i)return;const n=i.getBoundingClientRect();this.menu.flipX=n.right>window.innerWidth?window.innerWidth-n.right-8:0,this.menu.flipY=n.bottom>window.innerHeight?window.innerHeight-n.bottom-8:0,this.paint()})}startMarquee(e){const t={x:e.clientX,y:e.clientY},i=r=>{this.marquee={visible:!0,x:Math.min(t.x,r.clientX),y:Math.min(t.y,r.clientY),w:Math.abs(r.clientX-t.x),h:Math.abs(r.clientY-t.y)},this.paint()},n=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const l=this.store.elements.filter(s=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(s.id)}"]`);if(!c)return!1;const u=c.getBoundingClientRect();return u.left<r.x+r.w&&u.right>r.x&&u.top<r.y+r.h&&u.bottom>r.y});this.store.select(new Set(l.map(s=>s.id)))}else this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}taps=new Map;isDoubleTap(e,t){const i=this.taps.get(e);return this.taps.set(e,{t:t.timeStamp,x:t.clientX,y:t.clientY}),!i||t.timeStamp-i.t>=500||Math.abs(t.clientX-i.x)>6||Math.abs(t.clientY-i.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const t=e.event;if(t.button!==0)return;const i=this.store;t.stopPropagation();const n=i.elements.find(s=>s.id===e.id);if(!n||(i.selectElement(n.id,t.ctrlKey||t.metaKey),n.options.locked))return;const r=t.altKey?[n.id]:i.dragIds(n.id),l=new Map;for(const s of r){const c=i.elements.find(u=>u.id===s);c&&l.set(s,{left:c.options.left,top:c.options.top})}this.drag={ids:r,primary:n.id,altKey:t.altKey,movedPositions:new Map,startX:t.clientX,startY:t.clientY,origin:l,zone:n.zone||"content",moved:!1},i.draggingIds=new Set(r),i.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const t of Array.from(this.root.querySelectorAll(".print-element"))){const i=e.has(t.dataset.elId??"");t.classList.toggle("drag-ghost",i);const n=t.querySelector(":scope > .drag-preview");i&&!n?me(a("div",{class:"drag-preview"}),t):!i&&n&&n.remove()}}finishAltClone(e){const t=this.store;t.adsorbGuides=[];const i=t.elements.find(l=>l.id===e.primary),n=e.movedPositions.get(e.primary);if(t.discardLive(),!i||!n)return;const r=JSON.parse(JSON.stringify(i));r.id=p.generateId(),r.options.left=n.left,r.options.top=n.top,r.options.groupId=void 0,t.cloneElement(r)}flashSnapIndicator(e,t){const i=this.root.querySelector(".hiprint-printPaper-content");i&&(i.querySelector(".snap-indicator")?.remove(),me(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${t}mm`}}),i),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{i.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const t=e.event;t.stopPropagation();const i=this.store.elements.find(n=>n.id===e.id);!i||i.options.locked||(this.resize={id:e.id,point:e.point,startX:t.clientX,startY:t.clientY,origin:{left:i.options.left,top:i.options.top,width:i.options.width,height:i.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const t=e.event.clientY,i=this.store.templateData,n=e.zone==="header"?i.header.height:i.footer.height,r=(this.store.scale||100)/100,l=c=>{const u=p.pxToMm((c.clientY-t)/r),h=Math.max(0,Math.round((n+(e.zone==="header"?u:-u))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...i.header,height:h}}):this.store.updateTemplateData({footer:{...i.footer,height:h}}),this.paint()},s=()=>{window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",s),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",l),window.addEventListener("mouseup",s)}beginGuideDrag(e){const t=(this.store.templateData.guides??[]).find(h=>h.id===e.id);if(!t)return;const i=p.getPaperDimensions(this.store.templateData),n=t.type==="vertical"?i.width:i.height,r=e.event.clientX,l=e.event.clientY,s=(this.store.scale||100)/100,c=h=>{const m=p.pxToMm((t.type==="vertical"?h.clientX-r:h.clientY-l)/s);this.store.moveGuide(t.id,Math.min(n,Math.max(0,t.position+m))),this.paint()},u=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",u),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",u)}beginRulerGuide(e){const t=e.orientation==="horizontal"?"vertical":"horizontal",i=r=>{this.guidePreview={type:t,position:t==="vertical"?r.clientX:r.clientY},this.paint()},n=r=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const l=this.rulerPointToMM(r,t);this.guidePreview=null,l!==null?this.store.addGuide(t,l):this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}rulerPointToMM(e,t){const i=this.root.querySelector(".hiprint-printPaper");if(!i)return null;const n=i.getBoundingClientRect(),r=p.mmToPx(1)*(this.geom.paperScale||1),l=t==="vertical"?(e.clientX-n.left)/r:(e.clientY-n.top)/r,s=p.getPaperDimensions(this.store.templateData),c=t==="vertical"?s.width:s.height;return l<0||l>c?null:l}applyZoom(e,t,i,n){const r=this.root.querySelector(".canvas-area");if(!r)return;const l=Math.round(this.store.scale),s=Math.max(n,Math.round(e));if(s===l)return;const c=getComputedStyle(r),u=parseFloat(c.paddingLeft)||0,h=parseFloat(c.paddingTop)||0,m=r.scrollLeft+t-u,g=r.scrollTop+i-h,v=s/l;this.store.setScale(s,n),r.scrollLeft=m*v-t+u,r.scrollTop=g*v-i+h}zoomByStep(e){const t=this.root.querySelector(".canvas-area");t&&this.applyZoom(p.nextWheelScale(this.store.scale,e),t.clientWidth/2,t.clientHeight/2,p.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const t=getComputedStyle(e),i=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0),n=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0),r=p.getPaperDimensions(this.store.templateData),l=p.computeFitScale(e.clientWidth-i,e.clientHeight-n,p.mmToPx(r.width),p.mmToPx(r.height));this.applyZoom(l,e.clientWidth/2,e.clientHeight/2,p.FIT_SCALE_MIN_PERCENT)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=this.root.querySelector(".canvas-area");if(!t)return;const i=Math.round(this.store.scale),n=p.nextWheelScale(i,e.deltaY>0?-1:1);if(n===i)return;const r=t.getBoundingClientRect();this.applyZoom(n,e.clientX-r.left,e.clientY-r.top,p.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const t=this.store;if(!t)return;const n=((t.scale||100)/100||1)*p.mmToPx(1),r=(l,s)=>({dx:l/n,dy:s/n});if(this.drag){const{dx:l,dy:s}=r(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(l)>.05||Math.abs(s)>.05)&&(this.drag.moved=!0);const c=t.elements.find(S=>S.id===this.drag.primary),u=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+l,top:(this.drag.origin.get(c.id)?.top??0)+s,width:c.options.width,height:c.options.height};let h=null;if(u&&t.snapToGrid!==!1){const S=t.elements.filter(E=>!this.drag.ids.includes(E.id)&&(E.zone||"content")===this.drag.zone).map(E=>({id:E.id,left:E.options.left,top:E.options.top,width:E.options.width,height:E.options.height})),b=Uo(t.templateData,t.paperSize)[this.drag.zone],T=p.computeAdsorb(u,S,this.manualGuides());h={left:T.left,top:T.top},t.adsorbGuides=(T.lines??[]).filter(E=>E.position>=0&&E.position<=(E.type==="vertical"?b.width:b.height)),(h.left!==u.left||h.top!==u.top)&&this.flashSnapIndicator(h.left+u.width/2,h.top+u.height/2)}else t.adsorbGuides=[];const m=c?this.drag.origin.get(c.id):void 0,g=h&&m?h.left-m.left:l,v=h&&m?h.top-m.top:s;for(const S of this.drag.ids){const b=this.drag.origin.get(S);if(!b)continue;const T={left:b.left+g,top:b.top+v};this.drag.movedPositions.set(S,T),t.livePatch(S,T)}this.patchElementDom(),t.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:l,dy:s}=r(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=p.calcResizeRect(this.resize.point,this.resize.origin,l,s,3.5,3.5);t.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const e=!!this.drag,t=this.drag;if(t?.moved&&t.altKey){this.finishAltClone(t),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),e&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",e=>{const t=e.composedPath(),i=t.some(r=>r.classList?.contains("tb-dd"));this.state.openDd&&!i&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!i&&(this.state.openMore=!1,this.repaint());const n=t.some(r=>r.classList?.contains("context-menu"));this.menu.visible&&!n&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const i=e.target?.closest?.("[data-tip]");!i||!i.closest(Os)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(i),300))}),this.root.addEventListener("mouseout",e=>{const t=e,i=t.target?.closest?.("[data-tip]");i&&t.relatedTarget?.closest?.("[data-tip]")!==i&&this.hideHoverTip()})}showHoverTip(e){const t=e.dataset.tip;if(!t)return;this.hideHoverTip();const i=e.getBoundingClientRect(),n=i.left+i.width/2;this.hoverTipEl=me(a("div",{class:"pd-hover-tip",style:{left:`${n}px`,top:`${i.bottom+6}px`},text:t}),this.root);const r=this.hoverTipEl.offsetWidth/2;if(!r)return;const l=r+8,s=Math.max(window.innerWidth-r-8,l);this.hoverTipEl.style.left=`${Math.min(Math.max(n,l),s)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const e=[],t=[];for(const i of this.store.templateData.guides??[])i.type==="vertical"?e.push(i.position):t.push(i.position);return{vertical:e,horizontal:t}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const i of Array.from(e.querySelectorAll(".adsorb-guide")))i.remove();const t=this.store.paperSize;Uo(this.store.templateData,t);for(const i of this.store.adsorbGuides){const n=document.createElement("div");n.className=`adsorb-guide guide-${i.type}`,i.type==="vertical"?n.style.cssText=`left:${i.position}mm;top:0;height:${t.height}mm;border-left-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`:n.style.cssText=`top:${i.position}mm;left:0;width:${t.width}mm;border-top-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(n)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{Ne.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),Ne.active||(Ne.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null)}onGlobalKeydown(e){const t=this.store;if(!t||Ne.active!==this)return;const n=e.composedPath()[0]?.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const l=e.shiftKey?10:e.ctrlKey?.5:1,s=e.key==="ArrowLeft"?-l:e.key==="ArrowRight"?l:0,c=e.key==="ArrowUp"?-l:e.key==="ArrowDown"?l:0;t.moveSelected(s,c);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),t.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const r=e.key.toLowerCase();Ns.has(r)&&(e.preventDefault(),r==="z"?e.shiftKey?t.redo():t.undo():r==="y"?t.redo():r==="a"?t.selectAll():r==="c"?t.copy():r==="x"?t.cutSelected():r==="v"?t.paste():r==="d"?t.duplicateSelected():r==="g"?e.shiftKey?t.ungroupSelected():t.groupSelected():r==="1"?t.resetZoom():r==="l"?t.alignSelected("left"):r==="r"?t.alignSelected("right"):r==="e"?t.alignSelected("vertical"):r==="t"?t.alignSelected("top"):r==="b"?t.alignSelected("bottom"):r==="0"&&this.fire("fit-window"))}}function Yn(o="print-designer"){return customElements.get(o)||customElements.define(o,Ne),o}function Bs(){return Yn()}exports.DesignerStore=kn;exports.PrintDesignerElement=Ne;exports.TILING_SINGLE_PAGE_TIP=No;exports.createDefaultTemplate=Rt;exports.definePrintDesigner=Yn;exports.registerAll=Bs;exports.serializePage=En;exports.toRuntimePool=Xo;
806
+ `},to=[zs,Fs,Ps,Ls,Is],Yn="worm-print-help-tab",Os="getting-started";function fn(t){return to.some(e=>e.id===t)?String(t):""}function Ns(t){let e=null;try{e=window.localStorage.getItem(Yn)}catch{e=null}return fn(e)||fn(t)||Os}function $s(t){const e=Ns(t.initialTab),o=(i,n)=>{const r=i.currentTarget,l=r.closest(".help-modal");if(!l)return;for(const c of Array.from(l.querySelectorAll(".help-tab")))c.classList.toggle("active",c===r);const s=l.querySelector(".help-content");s&&(s.innerHTML=to.find(c=>c.id===n)?.content??"");try{window.localStorage.setItem(Yn,n)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:i=>{i.target===i.currentTarget&&t.onClose()},onKeydown:i=>{i.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"},to.map(i=>a("button",{type:"button",class:`help-tab${i.id===e?" active":""}`,text:i.title,onClick:n=>o(n,i.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:to.find(i=>i.id===e)?.content??""})])])])])}function Bs(t,e){const o=be($s(e),t),i=n=>{n.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",i),o.focus?.(),()=>{document.removeEventListener("keydown",i),o.remove()}}const Hs=2,Ws=74,Yo=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function Us(t){const e=!!t.state.openMore,o=Yo.slice().sort((i,n)=>i.order-n.order).map(i=>a("div",{class:"tb-more-item",dataset:{unit:i.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:i.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${i.id}`,dataset:{unit:i.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{t.state.openMore=!e,t.repaint()},html:`${xe("Ellipsis",15)}<span class="tb-btn-text">更多</span>${xe("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 mn=new WeakMap;function gn(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const o=getComputedStyle(e),i=Number.parseFloat(o.gap)||Hs,n=Number.parseFloat(o.paddingLeft)||0,r=Number.parseFloat(o.paddingRight)||0,l=new Map;for(const x of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const T=x.parentElement;T&&!T.classList.contains("tb-more-slot")&&mn.set(x,{parent:T,next:x.nextSibling}),l.set(x.dataset.unit,x)}for(const x of l.values()){const T=mn.get(x);!T||x.parentElement===T.parent||(T.next?.parentElement===T.parent?T.parent.insertBefore(x,T.next):T.parent.appendChild(x))}let s=0;for(const x of Array.from(e.children)){if(x.classList.contains("tb-spacer")||x.classList.contains("tb-more-group"))continue;const T=Math.max(x.offsetWidth,x.scrollWidth);T<=0||(s+=T+i)}const c=new Map;for(const[x,T]of l){const E=T.offsetWidth;E>0&&c.set(x,E)}const u=Yo.map(x=>({id:x.id,order:x.order,width:c.get(x.id)??0})),h=u.reduce((x,T)=>x-T.width-i,s),m=e.clientWidth-n-r,{movedIds:g,overflowRemains:v}=p.resolveToolbarOverflow({available:m,pinned:h,moreTriggerWidth:Ws,gap:i,units:u});for(const x of Yo){const T=e.querySelector(`.tb-more-item[data-unit="${x.id}"]`),E=e.querySelector(`#tb-more-slot-${x.id}`),A=l.get(x.id);if(!T||!E||!A)continue;const L=g.includes(x.id);L&&A.parentElement!==E&&E.appendChild(A),T.style.display=L?"":"none"}const S=e.querySelector(".tb-more-group");return S&&(S.style.display=g.length>0?"":"none"),e.classList.toggle("is-tight",v),{movedIds:g,overflowRemains:v}}function Gs(t,e){const o=t.store,i=o.selectedIds.size>0,n=o.selectedIds.size>1,r=o.selectedElement,l=!i,s=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"},[ee(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!n}),ee(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!n}),ee(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!n}),ee(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!n}),ee(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!n}),ee(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!n}),ee(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!n}),ee(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!n})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[ee(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!i}),ee(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!i}),ee(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!i}),ee(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!i})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[ee(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!n}),ee(t,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],u=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[h("标尺",o.showRuler,"toggle-ruler","显示/隐藏标尺"),h("网格",o.showGrid,"toggle-grid","显示/隐藏网格背景"),h("虚框",o.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),h("吸附",o.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function h(m,g,v,S){return a("button",{type:"button",class:`tb-btn tb-menu-row${g?" on":""}`,dataset:{tip:S},onClick:()=>t.fire(v)},[a("span",{class:"dot"}),m])}return a("div",{class:"designer-toolbar"},[a("div",{class:"tb-group tb-brand"},[a("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),a("div",{class:"tb-title"},[a("span",{class:"tb-title-name",text:s}),a("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),a("div",{class:"tb-group"},[ee(t,"Undo2","undo",{tip:"撤销",disabled:!o.canUndo}),ee(t,"Redo2","redo",{tip:"重做",disabled:!o.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[no(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),no(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},u)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[ee(t,"Maximize","fit-window",{tip:"适应窗口"}),ee(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${o.scale}%`}),ee(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[ee(t,"Copy","copy",{tip:l?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:l,test:"copy"}),ee(t,"ClipboardPaste","paste",{tip:l?"粘贴 (Ctrl+V),需选中元素":o.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:l||!o.hasClipboard,test:"paste"}),ee(t,"Trash2","delete",{tip:l?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:l,danger:!0,test:"delete"})]),Us(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 Oo(t,e,o){for(const i of e){const n=t.getPropertyValue(i).trim();if(n)return n}return o}function qs(t,e){const o=e.orientation==="horizontal",i=e.geom,n=o?i.viewW:i.viewH;t.style.width=`${o?n:p.RULER_THICKNESS}px`,t.style.height=`${o?p.RULER_THICKNESS:n}px`;const r=t.getContext("2d");if(!r)return;const l=window.devicePixelRatio||1,s=Math.max(0,Math.round(n)),c=p.RULER_THICKNESS;t.width=(o?s:c)*l,t.height=(o?c:s)*l,r.setTransform(l,0,0,l,0,0);const u=getComputedStyle(t),h=Oo(u,["--pd-ruler-bg"],"#F8F9FC"),m=Oo(u,["--pd-ruler"],"#9AA1AF"),g=Oo(u,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=h,r.fillRect(0,0,o?s:c,o?c:s);const v=e.scale>0?e.scale:i.paperScale>0?i.paperScale:1,S=p.mmToPx(1)*v;if(S<=0)return;const x={ctx:r,horizontal:o,viewportPx:n,thickness:c,originPx:o?i.originX:i.originY,pxPerMM:S,paperLengthMM:e.paperLengthMM},T=-x.originPx/S,E=(s-x.originPx)/S,A=p.chooseMajorStepMM(v),L=p.buildRulerTicks(T,E,A);bn(x,L,m,!0),bn(x,L,m,!1),xn(x,0,g),xn(x,e.paperLengthMM,g);const F=e.cursorPx??null;if(F!==null&&F>=0&&F<=s){if(r.strokeStyle=g,r.lineWidth=1.5,r.beginPath(),o){const G=Math.round(F)+.5;r.moveTo(G,0),r.lineTo(G,c)}else{const G=Math.round(F)+.5;r.moveTo(0,G),r.lineTo(c,G)}r.stroke()}}function Vn(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function bn(t,e,o,i){const{ctx:n,horizontal:r,paperLengthMM:l}=t;n.strokeStyle=o,n.fillStyle=o,n.globalAlpha=i?.32:1,n.lineWidth=1,n.font="9px ui-monospace, Menlo, monospace",n.textBaseline="top";for(const s of e){if((s.mm<0||s.mm>l)!==i)continue;const u=Vn(t,s.mm),h=s.major?8:4;n.beginPath(),r?(n.moveTo(u,0),n.lineTo(u,h)):(n.moveTo(0,u),n.lineTo(h,u)),n.stroke(),s.major&&s.label&&(r?n.fillText(s.label,u+2,11):(n.save(),n.translate(11,u+2),n.rotate(-Math.PI/2),n.fillText(s.label,0,0),n.restore()))}n.globalAlpha=1}function xn(t,e,o){const{ctx:i,horizontal:n,thickness:r,viewportPx:l}=t,s=Vn(t,e);s<=0||s>=l||(i.strokeStyle=o,i.globalAlpha=.55,i.lineWidth=1,i.beginPath(),n?(i.moveTo(s,0),i.lineTo(s,r)):(i.moveTo(0,s),i.lineTo(r,s)),i.stroke(),i.globalAlpha=1)}const Ks=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{display:flex;gap:8px}.merge-card{margin-top:8px;padding:8px;border:1px solid var(--pd-border, #dcdfe6);border-radius:6px}.merge-card-title{font-size:12px;font-weight:600;color:var(--pd-text, #303133);margin-bottom:8px}.merge-card-divider{height:1px;background:var(--pd-menu-divider, #ebeef5);margin:8px 0}.merge-card-hint{margin-top:6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #8b909c)}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Jt=20,js=".page-tabs, .field-tree-panel, .pd-dialog-overlay",Ys=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),Vs={text:"formatter",longText:"formatter",flowList:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},vn="print-studio:left",yn="print-studio:right";function wn(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function Sn(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}class He 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;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Ks,this.root.appendChild(e),be(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,i){if(!i)return;if(e==="name"){this.repaint();return}let n;try{n=JSON.parse(i)}catch{return}e==="template"?this.applyTemplate(n):e==="fields"?(this.store.fields=n,this.repaint()):e==="fonts"&&Array.isArray(n)&&(this.fonts=n)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},o=this.getAttribute("template");if(o)try{e.initialTemplate=JSON.parse(o)}catch{}const i=this.getAttribute("fields");if(i)try{e.initialFields=JSON.parse(i)}catch{}this.store=new An(e),this.format=new yr(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=wn(vn),this.state.propCollapsed=wn(yn),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,Sn(vn,this.state.leftCollapsed),Sn(yn,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,He.active===this&&(He.active=null),Nn(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=D.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 i=e;return{...i,pages:i.pages.map(n=>({...n,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.getGeometryWarnings();o.length&&window.alert(`出纸提示(不影响保存):
807
+ ${o.join(`
808
+ `)}`);const i=this.templateJsonWithFonts();if(Array.isArray(i.pages))try{D.normalizeTemplate(i)}catch(r){window.alert(r instanceof Error?r.message:String(r));return}const n=JSON.stringify(i);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?D.validateTiling(e):[]}getGeometryWarnings(){return D.collectPrintWarnings(this.store.templateData)}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(i=>i.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(i=>i.remove());const o=this.exprTarget;be(Rs({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:i=>this.applyExpression(o,i)},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=Bs(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const o=this.unmountHelp;this.unmountHelp=null,o()}}applyExpression(e,o){const i=o.formatter??"",n=e.targetPath;if(n.startsWith("options.")){if(n.includes("[")){const l=this.store.elements.find(s=>s.id===e.elementId);l&&si(this.store,l,n,i);return}const r={[n.slice(8)]:i||void 0};o.title!==void 0&&(r.title=o.title),this.store.updateElement(e.elementId,r);return}if(n==="watermark.content"){const r={...this.store.templateData.watermark};Ko(i)?Object.assign(r,{mode:"binding",binding:i,content:""}):Object.assign(r,{mode:"fixed",content:i,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const o=this.store.elements.find(n=>n.id===e);if(!o||(this.store.selectOne(e),this.state.propTab="element",o.options.locked))return;const i=Vs[o.printElementType.type];i&&this.openExpression({elementId:o.id,targetPath:`options.${i}`,value:String(o.options[i]??"")})}dblEditCell(e){const o=this.store.elements.find(s=>s.id===e.elementId);if(!o||(this.store.selectOne(o.id),this.state.propTab="element",o.options.locked))return;const i=o.options.tableRows??[],n=p.findMainCell(i,e.r,e.c),l=i[n.r]?.cells[n.c];l&&this.openExpression({elementId:o.id,targetPath:`options.tableRows[${n.r}].cells[${n.c}].formatter`,value:l.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),kn(o);const i=this.ctx;be(Gs(i,Fl(i)),o),be(Bl(i),o),be(a("div",{class:"designer-body"},[Il(i),fl(i,this.canvasUi()),ys(i)]),o),be(Hl(i),o),gn(o),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>gn(o)),this.toolbarRo.observe(o));const n=Oa(this.store,(r,l)=>this.fire(r,l),this.tableMenu);n&&be(n,o),da(this.root,this.store.elements),Gn(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Vo.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const 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 i=e.getBoundingClientRect(),n=o.getBoundingClientRect(),r=(this.store.scale||100)/100,l=n.width/p.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(l-r)<.002?r:l,originX:n.left-i.left-Jt+this.scrollPos.x,originY:n.top-i.top-Jt+this.scrollPos.y,viewW:e.clientWidth-Jt,viewH:e.clientHeight-Jt},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,o=p.getPaperDimensions(e),i=this.geom.paperScale;for(const n of Array.from(this.root.querySelectorAll(".pd-ruler"))){const r=n.dataset.ruler==="vertical"?"vertical":"horizontal";qs(n,{orientation:r,geom:this.geom,scale:i,paperLengthMM:r==="horizontal"?o.width:o.height})}}patchElementDom(){for(const i of this.store.elements){const n=this.root.querySelector(`[data-el-id="${CSS.escape(i.id)}"]`);n&&(n.style.left=`${i.options.left}mm`,n.style.top=`${i.options.top}mm`,n.style.width=`${i.options.width}mm`,n.style.height=`${i.options.height}mm`)}const e=this.root.querySelector(".position-label"),o=this.store.selectedElement;e&&o&&!this.drag&&(e.textContent=$n(o.options))}fire(e,o){const i=this.store;switch(e){case"undo":i.undo();break;case"redo":i.redo();break;case"align":i.alignSelected(o);break;case"move-layer":i.moveLayer(o);break;case"group":i.groupSelected();break;case"ungroup":i.ungroupSelected();break;case"copy":i.copy();break;case"cut":i.cutSelected();break;case"paste":i.paste();break;case"paste-at":i.paste();break;case"delete":i.deleteSelected();break;case"delete-page":i.deletePage(i.activePageIndex);break;case"add-page":i.addPage();break;case"duplicate-page":i.duplicatePage(i.activePageIndex);break;case"move-page":i.movePage(i.activePageIndex,i.activePageIndex+o);break;case"select-all":i.selectAll();break;case"clear-selection":i.clearSelection();break;case"toggle-ruler":i.showRuler=!i.showRuler,this.repaint();break;case"toggle-grid":i.showGrid=!i.showGrid,this.repaint();break;case"toggle-snap":i.snapToGrid=!i.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":i.showTableGhostBorder=!i.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(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":i.removeGuide(o);break;case"resize-start":this.beginResize(o);break;case"element-mousedown":{const n=o;n.event.button===0&&this.isDoubleTap(`el:${n.id}`,n.event)&&this.fire("element-dblclick",{event:n.event,id:n.id}),this.beginDrag(n);break}case"table-cell-mousedown":{const n=o;this.isDoubleTap(`cell:${n.elementId}:${n.r}:${n.c}`,n.event)&&(this.taps.delete(`el:${n.elementId}`),this.fire("table-cell-dblclick",{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId}));break}case"zone-resize":this.beginZoneResize(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:n}=o;this.dblEditElement(n),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:n,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const n=o;this.dblEditCell(n),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(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,i=o?.getData("elementType"),n=o?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const l={x:r.left,y:r.top};if(i)this.store.addElement(i,{},l);else if(n){const s=this.store.fields.find(c=>c.fieldKey===n);s&&this.store.addFieldElement(s,{},l,e.ctrlKey||e.metaKey||e.labelIntent===!0)}}pointToPaperMm(e){const o=this.root.querySelector(".hiprint-printPaper");if(!o)return null;const i=o.getBoundingClientRect(),n=(this.store.scale||100)/100,r=p.pxToMm((e.clientX-i.left)/n),l=p.pxToMm((e.clientY-i.top)/n);return r<0||l<0?null:{left:r,top:l}}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(n=>o.classList.contains(n)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const o=this.pointToPaperMm(e),i=this.root.querySelector("[data-coord]");if(i){if(!o){i.style.display="none";return}i.style.display="",i.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 i=this.root.querySelector(".context-menu");if(!i)return;const n=i.getBoundingClientRect();this.menu.flipX=n.right>window.innerWidth?window.innerWidth-n.right-8:0,this.menu.flipY=n.bottom>window.innerHeight?window.innerHeight-n.bottom-8:0,this.paint()})}startMarquee(e){const o={x:e.clientX,y:e.clientY},i=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()},n=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const l=this.store.elements.filter(s=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(s.id)}"]`);if(!c)return!1;const u=c.getBoundingClientRect();return u.left<r.x+r.w&&u.right>r.x&&u.top<r.y+r.h&&u.bottom>r.y});this.store.select(new Set(l.map(s=>s.id)))}else this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}taps=new Map;isDoubleTap(e,o){const i=this.taps.get(e);return this.taps.set(e,{t:o.timeStamp,x:o.clientX,y:o.clientY}),!i||o.timeStamp-i.t>=500||Math.abs(o.clientX-i.x)>6||Math.abs(o.clientY-i.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const o=e.event;if(o.button!==0)return;const i=this.store;o.stopPropagation();const n=i.elements.find(s=>s.id===e.id);if(!n||(i.selectElement(n.id,o.ctrlKey||o.metaKey),n.options.locked))return;const r=o.altKey?[n.id]:i.dragIds(n.id),l=new Map;for(const s of r){const c=i.elements.find(u=>u.id===s);c&&l.set(s,{left:c.options.left,top:c.options.top})}this.drag={ids:r,primary:n.id,altKey:o.altKey,movedPositions:new Map,startX:o.clientX,startY:o.clientY,origin:l,zone:n.zone||"content",moved:!1},i.draggingIds=new Set(r),i.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const o of Array.from(this.root.querySelectorAll(".print-element"))){const i=e.has(o.dataset.elId??"");o.classList.toggle("drag-ghost",i);const n=o.querySelector(":scope > .drag-preview");i&&!n?be(a("div",{class:"drag-preview"}),o):!i&&n&&n.remove()}}finishAltClone(e){const o=this.store;o.adsorbGuides=[];const i=o.elements.find(l=>l.id===e.primary),n=e.movedPositions.get(e.primary);if(o.discardLive(),!i||!n)return;const r=JSON.parse(JSON.stringify(i));r.id=p.generateId(),r.options.left=n.left,r.options.top=n.top,r.options.groupId=void 0,o.cloneElement(r)}flashSnapIndicator(e,o){const i=this.root.querySelector(".hiprint-printPaper-content");i&&(i.querySelector(".snap-indicator")?.remove(),be(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${o}mm`}}),i),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{i.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const o=e.event;o.stopPropagation();const i=this.store.elements.find(n=>n.id===e.id);!i||i.options.locked||(this.resize={id:e.id,point:e.point,startX:o.clientX,startY:o.clientY,origin:{left:i.options.left,top:i.options.top,width:i.options.width,height:i.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const o=e.event.clientY,i=this.store.templateData,n=e.zone==="header"?i.header.height:i.footer.height,r=(this.store.scale||100)/100,l=c=>{const u=p.pxToMm((c.clientY-o)/r),h=Math.max(0,Math.round((n+(e.zone==="header"?u:-u))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...i.header,height:h}}):this.store.updateTemplateData({footer:{...i.footer,height:h}}),this.paint()},s=()=>{window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",s),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",l),window.addEventListener("mouseup",s)}beginGuideDrag(e){const o=(this.store.templateData.guides??[]).find(h=>h.id===e.id);if(!o)return;const i=p.getPaperDimensions(this.store.templateData),n=o.type==="vertical"?i.width:i.height,r=e.event.clientX,l=e.event.clientY,s=(this.store.scale||100)/100,c=h=>{const m=p.pxToMm((o.type==="vertical"?h.clientX-r:h.clientY-l)/s);this.store.moveGuide(o.id,Math.min(n,Math.max(0,o.position+m))),this.paint()},u=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",u),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",u)}beginRulerGuide(e){const o=e.orientation==="horizontal"?"vertical":"horizontal",i=r=>{this.guidePreview={type:o,position:o==="vertical"?r.clientX:r.clientY},this.paint()},n=r=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const l=this.rulerPointToMM(r,o);this.guidePreview=null,l!==null?this.store.addGuide(o,l):this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}rulerPointToMM(e,o){const i=this.root.querySelector(".hiprint-printPaper");if(!i)return null;const n=i.getBoundingClientRect(),r=p.mmToPx(1)*(this.geom.paperScale||1),l=o==="vertical"?(e.clientX-n.left)/r:(e.clientY-n.top)/r,s=p.getPaperDimensions(this.store.templateData),c=o==="vertical"?s.width:s.height;return l<0||l>c?null:l}applyZoom(e,o,i,n){const r=this.root.querySelector(".canvas-area");if(!r)return;const l=Math.round(this.store.scale),s=Math.max(n,Math.round(e));if(s===l)return;const c=getComputedStyle(r),u=parseFloat(c.paddingLeft)||0,h=parseFloat(c.paddingTop)||0,m=r.scrollLeft+o-u,g=r.scrollTop+i-h,v=s/l;this.store.setScale(s,n),r.scrollLeft=m*v-o+u,r.scrollTop=g*v-i+h}zoomByStep(e){const o=this.root.querySelector(".canvas-area");o&&this.applyZoom(p.nextWheelScale(this.store.scale,e),o.clientWidth/2,o.clientHeight/2,p.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const o=getComputedStyle(e),i=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0),n=(parseFloat(o.paddingTop)||0)+(parseFloat(o.paddingBottom)||0),r=p.getPaperDimensions(this.store.templateData),l=p.computeFitScale(e.clientWidth-i,e.clientHeight-n,p.mmToPx(r.width),p.mmToPx(r.height));this.applyZoom(l,e.clientWidth/2,e.clientHeight/2,p.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 i=Math.round(this.store.scale),n=p.nextWheelScale(i,e.deltaY>0?-1:1);if(n===i)return;const r=o.getBoundingClientRect();this.applyZoom(n,e.clientX-r.left,e.clientY-r.top,p.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const o=this.store;if(!o)return;const n=((o.scale||100)/100||1)*p.mmToPx(1),r=(l,s)=>({dx:l/n,dy:s/n});if(this.drag){const{dx:l,dy:s}=r(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(l)>.05||Math.abs(s)>.05)&&(this.drag.moved=!0);const c=o.elements.find(S=>S.id===this.drag.primary),u=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+l,top:(this.drag.origin.get(c.id)?.top??0)+s,width:c.options.width,height:c.options.height};let h=null;if(u&&o.snapToGrid!==!1){const S=o.elements.filter(E=>!this.drag.ids.includes(E.id)&&(E.zone||"content")===this.drag.zone).map(E=>({id:E.id,left:E.options.left,top:E.options.top,width:E.options.width,height:E.options.height})),x=Uo(o.templateData,o.paperSize)[this.drag.zone],T=p.computeAdsorb(u,S,this.manualGuides());h={left:T.left,top:T.top},o.adsorbGuides=(T.lines??[]).filter(E=>E.position>=0&&E.position<=(E.type==="vertical"?x.width:x.height)),(h.left!==u.left||h.top!==u.top)&&this.flashSnapIndicator(h.left+u.width/2,h.top+u.height/2)}else o.adsorbGuides=[];const m=c?this.drag.origin.get(c.id):void 0,g=h&&m?h.left-m.left:l,v=h&&m?h.top-m.top:s;for(const S of this.drag.ids){const x=this.drag.origin.get(S);if(!x)continue;const T={left:x.left+g,top:x.top+v};this.drag.movedPositions.set(S,T),o.livePatch(S,T)}this.patchElementDom(),o.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:l,dy:s}=r(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=p.calcResizeRect(this.resize.point,this.resize.origin,l,s,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(),i=o.some(r=>r.classList?.contains("tb-dd"));this.state.openDd&&!i&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!i&&(this.state.openMore=!1,this.repaint());const n=o.some(r=>r.classList?.contains("context-menu"));this.menu.visible&&!n&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const i=e.target?.closest?.("[data-tip]");!i||!i.closest(js)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(i),300))}),this.root.addEventListener("mouseout",e=>{const o=e,i=o.target?.closest?.("[data-tip]");i&&o.relatedTarget?.closest?.("[data-tip]")!==i&&this.hideHoverTip()})}showHoverTip(e){const o=e.dataset.tip;if(!o)return;this.hideHoverTip();const i=e.getBoundingClientRect(),n=i.left+i.width/2;this.hoverTipEl=be(a("div",{class:"pd-hover-tip",style:{left:`${n}px`,top:`${i.bottom+6}px`},text:o}),this.root);const r=this.hoverTipEl.offsetWidth/2;if(!r)return;const l=r+8,s=Math.max(window.innerWidth-r-8,l);this.hoverTipEl.style.left=`${Math.min(Math.max(n,l),s)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const e=[],o=[];for(const i of this.store.templateData.guides??[])i.type==="vertical"?e.push(i.position):o.push(i.position);return{vertical:e,horizontal:o}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const i of Array.from(e.querySelectorAll(".adsorb-guide")))i.remove();const o=this.store.paperSize;Uo(this.store.templateData,o);for(const i of this.store.adsorbGuides){const n=document.createElement("div");n.className=`adsorb-guide guide-${i.type}`,i.type==="vertical"?n.style.cssText=`left:${i.position}mm;top:0;height:${o.height}mm;border-left-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`:n.style.cssText=`top:${i.position}mm;left:0;width:${o.width}mm;border-top-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(n)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{He.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),He.active||(He.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>Bn(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(e){const o=this.store;if(!o||He.active!==this)return;const n=e.composedPath()[0]?.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const l=e.shiftKey?10:e.ctrlKey?.5:1,s=e.key==="ArrowLeft"?-l:e.key==="ArrowRight"?l:0,c=e.key==="ArrowUp"?-l:e.key==="ArrowDown"?l:0;o.moveSelected(s,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();Ys.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 Xn(t="print-designer"){return customElements.get(t)||customElements.define(t,He),t}function Xs(){return Xn()}exports.DesignerStore=An;exports.PrintDesignerElement=He;exports.TILING_SINGLE_PAGE_TIP=No;exports.createDefaultTemplate=Ft;exports.definePrintDesigner=Xn;exports.registerAll=Xs;exports.serializePage=Cn;exports.toRuntimePool=Xo;