@worm-vue3-print/common 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/browser-bundle.d.ts +1 -1
- package/dist/common.css +1 -1
- package/dist/common.js +67 -48
- package/dist/core/default-template.d.ts +1 -1
- package/dist/core/format.d.ts +1 -1
- package/dist/core/h.d.ts +1 -1
- package/dist/core/icons.d.ts +1 -1
- package/dist/core/store.d.ts +2 -2
- package/dist/index.cjs +28 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1439 -1376
- package/dist/print-designer.d.ts +1 -1
- package/dist/shell/binding.d.ts +1 -1
- package/dist/shell/canvas.d.ts +1 -1
- package/dist/shell/code.d.ts +1 -1
- package/dist/shell/color-picker.d.ts +1 -1
- package/dist/shell/controls.d.ts +3 -1
- package/dist/shell/crop-anchor.d.ts +1 -1
- package/dist/shell/elements.d.ts +1 -1
- package/dist/shell/expression-editor.d.ts +1 -1
- package/dist/shell/flow-list.d.ts +1 -1
- package/dist/shell/font-select.d.ts +1 -1
- package/dist/shell/format-bar.d.ts +1 -1
- package/dist/shell/help-content/changelog.d.ts +1 -1
- package/dist/shell/help-content/faq.d.ts +1 -1
- package/dist/shell/help-content/features.d.ts +1 -1
- package/dist/shell/help-content/getting-started.d.ts +1 -1
- package/dist/shell/help-content/index.d.ts +1 -1
- package/dist/shell/help-content/shortcuts.d.ts +1 -1
- package/dist/shell/help-modal.d.ts +1 -1
- package/dist/shell/page-extras.d.ts +1 -1
- package/dist/shell/panels.d.ts +1 -1
- package/dist/shell/prop-group.d.ts +1 -1
- package/dist/shell/property-panel.d.ts +1 -1
- package/dist/shell/property-search.d.ts +1 -1
- package/dist/shell/ruler.d.ts +1 -1
- package/dist/shell/table-props.d.ts +1 -1
- package/dist/shell/table.d.ts +1 -1
- package/dist/shell/toolbar-overflow.d.ts +1 -1
- package/dist/shell/toolbar.d.ts +1 -1
- package/dist/shell/watermark.d.ts +1 -1
- 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"),A=require("@worm-vue3-print/core"),Vo=require("@worm-vue3-print/core/browser"),wn=require("jsbarcode");function a(o,e={},t=[]){return{tag:o,props:e,children:t}}const Sn="http://www.w3.org/2000/svg",pr=new Set(["draggable","contenteditable","spellcheck"]),ur=new Set(["indeterminate"]);function hr(o){return o==="svg"||o==="path"||o==="circle"||o==="rect"||o==="line"||o==="g"}function fe(o,e){if(typeof o=="string"){const s=document.createTextNode(o);return e.appendChild(s),s}if(o instanceof Node)return e.appendChild(o),o;const{tag:t,props:i,children:n}=o,r=hr(t)?document.createElementNS(Sn,t):document.createElement(t);for(const[s,l]of Object.entries(i))if(!(l==null||l===!1))if(s==="class")r.setAttribute("class",String(l));else if(s==="style")typeof l=="string"?r.style.cssText=l:Object.assign(r.style,l);else if(s==="html")r.innerHTML=String(l);else if(s==="text")r.textContent=String(l);else if(s.startsWith("on")&&typeof l=="function")r.addEventListener(s.slice(2).toLowerCase(),l);else if(s==="dataset")for(const[c,u]of Object.entries(l))r.dataset[c]=u;else ur.has(s)?r[s]=!0:typeof l=="boolean"?l&&r.setAttribute(s,pr.has(s)?"true":""):r.setAttribute(s,String(l));for(const s of n)fe(s,r);return e.appendChild(r),r}function Tn(o){for(;o.firstChild;)o.removeChild(o.firstChild)}const fr=Sn;function Rt(){return{paperSize:"A4",orientation:"portrait",unit:"mm",margins:{top:10,right:10,bottom:10,left:10},header:{height:10,elements:[]},footer:{height:10,elements:[]},elements:[],watermark:{}}}const No="开启拼版后只能有一个设计页面";function Xo(o){const e=(t,i)=>(t??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&p.syncTableElementSize(r),{id:n.id||p.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...o,margins:{...o.margins},header:{height:o.header?.height??10,elements:[]},footer:{height:o.footer?.height??10,elements:[]},guides:[...o.guides??[]],elements:[...e(o.elements??[],"content"),...e(o.header?.elements??[],"header"),...e(o.footer?.elements??[],"footer")]}}function En(o){const e=o.elements,t=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...o,header:{...o.header,elements:t("header")},footer:{...o.footer,elements:t("footer")},elements:t("content"),guides:[...o.guides??[]]}}function Ri(o){const e=(i,n)=>{const r=Xo(p.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!o)return[e(Rt(),0)];const t=Array.isArray(o.pages)?o.pages:[o];return t.length?t.map(e):[e(Rt(),0)]}const pt=o=>JSON.parse(JSON.stringify(o));class kn{scale=100;showRuler=!0;showGrid=!0;snapToGrid=!1;showTableGhostBorder=!0;dirty=!1;pages;activePageIndex=0;fields;selectedIds=new Set;previewIds=new Set;tableSelection=null;draggingIds=new Set;adsorbGuides=[];live=new Map;clipboard=[];moveSessionActive=!1;moveTimer=null;dragBefore=null;undoStack=[];redoStack=[];listeners=new Set;align=p.useAlign();group=p.useGroup();constructor(e={}){if(this.pages=Ri(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const t=this.pages[0];t.elements=[...t.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const t of[...this.listeners])t()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const e=this.pages[this.activePageIndex]??Rt();this.pages.push(Xo({...Rt(),paperSize:e.paperSize,orientation:e.orientation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let t=this.pages.length+1;for(;e.has(`页面 ${t}`);)t++;return`页面 ${t}`}duplicatePage(e){if(this.tilingEnabled){window.alert(No);return}this.recordHistory();const t=pt(this.pages[e]);t.name=`${t.name??`页面 ${e+1}`} 副本`,t.elements=t.elements.map(i=>({...i,id:p.generateId()})),this.pages.splice(e+1,0,t),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,t){this.recordHistory(),this.pages[e].name=t,this.emit()}movePage(e,t){if(t<0||t>=this.pages.length||e===t)return;this.recordHistory();const[i]=this.pages.splice(e,1);this.pages.splice(t,0,i),this.activePageIndex=t,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,t=!1){if(t){const i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,t=!1){if(t){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(t=>t.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=[...i,{id:p.generateId(),type:e,position:Math.round(t*10)/10}],this.emit()}moveGuide(e,t){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(t*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(t=>t.id!==e),this.emit()}addElement(e,t={},i){const n=p.createRuntimeElement(e,t);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,t={},i){const n=p.createFieldElement(e);return Object.assign(n.options,t),i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}placeAtDropPoint(e,t){const i=this.templateData,n=p.zoneFromPaperPoint(i,t.x,t.y);if(n!=="content"&&!p.ZONE_ALLOWED_TYPES.includes(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=p.getZoneRects(i)[n];return e.zone=n,e.options.left=t.x-r.left,e.options.top=t.y-r.top,n!=="content"&&p.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,t){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...t}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[t,i]of this.live){const n=e.find(r=>r.id===t);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const t=this.templateData.elements.find(i=>i.id===e);return!t||t.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let t=!1;for(const i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||p.finalizeElementZone(i,this.templateData).rejected&&(t=!0)}t&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,t,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,t),n.printElementType.type==="table"&&p.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e),this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const t=this.templateData.elements,i=t.filter(r=>this.selectedIds.has(r.id)),n=t.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=t.findIndex(c=>this.selectedIds.has(c.id)),s=e==="up"?r+1:r-1;if(s<0||s>=t.length)return;const l=[...t];[l[r],l[s]]=[l[s],l[r]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(t=>this.selectedIds.has(t.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=pt(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const t=new Map;for(const r of this.clipboard){const s=r.options.groupId;s&&t.set(s,(t.get(s)??0)+1)}const i=new Map;for(const[r,s]of t)i.set(r,s>=2?p.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const s=pt(r);s.id=p.generateId(),s.options.left+=e,s.options.top+=e,s.options.groupId=s.options.groupId?i.get(s.options.groupId):void 0,n.push(s)}this.emit()}duplicateSelected(){if(this.copy(),!this.clipboard.length)return;this.paste(15);const e=this.templateData.elements;this.selectOne(e[e.length-this.clipboard.length].id)}get hasClipboard(){return this.clipboard.length>0}moveSelected(e,t){const i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=t;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack=[]}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}undo(){const e=this.undoStack.pop();e&&(this.redoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}redo(){const e=this.redoStack.pop();e&&(this.undoStack.push({pages:pt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,t=p.MIN_SCALE_PERCENT){this.scale=Math.max(t,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(En),t=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(t)}loadTemplate(e){this.pages=Ri(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return p.getPaperDimensions(this.templateData)}}const Qe=Symbol("mixed"),Eo=new Set(["text","longText"]),mr=["top","right","bottom","left"],gr={on:!0,off:!1,mixed:Qe};function zi(o){const e=p.resolveBorderEdgeStates(o),t={};for(const i of mr)t[i]=gr[e[i]];return t}const br=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class xr{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(t=>t.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return[];const i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=t[n]?.cells[r];s&&!s.merged&&i.push(s)}return i}get textTargets(){return this.selectedElements.filter(e=>Eo.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const t=e[0];return e.every(i=>i===t)?t:Qe}hasToken(e,t){return(e??"").split(/\s+/).includes(t)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const t=e.map(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:t.every(Boolean)?!0:t.some(Boolean)?Qe:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?Qe:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?Qe:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const t=this.targetCells;t.length&&(t.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const t=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),s="backgroundColor"in e;!(t.length&&r)&&!(i.length&&s)||(t.forEach(l=>{const c=l.options;"fontFamily"in e&&(c.fontFamily=e.fontFamily),"fontSize"in e&&(c.fontSize=e.fontSize),"color"in e&&(c.color=e.color),"textAlign"in e&&(c.textAlign=e.textAlign),"verticalAlign"in e&&(c.verticalAlign=e.verticalAlign)}),s&&i.forEach(l=>{l.options.backgroundColor=e.backgroundColor}),this.commit())}toggleBold(){if(this.context==="cells"){const i=this.values.bold!==!0;this.writeCells(n=>{n.fontWeight=i?"bold":void 0});return}const e=this.values.bold!==!0,t=this.textTargets;t.length&&(t.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const t=this.textTargets;if(!t.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;t.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),s=r.indexOf(e);i&&s<0&&r.push(e),!i&&s>=0&&r.splice(s,1),n.options.textDecoration=r.length?r.join(" "):void 0}),this.commit()}toggleUnderline(){this.toggleDecoration("underline")}toggleStrike(){this.toggleDecoration("line-through")}syncBorderDraft(){if(this.context!=="cells"){this.borderDraftKey&&(this.borderDraftKey="",this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1});return}const e=this.store.tableSelection,t=this.tableElement?.options.tableRows;if(!e||!t)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,p.resolveCellGroupMode(t,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=p.resolveCellBorderDisplay(t,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const t=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=t,t===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,t){const i=this.selectedElements;i.length&&(i.forEach(n=>{p.applyElementBorderPreset(n.options,e,t)}),this.commit())}applyCellBorderPreset(e,t){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(p.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,t),this.commit())}applyCellBorderEdges(e,t,i){this.writeCells(n=>{for(const r of e)p.setCellBorderEdge(n,r,i?t:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?zi(e.map(t=>t.borders)):null}toggleCellEdge(e,t){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],t,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?zi(e.map(t=>p.elementVisibleBorders(t.options))):null}toggleElementEdge(e,t){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>p.setElementBorderEdgeVisible(r.options,e,n,t)),this.commit()}applyBorderPreset(e){const t=this.borderStyle===null;if(this.context==="cells"){const i=t&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(t||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const t=this.selectedElements;t.length&&(t.forEach(i=>p.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const t={};for(const i of p.ELEMENT_BORDER_SIDES){const n=e[i];n&&(t[i]={...n})}return t}pickPainterSource(e=!1){const t=this.selectedElements[0];if(!t)return!1;const i=t.options,n=t.printElementType.type;return this.painterSnapshot={text:Eo.has(n)?Object.fromEntries(br.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:p.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=t.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const t=this.painterSnapshot;if(!t||e.options.locked||e.id===this.painterSource)return!1;const i=e.options,n=e.printElementType.type;return t.text&&Eo.has(n)&&Object.assign(i,t.text),i.backgroundColor=t.backgroundColor,t.border&&p.acceptsElementBorder(n)&&(i.borderWidth=t.border.borderWidth,i.borderStyle=t.border.borderStyle,i.borderColor=t.border.borderColor,i.borders=this.clonePainterBorders(t.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let t=!1;e.forEach(i=>{t=this.applyPainter(i)||t}),t&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const t=e.target?.tagName;t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||this.cancelPainter()}}function Pi(o,e){(e==null||e>o.length)&&(e=o.length);for(var t=0,i=Array(e);t<e;t++)i[t]=o[t];return i}function vr(o){if(Array.isArray(o))return o}function yr(o,e){var t=o==null?null:typeof Symbol<"u"&&o[Symbol.iterator]||o["@@iterator"];if(t!=null){var i,n,r,s,l=[],c=!0,u=!1;try{if(r=(t=t.call(o)).next,e!==0)for(;!(c=(i=r.call(t)).done)&&(l.push(i.value),l.length!==e);c=!0);}catch(h){u=!0,n=h}finally{try{if(!c&&t.return!=null&&(s=t.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}function wr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Sr(o,e){return vr(o)||yr(o,e)||Tr(o,e)||wr()}function Tr(o,e){if(o){if(typeof o=="string")return Pi(o,e);var t={}.toString.call(o).slice(8,-1);return t==="Object"&&o.constructor&&(t=o.constructor.name),t==="Map"||t==="Set"?Array.from(o):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Pi(o,e):void 0}}const Cn=Object.entries,Fi=Object.setPrototypeOf,Er=Object.isFrozen,kr=Object.getPrototypeOf,Cr=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,ft=Object.create,An=typeof Reflect<"u"&&Reflect,$o=An.apply,Bo=An.construct;re||(re=function(e){return e});se||(se=function(e){return e});$o||($o=function(e,t){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(t,n)});Bo||(Bo=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return new e(...i)});const Xe=ie(Array.prototype.forEach),Ar=ie(Array.prototype.lastIndexOf),Li=ie(Array.prototype.pop),Tt=ie(Array.prototype.push),Dr=ie(Array.prototype.splice),gt=Array.isArray,Mt=ie(String.prototype.toLowerCase),ko=ie(String.prototype.toString),Ii=ie(String.prototype.match),Et=ie(String.prototype.replace),Oi=ie(String.prototype.indexOf),Mr=ie(String.prototype.trim),_r=ie(Number.prototype.toString),Rr=ie(Boolean.prototype.toString),Ni=typeof BigInt>"u"?null:ie(BigInt.prototype.toString),$i=typeof Symbol>"u"?null:ie(Symbol.prototype.toString),be=ie(Object.prototype.hasOwnProperty),kt=ie(Object.prototype.toString),le=ie(RegExp.prototype.test),Ye=zr(TypeError);function ie(o){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return $o(o,e,i)}}function zr(o){return function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return Bo(o,t)}}function $(o,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Mt;if(Fi&&Fi(o,null),!gt(e))return o;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=t(n);r!==n&&(Er(e)||(e[i]=r),n=r)}o[n]=!0}return o}function Pr(o){for(let e=0;e<o.length;e++)be(o,e)||(o[e]=null);return o}function ke(o){const e=ft(null);for(const i of Cn(o)){var t=Sr(i,2);const n=t[0],r=t[1];be(o,n)&&(gt(r)?e[n]=Pr(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=ke(r):e[n]=r)}return e}function Fr(o){switch(typeof o){case"string":return o;case"number":return _r(o);case"boolean":return Rr(o);case"bigint":return Ni?Ni(o):"0";case"symbol":return $i?$i(o):"Symbol()";case"undefined":return kt(o);case"function":case"object":{if(o===null)return kt(o);const e=o,t=_e(e,"toString");if(typeof t=="function"){const i=t(e);return typeof i=="string"?i:kt(i)}return kt(o)}default:return kt(o)}}function _e(o,e){for(;o!==null;){const i=Cr(o,e);if(i){if(i.get)return ie(i.get);if(typeof i.value=="function")return ie(i.value)}o=kr(o)}function t(){return null}return t}function Lr(o){try{return le(o,""),!0}catch{return!1}}const Bi=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Co=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ao=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ir=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Do=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Or=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Hi=re(["#text"]),Wi=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Mo=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ui=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Xt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Nr=se(/{{[\w\W]*|^[\w\W]*}}/g),$r=se(/<%[\w\W]*|^[\w\W]*%>/g),Br=se(/\${[\w\W]*/g),Hr=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Wr=se(/^aria-[\-\w]+$/),Gi=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ur=se(/^(?:\w+script|data):/i),Gr=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qr=se(/^html$/i),Kr=se(/^[a-z][.\w]*(-[.\w]+)+$/i),qi=se(/<[/\w!]/g),Ki=se(/<[/\w]/g),jr=se(/<\/no(script|embed|frames)/i),Yr=se(/\/>/i),Ee={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Dn=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"],Vr=re($({},Dn)),Xr=(function(){const o={};return Xe(Dn,e=>{o[e]=se(new RegExp("</"+e+"(?=[\\t\\n\\f\\r />])","i"))}),re(o)})(),Zr=function(){return typeof window>"u"?null:window},Qr=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(i=t.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},ji=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Be=function(e,t,i,n){return be(e,t)&>(e[t])?$(n.base?ke(n.base):{},e[t],n.transform):i},_o=function(e,t,i){const n=be(e,t)?e[t]:void 0;return n&&typeof n=="object"?ke(n):i()};function Mn(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zr();const e=E=>Mn(E);if(e.version="3.4.14",e.removed=[],!o||!o.document||o.document.nodeType!==Ee.document||!o.Element)return e.isSupported=!1,e;let t=o.document;const i=t,n=i.currentScript;o.DocumentFragment;const r=o.HTMLTemplateElement,s=o.Node,l=o.Element,c=o.NodeFilter,u=o.NamedNodeMap;u===void 0&&(o.NamedNodeMap||o.MozNamedAttrMap),o.HTMLFormElement;const h=o.DOMParser,m=o.trustedTypes,g=l.prototype,v=_e(g,"cloneNode"),b=_e(g,"remove"),w=_e(g,"nextSibling"),T=_e(g,"childNodes"),k=_e(g,"parentNode"),z=_e(g,"shadowRoot"),W=_e(g,"attributes"),P=s&&s.prototype?_e(s.prototype,"nodeType"):null,ne=s&&s.prototype?_e(s.prototype,"nodeName"):null,ye=s&&s.prototype?_e(s.prototype,"ownerDocument"):null,Y=function(d){return P?P(d):d.nodeType},F=function(d){return ne?ne(d):d.nodeName};if(typeof r=="function"){const E=t.createElement("template");E.content&&E.content.ownerDocument&&(t=E.content.ownerDocument)}let M,G="",V,ce=!1,Z=0;const y=function(){if(Z>0)throw Ye('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},H=function(d){y(),Z++;try{return M.createHTML(d)}finally{Z--}},ae=function(d){y(),Z++;try{return M.createScriptURL(d)}finally{Z--}},Fe=function(){return ce||(V=Qr(m,n),ce=!0),V},L=t,ee=L.implementation,Ge=L.createNodeIterator,pe=L.createDocumentFragment,qe=L.getElementsByTagName,ot=i.importNode;let U=ji();e.isSupported=typeof Cn=="function"&&typeof k=="function"&&ee&&ee.createHTMLDocument!==void 0;const co=Nr,Ft=$r,Lt=Br,po=Hr,Ke=Wr,we=Ur,Se=Gr,uo=Kr;let It=Gi,q=null;const xt=$({},[...Bi,...Co,...Ao,...Do,...Hi]);let K=null;const it=$({},[...Wi,...Mo,...Ui,...Xt]);let ue=Object.seal(ft(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ot=null;const N=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let vt=!0,nt=!0,x=!1,O=!0,Q=!1,te=!0,De=!1,yt=!1,Nt=null,$t=null,ho=!1,rt=!1,Bt=!1,Ht=!1,li=!0,di=!1;const ci="user-content-";let fo=!0,mo=!1,at={},st=null;const pi=$({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let ui=null;const hi=$({},["audio","video","img","source","image","track"]);let fi=null;const mi=$({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Wt="http://www.w3.org/1998/Math/MathML",Ut="http://www.w3.org/2000/svg",Re="http://www.w3.org/1999/xhtml";let lt=Re,go=!1,bo=null;const Vn=$({},[Wt,Ut,Re],ko),gi=re(["mi","mo","mn","ms","mtext"]);let xo=$({},gi);const bi=re(["annotation-xml"]);let vo=$({},bi);const Xn=$({},["title","style","font","a","script"]);let wt=null;const Zn=["application/xhtml+xml","text/html"],Qn="text/html";let oe=null,dt=null;const Jn=t.createElement("form"),xi=function(d){return d instanceof RegExp||d instanceof Function},yo=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(dt&&dt===d)return;(!d||typeof d!="object")&&(d={}),d=ke(d),wt=Zn.indexOf(d.PARSER_MEDIA_TYPE)===-1?Qn:d.PARSER_MEDIA_TYPE,oe=wt==="application/xhtml+xml"?ko:Mt,q=Be(d,"ALLOWED_TAGS",xt,{transform:oe}),K=Be(d,"ALLOWED_ATTR",it,{transform:oe}),bo=Be(d,"ALLOWED_NAMESPACES",Vn,{transform:ko}),fi=Be(d,"ADD_URI_SAFE_ATTR",mi,{transform:oe,base:mi}),ui=Be(d,"ADD_DATA_URI_TAGS",hi,{transform:oe,base:hi}),st=Be(d,"FORBID_CONTENTS",pi,{transform:oe}),Te=Be(d,"FORBID_TAGS",ke({}),{transform:oe}),Ot=Be(d,"FORBID_ATTR",ke({}),{transform:oe}),at=be(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?ke(d.USE_PROFILES):d.USE_PROFILES:!1,vt=d.ALLOW_ARIA_ATTR!==!1,nt=d.ALLOW_DATA_ATTR!==!1,x=d.ALLOW_UNKNOWN_PROTOCOLS||!1,O=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=d.SAFE_FOR_TEMPLATES||!1,te=d.SAFE_FOR_XML!==!1,De=d.WHOLE_DOCUMENT||!1,rt=d.RETURN_DOM||!1,Bt=d.RETURN_DOM_FRAGMENT||!1,Ht=d.RETURN_TRUSTED_TYPE||!1,ho=d.FORCE_BODY||!1,li=d.SANITIZE_DOM!==!1,di=d.SANITIZE_NAMED_PROPS||!1,fo=d.KEEP_CONTENT!==!1,mo=d.IN_PLACE||!1,It=Lr(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Gi,lt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Re,xo=_o(d,"MATHML_TEXT_INTEGRATION_POINTS",()=>$({},gi)),vo=_o(d,"HTML_INTEGRATION_POINTS",()=>$({},bi));const f=_o(d,"CUSTOM_ELEMENT_HANDLING",()=>ft(null));if(ue=ft(null),be(f,"tagNameCheck")&&xi(f.tagNameCheck)&&(ue.tagNameCheck=f.tagNameCheck),be(f,"attributeNameCheck")&&xi(f.attributeNameCheck)&&(ue.attributeNameCheck=f.attributeNameCheck),be(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),se(ue),Q&&(nt=!1),Bt&&(rt=!0),at&&(q=$({},Hi),K=ft(null),at.html===!0&&($(q,Bi),$(K,Wi)),at.svg===!0&&($(q,Co),$(K,Mo),$(K,Xt)),at.svgFilters===!0&&($(q,Ao),$(K,Mo),$(K,Xt)),at.mathMl===!0&&($(q,Do),$(K,Ui),$(K,Xt))),N.tagCheck=null,N.attributeCheck=null,be(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?N.tagCheck=d.ADD_TAGS:gt(d.ADD_TAGS)&&(q===xt&&(q=ke(q)),$(q,d.ADD_TAGS,oe))),be(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?N.attributeCheck=d.ADD_ATTR:gt(d.ADD_ATTR)&&(K===it&&(K=ke(K)),$(K,d.ADD_ATTR,oe))),be(d,"ADD_FORBID_CONTENTS")&>(d.ADD_FORBID_CONTENTS)&&(st===pi&&(st=ke(st)),$(st,d.ADD_FORBID_CONTENTS,oe)),fo&&(q["#text"]=!0),De&&$(q,["html","head","body"]),q.table&&($(q,["tbody"]),delete Te.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ye('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const S=M;M=d.TRUSTED_TYPES_POLICY;try{G=H("")}catch(C){throw M=S,C}}else d.TRUSTED_TYPES_POLICY===null?(M=void 0,G=""):(M===void 0&&(M=Fe()),M&&typeof G=="string"&&(G=H("")));re&&re(d),dt=d},vi=$({},[...Co,...Ao,...Ir]),yi=$({},[...Do,...Or]),er=function(d,f,S){return f.namespaceURI===Re?d==="svg":f.namespaceURI===Wt?d==="svg"&&(S==="annotation-xml"||xo[S]):!!vi[d]},tr=function(d,f,S){return f.namespaceURI===Re?d==="math":f.namespaceURI===Ut?d==="math"&&vo[S]:!!yi[d]},or=function(d,f,S){return f.namespaceURI===Ut&&!vo[S]||f.namespaceURI===Wt&&!xo[S]?!1:!yi[d]&&(Xn[d]||!vi[d])},ir=function(d){let f=k(d);(!f||!f.tagName)&&(f={namespaceURI:lt,tagName:"template"});const S=Mt(d.tagName),C=Mt(f.tagName);return bo[d.namespaceURI]?d.namespaceURI===Ut?er(S,f,C):d.namespaceURI===Wt?tr(S,f,C):d.namespaceURI===Re?or(S,f,C):!!(wt==="application/xhtml+xml"&&bo[d.namespaceURI]):!1},$e=function(d){Tt(e.removed,{element:d});try{k(d).removeChild(d)}catch{if(b(d),!k(d))throw Ye("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},wi=function(d,f,S){try{d.removeAttributeNode(f)}catch{try{d.removeAttribute(S)}catch{}}},Gt=function(d){qt(d);const f=T(d);if(f){const C=[];Xe(f,D=>{Tt(C,D)}),Xe(C,D=>{try{b(D)}catch{}})}const S=W(d);if(S)for(let C=S.length-1;C>=0;--C){const D=S[C],R=D&&D.name;typeof R=="string"&&wi(d,D,R)}},je=function(d,f,S){if(!S)try{S=f.getAttributeNode(d)}catch{S=null}Tt(e.removed,{attribute:S||null,from:f});try{S?f.removeAttributeNode(S):f.removeAttribute(d)}catch{try{f.removeAttribute(d)}catch{}}if(d==="is")if(rt||Bt)try{$e(f)}catch{}else try{f.setAttribute(d,"")}catch{}},nr=function(d){const f=W(d);if(f)for(let S=f.length-1;S>=0;--S){const C=f[S],D=C&&C.name;typeof D!="string"||K[oe(D)]||wi(d,C,D)}},qt=function(d){const f=[d];for(;f.length>0;){const S=f.pop();Y(S)===Ee.element&&nr(S);const D=T(S);if(D)for(let R=D.length-1;R>=0;--R)f.push(D[R])}},Si=function(d,f){return te?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},rr=function(d){if(!te)return;const f=[d];for(;f.length>0;){const S=f.pop(),C=Y(S);if(C===Ee.processingInstruction||C===Ee.comment&&le(Ki,S.data)){try{b(S)}catch{}continue}if(C===Ee.element){const R=S,j=oe(F(S));try{R.hasAttribute&&R.hasAttribute("patchsrc")&&R.removeAttribute("patchsrc"),R.hasAttribute&&R.hasAttribute("for")&&Si("for",j)&&R.removeAttribute("for")}catch{}}const D=T(S);if(D)for(let R=D.length-1;R>=0;--R)f.push(D[R])}},Ti=function(d){let f=null,S=null;if(ho)d="<remove></remove>"+d;else{const R=Ii(d,/^[\r\n\t ]+/);S=R&&R[0]}wt==="application/xhtml+xml"&<===Re&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const C=M?H(d):d;if(lt===Re)try{f=new h().parseFromString(C,wt)}catch{}if(!f||!f.documentElement){f=ee.createDocument(lt,"template",null);try{f.documentElement.innerHTML=go?G:C}catch{}}const D=f.body||f.documentElement;return d&&S&&D.insertBefore(t.createTextNode(S),D.childNodes[0]||null),lt===Re?qe.call(f,De?"html":"body")[0]:De?f.documentElement:D},Ei=function(d){const f=ye?ye(d):d.ownerDocument;return Ge.call(f||d,d,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(d){return d=Et(d,co," "),d=Et(d,Ft," "),d=Et(d,Lt," "),d},wo=function(d){var f;d.normalize();const S=ye?ye(d):d.ownerDocument,C=Ge.call(S||d,d,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let D=C.nextNode();for(;D;)D.data=Kt(D.data),D=C.nextNode();const R=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");R&&Xe(R,j=>{ct(j.content)&&wo(j.content)})},jt=function(d){const f=ne?ne(d):null;return typeof f!="string"||oe(f)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==W(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==P(d)||d.childNodes!==T(d)},ct=function(d){if(!P||typeof d!="object"||d===null)return!1;try{return P(d)===Ee.documentFragment}catch{return!1}},St=function(d){if(!P||typeof d!="object"||d===null)return!1;try{return typeof P(d)=="number"}catch{return!1}};function ze(E,d,f){E.length!==0&&Xe(E,S=>{S.call(e,d,f,dt)})}const ar=function(d,f){return!!(te&&d.hasChildNodes()&&!St(d.firstElementChild)&&le(qi,d.textContent)&&le(qi,d.innerHTML)||te&&d.namespaceURI===Re&&Vr[f]&&(St(d.firstElementChild)||typeof d.textContent=="string"&&le(Xr[f],d.textContent))||d.nodeType===Ee.processingInstruction||te&&d.nodeType===Ee.comment&&le(Ki,d.data))},Yt=function(d,f){if(d instanceof RegExp)return le(d,f);if(d instanceof Function){for(var S=arguments.length,C=new Array(S>2?S-2:0),D=2;D<S;D++)C[D-2]=arguments[D];return!!d(f,...C)}return!1},sr=function(d,f,S){if(!Te[f]&&Mi(f)&&Yt(ue.tagNameCheck,f))return!1;if(fo&&!st[f]){const C=k(d),D=T(d);if(D&&C){const R=D.length;for(let j=R-1;j>=0;--j){const X=d===S?v(D[j],!0):D[j];C.insertBefore(X,w(d))}}}return $e(d),!0},ki=function(d,f,S,C){return d.length===0?f:f===S||f===C?ke(f):f},Ci=function(d,f){return d===f||k(d)!==null?!1:(mo&&qt(d),!0)},Ai=function(d,f){if(ze(U.beforeSanitizeElements,d,null),Ci(d,f))return!0;if(jt(d))return $e(d),!0;const S=oe(F(d));if(q=ki(U.uponSanitizeElement,q,xt,Nt),ze(U.uponSanitizeElement,d,{tagName:S,allowedTags:q}),Ci(d,f))return!0;if(ar(d,S))return $e(d),!0;if(Te[S]||!(N.tagCheck instanceof Function&&N.tagCheck(S))&&!q[S]){const D=sr(d,S,f);return D===!1&&ze(U.afterSanitizeElements,d,null),D}if(Y(d)===Ee.element&&!ir(d)||(S==="noscript"||S==="noembed"||S==="noframes")&&le(jr,d.innerHTML))return $e(d),!0;if(Q&&d.nodeType===Ee.text){const D=Kt(d.textContent);d.textContent!==D&&(Tt(e.removed,{element:d.cloneNode()}),d.textContent=D)}return ze(U.afterSanitizeElements,d,null),!1},Di=function(d,f,S){if(Ot[f]||Si(f,d)||li&&(f==="id"||f==="name")&&(S in t||S in Jn))return!1;const C=K[f]||N.attributeCheck instanceof Function&&N.attributeCheck(f,d);return nt&&le(po,f)||vt&&le(Ke,f)?!0:C?fi[f]||le(It,Et(S,Se,""))||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Oi(S,"data:")===0&&ui[d]||x&&!le(we,Et(S,Se,""))?!0:!S:Mi(d)&&Yt(ue.tagNameCheck,d)&&Yt(ue.attributeNameCheck,f,d)||f==="is"&&ue.allowCustomizedBuiltInElements&&Yt(ue.tagNameCheck,S)},lr=$({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Mi=function(d){return!lr[Mt(d)]&&le(uo,d)},dr=function(d,f,S,C){if(M&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!S)switch(m.getAttributeType(d,f)){case"TrustedHTML":return H(C);case"TrustedScriptURL":return ae(C)}return C},cr=function(d,f,S,C){try{S?d.setAttributeNS(S,f,C):d.setAttribute(f,C),jt(d)?$e(d):Li(e.removed)}catch{je(f,d)}},_i=function(d){ze(U.beforeSanitizeAttributes,d,null);const f=d.attributes;if(!f||jt(d))return;K=ki(U.uponSanitizeAttribute,K,it,$t);const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let C=f.length;const D=oe(d.nodeName);for(;C--;){const R=f[C],j=R.name,X=R.namespaceURI,me=R.value,ge=oe(j),To=me;let he=j==="value"?To:Mr(To);if(S.attrName=ge,S.attrValue=he,S.keepAttr=!0,S.forceKeepAttr=void 0,ze(U.uponSanitizeAttribute,d,S),he=S.attrValue,di&&(ge==="id"||ge==="name")&&Oi(he,ci)!==0&&(je(j,d,R),he=ci+he),te&&le(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,he)){je(j,d,R);continue}if(ge==="attributename"&&Ii(he,"href")){je(j,d,R);continue}if(!S.forceKeepAttr){if(!S.keepAttr){je(j,d,R);continue}if(!O&&le(Yr,he)){je(j,d,R);continue}if(Q&&(he=Kt(he)),!Di(D,ge,he)){je(j,d,R);continue}he=dr(D,ge,X,he),he!==To&&cr(d,j,X,he)}}ze(U.afterSanitizeAttributes,d,null)},Vt=function(d){let f=null;const S=Ei(d);for(ze(U.beforeSanitizeShadowDOM,d,null);f=S.nextNode();)if(ze(U.uponSanitizeShadowNode,f,null),Ai(f,d),_i(f),ct(f.content)&&Vt(f.content),Y(f)===Ee.element){const C=z(f);ct(C)&&(So(C),Vt(C))}ze(U.afterSanitizeShadowDOM,d,null)},So=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const S=f.pop();if(S.shadow){Vt(S.shadow);continue}const C=S.node,R=Y(C)===Ee.element,j=T(C);if(j)for(let X=j.length-1;X>=0;--X)f.push({node:j[X],shadow:null});if(R){const X=ne?ne(C):null;if(typeof X=="string"&&oe(X)==="template"){const me=C.content;ct(me)&&f.push({node:me,shadow:null})}}if(R){const X=z(C);ct(X)&&f.push({node:null,shadow:X},{node:X,shadow:null})}}};return e.sanitize=function(E){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,S=null,C=null,D=null;if(go=!E,go&&(E="<!-->"),typeof E!="string"&&!St(E)&&(E=Fr(E),typeof E!="string"))throw Ye("dirty is not a string, aborting");if(!e.isSupported)return E;yt?(q=Nt,K=$t):yo(d),(U.uponSanitizeElement.length>0||U.uponSanitizeAttribute.length>0)&&(q=ke(q)),U.uponSanitizeAttribute.length>0&&(K=ke(K)),e.removed=[];const R=mo&&typeof E!="string"&&St(E);if(R){rr(E);const me=F(E);if(typeof me=="string"){const ge=oe(me);if(!q[ge]||Te[ge])throw Gt(E),Ye("root node is forbidden and cannot be sanitized in-place")}if(jt(E))throw Gt(E),Ye("root node is clobbered and cannot be sanitized in-place");try{So(E)}catch(ge){throw Gt(E),ge}}else if(St(E))f=Ti("<!---->"),S=f.ownerDocument.importNode(E,!0),S.nodeType===Ee.element&&S.nodeName==="BODY"||S.nodeName==="HTML"?f=S:f.appendChild(S),So(S);else{if(!rt&&!Q&&!De&&E.indexOf("<")===-1)return M&&Ht?H(E):E;if(f=Ti(E),!f)return rt?null:Ht?G:""}f&&ho&&$e(f.firstChild);const j=R?E:f;try{const me=Ei(j);for(;C=me.nextNode();)Ai(C,j),_i(C),ct(C.content)&&Vt(C.content)}catch(me){throw R&&(Gt(E),Xe(e.removed,ge=>{ge.element&&qt(ge.element)})),me}if(R)return Xe(e.removed,me=>{me.element&&qt(me.element)}),Q&&wo(E),E;if(rt){if(Q&&wo(f),Bt)for(D=pe.call(f.ownerDocument);f.firstChild;)D.appendChild(f.firstChild);else D=f;return(K.shadowroot||K.shadowrootmode)&&(D=ot.call(i,D,!0)),D}let X=De?f.outerHTML:f.innerHTML;return De&&q["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&le(qr,f.ownerDocument.doctype.name)&&(X="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
|
|
3
|
-
`+X),Q&&(X=Kt(X)),M&&Ht?H(X):X},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};yo(E),yt=!0,Nt=q,$t=K},e.clearConfig=function(){dt=null,yt=!1,Nt=null,$t=null,M=V,G=""},e.isValidAttribute=function(E,d,f){dt||yo({});const S=oe(E),C=oe(d);return Di(S,C,f)},e.addHook=function(E,d){typeof d=="function"&&be(U,E)&&Tt(U[E],d)},e.removeHook=function(E,d){if(be(U,E)){if(d!==void 0){const f=Ar(U[E],d);return f===-1?void 0:Dr(U[E],f,1)[0]}return Li(U[E])}},e.removeHooks=function(E){be(U,E)&&(U[E]=[])},e.removeAllHooks=function(){U=ji()},e}var Jr=Mn();const ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ta(o){const e=o.options;return 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=s=>{wn(e,ta(o),{format:String(t.barcodeType||"CODE128"),width:i,height:s*i,displayValue:!t.hideTitle,fontSize:(t.fontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*i,margin:0,marginLeft:n*i,marginRight:n*i,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*i});const l=na(e);return l?{widthUnits:l.width,heightUnits:l.height}:null};try{const s=p.layoutBarcodeSize({barHeightMm:t.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(t.width,t.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(t.height,t.maxHeight),dpi:t.printerDpi,barWidth:t.barWidth,measure:r});e.style.width=s.size?`${s.size.widthMm}mm`:"",e.style.height=s.size?`${s.size.heightMm}mm`:""}catch{e.replaceChildren();return}e.setAttribute("shape-rendering","crispEdges")}function aa(o,e){const t=o.options,i=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 sa(o,e){for(const t of Array.from(o.querySelectorAll("[data-code-kind]"))){const i=t.dataset.codeId,n=e.find(r=>r.id===i);if(n)if(t.dataset.codeKind==="barcode"){const r=t.querySelector("svg");r&&ra(n,r)}else aa(n,t)}}const la={header:"题",data:"数",subtotal:"小",summary:"汇"},da=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],eo=3.7795275591,ca=.1,Ho=o=>JSON.parse(JSON.stringify(o)),Yi=new WeakMap;function Ne(o){let e=Yi.get(o);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Yi.set(o,e)),e}function Pt(o,e){return o.templateData.elements.find(t=>t.id===e)??null}function pa(o,e){const t=o.tableSelection;return!t||t.elementId!==e.id?null:o.selectedElement?.id!==e.id?(o.tableSelection=null,null):t}function _n(o,e,t){const i=Pt(o,t.id);if(!i)return null;const n=t.options;return{store:o,fire:e,el:t,real:i,options:n,rows:n.tableRows??[],colWidths:n.tableColWidths??[],isSelected:o.selectedIds.has(t.id),selection:pa(o,t),maxTableWidth:Rn(o)}}function Rn(o){return o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right}function Zo(o){return o.options.tableDefaultFontSize??10}function zn(o){return o.options.tableDefaultColor??"#333333"}function ua(o,e){let t=0;for(let i=0;i<e;i++)t+=o.rows[i].height;return t}function ha(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.top??ua(o,e)}function fa(o,e){return Ne(o.store).layouts.get(o.el.id)?.[e]?.height??o.rows[e]?.height??0}function ma(o){const e=o.options.dataSource;if(e&&Array.isArray(p.DEFAULT_DEMO_DATA[e]))return p.DEFAULT_DEMO_DATA[e];for(const t of Object.values(p.DEFAULT_DEMO_DATA))if(Array.isArray(t))return t}function Pn(o){return o.cellType==="barcode"||o.cellType==="qrcode"}function Fn(o,e){return Pn(e)?p.resolveBarcodeDesignValue(e.formatter,ma(o)):e.formatter||""}function ga(o,e){const t={designMode:!0,showGhostBorder:o.store.showTableGhostBorder};return{fontFamily:A.resolveCanvasFontFamily(e.fontFamily??o.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??Zo(o))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??zn(o),backgroundColor:e.backgroundColor??"transparent",borderTop:p.resolveCellBorderCss(e.borders?.top,t),borderRight:p.resolveCellBorderCss(e.borders?.right,t),borderBottom:p.resolveCellBorderCss(e.borders?.bottom,t),borderLeft:p.resolveCellBorderCss(e.borders?.left,t),padding:(e.padding??o.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function ba(o,e,t){const i=o.selection;return[!!i&&e>=i.r1&&e<=i.r2&&t>=i.c1&&t<=i.c2?"cell-selected":"",o.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Ln(o){return p.resolveCellTextFit(o)}function xa(o){return Ln(o)!=="autoHeight"}function va(o,e){return e.fontSize??Zo(o)}function ro(o,e,t){return p.cellFitCapMm(o.rows,e,t,o.options.tableDefaultPadding??1)}function ya(o,e,t){return p.cellFitWidthMm(o.colWidths,e,t,o.options.tableDefaultPadding??1)}function wa(o,e,t){return{maxHeight:ro(o,t,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Sa(o,e,t){const i={fitBase:String(va(o,e)),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(ro(o,t,e))};return Ln(e)==="shrink"&&(i.fit="shrink"),i}function Ta(o){const e=(o.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(t=>!Number.isFinite(t))?null:{width:e[2],height:e[3]}}const Ea={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ka(o,e,t,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(fr,"svg");n.appendChild(r);const s=Fn(o,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Ea[i.fit||"contain"]??"xMidYMid meet");const l=p.barcodeUnitsPerModule(i.barWidth),c=p.barcodeQuietZoneModules(i.barQuietZone),u=g=>{wn(r,s,{format:i.barcodeType||"CODE128",width:l,height:g*l,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??p.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:c*l,marginRight:c*l,marginTop:0,marginBottom:p.BARCODE_MARGIN_BOTTOM_MODULES*l});const v=Ta(r);return v?{widthUnits:v.width,heightUnits:v.height}:null};let h=null;try{h=p.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:p.barcodeAvailableBoxMm(ya(o,t,i),i.maxWidth),boxHeightMm:p.barcodeAvailableBoxMm(ro(o,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=s||"条码",n.appendChild(g),n}const m=h.size;return m?(r.style.width=`${m.widthMm}mm`,r.style.height=`${m.heightMm}mm`):(r.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",r.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%"),r.setAttribute("shape-rendering","crispEdges"),n}if(r.style.display="none",!s)return n;try{const l=Vo.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),c=document.createElement("img");c.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),c.setAttribute("alt","qrcode"),c.style.width="100%",c.style.height="100%",c.style.objectFit=i.fit||"contain",i.objectPosition&&(c.style.objectPosition=i.objectPosition),c.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",c.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(c)}catch{}return n}function Vi(){const o=document.createElement("div");return o.className="image-placeholder",o.textContent="图片",o}function Ca(o){const e=o.formatter||"";return e?e.includes("{")?p.evaluateTemplate(e,p.DEFAULT_DEMO_DATA):e:""}function Aa(o,e,t){const i=document.createElement("div");i.className="cell-image";const n=p.cellImageBoxMm(t.fit,ro(o,e,t));n!==void 0&&(i.style.height=`${n}mm`);const r=Ca(t);if(!r)return i.appendChild(Vi()),i;const s=document.createElement("img");s.setAttribute("src",r),n!==void 0&&(s.style.width="100%",s.style.height="100%"),s.style.objectFit=t.fit||"contain";for(const[l,c]of Object.entries(p.cropStyleDeclarations(t.fit,t.fitScale,t.objectPosition)))s.style[l]=c;return s.style.maxWidth=t.maxWidth?`${t.maxWidth}mm`:"100%",s.style.maxHeight=t.maxHeight?`${t.maxHeight}mm`:"100%",s.addEventListener("error",()=>{s.remove(),i.appendChild(Vi())},{once:!0}),i.appendChild(s),i}function Da(o,e,t,i,n){if(Pn(n))return ka(o,t,i,n);if(n.cellType==="image")return Aa(o,t,n);const r=Fn(o,n),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return xa(n)?a("div",{class:"cell-fit",style:wa(o,n,t),dataset:Sa(o,n,t)},[s()]):s()}function oo(o,e,t){const i={elementId:o.el.id,...p.normalizeSelection(o.rows,e,t)};o.store.setTableSelection(i),o.fire("table-selection-change",{elementId:o.el.id,selection:i})}function Ma(o,e,t,i,n){if(n.button!==0||(o.fire("table-cell-mousedown",{elementId:o.el.id,r:e,c:t,cellId:i,event:n}),!o.isSelected))return;n.stopPropagation();const r=Ne(o.store);n.shiftKey&&o.selection?oo(o,{r:o.selection.r1,c:o.selection.c1},{r:e,c:t}):(r.anchor={r:e,c:t},oo(o,{r:e,c:t},{r:e,c:t})),document.addEventListener("mouseup",()=>{Ne(o.store).anchor=null},{once:!0})}function _a(o,e,t){const i=Ne(o.store).anchor;i&&oo(o,i,{r:e,c:t})}function In(o,e){const t=Ne(o);t.menu?.visible&&(t.menu.visible=!1,e("table-menu-close",{elementId:t.menuElId}),o.emit(!1))}function Ra(o,e,t,i){i.preventDefault(),i.stopPropagation(),o.isSelected||o.store.selectOne(o.el.id);const n=o.selection;n&&e>=n.r1&&e<=n.r2&&t>=n.c1&&t<=n.c2||oo(o,{r:e,c:t},{r:e,c:t});const s=Ne(o.store);s.menuElId=o.el.id,s.menu&&(s.menu.x=i.clientX,s.menu.y=i.clientY,s.menu.visible=!0),o.fire("table-cell-contextmenu",{elementId:o.el.id,r:e,c:t,clientX:i.clientX,clientY:i.clientY}),o.store.emit(!1),document.addEventListener("mousedown",()=>In(o.store,o.fire),{once:!0})}function Xi(o,e,t){const i=o.reduce((n,r)=>n+r,0)+(o[e]??0);return i>t?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${t}mm,请先缩小列宽`:null}function za(o,e){const t=o.real.options.tableRows??[],i=o.real.options.tableColWidths??[],n=e(Ho(t),Ho(i));return n?(window.alert(n),!1):(o.store.recordHistory(),e(t,i),o.store.setTableSelection(null),p.syncTableElementSize(o.real.options),o.store.emit(),!0)}function Le(o,e,t){In(o.store,o.fire);const i=o.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(p.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(p.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>p.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,s)=>{const l=Xi(s,i.c1,o.maxTableWidth);return l||(p.insertCol(r,s,i.c1,"left"),null)};break;case"insert-col-right":n=(r,s)=>{const l=Xi(s,i.c2,o.maxTableWidth);return l||(p.insertCol(r,s,i.c2,"right"),null)};break;case"delete-col":n=(r,s)=>p.deleteCol(r,s,i.c1);break;case"merge":n=r=>(p.mergeCells(r,i),null);break;case"split":n=r=>(p.splitCells(r,i),null);break;case"set-row-type":n=r=>t?p.setRowType(r,i.r1,t):"未指定行类型";break}n&&za(o,n)&&o.fire(`table-${e}`,{elementId:o.el.id,...t?{type:t}:{}})}function Pa(o){const e=o.selection;if(!e)return!1;for(let t=e.r1;t<=e.r2;t++)for(let i=e.c1;i<=e.c2;i++){const n=o.rows[t]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function Zi(o,e){const t=o.selection;return t?t.r1!==t.r2?"行类型仅支持单行设置":p.setRowType(Ho(o.rows),t.r1,e):"未选择单元格"}function Ie(o,e,t={}){return a("div",{class:`menu-item${t.disabled?" disabled":""}${t.active?" active":""}`,title:t.title||"",text:o,onClick:()=>{t.disabled||e()}})}const Ro=()=>a("div",{class:"menu-divider"});function Fa(o,e,t){const i=Ne(o);if(i.menu=t,!t.visible||!i.menuElId)return"";const n=Pt(o,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=_n(o,e,n);if(!r)return"";const s=r.selection?p.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:t.x+"px",top:t.y+"px"},onMousedown:c=>c.stopPropagation()},[Ie("在上方插入行",()=>Le(r,"insert-row-above")),Ie("在下方插入行",()=>Le(r,"insert-row-below")),Ie("删除行",()=>Le(r,"delete-row"),{disabled:r.rows.length<=1}),Ro(),Ie("在左侧插入列",()=>Le(r,"insert-col-left")),Ie("在右侧插入列",()=>Le(r,"insert-col-right")),Ie("删除列",()=>Le(r,"delete-col"),{disabled:r.colWidths.length<=1}),Ro(),Ie("合并单元格",()=>Le(r,"merge"),{disabled:!!s,title:s||""}),Ie("拆分单元格",()=>Le(r,"split"),{disabled:!Pa(r)}),Ro(),a("div",{class:"menu-group-title",text:"行类型"}),...da.map(c=>Ie(c.label,()=>Le(r,"set-row-type",c.value),{disabled:!!Zi(r,c.value),title:Zi(r,c.value)||"",active:l===c.value}))])}let et=null;function On(){et&&(document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo),et.handle.classList.remove("dragging"),et=null)}function La(o,e){const t=o.closest(".hiprint-printPaper");return(t&&t.offsetWidth>0?t.getBoundingClientRect().width/t.offsetWidth:0)||(e.scale||100)/100}function Ia(o,e,t){if(t.button!==0)return;const i=t.currentTarget,n=i.closest(".print-table");if(!n)return;On();const r=o.real.options.tableColWidths??[];et={store:o.store,fire:o.fire,elId:o.real.id,boundary:e,startX:t.clientX,startWidth:r[e-1]??0,scale:La(n,o.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),o.store.recordHistory(),document.addEventListener("mousemove",Qo),document.addEventListener("mouseup",Jo)}function Qo(o){const e=et;if(!e)return;const t=Pt(e.store,e.elId),i=t?.options.tableColWidths;if(!t||!i)return;const n=(o.clientX-e.startX)/(e.scale*eo),r=e.boundary-1;i[r]=p.clampResizedColumnWidth(i,r,e.startWidth+n,Rn(e.store)),p.syncTableElementSize(t.options),i.forEach((s,l)=>{const c=e.root.querySelector(`colgroup col:nth-child(${l+1})`);c&&(c.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${i.slice(0,l+1).reduce((c,u)=>c+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${t.options.width}mm`,e.wrapper.style.height=`${t.options.height}mm`)}function Jo(){document.removeEventListener("mousemove",Qo),document.removeEventListener("mouseup",Jo);const o=et;if(!o)return;et=null,o.handle.classList.remove("dragging");const e=Pt(o.store,o.elId);e&&p.syncTableElementSize(e.options),o.store.emit(),o.fire("table-col-resize-end",{elementId:o.elId})}function Oa(o,e,t){const i=t.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Pt(o,e);if(!r)return;let s=!1;const l=n/eo;Math.abs(l-(r.options.height??0))>ca&&(r.options.height=Math.round(l*100)/100,s=!0);const c=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-c)/eo,height:m.offsetHeight/eo})),h=Ne(o);Na(h.layouts.get(e),u)||(h.layouts.set(e,u),s=!0),s&&o.emit(!1)}function Na(o,e){return!o||o.length!==e.length?!1:e.every((t,i)=>{const n=o[i];return Math.round(t.top*10)===Math.round(n.top*10)&&Math.round(t.height*10)===Math.round(n.height*10)})}function $a(o,e){const t=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!t.isConnected)return;const i=t.parentElement;i&&Oa(o,e,i)}),t}function Ba(o){return o.isSelected&&!o.real.options.locked&&o.colWidths.length>=1}function Ha(o){return Array.from({length:o.colWidths.length},(e,t)=>t+1)}function Wa(o,e){return o.colWidths.slice(0,e).reduce((t,i)=>t+i,0)}function Ua(o,e,t){const i=_n(e,t,o);if(!i)return a("div",{class:"print-table"});const n=[a("table",{style:{fontSize:`${Zo(i)}pt`,color:zn(i)}},[a("colgroup",{},i.colWidths.map(r=>a("col",{style:{width:r+"mm"}}))),a("tbody",{},i.rows.map((r,s)=>a("tr",{style:{height:r.height+"mm"}},r.cells.map((l,c)=>l.merged?"":a("td",{rowspan:l.rowspan||1,colspan:l.colspan||1,class:ba(i,s,c),style:ga(i,l),onMousedown:u=>Ma(i,s,c,l.id,u),onMouseenter:()=>_a(i,s,c),onContextmenu:u=>Ra(i,s,c,u)},[Da(i,r,s,c,l)])).filter(Boolean))))])];return Ba(i)&&n.push(a("div",{class:"col-resize-layer"},Ha(i).map(r=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${r}`,style:{left:Wa(i,r)+"mm"},onMousedown:s=>{s.stopPropagation(),s.preventDefault(),Ia(i,r,s)}})))),i.isSelected&&n.push(a("div",{class:"row-badges"},i.rows.map((r,s)=>a("span",{class:"row-badge",style:{top:ha(i,s)+"mm",height:fa(i,s)+"mm"},text:la[r.type]})))),n.push($a(e,o.id)),a("div",{class:"print-table design-mode",dataset:{tableId:o.id},onContextmenu:r=>r.preventDefault()},n)}const Ga=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function Wo(o){return Array.isArray(o)&&o.length>0?o:[]}function qa(o,e){const t=p.detectFlowListKey(o,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(t)return Wo(e?.[t]);const i=p.detectFlowListKey(o,p.DEFAULT_DEMO_DATA);return i?Wo(p.DEFAULT_DEMO_DATA[i]):[]}function Ka(o,e){const t=o.options,i=typeof t.formatter=="string"?t.formatter:"",n=Wo(e)[0],r=qa(i,n);if(r.length===0)return[...Ga];if(!i)return r.map(c=>String(c?.name??JSON.stringify(c)));const s=n??{},l=p.detectFlowListKey(i,s)??Object.keys(s).find(c=>Array.isArray(s[c]));return r.map(c=>{try{return p.evaluateTemplate(i,{...s,...c,...l?{[l]:c}:{}})}catch{return i}})}function ja(o,e){const t=o.options,i=p.resolveFlowColumns(t.flowColumns),n=p.resolveFlowGapX(t.flowGapX),r=p.resolveFlowRowHeight(t.flowRowHeight),s={display:"grid",gridTemplateColumns:`repeat(${i},minmax(0,1fr))`,columnGap:`${n}mm`,gridAutoRows:`minmax(${r}mm,auto)`,width:"100%",height:"100%",overflow:"hidden",fontSize:`${t.fontSize||12}pt`,fontWeight:t.fontWeight||"normal",color:t.color||"#333",boxSizing:"border-box"};return t.fontFamily&&(s.fontFamily=String(t.fontFamily)),t.backgroundColor&&(s.backgroundColor=String(t.backgroundColor)),a("div",{class:"print-flowlist",style:s},Ka(o,e).map(l=>a("div",{class:"print-flow-cell",text:l})))}const Qi={top:"flex-start",middle:"center",bottom:"flex-end"},Ya={left:"flex-start",center:"center",right:"flex-end"};function Va(o,e){const t=o.options,i=p.resolveElementBorder(o.printElementType.type,t),n={};if(i?.all&&(n.border=`${i.all.borderWidth} ${i.all.borderStyle} ${i.all.borderColor}`),i)for(const r of p.ELEMENT_BORDER_SIDES){const s=i.edges[r];s&&(n[`border${r.charAt(0).toUpperCase()}${r.slice(1)}`]=`${s.borderWidth} ${s.borderStyle} ${s.borderColor}`)}return{position:"absolute",left:`${t.left}mm`,top:`${t.top}mm`,width:`${t.width}mm`,height:`${t.height}mm`,zIndex:String(t.zIndex||"auto"),...n,...Xa(o,e)}}function Xa(o,e){if(e?.has(o.id))return{};const t=p.resolveElementRotation(o.printElementType.type,o.options);return t===void 0?{}:{rotate:`${t}deg`}}function Ji(o){const e=o.options,t=o.printElementType.type==="longText",i=p.resolveElementTextFit(o.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",s={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:t?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...t?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};p.resolveElementNowrap(e)&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis");const l=p.resolveElementWhiteSpace(e);return l&&(s.whiteSpace=l),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Qi[e.verticalAlign]??"flex-start"):(s.alignItems=Qi[e.verticalAlign]??"flex-start",s.justifyContent=Ya[e.textAlign||"left"]??"flex-start")),{style:s,fit:i}}function Za(o){const e=o.options,t=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return o.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${t} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${t} ${i} ${n}`,boxSizing:"border-box"}}function Qa(o){const e=o.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:o.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Ja(o){const e=o.options;return{objectFit:e.fit||"contain",...p.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function en(o){const e=o.options,t={fitBase:String(e.fontSize||12),fitMin:String(p.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return p.resolveElementTextFit(o.printElementType.type,e)==="shrink"&&(t.fit="shrink"),t}function es(o,e,t){const i=o.printElementType.type,n=o.options;switch(i){case"text":{const{style:r}=Ji(o);return a("div",{class:"print-text",style:r,dataset:en(o),text:String(n.testData||n.formatter||"")||"文本"})}case"longText":{const{style:r}=Ji(o);return a("div",{class:"print-longtext",style:r,dataset:en(o),text:String(n.formatter||"")||"长文本内容"})}case"hline":case"vline":return a("div",{class:"print-line",style:Za(o)});case"rect":case"oval":return a("div",{class:"print-shape",style:Qa(o)});case"image":{const r=String(n.src??""),s=r.includes("{")?p.evaluateTemplate(r,p.DEFAULT_DEMO_DATA):r;return a("div",{class:"print-image"},[s?a("img",{src:s,style:Ja(o)}):a("div",{class:"image-placeholder",text:"图片"})])}case"qrcode":return oa(o);case"barcode":return ia(o);case"html":{const r=String(n.formatter??""),s=r?Jr.sanitize(p.evaluateTemplate(r,{})):'<div style="background:#e0e0e0;width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:10pt;color:#999">HTML</div>';return a("div",{class:"print-html",html:s})}case"pageNumber":return a("div",{class:"page-number-element",style:{fontSize:`${n.fontSize||12}pt`,fontWeight:n.fontWeight||"normal",fontFamily:A.resolveCanvasFontFamily(n.fontFamily),color:n.color||"#333",textAlign:n.textAlign||"left",...n.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:n.title||"{pageIndex}/{totalPages}"});case"table":return t?Ua(o,t.store,t.fire):a("div",{class:"print-table"});case"flowList":return ja(o);default:return a("div",{text:i})}}function Nn(o){return`x:${Math.round(o.left)} y:${Math.round(o.top)} ${Math.round(o.width)}×${Math.round(o.height)}mm`}function ts(o,e,t){const i=o.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),s=e.options,l=e.zone||"content",c=[es(e,!0,{store:i,fire:o.fire})];return i.draggingIds.has(e.id)&&c.push(a("div",{class:"drag-preview"})),n&&(c.push(a("div",{class:"resize-handles"},p.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>o.fire("resize-start",{event:h,id:e.id,point:u})})))),c.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Nn(s)})]))),a("div",{class:["print-element",`type-${e.printElementType.type}`,`zone-${l}`,n?"selected":"",r?"previewed":"",i.draggingIds.has(e.id)?"drag-ghost":"","design-mode",s.locked?"locked":"",s.visible===!1?"hidden":""].filter(Boolean).join(" "),style:Va(e,t),dataset:{elId:e.id},onMousedown:u=>o.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),o.fire("contextmenu",{event:u,id:e.id})}},c)}function Uo(o,e){const t=o.margins,i=o.header?.height??10,n=o.footer?.height??10,r=e.width-t.left-t.right;return{header:{left:t.left,top:t.top,width:r,height:i},content:{left:t.left,top:t.top+i,width:r,height:e.height-t.top-t.bottom-i-n},footer:{left:t.left,top:e.height-t.bottom-n,width:r,height:n}}}const os='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>';function tn(o,e){return o.type==="vertical"?{left:`${o.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${o.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:o.color||"var(--pd-accent-secondary, #f56c6c)"}}function is(o,e){const t=A.resolveWatermarkLayout(o.watermark,[],e);return t?a("div",{class:"watermark-layer",style:{opacity:String(t.opacity)}},t.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${t.tileWidthPx} ${t.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(t.tileWidthPx/2),y:String(t.tileHeightPx/2),"font-size":String(t.fontSizePx),fill:t.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${t.rotate},${t.tileWidthPx/2},${t.tileHeightPx/2})`,text:t.text})]))):""}function zo(o,e,t,i,n,r){const s=o.store,l=[];t!=="content"&&l.push(a("span",{class:"zone-label",text:t==="header"?"页眉":"页脚"}));const c=t==="content"?A.collectFollowMemberIds(n):void 0;if(l.push(...n.map(u=>ts(o,u,c))),t!=="content"){const u=t==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:t},onMousedown:h=>o.fire("zone-resize",{event:h,zone:t})},[e.zoneResizing===t?a("div",{class:"zone-height-tip",text:`${(t==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${t} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:t,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function ns(o,e){const t=o.store,i=t.templateData,n=A.getPaperDimensions(i),r=(t.scale||100)/100,s=Uo(i,n),l=m=>t.elements.filter(g=>(g.zone||"content")===m),c=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[t.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(os)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[is(i,n)]:[],zo(o,e,"header",s.header,l("header"),n),zo(o,e,"content",s.content,l("content"),n),zo(o,e,"footer",s.footer,l("footer"),n),...t.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:tn(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...tn(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>o.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),o.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],c]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${A.mmToPx(n.width)*r}px`,height:`${A.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(t.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>o.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Me(o,m,"复制","copy"),Me(o,m,"剪切","cut"),Me(o,m,"粘贴","paste",!t.hasClipboard),Me(o,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Me(o,m,"置顶","move-layer",!1,"top"),Me(o,m,"上移","move-layer",!1,"up"),Me(o,m,"下移","move-layer",!1,"down"),Me(o,m,"置底","move-layer",!1,"bottom")]:[Me(o,m,"粘贴","paste-at",!t.hasClipboard),Me(o,m,"全选","select-all"),Me(o,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>m.preventDefault(),onDrop:m=>o.fire("drop",m),onMousedown:m=>o.fire("canvas-mousedown",m),onMousemove:m=>o.fire("canvas-mousemove",m),onMouseleave:()=>o.fire("canvas-mouseleave"),onWheel:m=>o.fire("wheel",m),onScroll:m=>o.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),o.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Me(o,e,t,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:t,onClick:()=>{e.visible=!1,n||o.fire(i,r),o.repaint()}})}const rs={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function ve(o,e=15,t){const i=rs[o];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${t?` class="${t}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let Je=null;function ei(o){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(o.trim());if(!e)return null;const t=e[1],i=t.length===3?t.split("").map(n=>n+n).join(""):t;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function ti(o){const e=ei(o);return e?$n(e):"#000000"}function $n({r:o,g:e,b:t}){return`#${[o,e,t].map(i=>Math.round(zt(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function as(o,e,t){const i=o/255,n=e/255,r=t/255,s=Math.max(i,n,r),l=Math.min(i,n,r),c=s-l;let u=0;return c!==0&&(s===i?u=(n-r)/c%6:s===n?u=(r-i)/c+2:u=(i-n)/c+4,u*=60,u<0&&(u+=360)),{h:u,s:s===0?0:c/s,v:s}}function ss(o,e,t){const i=t*e,n=(o%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[s,l,c]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=t-i;return{r:(s+u)*255,g:(l+u)*255,b:(c+u)*255}}function ls(o){return((Number.isFinite(o)?o:0)%360+360)%360}function zt(o){return Math.min(1,Math.max(0,Number.isFinite(o)?o:0))}function ds(o){const e=o.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${o.triggerClass?` ${o.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:t=>{const i=t.currentTarget??t.target,n=i.getRootNode();if(!!Je&&Je.root===n&&Je.title===e&&Je.trigger===i){_t();return}_t(),cs(i,o)}},[a("span",{class:"preset-color-swatch",style:o.value?{background:o.value}:{background:"transparent"}})])}function _t(){const o=Je;o&&(Je=null,o.teardowns.forEach(e=>e()),o.trigger.setAttribute("aria-expanded","false"),o.panel.remove())}function cs(o,e){const t=o.getRootNode(),i=t instanceof ShadowRoot?t:document.body,n={root:t,title:e.title??"颜色选择",trigger:o,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&ii(n,e.value)?n.hexText=ti(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=fe(fs(n),i),n.current=n.panel.querySelector(".picker-current"),n.hex=n.panel.querySelector(".picker-hex"),n.area=n.panel.querySelector(".picker-area"),n.handle=n.panel.querySelector(".picker-handle"),n.hueRange=n.panel.querySelector(".picker-hue"),n.clearBtn=n.panel.querySelector(".picker-clear"),n.items=Array.from(n.panel.querySelectorAll(".preset-color-item")).map((r,s)=>({el:r,color:p.PRESET_COLORS[s]})),ao(n),ps(n),us(n),Je=n,o.setAttribute("aria-expanded","true")}function ps(o){const e=o.trigger.getBoundingClientRect(),t=190,i=o.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-t-n)),s=e.bottom+6,l=s+i>window.innerHeight-n?Math.max(n,e.top-i-6):s;o.panel.style.left=`${r}px`,o.panel.style.top=`${l}px`}function us(o){const e=n=>{const r=hs(n);r.includes(o.trigger)||r.includes(o.panel)||_t()},t=n=>{n.key==="Escape"&&_t()},i=()=>_t();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",t),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),o.root.addEventListener("scroll",i,!0),o.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",t),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>o.root.removeEventListener("scroll",i,!0))}function hs(o){const e=typeof o.composedPath=="function"?o.composedPath():[];return e.length?e:[o.target]}function fs(o){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>gs(o,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>bs(o,e),onKeydown:e=>xs(o,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>vs(o,Number(e.target.value)),onChange:()=>ni(o)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),o.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>io(o,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},p.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ms(o,e)})))])}function oi(o){return $n(ss(o.hue,o.saturation,o.value_))}function ao(o){const e=oi(o);o.hex.value!==o.hexText&&(o.hex.value=o.hexText),o.current.className=o.model?"picker-current":"picker-current is-empty",o.model?o.current.style.background=e:o.current.style.removeProperty("background"),o.area.style.setProperty("--picker-hue",`${Math.round(o.hue)}deg`),o.handle.style.left=`${o.saturation*100}%`,o.handle.style.top=`${(1-o.value_)*100}%`,o.handle.style.background=e;const t=String(Math.round(o.hue));o.hueRange.value!==t&&(o.hueRange.value=t),o.clearBtn&&(o.clearBtn.disabled=!o.model);for(const i of o.items)i.el.className=o.model&&i.color.toLowerCase()===o.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function ii(o,e){const t=ei(e);if(!t)return!1;const i=as(t.r,t.g,t.b);return o.hue=i.h,o.saturation=i.s,o.value_=i.v,o.hexText=ti(e).toUpperCase(),!0}function mt(o,e,t,i){o.hue=ls(e),o.saturation=zt(t),o.value_=zt(i),o.hexText=oi(o).toUpperCase(),ao(o)}function ni(o){const e=oi(o);o.model=e,ao(o),o.onChange(e)}function io(o,e){o.model=e,e||(o.hexText=""),ao(o),o.onChange(e)}function ms(o,e){ii(o,e),io(o,e)}function gs(o,e){const t=e.trim();if(!t){o.clearable&&io(o,void 0);return}ei(t)&&(ii(o,t),io(o,ti(t)))}function bs(o,e){o.dragging=!0,on(o,e);const t=n=>{o.dragging&&on(o,n)},i=()=>{o.dragging&&(o.dragging=!1,document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),ni(o))};document.addEventListener("pointermove",t),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function on(o,e){const t=o.area.getBoundingClientRect();if(!t.width||!t.height)return;const i=zt((e.clientX-t.left)/t.width),n=zt(1-(e.clientY-t.top)/t.height);mt(o,o.hue,i,n)}function xs(o,e){const t=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?mt(o,o.hue,o.saturation-t,o.value_):e.key==="ArrowRight"?mt(o,o.hue,o.saturation+t,o.value_):e.key==="ArrowUp"?mt(o,o.hue,o.saturation,o.value_+t):e.key==="ArrowDown"?mt(o,o.hue,o.saturation,o.value_-t):i=!1,i&&(e.preventDefault(),ni(o))}function vs(o,e){mt(o,e,o.saturation,o.value_)}function J(o,e,t,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>o.fire(t,i.arg),html:ve(e)})}function no(o,e,t,i){const n=o.state.openDd===e,r=()=>{o.state.openDd=n?null:e,o.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!t.disabled,dataset:{test:t.testId??e,tip:t.tip},onClick:r,html:`${t.icon?ve(t.icon):""}${t.text?`<span class="${t.textClass??"tb-btn-text"}">${t.text}</span>`:""}${ve("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${t.panelClass?` ${t.panelClass}`:""}`},i):""].filter(Boolean))}function I(o){const e=o.step??1,t=String(e),i=t.indexOf("."),n=i===-1?0:t.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,s=m=>{let g=r(m);return o.min!==void 0&&g<o.min&&(g=o.min),o.max!==void 0&&g>o.max&&(g=o.max),g},l=o.value===void 0||o.value===null||!Number.isFinite(o.value)?void 0:r(o.value),c=l??o.min??0,u=m=>{m!==l&&o.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:o.min,max:o.max,step:e,placeholder:o.placeholder,disabled:!!o.disabled,onChange:m=>{const g=m.target,v=(g.value??"").trim();if(v===""){l!==void 0&&(g.value=String(l));return}const b=Number(v);if(!Number.isFinite(b)){g.value=l===void 0?"":String(l);return}const w=s(b);g.value=String(w),u(w)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!o.disabled||c<=(o.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(s(c-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!o.disabled||c>=(o.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(s(c+e))})])}function B(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),i??""]),e,t?a("p",{class:"pd-hint",text:t}):""].filter(Boolean))}const Go=o=>a("button",{class:"pd-help",type:"button","data-tip":o,"aria-label":"字段说明"});function Ce(o,e,t,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[o,Go(t)]),i??""]),e])}function tt(o){const e=o.base?.[o.propKey],t=o.target?.[o.propKey]!==e,i=o.force===!0||t,n=o.tipOverride??(o.tipValue===void 0?"恢复默认值":`恢复默认值(${o.tipValue}${o.tipUnit?" "+o.tipUnit:""})`),r=o.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${t&&!o.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ve("RotateCcw",13),onClick:()=>{i&&(o.write?o.write(e):o.target[o.propKey]=e,o.onReset?.())}})}const Pe=o=>a("h3",{class:"pd-divider",text:o});function Ae(o,e,t="颜色选择",i){return ds({value:o,title:t,triggerClass:i,onChange:n=>e(n)})}function Ue(o,e,t,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:o,value:r.value,checked:t===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Bn(o,e,t,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const s=document.createElement("option");s.value=r.value,s.textContent=r.label,r.disabled&&(s.disabled=!0),n.appendChild(s)}return n.value=o,e.some(r=>r.value===o)||(n.selectedIndex=-1),n.addEventListener("change",()=>t(n.value)),n}function ys(o){const e=window.innerHeight;for(let t=o.parentElement;t&&t!==document.body;t=t.parentElement){const i=getComputedStyle(t).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=t.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function so(o){const e=A.normalizeFontCatalog(o.fonts),t=o.placeholder??"默认",i=`font-select-list-${o.id}`,n=F=>{const M=F?.trim();return M?A.findFontOption(e,M)?.label??M:""},r=F=>{const M=A.normalizeFontQuery(F);return e.find(V=>V.label&&A.normalizeFontQuery(V.label)===M)?.family??F},s=()=>{const F=o.value?.trim();return F?A.findFontOption(e,F)?"":F:""},l=F=>{const M=(o.value??"").trim(),G=(Z,y,H,ae)=>({kind:Z,key:y,label:H,value:ae,selected:(ae??"")===M}),V=F.trim();if(!V){const Z=[G("clear","__clear__",t)],y=s();y&&Z.push(G("unknown","__unknown__",`${y}(未知)`,y));for(const H of e)Z.push(G("font",H.family,A.fontOptionLabel(H),H.family));return Z}const ce=A.filterFontOptions(e,V).map(Z=>G("font",Z.family,A.fontOptionLabel(Z),Z.family));if(!ce.length){const Z=r(V);ce.push(G("free","__free__",`使用「${Z}」`,Z))}return ce},c=document.createElement("div");c.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=t,u.disabled=!!o.disabled,u.value=n(o.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=o.state.fontOpen?.id===o.id?o.state.fontOpen:null,g={open:!!m&&!o.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const v=()=>{o.state.fontOpen=g.open?{id:o.id,query:g.query,highlighted:g.highlighted}:null};v();const b=()=>{const F=(o.value??"").trim();return l(g.query).findIndex(M=>(M.value??"")===F)},w=()=>{const F=u.getBoundingClientRect(),M=ys(u);h.classList.toggle("is-up",p.resolveOverlayPlacement({triggerTop:F.top,triggerBottom:F.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:M.top,boundaryBottom:M.bottom})==="up")},T=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||c.appendChild(h);const F=l(g.query);h.replaceChildren(...F.map((M,G)=>{const V=document.createElement("li");return V.id=`${i}-${G}`,V.className="font-select-option"+(G===g.highlighted?" is-active":"")+(M.kind==="unknown"||M.kind==="free"?" is-muted":""),V.setAttribute("role","option"),V.setAttribute("aria-selected",String(M.selected)),V.textContent=M.label,V.addEventListener("mousedown",ce=>{ce.preventDefault(),ye(M)}),V})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),w()},k=()=>{g.open||o.disabled||(g.open=!0,g.query="",g.highlighted=b(),v(),T())},z=()=>{g.open||k()},W=()=>{g.open=!0,g.query=u.value,g.highlighted=l(g.query).length?0:-1,v(),T()},P=F=>{if(!g.open){k();return}const M=l(g.query).length-1;if(M<0)return;g.highlighted=Math.min(Math.max(g.highlighted+F,0),M),v(),T(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},ne=()=>{if(!g.open)return;const F=l(g.query)[g.highlighted];if(F){ye(F);return}const M=g.query.trim();if(M){const G=r(M);ye({value:G})}},ye=F=>{g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(F.value),T(),o.onChange(F.value)},Y=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,v(),u.value=n(o.value),T())};return u.addEventListener("focus",k),u.addEventListener("click",z),u.addEventListener("input",W),u.addEventListener("blur",Y),u.addEventListener("keydown",F=>{const M=F;M.key==="ArrowDown"?(M.preventDefault(),P(1)):M.key==="ArrowUp"?(M.preventDefault(),P(-1)):M.key==="Enter"?(M.preventDefault(),ne()):M.key==="Escape"&&(M.preventDefault(),Y())}),c.append(u),T(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),c}const ws=[{key:"solid",label:"实线",preview:"1.5px solid currentColor"},{key:"dashed",label:"虚线",preview:"1.5px dashed currentColor"},{key:"dotted",label:"点线",preview:"1.5px dotted currentColor"},{key:"double",label:"双线",preview:"3px double currentColor"}],Ss={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function He(o,e,t,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:o,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${t}</svg>`})}const ut='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',nn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Ts(o){const e=o.format;e.syncBorderDraft();const t=e.values,i=!e.fontEditable,n=i||e.context==="cells",r=e.context==="none",s=e.context==="cells",l=!e.painterActive&&(e.context==="none"||e.context==="cells"||!e.painterCapturable),c=e.painterActive?"退出格式刷(Esc)":e.context==="cells"?"格式刷(表格单元格暂不支持)":e.context==="none"?"格式刷(需选中元素)":e.painterCapturable?"格式刷:单击刷一次,双击连续刷":"格式刷(请仅选中一个源元素)",u=g=>i?`${g}(需选中文本元素)`:g,h=[a("div",{class:"ft-border-panel",dataset:{test:"border-panel"}},[a("div",{class:"ft-border-grid"},[He("preset-none","无边框",`${ut}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),He("preset-all","所有边框",`${nn}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("all")),He("preset-outer","外侧边框",nn,()=>e.applyBorderPreset("outer")),He("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${ut}<line class="g-solid" x1="9" y1="3" x2="9" y2="15" /><line class="g-solid" x1="3" y1="9" x2="15" y2="9" />`,()=>e.applyBorderPreset("inner"),{disabled:!s}),He("edge-top","上边框",`${ut}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),He("edge-bottom","下边框",`${ut}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),He("edge-left","左边框",`${ut}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),He("edge-right","右边框",`${ut}<line class="g-solid" x1="15" y1="2" x2="15" y2="16" />`,()=>e.applyEdge("right"),{on:e.edgeOn("right")})]),a("div",{class:"ft-style-row"},ws.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),o.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[I({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),o.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Ae(e.borderColor,g=>{e.setBorderColor(g),o.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ve(b)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,v,b])=>a("button",{type:"button",class:`ft-cell-btn${t.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:v},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ve(b)})))])];return a("div",{class:"format-toolbar"},[a("div",{class:"tb-ou ft-group",dataset:{unit:"painter"}},[a("button",{type:"button",class:`ft-btn${e.painterActive?" on":""}`,dataset:{test:"format-painter",tip:c},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),o.repaint()},onDblclick:()=>{e.pickPainterSource(!0),o.repaint()},html:ve("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[so({id:"ft-font",state:o.state,fonts:o.host.fonts,value:typeof t.fontFamily=="string"?t.fontFamily:void 0,placeholder:t.fontFamily===Qe?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[I({value:typeof t.fontSize=="number"?t.fontSize:void 0,min:5,max:72,disabled:i,placeholder:t.fontSize===Qe?"混合":"默认",onCommit:g=>e.applyStyle({fontSize:g})})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"style"}},[...[["bold","Bold","加粗",()=>e.toggleBold()],["underline","Underline","下划线",()=>e.toggleUnderline()],["strike","Strikethrough","删除线",()=>e.toggleStrike()]].map(([g,v,b,w])=>a("button",{type:"button",class:`ft-btn${t[g]===!0?" on":""}`,dataset:{test:g,tip:u(b)},disabled:g==="bold"?i:n,onClick:w,html:ve(v)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Ae(typeof t.color=="string"?t.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Ae(typeof t.backgroundColor=="string"?t.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ve("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[no(o,"align",{icon:Ss[String(t.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[no(o,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const Es=[{type:"text",label:"文本",icon:"T"},{type:"barcode",label:"条形码",icon:"▍▍"},{type:"qrcode",label:"二维码",icon:"▦"},{type:"image",label:"图片",icon:"▧"},{type:"table",label:"表格",icon:"⊞"},{type:"flowList",label:"流式列表",icon:"⊟"},{type:"longText",label:"长文",icon:"¶"},{type:"hline",label:"横线",icon:"―"},{type:"vline",label:"竖线",icon:"│"},{type:"rect",label:"矩形",icon:"▭"},{type:"oval",label:"椭圆",icon:"◯"},{type:"html",label:"HTML",icon:"<>"}],ks={text:"T",longText:"¶",table:"⊞",flowList:"⊟",image:"🖼",barcode:"≡",qrcode:"▣",hline:"—",vline:"|",rect:"□",oval:"○",html:"<>"};function Cs(o){const e=o.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[rn("»","展开素材台",()=>{e.leftCollapsed=!1,o.repaint()}),...[["elements","元素","▦"],["fields","字段","⊛"],["layers","图层","≡"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,text:r,onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,o.repaint()}}))])]);const t=(i,n)=>a("div",{class:"pd-tab-pane",role:"tabpanel",style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),rn("«","收起素材台",()=>{e.leftCollapsed=!0,o.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,o.repaint()}}))]),t("elements",As()),t("fields",[Ds(o)]),t("layers",[Ms(o)])])])}function rn(o,e,t){return a("button",{type:"button",class:"collapse-btn",title:e,text:o,onClick:t})}function As(){return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...Es.map(o=>a("div",{class:"material-card",draggable:!0,dataset:{test:`material-${o.type}`},onDragstart:e=>e.dataTransfer?.setData("elementType",o.type)},[a("span",{class:"material-icon",text:o.icon}),a("span",{class:"material-label",text:o.label})]))]}function Ds(o){const e=o.state,t=p.groupFields(o.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?t.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):t;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>o.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const s=e.collapsedGroups.has(r.key)&&!i,l=r.key?a("div",{class:`field-group-header${r.isList?" is-list":""}`,onClick:()=>{s?e.collapsedGroups.delete(r.key):e.collapsedGroups.add(r.key),o.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",c=s?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey})`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{h.dataTransfer?.setData("fieldKey",u.fieldKey)}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})])]));return[l,a("div",{},c.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function Ms(o){const e=o.store,t=[...e.elements].sort((l,c)=>(c.options.zIndex??0)-(l.options.zIndex??0)),i=e.elements.filter(l=>e.selectedIds.has(l.id)),n=i.length>=2,r=i.some(l=>!!l.options.groupId),s=l=>l.zone==="header"?"页眉":l.zone==="footer"?"页脚":"";return a("div",{class:"layer-panel"},[a("div",{class:"panel-title",text:"图层"}),...t.map(l=>a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:c=>e.selectElement(l.id,c.ctrlKey||c.metaKey)},[a("span",{class:"layer-icon",text:ks[l.printElementType.type]||"?"}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))),t.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,c,u])=>a("button",{type:"button",class:"pd-button small",title:c,html:ve(u,14),onClick:()=>o.fire("move-layer",l)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ve("Group",14),onClick:()=>o.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ve("Ungroup",14),onClick:()=>o.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function _s(o){const e=o.store,t=o.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,c)=>t.renamingPage===c?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:t.renameText??"",onInput:u=>{t.renameText=u.target.value},onBlur:()=>s(),onKeydown:u=>{const h=u;if(h.key==="Enter"){s();return}h.key==="Escape"&&(t.renamingPage=null,o.repaint())}}):a("button",{type:"button",class:`page-tab${c===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${c+1}`,onClick:()=>e.switchPage(c),onDblclick:()=>{t.renamingPage=c,t.renameText=l.name??"",o.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>o.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>o.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>o.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>o.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>o.fire("move-page",1)})])]);function s(){const l=(t.renameText??"").trim();t.renamingPage!==null&&l&&e.renamePage(t.renamingPage,l),t.renamingPage=null,o.repaint()}}function Rs(o){const e=o.store,t=e.templateData,i=p.getPaperDimensions(t),n=t.orientation==="landscape"?"横向":"纵向",r=p.PAPER_PRESETS[t.paperSize]?.label??t.paperSize,s=t.outputRotation,l=`${r} ${n} ${Math.round(i.width)}×${Math.round(i.height)}mm${s?`(旋转${s}°)`:""}`;return a("div",{class:"status-bar"},[a("span",{class:"status-item coord",dataset:{coord:""},style:{display:"none"}}),a("span",{class:"status-item",text:`缩放 ${e.scale}%`}),a("span",{class:"status-item",text:`元素 ${e.elements.length}${e.selectedIds.size?` (选中 ${e.selectedIds.size})`:""}`}),a("span",{class:`status-dirty${e.dirty?" on":""}`},[a("span",{class:"dirty-dot"}),e.dirty?"未保存":"已保存"]),a("span",{class:"status-item status-paper",text:l})])}const zs=Object.keys(p.PAPER_PRESETS).filter(o=>o!=="CUSTOM"&&!p.PAPER_PRESETS[o]?.continuous);function Ps(o){const e=document.createElement("label");e.className="pd-button small upload-label";const t=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(t,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const s=o.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),i.value="";return}n(!0),t.textContent="上传中...";try{const l=await s(r);l?o.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{t.textContent="上传背景图",n(!o.host.uploadDesignBackground),i.value=""}}),o.host.uploadDesignBackground||n(!0),e}function Fs(o){const t=o.store.templateData.designBackground,i=t?.rotation??0;return a("div",{class:"design-background-config"},[Pe("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),t?.src?[a("div",{class:"design-background-path",title:t.src,text:t.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>o.store.updateTemplateData({designBackground:{...t,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>o.store.updateTemplateData({designBackground:void 0})})])]:Ps(o)].flat())}function Ls(o){const e=o.store,t=e.templateData,i=t.tiling,n={...A.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{...A.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=p.isContinuousPaperSize(t.paperSize),s=b=>e.updateTemplateData({tiling:{...n,...b}}),l=b=>tt({target:n,base:A.TILE_DEFAULTS,propKey:b,write:()=>s({[b]:A.TILE_DEFAULTS[b]})}),c=b=>tt({target:n.sheetMargin,base:A.TILE_DEFAULTS.sheetMargin,propKey:b,write:()=>u(b,A.TILE_DEFAULTS.sheetMargin[b])}),u=(b,w)=>s({sheetMargin:{...n.sheetMargin,[b]:w??0}}),h={...t,tiling:n},m=A.validateTiling(h),g=Math.max(A.computeMaxColumns(h),1);let v="";if(!m.length)try{const b=A.computeTileLayout(h),w=A.resolveSheetMm(h),T=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",k=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";v=`目标纸 ${T}${k} ${w.width}×${w.height}mm · ${b.columns} 列 × ${b.rows} 行 = 每张 ${b.perSheet} 格 · 每格 ${b.tile.width}×${b.tile.height}mm`}catch{v=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[Pe("拼版打印"),a("p",{class:"pd-hint",text:"把标签按「列 × 行」铺到一张大纸上批量打印"}),a("div",{class:"pd-field"},[a("label",{class:"tiling-switch"},[a("input",{type:"checkbox",checked:n.enabled===!0,disabled:r,onChange:b=>{if(!b.target.checked){s({enabled:!1});return}s({...A.TILE_DEFAULTS,columns:Math.min(A.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[B("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:b=>{const w=b.target.value;if(w!=="CUSTOM"){s({sheetPaperSize:w});return}const T=A.resolveSheetMm(h);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??T.width,sheetCustomHeight:n.sheetCustomHeight??T.height})}},[...zs.map(b=>a("option",{value:b,text:p.PAPER_PRESETS[b]?.label??b,selected:(n.sheetPaperSize??"A4")===b})),a("option",{value:"CUSTOM",text:"自定义",selected:n.sheetPaperSize==="CUSTOM"})]),void 0,l("sheetPaperSize")),n.sheetPaperSize==="CUSTOM"?B("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:b=>s({sheetCustomWidth:b})}),a("span",{class:"custom-size-x",text:"×"}),I({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:b=>s({sheetCustomHeight:b})})])):B("目标纸方向",Ue("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",b=>s({sheetOrientation:b})),void 0,l("sheetOrientation")),Pe("拼版留白 (mm)"),a("div",{class:"margin-grid"},[B("上",I({value:n.sheetMargin.top??0,min:0,max:100,onCommit:b=>u("top",b)}),void 0,c("top")),B("下",I({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:b=>u("bottom",b)}),void 0,c("bottom")),B("左",I({value:n.sheetMargin.left??0,min:0,max:100,onCommit:b=>u("left",b)}),void 0,c("left")),B("右",I({value:n.sheetMargin.right??0,min:0,max:100,onCommit:b=>u("right",b)}),void 0,c("right"))]),Pe("格间距与列数"),B("横向间距",I({value:n.gapX??0,min:0,max:50,onCommit:b=>s({gapX:b??0})}),void 0,l("gapX")),B("纵向间距",I({value:n.gapY??0,min:0,max:50,onCommit:b=>s({gapY:b??0})}),void 0,l("gapY")),B("列数",I({value:n.columns??1,min:1,max:g,onCommit:b=>s({columns:b||1})})),...m.map(b=>a("p",{class:"pd-hint tiling-error",text:b.message})),!m.length&&v?a("p",{class:"pd-hint tiling-summary",text:v}):""]:""].flat().filter(Boolean))}const Is=new Set(p.PROPERTY_REGISTRY.map(o=>o.group)),Os={"table-settings":"content"},an=new Map;function ri(o){const e=o??"";let t=an.get(e);if(!t){const{groups:i,itemKeys:n}=p.searchProperties(e);t={groups:i,keys:n,searching:!!e.trim()},an.set(e,t)}return t}function ai(o){const e=Os[o]??o;return Is.has(e)?e:""}function Ns(o,e){const t=ri(o.state.propSearch);if(!t.searching)return!0;const i=ai(e);return!i||t.groups.includes(i)}function $s(o,e){const t=ri(o.state.propSearch);return!t.searching||t.keys.has(e)}function Hn(o,e){const t=o.props.style??{};return o.props.style={...t,display:e?"":"none"},o}function _(o,e,t){const i=t.props.dataset??{};return t.props.dataset={...i,propKey:e},Hn(t,$s(o,e))}function Bs(o,e,t){const i=ai(e);if(!i)return t;const n=t.props.dataset??{};return t.props.dataset={...n,propGroup:i},Hn(t,Ns(o,e))}function Wn(o,e){const t=ri(e);for(const i of Array.from(o.querySelectorAll("[data-prop-group]"))){const n=ai(i.dataset.propGroup??"");i.style.display=!t.searching||!n||t.groups.includes(n)?"":"none"}for(const i of Array.from(o.querySelectorAll("[data-prop-key]")))i.style.display=!t.searching||t.keys.has(i.dataset.propKey??"")?"":"none"}function Hs(o){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:o.state.propSearch??"",onInput:e=>{const t=e.target,i=t.value;o.state.propSearch=i,Wn(t.getRootNode(),i)}})])}const Ws={Document:"≡",Brush:"◧",Setting:"⚙"};function Us(o,e){try{const t=window.localStorage.getItem(`property-group-${o}`);return t===null?e:t==="true"}catch{return e}}function Gs(o,e){try{window.localStorage.setItem(`property-group-${o}`,String(e))}catch{}}function xe(o,e,t,i,n,r=!0){const s=Us(e,r);return Bs(o,e,a("div",{class:`property-group${s?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{Gs(e,!s),o.repaint()}},[a("span",{class:"group-icon",text:Ws[i]||"•"}),a("span",{class:"group-title",text:t}),a("span",{class:"expand-icon",text:s?"▾":"▸"})]),a("div",{class:"group-content",style:s?"":{display:"none"}},n.filter(Boolean))]))}function lo(o){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},o.filter(Boolean))}function Un(o){return o.split(".").flatMap(e=>{const t=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!t)return[e];const i=t[1],n=[...t[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function sn(o,e){return Un(e).reduce((n,r)=>n==null?"":n[r],o)??""}function si(o,e,t,i){const n=Un(t),r=n.pop(),s=n.reduce((l,c)=>((l[c]===void 0||l[c]===null)&&(l[c]={}),l[c]),e);s[r]=i||void 0,o.recordHistory(),o.emit()}function qs(o,e){const t=o.store;if(e.printElementType.type==="table"&&t.tableSelection?.elementId===e.id){const{r1:i,c1:n}=t.tableSelection,r=(e.options.tableRows??[])[i];if(r)return p.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return p.getElementBindings(e)}function Ks(o,e){const t=document.createElement("label");t.className="pd-button small upload-label",fe(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),t);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",t.append(i,n);const r=c=>{t.className=`pd-button small upload-label${c?" disabled":""}`,n.disabled=c};n.addEventListener("change",async()=>{const c=n.files?.[0];if(!c)return;if(!c.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=o.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(c);h?si(o.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!o.host.uploadImage),n.value=""}}),o.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(t,l),s}function js(o,e){const t=i=>o.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:sn(e,i.targetPath)});return xe(o,"binding","内容","Document",[...qs(o,e).map(i=>B(i.label,a("input",{class:"pd-input",type:"text",value:sn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>si(o.store,e,i.targetPath,n.target.value),onDblclick:()=>t(i)}))),e.printElementType.type==="image"?Ks(o,e):""].filter(Boolean))}const Ct=new Map;function Zt(o){return`${Math.round(o*1e4)/1e4}%`}function Gn(o,e){const t=p.parseCropAnchor(e.value),i=t.kind==="custom",n=t.kind==="axes"?t.x:50,r=t.kind==="axes"?t.y:50,s=p.resolveCropPreview(e.src),l=Ct.get(s.src),c={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},u=p.resolveCropTravel(c),h=p.cropWindow(c,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const w of p.cropPresetOptions(u,n,r)){const T=document.createElement("option");T.value=w.value,T.textContent=w.label,m.appendChild(T)}if(i){const w=document.createElement("option");w.value="custom",w.textContent="自定义(保留原值)",m.appendChild(w)}m.value=i?"custom":`${n},${r}`,m.selectedIndex<0&&(m.selectedIndex=i?m.options.length-1:0),m.addEventListener("change",()=>{if(m.value==="custom")return;const[w,T]=m.value.split(",").map(Number);e.onCommit(p.buildCropAnchor(w,T))});const g=p.propertyTip(e.fieldKey),v=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,Go(g)]),e.resetAnchor??""].filter(Boolean)),m])];v.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[p.CROP_SCALE_LABEL,Go(p.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),I({value:e.scale,min:p.CROP_SCALE_MIN,max:p.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:w=>e.onScaleCommit(w>p.CROP_SCALE_MIN?w:void 0)})]));for(const w of p.cropAxisFields(u,n,r))v.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:w.label}),I({value:w.value,min:0,max:100,step:1,onCommit:T=>e.onCommit(p.buildCropAnchor(w.name==="horizontal"?T:n,w.name==="vertical"?T:r))})]));const b=p.cropAxisNote(u,i);return b&&v.push(a("p",{class:"pd-crop-note",text:b})),s.isSample&&v.push(a("p",{class:"pd-crop-note",text:p.CROP_SAMPLE_NOTE})),v.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:s.src,alt:s.isSample?"示例图":"原图",onLoad:w=>{const T=w.target;if(!(T.naturalWidth>0&&T.naturalHeight>0))return;const k=Ct.get(s.src);k&&k.width===T.naturalWidth&&k.height===T.naturalHeight||(Ct.set(s.src,{width:T.naturalWidth,height:T.naturalHeight}),o.repaint())},onError:()=>{Ct.has(s.src)&&(Ct.delete(s.src),o.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:Zt(h.leftPct),top:Zt(h.topPct),width:Zt(h.widthPct),height:Zt(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},v)}const Ze=o=>Number(o??0),qo=o=>o||void 0;function bt(o,e,t,i,n){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:o}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,onChange:r=>t(r.target.checked)})])}function qn(o,e,t,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:s=>i(s.target.value)},t.map(s=>a("option",{value:s.value,text:s.label,selected:s.value===e})))])}function At(o,e,t,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:o}),n.reset??""].filter(Boolean)),Bn(e,t,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Dt=o=>a("p",{class:"pd-hint",text:o}),Ys="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Vs=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Xs=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Zs=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Qs=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Js={value:"__multi__",label:"多选",disabled:!0};function el(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return xe(o,"table-row","行属性","Grid",[]);const s=l=>t.updateElement(e.id,l);return xe(o,"table-row","行属性","Grid",[lo([qn("行类型",r.type,Vs,l=>{const c=p.setRowType(n,i.r1,l);if(c){window.alert(c);return}s({tableRows:n})},!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"行高 (mm)"}),I({value:r.height,min:3,max:100,step:.5,onCommit:l=>{r.height=l,s({tableRows:n})}})]),r.type==="header"?bt("表头每页重复",r.repeatOnPage??!1,l=>{p.setHeaderRepeat(n,l),s({tableRows:n})},Ys):""])])}function tl(o,e){const t=o.store,i=e.options,n=h=>t.updateElement(e.id,h),r=i.tableColWidths??[],s=t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right,l=t.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),c=p.createDefaultOptions("table"),u=h=>tt({target:i,base:c,propKey:h,write:()=>n({[h]:c[h]})});return xe(o,"table-settings","表格设置","Grid",[lo([qn("列表数据源字段",i.dataSource??"",l,h=>n({dataSource:h||void 0}),!0),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字体"}),u("tableDefaultFontFamily")]),so({id:"table-default-font",state:o.state,fonts:o.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),I({value:Ze(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Ae(i.tableDefaultColor,h=>n({tableDefaultColor:h}),"默认文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认内边距 (mm)"}),u("tableDefaultPadding")]),I({value:Ze(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:qo(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"列宽 (mm)"}),...r.map((h,m)=>a("div",{class:"col-width-row"},[a("span",{style:{width:"60px"},text:`列${m+1}`}),I({value:h,min:5,max:200,onCommit:g=>{const v=r.reduce((b,w,T)=>T===m?b:b+w,0);if(v+g>s){const b=Math.max(5,Math.round((s-v)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${m+1} 已调整为 ${b}mm`),r[m]=b}else r[m]=g;n({tableColWidths:r})}})]))])])])}function ol(o,e){const t=o.store,i=e.options,n=e.printElementType.type==="table",r=l=>t.updateElement(e.id,l),s=[];if(n)s.push(_(o,"pg-enabled",bt("启用分页",i.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=i.pagination?.pageable??!0,c=i.pagination?.keepWithNext??!1;s.push(_(o,"pg-pageable",bt("参与分页",l,u=>r({pagination:{pageable:u,keepWithNext:c}})))),s.push(_(o,"pg-keep-with-next",bt("与下元素同页",c,u=>r({pagination:{pageable:l,keepWithNext:u}}))))}return xe(o,"pagination","分页配置","Document",[lo(s)],!1)}const Po=new WeakMap,ln=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function il(o,e){const t=o.store,i=t.tableSelection,n=e.options.tableRows??[];if(!i)return xe(o,"table-cell","单元格","Menu",[]);const r=p.findMainCell(n,i.r1,i.c1),s=n[r.r]?.cells[r.c];if(!s)return xe(o,"table-cell","单元格","Menu",[]);const l=()=>p.collectWritableCells(n,i),c=p.resolveCellGroupMode(n,i),u=c.count,h=c.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=Po.get(t),v=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&Po.set(t,v);const b=x=>{Po.set(t,{key:m,border:x.border??v.border,values:x.values??v.values,edges:x.edges??v.edges})},w=(x,O)=>{b({border:{...v.border,[x]:O}}),o.repaint()},T=(x,O)=>{l().forEach(x),h&&O&&b({values:{...v.values,...O}}),t.updateElement(e.id,{tableRows:n})},k=(x,O)=>{T(Q=>{Q[x]=O},{[x]:O})},z=x=>h?v.values[x]:s[x],W=x=>h&&x in v.values,P=h?{width:void 0,style:void 0,color:void 0}:p.resolveCellBorderDisplay(n,i),ne=!h&&l().some(x=>!!x.borders&&!!(x.borders.top||x.borders.right||x.borders.bottom||x.borders.left)),ye=!h&&!ne,Y={width:ye?0:typeof P.width=="number"?P.width:p.DEFAULT_BORDER.width,style:ye?"none":typeof P.style=="string"&&P.style!=="mixed"?P.style:p.DEFAULT_BORDER.style,color:typeof P.color=="string"&&P.color!=="mixed"?P.color:p.DEFAULT_BORDER.color,...v.border},F="__mixed__",M={style:!h&&P.style==="mixed",width:!h&&P.width==="mixed",color:!h&&P.color==="mixed"},G=M.style&&!("style"in v.border),V=M.width&&!("width"in v.border),ce=M.color&&!("color"in v.border),Z=G||V||ce,y=G?F:Y.style,H=V?void 0:Y.width,ae=ce?void 0:Y.color,Fe=x=>{const O={style:x};x!=="none"&&H===0?O.width=p.DEFAULT_BORDER.width:x==="none"&&!ne&&(O.width=0),b({border:{...v.border,...O}}),o.repaint()},L=()=>({...Y}),ee=h?ln.reduce((x,O)=>(x[O.value]=v.edges[O.value]?"on":"off",x),{}):p.resolveBorderEdgeStates(l().map(x=>x.borders)),Ge=h?"cellType"in v.values?v.values.cellType??"text":p.resolveSharedCellType(n,i):s.cellType??"text",pe=Ge==="barcode",qe=Ge==="qrcode",ot=Ge==="image",U=Ge==="text",co=pe&&!!z("printerDpi"),Ft=p.barcodeBarWidthRecommendText(z("printerDpi"),z("barWidth")),Lt=h?v.values.textFit:p.resolveCellTextFit(s),po=h?"cellType"in v.values?v.values.cellType??"text":"":s.cellType||"text",Ke=x=>h?[Js,...x]:x,we=x=>h?"多选":x,Se=(x,O)=>h?v.values[x]:O,uo=h?z("barcodeType")??"__multi__":s.barcodeType||"CODE128",It=h?W("printerDpi")?z("printerDpi")?String(z("printerDpi")):"":"__multi__":s.printerDpi?String(s.printerDpi):"",q=h?z("qrCodeLevel")??"__multi__":s.qrCodeLevel||"M",xt=h?z("fit")??"__multi__":s.fit||"contain",K=Lt??"__multi__",it=p.canMergeReason(n,i);let ue=!1;for(let x=i.r1;x<=i.r2&&!ue;x++)for(let O=i.c1;O<=i.c2&&!ue;O++){const Q=n[x]?.cells[O];Q&&!Q.merged&&((Q.rowspan??1)>1||(Q.colspan??1)>1)&&(ue=!0)}const Te=(x,O,Q,te={},De)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:x}),De??""].filter(Boolean)),I({value:O,...te,onCommit:yt=>k(Q,qo(yt))})]),Ot="恢复默认值(跟随表格默认)",N=x=>tt({target:s,base:{},propKey:x,tipOverride:Ot,force:h,write:()=>k(x,void 0)}),vt=e.options.tableDefaultPadding??1,nt={width:p.cellFitWidthMm(e.options.tableColWidths??[],r.c,s,vt),height:p.cellFitCapMm(n,r.r,s,vt)};return xe(o,"table-cell","单元格","Menu",[lo([h?Dt(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),Ue("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],po,x=>{const O=x==="text"?void 0:x,Q={cellType:x};x!=="barcode"&&Object.assign(Q,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),x!=="qrcode"&&Object.assign(Q,{qrCodeLevel:void 0,qrQuietZone:void 0}),T(te=>{te.cellType=O,x!=="barcode"&&(te.barcodeType=void 0,te.showBarcodeText=void 0,te.printerDpi=void 0,te.barQuietZone=void 0,te.barHeight=void 0),x!=="qrcode"&&(te.qrCodeLevel=void 0,te.qrQuietZone=void 0)},Q)})]),pe?At("码制",uo,Ke(Xs),x=>{x!=="__multi__"&&k("barcodeType",x||void 0)}):"",pe?bt("显示文本",h?v.values.showBarcodeText===!0:s.showBarcodeText!==!1,x=>k("showBarcodeText",x),void 0,N("showBarcodeText")):"",pe?Te("条宽(倍率)",Se("barWidth",s.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:we("")},N("barWidth")):"",pe?Dt((co?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Ft?`。${Ft}`:"")):"",pe?Ce("静区 (模块)",I({value:Se("barQuietZone",s.barQuietZone),min:0,max:20,placeholder:we("默认 10"),onCommit:x=>k("barQuietZone",x)}),p.propertyTip("cd-bar-quiet-zone"),N("barQuietZone")):"",pe?Ce("条高 (mm)",I({value:Se("barHeight",s.barHeight),min:1,max:100,placeholder:we("默认 30 模块"),onCommit:x=>k("barHeight",x??void 0)}),p.propertyTip("cd-bar-height"),N("barHeight")):"",pe?Te("文本字号(相对条高,条高为 30)",Se("barFontSize",s.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:we("默认 10")},N("barFontSize")):"",pe?At("打印机分辨率",It,Ke([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),x=>{if(x==="__multi__")return;const O=Number(x);k("printerDpi",O>0?O:void 0)},{reset:N("printerDpi")}):"",pe?Dt("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",qe?At("纠错级别",q,Ke(Zs),x=>{x!=="__multi__"&&k("qrCodeLevel",x||void 0)},{reset:N("qrCodeLevel")}):"",qe?Ce("静区 (模块)",I({value:Se("qrQuietZone",s.qrQuietZone),min:0,max:8,placeholder:we("默认 0"),onCommit:x=>k("qrQuietZone",x)}),p.propertyTip("cd-quiet-zone"),N("qrQuietZone")):"",pe?Dt("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",qe||ot?At("缩放模式",xt,Ke(p.IMAGE_FIT_OPTIONS),x=>{x!=="__multi__"&&k("fit",x)},{reset:N("fit")}):"",ot&&!h&&s.fit==="cover"?Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(s.formatter),fit:s.fit,containerClass:"pd-cell-anchor",widthMm:nt.width,heightMm:nt.height,scale:s.fitScale,value:s.objectPosition,onCommit:x=>k("objectPosition",x),onScaleCommit:x=>k("fitScale",x),resetAnchor:N("objectPosition"),resetScale:N("fitScale")}):"",pe||qe||ot?Te("最大宽度 (mm)",Se("maxWidth",Ze(s.maxWidth)),"maxWidth",{min:0,max:200,placeholder:we("默认")},N("maxWidth")):"",pe||qe||ot?Te("最大高度 (mm)",Se("maxHeight",Ze(s.maxHeight)),"maxHeight",{min:0,max:200,placeholder:we("默认")},N("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?z("formatter")??"":s.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:x=>k("formatter",x.target.value||void 0),onDblclick:()=>o.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),N("align")]),Ue("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?v.values.align??"":s.align||"left",x=>k("align",x))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),N("valign")]),Ue("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?v.values.valign??"":s.valign||"top",x=>k("valign",x))]),a("div",{class:"cell-style-grid"},[a("div",{class:"pd-field cell-font-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"字体"}),N("fontFamily")]),so({id:"cell-font",state:o.state,fonts:o.host.fonts,value:h?z("fontFamily"):s.fontFamily,placeholder:we("继承默认"),onChange:x=>k("fontFamily",x)})]),Te("字号 (pt)",Se("fontSize",Ze(s.fontSize)),"fontSize",{min:0,max:72,placeholder:we("默认")},N("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),N("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?v.values.fontWeight==="bold":s.fontWeight==="bold",onChange:x=>k("fontWeight",x.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),N("color")]),Ae(h?z("color"):s.color,x=>k("color",x),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),N("backgroundColor")]),Ae(h?z("backgroundColor"):s.backgroundColor,x=>k("backgroundColor",x),"背景颜色")])]),Pe("边框"),a("div",{class:"border-style-row"},[Bn(y,[...G?[{value:F,label:"混合",disabled:!0}]:[],...p.BORDER_LINE_STYLES],x=>{x!==F&&Fe(x)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[I({value:H,min:.25,max:5,step:.25,placeholder:h?"多选":V?"混合":void 0,onCommit:x=>w("width",x)})]),Ae(ae,x=>w("color",x),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([x,O])=>a("button",{type:"button",class:"pd-button small",text:O,onClick:()=>{p.applyBorderPreset(n,i,Y.style==="none"?"none":x,L()),t.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},ln.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:x.value,checked:ee[x.value]==="on",indeterminate:ee[x.value]==="mixed",onChange:O=>{const te=O.target.checked&&Y.style!=="none";h&&b({edges:{...v.edges,[x.value]:te}}),T(De=>{p.setCellBorderEdge(De,x.value,te?L():null)})}}),a("span",{text:x.label})]))),Dt(h?p.CELL_BORDER_APPLY_HINT_MULTI:Z?p.CELL_BORDER_APPLY_HINT_MIXED:p.CELL_BORDER_APPLY_HINT),Te("内边距 (mm)",Se("padding",Ze(s.padding)),"padding",{min:0,max:10,step:.5,placeholder:we("默认")},N("padding")),bt("自动换行",h?v.values.wordWrap===!0:s.wordWrap??!0,x=>k("wordWrap",x),void 0,N("wordWrap")),U?At("文字溢出",K,Ke(Qs),x=>{x!=="__multi__"&&k("textFit",x)},{full:!0,reset:N("textFit")}):"",U&&Lt==="shrink"?Te("最小字号 (pt)",Se("shrinkMinFontSize",Ze(s.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:we("默认 6")},N("shrinkMinFontSize")):"",a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!it,title:it||"",onClick:()=>{p.mergeCells(n,i),t.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!ue,onClick:()=>{p.splitCells(n,i),t.updateElement(e.id,{tableRows:n})}})])])])}const Fo=A.WATERMARK_DENSITY_PRESETS;function Ko(o){const e=o.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function nl(o){return o?o.mode==="binding"?o.binding??"":o.content??"":""}function rl(o){const e=o.store.templateData.watermark,t=nl(e),i=e?.mode==="binding"||t!==""&&Ko(t),n=(()=>{const u=e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(Fo))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={testData:e?.testData??"",rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight,timestamp:e?.timestamp,format:e?.format};o.store.updateTemplateData({watermark:{...h,...u}})},s=()=>o.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:t}),l={rotate:e?.rotate??A.WATERMARK_DEFAULTS.rotate,color:e?.color||A.WATERMARK_DEFAULTS.color,opacity:e?.opacity??A.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight},c=u=>tt({target:l,base:A.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:A.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[Pe("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:t,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(Ko(h)?{mode:"binding",binding:h,content:""}:{mode:"fixed",content:h,binding:""})},onDblclick:s}),a("button",{type:"button",class:"pd-button small",text:"编辑表达式",onClick:s})]),i?B("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),c("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??A.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??A.WATERMARK_DEFAULTS.rotate}°`})]),B("颜色",Ae(e?.color||A.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,c("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),c("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??A.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??A.WATERMARK_DEFAULTS.opacity).toFixed(2)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"密度"}),a("select",{class:"pd-select",style:{width:"100%"},onChange:u=>{const h=u.target.value,m=Fo[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(Fo).map(([u,h])=>a("option",{value:u,text:`${h.label}(${h.width}×${h.height})`,selected:n===u})),a("option",{value:"custom",text:"自定义",selected:n==="custom"})])]),n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片宽"}),c("tileWidth")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??A.WATERMARK_DEFAULTS.tileWidth),onChange:u=>r({tileWidth:Number(u.target.value)})})]):"",n==="custom"?a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"瓦片高"}),c("tileHeight")]),a("input",{type:"number",class:"pd-input",min:A.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??A.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function de(o,e,t,i,n={},r){return B(e,I({value:t,...n,onCommit:i}),void 0,r)}function We(o,e,t,i,n,r,s){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>n(l.value));for(const c of i){const u=document.createElement("option");u.value=c.value,u.textContent=c.label,l.appendChild(u)}return l.value=t,i.some(c=>c.value===t)||(l.selectedIndex=-1),r?Ce(e,l,r,s):B(e,l,void 0,s)}function ht(o,e,t,i,n){return B(e,a("input",{type:"checkbox",class:"pd-switch",checked:t,onChange:r=>i(r.target.checked)}),void 0,n)}const al=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],sl=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function ll(o,e){const t=o.store,i=e.options,n=e.printElementType.type,r=y=>t.updateElement(e.id,y),s=n==="text"||n==="longText",l=n==="barcode"||n==="qrcode",c=n==="table",u=c&&t.tableSelection?.elementId===e.id,h=u&&p.resolveCellGroupMode(e.options.tableRows??[],t.tableSelection).mode==="multi",m=[];u||m.push(xe(o,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"position-grid"},[_(o,"ps-left",de(o,"X",i.left,y=>r({left:y}),{min:0})),_(o,"ps-top",de(o,"Y",i.top,y=>r({top:y}),{min:0})),_(o,"ps-width",de(o,"W",i.width,y=>r({width:y}),{min:4})),_(o,"ps-height",de(o,"H",i.height,y=>r({height:y}),{min:4}))])])]));const g=p.createDefaultOptions(n),v=(y,H)=>{const ae=p.propertyDefault(H);return tt({target:i,base:g,propKey:y,tipValue:ae?.value,tipUnit:ae?.unit,write:()=>r({[y]:g[y]})})},b=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?p.normalizeRotationAngle(i.rotate):void 0,w=y=>r({rotate:y===void 0||y===0?void 0:p.normalizeRotationAngle(y)}),T=p.isFreeAngleEditable(n,i),k=p.isRotationExcludedType(n)||p.collectFollowMemberIds(t.elements).has(e.id),z=k?"":_(o,"ap-rotate",Ce("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>w((b??0)-90)}),a("div",{class:"pd-rotate-stepper"},[I({value:b,min:0,max:359,placeholder:"0",disabled:!T,onCommit:y=>w(y)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>w((b??0)+90)})]),p.propertyTip("ap-rotate"),v("rotate","ap-rotate"))),W=k||T?"":a("p",{class:"pd-hint pd-rotate-note",text:p.CODE_OBLIQUE_NOTE});if(m.push(xe(o,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},s?[_(o,"ap-font-family",B("字体",so({id:"prop-font",state:o.state,fonts:o.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:y=>r({fontFamily:y})}),void 0,v("fontFamily","ap-font-family"))),_(o,"ap-font-size",de(o,"字体大小",i.fontSize,y=>r({fontSize:y}),{min:8,max:72},v("fontSize","ap-font-size"))),_(o,"ap-font-weight",We(o,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],y=>r({fontWeight:y}),void 0,v("fontWeight","ap-font-weight"))),_(o,"ap-align",B("对齐",Ue("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",y=>r({textAlign:y})),void 0,v("textAlign","ap-align"))),_(o,"ap-vertical-align",B("垂直对齐",Ue("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",y=>r({verticalAlign:y})),void 0,v("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[_(o,"ap-color",B("颜色",Ae(i.color,y=>r({color:y}),"字体颜色"),void 0,v("color","ap-color"))),_(o,"ap-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","ap-bg-color")))]),_(o,"ap-line-height",de(o,"行高",i.lineHeight,y=>r({lineHeight:y||void 0}),{min:0,max:100},v("lineHeight","ap-line-height"))),_(o,"ap-letter-spacing",de(o,"字间距",i.letterSpacing,y=>r({letterSpacing:y||void 0}),{min:0,max:20,step:.5},v("letterSpacing","ap-letter-spacing"))),_(o,"ap-text-fit",We(o,"文字溢出",p.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],y=>r({textFit:y}),void 0,v("textFit","ap-text-fit"))),i.textFit==="shrink"?_(o,"ap-shrink-min",B("最小字号 (pt)",I({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:y=>r({shrinkMinFontSize:y||void 0})}),void 0,v("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?_(o,"ap-long-text-indent",Ce("首行缩进 (字符)",I({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:y=>r({longTextIndent:y||void 0})}),p.propertyTip("ap-long-text-indent"),v("longTextIndent","ap-long-text-indent"))):"",_(o,"ap-word-wrap",ht(o,"自动换行",i.wordWrap!==!1,y=>r({wordWrap:y?void 0:!1}),v("wordWrap","ap-word-wrap"))),_(o,"ap-keep-line-breaks",ht(o,"保留换行符",i.keepLineBreaks===!0,y=>r({keepLineBreaks:y?!0:void 0}),v("keepLineBreaks","ap-keep-line-breaks"))),z,W]:[n==="image"?_(o,"ap-img-fit",We(o,"缩放模式",String(i.fit??"contain"),p.IMAGE_FIT_OPTIONS,y=>r({fit:y}),p.propertyTip("ap-img-fit"),v("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?_(o,"ap-img-object-position",Gn(o,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:p.resolveDesignImageSrc(i.src),widthMm:Number(i.width)||0,heightMm:Number(i.height)||0,fit:i.fit,scale:i.fitScale,value:i.objectPosition===void 0?void 0:String(i.objectPosition),onCommit:y=>r({objectPosition:y}),onScaleCommit:y=>r({fitScale:y}),resetAnchor:v("objectPosition","ap-img-object-position"),resetScale:v("fitScale","ap-img-fit-scale")})):"",z,W,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),l){const y=n==="barcode",H=String(i.barcodeType||"CODE128").toUpperCase(),ae=i.printerDpi?String(i.printerDpi):"",Fe=p.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);m.push(xe(o,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:L=>L.preventDefault()},[y?[_(o,"cd-type",We(o,"码制",H,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],L=>r({barcodeType:L==="CODE128"?void 0:L}))),_(o,"cd-dpi",We(o,"打印机分辨率",ae,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],L=>r({printerDpi:Number(L)>0?Number(L):void 0}),void 0,v("printerDpi","cd-dpi"))),_(o,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),_(o,"cd-bar-width",de(o,"条宽(倍率)",i.barWidth??2,L=>r({barWidth:L}),{min:2,max:8,step:.5},v("barWidth","cd-bar-width"))),_(o,"cd-bar-width",a("p",{class:"pd-hint",text:(ae?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Fe?`。${Fe}`:"")})),_(o,"cd-bar-quiet-zone",Ce("静区 (模块)",I({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:L=>r({barQuietZone:L})}),p.propertyTip("cd-bar-quiet-zone"),v("barQuietZone","cd-bar-quiet-zone"))),_(o,"cd-bar-height",Ce("条高 (mm)",I({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:L=>r({barHeight:L??void 0})}),p.propertyTip("cd-bar-height"),v("barHeight","cd-bar-height"))),_(o,"cd-show-text",ht(o,"显示文本",i.hideTitle!==!0,L=>r({hideTitle:L?void 0:!0}),v("hideTitle","cd-show-text"))),_(o,"cd-font-size",B("文本字号(相对条高,条高为 30)",I({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:L=>r({fontSize:L||void 0})}),void 0,v("fontSize","cd-font-size")))]:[_(o,"cd-ec-level",We(o,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],L=>r({qrCodeLevel:L}),void 0,v("qrCodeLevel","cd-ec-level"))),_(o,"cd-quiet-zone",Ce("静区 (模块)",I({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:L=>r({qrQuietZone:L})}),p.propertyTip("cd-quiet-zone"),v("qrQuietZone","cd-quiet-zone")))],Pe("自定义设置"),y?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",y?"":_(o,"cd-fit",We(o,"缩放模式",String(i.fit||"contain"),p.IMAGE_FIT_OPTIONS,L=>r({fit:L||void 0}),void 0,v("fit","cd-fit"))),_(o,"cd-max-width",B("最大宽度 (mm)",I({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxWidth:L||void 0})}),void 0,v("maxWidth","cd-max-width"))),_(o,"cd-max-height",B("最大高度 (mm)",I({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:L=>r({maxHeight:L||void 0})}),void 0,v("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(h||m.push(js(o,e)),u&&(m.push(el(o,e)),m.push(il(o,e))),c&&m.push(tl(o,e)),n==="flowList"){const y=p.resolveFlowColumns(i.flowColumns),H=p.resolveFlowRowHeight(i.flowRowHeight),ae=p.resolveFlowGapX(i.flowGapX),Fe=p.resolveFlowMaxSpan(i.flowMaxSpan,y),L=p.suggestFlowColumns(i.width??0,ae,i.fontSize??12);m.push(xe(o,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:ee=>ee.preventDefault()},[_(o,"fl-columns",Ce("每行列数",I({value:y,min:1,max:12,onCommit:ee=>r({flowColumns:p.resolveFlowColumns(ee),flowMaxSpan:p.resolveFlowMaxSpan(i.flowMaxSpan,p.resolveFlowColumns(ee))})}),p.propertyTip("fl-columns"))),_(o,"fl-row-height",Ce("行高 (mm)",I({value:H,min:3,max:100,step:.5,onCommit:ee=>r({flowRowHeight:p.resolveFlowRowHeight(ee)})}),p.propertyTip("fl-row-height"))),_(o,"fl-gap-x",Ce("单元横向间距 (mm)",I({value:ae,min:0,max:50,step:.5,onCommit:ee=>r({flowGapX:p.resolveFlowGapX(ee)})}),p.propertyTip("fl-gap-x"))),_(o,"fl-auto-span",ht(o,"内容过长时跨列",i.flowAutoSpan===!0,ee=>{r(ee?{flowAutoSpan:ee,flowMaxSpan:Fe}:{flowAutoSpan:ee})})),i.flowAutoSpan===!0?_(o,"fl-max-span",Ce("最多跨几列",I({value:Fe,min:1,max:y,onCommit:ee=>r({flowMaxSpan:p.resolveFlowMaxSpan(ee,y)})}),p.propertyTip("fl-max-span"))):"",y>L?a("p",{class:"pd-hint",text:`按当前字号与框宽,${y} 列偏挤(可放约 ${L} 列)。数值保持不变,出纸按 ${y} 列排。`}):""].flat().filter(Boolean))]))}const P=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),ne=y=>{const H=P();p.applyElementBorderPreset(H,y,p.effectiveElementBorderSpec(H)),r(H)},ye=y=>{const H=P();p.setElementBorderEdgeVisible(H,y,!p.elementBorderEdgeVisible(H,y)),r(H)},Y=p.resolveElementBorderDisplay(i),F=Y.style==="mixed",M=typeof Y.width=="number"?Y.width:void 0,G=F||Y.style===void 0?"":Y.style,V=typeof Y.color=="string"?Y.color:void 0,ce=(y,H)=>{const ae=P();p.setElementBorderField(ae,y,H),r(ae)},Z=F?[{value:"",label:"混合"},...p.BORDER_LINE_STYLES]:[...p.BORDER_LINE_STYLES];return m.push(xe(o,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[_(o,"bb-border-style",We(o,"线型",G,Z,y=>ce("borderStyle",y))),a("div",{class:"border-row"},[_(o,"bb-border-width",de(o,"边框宽度",M,y=>ce("borderWidth",y),{min:0,max:20,step:.25,placeholder:Y.width==="mixed"?"混合":void 0},v("borderWidth","bb-border-width"))),_(o,"bb-border-color",B("边框颜色",Ae(V,y=>ce("borderColor",y),"边框颜色"),void 0,v("borderColor","bb-border-color")))]),...p.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},al.map(y=>a("button",{type:"button",class:"pd-button small",text:y.label,disabled:y.value==="inner",onClick:()=>ne(y.value)}))),a("div",{class:"pd-checkbox-group"},sl.map(y=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:p.elementBorderEdgeVisible(i,y.value),onChange:()=>ye(y.value)}),a("span",{text:y.label})]))),a("p",{class:"pd-hint",text:p.ELEMENT_BORDER_APPLY_HINT})]:[],_(o,"bb-bg-color",B("背景色",Ae(i.backgroundColor,y=>r({backgroundColor:y}),"背景颜色"),void 0,v("backgroundColor","bb-bg-color")))])])),m.push(ol(o,e)),m.push(xe(o,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:y=>y.preventDefault()},[a("div",{class:"advanced-row"},[_(o,"ad-locked",ht(o,"锁定",!!i.locked,y=>r({locked:y}),v("locked","ad-locked"))),_(o,"ad-fixed",ht(o,"每页重复",!!i.fixed,y=>r({fixed:y}),v("fixed","ad-fixed")))]),_(o,"ad-z-index",de(o,"层级",i.zIndex,y=>r({zIndex:y}),{min:0,max:999},v("zIndex","ad-z-index"))),_(o,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>t.deleteSelected()})]))])],!1)),a("div",{class:"property-content"},m)}function dl(o){const e=o.store,t=e.templateData,i=c=>e.updateTemplateData(c),n=c=>{const u=t.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(c)!==h(t.outputRotation)){const m=A.computeMaxColumns({...t,outputRotation:c});i({outputRotation:c,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:c})},r=[];for(const[c,u]of Object.entries(p.PAPER_PRESETS)){const h=u.group??"其他";let m=r.find(g=>g.group===h);m||(m={group:h,items:[]},r.push(m)),m.items.push({key:c,label:u.label??c})}const s=!p.PAPER_PRESETS[t.paperSize],l=p.isContinuousPaperSize(t.paperSize);return a("form",{class:"pd-form",onSubmit:c=>c.preventDefault()},[Pe("纸张设置"),B("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:c=>i({paperSize:c.target.value})},[...r.map(c=>a("optgroup",{label:c.group},c.items.map(u=>a("option",{value:u.key,text:u.label,selected:t.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:s})])),l||s?B(l?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[I({value:Number(t.customWidth??0),min:25,max:2e3,onCommit:c=>i({customWidth:c})}),...s?[a("span",{class:"custom-size-x",text:"×"}),I({value:Number(t.customHeight??0),min:25,max:2e3,onCommit:c=>i({customHeight:c})})]:[]])):"",l?"":B("纸张方向",Ue("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],t.orientation==="landscape"?"landscape":"portrait",c=>i({orientation:c})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":B("内容旋转角度",Ue("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(t.outputRotation??0),c=>n(Number(c)),!0),t.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),B("页面背景色",a("div",{class:"page-bg-row"},[Ae(t.pageBackground,c=>i({pageBackground:c}),"页面背景色","page-bg-picker")]),void 0,tt({target:t,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),Fs(o),e.pages.length>1?"":Ls(o),Pe("页边距 (mm)"),a("div",{class:"margin-grid"},[de(o,"上",t.margins.top,c=>i({margins:{...t.margins,top:c}}),{min:0,max:50}),de(o,"下",t.margins.bottom,c=>i({margins:{...t.margins,bottom:c}}),{min:0,max:100}),de(o,"左",t.margins.left,c=>i({margins:{...t.margins,left:c}}),{min:0,max:50}),de(o,"右",t.margins.right,c=>i({margins:{...t.margins,right:c}}),{min:0,max:50})]),Pe("页眉/页脚高度 (mm)"),de(o,"页眉高度",t.header.height??10,c=>i({header:{...t.header,height:c}}),{min:0,max:100,step:.1}),de(o,"页脚高度",t.footer.height??10,c=>i({footer:{...t.footer,height:c}}),{min:0,max:100,step:.1}),rl(o)].filter(Boolean))}function cl(o){const e=o.store,t=o.state,i=e.selectedElement;if(t.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{t.propCollapsed=!1,o.repaint()}}),...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([r,s,l])=>a("button",{type:"button",class:`pc-btn${t.propTab===r?" on":""}`,title:s,text:l,onClick:()=>{t.propTab=r,t.propCollapsed=!1,o.repaint()}}))])]);const n=i?t.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{t.propCollapsed=!0,o.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[a("button",{type:"button",class:`pd-tab${n==="element"?" active":""}`,text:"元素属性",onClick:()=>{t.propTab="element",o.repaint()}}),a("button",{type:"button",class:`pd-tab${n==="page"?" active":""}`,text:"页面属性",onClick:()=>{t.propTab="page",o.repaint()}})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="element"?"":{display:"none"}},i?[Hs(o),ll(o,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",style:n==="page"?"":{display:"none"}},[dl(o)])])])}const Lo=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],dn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},pl=[{name:"SUM",label:"求和",template:"SUM()"},{name:"AVG",label:"平均值",template:"AVG()"},{name:"COUNT",label:"计数",template:"COUNT()"},{name:"MIN",label:"最小值",template:"MIN()"},{name:"MAX",label:"最大值",template:"MAX()"}],ul=[{name:"ADD",label:"相加",template:"ADD()"},{name:"SUB",label:"相减",template:"SUB()"},{name:"MUL",label:"相乘",template:"MUL()"},{name:"DIV",label:"相除",template:"DIV()"},{name:"ROUND",label:"四舍五入",template:"ROUND()"},{name:"ROUNDUP",label:"进一法",template:"ROUNDUP()"},{name:"ROUNDDOWN",label:"去尾法",template:"ROUNDDOWN()"},{name:"ROUNDBANK",label:"四舍六入五成双",template:"ROUNDBANK()"}],hl=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],fl=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],ml=[{title:"聚合函数",items:pl},{title:"数值运算",items:ul},{title:"格式化函数",items:hl}],gl="(输入表达式后预览)",bl="(无法计算)",jo="(表达式错误)";function cn(o,e){if(!o.trim())return gl;try{const t={...p.DEFAULT_DEMO_DATA,...e??{},...A.resolveSystemVariables()},i=p.evaluateTemplate(o,t);return i==null?bl:String(i)}catch{return jo}}function pn(o,e){const t=e.trim().toLowerCase();return t?o.filter(i=>i.label.toLowerCase().includes(t)||i.name.toLowerCase().includes(t)):o}function xl(o,e){const t=o.substring(0,e),i=t.lastIndexOf("{"),n=i!==-1&&!t.slice(i+1).includes("}"),r=t.lastIndexOf("("),s=r!==-1&&!t.slice(r+1).includes(")");return{insideBlock:n,insideParens:s}}function vl(o,e){const t=/^\{\s*([^{}]+?)\s*\}$/.exec(o.trim());if(!t)return null;const i=t[1]??"";return e.find(n=>n.fieldKey===i)??null}function Io(o,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:o}),a("span",{class:"ee-item-key",text:e})])}function Ve(o){return o.currentTarget.getRootNode()}function Qt(o,e,t){const i=[];return t.forEach((n,r)=>{i.push(n),r<t.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${o}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function yl(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[Qt("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","注意:只能嵌套一层"]),Qt("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),Qt("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),Qt("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function wl(o,e){const t={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding},i=(b,w)=>b.querySelector(w),n=b=>{const w=i(b,".ee-preview");if(!w)return;const T=cn(t.expression,o.demoData);w.textContent=T,w.classList.toggle("ee-preview-error",T===jo)},r=()=>{if(t.activeTab==="variable")return pn(fl,t.searchText).map(T=>a("div",{class:"ee-list-item",onDblclick:k=>{const{insideParens:z}=l(k);c(Ve(k),z?T.template.replace(/^\{|\}$/g,""):T.template)}},[Io(T.label,T.template)]));if(t.activeTab==="function")return ml.map(T=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:T.title}),...pn(T.items,t.searchText).map(k=>a("div",{class:"ee-list-item",onDblclick:z=>{const{insideBlock:W}=l(z),P=W?k.template:`{${k.template}}`;c(Ve(z),P,P.indexOf("(")+1)}},[Io(k.label,`${k.name}()`)]))]));const b=p.filterGroups(p.groupFields(o.fields??[]),t.searchText);if(!b.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const w=[];for(const T of b){T.key&&w.push(a("div",{class:`ee-field-group${T.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:T.isList?"📋":"📁"}),a("span",{text:T.label})]));for(const k of T.fields)w.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:T.key?"22px":"10px"},onDblclick:z=>{const{insideParens:W}=l(z);c(Ve(z),W?k.fieldKey:`{${k.fieldKey}}`)}},[Io(k.fieldLabel,k.fieldKey)]))}return w},s=b=>{Array.from(b.querySelectorAll(".ee-nav-tab")).forEach((W,P)=>W.classList.toggle("active",Lo[P]?.key===t.activeTab));const T=i(b,".ee-content-search .pd-input");if(T){const W=dn[t.activeTab];T.placeholder!==W&&(T.placeholder=W),T.value!==t.searchText&&(T.value=t.searchText)}const k=i(b,".ee-textarea");k&&k.value!==t.expression&&(k.value=t.expression);const z=i(b,".ee-content-list");if(z){Tn(z);for(const W of r())fe(W,z)}n(b)},l=b=>{const T=i(Ve(b),".ee-textarea")?.selectionStart??t.expression.length;return xl(t.expression,T)},c=(b,w,T=w.length)=>{const k=i(b,".ee-textarea");if(!k){t.expression+=w,n(b);return}const z=k.selectionStart??t.expression.length,W=k.selectionEnd??z;t.expression=t.expression.substring(0,z)+w+t.expression.substring(W);const P=z+T;k.value=t.expression,k.focus(),k.selectionStart=k.selectionEnd=P,n(b)},u=()=>{const b=t.expression;if(t.binding===void 0){o.onApply({formatter:b}),o.onClose();return}const w=vl(b,o.fields??[]);o.onApply(w?{formatter:b,binding:w.fieldKey,title:w.fieldLabel}:{formatter:b}),o.onClose()},h=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},Lo.map((b,w)=>a("div",{class:`ee-nav-tab${t.activeTab===b.key?" active":""}`,text:b.text,onClick:T=>{t.activeTab=Lo[w].key,s(Ve(T))}})))]),m=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:dn[t.activeTab],onInput:b=>{t.searchText=b.target.value,s(Ve(b))}})]),a("div",{class:"ee-content-list"},r())]),g=cn(t.expression,o.demoData),v=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,或直接输入静态内容",text:t.expression,onInput:b=>{t.expression=b.target.value,n(Ve(b))}})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${g===jo?" ee-preview-error":""}`,text:g})]),yl()]);return a("div",{class:"pd-dialog-overlay",onKeydown:b=>{b.key==="Escape"&&o.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"expression-editor"},[h,m,v]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>o.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>u()})])])])}const Sl={id:"getting-started",title:"快速入门",content:`
|
|
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)&>(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")&>(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:`
|
|
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
|
-
`},
|
|
43
|
+
`},Ts={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
|
-
`},
|
|
214
|
+
`},Es={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
|
-
`},
|
|
284
|
+
`},ks={id:"faq",title:"常见问题",content:`
|
|
285
285
|
<h2>如何调整纸张大小?</h2>
|
|
286
286
|
<ol>
|
|
287
287
|
<li>在右侧面板选择"页面设置"</li>
|
|
@@ -415,7 +415,26 @@ 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
|
-
`},
|
|
418
|
+
`},Cs={id:"changelog",title:"更新记录",content:`
|
|
419
|
+
<h2>V1.4.2<small>(2026-10-30)</small></h2>
|
|
420
|
+
|
|
421
|
+
<h3>新增</h3>
|
|
422
|
+
<ul>
|
|
423
|
+
<li><strong>素材台单击字段复制中文名</strong>:单击素材台字段行复制字段名并提示「已复制」(拖拽起手不触发);表达式弹窗里每个字段行右侧新增复制图标,点击后短暂变对勾。字段名需要当静态文本复用时不用再手打。</li>
|
|
424
|
+
<li><strong>字段名当静态文本的两条 Ctrl 入口</strong>:表达式弹窗里按住 Ctrl(Mac 为 ⌘)双击字段插入字段中文名,函数参数内自动加引号;素材台按住 Ctrl 拖动字段到画布,直接生成内容为字段中文名的文本元素。不按 Ctrl 仍是原来的取值绑定。</li>
|
|
425
|
+
</ul>
|
|
426
|
+
|
|
427
|
+
<h3>变更</h3>
|
|
428
|
+
<ul>
|
|
429
|
+
<li><strong>属性台「内容」分组置顶</strong>:「内容」(绑定表达式、图片上传)移到第一个分组,位置与尺寸、外观、条码设置顺延,改文本或图片不用再往下找。</li>
|
|
430
|
+
</ul>
|
|
431
|
+
|
|
432
|
+
<h3>修复</h3>
|
|
433
|
+
<ul>
|
|
434
|
+
<li><strong>竖线不再挤占表格所在列、把明细拆成两页</strong>:表格旁的竖线此前按画布编辑盒宽度计算横向占用,与表格被误判为同列后占走版面,10 条明细会被拆成 2 页且竖线看起来消失。现在按描边宽度计算,明细回到单页。</li>
|
|
435
|
+
<li><strong>流式列表双击可打开表达式编辑器</strong>:此前双击只选中、不弹框,现在双击元素框或内部任一单元格都会弹出表达式编辑器并预填模板。</li>
|
|
436
|
+
</ul>
|
|
437
|
+
|
|
419
438
|
<h2>V1.4.1<small>(2026-10-28)</small></h2>
|
|
420
439
|
|
|
421
440
|
<h3>修复</h3>
|
|
@@ -762,6 +781,6 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
762
781
|
<blockquote>
|
|
763
782
|
<p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
|
|
764
783
|
</blockquote>
|
|
765
|
-
`},to=[Sl,Tl,El,kl,Cl],Kn="worm-print-help-tab",Al="getting-started";function un(o){return to.some(e=>e.id===o)?String(o):""}function Dl(o){let e=null;try{e=window.localStorage.getItem(Kn)}catch{e=null}return un(e)||un(o)||Al}function Ml(o){const e=Dl(o.initialTab),t=(i,n)=>{const r=i.currentTarget,s=r.closest(".help-modal");if(!s)return;for(const c of Array.from(s.querySelectorAll(".help-tab")))c.classList.toggle("active",c===r);const l=s.querySelector(".help-content");l&&(l.innerHTML=to.find(c=>c.id===n)?.content??"");try{window.localStorage.setItem(Kn,n)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:i=>{i.target===i.currentTarget&&o.onClose()},onKeydown:i=>{i.key==="Escape"&&o.onClose()}},[a("div",{class:"help-modal"},[a("div",{class:"help-modal-header"},[a("div",{class:"help-modal-title-wrap"},[a("h2",{class:"help-modal-title",text:"帮助文档"}),a("span",{class:"help-modal-project",text:"worm-vue3-print"})]),a("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>o.onClose()})]),a("div",{class:"help-modal-body"},[a("div",{class:"help-modal-sidebar"},to.map(i=>a("button",{type:"button",class:`help-tab${i.id===e?" active":""}`,text:i.title,onClick:n=>t(n,i.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:to.find(i=>i.id===e)?.content??""})])])])])}function _l(o,e){const t=fe(Ml(e),o),i=n=>{n.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",i),t.focus?.(),()=>{document.removeEventListener("keydown",i),t.remove()}}const Rl=2,zl=74,Yo=[{id:"clipboard",order:1,label:"剪贴板"},{id:"painter",order:2,label:"格式刷"},{id:"zoom",order:3,label:"缩放"},{id:"arrange-view",order:4,label:"排列 / 视图"},{id:"border",order:5,label:"边框"},{id:"color",order:6,label:"颜色"},{id:"align",order:7,label:"对齐"},{id:"style",order:8,label:"文字样式"},{id:"font",order:9,label:"字体与字号"}];function Pl(o){const e=!!o.state.openMore,t=Yo.slice().sort((i,n)=>i.order-n.order).map(i=>a("div",{class:"tb-more-item",dataset:{unit:i.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:i.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${i.id}`,dataset:{unit:i.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{o.state.openMore=!e,o.repaint()},html:`${ve("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ve("ChevronDown",12,"tb-dd-arrow")}`}),a("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[a("div",{class:"tb-menu tb-more-menu"},t)])])])}const hn=new WeakMap;function fn(o){const e=o.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const t=getComputedStyle(e),i=Number.parseFloat(t.gap)||Rl,n=Number.parseFloat(t.paddingLeft)||0,r=Number.parseFloat(t.paddingRight)||0,s=new Map;for(const w of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const T=w.parentElement;T&&!T.classList.contains("tb-more-slot")&&hn.set(w,{parent:T,next:w.nextSibling}),s.set(w.dataset.unit,w)}for(const w of s.values()){const T=hn.get(w);!T||w.parentElement===T.parent||(T.next?.parentElement===T.parent?T.parent.insertBefore(w,T.next):T.parent.appendChild(w))}let l=0;for(const w of Array.from(e.children)){if(w.classList.contains("tb-spacer")||w.classList.contains("tb-more-group"))continue;const T=Math.max(w.offsetWidth,w.scrollWidth);T<=0||(l+=T+i)}const c=new Map;for(const[w,T]of s){const k=T.offsetWidth;k>0&&c.set(w,k)}const u=Yo.map(w=>({id:w.id,order:w.order,width:c.get(w.id)??0})),h=u.reduce((w,T)=>w-T.width-i,l),m=e.clientWidth-n-r,{movedIds:g,overflowRemains:v}=p.resolveToolbarOverflow({available:m,pinned:h,moreTriggerWidth:zl,gap:i,units:u});for(const w of Yo){const T=e.querySelector(`.tb-more-item[data-unit="${w.id}"]`),k=e.querySelector(`#tb-more-slot-${w.id}`),z=s.get(w.id);if(!T||!k||!z)continue;const W=g.includes(w.id);W&&z.parentElement!==k&&k.appendChild(z),T.style.display=W?"":"none"}const b=e.querySelector(".tb-more-group");return b&&(b.style.display=g.length>0?"":"none"),e.classList.toggle("is-tight",v),{movedIds:g,overflowRemains:v}}function Fl(o,e){const t=o.store,i=t.selectedIds.size>0,n=t.selectedIds.size>1,r=t.selectedElement,s=!i,l=o.isEdit?"编辑模板":"新建模板",c=[a("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[a("div",{class:"tb-menu-label",text:"对齐 / 分布"}),a("div",{class:"tb-menu-grid"},[J(o,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!n}),J(o,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!n}),J(o,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!n}),J(o,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!n}),J(o,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!n}),J(o,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!n}),J(o,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!n}),J(o,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!n})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[J(o,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!i}),J(o,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!i}),J(o,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!i}),J(o,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!i})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[J(o,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!n}),J(o,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],u=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[h("标尺",t.showRuler,"toggle-ruler","显示/隐藏标尺"),h("网格",t.showGrid,"toggle-grid","显示/隐藏网格背景"),h("虚框",t.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),h("吸附",t.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function h(m,g,v,b){return a("button",{type:"button",class:`tb-btn tb-menu-row${g?" on":""}`,dataset:{tip:b},onClick:()=>o.fire(v)},[a("span",{class:"dot"}),m])}return a("div",{class:"designer-toolbar"},[a("div",{class:"tb-group tb-brand"},[a("span",{class:"tb-mark","aria-hidden":"true",html:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="3" width="14" height="18" rx="2.5" /><line x1="8.5" y1="8.5" x2="15.5" y2="8.5" /><line x1="8.5" y1="12.5" x2="15.5" y2="12.5" /><line x1="8.5" y1="16.5" x2="12.5" y2="16.5" /></svg>'}),a("div",{class:"tb-title"},[a("span",{class:"tb-title-name",text:l}),a("span",{class:"tb-title-sub",text:"打印模板设计器"})])]),a("div",{class:"tb-group"},[J(o,"Undo2","undo",{tip:"撤销",disabled:!t.canUndo}),J(o,"Redo2","redo",{tip:"重做",disabled:!t.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[no(o,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},c),no(o,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},u)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[J(o,"Maximize","fit-window",{tip:"适应窗口"}),J(o,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${t.scale}%`}),J(o,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[J(o,"Copy","copy",{tip:s?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:s,test:"copy"}),J(o,"ClipboardPaste","paste",{tip:s?"粘贴 (Ctrl+V),需选中元素":t.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:s||!t.hasClipboard,test:"paste"}),J(o,"Trash2","delete",{tip:s?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:s,danger:!0,test:"delete"})]),Pl(o),a("div",{class:"tb-spacer"}),o.showHelp?a("div",{class:"tb-group"},[a("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>o.fire("help")},[a("span",{class:"help-icon",text:"?"})])]):"",a("div",{class:"tb-group"},[a("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>o.fire("preview")}),a("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>o.fire("save")})])].filter(Boolean))}function Oo(o,e,t){for(const i of e){const n=o.getPropertyValue(i).trim();if(n)return n}return t}function Ll(o,e){const t=e.orientation==="horizontal",i=e.geom,n=t?i.viewW:i.viewH;o.style.width=`${t?n:p.RULER_THICKNESS}px`,o.style.height=`${t?p.RULER_THICKNESS:n}px`;const r=o.getContext("2d");if(!r)return;const s=window.devicePixelRatio||1,l=Math.max(0,Math.round(n)),c=p.RULER_THICKNESS;o.width=(t?l:c)*s,o.height=(t?c:l)*s,r.setTransform(s,0,0,s,0,0);const u=getComputedStyle(o),h=Oo(u,["--pd-ruler-bg"],"#F8F9FC"),m=Oo(u,["--pd-ruler"],"#9AA1AF"),g=Oo(u,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=h,r.fillRect(0,0,t?l:c,t?c:l);const v=e.scale>0?e.scale:i.paperScale>0?i.paperScale:1,b=p.mmToPx(1)*v;if(b<=0)return;const w={ctx:r,horizontal:t,viewportPx:n,thickness:c,originPx:t?i.originX:i.originY,pxPerMM:b,paperLengthMM:e.paperLengthMM},T=-w.originPx/b,k=(l-w.originPx)/b,z=p.chooseMajorStepMM(v),W=p.buildRulerTicks(T,k,z);mn(w,W,m,!0),mn(w,W,m,!1),gn(w,0,g),gn(w,e.paperLengthMM,g);const P=e.cursorPx??null;if(P!==null&&P>=0&&P<=l){if(r.strokeStyle=g,r.lineWidth=1.5,r.beginPath(),t){const ne=Math.round(P)+.5;r.moveTo(ne,0),r.lineTo(ne,c)}else{const ne=Math.round(P)+.5;r.moveTo(0,ne),r.lineTo(c,ne)}r.stroke()}}function jn(o,e){return Math.round(o.originPx+e*o.pxPerMM)+.5}function mn(o,e,t,i){const{ctx:n,horizontal:r,paperLengthMM:s}=o;n.strokeStyle=t,n.fillStyle=t,n.globalAlpha=i?.32:1,n.lineWidth=1,n.font="9px ui-monospace, Menlo, monospace",n.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>s)!==i)continue;const u=jn(o,l.mm),h=l.major?8:4;n.beginPath(),r?(n.moveTo(u,0),n.lineTo(u,h)):(n.moveTo(0,u),n.lineTo(h,u)),n.stroke(),l.major&&l.label&&(r?n.fillText(l.label,u+2,11):(n.save(),n.translate(11,u+2),n.rotate(-Math.PI/2),n.fillText(l.label,0,0),n.restore()))}n.globalAlpha=1}function gn(o,e,t){const{ctx:i,horizontal:n,thickness:r,viewportPx:s}=o,l=jn(o,e);l<=0||l>=s||(i.strokeStyle=t,i.globalAlpha=.55,i.lineWidth=1,i.beginPath(),n?(i.moveTo(l,0),i.lineTo(l,r)):(i.moveTo(0,l),i.lineTo(r,l)),i.stroke(),i.globalAlpha=1)}const Il=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.left-panel{width:224px;min-width:224px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{display:flex;align-items:center;gap:10px;padding:8px 10px;margin-bottom:7px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;background:var(--pd-field-bg, #f4f6fa);cursor:grab;-webkit-user-select:none;user-select:none;transition:border-color .14s ease,background .14s ease,transform .14s ease,box-shadow .14s ease}.material-card:hover{border-color:#165dff73;background:var(--pd-surface, #ffffff);transform:translateY(-1px);box-shadow:var(--pd-shadow-sm, 0 1px 2px rgba(23, 32, 60, .05))}.material-card:active{cursor:grabbing;transform:translateY(0)}.material-icon{width:30px;height:24px;border:1px dashed var(--pd-border, #d9dde6);border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:11px;color:var(--pd-accent, #165DFF);background:var(--pd-surface, #ffffff);flex-shrink:0;transition:border-color .14s ease,background .14s ease}.material-card:hover .material-icon{border-style:solid;border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.material-label{font-size:12.5px;color:var(--pd-text, #2a2e37)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{margin-top:8px;display:flex;gap:8px}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:280px;min-width:280px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-dirty{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;color:var(--pd-text-muted, #8b909c)}.status-dirty.on{color:var(--pd-accent-secondary, #f56c6c)}.dirty-dot{width:7px;height:7px;border-radius:50%;background:var(--pd-ink-green, #67c23a)}.status-dirty.on .dirty-dot{background:var(--pd-accent-secondary, #f56c6c);box-shadow:0 0 0 3px #f56c6c24;animation:dirty-pulse-a91952ff 1.6s ease-in-out infinite}@keyframes dirty-pulse-a91952ff{0%,to{box-shadow:0 0 0 2px #f56c6c1f}50%{box-shadow:0 0 0 4px #f56c6c0d}}@media(prefers-reduced-motion:reduce){.status-dirty.on .dirty-dot{animation:none}}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',Jt=20,Ol=".page-tabs, .field-tree-panel",Nl=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),$l={text:"formatter",longText:"formatter",barcode:"formatter",qrcode:"formatter",image:"src"},bn="print-studio:left",xn="print-studio:right";function vn(o){try{return localStorage.getItem(o)==="1"}catch{return!1}}function yn(o,e){try{localStorage.setItem(o,e?"1":"0")}catch{}}class Oe extends HTMLElement{root;store;format;unsub=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_fonts;set fonts(e){this._fonts=e,this.applyFontFace(),this.repaint()}get fonts(){return this._fonts}fontFaceStyle=null;docFontFaceStyle=null;constructor(){super(),this.root=this.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=Il,this.root.appendChild(e),fe(a("div",{class:"designer-container",dataset:{test:"designer-container"}}),this.root)}set template(e){this.applyTemplate(e)}get template(){return this.store?.getTemplateJson()}set fields(e){this.store.fields=(typeof e=="string"?JSON.parse(e):e)??[],this.repaint()}set isEdit(e){this.setAttribute("is-edit",String(e)),this.repaint()}set showHelp(e){this.setAttribute("show-help",String(e)),e||this.closeHelp(),this.repaint()}static get observedAttributes(){return["template","fields","name","fonts"]}attributeChangedCallback(e,t,i){if(!i)return;if(e==="name"){this.repaint();return}let n;try{n=JSON.parse(i)}catch{return}e==="template"?this.applyTemplate(n):e==="fields"?(this.store.fields=n,this.repaint()):e==="fonts"&&Array.isArray(n)&&(this.fonts=n)}connectedCallback(){if(this.store){this.applyFontFace(),this.attachDocKeys();return}const e={},t=this.getAttribute("template");if(t)try{e.initialTemplate=JSON.parse(t)}catch{}const i=this.getAttribute("fields");if(i)try{e.initialFields=JSON.parse(i)}catch{}this.store=new kn(e),this.format=new xr(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.bindPointer(),this.bindKeys(),this.attachDocKeys(),this.applyFontFace(),this.repaint(),requestAnimationFrame(()=>this.measureRuler())}readChrome(){this.state.leftCollapsed=vn(bn),this.state.propCollapsed=vn(xn),this.chromeKey=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`}persistChrome(){const e=`${this.state.leftCollapsed?1:0}|${this.state.propCollapsed?1:0}`;e!==this.chromeKey&&(this.chromeKey=e,yn(bn,this.state.leftCollapsed),yn(xn,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Oe.active===this&&(Oe.active=null),On(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null)}applyFontFace(){const e=A.buildFontFaceCss(this._fonts);if(!e){this.fontFaceStyle?.remove(),this.fontFaceStyle=null,this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null;return}this.fontFaceStyle||(this.fontFaceStyle=document.createElement("style"),this.root.appendChild(this.fontFaceStyle)),this.fontFaceStyle.textContent=e,this.docFontFaceStyle||(this.docFontFaceStyle=document.createElement("style"),this.ownerDocument.head.appendChild(this.docFontFaceStyle)),this.docFontFaceStyle.textContent=e}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),t=this.fonts;if(!t?.length)return e;if(Array.isArray(e.pages)){const i=e;return{...i,pages:i.pages.map(n=>({...n,fonts:[...t]}))}}return{...e,fonts:[...t]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const t=this.getGeometryWarnings();t.length&&window.alert(`出纸提示(不影响保存):
|
|
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(`出纸提示(不影响保存):
|
|
766
785
|
${t.join(`
|
|
767
|
-
`)}`);const i=this.templateJsonWithFonts();if(Array.isArray(i.pages))try{A.normalizeTemplate(i)}catch(r){window.alert(r instanceof Error?r.message:String(r));return}const n=JSON.stringify(i);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent("save",{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?A.validateTiling(e):[]}getGeometryWarnings(){return A.collectPrintWarnings(this.store.templateData)}applyTemplate(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(t):this.setAttribute("template",JSON.stringify(t))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(i=>i.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(i=>i.remove());const t=this.exprTarget;fe(wl({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:i=>this.applyExpression(t,i)},t),this.root),this.exprMountedFor=t}openHelp(){this.helpVisible=!0,this.syncHelp()}closeHelp(){this.helpVisible&&(this.helpVisible=!1,this.syncHelp())}syncHelp(){const e=this.helpVisible&&this.getAttribute("show-help")!=="false";if(e&&!this.unmountHelp)this.unmountHelp=_l(this.root,{onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const t=this.unmountHelp;this.unmountHelp=null,t()}}applyExpression(e,t){const i=t.formatter??"",n=e.targetPath;if(n.startsWith("options.")){if(n.includes("[")){const s=this.store.elements.find(l=>l.id===e.elementId);s&&si(this.store,s,n,i);return}const r={[n.slice(8)]:i||void 0};t.title!==void 0&&(r.title=t.title),this.store.updateElement(e.elementId,r);return}if(n==="watermark.content"){const r={...this.store.templateData.watermark};Ko(i)?Object.assign(r,{mode:"binding",binding:i,content:""}):Object.assign(r,{mode:"fixed",content:i,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const t=this.store.elements.find(n=>n.id===e);if(!t||(this.store.selectOne(e),this.state.propTab="element",t.options.locked))return;const i=$l[t.printElementType.type];i&&this.openExpression({elementId:t.id,targetPath:`options.${i}`,value:String(t.options[i]??"")})}dblEditCell(e){const t=this.store.elements.find(l=>l.id===e.elementId);if(!t||(this.store.selectOne(t.id),this.state.propTab="element",t.options.locked))return;const i=t.options.tableRows??[],n=p.findMainCell(i,e.r,e.c),s=i[n.r]?.cells[n.c];s&&this.openExpression({elementId:t.id,targetPath:`options.tableRows[${n.r}].cells[${n.c}].formatter`,value:s.formatter??""})}get ctx(){return{store:this.store,format:this.format,state:this.state,repaint:()=>this.repaint(),fire:(e,t)=>this.fire(e,t),showHelp:this.getAttribute("show-help")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;const e=[...this.store.selectedIds].join(",");e!==this.lastSelKey&&(this.lastSelKey=e,this.state.propTab=e?"element":"page");const t=this.root.querySelector(".designer-container");t.classList.toggle("format-painting",this.format.painterActive),Tn(t);const i=this.ctx;fe(Fl(i,Ts(i)),t),fe(_s(i),t),fe(a("div",{class:"designer-body"},[Cs(i),ns(i,this.canvasUi()),cl(i)]),t),fe(Rs(i),t),fn(t),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>fn(t)),this.toolbarRo.observe(t));const n=Fa(this.store,(r,s)=>this.fire(r,s),this.tableMenu);n&&fe(n,t),sa(this.root,this.store.elements),Wn(this.root,this.state.propSearch),this.applyShrinkFit(),this.syncRulers(),this.persistChrome()}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Vo.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const t=e.getAttribute("data-fit-base");t?e.style.fontSize=`${t}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),t=this.root.querySelector(".hiprint-printPaper");if(!e||!t)return;const i=e.getBoundingClientRect(),n=t.getBoundingClientRect(),r=(this.store.scale||100)/100,s=n.width/p.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(s-r)<.002?r:s,originX:n.left-i.left-Jt+this.scrollPos.x,originY:n.top-i.top-Jt+this.scrollPos.y,viewW:e.clientWidth-Jt,viewH:e.clientHeight-Jt},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,t=p.getPaperDimensions(e),i=this.geom.paperScale;for(const n of Array.from(this.root.querySelectorAll(".pd-ruler"))){const r=n.dataset.ruler==="vertical"?"vertical":"horizontal";Ll(n,{orientation:r,geom:this.geom,scale:i,paperLengthMM:r==="horizontal"?t.width:t.height})}}patchElementDom(){for(const i of this.store.elements){const n=this.root.querySelector(`[data-el-id="${CSS.escape(i.id)}"]`);n&&(n.style.left=`${i.options.left}mm`,n.style.top=`${i.options.top}mm`,n.style.width=`${i.options.width}mm`,n.style.height=`${i.options.height}mm`)}const e=this.root.querySelector(".position-label"),t=this.store.selectedElement;e&&t&&!this.drag&&(e.textContent=Nn(t.options))}fire(e,t){const i=this.store;switch(e){case"undo":i.undo();break;case"redo":i.redo();break;case"align":i.alignSelected(t);break;case"move-layer":i.moveLayer(t);break;case"group":i.groupSelected();break;case"ungroup":i.ungroupSelected();break;case"copy":i.copy();break;case"cut":i.cutSelected();break;case"paste":i.paste();break;case"paste-at":i.paste();break;case"delete":i.deleteSelected();break;case"delete-page":i.deletePage(i.activePageIndex);break;case"add-page":i.addPage();break;case"duplicate-page":i.duplicatePage(i.activePageIndex);break;case"move-page":i.movePage(i.activePageIndex,i.activePageIndex+t);break;case"select-all":i.selectAll();break;case"clear-selection":i.clearSelection();break;case"toggle-ruler":i.showRuler=!i.showRuler,this.repaint();break;case"toggle-grid":i.showGrid=!i.showGrid,this.repaint();break;case"toggle-snap":i.snapToGrid=!i.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":i.showTableGhostBorder=!i.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(t>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent("preview",{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent("help",{bubbles:!0,composed:!0})),this.openHelp();break;case"guide-remove":i.removeGuide(t);break;case"resize-start":this.beginResize(t);break;case"element-mousedown":{const n=t;n.event.button===0&&this.isDoubleTap(`el:${n.id}`,n.event)&&this.fire("element-dblclick",{event:n.event,id:n.id}),this.beginDrag(n);break}case"table-cell-mousedown":{const n=t;this.isDoubleTap(`cell:${n.elementId}:${n.r}:${n.c}`,n.event)&&(this.taps.delete(`el:${n.elementId}`),this.fire("table-cell-dblclick",{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId}));break}case"zone-resize":this.beginZoneResize(t);break;case"guide-mousedown":this.beginGuideDrag(t);break;case"ruler-mousedown":this.beginRulerGuide(t);break;case"canvas-mousedown":this.onCanvasMouseDown(t);break;case"canvas-mousemove":this.onCanvasMouseMove(t);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(t);break;case"contextmenu":this.onElementContextMenu(t);break;case"element-dblclick":{const{id:n}=t;this.dblEditElement(n),this.dispatchEvent(new CustomEvent("dblclick-element",{detail:n,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const n=t;this.dblEditCell(n),this.dispatchEvent(new CustomEvent("dblclick-cell",{detail:{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(t);break;case"drop":this.onDrop(t);break;case"wheel":this.onWheel(t);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const t=e.dataTransfer,i=t?.getData("elementType"),n=t?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const s={x:r.left,y:r.top};if(i)this.store.addElement(i,{},s);else if(n){const l=this.store.fields.find(c=>c.fieldKey===n);l&&this.store.addFieldElement(l,{},s)}}pointToPaperMm(e){const t=this.root.querySelector(".hiprint-printPaper");if(!t)return null;const i=t.getBoundingClientRect(),n=(this.store.scale||100)/100,r=p.pxToMm((e.clientX-i.left)/n),s=p.pxToMm((e.clientY-i.top)/n);return r<0||s<0?null:{left:r,top:s}}onCanvasMouseDown(e){const t=e.target;(t===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(n=>t.classList.contains(n)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const t=this.pointToPaperMm(e),i=this.root.querySelector("[data-coord]");if(i){if(!t){i.style.display="none";return}i.style.display="",i.textContent=`x:${(t.left-this.store.templateData.margins.left).toFixed(1)} y:${(t.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,t){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=t,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const i=this.root.querySelector(".context-menu");if(!i)return;const n=i.getBoundingClientRect();this.menu.flipX=n.right>window.innerWidth?window.innerWidth-n.right-8:0,this.menu.flipY=n.bottom>window.innerHeight?window.innerHeight-n.bottom-8:0,this.paint()})}startMarquee(e){const t={x:e.clientX,y:e.clientY},i=r=>{this.marquee={visible:!0,x:Math.min(t.x,r.clientX),y:Math.min(t.y,r.clientY),w:Math.abs(r.clientX-t.x),h:Math.abs(r.clientY-t.y)},this.paint()},n=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const s=this.store.elements.filter(l=>{const c=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!c)return!1;const u=c.getBoundingClientRect();return u.left<r.x+r.w&&u.right>r.x&&u.top<r.y+r.h&&u.bottom>r.y});this.store.select(new Set(s.map(l=>l.id)))}else this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}taps=new Map;isDoubleTap(e,t){const i=this.taps.get(e);return this.taps.set(e,{t:t.timeStamp,x:t.clientX,y:t.clientY}),!i||t.timeStamp-i.t>=500||Math.abs(t.clientX-i.x)>6||Math.abs(t.clientY-i.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const t=e.event;if(t.button!==0)return;const i=this.store;t.stopPropagation();const n=i.elements.find(l=>l.id===e.id);if(!n||(i.selectElement(n.id,t.ctrlKey||t.metaKey),n.options.locked))return;const r=t.altKey?[n.id]:i.dragIds(n.id),s=new Map;for(const l of r){const c=i.elements.find(u=>u.id===l);c&&s.set(l,{left:c.options.left,top:c.options.top})}this.drag={ids:r,primary:n.id,altKey:t.altKey,movedPositions:new Map,startX:t.clientX,startY:t.clientY,origin:s,zone:n.zone||"content",moved:!1},i.draggingIds=new Set(r),i.dragStart(),this.syncDragGhost()}syncDragGhost(){const e=this.store.draggingIds;for(const t of Array.from(this.root.querySelectorAll(".print-element"))){const i=e.has(t.dataset.elId??"");t.classList.toggle("drag-ghost",i);const n=t.querySelector(":scope > .drag-preview");i&&!n?fe(a("div",{class:"drag-preview"}),t):!i&&n&&n.remove()}}finishAltClone(e){const t=this.store;t.adsorbGuides=[];const i=t.elements.find(s=>s.id===e.primary),n=e.movedPositions.get(e.primary);if(t.discardLive(),!i||!n)return;const r=JSON.parse(JSON.stringify(i));r.id=p.generateId(),r.options.left=n.left,r.options.top=n.top,r.options.groupId=void 0,t.cloneElement(r)}flashSnapIndicator(e,t){const i=this.root.querySelector(".hiprint-printPaper-content");i&&(i.querySelector(".snap-indicator")?.remove(),fe(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${t}mm`}}),i),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{i.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const t=e.event;t.stopPropagation();const i=this.store.elements.find(n=>n.id===e.id);!i||i.options.locked||(this.resize={id:e.id,point:e.point,startX:t.clientX,startY:t.clientY,origin:{left:i.options.left,top:i.options.top,width:i.options.width,height:i.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const t=e.event.clientY,i=this.store.templateData,n=e.zone==="header"?i.header.height:i.footer.height,r=(this.store.scale||100)/100,s=c=>{const u=p.pxToMm((c.clientY-t)/r),h=Math.max(0,Math.round((n+(e.zone==="header"?u:-u))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...i.header,height:h}}):this.store.updateTemplateData({footer:{...i.footer,height:h}}),this.paint()},l=()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",s),window.addEventListener("mouseup",l)}beginGuideDrag(e){const t=(this.store.templateData.guides??[]).find(h=>h.id===e.id);if(!t)return;const i=p.getPaperDimensions(this.store.templateData),n=t.type==="vertical"?i.width:i.height,r=e.event.clientX,s=e.event.clientY,l=(this.store.scale||100)/100,c=h=>{const m=p.pxToMm((t.type==="vertical"?h.clientX-r:h.clientY-s)/l);this.store.moveGuide(t.id,Math.min(n,Math.max(0,t.position+m))),this.paint()},u=()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",u),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",c),window.addEventListener("mouseup",u)}beginRulerGuide(e){const t=e.orientation==="horizontal"?"vertical":"horizontal",i=r=>{this.guidePreview={type:t,position:t==="vertical"?r.clientX:r.clientY},this.paint()},n=r=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const s=this.rulerPointToMM(r,t);this.guidePreview=null,s!==null?this.store.addGuide(t,s):this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}rulerPointToMM(e,t){const i=this.root.querySelector(".hiprint-printPaper");if(!i)return null;const n=i.getBoundingClientRect(),r=p.mmToPx(1)*(this.geom.paperScale||1),s=t==="vertical"?(e.clientX-n.left)/r:(e.clientY-n.top)/r,l=p.getPaperDimensions(this.store.templateData),c=t==="vertical"?l.width:l.height;return s<0||s>c?null:s}applyZoom(e,t,i,n){const r=this.root.querySelector(".canvas-area");if(!r)return;const s=Math.round(this.store.scale),l=Math.max(n,Math.round(e));if(l===s)return;const c=getComputedStyle(r),u=parseFloat(c.paddingLeft)||0,h=parseFloat(c.paddingTop)||0,m=r.scrollLeft+t-u,g=r.scrollTop+i-h,v=l/s;this.store.setScale(l,n),r.scrollLeft=m*v-t+u,r.scrollTop=g*v-i+h}zoomByStep(e){const t=this.root.querySelector(".canvas-area");t&&this.applyZoom(p.nextWheelScale(this.store.scale,e),t.clientWidth/2,t.clientHeight/2,p.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const t=getComputedStyle(e),i=(parseFloat(t.paddingLeft)||0)+(parseFloat(t.paddingRight)||0),n=(parseFloat(t.paddingTop)||0)+(parseFloat(t.paddingBottom)||0),r=p.getPaperDimensions(this.store.templateData),s=p.computeFitScale(e.clientWidth-i,e.clientHeight-n,p.mmToPx(r.width),p.mmToPx(r.height));this.applyZoom(s,e.clientWidth/2,e.clientHeight/2,p.FIT_SCALE_MIN_PERCENT)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const t=this.root.querySelector(".canvas-area");if(!t)return;const i=Math.round(this.store.scale),n=p.nextWheelScale(i,e.deltaY>0?-1:1);if(n===i)return;const r=t.getBoundingClientRect();this.applyZoom(n,e.clientX-r.left,e.clientY-r.top,p.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");e&&(this.scrollPos={x:e.scrollLeft,y:e.scrollTop},this.syncRulers())}bindPointer(){window.addEventListener("mousemove",e=>{const t=this.store;if(!t)return;const n=((t.scale||100)/100||1)*p.mmToPx(1),r=(s,l)=>({dx:s/n,dy:l/n});if(this.drag){const{dx:s,dy:l}=r(e.clientX-this.drag.startX,e.clientY-this.drag.startY);(Math.abs(s)>.05||Math.abs(l)>.05)&&(this.drag.moved=!0);const c=t.elements.find(b=>b.id===this.drag.primary),u=c&&{id:c.id,left:(this.drag.origin.get(c.id)?.left??0)+s,top:(this.drag.origin.get(c.id)?.top??0)+l,width:c.options.width,height:c.options.height};let h=null;if(u&&t.snapToGrid!==!1){const b=t.elements.filter(k=>!this.drag.ids.includes(k.id)&&(k.zone||"content")===this.drag.zone).map(k=>({id:k.id,left:k.options.left,top:k.options.top,width:k.options.width,height:k.options.height})),w=Uo(t.templateData,t.paperSize)[this.drag.zone],T=p.computeAdsorb(u,b,this.manualGuides());h={left:T.left,top:T.top},t.adsorbGuides=(T.lines??[]).filter(k=>k.position>=0&&k.position<=(k.type==="vertical"?w.width:w.height)),(h.left!==u.left||h.top!==u.top)&&this.flashSnapIndicator(h.left+u.width/2,h.top+u.height/2)}else t.adsorbGuides=[];const m=c?this.drag.origin.get(c.id):void 0,g=h&&m?h.left-m.left:s,v=h&&m?h.top-m.top:l;for(const b of this.drag.ids){const w=this.drag.origin.get(b);if(!w)continue;const T={left:w.left+g,top:w.top+v};this.drag.movedPositions.set(b,T),t.livePatch(b,T)}this.patchElementDom(),t.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:s,dy:l}=r(e.clientX-this.resize.startX,e.clientY-this.resize.startY),c=p.calcResizeRect(this.resize.point,this.resize.origin,s,l,3.5,3.5);t.livePatch(this.resize.id,c),this.patchElementDom()}}),window.addEventListener("mouseup",()=>{const e=!!this.drag,t=this.drag;if(t?.moved&&t.altKey){this.finishAltClone(t),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),e&&(this.store.draggingIds=new Set,this.syncDragGhost()))}),this.addEventListener("pointerdown",e=>{const t=e.composedPath(),i=t.some(r=>r.classList?.contains("tb-dd"));this.state.openDd&&!i&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!i&&(this.state.openMore=!1,this.repaint());const n=t.some(r=>r.classList?.contains("context-menu"));this.menu.visible&&!n&&(this.menu.visible=!1,this.repaint())}),this.root.addEventListener("mouseover",e=>{const i=e.target?.closest?.("[data-tip]");!i||!i.closest(Ol)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(i),300))}),this.root.addEventListener("mouseout",e=>{const t=e,i=t.target?.closest?.("[data-tip]");i&&t.relatedTarget?.closest?.("[data-tip]")!==i&&this.hideHoverTip()})}showHoverTip(e){const t=e.dataset.tip;if(!t)return;this.hideHoverTip();const i=e.getBoundingClientRect(),n=i.left+i.width/2;this.hoverTipEl=fe(a("div",{class:"pd-hover-tip",style:{left:`${n}px`,top:`${i.bottom+6}px`},text:t}),this.root);const r=this.hoverTipEl.offsetWidth/2;if(!r)return;const s=r+8,l=Math.max(window.innerWidth-r-8,s);this.hoverTipEl.style.left=`${Math.min(Math.max(n,s),l)}px`}hideHoverTip(){this.hoverTipTimer&&(clearTimeout(this.hoverTipTimer),this.hoverTipTimer=null),this.hoverTipEl?.remove(),this.hoverTipEl=null}manualGuides(){const e=[],t=[];for(const i of this.store.templateData.guides??[])i.type==="vertical"?e.push(i.position):t.push(i.position);return{vertical:e,horizontal:t}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const i of Array.from(e.querySelectorAll(".adsorb-guide")))i.remove();const t=this.store.paperSize;Uo(this.store.templateData,t);for(const i of this.store.adsorbGuides){const n=document.createElement("div");n.className=`adsorb-guide guide-${i.type}`,i.type==="vertical"?n.style.cssText=`left:${i.position}mm;top:0;height:${t.height}mm;border-left-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`:n.style.cssText=`top:${i.position}mm;left:0;width:${t.width}mm;border-top-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(n)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{Oe.active=this};this.addEventListener("pointerdown",e),this.addEventListener("focusin",e),Oe.active||(Oe.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null)}onGlobalKeydown(e){const t=this.store;if(!t||Oe.active!==this)return;const n=e.composedPath()[0]?.tagName;if(n==="INPUT"||n==="TEXTAREA"||n==="SELECT")return;if(this.format.handlePainterKeydown(e),e.key.startsWith("Arrow")){e.preventDefault();const s=e.shiftKey?10:e.ctrlKey?.5:1,l=e.key==="ArrowLeft"?-s:e.key==="ArrowRight"?s:0,c=e.key==="ArrowUp"?-s:e.key==="ArrowDown"?s:0;t.moveSelected(l,c);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),t.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const r=e.key.toLowerCase();Nl.has(r)&&(e.preventDefault(),r==="z"?e.shiftKey?t.redo():t.undo():r==="y"?t.redo():r==="a"?t.selectAll():r==="c"?t.copy():r==="x"?t.cutSelected():r==="v"?t.paste():r==="d"?t.duplicateSelected():r==="g"?e.shiftKey?t.ungroupSelected():t.groupSelected():r==="1"?t.resetZoom():r==="l"?t.alignSelected("left"):r==="r"?t.alignSelected("right"):r==="e"?t.alignSelected("vertical"):r==="t"?t.alignSelected("top"):r==="b"?t.alignSelected("bottom"):r==="0"&&this.fire("fit-window"))}}function Yn(o="print-designer"){return customElements.get(o)||customElements.define(o,Oe),o}function Bl(){return Yn()}exports.DesignerStore=kn;exports.PrintDesignerElement=Oe;exports.TILING_SINGLE_PAGE_TIP=No;exports.createDefaultTemplate=Rt;exports.definePrintDesigner=Yn;exports.registerAll=Bl;exports.serializePage=En;exports.toRuntimePool=Xo;
|
|
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;
|