@worm-print-platform/canvas 1.5.2 → 1.5.3
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 +20 -4
- package/dist/browser-bundle.d.ts +1 -1
- package/dist/canvas.css +2 -2
- package/dist/canvas.js +71 -36
- package/dist/core/default-template.d.ts +1 -1
- package/dist/core/element-definitions.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/plugin.d.ts +1 -1
- package/dist/core/store.d.ts +1 -1
- package/dist/host-contract.d.ts +19 -7
- package/dist/index.cjs +45 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1151 -958
- package/dist/print-designer.d.ts +27 -4
- 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 +1 -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/advanced-settings.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/plugin-ui.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/dist/theme-tokens.d.ts +21 -0
- package/dist/version.d.ts +8 -0
- package/dist/vue3/PrintDesigner.d.ts +24 -1
- package/dist/vue3/PrintHtmlPreview.d.ts +1 -1
- package/dist/vue3/index.cjs +2 -2
- package/dist/vue3/index.d.ts +1 -1
- package/dist/vue3/index.js +70 -60
- package/dist/vue3/previewStyle.d.ts +1 -1
- package/dist/vue3/toolbarOverflow.d.ts +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@worm-print-platform/core/designer"),_=require("@worm-print-platform/core"),Si=require("@worm-print-platform/core/browser"),ci=require("@worm-print-platform/plugin-kit"),nr=require("jsbarcode");function a(t,e={},o=[]){return{tag:t,props:e,children:o}}const Ti="http://www.w3.org/2000/svg",ya=new Set(["draggable","contenteditable","spellcheck"]),wa=new Set(["indeterminate"]);function Ea(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function Sa(t){return t instanceof Element&&t.namespaceURI===Ti}function ve(t,e){if(typeof t=="string"){const s=document.createTextNode(t);return e.appendChild(s),s}if(t instanceof Node)return e.appendChild(t),t;const{tag:o,props:i,children:n}=t,r=Ea(o)||Sa(e)?document.createElementNS(Ti,o):document.createElement(o);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[p,u]of Object.entries(l))r.dataset[p]=u;else wa.has(s)?r[s]=!0:typeof l=="boolean"?l&&r.setAttribute(s,ya.has(s)?"true":""):r.setAttribute(s,String(l));for(const s of n)ve(s,r);return e.appendChild(r),r}function rr(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const Ta=Ti;function $t(){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 pi="开启拼版后只能有一个设计页面";function ki(t){const e=(o,i)=>(o??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&c.syncTableElementSize(r),{id:n.id||c.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},guides:[...t.guides??[]],elements:[...e(t.elements??[],"content"),...e(t.header?.elements??[],"header"),...e(t.footer?.elements??[],"footer")]}}function ar(t){const e=t.elements,o=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...t,header:{...t.header,elements:o("header")},footer:{...t.footer,elements:o("footer")},elements:o("content"),guides:[...t.guides??[]]}}function pn(t){const e=(i,n)=>{const r=ki(c.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!t)return[e($t(),0)];const o=Array.isArray(t.pages)?t.pages:[t];return o.length?o.map(e):[e($t(),0)]}const Tt=t=>JSON.parse(JSON.stringify(t));class sr{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=c.useAlign();group=c.useGroup();constructor(e={}){if(this.pages=pn(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const o=this.pages[0];o.elements=[...o.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const o of[...this.listeners])o()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(pi);return}this.recordHistory();const e=this.pages[this.activePageIndex]??$t();this.pages.push(ki({...$t(),paperSize:e.paperSize,orientation:e.orientation,outputRotation:e.outputRotation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let o=this.pages.length+1;for(;e.has(`页面 ${o}`);)o++;return`页面 ${o}`}duplicatePage(e){if(this.tilingEnabled){window.alert(pi);return}this.recordHistory();const o=Tt(this.pages[e]);o.name=`${o.name??`页面 ${e+1}`} 副本`,o.elements=o.elements.map(i=>({...i,id:c.generateId()})),this.pages.splice(e+1,0,o),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,o){this.recordHistory(),this.pages[e].name=o,this.emit()}movePage(e,o){if(o<0||o>=this.pages.length||e===o)return;this.recordHistory();const[i]=this.pages.splice(e,1);this.pages.splice(o,0,i),this.activePageIndex=o,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,o=!1){if(o){const i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,o=!1){if(o){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(o=>o.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,o){const i=this.templateData.guides??[];this.templateData.guides=[...i,{id:c.generateId(),type:e,position:Math.round(o*10)/10}],this.emit()}moveGuide(e,o){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(o*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(o=>o.id!==e),this.emit()}addElement(e,o={},i){const n=c.createRuntimeElement(e,o);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,o={},i,n=!1){const r=n?c.createFieldLabelElement(e):c.createFieldElement(e);return Object.assign(r.options,o),i&&!this.placeAtDropPoint(r,i)||(this.recordHistory(),this.templateData.elements.push(r),this.select(new Set([r.id])),this.emit()),r}placeAtDropPoint(e,o){const i=this.templateData,n=c.zoneFromPaperPoint(i,o.x,o.y);if(n!=="content"&&!c.isZoneAllowedType(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=c.getZoneRects(i)[n];return e.zone=n,e.options.left=o.x-r.left,e.options.top=o.y-r.top,n!=="content"&&c.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,o){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...o}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[o,i]of this.live){const n=e.find(r=>r.id===o);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const o=this.templateData.elements.find(i=>i.id===e);return!o||o.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let o=!1;for(const i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||c.finalizeElementZone(i,this.templateData).rejected&&(o=!0)}o&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,o,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,o),n.printElementType.type==="table"&&c.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e);for(const o of["paperSize","customWidth","customHeight"])if(o in e)for(const i of this.pages)Object.assign(i,{[o]:e[o]});this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const o=this.templateData.elements,i=o.filter(r=>this.selectedIds.has(r.id)),n=o.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=o.findIndex(p=>this.selectedIds.has(p.id)),s=e==="up"?r+1:r-1;if(s<0||s>=o.length)return;const l=[...o];[l[r],l[s]]=[l[s],l[r]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(o=>this.selectedIds.has(o.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=Tt(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const o=new Map;for(const r of this.clipboard){const s=r.options.groupId;s&&o.set(s,(o.get(s)??0)+1)}const i=new Map;for(const[r,s]of o)i.set(r,s>=2?c.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const s=Tt(r);s.id=c.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,o){const i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=o;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:Tt(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:Tt(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:Tt(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,o=c.MIN_SCALE_PERCENT){this.scale=Math.max(o,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(ar),o=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(o)}loadTemplate(e){this.pages=pn(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return c.getPaperDimensions(this.templateData)}}const ht=Symbol("mixed"),qo=new Set(["text","longText"]),ka=["top","right","bottom","left"],Ca={on:!0,off:!1,mixed:ht};function un(t){const e=c.resolveBorderEdgeStates(t),o={};for(const i of ka)o[i]=Ca[e[i]];return o}const Aa=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class Da{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(o=>o.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,o=this.tableElement?.options.tableRows;if(!e||!o)return[];const i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=o[n]?.cells[r];s&&!s.merged&&i.push(s)}return i}get textTargets(){return this.selectedElements.filter(e=>qo.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const o=e[0];return e.every(i=>i===o)?o:ht}hasToken(e,o){return(e??"").split(/\s+/).includes(o)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const o=e.map(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:o.every(Boolean)?!0:o.some(Boolean)?ht:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?ht:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?ht:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const o=this.targetCells;o.length&&(o.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const o=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),s="backgroundColor"in e;!(o.length&&r)&&!(i.length&&s)||(o.forEach(l=>{const p=l.options;"fontFamily"in e&&(p.fontFamily=e.fontFamily),"fontSize"in e&&(p.fontSize=e.fontSize),"color"in e&&(p.color=e.color),"textAlign"in e&&(p.textAlign=e.textAlign),"verticalAlign"in e&&(p.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,o=this.textTargets;o.length&&(o.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const o=this.textTargets;if(!o.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;o.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),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,o=this.tableElement?.options.tableRows;if(!e||!o)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,c.resolveCellGroupMode(o,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=c.resolveCellBorderDisplay(o,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const o=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=o,o===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,o){const i=this.selectedElements;i.length&&(i.forEach(n=>{c.applyElementBorderPreset(n.options,e,o)}),this.commit())}applyCellBorderPreset(e,o){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(c.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,o),this.commit())}applyCellBorderEdges(e,o,i){this.writeCells(n=>{for(const r of e)c.setCellBorderEdge(n,r,i?o:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?un(e.map(o=>o.borders)):null}toggleCellEdge(e,o){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],o,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?un(e.map(o=>c.elementVisibleBorders(o.options))):null}toggleElementEdge(e,o){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>c.setElementBorderEdgeVisible(r.options,e,n,o)),this.commit()}applyBorderPreset(e){const o=this.borderStyle===null;if(this.context==="cells"){const i=o&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(o||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const o=this.selectedElements;o.length&&(o.forEach(i=>c.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const o={};for(const i of c.ELEMENT_BORDER_SIDES){const n=e[i];n&&(o[i]={...n})}return o}pickPainterSource(e=!1){const o=this.selectedElements[0];if(!o)return!1;const i=o.options,n=o.printElementType.type;return this.painterSnapshot={text:qo.has(n)?Object.fromEntries(Aa.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:c.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=o.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const o=this.painterSnapshot;if(!o||e.options.locked||e.id===this.painterSource)return!1;const i=e.options,n=e.printElementType.type;return o.text&&qo.has(n)&&Object.assign(i,o.text),i.backgroundColor=o.backgroundColor,o.border&&c.acceptsElementBorder(n)&&(i.borderWidth=o.border.borderWidth,i.borderStyle=o.border.borderStyle,i.borderColor=o.border.borderColor,i.borders=this.clonePainterBorders(o.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let o=!1;e.forEach(i=>{o=this.applyPainter(i)||o}),o&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const o=e.target?.tagName;o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||this.cancelPainter()}}const Ma="自定义属性";function lr(){const t=[];for(const{plugin:e,kind:o}of c.getElementPluginKinds()){const i=ci.getElementUI(o.type);if(!i)continue;const r=(o.designer??e.designer)?.materialCard;t.push({type:o.type,label:o.label,icon:o.icon??r?.icon??"Shapes",group:r?.group??i.group,ui:i})}return t}function Ci(t){if(t)return lr().find(e=>e.type===t)}function ui(t){if(!t)return;const e=Ci(t.printElementType.type);if(!e||!e.ui.renderProperty)return;const o=e.ui;if(o.hasProperties)try{if(!o.hasProperties(t))return}catch{return}const i=Ma;return{ui:o,label:i,icon:e.icon,searchKeywords:o.searchKeywords?[...o.searchKeywords]:[i,e.label,e.type]}}const fo=Object.freeze([{type:"text",label:"文本",icon:"Type",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"barcode",label:"条形码",icon:"Barcode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"qrcode",label:"二维码",icon:"QrCode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"image",label:"图片",icon:"Image",material:!0,propertyGroup:"general",dblEditableField:"src",origin:"builtin"},{type:"table",label:"表格",icon:"Table",material:!0,propertyGroup:"table",origin:"builtin"},{type:"longText",label:"长文",icon:"TextAlignStart",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"flowList",label:"流式列表",icon:"List",material:!0,propertyGroup:"general",dblEditableField:"formatter",origin:"builtin"},{type:"hline",label:"横线",icon:"Minus",material:!0,propertyGroup:"general",origin:"builtin"},{type:"vline",label:"竖线",icon:"SeparatorVertical",material:!0,propertyGroup:"general",origin:"builtin"},{type:"rect",label:"矩形",icon:"Square",material:!0,propertyGroup:"general",origin:"builtin"},{type:"oval",label:"椭圆",icon:"Circle",material:!0,propertyGroup:"general",origin:"builtin"},{type:"html",label:"HTML",icon:"Code",material:!1,propertyGroup:"general",origin:"builtin"},{type:"pageNumber",label:"页码",icon:"Shapes",material:!1,propertyGroup:"general",origin:"builtin"}]),hn=Symbol.for("worm-print-platform.element-definitions.v1"),fn=globalThis;function ze(){const t=fn[hn];if(t)return t;const e={overrides:new Map,builtinRenderers:new Map,rendererOverrides:new Map,listeners:new Set,nextSeq:0,seq:new Map};return fn[hn]=e,e}function Bt(){for(const t of[...ze().listeners])try{t()}catch{}}function dr(t){const e=ze();return e.listeners.add(t),()=>{e.listeners.delete(t)}}function _a(){return new Map(fo.map(t=>[t.type,t]))}function Ra(t){if(!t?.type||typeof t.type!="string")throw new Error("registerElementDefinition: type 必须是非空字符串");if(!t.label||typeof t.label!="string")throw new Error("registerElementDefinition: label 必须是非空字符串");const e=ze(),o={...t,origin:t.origin??"custom"};return e.overrides.set(o.type,o),e.seq.set(o.type,e.nextSeq++),Bt(),()=>{const i=ze();i.overrides.get(o.type)===o&&(i.overrides.delete(o.type),Bt())}}function Pa(t,e){if(!t||typeof e!="function")throw new Error("registerElementRenderer: 需要 type 与渲染函数");return ze().rendererOverrides.set(t,e),Bt(),()=>{const i=ze();i.rendererOverrides.get(t)===e&&(i.rendererOverrides.delete(t),Bt())}}function cr(t){const e=ze();for(const[o,i]of Object.entries(t))e.builtinRenderers.set(o,i);return()=>{const o=ze();for(const[i,n]of Object.entries(t))o.builtinRenderers.get(i)===n&&o.builtinRenderers.delete(i)}}function Ia(t){const e=Ci(t);if(e)return{type:e.type,label:e.label,icon:e.icon,group:e.group,material:!0,propertyGroup:"general",origin:"plugin"}}function nt(t){if(!t)return;const e=ze(),o=e.overrides.get(t)??_a().get(t)??Ia(t);if(!o)return;const i=e.rendererOverrides.get(t)??e.builtinRenderers.get(t);return i?{...o,renderContent:i}:o}function pr(){const t=ze(),e=[],o=new Set;for(const n of fo)e.push(nt(n.type)??n),o.add(n.type);const i=[...t.overrides.entries()].filter(([n])=>!o.has(n)).sort((n,r)=>(t.seq.get(n[0])??0)-(t.seq.get(r[0])??0));for(const[n]of i){const r=nt(n);r&&e.push(r),o.add(n)}for(const n of lr()){if(o.has(n.type))continue;const r=nt(n.type);r&&e.push(r),o.add(n.type)}return e}function ur(){return pr().filter(t=>t.material)}function hr(t){return nt(t)?.propertyGroup??"general"}function fr(t){return nt(t)?.dblEditableField}function gr(t){return nt(t)?.icon??"Shapes"}function La(){const t=ze();t.overrides.clear(),t.rendererOverrides.clear(),t.seq.clear(),t.nextSeq=0,Bt()}const Ai="1.1.0",mr="print-designer",Di=["template","fields","name","fonts","design-data"],br=["is-edit","show-help","show-preview","show-save"],Fa=Object.freeze({bubbles:!0,composed:!0}),Mi=["container","toolbar","format-bar","left-panel","canvas-area","property-panel","status-bar","page-tabs"],xr=["--pd-bg","--pd-surface","--pd-sidebar","--pd-canvas-bg","--pd-paper","--pd-text","--pd-text-muted","--pd-text-faint","--pd-border","--pd-border-soft","--pd-accent","--pd-accent-soft","--pd-hover-tint","--pd-danger","--pd-radius"],vr=["getTemplateJson","loadTemplate","save","validateTemplate","getGeometryWarnings"],yr=["template","fields","fonts","designData","isEdit","showHelp","showPreview","showSave","uploadImage","uploadDesignBackground"],Fe=Object.freeze({save:"save",preview:"preview",help:"help",dblclickElement:"dblclick-element",dblclickCell:"dblclick-cell"}),wr=[Fe.save,Fe.preview,Fe.help,Fe.dblclickElement,Fe.dblclickCell];function hi(){return{version:Ai,tag:mr,attributes:Di,booleanAttributes:br,events:wr,parts:Mi,themeTokens:xr,methods:vr,properties:yr}}function gn(t,e){(e==null||e>t.length)&&(e=t.length);for(var o=0,i=Array(e);o<e;o++)i[o]=t[o];return i}function za(t){if(Array.isArray(t))return t}function Oa(t,e){var o=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(o!=null){var i,n,r,s,l=[],p=!0,u=!1;try{if(r=(o=o.call(t)).next,e!==0)for(;!(p=(i=r.call(o)).done)&&(l.push(i.value),l.length!==e);p=!0);}catch(h){u=!0,n=h}finally{try{if(!p&&o.return!=null&&(s=o.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}function Na(){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 $a(t,e){return za(t)||Oa(t,e)||Ba(t,e)||Na()}function Ba(t,e){if(t){if(typeof t=="string")return gn(t,e);var o={}.toString.call(t).slice(8,-1);return o==="Object"&&t.constructor&&(o=t.constructor.name),o==="Map"||o==="Set"?Array.from(t):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?gn(t,e):void 0}}const Er=Object.entries,Ha=Object.keys,mn=Object.setPrototypeOf,Ua=Object.isFrozen,Sr=Object.getPrototypeOf,Tr=Object.getOwnPropertyDescriptor;let fe=Object.freeze,se=Object.seal,it=Object.create,kr=typeof Reflect<"u"&&Reflect,so=kr.apply,fi=kr.construct;fe||(fe=function(e){return e});se||(se=function(e){return e});so||(so=function(e,o){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(o,n)});fi||(fi=function(e){for(var o=arguments.length,i=new Array(o>1?o-1:0),n=1;n<o;n++)i[n-1]=arguments[n];return new e(...i)});const qe=J(Array.prototype.forEach),Wa=J(Array.prototype.lastIndexOf),bn=J(Array.prototype.pop),Pt=J(Array.prototype.push),Ga=J(Array.prototype.slice),qa=J(Array.prototype.splice),Dt=Array.isArray,Ko=Cr(Set),Vo=J(Set.prototype.add),It=J(Set.prototype.has),pt=J(String.prototype.toLowerCase),jo=J(String.prototype.toString),Ka=J(String.prototype.match),eo=J(String.prototype.replace),Yo=J(String.prototype.indexOf),Va=J(String.prototype.trim),ja=J(Number.prototype.toString),Ya=J(Boolean.prototype.toString),xn=typeof BigInt>"u"?null:J(BigInt.prototype.toString),vn=typeof Symbol>"u"?null:J(Symbol.prototype.toString),xe=J(Object.prototype.hasOwnProperty),Lt=J(Object.prototype.toString),Xa=RegExp.prototype.test,he=function(e,o){return e instanceof RegExp&&(e.lastIndex=0),so(Xa,e,[o])},Ke=Cr(TypeError);function J(t){return function(e){for(var o=arguments.length,i=new Array(o>1?o-1:0),n=1;n<o;n++)i[n-1]=arguments[n];return so(t,e,i)}}function Cr(t){return function(){for(var e=arguments.length,o=new Array(e),i=0;i<e;i++)o[i]=arguments[i];return fi(t,o)}}function q(t,e){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pt;if(mn&&mn(t,null),!Dt(e))return t;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=o(n);r!==n&&(Ua(e)||(e[i]=r),n=r)}t[n]=!0}return t}function Za(t){for(let e=0;e<t.length;e++)xe(t,e)||(t[e]=null);return t}function lo(t){const e=it(null);for(const i of Er(t)){var o=$a(i,2);const n=o[0],r=o[1];xe(t,n)&&(Dt(r)?e[n]=Za(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=lo(r):e[n]=r)}return e}function Ot(t){const e=it(null),o=Ha(t);let i=o.length;for(;i--;)e[o[i]]=t[o[i]];return e}function Qa(t){switch(typeof t){case"string":return t;case"number":return ja(t);case"boolean":return Ya(t);case"bigint":return xn?xn(t):"0";case"symbol":return vn?vn(t):"Symbol()";case"undefined":return Lt(t);case"function":case"object":{if(t===null)return Lt(t);const e=t,o=Ae(e,"toString");if(typeof o=="function"){const i=o(e);return typeof i=="string"?i:Lt(i)}return Lt(t)}default:return Lt(t)}}function Ae(t,e){for(;t!==null;){const i=Tr(t,e);if(i){if(i.get)return J(i.get);if(typeof i.value=="function")return J(i.value)}t=Sr(t)}function o(){return null}return o}function Ja(t,e){for(;t!==null;){const o=Tr(t,e);if(o)return o.get?J(o.get):null;t=Sr(t)}return null}function es(t){if(!t)return!1;try{return he(t,""),!0}catch{return!1}}const yn=fe(["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"]),Xo=fe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Zo=fe(["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"]),ts=fe(["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"]),Qo=fe(["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"]),os=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wn=fe(["#text"]),En=fe(["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"]),Jo=fe(["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"]),Sn=fe(["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"]),to=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),is=se(/{{[\w\W]*|^[\w\W]*}}/g),ns=se(/<%[\w\W]*|^[\w\W]*%>/g),rs=se(/\${[\w\W]*/g),as=se(/{{|}}|\${|<%|%>|<%|%>/),ss=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),ls=se(/^aria-[\-\w]+$/),Tn=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ds=se(/^(?:\w+script|data):/i),cs=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ps=se(/^html$/i),us=se(/^[a-z][.\w]*(-[.\w]+)+$/i),ei=se(/<[/\w!]/g),kn=se(/<[/\w]/g),hs=se(/<\/no(script|embed|frames)/i),Cn=se(/\/>/i),fs=se(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),gs=se(/^[\r\n\t ]+/),ne={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},ms=fe(q({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),bs=function(){return typeof window>"u"?null:window},xs=function(e,o){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";o&&o.hasAttribute(n)&&(i=o.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},An=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},tt=function(e,o,i,n){return xe(e,o)&&Dt(e[o])?q(n.base?Ot(n.base):{},e[o],n.transform):i},ti=function(e,o,i){const n=xe(e,o)?e[o]:void 0;return n&&typeof n=="object"?lo(n):i};function Ar(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:bs();const e=E=>Ar(E);if(e.version="3.4.18",e.removed=[],!t||!t.document||t.document.nodeType!==ne.document||!t.Element)return e.isSupported=!1,e;let o=t.document;const i=o,n=i.currentScript,r=t.HTMLTemplateElement,s=t.Node,l=t.Element,p=t.NodeFilter,u=t.DOMParser,h=t.trustedTypes,m=l.prototype,g=Ae(m,"cloneNode"),S=Ae(m,"remove"),b=Ae(m,"removeAttributeNode"),k=Ae(m,"nextSibling"),y=Ae(m,"childNodes"),C=Ae(m,"parentNode"),D=Ae(m,"shadowRoot"),P=Ae(m,"attributes"),A=s&&s.prototype?Ae(s.prototype,"nodeType"):null,F=s&&s.prototype?Ae(s.prototype,"nodeName"):null,K=s&&s.prototype?Ae(s.prototype,"ownerDocument"):null,N=function(d){return A?A(d):d.nodeType},L=function(d){return F?F(d):d.nodeName},z=Ja(m,"namespaceURI"),ee=function(d){return z?z(d):d.namespaceURI};if(typeof r=="function"){const E=o.createElement("template");E.content&&E.content.ownerDocument&&(o=E.content.ownerDocument)}let H,pe="",te,ke=!1,x=0;const Z=function(){if(x>0)throw Ke('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.')},le=function(d){Z(),x++;try{return H.createHTML(d)}finally{x--}},De=function(d){return H&&Ao?le(d):d},B=function(d){Z(),x++;try{return H.createScriptURL(d)}finally{x--}},Ue=function(){return ke||(te=xs(h,n),ke=!0),te},re=o,ye=re.implementation,Me=re.createNodeIterator,G=re.createDocumentFragment,Ze=re.getElementsByTagName,Wt=i.importNode;let j=An();e.isSupported=typeof Er=="function"&&typeof C=="function"&&ye&&ye.createHTMLDocument!==void 0;const yo=is,at=ns,Ee=rs,Ce=ss,wo=ls,Eo=ds,So=cs,To=us;let Gt=Tn,Y=null;const Qe=q({},[...yn,...Xo,...Zo,...Qo,...wn]);let X=null;const Je=q({},[...En,...Jo,...Sn,...to]);let ue=null,st=null,V=null;const _e=Object.seal(it(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mt=!0,v=!0,U=!1,ge=!0,Q=!1,Re=!0,We=!1,ko=!1,qt=null,Kt=null,Co=!1,xt=!1,Vt=!1,Ao=!1,Ui=!0,Wi=!1;const Gi="user-content-";let Do=!0,Mo=!1,lt=null,vt=!1,dt=null;const qi=q({},["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 Ki=null;const Vi=q({},["audio","video","img","source","image","track"]);let ji=null;const Yi=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jt="http://www.w3.org/1998/Math/MathML",Yt="http://www.w3.org/2000/svg",Oe="http://www.w3.org/1999/xhtml";let yt=Oe,_o=!1,Xi=null;const Yr=q({},[jt,Yt,Oe],jo),Xr=fe(q({},["mi","mo","mn","ms","mtext"]));let Ro=null;const Zr=fe(q({},["annotation-xml"]));let Po=null;const Qr=fe(it(null)),Jr=q({},["title","style","font","a","script"]);let _t=null;const ea=["application/xhtml+xml","text/html"],ta="text/html";let ie=null,Xt=null;const oa=o.createElement("form"),Zi=function(d){return d instanceof RegExp||d instanceof Function},Io=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(!d||typeof d!="object")&&(d={}),d=lo(d),_t=ea.indexOf(d.PARSER_MEDIA_TYPE)===-1?ta:d.PARSER_MEDIA_TYPE,ie=_t==="application/xhtml+xml"?jo:pt,Y=tt(d,"ALLOWED_TAGS",Qe,{transform:ie}),X=tt(d,"ALLOWED_ATTR",Je,{transform:ie}),Xi=tt(d,"ALLOWED_NAMESPACES",Yr,{transform:jo}),ji=tt(d,"ADD_URI_SAFE_ATTR",Yi,{transform:ie,base:Yi}),Ki=tt(d,"ADD_DATA_URI_TAGS",Vi,{transform:ie,base:Vi}),dt=tt(d,"FORBID_CONTENTS",qi,{transform:ie}),st=tt(d,"FORBID_TAGS",it(null),{transform:ie}),V=tt(d,"FORBID_ATTR",it(null),{transform:ie}),vt=xe(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?lo(d.USE_PROFILES):d.USE_PROFILES:!1,Mt=d.ALLOW_ARIA_ATTR!==!1,v=d.ALLOW_DATA_ATTR!==!1,U=d.ALLOW_UNKNOWN_PROTOCOLS||!1,ge=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=d.SAFE_FOR_TEMPLATES||!1,Re=d.SAFE_FOR_XML!==!1,We=d.WHOLE_DOCUMENT||!1,xt=d.RETURN_DOM||!1,Vt=d.RETURN_DOM_FRAGMENT||!1,Ao=d.RETURN_TRUSTED_TYPE||!1,Co=d.FORCE_BODY||!1,Ui=d.SANITIZE_DOM!==!1,Wi=d.SANITIZE_NAMED_PROPS||!1,Do=d.KEEP_CONTENT!==!1,Mo=d.IN_PLACE||!1,Gt=es(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Tn,yt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Oe,Ro=ti(d,"MATHML_TEXT_INTEGRATION_POINTS",Xr),Po=ti(d,"HTML_INTEGRATION_POINTS",Zr);const f=ti(d,"CUSTOM_ELEMENT_HANDLING",Qr);if(ue=it(null),xe(f,"tagNameCheck")&&Zi(f.tagNameCheck)&&(ue.tagNameCheck=f.tagNameCheck),xe(f,"attributeNameCheck")&&Zi(f.attributeNameCheck)&&(ue.attributeNameCheck=f.attributeNameCheck),xe(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),se(ue),Q&&(v=!1),Vt&&(xt=!0),vt&&((xe(d,"ALLOWED_TAGS")||xe(d,"ALLOWED_ATTR"))&&typeof console<"u"&&typeof console.warn=="function"&&console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together."),Y=q({},wn),X=it(null),vt.html===!0&&(q(Y,yn),q(X,En)),vt.svg===!0&&(q(Y,Xo),q(X,Jo),q(X,to)),vt.svgFilters===!0&&(q(Y,Zo),q(X,Jo),q(X,to)),vt.mathMl===!0&&(q(Y,Qo),q(X,Sn),q(X,to))),_e.tagCheck=null,_e.attributeCheck=null,xe(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?_e.tagCheck=d.ADD_TAGS:Dt(d.ADD_TAGS)&&(Y===Qe&&(Y=Ot(Y)),q(Y,d.ADD_TAGS,ie))),xe(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?_e.attributeCheck=d.ADD_ATTR:Dt(d.ADD_ATTR)&&(X===Je&&(X=Ot(X)),q(X,d.ADD_ATTR,ie))),xe(d,"ADD_FORBID_CONTENTS")&&Dt(d.ADD_FORBID_CONTENTS)&&(dt===qi&&(dt=Ot(dt)),q(dt,d.ADD_FORBID_CONTENTS,ie)),Do&&(Y["#text"]=!0),We&&q(Y,["html","head","body"]),Y.table&&(Y.tbody=!0,delete st.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const w=H;H=d.TRUSTED_TYPES_POLICY;try{pe=le("")}catch(T){throw H=w,T}}else d.TRUSTED_TYPES_POLICY===null?(H=void 0,pe=""):(H===void 0&&(H=Ue()),H&&typeof pe=="string"&&(pe=le("")));Xt=fe(d)},Qi=q({},[...Xo,...Zo,...ts]),Ji=q({},[...Qo,...os]),ia=function(d,f,w){return f===Oe?d==="svg":f===jt?d==="svg"&&(w==="annotation-xml"||Ro[w]):!!Qi[d]},na=function(d,f,w){return f===Oe?d==="math":f===Yt?d==="math"&&Po[w]:!!Ji[d]},ra=function(d,f,w){return f===Yt&&!Po[w]||f===jt&&!Ro[w]?!1:!Ji[d]&&(Jr[d]||!Qi[d])},aa=function(d){const f=ee(d),w=pt(L(d)),T=C(d);let R=yt,I="template";return T&&N(T)===ne.element&&(R=ee(T),I=pt(L(T))),Xi[f]?f===Yt?ia(w,R,I):f===jt?na(w,R,I):f===Oe?ra(w,R,I):_t==="application/xhtml+xml":!1},et=function(d){Pt(e.removed,{element:d});try{C(d).removeChild(d)}catch{if(S(d),!C(d))throw Ke("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},en=function(d,f,w){try{b(d,f)}catch{try{d.removeAttribute(w)}catch{}}},Lo=function(d){Oo(d);const f=y(d);f&&qe(Ga(f),w=>{try{S(w)}catch{}}),N(d)===ne.element&&Fo(d,!1)},wt=function(d,f,w){if(!w)try{w=f.getAttributeNode(d)}catch{w=null}if(Pt(e.removed,{attribute:w||null,from:f}),w)en(f,w,d);else try{f.removeAttribute(d)}catch{}if(d==="is")if(xt||Vt)try{et(f)}catch{}else try{f.setAttribute(d,"")}catch{}},Fo=function(d,f){const w=P(d);if(w)for(let T=w.length-1;T>=0;--T){const R=w[T],I=R&&R.name;typeof I=="string"&&!(f&&X[ie(I)])&&en(d,R,I)}},zo=function(d,f){let w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const T=[d];for(;T.length>0;){const R=T.pop();if(f(R)===!1)continue;if(w&&N(R)===ne.element){const $=D(R);Et($)&&T.push($)}const I=y(R);if(I)for(let $=I.length-1;$>=0;--$)T.push(I[$])}},Oo=function(d){zo(d,f=>{N(f)===ne.element&&Fo(f,!0)})},No=function(d){const f=[];return zo(d,w=>{f.push(w)},!0),f},sa=function(d,f){const w=Ko();qe(No(d),T=>{N(T)===ne.element&&Vo(w,T)}),qe(f,T=>{N(T)===ne.element&&!It(w,T)&&Fo(T,!0)})},tn=function(d,f){let w=!1;return qe(e.removed,T=>{T.element&&(w=w||T.element===d,Oo(T.element))}),sa(d,f),w},la=8,da=function(d,f){const w=lt;let T=null;const R=()=>(T||(T=Ko(),qe(f,I=>{Vo(T,I)})),T);for(let I=0;;I++){const $=No(d),de=[d];let Ge=!1;if(qe($,Ie=>{N(Ie)===ne.documentFragment?Pt(de,Ie):!Ge&&!It(w,Ie)&&(Ge=It(R(),Ie))}),!Ge)return;if(I>=la)throw Ke("the tree kept changing during in-place sanitization; refusing to return it");qe(de,(Ie,Se)=>{ca(Ie,Se>0,d,R())})}},ca=function(d,f,w,T){const R=Zt(d);let I;for(;I=R.nextNode();)!It(T,I)||It(lt,I)||(f&&Pe(j.uponSanitizeShadowNode,I,null),Uo(I,w))},pa=function(d){lt&&Vo(lt,d)},on=function(d,f){return Re?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},ua=function(d){Re&&zo(d,f=>{const w=N(f);if(w===ne.processingInstruction||w===ne.comment&&he(kn,f.data)){try{S(f)}catch{}return!1}if(w===ne.element){const T=f,R=ie(L(f));try{T.hasAttribute&&T.hasAttribute("patchsrc")&&T.removeAttribute("patchsrc"),T.hasAttribute&&T.hasAttribute("for")&&on("for",R)&&T.removeAttribute("for")}catch{}}return!0})},nn=function(d){let f=null,w=null;if(Co)d="<remove></remove>"+d;else{const I=Ka(d,gs);w=I&&I[0]}_t==="application/xhtml+xml"&&yt===Oe&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const T=H?le(d):d;if(yt===Oe)try{f=new u().parseFromString(T,_t)}catch{}if(!f||!f.documentElement){f=ye.createDocument(yt,"template",null);try{f.documentElement.innerHTML=_o?pe:T}catch{}}const R=f.body||f.documentElement;return d&&w&&R.insertBefore(o.createTextNode(w),R.childNodes[0]||null),yt===Oe?Ze.call(f,We?"html":"body")[0]:We?f.documentElement:R},Zt=function(d){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const w=K?K(d):d.ownerDocument;return Me.call(w||d,d,(f?0:p.SHOW_ELEMENT)|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},$o=function(d){return d=eo(d,yo," "),d=eo(d,at," "),d=eo(d,Ee," "),d},Bo=function(d){var f;Ho(d);const w=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");w&&qe(w,T=>{Et(T.content)&&Bo(T.content)})},Ho=function(d){d.normalize();const f=Zt(d,!0);let w=f.nextNode();for(;w;)w.data=$o(w.data),w=f.nextNode()},Qt=function(d){const f=F?F(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.removeAttributeNode!="function"||typeof d.getAttributeNode!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==A(d)||d.childNodes!==y(d)},rn=function(d){if(!A||typeof d!="object"||d===null)return null;try{const f=A(d);return typeof f=="number"?f:null}catch{return null}},Et=function(d){return rn(d)===ne.documentFragment},Rt=function(d){return rn(d)!==null};function Pe(E,d,f){E.length!==0&&qe(E,w=>{w.call(e,d,f,Xt)})}const ha=function(d,f,w){return!!(Re&&w===ne.element&&d.hasChildNodes()&&!Rt(d.firstElementChild)&&he(ei,d.textContent)&&he(ei,d.innerHTML)||Re&&ms[f]&&w===ne.element&&ee(d)===Oe&&(Rt(d.firstElementChild)||typeof d.textContent=="string"&&he(ei,d.textContent))||w===ne.processingInstruction||Re&&w===ne.comment&&he(kn,d.data))},Jt=function(d,f){if(d instanceof RegExp)return he(d,f);if(d instanceof Function){for(var w=arguments.length,T=new Array(w>2?w-2:0),R=2;R<w;R++)T[R-2]=arguments[R];return!!d(f,...T)}return!1},fa=function(d,f,w){if(!st[f]&&ln(f)&&Jt(ue.tagNameCheck,f))return!1;if(Do&&!dt[f]&&!dt[pt(f)]){const T=C(d),R=y(d);if(R&&T){const I=R.length;for(let $=I-1;$>=0;--$){const de=d===w?g(R[$],!0):R[$];T.insertBefore(de,k(d))}}}return et(d),!0},an=function(d,f,w,T){return d.length===0?f:f===w||f===T?Ot(f):f},St=function(d,f){return d===f||C(d)!==null?!1:(Mo&&Oo(d),!0)},ga=function(d,f){if(pa(d),Pe(j.beforeSanitizeElements,d,null),St(d,f))return!0;if(Qt(d))return et(d),!0;const w=ie(L(d)),T=N(d);if(Y=an(j.uponSanitizeElement,Y,Qe,qt),Pe(j.uponSanitizeElement,d,{tagName:w,allowedTags:Y}),St(d,f))return!0;if(ha(d,w,T))return et(d),!0;if(st[w]||!(_e.tagCheck instanceof Function&&_e.tagCheck(w))&&!Y[w]){const R=fa(d,w,f);return R===!1&&(Pe(j.afterSanitizeElements,d,null),St(d,f))?!0:R}if(T===ne.element&&!aa(d)||(w==="noscript"||w==="noembed"||w==="noframes")&&he(hs,d.innerHTML))return et(d),!0;if(Q&&T===ne.text){const R=d.textContent,I=$o(R);R!==I&&(Pt(e.removed,{element:d.cloneNode()}),d.textContent=I)}return Pe(j.afterSanitizeElements,d,null),St(d,f)},sn=function(d,f,w){if(V[f]||on(f,d)||Ui&&(f==="id"||f==="name")&&(w in o||w in oa))return!1;const T=X[f]||_e.attributeCheck instanceof Function&&_e.attributeCheck(f,d);if(v&&he(Ce,f)||Mt&&he(wo,f))return!0;if(!T)return ln(d)&&Jt(ue.tagNameCheck,d)&&Jt(ue.attributeNameCheck,f,d)||f==="is"&&ue.allowCustomizedBuiltInElements&&Jt(ue.tagNameCheck,w);if(ji[f])return!0;const R=eo(w,So,"");return he(Gt,R)||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Yo(w,"data:")===0&&Ki[d]||U&&!he(Eo,R)?!0:!w},ma=q({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ln=function(d){return!ma[pt(d)]&&he(To,d)},ba=function(d,f,w,T){if(H&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!w)switch(h.getAttributeType(d,f)){case"TrustedHTML":return le(T);case"TrustedScriptURL":return B(T)}return T},xa=function(d,f,w,T){try{return w?d.setAttributeNS(w,f,T):d.setAttribute(f,T),Qt(d)?(et(d),!1):!0}catch{return wt(f,d),!1}},dn=function(d,f){return Re&&he(fs,f)?!0:pt(d)==="attributename"&&Yo(f,"href")!==-1},va=function(d,f){if(Pe(j.beforeSanitizeAttributes,d,null),St(d,f))return;const w=d.attributes;if(!w||Qt(d))return;X=an(j.uponSanitizeAttribute,X,Je,Kt);const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0};let R=w.length;const I=ie(L(d));for(;R--;){const $=w[R],de=$.name,Ge=$.namespaceURI,Ie=$.value,Se=ie(de),Ne=Ie;let me=de==="value"?Ne:Va(Ne),cn=!1;if(T.attrName=Se,T.attrValue=me,T.keepAttr=!0,T.forceKeepAttr=void 0,Pe(j.uponSanitizeAttribute,d,T),me=T.attrValue,Wi&&(Se==="id"||Se==="name")&&Yo(me,Gi)!==0&&(wt(de,d,$),me=Gi+me,cn=!0),dn(de,me)){wt(de,d,$);continue}if(!T.forceKeepAttr){if(!T.keepAttr){wt(de,d,$);continue}if(!ge&&he(Cn,me)){wt(de,d,$);continue}if(Q&&(me=$o(me)),!sn(I,Se,me)){wt(de,d,$);continue}me=ba(I,Se,Ge,me),me!==Ne&&xa(d,de,Ge,me)&&cn&&bn(e.removed)}}Pe(j.afterSanitizeAttributes,d,null),St(d,f)},Uo=function(d,f){ga(d,f),va(d,f),Et(d.content)&&Wo(d.content)},Wo=function(d){let f=null;const w=Zt(d);for(Pe(j.beforeSanitizeShadowDOM,d,null);f=w.nextNode();)if(Pe(j.uponSanitizeShadowNode,f,null),Uo(f,d),N(f)===ne.element){const T=D(f);Et(T)&&(Go(T),Wo(T))}Q&&Ho(d),Pe(j.afterSanitizeShadowDOM,d,null)},Go=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const w=f.pop();if(w.shadow){Wo(w.shadow);continue}const T=w.node,R=N(T)===ne.element,I=y(T);if(I)for(let $=I.length-1;$>=0;--$)f.push({node:I[$],shadow:null});if(R){const $=F?F(T):null;if(typeof $=="string"&&ie($)==="template"){const de=T.content;Et(de)&&f.push({node:de,shadow:null})}}if(R){const $=D(T);Et($)&&f.push({node:null,shadow:$},{node:$,shadow:null})}}};return e.sanitize=function(E){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,w=null,T=null,R=null;if(_o=!E,_o&&(E="<!-->"),typeof E!="string"&&!Rt(E)&&(E=Qa(E),typeof E!="string"))throw Ke("dirty is not a string, aborting");if(!e.isSupported)return E;ko?(Y=qt,X=Kt):Io(d),e.removed=[];const I=Mo&&typeof E!="string"&&Rt(E);let $=[];const de=lt;if(I){ua(E);const Ne=L(E);if(typeof Ne=="string"){const me=ie(Ne);if(!Y[me]||st[me])throw Lo(E),Ke("root node is forbidden and cannot be sanitized in-place")}if(Qt(E))throw Lo(E),Ke("root node is clobbered and cannot be sanitized in-place");$=No(E),lt=Ko()}else if(Rt(E))f=nn("<!---->"),w=f.ownerDocument.importNode(E,!0),w.nodeType===ne.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?f=w:f.appendChild(w),Go(f);else{if(!xt&&!Q&&!We&&E.indexOf("<")===-1)return De(E);if(f=nn(E),!f)return xt?null:Ao?pe:""}f&&Co&&et(f.firstChild);const Ge=I?E:f;try{I&&Go(E);const Ne=Zt(Ge);for(;T=Ne.nextNode();)Uo(T,Ge);I&&da(E,$)}catch(Ne){throw I&&(Lo(E),tn(E,$)),Ne}finally{lt=de}if(I){if(tn(E,$))throw Ke("a node selected for removal could not be safely returned; refusing to sanitize in place");return Q&&Bo(E),E}if(xt){if(Q&&Bo(f),Vt)for(R=G.call(f.ownerDocument);f.firstChild;)R.appendChild(f.firstChild);else R=f;return(X.shadowroot||X.shadowrootmode)&&(R=Wt.call(i,R,!0)),R}const Ie=()=>We?f.outerHTML:f.innerHTML;let Se=Ie();return Q&&he(as,Se)&&(Ho(f),Se=Ie()),We&&Y["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&he(ps,f.ownerDocument.doctype.name)&&(Se="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
|
|
3
|
-
`+Se),De(Se)},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Io(E),ko=!0,qt=Y,Kt=X},e.clearConfig=function(){Xt=null,ko=!1,qt=null,Kt=null,H=te,pe=""},e.isValidAttribute=function(E,d,f){Xt||Io({});const w=ie(E),T=ie(d);return typeof f=="string"&&(dn(d,f)||!ge&&he(Cn,f))?!1:sn(w,T,f)},e.addHook=function(E,d){typeof d=="function"&&xe(j,E)&&Pt(j[E],d)},e.removeHook=function(E,d){if(xe(j,E)){if(d!==void 0){const f=Wa(j[E],d);return f===-1?void 0:qa(j[E],f,1)[0]}return bn(j[E])}},e.removeHooks=function(E){xe(j,E)&&(j[E]=[])},e.removeAllHooks=function(){j=An()},e}var vs=Ar();const ys={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function ws(t,e){const o=t.options;return c.resolveBarcodeDesignValue(o.formatter,e,String(o.testData||o.title||""))||"1234567890128"}function Es(t){return a("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function Ss(t){const e=t.options;return a("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:ys[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function Ts(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(o=>!Number.isFinite(o))?null:{width:e[2],height:e[3]}}function ks(t,e,o){const i=t.options,n=c.barcodeUnitsPerModule(i.barWidth),r=c.barcodeQuietZoneModules(i.barQuietZone),s=l=>{nr(e,ws(t,o),{format:String(i.barcodeType||"CODE128"),width:n,height:l*n,displayValue:!i.hideTitle,fontSize:(i.fontSize??c.BARCODE_TEXT_FONT_SIZE_MODULES)*n,margin:0,marginLeft:r*n,marginRight:r*n,marginTop:0,marginBottom:c.BARCODE_MARGIN_BOTTOM_MODULES*n});const p=Ts(e);return p?{widthUnits:p.width,heightUnits:p.height}:null};try{const l=c.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:c.barcodeAvailableBoxMm(i.width,i.maxWidth),boxHeightMm:c.barcodeAvailableBoxMm(i.height,i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:s});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 Cs(t,e,o){const i=t.options,n=c.resolveBarcodeDesignValue(i.formatter,o,String(i.testData||i.title||""))||"二维码";e.replaceChildren();try{const r=Si.browserCodeRenderer.render(n,"qrcode",{qrCodeLevel:String(i.qrCodeLevel??"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),s=document.createElement("img");s.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`,s.alt="qrcode",s.style.width="100%",s.style.height="100%",s.style.objectFit=String(i.fit||"contain"),s.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",s.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",e.appendChild(s)}catch{}}function As(t,e,o){for(const i of Array.from(t.querySelectorAll("[data-code-kind]"))){const n=i.dataset.codeId,r=e.find(s=>s.id===n);if(r)if(i.dataset.codeKind==="barcode"){const s=i.querySelector("svg");s&&ks(r,s,o)}else Cs(r,i,o)}}const co=new Map;function Ds(t){return typeof Node<"u"&&t instanceof Node}function Dr(t,e,o){if(Mr(t),typeof e=="string"){o.innerHTML=e;return}if(Ds(e)){o.appendChild(e);return}typeof e.node=="string"?o.innerHTML=e.node:o.appendChild(e.node),typeof e.dispose=="function"&&co.set(t,e.dispose)}function Mr(t){const e=co.get(t);if(e){co.delete(t);try{e()}catch{}}}function Dn(){for(const t of[...co.keys()])Mr(t)}const Ms={header:"题",data:"数",subtotal:"小",summary:"汇"},_s=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],ro=3.7795275591,Rs=.1,gi=t=>JSON.parse(JSON.stringify(t)),Mn=new WeakMap;function Xe(t){let e=Mn.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Mn.set(t,e)),e}function Ut(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function Ps(t,e){const o=t.tableSelection;return!o||o.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):o}function _r(t,e,o,i){const n=Ut(t,o.id);if(!n)return null;const r=o.options;return{store:t,fire:e,el:o,real:n,options:r,rows:r.tableRows??[],colWidths:r.tableColWidths??[],isSelected:t.selectedIds.has(o.id),selection:Ps(t,o),maxTableWidth:Rr(t),designData:i}}function Rr(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function _i(t){return t.options.tableDefaultFontSize??10}function Pr(t){return t.options.tableDefaultColor??"#333333"}function Is(t,e){let o=0;for(let i=0;i<e;i++)o+=t.rows[i].height;return o}function Ls(t,e){return Xe(t.store).layouts.get(t.el.id)?.[e]?.top??Is(t,e)}function Fs(t,e){return Xe(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function zs(t){const e=t.options.dataSource;if(e&&Array.isArray(c.DEFAULT_DEMO_DATA[e]))return c.DEFAULT_DEMO_DATA[e];for(const o of Object.values(c.DEFAULT_DEMO_DATA))if(Array.isArray(o))return o}function Ir(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function Lr(t,e){return Ir(e)?c.resolveBarcodeDesignValue(e.formatter,zs(t)):e.formatter||""}function Os(t,e){const o={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:_.resolveCanvasFontFamily(e.fontFamily??t.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??_i(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??Pr(t),backgroundColor:e.backgroundColor??"transparent",borderTop:c.resolveCellBorderCss(e.borders?.top,o),borderRight:c.resolveCellBorderCss(e.borders?.right,o),borderBottom:c.resolveCellBorderCss(e.borders?.bottom,o),borderLeft:c.resolveCellBorderCss(e.borders?.left,o),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function Ns(t,e,o){const i=t.selection;return[!!i&&e>=i.r1&&e<=i.r2&&o>=i.c1&&o<=i.c2?"cell-selected":"",t.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function Fr(t){return c.resolveCellTextFit(t)}function $s(t){return Fr(t)!=="autoHeight"}function Bs(t,e){return e.fontSize??_i(t)}function go(t,e,o){return c.cellFitCapMm(t.rows,e,o,t.options.tableDefaultPadding??1)}function Hs(t,e,o){return c.cellFitWidthMm(t.colWidths,e,o,t.options.tableDefaultPadding??1)}function Us(t,e,o){return{maxHeight:go(t,o,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function Ws(t,e,o){const i={fitBase:String(Bs(t,e)),fitMin:String(c.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(go(t,o,e))};return Fr(e)==="shrink"&&(i.fit="shrink"),i}function Gs(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(o=>!Number.isFinite(o))?null:{width:e[2],height:e[3]}}const qs={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Ks(t,e,o,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(Ta,"svg");n.appendChild(r);const s=Lr(t,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",qs[i.fit||"contain"]??"xMidYMid meet");const l=c.barcodeUnitsPerModule(i.barWidth),p=c.barcodeQuietZoneModules(i.barQuietZone),u=g=>{nr(r,s,{format:i.barcodeType||"CODE128",width:l,height:g*l,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??c.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:p*l,marginRight:p*l,marginTop:0,marginBottom:c.BARCODE_MARGIN_BOTTOM_MODULES*l});const S=Gs(r);return S?{widthUnits:S.width,heightUnits:S.height}:null};let h=null;try{h=c.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:c.barcodeAvailableBoxMm(Hs(t,o,i),i.maxWidth),boxHeightMm:c.barcodeAvailableBoxMm(go(t,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=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=Si.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),p=document.createElement("img");p.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),p.setAttribute("alt","qrcode"),p.style.width="100%",p.style.height="100%",p.style.objectFit=i.fit||"contain",i.objectPosition&&(p.style.objectPosition=i.objectPosition),p.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",p.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(p)}catch{}return n}function _n(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function Vs(t,e){const o=t.formatter||"";if(!o)return"";if(!o.includes("{"))return o;const i=e.designData?.length?e.designData[0]:c.DEFAULT_DEMO_DATA;return c.evaluateTemplate(o,i)}function js(t,e,o){const i=document.createElement("div");i.className="cell-image";const n=c.cellImageBoxMm(o.fit,go(t,e,o));n!==void 0&&(i.style.height=`${n}mm`);const r=Vs(o,t);if(!r)return i.appendChild(_n()),i;const s=document.createElement("img");s.setAttribute("src",r),n!==void 0&&(s.style.width="100%",s.style.height="100%"),s.style.objectFit=o.fit||"contain";for(const[l,p]of Object.entries(c.cropStyleDeclarations(o.fit,o.fitScale,o.objectPosition)))s.style[l]=p;return s.style.maxWidth=o.maxWidth?`${o.maxWidth}mm`:"100%",s.style.maxHeight=o.maxHeight?`${o.maxHeight}mm`:"100%",s.addEventListener("error",()=>{s.remove(),i.appendChild(_n())},{once:!0}),i.appendChild(s),i}function Ys(t,e,o,i,n){if(Ir(n))return Ks(t,o,i,n);if(n.cellType==="image")return js(t,o,n);const r=Lr(t,n),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return $s(n)?a("div",{class:"cell-fit",style:Us(t,n,o),dataset:Ws(t,n,o)},[s()]):s()}function po(t,e,o){const i={elementId:t.el.id,...c.normalizeSelection(t.rows,e,o)};t.store.setTableSelection(i),t.fire("table-selection-change",{elementId:t.el.id,selection:i})}function Xs(t,e,o,i,n){if(n.button!==0||(t.fire("table-cell-mousedown",{elementId:t.el.id,r:e,c:o,cellId:i,event:n}),!t.isSelected))return;n.stopPropagation();const r=Xe(t.store);n.shiftKey&&t.selection?po(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:o}):(r.anchor={r:e,c:o},po(t,{r:e,c:o},{r:e,c:o})),document.addEventListener("mouseup",()=>{Xe(t.store).anchor=null},{once:!0})}function Zs(t,e,o){const i=Xe(t.store).anchor;i&&po(t,i,{r:e,c:o})}function Ri(t,e){const o=Xe(t);o.menu?.visible&&(o.menu.visible=!1,e("table-menu-close",{elementId:o.menuElId}),t.emit(!1))}function Qs(t,e,o,i){i.preventDefault(),i.stopPropagation(),t.isSelected||t.store.selectOne(t.el.id);const n=t.selection;n&&e>=n.r1&&e<=n.r2&&o>=n.c1&&o<=n.c2||po(t,{r:e,c:o},{r:e,c:o});const s=Xe(t.store);s.menuElId=t.el.id,s.menu&&(s.menu.x=i.clientX,s.menu.y=i.clientY,s.menu.visible=!0),t.fire("table-cell-contextmenu",{elementId:t.el.id,r:e,c:o,clientX:i.clientX,clientY:i.clientY}),t.store.emit(!1),document.addEventListener("mousedown",()=>Ri(t.store,t.fire),{once:!0})}function Rn(t,e,o){const i=t.reduce((n,r)=>n+r,0)+(t[e]??0);return i>o?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${o}mm,请先缩小列宽`:null}function Js(t,e){const o=t.real.options.tableRows??[],i=t.real.options.tableColWidths??[],n=e(gi(o),gi(i));return n?(window.alert(n),!1):(t.store.recordHistory(),e(o,i),t.store.setTableSelection(null),c.syncTableElementSize(t.real.options),t.store.emit(),!0)}function Ve(t,e,o){Ri(t.store,t.fire);const i=t.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(c.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(c.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>c.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,s)=>{const l=Rn(s,i.c1,t.maxTableWidth);return l||(c.insertCol(r,s,i.c1,"left"),null)};break;case"insert-col-right":n=(r,s)=>{const l=Rn(s,i.c2,t.maxTableWidth);return l||(c.insertCol(r,s,i.c2,"right"),null)};break;case"delete-col":n=(r,s)=>c.deleteCol(r,s,i.c1);break;case"merge":n=r=>(c.mergeCells(r,i),null);break;case"split":n=r=>(c.splitCells(r,i),null);break;case"set-row-type":n=r=>o?c.setRowType(r,i.r1,o):"未指定行类型";break}n&&Js(t,n)&&t.fire(`table-${e}`,{elementId:t.el.id,...o?{type:o}:{}})}function el(t){const e=t.selection;if(!e)return!1;for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const n=t.rows[o]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function tl(t){const e=t.selection;if(!e)return;const o=c.findMainCell(t.rows,e.r1,e.c1),i=!t.rows[o.r]?.cells[o.c]?.mergeSameValue;for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=t.rows[n]?.cells[r];s&&!s.merged&&(s.mergeSameValue=i)}t.store.updateElement(t.el.id,{tableRows:t.rows}),Ri(t.store,t.fire)}function Pn(t){const e=t.selection;if(!e)return"未选择单元格";for(let o=e.r1;o<=e.r2;o++)if(t.rows[o]?.type!=="data")return"仅数据行(明细行)支持按值合并";return null}function In(t,e){const o=t.selection;return o?o.r1!==o.r2?"行类型仅支持单行设置":c.setRowType(gi(t.rows),o.r1,e):"未选择单元格"}function $e(t,e,o={}){return a("div",{class:`menu-item${o.disabled?" disabled":""}${o.active?" active":""}`,title:o.title||"",text:t,onClick:()=>{o.disabled||e()}})}const oi=()=>a("div",{class:"menu-divider"});function ol(t,e,o){const i=Xe(t);if(i.menu=o,!o.visible||!i.menuElId)return"";const n=Ut(t,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=_r(t,e,n);if(!r)return"";const s=r.selection?c.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:o.x+"px",top:o.y+"px"},onMousedown:p=>p.stopPropagation()},[$e("在上方插入行",()=>Ve(r,"insert-row-above")),$e("在下方插入行",()=>Ve(r,"insert-row-below")),$e("删除行",()=>Ve(r,"delete-row"),{disabled:r.rows.length<=1}),oi(),$e("在左侧插入列",()=>Ve(r,"insert-col-left")),$e("在右侧插入列",()=>Ve(r,"insert-col-right")),$e("删除列",()=>Ve(r,"delete-col"),{disabled:r.colWidths.length<=1}),oi(),$e("合并单元格",()=>Ve(r,"merge"),{disabled:!!s,title:s||""}),$e("拆分单元格",()=>Ve(r,"split"),{disabled:!el(r)}),$e("按值合并",()=>tl(r),{disabled:!!Pn(r),title:Pn(r)||"",active:(()=>{const p=r.selection;if(!p)return!1;const u=c.findMainCell(r.rows,p.r1,p.c1);return r.rows[u.r]?.cells[u.c]?.mergeSameValue===!0})()}),oi(),a("div",{class:"menu-group-title",text:"行类型"}),..._s.map(p=>$e(p.label,()=>Ve(r,"set-row-type",p.value),{disabled:!!In(r,p.value),title:In(r,p.value)||"",active:l===p.value}))])}let gt=null;function zr(){gt&&(document.removeEventListener("mousemove",Pi),document.removeEventListener("mouseup",Ii),gt.handle.classList.remove("dragging"),gt=null)}function il(t,e){const o=t.closest(".hiprint-printPaper");return(o&&o.offsetWidth>0?o.getBoundingClientRect().width/o.offsetWidth:0)||(e.scale||100)/100}function nl(t,e,o){if(o.button!==0)return;const i=o.currentTarget,n=i.closest(".print-table");if(!n)return;zr();const r=t.real.options.tableColWidths??[];gt={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:o.clientX,startWidth:r[e-1]??0,scale:il(n,t.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",Pi),document.addEventListener("mouseup",Ii)}function Pi(t){const e=gt;if(!e)return;const o=Ut(e.store,e.elId),i=o?.options.tableColWidths;if(!o||!i)return;const n=(t.clientX-e.startX)/(e.scale*ro),r=e.boundary-1;i[r]=c.clampResizedColumnWidth(i,r,e.startWidth+n,Rr(e.store)),c.syncTableElementSize(o.options),i.forEach((s,l)=>{const p=e.root.querySelector(`colgroup col:nth-child(${l+1})`);p&&(p.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${i.slice(0,l+1).reduce((p,u)=>p+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${o.options.width}mm`,e.wrapper.style.height=`${o.options.height}mm`)}function Ii(){document.removeEventListener("mousemove",Pi),document.removeEventListener("mouseup",Ii);const t=gt;if(!t)return;gt=null,t.handle.classList.remove("dragging");const e=Ut(t.store,t.elId);e&&c.syncTableElementSize(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function rl(t,e,o){const i=o.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Ut(t,e);if(!r)return;let s=!1;const l=n/ro;Math.abs(l-(r.options.height??0))>Rs&&(r.options.height=Math.round(l*100)/100,s=!0);const p=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-p)/ro,height:m.offsetHeight/ro})),h=Xe(t);al(h.layouts.get(e),u)||(h.layouts.set(e,u),s=!0),s&&t.emit(!1)}function al(t,e){return!t||t.length!==e.length?!1:e.every((o,i)=>{const n=t[i];return Math.round(o.top*10)===Math.round(n.top*10)&&Math.round(o.height*10)===Math.round(n.height*10)})}function sl(t,e){const o=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const i=o.parentElement;i&&rl(t,e,i)}),o}function ll(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function dl(t){return Array.from({length:t.colWidths.length},(e,o)=>o+1)}function cl(t,e){return t.colWidths.slice(0,e).reduce((o,i)=>o+i,0)}function pl(t,e,o,i){const n=_r(e,o,t,i);if(!n)return a("div",{class:"print-table"});const r=[a("table",{style:{fontSize:`${_i(n)}pt`,color:Pr(n)}},[a("colgroup",{},n.colWidths.map(s=>a("col",{style:{width:s+"mm"}}))),a("tbody",{},n.rows.map((s,l)=>a("tr",{style:{height:s.height+"mm"}},s.cells.map((p,u)=>p.merged?"":a("td",{rowspan:p.rowspan||1,colspan:p.colspan||1,class:Ns(n,l,u),style:Os(n,p),onMousedown:h=>Xs(n,l,u,p.id,h),onMouseenter:()=>Zs(n,l,u),onContextmenu:h=>Qs(n,l,u,h)},[Ys(n,s,l,u,p)])).filter(Boolean))))])];return ll(n)&&r.push(a("div",{class:"col-resize-layer"},dl(n).map(s=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${s}`,style:{left:cl(n,s)+"mm"},onMousedown:l=>{l.stopPropagation(),l.preventDefault(),nl(n,s,l)}})))),n.isSelected&&r.push(a("div",{class:"row-badges"},n.rows.map((s,l)=>a("span",{class:"row-badge",style:{top:Ls(n,l)+"mm",height:Fs(n,l)+"mm"},text:Ms[s.type]})))),r.push(sl(e,t.id)),a("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:s=>s.preventDefault()},r)}const ul=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function mi(t){return Array.isArray(t)&&t.length>0?t:[]}function hl(t,e){const o=c.detectFlowListKey(t,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(o)return mi(e?.[o]);const i=c.detectFlowListKey(t,c.DEFAULT_DEMO_DATA);return i?mi(c.DEFAULT_DEMO_DATA[i]):[]}function fl(t,e){const o=t.options,i=typeof o.formatter=="string"?o.formatter:"",n=mi(e)[0],r=hl(i,n);if(r.length===0)return[...ul];if(!i)return r.map(p=>String(p?.name??JSON.stringify(p)));const s=n??{},l=c.detectFlowListKey(i,s)??Object.keys(s).find(p=>Array.isArray(s[p]));return r.map(p=>{try{return c.evaluateTemplate(i,{...s,...p,...l?{[l]:p}:{}})}catch{return i}})}const gl=3.7795275591,ml=.1;function bl(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function xl(t){const e=t.parentElement;if(!e?.classList.contains("print-element"))return 0;const o=getComputedStyle(e);return(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0)}function vl(t,e,o){const i=o.offsetHeight+xl(o);if(i<=0)return;const n=bl(t,e);if(!n)return;const r=i/gl;Math.abs(r-(n.options.height??0))>ml&&(n.options.height=Math.round(r*100)/100,t.emit(!1))}function yl(t,e){const o=document.createComment("pd-flowlist-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const i=o.parentElement;i&&vl(t,e,i)}),o}function wl(t,e,o){const i=t.options,n=c.resolveFlowColumns(i.flowColumns),r=c.resolveFlowGapX(i.flowGapX),s=c.resolveFlowRowHeight(i.flowRowHeight),l=c.resolveFlowLayoutMode(i.flowLayoutMode)==="dynamic",p=c.resolveFlowPadding(i),u={display:"grid",gridTemplateColumns:`repeat(${n},minmax(0,1fr))`,columnGap:`${r}mm`,gridAutoRows:`minmax(${s}mm,auto)`,width:"100%",...l?{padding:`${p.top}mm ${p.right}mm ${p.bottom}mm ${p.left}mm`,height:"auto",overflow:"visible"}:{height:"100%",overflow:"hidden"},fontSize:`${i.fontSize||12}pt`,fontWeight:i.fontWeight||"normal",color:i.color||"#333",boxSizing:"border-box"};i.fontFamily&&(u.fontFamily=String(i.fontFamily)),i.backgroundColor&&(u.backgroundColor=String(i.backgroundColor));const h=fl(t,e).map(m=>a("div",{class:"print-flow-cell",text:m}));return l&&o&&h.push(yl(o,t.id)),a("div",{class:"print-flowlist",style:u},h)}const Ln={top:"flex-start",middle:"center",bottom:"flex-end"},El={left:"flex-start",center:"center",right:"flex-end"};function Sl(t,e){const o=t.options,i=c.resolveElementMargins(o),n=c.resolveElementBorder(t.printElementType.type,o),r={};if(n?.all&&(r.border=`${n.all.borderWidth} ${n.all.borderStyle} ${n.all.borderColor}`),n)for(const s of c.ELEMENT_BORDER_SIDES){const l=n.edges[s];l&&(r[`border${s.charAt(0).toUpperCase()}${s.slice(1)}`]=`${l.borderWidth} ${l.borderStyle} ${l.borderColor}`)}return{position:"absolute",left:`${o.left}mm`,top:`${o.top}mm`,width:`${o.width}mm`,height:`${o.height}mm`,...i.top!==0?{marginTop:`${i.top}mm`}:{},...i.right!==0?{marginRight:`${i.right}mm`}:{},...i.bottom!==0?{marginBottom:`${i.bottom}mm`}:{},...i.left!==0?{marginLeft:`${i.left}mm`}:{},zIndex:String(o.zIndex||"auto"),...r,...Tl(t,e)}}function Tl(t,e){if(e?.has(t.id))return{};const o=c.resolveElementRotation(t.printElementType.type,t.options);return o===void 0?{}:{rotate:`${o}deg`}}function Fn(t){const e=t.options,o=t.printElementType.type==="longText",i=c.resolveElementTextFit(t.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",s={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:_.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:o?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...o?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};c.resolveElementNowrap(e)&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis");const l=c.resolveElementWhiteSpace(e);return l&&(s.whiteSpace=l),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Ln[e.verticalAlign]??"flex-start"):(s.alignItems=Ln[e.verticalAlign]??"flex-start",s.justifyContent=El[e.textAlign||"left"]??"flex-start")),{style:s,fit:i}}function zn(t){const e=t.options,o=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return t.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${o} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${o} ${i} ${n}`,boxSizing:"border-box"}}function On(t){const e=t.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:t.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function kl(t){const e=t.options;return{objectFit:e.fit||"contain",...c.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function Nn(t){const e=t.options,o={fitBase:String(e.fontSize||12),fitMin:String(c.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return c.resolveElementTextFit(t.printElementType.type,e)==="shrink"&&(o.fit="shrink"),o}const Cl={text:t=>{const{style:e}=Fn(t),o=t.options;return a("div",{class:"print-text",style:e,dataset:Nn(t),text:String(o.testData||o.formatter||"")||"文本"})},longText:t=>{const{style:e}=Fn(t),o=t.options;return a("div",{class:"print-longtext",style:e,dataset:Nn(t),text:String(o.formatter||"")||"长文本内容"})},hline:t=>a("div",{class:"print-line",style:zn(t)}),vline:t=>a("div",{class:"print-line",style:zn(t)}),rect:t=>a("div",{class:"print-shape",style:On(t)}),oval:t=>a("div",{class:"print-shape",style:On(t)}),image:(t,e,o)=>{const i=t.options,n=String(i.src??""),r=o?.designData?.length?o.designData[0]:c.DEFAULT_DEMO_DATA,s=n.includes("{")?c.evaluateTemplate(n,r):n;return a("div",{class:"print-image"},[s?a("img",{src:s,style:kl(t)}):a("div",{class:"image-placeholder",text:"图片"})])},qrcode:t=>Es(t),barcode:t=>Ss(t),html:t=>{const e=t.options,o=String(e.formatter??""),i=o?vs.sanitize(c.evaluateTemplate(o,{})):'<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:i})},pageNumber:(t,e)=>{const o=t.options;return a("div",{class:"page-number-element",style:{fontSize:`${o.fontSize||12}pt`,fontWeight:o.fontWeight||"normal",fontFamily:_.resolveCanvasFontFamily(o.fontFamily),color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:e?o.title||"{pageIndex}/{totalPages}":String(o.title||"")})},table:(t,e,o)=>o?pl(t,o.store,o.fire,o.designData):a("div",{class:"print-table"}),flowList:(t,e,o)=>wl(t,void 0,o?.store)};cr(Cl);function Al(t,e,o){const i=t.printElementType.type,n=nt(i)?.renderContent;if(n)return n(t,e,o);const r=Ci(i);if(!r)return a("div",{text:i});const s=document.createElement("div");s.className="plugin-kit-canvas",s.style.width="100%",s.style.height="100%";try{Dr(`canvas:${t.id}`,r.ui.renderCanvas({element:t,data:o?.designData?.length?o.designData:[c.DEFAULT_DEMO_DATA],designMode:!0}),s)}catch{s.textContent=String(i)}return s}function Or(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function Dl(t,e,o){const i=t.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),s=e.options,l=e.zone||"content",p=[Al(e,!0,{store:i,fire:t.fire,designData:t.host.designData})];return i.draggingIds.has(e.id)&&p.push(a("div",{class:"drag-preview"})),n&&(p.push(a("div",{class:"resize-handles"},c.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>t.fire("resize-start",{event:h,id:e.id,point:u})})))),p.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Or(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:Sl(e,o),dataset:{elId:e.id},onMousedown:u=>t.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),t.fire("contextmenu",{event:u,id:e.id})}},p)}function bi(t,e){const o=t.margins,i=t.header?.height??10,n=t.footer?.height??10,r=e.width-o.left-o.right;return{header:{left:o.left,top:o.top,width:r,height:i},content:{left:o.left,top:o.top+i,width:r,height:e.height-o.top-o.bottom-i-n},footer:{left:o.left,top:e.height-o.bottom-n,width:r,height:n}}}const Ml='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>';function $n(t,e){return t.type==="vertical"?{left:`${t.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${t.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}}function _l(t,e){const o=_.resolveWatermarkLayout(t.watermark,[],e);return o?a("div",{class:"watermark-layer",style:{opacity:String(o.opacity)}},o.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${o.tileWidthPx} ${o.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(o.tileWidthPx/2),y:String(o.tileHeightPx/2),"font-size":String(o.fontSizePx),fill:o.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${o.rotate},${o.tileWidthPx/2},${o.tileHeightPx/2})`,text:o.text})]))):""}function ii(t,e,o,i,n,r){const s=t.store,l=[];o!=="content"&&l.push(a("span",{class:"zone-label",text:o==="header"?"页眉":"页脚"}));const p=o==="content"?_.collectFollowMemberIds(n):void 0;if(l.push(...n.map(u=>Dl(t,u,p))),o!=="content"){const u=o==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:o},onMousedown:h=>t.fire("zone-resize",{event:h,zone:o})},[e.zoneResizing===o?a("div",{class:"zone-height-tip",text:`${(o==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${o} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:o,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function Rl(t){const e=t.currentTarget,o=t.dataTransfer?.types??[],i=o.includes("fieldkey"),n=o.includes("elementtype");if(!i&&!n){e.querySelector(".drop-hint")?.remove();return}i&&(t.ctrlKey||t.metaKey)&&(e.dataset.dropLabelIntent="1");const r=n?"+ 元素":e.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let s=e.querySelector(".drop-hint");s||(s=document.createElement("div"),s.className="drop-hint",e.appendChild(s)),s.textContent=r,s.style.left=`${t.clientX+14}px`,s.style.top=`${t.clientY+18}px`}function Nr(t){t&&(t.querySelector(".drop-hint")?.remove(),delete t.dataset.dropLabelIntent)}function Pl(t,e){const o=t.store,i=o.templateData,n=_.getPaperDimensions(i),r=(o.scale||100)/100,s=bi(i,n),l=m=>o.elements.filter(g=>(g.zone||"content")===m),p=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[o.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(Ml)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[_l(i,n)]:[],ii(t,e,"header",s.header,l("header"),n),ii(t,e,"content",s.content,l("content"),n),ii(t,e,"footer",s.footer,l("footer"),n),...o.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:$n(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...$n(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>t.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),t.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],p]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${_.mmToPx(n.width)*r}px`,height:`${_.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(o.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>t.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>t.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Le(t,m,"复制","copy"),Le(t,m,"剪切","cut"),Le(t,m,"粘贴","paste",!o.hasClipboard),Le(t,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Le(t,m,"置顶","move-layer",!1,"top"),Le(t,m,"上移","move-layer",!1,"up"),Le(t,m,"下移","move-layer",!1,"down"),Le(t,m,"置底","move-layer",!1,"bottom")]:[Le(t,m,"粘贴","paste-at",!o.hasClipboard),Le(t,m,"全选","select-all"),Le(t,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>{const g=m;g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"),Rl(g)},onDragleave:m=>{const g=m.currentTarget,S=m.relatedTarget;(!S||!g.contains(S))&&g.querySelector(".drop-hint")?.remove()},onDrop:m=>{const g=m,S=m.currentTarget,b=S.dataset.dropLabelIntent==="1";Nr(S),b&&(g.labelIntent=!0),t.fire("drop",g)},onMousedown:m=>t.fire("canvas-mousedown",m),onMousemove:m=>t.fire("canvas-mousemove",m),onMouseleave:()=>t.fire("canvas-mouseleave"),onWheel:m=>t.fire("wheel",m),onScroll:m=>t.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),t.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Le(t,e,o,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:o,onClick:()=>{e.visible=!1,n||t.fire(i,r),t.repaint()}})}const Il={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Barcode:'<path d="M3 5v14" /><path d="M8 5v14" /><path d="M12 5v14" /><path d="M17 5v14" /><path d="M21 5v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChartArea:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z" />',ChartBar:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 16h8" /><path d="M7 11h12" /><path d="M7 6h3" />',ChartColumn:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M18 17V9" /><path d="M13 17V5" /><path d="M8 17v-3" />',ChartLine:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="m19 9-5 5-4-4-3 3" />',ChartPie:'<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z" /><path d="M21.21 15.89A10 10 0 1 1 8 2.83" />',ChartScatter:'<circle cx="7.5" cy="7.5" r=".5" fill="currentColor" /><circle cx="18.5" cy="5.5" r=".5" fill="currentColor" /><circle cx="11.5" cy="11.5" r=".5" fill="currentColor" /><circle cx="7.5" cy="16.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="14.5" r=".5" fill="currentColor" /><path d="M3 3v16a2 2 0 0 0 2 2h16" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsLeft:'<path d="m11 17-5-5 5-5" /><path d="m18 17-5-5 5-5" />',ChevronsRight:'<path d="m6 17 5-5-5-5" /><path d="m13 17 5-5-5-5" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',Circle:'<circle cx="12" cy="12" r="10" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Code:'<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Donut:'<path d="M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3" /><circle cx="12" cy="12" r="3" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',FileText:'<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 9H8" /><path d="M16 13H8" /><path d="M16 17H8" />',Funnel:'<path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" />',Gauge:'<path d="m12 14 4-4" /><path d="M3.34 19a10 10 0 1 1 17.32 0" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Image:'<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',List:'<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />',ListTree:'<path d="M8 5h13" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="M3 10a2 2 0 0 0 2 2h3" /><path d="M3 5v12a2 2 0 0 0 2 2h3" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',Minus:'<path d="M5 12h14" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',QrCode:'<rect width="5" height="5" x="3" y="3" rx="1" /><rect width="5" height="5" x="16" y="3" rx="1" /><rect width="5" height="5" x="3" y="16" rx="1" /><path d="M21 16h-3a2 2 0 0 0-2 2v3" /><path d="M21 21v.01" /><path d="M12 7v3a2 2 0 0 1-2 2H7" /><path d="M3 12h.01" /><path d="M12 3h.01" /><path d="M12 16v.01" /><path d="M16 12h1" /><path d="M21 12v.01" /><path d="M12 21v-1" />',Radar:'<path d="M19.07 4.93A10 10 0 0 0 6.99 3.34" /><path d="M4 6h.01" /><path d="M2.29 9.62A10 10 0 1 0 21.31 8.35" /><path d="M16.24 7.76A6 6 0 1 0 8.23 16.67" /><path d="M12 18h.01" /><path d="M17.99 11.66A6 6 0 0 1 15.77 16.67" /><circle cx="12" cy="12" r="2" /><path d="m13.41 10.59 5.66-5.66" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',SeparatorVertical:'<path d="M12 3v18" /><path d="m16 16 4-4-4-4" /><path d="m8 8-4 4 4 4" />',Shapes:'<path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z" /><rect x="3" y="14" width="7" height="7" rx="1" /><circle cx="17.5" cy="17.5" r="3.5" />',Square:'<rect width="18" height="18" x="3" y="3" rx="2" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',Table:'<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />',Table2:'<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Type:'<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function ce(t,e=15,o){const i=Il[t];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${o?` class="${o}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let ft=null;function Li(t){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return null;const o=e[1],i=o.length===3?o.split("").map(n=>n+n).join(""):o;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function Fi(t){const e=Li(t);return e?$r(e):"#000000"}function $r({r:t,g:e,b:o}){return`#${[t,e,o].map(i=>Math.round(Ht(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function Ll(t,e,o){const i=t/255,n=e/255,r=o/255,s=Math.max(i,n,r),l=Math.min(i,n,r),p=s-l;let u=0;return p!==0&&(s===i?u=(n-r)/p%6:s===n?u=(r-i)/p+2:u=(i-n)/p+4,u*=60,u<0&&(u+=360)),{h:u,s:s===0?0:p/s,v:s}}function Fl(t,e,o){const i=o*e,n=(t%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[s,l,p]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=o-i;return{r:(s+u)*255,g:(l+u)*255,b:(p+u)*255}}function zl(t){return((Number.isFinite(t)?t:0)%360+360)%360}function Ht(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function Ol(t){const e=t.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${t.triggerClass?` ${t.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:o=>{const i=o.currentTarget??o.target,n=i.getRootNode();if(!!ft&&ft.root===n&&ft.title===e&&ft.trigger===i){Nt();return}Nt(),Nl(i,t)}},[a("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function Nt(){const t=ft;t&&(ft=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function Nl(t,e){const o=t.getRootNode(),i=o instanceof ShadowRoot?o:document.body,n={root:o,title:e.title??"颜色选择",trigger:t,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&Oi(n,e.value)?n.hexText=Fi(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=ve(Ul(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:c.PRESET_COLORS[s]})),mo(n),$l(n),Bl(n),ft=n,t.setAttribute("aria-expanded","true")}function $l(t){const e=t.trigger.getBoundingClientRect(),o=190,i=t.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-o-n)),s=e.bottom+6,l=s+i>window.innerHeight-n?Math.max(n,e.top-i-6):s;t.panel.style.left=`${r}px`,t.panel.style.top=`${l}px`}function Bl(t){const e=n=>{const r=Hl(n);r.includes(t.trigger)||r.includes(t.panel)||Nt()},o=n=>{n.key==="Escape"&&Nt()},i=()=>Nt();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",o),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),t.root.addEventListener("scroll",i,!0),t.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",o),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>t.root.removeEventListener("scroll",i,!0))}function Hl(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function Ul(t){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>Gl(t,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>ql(t,e),onKeydown:e=>Kl(t,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>Vl(t,Number(e.target.value)),onChange:()=>Ni(t)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),t.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>uo(t,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},c.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>Wl(t,e)})))])}function zi(t){return $r(Fl(t.hue,t.saturation,t.value_))}function mo(t){const e=zi(t);t.hex.value!==t.hexText&&(t.hex.value=t.hexText),t.current.className=t.model?"picker-current":"picker-current is-empty",t.model?t.current.style.background=e:t.current.style.removeProperty("background"),t.area.style.setProperty("--picker-hue",`${Math.round(t.hue)}deg`),t.handle.style.left=`${t.saturation*100}%`,t.handle.style.top=`${(1-t.value_)*100}%`,t.handle.style.background=e;const o=String(Math.round(t.hue));t.hueRange.value!==o&&(t.hueRange.value=o),t.clearBtn&&(t.clearBtn.disabled=!t.model);for(const i of t.items)i.el.className=t.model&&i.color.toLowerCase()===t.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function Oi(t,e){const o=Li(e);if(!o)return!1;const i=Ll(o.r,o.g,o.b);return t.hue=i.h,t.saturation=i.s,t.value_=i.v,t.hexText=Fi(e).toUpperCase(),!0}function At(t,e,o,i){t.hue=zl(e),t.saturation=Ht(o),t.value_=Ht(i),t.hexText=zi(t).toUpperCase(),mo(t)}function Ni(t){const e=zi(t);t.model=e,mo(t),t.onChange(e)}function uo(t,e){t.model=e,e||(t.hexText=""),mo(t),t.onChange(e)}function Wl(t,e){Oi(t,e),uo(t,e)}function Gl(t,e){const o=e.trim();if(!o){t.clearable&&uo(t,void 0);return}Li(o)&&(Oi(t,o),uo(t,Fi(o)))}function ql(t,e){t.dragging=!0,Bn(t,e);const o=n=>{t.dragging&&Bn(t,n)},i=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),Ni(t))};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function Bn(t,e){const o=t.area.getBoundingClientRect();if(!o.width||!o.height)return;const i=Ht((e.clientX-o.left)/o.width),n=Ht(1-(e.clientY-o.top)/o.height);At(t,t.hue,i,n)}function Kl(t,e){const o=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?At(t,t.hue,t.saturation-o,t.value_):e.key==="ArrowRight"?At(t,t.hue,t.saturation+o,t.value_):e.key==="ArrowUp"?At(t,t.hue,t.saturation,t.value_+o):e.key==="ArrowDown"?At(t,t.hue,t.saturation,t.value_-o):i=!1,i&&(e.preventDefault(),Ni(t))}function Vl(t,e){At(t,e,t.saturation,t.value_)}function oe(t,e,o,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>t.fire(o,i.arg),html:ce(e)})}function ho(t,e,o,i){const n=t.state.openDd===e,r=()=>{t.state.openDd=n?null:e,t.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!o.disabled,dataset:{test:o.testId??e,tip:o.tip},onClick:r,html:`${o.icon?ce(o.icon):""}${o.text?`<span class="${o.textClass??"tb-btn-text"}">${o.text}</span>`:""}${ce("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${o.panelClass?` ${o.panelClass}`:""}`},i):""].filter(Boolean))}function O(t){const e=t.step??1,o=String(e),i=o.indexOf("."),n=i===-1?0:o.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,s=m=>{let g=r(m);return t.min!==void 0&&g<t.min&&(g=t.min),t.max!==void 0&&g>t.max&&(g=t.max),g},l=t.value===void 0||t.value===null||!Number.isFinite(t.value)?void 0:r(t.value),p=l??t.min??0,u=m=>{m!==l&&t.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:t.min,max:t.max,step:e,placeholder:t.placeholder,disabled:!!t.disabled,onChange:m=>{const g=m.target,S=(g.value??"").trim();if(S===""){l!==void 0&&(g.value=String(l));return}const b=Number(S);if(!Number.isFinite(b)){g.value=l===void 0?"":String(l);return}const k=s(b);g.value=String(k),u(k)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!t.disabled||p<=(t.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(s(p-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!t.disabled||p>=(t.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(s(p+e))})])}function W(t,e,o,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),i??""]),e,o?a("p",{class:"pd-hint",text:o}):""].filter(Boolean))}const xi=t=>a("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function be(t,e,o,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[t,xi(o)]),i??""]),e])}function bt(t){const e=t.base?.[t.propKey],o=t.target?.[t.propKey]!==e,i=t.force===!0||o,n=t.tipOverride??(t.tipValue===void 0?"恢复默认值":`恢复默认值(${t.tipValue}${t.tipUnit?" "+t.tipUnit:""})`),r=t.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${o&&!t.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ce("RotateCcw",13),onClick:()=>{i&&(t.write?t.write(e):t.target[t.propKey]=e,t.onReset?.())}})}const He=t=>a("h3",{class:"pd-divider",text:t});function Te(t,e,o="颜色选择",i){return Ol({value:t,title:o,triggerClass:i,onChange:n=>e(n)})}function rt(t,e,o,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:t,value:r.value,checked:o===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Br(t,e,o,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const s=document.createElement("option");s.value=r.value,s.textContent=r.label,r.disabled&&(s.disabled=!0),n.appendChild(s)}return n.value=t,e.some(r=>r.value===t)||(n.selectedIndex=-1),n.addEventListener("change",()=>o(n.value)),n}function jl(t){const e=window.innerHeight;for(let o=t.parentElement;o&&o!==document.body;o=o.parentElement){const i=getComputedStyle(o).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=o.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function bo(t){const e=_.normalizeFontCatalog(t.fonts),o=t.placeholder??"默认",i=`font-select-list-${t.id}`,n=L=>{const z=L?.trim();return z?_.findFontOption(e,z)?.label??z:""},r=L=>{const z=_.normalizeFontQuery(L);return e.find(H=>H.label&&_.normalizeFontQuery(H.label)===z)?.family??L},s=()=>{const L=t.value?.trim();return L?_.findFontOption(e,L)?"":L:""},l=L=>{const z=(t.value??"").trim(),ee=(te,ke,x,Z)=>({kind:te,key:ke,label:x,value:Z,selected:(Z??"")===z}),H=L.trim();if(!H){const te=[ee("clear","__clear__",o)],ke=s();ke&&te.push(ee("unknown","__unknown__",`${ke}(未知)`,ke));for(const x of e)te.push(ee("font",x.family,_.fontOptionLabel(x),x.family));return te}const pe=_.filterFontOptions(e,H).map(te=>ee("font",te.family,_.fontOptionLabel(te),te.family));if(!pe.length){const te=r(H);pe.push(ee("free","__free__",`使用「${te}」`,te))}return pe},p=document.createElement("div");p.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=o,u.disabled=!!t.disabled,u.value=n(t.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=t.state.fontOpen?.id===t.id?t.state.fontOpen:null,g={open:!!m&&!t.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const S=()=>{t.state.fontOpen=g.open?{id:t.id,query:g.query,highlighted:g.highlighted}:null};S();const b=()=>{const L=(t.value??"").trim();return l(g.query).findIndex(z=>(z.value??"")===L)},k=()=>{const L=u.getBoundingClientRect(),z=jl(u);h.classList.toggle("is-up",c.resolveOverlayPlacement({triggerTop:L.top,triggerBottom:L.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:z.top,boundaryBottom:z.bottom})==="up")},y=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||p.appendChild(h);const L=l(g.query);h.replaceChildren(...L.map((z,ee)=>{const H=document.createElement("li");return H.id=`${i}-${ee}`,H.className="font-select-option"+(ee===g.highlighted?" is-active":"")+(z.kind==="unknown"||z.kind==="free"?" is-muted":""),H.setAttribute("role","option"),H.setAttribute("aria-selected",String(z.selected)),H.textContent=z.label,H.addEventListener("mousedown",pe=>{pe.preventDefault(),K(z)}),H})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),k()},C=()=>{g.open||t.disabled||(g.open=!0,g.query="",g.highlighted=b(),S(),y())},D=()=>{g.open||C()},P=()=>{g.open=!0,g.query=u.value,g.highlighted=l(g.query).length?0:-1,S(),y()},A=L=>{if(!g.open){C();return}const z=l(g.query).length-1;if(z<0)return;g.highlighted=Math.min(Math.max(g.highlighted+L,0),z),S(),y(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},F=()=>{if(!g.open)return;const L=l(g.query)[g.highlighted];if(L){K(L);return}const z=g.query.trim();if(z){const ee=r(z);K({value:ee})}},K=L=>{g.open=!1,g.query="",g.highlighted=-1,S(),u.value=n(L.value),y(),t.onChange(L.value)},N=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,S(),u.value=n(t.value),y())};return u.addEventListener("focus",C),u.addEventListener("click",D),u.addEventListener("input",P),u.addEventListener("blur",N),u.addEventListener("keydown",L=>{const z=L;z.key==="ArrowDown"?(z.preventDefault(),A(1)):z.key==="ArrowUp"?(z.preventDefault(),A(-1)):z.key==="Enter"?(z.preventDefault(),F()):z.key==="Escape"&&(z.preventDefault(),N())}),p.append(u),y(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),p}const Yl=[{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"}],Xl={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function ot(t,e,o,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:t,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${o}</svg>`})}const kt='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',Hn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Zl(t){const e=t.format;e.syncBorderDraft();const o=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),p=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"},[ot("preset-none","无边框",`${kt}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),ot("preset-all","所有边框",`${Hn}<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")),ot("preset-outer","外侧边框",Hn,()=>e.applyBorderPreset("outer")),ot("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${kt}<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}),ot("edge-top","上边框",`${kt}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),ot("edge-bottom","下边框",`${kt}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),ot("edge-left","左边框",`${kt}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),ot("edge-right","右边框",`${kt}<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"},Yl.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),t.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[O({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),t.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Te(e.borderColor,g=>{e.setBorderColor(g),t.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,S,b])=>a("button",{type:"button",class:`ft-cell-btn${o.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:S},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ce(b)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,S,b])=>a("button",{type:"button",class:`ft-cell-btn${o.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:S},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ce(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:p},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),t.repaint()},onDblclick:()=>{e.pickPainterSource(!0),t.repaint()},html:ce("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[bo({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof o.fontFamily=="string"?o.fontFamily:void 0,placeholder:o.fontFamily===ht?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[O({value:typeof o.fontSize=="number"?o.fontSize:void 0,min:5,max:72,disabled:i,placeholder:o.fontSize===ht?"混合":"默认",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,S,b,k])=>a("button",{type:"button",class:`ft-btn${o[g]===!0?" on":""}`,dataset:{test:g,tip:u(b)},disabled:g==="bold"?i:n,onClick:k,html:ce(S)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Te(typeof o.color=="string"?o.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Te(typeof o.backgroundColor=="string"?o.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ce("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[ho(t,"align",{icon:Xl[String(o.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[ho(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}fo.filter(t=>t.material).map(t=>({type:t.type,label:t.label,icon:t.icon}));function xo(t,e){return ce(t??"Shapes",e)||ce("Shapes",e)}function Ql(t){const e=t.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[Un("ChevronsRight","展开素材台",()=>{e.leftCollapsed=!1,t.repaint()}),...[["elements","元素","Table2"],["fields","字段","ListTree"],["layers","图层","Layers"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,html:xo(r,14),onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,t.repaint()}}))])]);const o=(i,n,r="")=>a("div",{class:`pd-tab-pane${r?` ${r}`:""}`,role:"tabpanel",dataset:{pane:`left:${i}`},style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),Un("ChevronsLeft","收起素材台",()=>{e.leftCollapsed=!0,t.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,t.repaint()}}))]),o("elements",ed(),"material-grid"),o("fields",[td(t)]),o("layers",[od(t)])])])}function Un(t,e,o){return a("button",{type:"button",class:"collapse-btn",title:e,html:xo(t,14),onClick:o})}function Jl(t,e,o){return a("div",{class:`material-card${c.isWideMaterialLabel(e)?" material-card--wide":""}`,draggable:!0,dataset:{test:`material-${t}`},onDragstart:i=>{const n=i.dataTransfer;n?.setData("elementType",t),n&&(n.effectAllowed="all")}},[a("span",{class:"material-icon","data-icon":o,html:xo(o,14)}),a("span",{class:"material-label",text:e})])}function ed(){const t=[];let e;for(const o of ur()){const i=o.group;i&&i!==e&&t.push(a("div",{class:"material-group-title",text:i})),i&&(e=i),t.push(Jl(o.type,o.label,o.icon))}return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...t]}function td(t){const e=t.state,o=c.groupFields(t.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?o.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):o;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>t.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const 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),t.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",p=s?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{const m=h.dataTransfer;m?.setData("fieldKey",u.fieldKey),m&&(m.effectAllowed="all")},onClick:()=>{c.copyTextToClipboard(u.fieldLabel||u.fieldKey).then(h=>{h&&(e.copiedFieldKey=u.fieldKey,t.repaint(),setTimeout(()=>{e.copiedFieldKey===u.fieldKey&&(e.copiedFieldKey="",t.repaint())},1200))})}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})]),e.copiedFieldKey===u.fieldKey?a("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[l,a("div",{},p.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function od(t){const e=t.store,o=[...e.elements].sort((l,p)=>(p.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:"图层"}),...o.map(l=>{const p=gr(l.printElementType.type);return a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:u=>e.selectElement(l.id,u.ctrlKey||u.metaKey)},[a("span",{class:"layer-icon","data-icon":p??"Shapes",html:xo(p,12)}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))}),o.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,p,u])=>a("button",{type:"button",class:"pd-button small",title:p,html:ce(u,14),onClick:()=>t.fire("move-layer",l)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ce("Group",14),onClick:()=>t.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ce("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function id(t){const e=t.store,o=t.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,p)=>o.renamingPage===p?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:o.renameText??"",onInput:u=>{o.renameText=u.target.value},onBlur:()=>s(),onKeydown:u=>{const h=u;if(h.key==="Enter"){s();return}h.key==="Escape"&&(o.renamingPage=null,t.repaint())}}):a("button",{type:"button",class:`page-tab${p===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${p+1}`,onClick:()=>e.switchPage(p),onDblclick:()=>{o.renamingPage=p,o.renameText=l.name??"",t.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>t.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>t.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>t.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>t.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>t.fire("move-page",1)})])]);function s(){const l=(o.renameText??"").trim();o.renamingPage!==null&&l&&e.renamePage(o.renamingPage,l),o.renamingPage=null,t.repaint()}}function nd(t){const e=t.store,o=e.templateData,i=c.getPaperDimensions(o),n=o.orientation==="landscape"?"横向":"纵向",r=c.PAPER_PRESETS[o.paperSize]?.label??o.paperSize,s=o.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 rd=Object.keys(c.PAPER_PRESETS).filter(t=>t!=="CUSTOM"&&!c.PAPER_PRESETS[t]?.continuous);function ad(t){const e=document.createElement("label");e.className="pd-button small upload-label";const o=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(o,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const s=t.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),i.value="";return}n(!0),o.textContent="上传中...";try{const l=await s(r);l?t.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{o.textContent="上传背景图",n(!t.host.uploadDesignBackground),i.value=""}}),t.host.uploadDesignBackground||n(!0),e}function sd(t){const o=t.store.templateData.designBackground,i=o?.rotation??0;return a("div",{class:"design-background-config"},[He("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),o?.src?[a("div",{class:"design-background-path",title:o.src,text:o.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>t.store.updateTemplateData({designBackground:{...o,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>t.store.updateTemplateData({designBackground:void 0})})])]:ad(t)].flat())}function ld(t){const e=t.store,o=e.templateData,i=o.tiling,n={..._.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{..._.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=c.isContinuousPaperSize(o.paperSize),s=b=>e.updateTemplateData({tiling:{...n,...b}}),l=b=>bt({target:n,base:_.TILE_DEFAULTS,propKey:b,write:()=>s({[b]:_.TILE_DEFAULTS[b]})}),p=b=>bt({target:n.sheetMargin,base:_.TILE_DEFAULTS.sheetMargin,propKey:b,write:()=>u(b,_.TILE_DEFAULTS.sheetMargin[b])}),u=(b,k)=>s({sheetMargin:{...n.sheetMargin,[b]:k??0}}),h={...o,tiling:n},m=_.validateTiling(h),g=Math.max(_.computeMaxColumns(h),1);let S="";if(!m.length)try{const b=_.computeTileLayout(h),k=_.resolveSheetMm(h),y=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",C=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";S=`目标纸 ${y}${C} ${k.width}×${k.height}mm · ${b.columns} 列 × ${b.rows} 行 = 每张 ${b.perSheet} 格 · 每格 ${b.tile.width}×${b.tile.height}mm`}catch{S=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[He("拼版打印"),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({..._.TILE_DEFAULTS,columns:Math.min(_.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[W("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:b=>{const k=b.target.value;if(k!=="CUSTOM"){s({sheetPaperSize:k});return}const y=_.resolveSheetMm(h);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??y.width,sheetCustomHeight:n.sheetCustomHeight??y.height})}},[...rd.map(b=>a("option",{value:b,text:c.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"?W("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[O({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:b=>s({sheetCustomWidth:b})}),a("span",{class:"custom-size-x",text:"×"}),O({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:b=>s({sheetCustomHeight:b})})])):W("目标纸方向",rt("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",b=>s({sheetOrientation:b})),void 0,l("sheetOrientation")),He("拼版留白 (mm)"),a("div",{class:"margin-grid"},[W("上",O({value:n.sheetMargin.top??0,min:0,max:100,onCommit:b=>u("top",b)}),void 0,p("top")),W("下",O({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:b=>u("bottom",b)}),void 0,p("bottom")),W("左",O({value:n.sheetMargin.left??0,min:0,max:100,onCommit:b=>u("left",b)}),void 0,p("left")),W("右",O({value:n.sheetMargin.right??0,min:0,max:100,onCommit:b=>u("right",b)}),void 0,p("right"))]),He("格间距与列数"),W("横向间距",O({value:n.gapX??0,min:0,max:50,onCommit:b=>s({gapX:b??0})}),void 0,l("gapX")),W("纵向间距",O({value:n.gapY??0,min:0,max:50,onCommit:b=>s({gapY:b??0})}),void 0,l("gapY")),W("列数",O({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&&S?a("p",{class:"pd-hint tiling-summary",text:S}):""]:""].flat().filter(Boolean))}const dd=new Set(c.PROPERTY_REGISTRY.map(t=>t.group)),cd={"table-settings":"content"},Wn=new Map;function $i(t){const e=t??"";let o=Wn.get(e);if(!o){const{groups:i,itemKeys:n}=c.searchProperties(e);o={groups:i,keys:n,searching:!!e.trim()},Wn.set(e,o)}return o}function Bi(t){const e=cd[t]??t;return dd.has(e)?e:""}function pd(t,e){const o=$i(t.state.propSearch);if(!o.searching)return!0;const i=Bi(e);return!i||o.groups.includes(i)}function ud(t,e){const o=$i(t.state.propSearch);return!o.searching||o.keys.has(e)}function Hr(t,e){const o=t.props.style??{};return t.props.style={...o,display:e?"":"none"},t}function M(t,e,o){const i=o.props.dataset??{};return o.props.dataset={...i,propKey:e},Hr(o,ud(t,e))}function hd(t,e,o){const i=Bi(e);if(!i)return o;const n=o.props.dataset??{};return o.props.dataset={...n,propGroup:i},Hr(o,pd(t,e))}function Ur(t,e){const o=$i(e);for(const i of Array.from(t.querySelectorAll("[data-prop-group]"))){const n=Bi(i.dataset.propGroup??"");i.style.display=!o.searching||!n||o.groups.includes(n)?"":"none"}for(const i of Array.from(t.querySelectorAll("[data-prop-key]")))i.style.display=!o.searching||o.keys.has(i.dataset.propKey??"")?"":"none"}function fd(t){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:t.state.propSearch??"",onInput:e=>{const o=e.target,i=o.value;t.state.propSearch=i,Ur(o.getRootNode(),i)}})])}const gd={Document:"≡",Brush:"◧",Setting:"⚙"};function md(t,e){try{const o=window.localStorage.getItem(`property-group-${t}`);return o===null?e:o==="true"}catch{return e}}function bd(t,e){try{window.localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function we(t,e,o,i,n,r=!0,s=[]){const l=md(e,r);return hd(t,e,a("div",{class:`property-group${l?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{bd(e,!l),t.repaint()}},[a("span",{class:"group-icon",text:gd[i]||"•"}),a("span",{class:"group-title",text:o}),...s,a("span",{class:"expand-icon",text:l?"▾":"▸"})]),a("div",{class:"group-content",style:l?"":{display:"none"}},n.filter(Boolean))]))}function vo(t){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function Wr(t){return t.split(".").flatMap(e=>{const o=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!o)return[e];const i=o[1],n=[...o[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function Gn(t,e){return Wr(e).reduce((n,r)=>n==null?"":n[r],t)??""}function Hi(t,e,o,i){const n=Wr(o),r=n.pop(),s=n.reduce((l,p)=>((l[p]===void 0||l[p]===null)&&(l[p]={}),l[p]),e);s[r]=i||void 0,t.recordHistory(),t.emit()}function xd(t,e){const o=t.store;if(e.printElementType.type==="table"&&o.tableSelection?.elementId===e.id){const{r1:i,c1:n}=o.tableSelection,r=(e.options.tableRows??[])[i];if(r)return c.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return c.getElementBindings(e)}function vd(t,e){const o=document.createElement("label");o.className="pd-button small upload-label",ve(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),o);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",o.append(i,n);const r=p=>{o.className=`pd-button small upload-label${p?" disabled":""}`,n.disabled=p};n.addEventListener("change",async()=>{const p=n.files?.[0];if(!p)return;if(!p.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=t.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(p);h?Hi(t.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!t.host.uploadImage),n.value=""}}),t.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(o,l),s}function yd(t,e){const o=i=>t.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:Gn(e,i.targetPath)});return we(t,"binding","内容","Document",[...xd(t,e).map(i=>W(i.label,a("input",{class:"pd-input",type:"text",value:Gn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>Hi(t.store,e,i.targetPath,n.target.value),onDblclick:()=>o(i)}))),e.printElementType.type==="image"?vd(t,e):""].filter(Boolean))}const Ft=new Map;function oo(t){return`${Math.round(t*1e4)/1e4}%`}function Gr(t,e){const o=c.parseCropAnchor(e.value),i=o.kind==="custom",n=o.kind==="axes"?o.x:50,r=o.kind==="axes"?o.y:50,s=c.resolveCropPreview(e.src),l=Ft.get(s.src),p={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},u=c.resolveCropTravel(p),h=c.cropWindow(p,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const k of c.cropPresetOptions(u,n,r)){const y=document.createElement("option");y.value=k.value,y.textContent=k.label,m.appendChild(y)}if(i){const k=document.createElement("option");k.value="custom",k.textContent="自定义(保留原值)",m.appendChild(k)}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[k,y]=m.value.split(",").map(Number);e.onCommit(c.buildCropAnchor(k,y))});const g=c.propertyTip(e.fieldKey),S=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,xi(g)]),e.resetAnchor??""].filter(Boolean)),m])];S.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[c.CROP_SCALE_LABEL,xi(c.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),O({value:e.scale,min:c.CROP_SCALE_MIN,max:c.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:k=>e.onScaleCommit(k>c.CROP_SCALE_MIN?k:void 0)})]));for(const k of c.cropAxisFields(u,n,r))S.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:k.label}),O({value:k.value,min:0,max:100,step:1,onCommit:y=>e.onCommit(c.buildCropAnchor(k.name==="horizontal"?y:n,k.name==="vertical"?y:r))})]));const b=c.cropAxisNote(u,i);return b&&S.push(a("p",{class:"pd-crop-note",text:b})),s.isSample&&S.push(a("p",{class:"pd-crop-note",text:c.CROP_SAMPLE_NOTE})),S.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:s.src,alt:s.isSample?"示例图":"原图",onLoad:k=>{const y=k.target;if(!(y.naturalWidth>0&&y.naturalHeight>0))return;const C=Ft.get(s.src);C&&C.width===y.naturalWidth&&C.height===y.naturalHeight||(Ft.set(s.src,{width:y.naturalWidth,height:y.naturalHeight}),t.repaint())},onError:()=>{Ft.has(s.src)&&(Ft.delete(s.src),t.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:oo(h.leftPct),top:oo(h.topPct),width:oo(h.widthPct),height:oo(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},S)}const ut=t=>Number(t??0),vi=t=>t||void 0;function mt(t,e,o,i,n,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:t}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,...r?{disabled:!0}:{},onChange:s=>o(s.target.checked)})])}function qr(t,e,o,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:s=>i(s.target.value)},o.map(s=>a("option",{value:s.value,text:s.label,selected:s.value===e})))])}function zt(t,e,o,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),n.reset??""].filter(Boolean)),Br(e,o,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Ct=t=>a("p",{class:"pd-hint",text:t}),wd="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",Ed=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Sd=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Td=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],kd=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Cd={value:"__multi__",label:"多选",disabled:!0};function Ad(t,e){const o=t.store,i=o.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return we(t,"table-row","行属性","Grid",[]);const s=l=>o.updateElement(e.id,l);return we(t,"table-row","行属性","Grid",[vo([qr("行类型",r.type,Ed,l=>{const p=c.setRowType(n,i.r1,l);if(p){window.alert(p);return}s({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:l=>{r.height=l,s({tableRows:n})}})]),r.type==="header"?mt("表头每页重复",r.repeatOnPage??!1,l=>{c.setHeaderRepeat(n,l),s({tableRows:n})},wd):""])])}function Dd(t,e){const o=t.store,i=e.options,n=h=>o.updateElement(e.id,h),r=i.tableColWidths??[],s=o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right,l=o.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),p=c.createDefaultOptions("table"),u=h=>bt({target:i,base:p,propKey:h,write:()=>n({[h]:p[h]})});return we(t,"table-settings","表格设置","Grid",[vo([qr("列表数据源字段",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")]),bo({id:"table-default-font",state:t.state,fonts:t.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),O({value:ut(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:vi(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Te(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:ut(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:vi(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 S=r.reduce((b,k,y)=>y===m?b:b+k,0);if(S+g>s){const b=Math.max(5,Math.round((s-S)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${m+1} 已调整为 ${b}mm`),r[m]=b}else r[m]=g;n({tableColWidths:r})}})]))])])])}function Md(t,e){const o=t.store,i=e.options,n=e.printElementType.type==="table",r=l=>o.updateElement(e.id,l),s=[];if(n)s.push(M(t,"pg-enabled",mt("启用分页",i.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=i.pagination?.pageable??!0,p=i.pagination?.keepWithNext??!1;s.push(M(t,"pg-pageable",mt("参与分页",l,u=>r({pagination:{pageable:u,keepWithNext:p}})))),s.push(M(t,"pg-keep-with-next",mt("与下元素同页",p,u=>r({pagination:{pageable:l,keepWithNext:u}}))))}return we(t,"pagination","分页配置","Document",[vo(s)],!1)}const ni=new WeakMap,qn=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function _d(t,e){const o=t.store,i=o.tableSelection,n=e.options.tableRows??[];if(!i)return we(t,"table-cell","单元格","Menu",[]);const r=c.findMainCell(n,i.r1,i.c1),s=n[r.r]?.cells[r.c];if(!s)return we(t,"table-cell","单元格","Menu",[]);const l=()=>c.collectWritableCells(n,i),p=c.resolveCellGroupMode(n,i),u=p.count,h=p.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=ni.get(o),S=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&ni.set(o,S);const b=v=>{ni.set(o,{key:m,border:v.border??S.border,values:v.values??S.values,edges:v.edges??S.edges})},k=(v,U)=>{b({border:{...S.border,[v]:U}}),t.repaint()},y=(v,U)=>{l().forEach(v),h&&U&&b({values:{...S.values,...U}}),o.updateElement(e.id,{tableRows:n})},C=(v,U)=>{y(ge=>{ge[v]=U},{[v]:U})},D=v=>h?S.values[v]:s[v],P=v=>h&&v in S.values,A=h?{width:void 0,style:void 0,color:void 0}:c.resolveCellBorderDisplay(n,i),F=!h&&l().some(v=>!!v.borders&&!!(v.borders.top||v.borders.right||v.borders.bottom||v.borders.left)),K=!h&&!F,N={width:K?0:typeof A.width=="number"?A.width:c.DEFAULT_BORDER.width,style:K?"none":typeof A.style=="string"&&A.style!=="mixed"?A.style:c.DEFAULT_BORDER.style,color:typeof A.color=="string"&&A.color!=="mixed"?A.color:c.DEFAULT_BORDER.color,...S.border},L="__mixed__",z={style:!h&&A.style==="mixed",width:!h&&A.width==="mixed",color:!h&&A.color==="mixed"},ee=z.style&&!("style"in S.border),H=z.width&&!("width"in S.border),pe=z.color&&!("color"in S.border),te=ee||H||pe,ke=ee?L:N.style,x=H?void 0:N.width,Z=pe?void 0:N.color,le=v=>{const U={style:v};v!=="none"&&x===0?U.width=c.DEFAULT_BORDER.width:v==="none"&&!F&&(U.width=0),b({border:{...S.border,...U}}),t.repaint()},De=()=>({...N}),B=h?qn.reduce((v,U)=>(v[U.value]=S.edges[U.value]?"on":"off",v),{}):c.resolveBorderEdgeStates(l().map(v=>v.borders)),Ue=h?"cellType"in S.values?S.values.cellType??"text":c.resolveSharedCellType(n,i):s.cellType??"text",re=Ue==="barcode",ye=Ue==="qrcode",Me=Ue==="image",G=Ue==="text",Ze=re&&!!D("printerDpi"),Wt=c.barcodeBarWidthRecommendText(D("printerDpi"),D("barWidth")),j=h?S.values.textFit:c.resolveCellTextFit(s),yo=h?"cellType"in S.values?S.values.cellType??"text":"":s.cellType||"text",at=v=>h?[Cd,...v]:v,Ee=v=>h?"多选":v,Ce=(v,U)=>h?S.values[v]:U,wo=h?D("barcodeType")??"__multi__":s.barcodeType||"CODE128",Eo=h?P("printerDpi")?D("printerDpi")?String(D("printerDpi")):"":"__multi__":s.printerDpi?String(s.printerDpi):"",So=h?D("qrCodeLevel")??"__multi__":s.qrCodeLevel||"M",To=h?D("fit")??"__multi__":s.fit||"contain",Gt=j??"__multi__",Y=c.canMergeReason(n,i);let Qe=!0;for(let v=i.r1;v<=i.r2;v++)if(n[v]?.type!=="data"){Qe=!1;break}const X=Qe?"":"仅数据行(明细行)支持按值合并";let Je=!1;for(let v=i.r1;v<=i.r2&&!Je;v++)for(let U=i.c1;U<=i.c2&&!Je;U++){const ge=n[v]?.cells[U];ge&&!ge.merged&&((ge.rowspan??1)>1||(ge.colspan??1)>1)&&(Je=!0)}const ue=(v,U,ge,Q={},Re)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:v}),Re??""].filter(Boolean)),O({value:U,...Q,onCommit:We=>C(ge,vi(We))})]),st="恢复默认值(跟随表格默认)",V=v=>bt({target:s,base:{},propKey:v,tipOverride:st,force:h,write:()=>C(v,void 0)}),_e=e.options.tableDefaultPadding??1,Mt={width:c.cellFitWidthMm(e.options.tableColWidths??[],r.c,s,_e),height:c.cellFitCapMm(n,r.r,s,_e)};return we(t,"table-cell","单元格","Menu",[vo([h?Ct(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),rt("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],yo,v=>{const U=v==="text"?void 0:v,ge={cellType:v};v!=="barcode"&&Object.assign(ge,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),v!=="qrcode"&&Object.assign(ge,{qrCodeLevel:void 0,qrQuietZone:void 0}),y(Q=>{Q.cellType=U,v!=="barcode"&&(Q.barcodeType=void 0,Q.showBarcodeText=void 0,Q.printerDpi=void 0,Q.barQuietZone=void 0,Q.barHeight=void 0),v!=="qrcode"&&(Q.qrCodeLevel=void 0,Q.qrQuietZone=void 0)},ge)})]),re?zt("码制",wo,at(Sd),v=>{v!=="__multi__"&&C("barcodeType",v||void 0)}):"",re?mt("显示文本",h?S.values.showBarcodeText===!0:s.showBarcodeText!==!1,v=>C("showBarcodeText",v),void 0,V("showBarcodeText")):"",re?ue("条宽(倍率)",Ce("barWidth",s.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:Ee("")},V("barWidth")):"",re?Ct((Ze?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Wt?`。${Wt}`:"")):"",re?be("静区 (模块)",O({value:Ce("barQuietZone",s.barQuietZone),min:0,max:20,placeholder:Ee("默认 10"),onCommit:v=>C("barQuietZone",v)}),c.propertyTip("cd-bar-quiet-zone"),V("barQuietZone")):"",re?be("条高 (mm)",O({value:Ce("barHeight",s.barHeight),min:1,max:100,placeholder:Ee("默认 30 模块"),onCommit:v=>C("barHeight",v??void 0)}),c.propertyTip("cd-bar-height"),V("barHeight")):"",re?ue("文本字号(相对条高,条高为 30)",Ce("barFontSize",s.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:Ee("默认 10")},V("barFontSize")):"",re?zt("打印机分辨率",Eo,at([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),v=>{if(v==="__multi__")return;const U=Number(v);C("printerDpi",U>0?U:void 0)},{reset:V("printerDpi")}):"",re?Ct("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",ye?zt("纠错级别",So,at(Td),v=>{v!=="__multi__"&&C("qrCodeLevel",v||void 0)},{reset:V("qrCodeLevel")}):"",ye?be("静区 (模块)",O({value:Ce("qrQuietZone",s.qrQuietZone),min:0,max:8,placeholder:Ee("默认 0"),onCommit:v=>C("qrQuietZone",v)}),c.propertyTip("cd-quiet-zone"),V("qrQuietZone")):"",re?Ct("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",ye||Me?zt("缩放模式",To,at(c.IMAGE_FIT_OPTIONS),v=>{v!=="__multi__"&&C("fit",v)},{reset:V("fit")}):"",Me&&!h&&s.fit==="cover"?Gr(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:c.resolveDesignImageSrc(s.formatter),fit:s.fit,containerClass:"pd-cell-anchor",widthMm:Mt.width,heightMm:Mt.height,scale:s.fitScale,value:s.objectPosition,onCommit:v=>C("objectPosition",v),onScaleCommit:v=>C("fitScale",v),resetAnchor:V("objectPosition"),resetScale:V("fitScale")}):"",re||ye||Me?ue("最大宽度 (mm)",Ce("maxWidth",ut(s.maxWidth)),"maxWidth",{min:0,max:200,placeholder:Ee("默认")},V("maxWidth")):"",re||ye||Me?ue("最大高度 (mm)",Ce("maxHeight",ut(s.maxHeight)),"maxHeight",{min:0,max:200,placeholder:Ee("默认")},V("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?D("formatter")??"":s.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:v=>C("formatter",v.target.value||void 0),onDblclick:()=>t.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),V("align")]),rt("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?S.values.align??"":s.align||"left",v=>C("align",v))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),V("valign")]),rt("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?S.values.valign??"":s.valign||"top",v=>C("valign",v))]),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:"字体"}),V("fontFamily")]),bo({id:"cell-font",state:t.state,fonts:t.host.fonts,value:h?D("fontFamily"):s.fontFamily,placeholder:Ee("继承默认"),onChange:v=>C("fontFamily",v)})]),ue("字号 (pt)",Ce("fontSize",ut(s.fontSize)),"fontSize",{min:0,max:72,placeholder:Ee("默认")},V("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),V("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?S.values.fontWeight==="bold":s.fontWeight==="bold",onChange:v=>C("fontWeight",v.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),V("color")]),Te(h?D("color"):s.color,v=>C("color",v),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),V("backgroundColor")]),Te(h?D("backgroundColor"):s.backgroundColor,v=>C("backgroundColor",v),"背景颜色")])]),He("边框"),a("div",{class:"border-style-row"},[Br(ke,[...ee?[{value:L,label:"混合",disabled:!0}]:[],...c.BORDER_LINE_STYLES],v=>{v!==L&&le(v)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[O({value:x,min:.25,max:5,step:.25,placeholder:h?"多选":H?"混合":void 0,onCommit:v=>k("width",v)})]),Te(Z,v=>k("color",v),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([v,U])=>a("button",{type:"button",class:"pd-button small",text:U,onClick:()=>{c.applyBorderPreset(n,i,N.style==="none"?"none":v,De()),o.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},qn.map(v=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:v.value,checked:B[v.value]==="on",indeterminate:B[v.value]==="mixed",onChange:U=>{const Q=U.target.checked&&N.style!=="none";h&&b({edges:{...S.edges,[v.value]:Q}}),y(Re=>{c.setCellBorderEdge(Re,v.value,Q?De():null)})}}),a("span",{text:v.label})]))),Ct(h?c.CELL_BORDER_APPLY_HINT_MULTI:te?c.CELL_BORDER_APPLY_HINT_MIXED:c.CELL_BORDER_APPLY_HINT),ue("内边距 (mm)",Ce("padding",ut(s.padding)),"padding",{min:0,max:10,step:.5,placeholder:Ee("默认")},V("padding")),mt("自动换行",h?S.values.wordWrap===!0:s.wordWrap??!0,v=>C("wordWrap",v),void 0,V("wordWrap")),G?zt("文字溢出",Gt,at(kd),v=>{v!=="__multi__"&&C("textFit",v)},{full:!0,reset:V("textFit")}):"",G&&j==="shrink"?ue("最小字号 (pt)",Ce("shrinkMinFontSize",ut(s.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:Ee("默认 6")},V("shrinkMinFontSize")):"",a("div",{class:"merge-card"},[a("div",{class:"merge-card-title",text:"单元格合并"}),a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!Y,title:Y||"",onClick:()=>{c.mergeCells(n,i),o.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Je,onClick:()=>{c.splitCells(n,i),o.updateElement(e.id,{tableRows:n})}})]),a("div",{class:"merge-card-divider"}),mt("按值合并",h?S.values.mergeSameValue===!0:s.mergeSameValue===!0,v=>C("mergeSameValue",v),X||void 0,Qe?V("mergeSameValue"):void 0,!Qe),Ct("明细相邻行同值时自动纵向合并;跨页时在该页内成段,续页首行重放该值")])])])}const ri=_.WATERMARK_DENSITY_PRESETS;function yi(t){const e=t.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function Rd(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function Pd(t){const e=t.store.templateData.watermark,o=Rd(e),i=e?.mode==="binding"||o!==""&&yi(o),n=(()=>{const u=e?.tileWidth??_.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(ri))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={...e,testData:e?.testData??"",rotate:e?.rotate??_.WATERMARK_DEFAULTS.rotate,color:e?.color||_.WATERMARK_DEFAULTS.color,opacity:e?.opacity??_.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??_.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight};t.store.updateTemplateData({watermark:{...h,...u}})},s=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:o}),l={rotate:e?.rotate??_.WATERMARK_DEFAULTS.rotate,color:e?.color||_.WATERMARK_DEFAULTS.color,opacity:e?.opacity??_.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??_.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight},p=u=>bt({target:l,base:_.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:_.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[He("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:o,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(yi(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?W("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),p("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??_.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??_.WATERMARK_DEFAULTS.rotate}°`})]),W("颜色",Te(e?.color||_.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,p("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),p("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??_.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??_.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=ri[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(ri).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:"瓦片宽"}),p("tileWidth")]),a("input",{type:"number",class:"pd-input",min:_.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??_.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:"瓦片高"}),p("tileHeight")]),a("input",{type:"number",class:"pd-input",min:_.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function ae(t,e,o,i,n={},r){return W(e,O({value:o,...n,onCommit:i}),void 0,r)}function je(t,e,o,i,n,r,s){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>n(l.value));for(const p of i){const u=document.createElement("option");u.value=p.value,u.textContent=p.label,l.appendChild(u)}return l.value=o,i.some(p=>p.value===o)||(l.selectedIndex=-1),r?be(e,l,r,s):W(e,l,void 0,s)}function ct(t,e,o,i,n){return W(e,a("input",{type:"checkbox",class:"pd-switch",checked:o,onChange:r=>i(r.target.checked)}),void 0,n)}const Id=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],Ld=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Fd(t,e){const o=t.store,i=e.options,n=e.printElementType.type,r=x=>o.updateElement(e.id,x),s=hr(n),l=s==="text",p=s==="code",u=s==="table",h=u&&o.tableSelection?.elementId===e.id,m=h&&c.resolveCellGroupMode(e.options.tableRows??[],o.tableSelection).mode==="multi",g=[];m||g.push(yd(t,e));const S=c.createDefaultOptions(n),b=(x,Z)=>{const le=c.propertyDefault(Z);return bt({target:i,base:S,propKey:x,tipValue:le?.value,tipUnit:le?.unit,write:()=>r({[x]:S[x]})})};h||g.push(we(t,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[a("div",{class:"position-grid"},[M(t,"ps-left",ae(t,"X",i.left,x=>r({left:x}),{min:0})),M(t,"ps-top",ae(t,"Y",i.top,x=>r({top:x}),{min:0})),M(t,"ps-width",ae(t,"W",i.width,x=>r({width:x}),{min:4})),M(t,"ps-height",ae(t,"H",i.height,x=>r({height:x}),{min:4}))]),a("h3",{class:"pd-divider",text:"外边距 (mm)"}),a("div",{class:"margin-grid"},[M(t,"ps-margin-top",ae(t,"上",i.marginTop,x=>r({marginTop:x===0?void 0:x}),{},b("marginTop","ps-margin-top"))),M(t,"ps-margin-right",ae(t,"右",i.marginRight,x=>r({marginRight:x===0?void 0:x}),{},b("marginRight","ps-margin-right"))),M(t,"ps-margin-bottom",ae(t,"下",i.marginBottom,x=>r({marginBottom:x===0?void 0:x}),{},b("marginBottom","ps-margin-bottom"))),M(t,"ps-margin-left",ae(t,"左",i.marginLeft,x=>r({marginLeft:x===0?void 0:x}),{},b("marginLeft","ps-margin-left")))])])]));const k=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?c.normalizeRotationAngle(i.rotate):void 0,y=x=>r({rotate:x===void 0||x===0?void 0:c.normalizeRotationAngle(x)}),C=c.isFreeAngleEditable(n,i),D=c.isRotationExcludedType(n)||c.collectFollowMemberIds(o.elements).has(e.id),P=D?"":M(t,"ap-rotate",be("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>y((k??0)-90)}),a("div",{class:"pd-rotate-stepper"},[O({value:k,min:0,max:359,placeholder:"0",disabled:!C,onCommit:x=>y(x)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>y((k??0)+90)})]),c.propertyTip("ap-rotate"),b("rotate","ap-rotate"))),A=D||C?"":a("p",{class:"pd-hint pd-rotate-note",text:c.CODE_OBLIQUE_NOTE});if(g.push(we(t,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},l?[M(t,"ap-font-family",W("字体",bo({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:x=>r({fontFamily:x})}),void 0,b("fontFamily","ap-font-family"))),M(t,"ap-font-size",ae(t,"字体大小",i.fontSize,x=>r({fontSize:x}),{min:8,max:72},b("fontSize","ap-font-size"))),M(t,"ap-font-weight",je(t,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],x=>r({fontWeight:x}),void 0,b("fontWeight","ap-font-weight"))),M(t,"ap-align",W("对齐",rt("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",x=>r({textAlign:x})),void 0,b("textAlign","ap-align"))),M(t,"ap-vertical-align",W("垂直对齐",rt("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",x=>r({verticalAlign:x})),void 0,b("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[M(t,"ap-color",W("颜色",Te(i.color,x=>r({color:x}),"字体颜色"),void 0,b("color","ap-color"))),M(t,"ap-bg-color",W("背景色",Te(i.backgroundColor,x=>r({backgroundColor:x}),"背景颜色"),void 0,b("backgroundColor","ap-bg-color")))]),M(t,"ap-line-height",ae(t,"行高",i.lineHeight,x=>r({lineHeight:x||void 0}),{min:0,max:100},b("lineHeight","ap-line-height"))),M(t,"ap-letter-spacing",ae(t,"字间距",i.letterSpacing,x=>r({letterSpacing:x||void 0}),{min:0,max:20,step:.5},b("letterSpacing","ap-letter-spacing"))),M(t,"ap-text-fit",je(t,"文字溢出",c.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],x=>r({textFit:x}),void 0,b("textFit","ap-text-fit"))),i.textFit==="shrink"?M(t,"ap-shrink-min",W("最小字号 (pt)",O({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:x=>r({shrinkMinFontSize:x||void 0})}),void 0,b("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?M(t,"ap-long-text-indent",be("首行缩进 (字符)",O({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:x=>r({longTextIndent:x||void 0})}),c.propertyTip("ap-long-text-indent"),b("longTextIndent","ap-long-text-indent"))):"",M(t,"ap-word-wrap",ct(t,"自动换行",i.wordWrap!==!1,x=>r({wordWrap:x?void 0:!1}),b("wordWrap","ap-word-wrap"))),M(t,"ap-keep-line-breaks",ct(t,"保留换行符",i.keepLineBreaks===!0,x=>r({keepLineBreaks:x?!0:void 0}),b("keepLineBreaks","ap-keep-line-breaks"))),P,A]:[n==="image"?M(t,"ap-img-fit",je(t,"缩放模式",String(i.fit??"contain"),c.IMAGE_FIT_OPTIONS,x=>r({fit:x}),c.propertyTip("ap-img-fit"),b("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?M(t,"ap-img-object-position",Gr(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:c.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:x=>r({objectPosition:x}),onScaleCommit:x=>r({fitScale:x}),resetAnchor:b("objectPosition","ap-img-object-position"),resetScale:b("fitScale","ap-img-fit-scale")})):"",P,A,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),p){const x=n==="barcode",Z=String(i.barcodeType||"CODE128").toUpperCase(),le=i.printerDpi?String(i.printerDpi):"",De=c.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);g.push(we(t,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:B=>B.preventDefault()},[x?[M(t,"cd-type",je(t,"码制",Z,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],B=>r({barcodeType:B==="CODE128"?void 0:B}))),M(t,"cd-dpi",je(t,"打印机分辨率",le,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],B=>r({printerDpi:Number(B)>0?Number(B):void 0}),void 0,b("printerDpi","cd-dpi"))),M(t,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),M(t,"cd-bar-width",ae(t,"条宽(倍率)",i.barWidth??2,B=>r({barWidth:B}),{min:2,max:8,step:.5},b("barWidth","cd-bar-width"))),M(t,"cd-bar-width",a("p",{class:"pd-hint",text:(le?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(De?`。${De}`:"")})),M(t,"cd-bar-quiet-zone",be("静区 (模块)",O({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:B=>r({barQuietZone:B})}),c.propertyTip("cd-bar-quiet-zone"),b("barQuietZone","cd-bar-quiet-zone"))),M(t,"cd-bar-height",be("条高 (mm)",O({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:B=>r({barHeight:B??void 0})}),c.propertyTip("cd-bar-height"),b("barHeight","cd-bar-height"))),M(t,"cd-show-text",ct(t,"显示文本",i.hideTitle!==!0,B=>r({hideTitle:B?void 0:!0}),b("hideTitle","cd-show-text"))),M(t,"cd-font-size",W("文本字号(相对条高,条高为 30)",O({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:B=>r({fontSize:B||void 0})}),void 0,b("fontSize","cd-font-size")))]:[M(t,"cd-ec-level",je(t,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],B=>r({qrCodeLevel:B}),void 0,b("qrCodeLevel","cd-ec-level"))),M(t,"cd-quiet-zone",be("静区 (模块)",O({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:B=>r({qrQuietZone:B})}),c.propertyTip("cd-quiet-zone"),b("qrQuietZone","cd-quiet-zone")))],He("自定义设置"),x?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",x?"":M(t,"cd-fit",je(t,"缩放模式",String(i.fit||"contain"),c.IMAGE_FIT_OPTIONS,B=>r({fit:B||void 0}),void 0,b("fit","cd-fit"))),M(t,"cd-max-width",W("最大宽度 (mm)",O({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:B=>r({maxWidth:B||void 0})}),void 0,b("maxWidth","cd-max-width"))),M(t,"cd-max-height",W("最大高度 (mm)",O({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:B=>r({maxHeight:B||void 0})}),void 0,b("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(h&&(g.push(Ad(t,e)),g.push(_d(t,e))),u&&g.push(Dd(t,e)),n==="flowList"){const x=c.resolveFlowColumns(i.flowColumns),Z=c.resolveFlowRowHeight(i.flowRowHeight),le=c.resolveFlowGapX(i.flowGapX),De=c.resolveFlowMaxSpan(i.flowMaxSpan,x),B=c.suggestFlowColumns(i.width??0,le,i.fontSize??12),Ue=c.resolveFlowLayoutMode(i.flowLayoutMode),re=Ue==="dynamic",ye=c.resolveFlowPadding(i),Me=(G,Ze)=>{r({[G]:typeof Ze=="number"&&Number.isFinite(Ze)&&Ze>0?Ze:0})};g.push(we(t,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:G=>G.preventDefault()},[M(t,"fl-layout-mode",je(t,"布局模式",Ue,[{value:"fixed",label:"固定高度"},{value:"dynamic",label:"动态分页"}],G=>r({flowLayoutMode:G==="dynamic"?"dynamic":"fixed"}),c.propertyTip("fl-layout-mode"))),...re?[M(t,"fl-padding-top",be("上内边距 (mm)",O({value:ye.top,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingTop",G)}),c.propertyTip("fl-padding-top"))),M(t,"fl-padding-right",be("右内边距 (mm)",O({value:ye.right,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingRight",G)}),c.propertyTip("fl-padding-right"))),M(t,"fl-padding-bottom",be("下内边距 (mm)",O({value:ye.bottom,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingBottom",G)}),c.propertyTip("fl-padding-bottom"))),M(t,"fl-padding-left",be("左内边距 (mm)",O({value:ye.left,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingLeft",G)}),c.propertyTip("fl-padding-left")))]:[],M(t,"fl-columns",be("每行列数",O({value:x,min:1,max:12,onCommit:G=>r({flowColumns:c.resolveFlowColumns(G),flowMaxSpan:c.resolveFlowMaxSpan(i.flowMaxSpan,c.resolveFlowColumns(G))})}),c.propertyTip("fl-columns"))),M(t,"fl-row-height",be("行高 (mm)",O({value:Z,min:3,max:100,step:.5,onCommit:G=>r({flowRowHeight:c.resolveFlowRowHeight(G)})}),c.propertyTip("fl-row-height"))),M(t,"fl-gap-x",be("单元横向间距 (mm)",O({value:le,min:0,max:50,step:.5,onCommit:G=>r({flowGapX:c.resolveFlowGapX(G)})}),c.propertyTip("fl-gap-x"))),M(t,"fl-auto-span",ct(t,"内容过长时跨列",i.flowAutoSpan===!0,G=>{r(G?{flowAutoSpan:G,flowMaxSpan:De}:{flowAutoSpan:G})})),i.flowAutoSpan===!0?M(t,"fl-max-span",be("最多跨几列",O({value:De,min:1,max:x,onCommit:G=>r({flowMaxSpan:c.resolveFlowMaxSpan(G,x)})}),c.propertyTip("fl-max-span"))):"",x>B?a("p",{class:"pd-hint",text:`按当前字号与框宽,${x} 列偏挤(可放约 ${B} 列)。数值保持不变,出纸按 ${x} 列排。`}):""].flat().filter(Boolean))]))}const F=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),K=x=>{const Z=F();c.applyElementBorderPreset(Z,x,c.effectiveElementBorderSpec(Z)),r(Z)},N=x=>{const Z=F();c.setElementBorderEdgeVisible(Z,x,!c.elementBorderEdgeVisible(Z,x)),r(Z)},L=c.resolveElementBorderDisplay(i),z=L.style==="mixed",ee=typeof L.width=="number"?L.width:void 0,H=z||L.style===void 0?"":L.style,pe=typeof L.color=="string"?L.color:void 0,te=(x,Z)=>{const le=F();c.setElementBorderField(le,x,Z),r(le)},ke=z?[{value:"",label:"混合"},...c.BORDER_LINE_STYLES]:[...c.BORDER_LINE_STYLES];return g.push(we(t,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[M(t,"bb-border-style",je(t,"线型",H,ke,x=>te("borderStyle",x))),a("div",{class:"border-row"},[M(t,"bb-border-width",ae(t,"边框宽度",ee,x=>te("borderWidth",x),{min:0,max:20,step:.25,placeholder:L.width==="mixed"?"混合":void 0},b("borderWidth","bb-border-width"))),M(t,"bb-border-color",W("边框颜色",Te(pe,x=>te("borderColor",x),"边框颜色"),void 0,b("borderColor","bb-border-color")))]),...c.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},Id.map(x=>a("button",{type:"button",class:"pd-button small",text:x.label,disabled:x.value==="inner",onClick:()=>K(x.value)}))),a("div",{class:"pd-checkbox-group"},Ld.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:c.elementBorderEdgeVisible(i,x.value),onChange:()=>N(x.value)}),a("span",{text:x.label})]))),a("p",{class:"pd-hint",text:c.ELEMENT_BORDER_APPLY_HINT})]:[],M(t,"bb-bg-color",W("背景色",Te(i.backgroundColor,x=>r({backgroundColor:x}),"背景颜色"),void 0,b("backgroundColor","bb-bg-color")))])])),g.push(Md(t,e)),g.push(we(t,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[a("div",{class:"advanced-row"},[M(t,"ad-locked",ct(t,"锁定",!!i.locked,x=>r({locked:x}),b("locked","ad-locked"))),M(t,"ad-fixed",ct(t,"每页重复",!!i.repeatOnEveryPage,x=>r({repeatOnEveryPage:x}),b("repeatOnEveryPage","ad-fixed"))),M(t,"ad-fixed-position",ct(t,"每页固定",!!i.fixed,x=>r({fixed:x}),b("fixed","ad-fixed-position")))]),M(t,"ad-z-index",ae(t,"层级",i.zIndex,x=>r({zIndex:x}),{min:0,max:999},b("zIndex","ad-z-index"))),M(t,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>o.deleteSelected()})]))])],!1,[a("button",{type:"button",class:"group-help",title:"高级设置说明","aria-label":"高级设置说明",text:"?",onClick:x=>{x.stopPropagation(),t.fire("help","advanced-settings")}})])),a("div",{class:"property-content"},g)}function zd(t){const e=t.store,o=e.templateData,i=p=>e.updateTemplateData(p),n=p=>{const u=o.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(p)!==h(o.outputRotation)){const m=_.computeMaxColumns({...o,outputRotation:p});i({outputRotation:p,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:p})},r=[];for(const[p,u]of Object.entries(c.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:p,label:u.label??p})}const s=!c.PAPER_PRESETS[o.paperSize],l=c.isContinuousPaperSize(o.paperSize);return a("form",{class:"pd-form",onSubmit:p=>p.preventDefault()},[He("纸张设置"),W("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:p=>i({paperSize:p.target.value})},[...r.map(p=>a("optgroup",{label:p.group},p.items.map(u=>a("option",{value:u.key,text:u.label,selected:o.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:s})])),l||s?W(l?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[O({value:Number(o.customWidth??0),min:25,max:2e3,onCommit:p=>i({customWidth:p})}),...s?[a("span",{class:"custom-size-x",text:"×"}),O({value:Number(o.customHeight??0),min:25,max:2e3,onCommit:p=>i({customHeight:p})})]:[]])):"",l?"":W("纸张方向",rt("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.orientation==="landscape"?"landscape":"portrait",p=>i({orientation:p})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":W("内容旋转角度",rt("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(o.outputRotation??0),p=>n(Number(p)),!0),o.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),W("页面背景色",a("div",{class:"page-bg-row"},[Te(o.pageBackground,p=>i({pageBackground:p}),"页面背景色","page-bg-picker")]),void 0,bt({target:o,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),sd(t),e.pages.length>1?"":ld(t),He("页边距 (mm)"),a("div",{class:"margin-grid"},[ae(t,"上",o.margins.top,p=>i({margins:{...o.margins,top:p}}),{min:0,max:50}),ae(t,"下",o.margins.bottom,p=>i({margins:{...o.margins,bottom:p}}),{min:0,max:100}),ae(t,"左",o.margins.left,p=>i({margins:{...o.margins,left:p}}),{min:0,max:50}),ae(t,"右",o.margins.right,p=>i({margins:{...o.margins,right:p}}),{min:0,max:50})]),He("页眉/页脚高度 (mm)"),ae(t,"页眉高度",o.header.height??10,p=>i({header:{...o.header,height:p}}),{min:0,max:100,step:.1}),ae(t,"页脚高度",o.footer.height??10,p=>i({footer:{...o.footer,height:p}}),{min:0,max:100,step:.1}),Pd(t)].filter(Boolean))}function Od(t,e,o){const i=(t.state.propSearch??"").trim(),n=!i||c.matchKeywords(i,[...o.searchKeywords,o.label]),r=document.createElement("div");if(r.className="property-content",n)try{Dr(`property:${e.id}`,o.ui.renderProperty({element:e,data:t.host.designData?.length?t.host.designData:[c.DEFAULT_DEMO_DATA],fields:t.host.fields??[],update:s=>t.store.updateElement(e.id,s),repaint:()=>t.repaint()}),r)}catch{}return a("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:custom"},style:t.state.propTab==="custom"?"":{display:"none"}},[r])}function Nd(t){const e=t.store,o=t.state,i=e.selectedElement,n=i?ui(i):void 0;if(o.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{o.propCollapsed=!1,t.repaint()}}),...n?[a("button",{type:"button",class:`pc-btn${o.propTab==="custom"?" on":""}`,title:n.label,html:ce(n.icon,14)||ce("Shapes",14),onClick:()=>{o.propTab="custom",o.propCollapsed=!1,t.repaint()}})]:[],...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([s,l,p])=>a("button",{type:"button",class:`pc-btn${o.propTab===s?" on":""}`,title:l,text:p,onClick:()=>{o.propTab=s,o.propCollapsed=!1,t.repaint()}}))])]);const r=i?o.propTab==="custom"&&!n?"element":o.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{o.propCollapsed=!0,t.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...n?[a("button",{type:"button",class:`pd-tab${r==="custom"?" active":""}`,text:n.label,onClick:()=>{o.propTab="custom",t.repaint()}})]:[],a("button",{type:"button",class:`pd-tab${r==="element"?" active":""}`,text:"元素属性",onClick:()=>{o.propTab="element",t.repaint()}}),a("button",{type:"button",class:`pd-tab${r==="page"?" active":""}`,text:"页面属性",onClick:()=>{o.propTab="page",t.repaint()}})]),n&&i?Od(t,i,n):"",a("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:element"},style:r==="element"?"":{display:"none"}},i?[fd(t),Fd(t,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:page"},style:r==="page"?"":{display:"none"}},[zd(t)])].filter(Boolean))])}const ai=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Kn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},$d=[{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()"}],Bd=[{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()"}],Hd=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],Ud=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],Wd=[{title:"聚合函数",items:$d},{title:"数值运算",items:Bd},{title:"格式化函数",items:Hd}],Gd="(输入表达式后预览)",qd="(无法计算)",wi="(表达式错误)";function Vn(t,e){if(!t.trim())return Gd;try{const o={...c.DEFAULT_DEMO_DATA,...e??{},..._.resolveSystemVariables()},i=c.evaluateTemplate(t,o);return i==null?qd:String(i)}catch{return wi}}function jn(t,e){const o=e.trim().toLowerCase();return o?t.filter(i=>i.label.toLowerCase().includes(o)||i.name.toLowerCase().includes(o)):t}function Kd(t,e){const o=t.substring(0,e),i=o.lastIndexOf("{"),n=i!==-1&&!o.slice(i+1).includes("}"),r=o.lastIndexOf("("),s=r!==-1&&!o.slice(r+1).includes(")");return{insideBlock:n,insideParens:s}}const Vd=t=>/[\u4e00-\u9fff]/.test(t),jd=t=>`字段「${t}」含中文,请用 {${t}} 引用(函数参数内写 ${t});中文可直接在 {} 中使用,无需 data['...'] 方括号`;function Yd(t,e){const o=/^\{\s*([^{}]+?)\s*\}$/.exec(t.trim());if(!o)return null;const i=o[1]??"";return e.find(n=>n.fieldKey===i)??null}function si(t,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:t}),a("span",{class:"ee-item-key",text:e})])}function Be(t){return t.currentTarget.getRootNode()}function io(t,e,o){const i=[];return o.forEach((n,r)=>{i.push(n),r<o.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${t}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function Xd(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[io("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","中文 key 直接写 {字段名},如 {姓名}、{supplier.名称}","注意:只能嵌套一层"]),io("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),io("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),io("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function Zd(t,e){const o={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding,copiedFieldKey:"",keyHint:""},i=(y,C)=>y.querySelector(C),n=y=>{const C=i(y,".ee-preview");if(!C)return;const D=Vn(o.expression,t.demoData);C.textContent=D,C.classList.toggle("ee-preview-error",D===wi)},r=y=>{const C=i(y,".ee-key-hint");C&&(C.textContent=o.keyHint,C.style.display=o.keyHint?"":"none")},s=()=>{if(o.activeTab==="variable")return jn(Ud,o.searchText).map(D=>a("div",{class:"ee-list-item",onDblclick:P=>{const{insideParens:A}=u(P);h(Be(P),A?D.template.replace(/^\{|\}$/g,""):D.template,void 0,"")}},[si(D.label,D.template)]));if(o.activeTab==="function")return Wd.map(D=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:D.title}),...jn(D.items,o.searchText).map(P=>a("div",{class:"ee-list-item",onDblclick:A=>{const{insideBlock:F}=u(A),K=F?P.template:`{${P.template}}`;h(Be(A),K,K.indexOf("(")+1,"")}},[si(P.label,`${P.name}()`)]))]));const y=c.filterGroups(c.groupFields(t.fields??[]),o.searchText);if(!y.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const C=[];for(const D of y){D.key&&C.push(a("div",{class:`ee-field-group${D.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:D.isList?"📋":"📁"}),a("span",{text:D.label})]));for(const P of D.fields)C.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:D.key?"22px":"10px"},onDblclick:A=>{const{insideParens:F}=u(A),K=A;if(K.ctrlKey||K.metaKey){const N=P.fieldLabel||P.fieldKey;h(Be(A),F?`"${N}"`:N,void 0,"");return}h(Be(A),F?P.fieldKey:`{${P.fieldKey}}`,void 0,Vd(P.fieldKey)?jd(P.fieldKey):"")}},[si(P.fieldLabel,P.fieldKey),a("button",{type:"button",class:`ee-copy-btn${o.copiedFieldKey===P.fieldKey?" is-copied":""}`,"data-tip":o.copiedFieldKey===P.fieldKey?"已复制":`复制字段名「${P.fieldLabel}」`,"aria-label":`复制字段名 ${P.fieldLabel}`,html:ce(o.copiedFieldKey===P.fieldKey?"Check":"Copy",13),onClick:A=>{A.stopPropagation(),p(A,P)},onDblclick:A=>A.stopPropagation()})]))}return C},l=y=>{Array.from(y.querySelectorAll(".ee-nav-tab")).forEach((F,K)=>F.classList.toggle("active",ai[K]?.key===o.activeTab));const D=i(y,".ee-content-search .pd-input");if(D){const F=Kn[o.activeTab];D.placeholder!==F&&(D.placeholder=F),D.value!==o.searchText&&(D.value=o.searchText)}const P=i(y,".ee-textarea");P&&P.value!==o.expression&&(P.value=o.expression);const A=i(y,".ee-content-list");if(A){rr(A);for(const F of s())ve(F,A)}n(y),r(y)};function p(y,C){const D=Be(y);c.copyTextToClipboard(C.fieldLabel||C.fieldKey).then(P=>{P&&(o.copiedFieldKey=C.fieldKey,l(D),setTimeout(()=>{o.copiedFieldKey===C.fieldKey&&(o.copiedFieldKey="",l(D))},1200))})}const u=y=>{const D=i(Be(y),".ee-textarea")?.selectionStart??o.expression.length;return Kd(o.expression,D)},h=(y,C,D=C.length,P)=>{P!==void 0&&(o.keyHint=P);const A=i(y,".ee-textarea");if(!A){o.expression+=C,n(y),r(y);return}const F=A.selectionStart??o.expression.length,K=A.selectionEnd??F;o.expression=o.expression.substring(0,F)+C+o.expression.substring(K);const N=F+D;A.value=o.expression,A.focus(),A.selectionStart=A.selectionEnd=N,n(y),r(y)},m=()=>{const y=o.expression;if(o.binding===void 0){t.onApply({formatter:y}),t.onClose();return}const C=Yd(y,t.fields??[]);t.onApply(C?{formatter:y,binding:C.fieldKey,title:C.fieldLabel}:{formatter:y}),t.onClose()},g=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},ai.map((y,C)=>a("div",{class:`ee-nav-tab${o.activeTab===y.key?" active":""}`,text:y.text,onClick:D=>{o.activeTab=ai[C].key,l(Be(D))}})))]),S=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:Kn[o.activeTab],onInput:y=>{o.searchText=y.target.value,l(Be(y))}})]),a("div",{class:"ee-content-list"},s())]),b=Vn(o.expression,t.demoData),k=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:o.expression,onInput:y=>{o.expression=y.target.value,o.keyHint="",n(Be(y)),r(Be(y))}}),a("div",{class:"pd-hint ee-key-hint",style:{display:"none",color:"var(--pd-accent, #165DFF)"},text:""})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${b===wi?" ee-preview-error":""}`,text:b})]),Xd()]);return a("div",{class:"pd-dialog-overlay",onKeydown:y=>{y.key==="Escape"&&t.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>t.onClose()})]),a("div",{class:"expression-editor"},[g,S,k]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>t.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>m()})])])])}const Qd={id:"getting-started",title:"快速入门",content:`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@worm-print-platform/core/designer"),_=require("@worm-print-platform/core"),Ti=require("@worm-print-platform/core/browser"),ci=require("@worm-print-platform/plugin-kit"),rr=require("jsbarcode");function a(t,e={},o=[]){return{tag:t,props:e,children:o}}const Si="http://www.w3.org/2000/svg",wa=new Set(["draggable","contenteditable","spellcheck"]),Ea=new Set(["indeterminate"]);function Ta(t){return t==="svg"||t==="path"||t==="circle"||t==="rect"||t==="line"||t==="g"}function Sa(t){return t instanceof Element&&t.namespaceURI===Si}function ve(t,e){if(typeof t=="string"){const s=document.createTextNode(t);return e.appendChild(s),s}if(t instanceof Node)return e.appendChild(t),t;const{tag:o,props:i,children:n}=t,r=Ta(o)||Sa(e)?document.createElementNS(Si,o):document.createElement(o);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[p,u]of Object.entries(l))r.dataset[p]=u;else Ea.has(s)?r[s]=!0:typeof l=="boolean"?l&&r.setAttribute(s,wa.has(s)?"true":""):r.setAttribute(s,String(l));for(const s of n)ve(s,r);return e.appendChild(r),r}function ar(t){for(;t.firstChild;)t.removeChild(t.firstChild)}const ka=Si;function $t(){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 pi="开启拼版后只能有一个设计页面";function ki(t){const e=(o,i)=>(o??[]).map(n=>{const r={...n.options};return(n.printElementType?.type??n.type)==="table"&&c.syncTableElementSize(r),{id:n.id||c.generateId(),zone:i,options:r,printElementType:{...n.printElementType}}});return{...t,margins:{...t.margins},header:{height:t.header?.height??10,elements:[]},footer:{height:t.footer?.height??10,elements:[]},guides:[...t.guides??[]],elements:[...e(t.elements??[],"content"),...e(t.header?.elements??[],"header"),...e(t.footer?.elements??[],"footer")]}}function sr(t){const e=t.elements,o=i=>e.filter(n=>(n.zone||"content")===i).map(n=>({id:n.id,type:n.printElementType.type,options:{...n.options},printElementType:{...n.printElementType}}));return{unit:"mm",...t,header:{...t.header,elements:o("header")},footer:{...t.footer,elements:o("footer")},elements:o("content"),guides:[...t.guides??[]]}}function pn(t){const e=(i,n)=>{const r=ki(c.normalizeTemplateUnits(i));return r.name||(r.name=`页面 ${n+1}`),r};if(!t)return[e($t(),0)];const o=Array.isArray(t.pages)?t.pages:[t];return o.length?o.map(e):[e($t(),0)]}const St=t=>JSON.parse(JSON.stringify(t));class lr{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=c.useAlign();group=c.useGroup();constructor(e={}){if(this.pages=pn(e.initialTemplate),this.fields=e.initialFields??[],e.initialElements?.length){const o=this.pages[0];o.elements=[...o.elements,...e.initialElements]}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emit(e=!0){e&&(this.dirty=!0);for(const o of[...this.listeners])o()}get templateData(){return this.pages[this.activePageIndex]}set templateData(e){this.pages[this.activePageIndex]=e}get elements(){return this.templateData.elements.map(e=>this.live.get(e.id)??e)}get tilingEnabled(){return this.pages.some(e=>e.tiling?.enabled===!0)}switchPage(e){e<0||e>=this.pages.length||(this.activePageIndex=e,this.resetSelection(),this.emit(!1))}addPage(){if(this.tilingEnabled){window.alert(pi);return}this.recordHistory();const e=this.pages[this.activePageIndex]??$t();this.pages.push(ki({...$t(),paperSize:e.paperSize,orientation:e.orientation,outputRotation:e.outputRotation,customWidth:e.customWidth,customHeight:e.customHeight,name:this.nextDefaultPageName()})),this.switchPage(this.pages.length-1),this.emit()}nextDefaultPageName(){const e=new Set(this.pages.map(i=>i.name));let o=this.pages.length+1;for(;e.has(`页面 ${o}`);)o++;return`页面 ${o}`}duplicatePage(e){if(this.tilingEnabled){window.alert(pi);return}this.recordHistory();const o=St(this.pages[e]);o.name=`${o.name??`页面 ${e+1}`} 副本`,o.elements=o.elements.map(i=>({...i,id:c.generateId()})),this.pages.splice(e+1,0,o),this.switchPage(e+1),this.emit()}deletePage(e){this.pages.length<=1||(this.recordHistory(),this.pages.splice(e,1),this.activePageIndex=Math.max(0,Math.min(this.activePageIndex,this.pages.length-1)),this.resetSelection(),this.emit())}renamePage(e,o){this.recordHistory(),this.pages[e].name=o,this.emit()}movePage(e,o){if(o<0||o>=this.pages.length||e===o)return;this.recordHistory();const[i]=this.pages.splice(e,1);this.pages.splice(o,0,i),this.activePageIndex=o,this.emit()}onSelectionChanged;setSelection(e){this.selectedIds=e,this.onSelectionChanged?.(),this.emit(!1)}select(e){this.setSelection(new Set(e))}selectOne(e,o=!1){if(o){const i=new Set(this.selectedIds);i.has(e)?i.delete(e):i.add(e),this.setSelection(i)}else this.setSelection(new Set([e]))}clearSelection(){this.setSelection(new Set)}selectElement(e,o=!1){if(o){this.selectOne(e,!0);return}this.setSelection(new Set(this.group.getGroupedIds(this.elements,e)))}selectAll(){this.setSelection(new Set(this.elements.map(e=>e.id)))}get selectedElements(){return this.elements.filter(e=>this.selectedIds.has(e.id))}get selectedElement(){const e=this.selectedIds.values().next().value;return e?this.elements.find(o=>o.id===e)??null:null}resetSelection(){this.selectedIds=new Set,this.tableSelection=null,this.onSelectionChanged?.()}setTableSelection(e){this.tableSelection=e,this.emit(!1)}setPreview(e){this.previewIds=e,this.emit(!1)}commitPreview(){this.previewIds=new Set,this.emit(!1)}addGuide(e,o){const i=this.templateData.guides??[];this.templateData.guides=[...i,{id:c.generateId(),type:e,position:Math.round(o*10)/10}],this.emit()}moveGuide(e,o){const i=this.templateData.guides??[];this.templateData.guides=i.map(n=>n.id===e?{...n,position:Math.round(o*10)/10}:n),this.emit(!1)}removeGuide(e){this.templateData.guides=(this.templateData.guides??[]).filter(o=>o.id!==e),this.emit()}addElement(e,o={},i){const n=c.createRuntimeElement(e,o);return i&&!this.placeAtDropPoint(n,i)||(this.recordHistory(),this.templateData.elements.push(n),this.select(new Set([n.id])),this.emit()),n}addFieldElement(e,o={},i,n=!1){const r=n?c.createFieldLabelElement(e):c.createFieldElement(e);return Object.assign(r.options,o),i&&!this.placeAtDropPoint(r,i)||(this.recordHistory(),this.templateData.elements.push(r),this.select(new Set([r.id])),this.emit()),r}placeAtDropPoint(e,o){const i=this.templateData,n=c.zoneFromPaperPoint(i,o.x,o.y);if(n!=="content"&&!c.isZoneAllowedType(e.printElementType.type))return alert("该元素类型不能放入页眉/页脚"),!1;const r=c.getZoneRects(i)[n];return e.zone=n,e.options.left=o.x-r.left,e.options.top=o.y-r.top,n!=="content"&&c.clampToZone(e,r),!0}deleteSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.templateData.elements.filter(e=>!this.selectedIds.has(e.id)),this.selectedIds=new Set,this.emit())}livePatch(e,o){const i=this.templateData.elements.find(r=>r.id===e);if(!i)return;const n=this.live.get(e)??i;this.live.set(e,{...n,options:{...n.options,...o}})}commitLive(){if(!this.live.size)return;this.recordHistory();const e=this.templateData.elements;for(const[o,i]of this.live){const n=e.find(r=>r.id===o);n&&Object.assign(n.options,i.options)}this.live.clear(),this.emit()}dragIds(e){const o=this.templateData.elements.find(i=>i.id===e);return!o||o.options.locked?[]:Array.from(this.group.getGroupedIds(this.elements,e))}discardLive(){this.live.clear()}dragStart(){this.dragBefore=new Map(this.elements.map(e=>[e.id,this.geoSig(e)]))}dragStop(){const e=this.dragBefore;if(!e)return;this.dragBefore=null;let o=!1;for(const i of this.elements){const n=e.get(i.id);!n||n===this.geoSig(i)||c.finalizeElementZone(i,this.templateData).rejected&&(o=!0)}o&&alert("该元素类型不能放入页眉/页脚"),this.emit()}geoSig(e){return`${e.zone||"content"}:${e.options.left},${e.options.top},${e.options.width},${e.options.height}`}updateElement(e,o,i=!0){i&&this.recordHistory();const n=this.templateData.elements.find(r=>r.id===e);n&&(Object.assign(n.options,o),n.printElementType.type==="table"&&c.syncTableElementSize(n.options),this.emit())}updateTemplateData(e){this.recordHistory(),Object.assign(this.templateData,e);for(const o of["paperSize","customWidth","customHeight"])if(o in e)for(const i of this.pages)Object.assign(i,{[o]:e[o]});this.emit()}moveLayer(e){if(!this.selectedIds.size)return;this.recordHistory();const o=this.templateData.elements,i=o.filter(r=>this.selectedIds.has(r.id)),n=o.filter(r=>!this.selectedIds.has(r.id));if(e==="top")this.templateData.elements=[...n,...i];else if(e==="bottom")this.templateData.elements=[...i,...n];else{const r=o.findIndex(p=>this.selectedIds.has(p.id)),s=e==="up"?r+1:r-1;if(s<0||s>=o.length)return;const l=[...o];[l[r],l[s]]=[l[s],l[r]],this.templateData.elements=l}this.emit()}alignSelected(e){this.selectedIds.size<2||(this.recordHistory(),this.align.align(this.elements.filter(o=>this.selectedIds.has(o.id)),e),this.emit())}groupSelected(){this.selectedIds.size<2||(this.recordHistory(),this.templateData.elements=this.group.group(this.elements,this.selectedIds),this.emit())}ungroupSelected(){this.selectedIds.size&&(this.recordHistory(),this.templateData.elements=this.group.ungroup(this.elements,this.selectedIds),this.emit())}copy(){this.clipboard=St(this.selectedElements),this.emit(!1)}cutSelected(){this.copy(),this.deleteSelected()}paste(e=10){if(!this.clipboard.length)return;this.recordHistory();const o=new Map;for(const r of this.clipboard){const s=r.options.groupId;s&&o.set(s,(o.get(s)??0)+1)}const i=new Map;for(const[r,s]of o)i.set(r,s>=2?c.generateGroupId():void 0);const n=this.templateData.elements;for(const r of this.clipboard){const s=St(r);s.id=c.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,o){const i=this.selectedElements.filter(n=>!n.options.locked);if(i.length){this.moveSessionActive||(this.moveSessionActive=!0,this.recordHistory());for(const n of i)n.options.left+=e,n.options.top+=o;this.moveTimer&&clearTimeout(this.moveTimer),this.moveTimer=setTimeout(()=>{this.moveSessionActive=!1,this.moveTimer=null},300),this.emit()}}cloneElement(e){this.recordHistory(),this.templateData.elements.push(e),this.selectedIds=new Set([e.id]),this.emit()}recordHistory(){this.undoStack.push({pages:St(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:St(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:St(this.pages),activePageIndex:this.activePageIndex}),this.pages=e.pages,this.activePageIndex=Math.min(e.activePageIndex,e.pages.length-1),this.resetSelection(),this.emit())}resetZoom(){this.setScale(100)}setScale(e,o=c.MIN_SCALE_PERCENT){this.scale=Math.max(o,Math.round(e)),this.emit(!1)}getTemplateJson(){const e=this.pages.map(sr),o=e.length===1?e[0]:{version:1,pages:e};return JSON.stringify(o)}loadTemplate(e){this.pages=pn(e),this.activePageIndex=0,this.resetSelection(),this.recordHistory(),this.emit()}get paperSize(){return c.getPaperDimensions(this.templateData)}}const ht=Symbol("mixed"),qo=new Set(["text","longText"]),Ca=["top","right","bottom","left"],Aa={on:!0,off:!1,mixed:ht};function un(t){const e=c.resolveBorderEdgeStates(t),o={};for(const i of Ca)o[i]=Aa[e[i]];return o}const Da=["fontFamily","fontSize","fontWeight","color","textAlign","verticalAlign","textDecoration"];class Ma{constructor(e){this.store=e}store;borderStyle="solid";borderWidth=.75;borderColor="#333333";borderMixed={style:!1,width:!1,color:!1};borderDraftKey="";get borderMixedAny(){return this.borderMixed.style||this.borderMixed.width||this.borderMixed.color}painterActive=!1;painterLocked=!1;painterSource=null;painterSnapshot=null;get selectedElements(){return this.store.elements.filter(e=>this.store.selectedIds.has(e.id)&&!e.options.locked)}get tableElement(){const e=this.store.tableSelection;return e?this.store.elements.find(o=>o.id===e.elementId)??null:null}get context(){return this.store.tableSelection&&this.tableElement?"cells":this.selectedElements.length>0||this.store.selectedIds.size>0?"elements":"none"}get targetCells(){const e=this.store.tableSelection,o=this.tableElement?.options.tableRows;if(!e||!o)return[];const i=[];for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=o[n]?.cells[r];s&&!s.merged&&i.push(s)}return i}get textTargets(){return this.selectedElements.filter(e=>qo.has(e.printElementType.type))}get fontEditable(){return this.context==="cells"?this.targetCells.length>0:this.context!=="elements"?!1:this.selectedElements.length>0&&this.textTargets.length===this.selectedElements.length}get styleTargets(){return this.context==="cells"?this.targetCells:this.textTargets.map(e=>e.options)}pick(e){if(!e.length)return;const o=e[0];return e.every(i=>i===o)?o:ht}hasToken(e,o){return(e??"").split(/\s+/).includes(o)}get values(){const e=this.styleTargets;if(!e.length)return{fontFamily:void 0,fontSize:void 0,color:void 0,backgroundColor:void 0,textAlign:void 0,verticalAlign:void 0,bold:!1,underline:!1,strike:!1};const o=e.map(n=>n.fontWeight==="bold"||n.fontWeight==="bolder"),i=e.map(n=>n.textDecoration);return{fontFamily:this.pick(e.map(n=>n.fontFamily)),fontSize:this.pick(e.map(n=>n.fontSize)),color:this.pick(e.map(n=>n.color)),backgroundColor:this.pick(e.map(n=>n.backgroundColor)),textAlign:this.pick(e.map(n=>this.context==="cells"?n.align:n.textAlign)),verticalAlign:this.pick(e.map(n=>this.context==="cells"?n.valign:n.verticalAlign)),bold:o.every(Boolean)?!0:o.some(Boolean)?ht:!1,underline:i.map(n=>this.hasToken(n,"underline")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"underline"))?ht:!1,strike:i.map(n=>this.hasToken(n,"line-through")).every(Boolean)?!0:i.some(n=>this.hasToken(n,"line-through"))?ht:!1}}commit(){this.store.recordHistory(),this.store.emit()}writeCells(e){const o=this.targetCells;o.length&&(o.forEach(e),this.commit())}applyStyle(e){if(this.context==="cells"){this.writeCells(l=>{"fontFamily"in e&&(l.fontFamily=e.fontFamily),"fontSize"in e&&(l.fontSize=e.fontSize),"color"in e&&(l.color=e.color),"backgroundColor"in e&&(l.backgroundColor=e.backgroundColor),"textAlign"in e&&(l.align=e.textAlign),"verticalAlign"in e&&(l.valign=e.verticalAlign)});return}const o=this.textTargets,i=this.selectedElements,r=["fontFamily","fontSize","color","textAlign","verticalAlign"].some(l=>l in e),s="backgroundColor"in e;!(o.length&&r)&&!(i.length&&s)||(o.forEach(l=>{const p=l.options;"fontFamily"in e&&(p.fontFamily=e.fontFamily),"fontSize"in e&&(p.fontSize=e.fontSize),"color"in e&&(p.color=e.color),"textAlign"in e&&(p.textAlign=e.textAlign),"verticalAlign"in e&&(p.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,o=this.textTargets;o.length&&(o.forEach(i=>{i.options.fontWeight=e?"bold":"normal"}),this.commit())}toggleDecoration(e){if(this.context==="cells")return;const o=this.textTargets;if(!o.length)return;const i=this.values[e==="underline"?"underline":"strike"]!==!0;o.forEach(n=>{const r=(n.options.textDecoration??"").split(/\s+/).filter(Boolean),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,o=this.tableElement?.options.tableRows;if(!e||!o)return;const i=`cells:${e.elementId}:${e.r1}:${e.c1}:${e.r2}:${e.c2}`;if(i===this.borderDraftKey)return;if(this.borderDraftKey=i,c.resolveCellGroupMode(o,e).mode==="multi"){this.borderStyle="solid",this.borderWidth=.75,this.borderColor="#333333",this.borderMixed={style:!1,width:!1,color:!1};return}const n=c.resolveCellBorderDisplay(o,e);if(n.style===void 0&&n.width===void 0&&n.color===void 0){this.borderMixed={style:!1,width:!1,color:!1},this.borderStyle=null,this.borderWidth=0,this.borderColor="#333333";return}this.borderMixed={style:n.style==="mixed",width:n.width==="mixed",color:n.color==="mixed"},this.borderMixed.style?this.borderStyle=null:n.style===void 0?this.borderStyle="solid":n.style==="none"?this.borderStyle=null:this.borderStyle=n.style,this.borderWidth=this.borderMixed.width?void 0:typeof n.width=="number"?n.width:.75,this.borderColor=this.borderMixed.color?void 0:typeof n.color=="string"?n.color:"#333333"}borderSpec(){const e=this.borderStyle??(this.borderMixed.style?"solid":"none");return{width:this.borderWidth??.75,style:e,color:this.borderColor??"#333333"}}setBorderWidth(e){this.borderWidth=e,this.borderMixed.width=!1}setBorderColor(e){this.borderColor=e,this.borderMixed.color=!1}settleBorderDraft(){this.context==="cells"&&(this.borderMixed.style&&(this.borderStyle="solid",this.borderMixed.style=!1),this.borderMixed.width&&(this.borderWidth=.75,this.borderMixed.width=!1),this.borderMixed.color&&(this.borderColor="#333333",this.borderMixed.color=!1))}toggleBorderStyle(e){const o=this.borderStyle===e?null:e;this.borderMixed.style=!1,this.borderStyle=o,o===null?this.borderWidth=0:this.borderWidth===0&&(this.borderWidth=.75)}applyElementBorder(e,o){const i=this.selectedElements;i.length&&(i.forEach(n=>{c.applyElementBorderPreset(n.options,e,o)}),this.commit())}applyCellBorderPreset(e,o){const i=this.store.tableSelection,n=this.tableElement?.options.tableRows;!i||!n||(c.applyBorderPreset(n,{r1:i.r1,c1:i.c1,r2:i.r2,c2:i.c2},e,o),this.commit())}applyCellBorderEdges(e,o,i){this.writeCells(n=>{for(const r of e)c.setCellBorderEdge(n,r,i?o:null)})}get cellEdges(){if(this.context!=="cells")return null;const e=this.targetCells;return e.length?un(e.map(o=>o.borders)):null}toggleCellEdge(e,o){const i=this.cellEdges?.[e]!==!0;this.applyCellBorderEdges([e],o,i)}get elementEdges(){if(this.context!=="elements")return null;const e=this.selectedElements;return e.length?un(e.map(o=>c.elementVisibleBorders(o.options))):null}toggleElementEdge(e,o){const i=this.selectedElements;if(!i.length)return;const n=this.elementEdges?.[e]!==!0;i.forEach(r=>c.setElementBorderEdgeVisible(r.options,e,n,o)),this.commit()}applyBorderPreset(e){const o=this.borderStyle===null;if(this.context==="cells"){const i=o&&!this.borderMixed.style;this.applyCellBorderPreset(i?"none":e,this.borderSpec()),this.settleBorderDraft()}else this.applyElementBorder(o||e==="none"?"none":"all",this.borderSpec())}applyEdge(e){if(this.borderStyle===null&&!this.borderMixed.style){this.context==="cells"?(this.applyCellBorderEdges([e],this.borderSpec(),!1),this.settleBorderDraft()):this.clearElementEdge(e);return}this.context==="cells"?(this.toggleCellEdge(e,this.borderSpec()),this.settleBorderDraft()):this.toggleElementEdge(e,this.borderSpec())}clearElementEdge(e){const o=this.selectedElements;o.length&&(o.forEach(i=>c.setElementBorderEdgeVisible(i.options,e,!1)),this.commit())}edgeOn(e){return(this.context==="cells"?this.cellEdges:this.elementEdges)?.[e]===!0}get painterCapturable(){return this.selectedElements.length===1}clonePainterBorders(e){if(!e)return;const o={};for(const i of c.ELEMENT_BORDER_SIDES){const n=e[i];n&&(o[i]={...n})}return o}pickPainterSource(e=!1){const o=this.selectedElements[0];if(!o)return!1;const i=o.options,n=o.printElementType.type;return this.painterSnapshot={text:qo.has(n)?Object.fromEntries(Da.map(r=>[r,i[r]])):null,backgroundColor:i.backgroundColor,border:c.acceptsElementBorder(n)?{borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:this.clonePainterBorders(i.borders)}:null},this.painterSource=o.id,this.painterActive=!0,this.painterLocked=e,!0}cancelPainter(){this.painterActive=!1,this.painterLocked=!1,this.painterSource=null,this.painterSnapshot=null}applyPainter(e){const o=this.painterSnapshot;if(!o||e.options.locked||e.id===this.painterSource)return!1;const i=e.options,n=e.printElementType.type;return o.text&&qo.has(n)&&Object.assign(i,o.text),i.backgroundColor=o.backgroundColor,o.border&&c.acceptsElementBorder(n)&&(i.borderWidth=o.border.borderWidth,i.borderStyle=o.border.borderStyle,i.borderColor=o.border.borderColor,i.borders=this.clonePainterBorders(o.border.borders)),!0}painterSyncSelection(){if(!this.painterActive||!this.painterSnapshot)return;const e=this.selectedElements;if(!e.length){this.cancelPainter();return}let o=!1;e.forEach(i=>{o=this.applyPainter(i)||o}),o&&(this.commit(),this.painterLocked||this.cancelPainter())}handlePainterKeydown(e){if(e.key!=="Escape"||!this.painterActive)return;const o=e.target?.tagName;o==="INPUT"||o==="TEXTAREA"||o==="SELECT"||this.cancelPainter()}}const _a="自定义属性";function dr(){const t=[];for(const{plugin:e,kind:o}of c.getElementPluginKinds()){const i=ci.getElementUI(o.type);if(!i)continue;const r=(o.designer??e.designer)?.materialCard;t.push({type:o.type,label:o.label,icon:o.icon??r?.icon??"Shapes",group:r?.group??i.group,ui:i})}return t}function Ci(t){if(t)return dr().find(e=>e.type===t)}function ui(t){if(!t)return;const e=Ci(t.printElementType.type);if(!e||!e.ui.renderProperty)return;const o=e.ui;if(o.hasProperties)try{if(!o.hasProperties(t))return}catch{return}const i=_a;return{ui:o,label:i,icon:e.icon,searchKeywords:o.searchKeywords?[...o.searchKeywords]:[i,e.label,e.type]}}const fo=Object.freeze([{type:"text",label:"文本",icon:"Type",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"barcode",label:"条形码",icon:"Barcode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"qrcode",label:"二维码",icon:"QrCode",material:!0,propertyGroup:"code",dblEditableField:"formatter",origin:"builtin"},{type:"image",label:"图片",icon:"Image",material:!0,propertyGroup:"general",dblEditableField:"src",origin:"builtin"},{type:"table",label:"表格",icon:"Table",material:!0,propertyGroup:"table",origin:"builtin"},{type:"longText",label:"长文",icon:"TextAlignStart",material:!0,propertyGroup:"text",dblEditableField:"formatter",origin:"builtin"},{type:"flowList",label:"流式列表",icon:"List",material:!0,propertyGroup:"general",dblEditableField:"formatter",origin:"builtin"},{type:"hline",label:"横线",icon:"Minus",material:!0,propertyGroup:"general",origin:"builtin"},{type:"vline",label:"竖线",icon:"SeparatorVertical",material:!0,propertyGroup:"general",origin:"builtin"},{type:"rect",label:"矩形",icon:"Square",material:!0,propertyGroup:"general",origin:"builtin"},{type:"oval",label:"椭圆",icon:"Circle",material:!0,propertyGroup:"general",origin:"builtin"},{type:"html",label:"HTML",icon:"Code",material:!1,propertyGroup:"general",origin:"builtin"},{type:"pageNumber",label:"页码",icon:"Shapes",material:!1,propertyGroup:"general",origin:"builtin"}]),hn=Symbol.for("worm-print-platform.element-definitions.v1"),fn=globalThis;function ze(){const t=fn[hn];if(t)return t;const e={overrides:new Map,builtinRenderers:new Map,rendererOverrides:new Map,listeners:new Set,nextSeq:0,seq:new Map};return fn[hn]=e,e}function Bt(){for(const t of[...ze().listeners])try{t()}catch{}}function cr(t){const e=ze();return e.listeners.add(t),()=>{e.listeners.delete(t)}}function Ra(){return new Map(fo.map(t=>[t.type,t]))}function Pa(t){if(!t?.type||typeof t.type!="string")throw new Error("registerElementDefinition: type 必须是非空字符串");if(!t.label||typeof t.label!="string")throw new Error("registerElementDefinition: label 必须是非空字符串");const e=ze(),o={...t,origin:t.origin??"custom"};return e.overrides.set(o.type,o),e.seq.set(o.type,e.nextSeq++),Bt(),()=>{const i=ze();i.overrides.get(o.type)===o&&(i.overrides.delete(o.type),Bt())}}function Ia(t,e){if(!t||typeof e!="function")throw new Error("registerElementRenderer: 需要 type 与渲染函数");return ze().rendererOverrides.set(t,e),Bt(),()=>{const i=ze();i.rendererOverrides.get(t)===e&&(i.rendererOverrides.delete(t),Bt())}}function pr(t){const e=ze();for(const[o,i]of Object.entries(t))e.builtinRenderers.set(o,i);return()=>{const o=ze();for(const[i,n]of Object.entries(t))o.builtinRenderers.get(i)===n&&o.builtinRenderers.delete(i)}}function Fa(t){const e=Ci(t);if(e)return{type:e.type,label:e.label,icon:e.icon,group:e.group,material:!0,propertyGroup:"general",origin:"plugin"}}function nt(t){if(!t)return;const e=ze(),o=e.overrides.get(t)??Ra().get(t)??Fa(t);if(!o)return;const i=e.rendererOverrides.get(t)??e.builtinRenderers.get(t);return i?{...o,renderContent:i}:o}function ur(){const t=ze(),e=[],o=new Set;for(const n of fo)e.push(nt(n.type)??n),o.add(n.type);const i=[...t.overrides.entries()].filter(([n])=>!o.has(n)).sort((n,r)=>(t.seq.get(n[0])??0)-(t.seq.get(r[0])??0));for(const[n]of i){const r=nt(n);r&&e.push(r),o.add(n)}for(const n of dr()){if(o.has(n.type))continue;const r=nt(n.type);r&&e.push(r),o.add(n.type)}return e}function hr(){return ur().filter(t=>t.material)}function fr(t){return nt(t)?.propertyGroup??"general"}function gr(t){return nt(t)?.dblEditableField}function mr(t){return nt(t)?.icon??"Shapes"}function La(){const t=ze();t.overrides.clear(),t.rendererOverrides.clear(),t.seq.clear(),t.nextSeq=0,Bt()}const Ai="1.2.0",br="print-designer",Di=["template","fields","name","fonts","design-data","theme","theme-config"],xr=["is-edit","show-help","show-preview","show-save"],za=Object.freeze({bubbles:!0,composed:!0}),Mi=["container","toolbar","format-bar","left-panel","canvas-area","property-panel","status-bar","page-tabs"],vr=["--pd-bg","--pd-surface","--pd-field-bg","--pd-sidebar","--pd-sidebar-hover","--pd-canvas-bg","--pd-paper","--pd-accent","--pd-accent-2","--pd-accent-soft","--pd-accent-secondary","--pd-danger-soft","--pd-ink-green","--pd-text","--pd-text-muted","--pd-text-faint","--pd-border","--pd-border-soft","--pd-input-bg","--pd-hover-tint","--pd-danger","--pd-danger-bg","--pd-danger-border","--pd-menu-text","--pd-menu-hover","--pd-menu-border","--pd-menu-divider","--pd-menu-muted","--pd-menu-disabled","--pd-scrollbar","--pd-scrollbar-thumb","--pd-scrollbar-thumb-hover","--pd-help-field-bg","--pd-help-field-line","--pd-help-field-ink","--pd-help-function-bg","--pd-help-function-line","--pd-help-function-ink","--pd-help-variable-bg","--pd-help-variable-line","--pd-help-variable-ink","--pd-help-conditional-bg","--pd-help-conditional-line","--pd-help-conditional-ink","--pd-handle","--pd-ruler","--pd-ruler-bg","--pd-ruler-cursor","--pd-radius","--pd-shadow-sm","--pd-shadow-md","--pd-shadow-paper","--pd-success","--pd-text-regular","--pd-fill-light"],yr=["getTemplateJson","loadTemplate","save","validateTemplate","getGeometryWarnings"],wr=["template","fields","fonts","designData","isEdit","showHelp","showPreview","showSave","theme","themeConfig","uploadImage","uploadDesignBackground"],Le=Object.freeze({save:"save",preview:"preview",help:"help",dblclickElement:"dblclick-element",dblclickCell:"dblclick-cell"}),Er=[Le.save,Le.preview,Le.help,Le.dblclickElement,Le.dblclickCell];function hi(){return{version:Ai,tag:br,attributes:Di,booleanAttributes:xr,events:Er,parts:Mi,themeTokens:vr,methods:yr,properties:wr}}const Oa={"--pd-bg":"#181a20","--pd-surface":"#1f2229","--pd-field-bg":"#252830","--pd-sidebar":"#1f2229","--pd-sidebar-hover":"#2b2f39","--pd-accent":"#4C8DFF","--pd-accent-2":"#6C9DFF","--pd-accent-soft":"rgba(76, 141, 255, .16)","--pd-accent-secondary":"#ff7a7a","--pd-danger-soft":"rgba(255, 122, 122, .14)","--pd-ink-green":"#6cce5a","--pd-text":"#e6e8ee","--pd-text-muted":"#9aa0ad","--pd-text-faint":"#6f7683","--pd-text-regular":"#c9cdd8","--pd-border":"#3a3f4b","--pd-border-soft":"#2d323c","--pd-input-bg":"#262a33","--pd-hover-tint":"rgba(76, 141, 255, .12)","--pd-fill-light":"#2b2f39","--pd-danger":"#ff6b6b","--pd-danger-bg":"#3a2226","--pd-danger-border":"#6b3535","--pd-success":"#4ade80","--pd-menu-text":"#d6d9e0","--pd-menu-hover":"#2b2f39","--pd-menu-border":"#3a3f4b","--pd-menu-divider":"#2d323c","--pd-menu-muted":"#8b91a0","--pd-menu-disabled":"#555b68","--pd-scrollbar":"rgba(255, 255, 255, .18)","--pd-scrollbar-thumb":"rgba(255, 255, 255, .16)","--pd-scrollbar-thumb-hover":"rgba(255, 255, 255, .3)","--pd-help-field-bg":"#16283a","--pd-help-field-line":"#2c5870","--pd-help-field-ink":"#7cc4f5","--pd-help-function-bg":"#162e22","--pd-help-function-line":"#2c5b3c","--pd-help-function-ink":"#79d69a","--pd-help-variable-bg":"#302c16","--pd-help-variable-line":"#6b5d24","--pd-help-variable-ink":"#d6b25e","--pd-help-conditional-bg":"#301a28","--pd-help-conditional-line":"#6b3454","--pd-help-conditional-ink":"#e58ab5","--pd-shadow-sm":"0 1px 2px rgba(0, 0, 0, .3)","--pd-shadow-md":"0 2px 8px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .5)"};function gn(t,e){(e==null||e>t.length)&&(e=t.length);for(var o=0,i=Array(e);o<e;o++)i[o]=t[o];return i}function Na(t){if(Array.isArray(t))return t}function $a(t,e){var o=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(o!=null){var i,n,r,s,l=[],p=!0,u=!1;try{if(r=(o=o.call(t)).next,e!==0)for(;!(p=(i=r.call(o)).done)&&(l.push(i.value),l.length!==e);p=!0);}catch(h){u=!0,n=h}finally{try{if(!p&&o.return!=null&&(s=o.return(),Object(s)!==s))return}finally{if(u)throw n}}return l}}function Ba(){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 Ha(t,e){return Na(t)||$a(t,e)||Ua(t,e)||Ba()}function Ua(t,e){if(t){if(typeof t=="string")return gn(t,e);var o={}.toString.call(t).slice(8,-1);return o==="Object"&&t.constructor&&(o=t.constructor.name),o==="Map"||o==="Set"?Array.from(t):o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?gn(t,e):void 0}}const Tr=Object.entries,Wa=Object.keys,mn=Object.setPrototypeOf,Ga=Object.isFrozen,Sr=Object.getPrototypeOf,kr=Object.getOwnPropertyDescriptor;let fe=Object.freeze,se=Object.seal,it=Object.create,Cr=typeof Reflect<"u"&&Reflect,so=Cr.apply,fi=Cr.construct;fe||(fe=function(e){return e});se||(se=function(e){return e});so||(so=function(e,o){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r<i;r++)n[r-2]=arguments[r];return e.apply(o,n)});fi||(fi=function(e){for(var o=arguments.length,i=new Array(o>1?o-1:0),n=1;n<o;n++)i[n-1]=arguments[n];return new e(...i)});const qe=J(Array.prototype.forEach),qa=J(Array.prototype.lastIndexOf),bn=J(Array.prototype.pop),Pt=J(Array.prototype.push),Ka=J(Array.prototype.slice),Va=J(Array.prototype.splice),Dt=Array.isArray,Ko=Ar(Set),Vo=J(Set.prototype.add),It=J(Set.prototype.has),pt=J(String.prototype.toLowerCase),jo=J(String.prototype.toString),ja=J(String.prototype.match),eo=J(String.prototype.replace),Yo=J(String.prototype.indexOf),Ya=J(String.prototype.trim),Xa=J(Number.prototype.toString),Za=J(Boolean.prototype.toString),xn=typeof BigInt>"u"?null:J(BigInt.prototype.toString),vn=typeof Symbol>"u"?null:J(Symbol.prototype.toString),xe=J(Object.prototype.hasOwnProperty),Ft=J(Object.prototype.toString),Qa=RegExp.prototype.test,he=function(e,o){return e instanceof RegExp&&(e.lastIndex=0),so(Qa,e,[o])},Ke=Ar(TypeError);function J(t){return function(e){for(var o=arguments.length,i=new Array(o>1?o-1:0),n=1;n<o;n++)i[n-1]=arguments[n];return so(t,e,i)}}function Ar(t){return function(){for(var e=arguments.length,o=new Array(e),i=0;i<e;i++)o[i]=arguments[i];return fi(t,o)}}function q(t,e){let o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pt;if(mn&&mn(t,null),!Dt(e))return t;let i=e.length;for(;i--;){let n=e[i];if(typeof n=="string"){const r=o(n);r!==n&&(Ga(e)||(e[i]=r),n=r)}t[n]=!0}return t}function Ja(t){for(let e=0;e<t.length;e++)xe(t,e)||(t[e]=null);return t}function lo(t){const e=it(null);for(const i of Tr(t)){var o=Ha(i,2);const n=o[0],r=o[1];xe(t,n)&&(Dt(r)?e[n]=Ja(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=lo(r):e[n]=r)}return e}function Ot(t){const e=it(null),o=Wa(t);let i=o.length;for(;i--;)e[o[i]]=t[o[i]];return e}function es(t){switch(typeof t){case"string":return t;case"number":return Xa(t);case"boolean":return Za(t);case"bigint":return xn?xn(t):"0";case"symbol":return vn?vn(t):"Symbol()";case"undefined":return Ft(t);case"function":case"object":{if(t===null)return Ft(t);const e=t,o=Ae(e,"toString");if(typeof o=="function"){const i=o(e);return typeof i=="string"?i:Ft(i)}return Ft(t)}default:return Ft(t)}}function Ae(t,e){for(;t!==null;){const i=kr(t,e);if(i){if(i.get)return J(i.get);if(typeof i.value=="function")return J(i.value)}t=Sr(t)}function o(){return null}return o}function ts(t,e){for(;t!==null;){const o=kr(t,e);if(o)return o.get?J(o.get):null;t=Sr(t)}return null}function os(t){if(!t)return!1;try{return he(t,""),!0}catch{return!1}}const yn=fe(["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"]),Xo=fe(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Zo=fe(["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"]),is=fe(["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"]),Qo=fe(["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"]),ns=fe(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),wn=fe(["#text"]),En=fe(["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"]),Jo=fe(["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"]),Tn=fe(["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"]),to=fe(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),rs=se(/{{[\w\W]*|^[\w\W]*}}/g),as=se(/<%[\w\W]*|^[\w\W]*%>/g),ss=se(/\${[\w\W]*/g),ls=se(/{{|}}|\${|<%|%>|<%|%>/),ds=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),cs=se(/^aria-[\-\w]+$/),Sn=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ps=se(/^(?:\w+script|data):/i),us=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),hs=se(/^html$/i),fs=se(/^[a-z][.\w]*(-[.\w]+)+$/i),ei=se(/<[/\w!]/g),kn=se(/<[/\w]/g),gs=se(/<\/no(script|embed|frames)/i),Cn=se(/\/>/i),ms=se(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),bs=se(/^[\r\n\t ]+/),ne={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},xs=fe(q({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),vs=function(){return typeof window>"u"?null:window},ys=function(e,o){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const n="data-tt-policy-suffix";o&&o.hasAttribute(n)&&(i=o.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+r+" could not be created."),null}},An=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},tt=function(e,o,i,n){return xe(e,o)&&Dt(e[o])?q(n.base?Ot(n.base):{},e[o],n.transform):i},ti=function(e,o,i){const n=xe(e,o)?e[o]:void 0;return n&&typeof n=="object"?lo(n):i};function Dr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vs();const e=E=>Dr(E);if(e.version="3.4.18",e.removed=[],!t||!t.document||t.document.nodeType!==ne.document||!t.Element)return e.isSupported=!1,e;let o=t.document;const i=o,n=i.currentScript,r=t.HTMLTemplateElement,s=t.Node,l=t.Element,p=t.NodeFilter,u=t.DOMParser,h=t.trustedTypes,m=l.prototype,g=Ae(m,"cloneNode"),T=Ae(m,"remove"),b=Ae(m,"removeAttributeNode"),k=Ae(m,"nextSibling"),y=Ae(m,"childNodes"),C=Ae(m,"parentNode"),D=Ae(m,"shadowRoot"),P=Ae(m,"attributes"),A=s&&s.prototype?Ae(s.prototype,"nodeType"):null,L=s&&s.prototype?Ae(s.prototype,"nodeName"):null,K=s&&s.prototype?Ae(s.prototype,"ownerDocument"):null,N=function(d){return A?A(d):d.nodeType},F=function(d){return L?L(d):d.nodeName},z=ts(m,"namespaceURI"),ee=function(d){return z?z(d):d.namespaceURI};if(typeof r=="function"){const E=o.createElement("template");E.content&&E.content.ownerDocument&&(o=E.content.ownerDocument)}let H,pe="",te,ke=!1,x=0;const Z=function(){if(x>0)throw Ke('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.')},le=function(d){Z(),x++;try{return H.createHTML(d)}finally{x--}},De=function(d){return H&&Ao?le(d):d},B=function(d){Z(),x++;try{return H.createScriptURL(d)}finally{x--}},Ue=function(){return ke||(te=ys(h,n),ke=!0),te},re=o,ye=re.implementation,Me=re.createNodeIterator,G=re.createDocumentFragment,Ze=re.getElementsByTagName,Wt=i.importNode;let j=An();e.isSupported=typeof Tr=="function"&&typeof C=="function"&&ye&&ye.createHTMLDocument!==void 0;const yo=rs,at=as,Ee=ss,Ce=ds,wo=cs,Eo=ps,To=us,So=fs;let Gt=Sn,Y=null;const Qe=q({},[...yn,...Xo,...Zo,...Qo,...wn]);let X=null;const Je=q({},[...En,...Jo,...Tn,...to]);let ue=null,st=null,V=null;const _e=Object.seal(it(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mt=!0,v=!0,U=!1,ge=!0,Q=!1,Re=!0,We=!1,ko=!1,qt=null,Kt=null,Co=!1,xt=!1,Vt=!1,Ao=!1,Ui=!0,Wi=!1;const Gi="user-content-";let Do=!0,Mo=!1,lt=null,vt=!1,dt=null;const qi=q({},["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 Ki=null;const Vi=q({},["audio","video","img","source","image","track"]);let ji=null;const Yi=q({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jt="http://www.w3.org/1998/Math/MathML",Yt="http://www.w3.org/2000/svg",Oe="http://www.w3.org/1999/xhtml";let yt=Oe,_o=!1,Xi=null;const Xr=q({},[jt,Yt,Oe],jo),Zr=fe(q({},["mi","mo","mn","ms","mtext"]));let Ro=null;const Qr=fe(q({},["annotation-xml"]));let Po=null;const Jr=fe(it(null)),ea=q({},["title","style","font","a","script"]);let _t=null;const ta=["application/xhtml+xml","text/html"],oa="text/html";let ie=null,Xt=null;const ia=o.createElement("form"),Zi=function(d){return d instanceof RegExp||d instanceof Function},Io=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};(!d||typeof d!="object")&&(d={}),d=lo(d),_t=ta.indexOf(d.PARSER_MEDIA_TYPE)===-1?oa:d.PARSER_MEDIA_TYPE,ie=_t==="application/xhtml+xml"?jo:pt,Y=tt(d,"ALLOWED_TAGS",Qe,{transform:ie}),X=tt(d,"ALLOWED_ATTR",Je,{transform:ie}),Xi=tt(d,"ALLOWED_NAMESPACES",Xr,{transform:jo}),ji=tt(d,"ADD_URI_SAFE_ATTR",Yi,{transform:ie,base:Yi}),Ki=tt(d,"ADD_DATA_URI_TAGS",Vi,{transform:ie,base:Vi}),dt=tt(d,"FORBID_CONTENTS",qi,{transform:ie}),st=tt(d,"FORBID_TAGS",it(null),{transform:ie}),V=tt(d,"FORBID_ATTR",it(null),{transform:ie}),vt=xe(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?lo(d.USE_PROFILES):d.USE_PROFILES:!1,Mt=d.ALLOW_ARIA_ATTR!==!1,v=d.ALLOW_DATA_ATTR!==!1,U=d.ALLOW_UNKNOWN_PROTOCOLS||!1,ge=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Q=d.SAFE_FOR_TEMPLATES||!1,Re=d.SAFE_FOR_XML!==!1,We=d.WHOLE_DOCUMENT||!1,xt=d.RETURN_DOM||!1,Vt=d.RETURN_DOM_FRAGMENT||!1,Ao=d.RETURN_TRUSTED_TYPE||!1,Co=d.FORCE_BODY||!1,Ui=d.SANITIZE_DOM!==!1,Wi=d.SANITIZE_NAMED_PROPS||!1,Do=d.KEEP_CONTENT!==!1,Mo=d.IN_PLACE||!1,Gt=os(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Sn,yt=typeof d.NAMESPACE=="string"?d.NAMESPACE:Oe,Ro=ti(d,"MATHML_TEXT_INTEGRATION_POINTS",Zr),Po=ti(d,"HTML_INTEGRATION_POINTS",Qr);const f=ti(d,"CUSTOM_ELEMENT_HANDLING",Jr);if(ue=it(null),xe(f,"tagNameCheck")&&Zi(f.tagNameCheck)&&(ue.tagNameCheck=f.tagNameCheck),xe(f,"attributeNameCheck")&&Zi(f.attributeNameCheck)&&(ue.attributeNameCheck=f.attributeNameCheck),xe(f,"allowCustomizedBuiltInElements")&&typeof f.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=f.allowCustomizedBuiltInElements),se(ue),Q&&(v=!1),Vt&&(xt=!0),vt&&((xe(d,"ALLOWED_TAGS")||xe(d,"ALLOWED_ATTR"))&&typeof console<"u"&&typeof console.warn=="function"&&console.warn("DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together."),Y=q({},wn),X=it(null),vt.html===!0&&(q(Y,yn),q(X,En)),vt.svg===!0&&(q(Y,Xo),q(X,Jo),q(X,to)),vt.svgFilters===!0&&(q(Y,Zo),q(X,Jo),q(X,to)),vt.mathMl===!0&&(q(Y,Qo),q(X,Tn),q(X,to))),_e.tagCheck=null,_e.attributeCheck=null,xe(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?_e.tagCheck=d.ADD_TAGS:Dt(d.ADD_TAGS)&&(Y===Qe&&(Y=Ot(Y)),q(Y,d.ADD_TAGS,ie))),xe(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?_e.attributeCheck=d.ADD_ATTR:Dt(d.ADD_ATTR)&&(X===Je&&(X=Ot(X)),q(X,d.ADD_ATTR,ie))),xe(d,"ADD_FORBID_CONTENTS")&&Dt(d.ADD_FORBID_CONTENTS)&&(dt===qi&&(dt=Ot(dt)),q(dt,d.ADD_FORBID_CONTENTS,ie)),Do&&(Y["#text"]=!0),We&&q(Y,["html","head","body"]),Y.table&&(Y.tbody=!0,delete st.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Ke('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const w=H;H=d.TRUSTED_TYPES_POLICY;try{pe=le("")}catch(S){throw H=w,S}}else d.TRUSTED_TYPES_POLICY===null?(H=void 0,pe=""):(H===void 0&&(H=Ue()),H&&typeof pe=="string"&&(pe=le("")));Xt=fe(d)},Qi=q({},[...Xo,...Zo,...is]),Ji=q({},[...Qo,...ns]),na=function(d,f,w){return f===Oe?d==="svg":f===jt?d==="svg"&&(w==="annotation-xml"||Ro[w]):!!Qi[d]},ra=function(d,f,w){return f===Oe?d==="math":f===Yt?d==="math"&&Po[w]:!!Ji[d]},aa=function(d,f,w){return f===Yt&&!Po[w]||f===jt&&!Ro[w]?!1:!Ji[d]&&(ea[d]||!Qi[d])},sa=function(d){const f=ee(d),w=pt(F(d)),S=C(d);let R=yt,I="template";return S&&N(S)===ne.element&&(R=ee(S),I=pt(F(S))),Xi[f]?f===Yt?na(w,R,I):f===jt?ra(w,R,I):f===Oe?aa(w,R,I):_t==="application/xhtml+xml":!1},et=function(d){Pt(e.removed,{element:d});try{C(d).removeChild(d)}catch{if(T(d),!C(d))throw Ke("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},en=function(d,f,w){try{b(d,f)}catch{try{d.removeAttribute(w)}catch{}}},Fo=function(d){Oo(d);const f=y(d);f&&qe(Ka(f),w=>{try{T(w)}catch{}}),N(d)===ne.element&&Lo(d,!1)},wt=function(d,f,w){if(!w)try{w=f.getAttributeNode(d)}catch{w=null}if(Pt(e.removed,{attribute:w||null,from:f}),w)en(f,w,d);else try{f.removeAttribute(d)}catch{}if(d==="is")if(xt||Vt)try{et(f)}catch{}else try{f.setAttribute(d,"")}catch{}},Lo=function(d,f){const w=P(d);if(w)for(let S=w.length-1;S>=0;--S){const R=w[S],I=R&&R.name;typeof I=="string"&&!(f&&X[ie(I)])&&en(d,R,I)}},zo=function(d,f){let w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const S=[d];for(;S.length>0;){const R=S.pop();if(f(R)===!1)continue;if(w&&N(R)===ne.element){const $=D(R);Et($)&&S.push($)}const I=y(R);if(I)for(let $=I.length-1;$>=0;--$)S.push(I[$])}},Oo=function(d){zo(d,f=>{N(f)===ne.element&&Lo(f,!0)})},No=function(d){const f=[];return zo(d,w=>{f.push(w)},!0),f},la=function(d,f){const w=Ko();qe(No(d),S=>{N(S)===ne.element&&Vo(w,S)}),qe(f,S=>{N(S)===ne.element&&!It(w,S)&&Lo(S,!0)})},tn=function(d,f){let w=!1;return qe(e.removed,S=>{S.element&&(w=w||S.element===d,Oo(S.element))}),la(d,f),w},da=8,ca=function(d,f){const w=lt;let S=null;const R=()=>(S||(S=Ko(),qe(f,I=>{Vo(S,I)})),S);for(let I=0;;I++){const $=No(d),de=[d];let Ge=!1;if(qe($,Ie=>{N(Ie)===ne.documentFragment?Pt(de,Ie):!Ge&&!It(w,Ie)&&(Ge=It(R(),Ie))}),!Ge)return;if(I>=da)throw Ke("the tree kept changing during in-place sanitization; refusing to return it");qe(de,(Ie,Te)=>{pa(Ie,Te>0,d,R())})}},pa=function(d,f,w,S){const R=Zt(d);let I;for(;I=R.nextNode();)!It(S,I)||It(lt,I)||(f&&Pe(j.uponSanitizeShadowNode,I,null),Uo(I,w))},ua=function(d){lt&&Vo(lt,d)},on=function(d,f){return Re?d==="patchsrc"?!0:d==="for"&&f!=="label"&&f!=="output":!1},ha=function(d){Re&&zo(d,f=>{const w=N(f);if(w===ne.processingInstruction||w===ne.comment&&he(kn,f.data)){try{T(f)}catch{}return!1}if(w===ne.element){const S=f,R=ie(F(f));try{S.hasAttribute&&S.hasAttribute("patchsrc")&&S.removeAttribute("patchsrc"),S.hasAttribute&&S.hasAttribute("for")&&on("for",R)&&S.removeAttribute("for")}catch{}}return!0})},nn=function(d){let f=null,w=null;if(Co)d="<remove></remove>"+d;else{const I=ja(d,bs);w=I&&I[0]}_t==="application/xhtml+xml"&&yt===Oe&&(d='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+d+"</body></html>");const S=H?le(d):d;if(yt===Oe)try{f=new u().parseFromString(S,_t)}catch{}if(!f||!f.documentElement){f=ye.createDocument(yt,"template",null);try{f.documentElement.innerHTML=_o?pe:S}catch{}}const R=f.body||f.documentElement;return d&&w&&R.insertBefore(o.createTextNode(w),R.childNodes[0]||null),yt===Oe?Ze.call(f,We?"html":"body")[0]:We?f.documentElement:R},Zt=function(d){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const w=K?K(d):d.ownerDocument;return Me.call(w||d,d,(f?0:p.SHOW_ELEMENT)|p.SHOW_COMMENT|p.SHOW_TEXT|p.SHOW_PROCESSING_INSTRUCTION|p.SHOW_CDATA_SECTION,null)},$o=function(d){return d=eo(d,yo," "),d=eo(d,at," "),d=eo(d,Ee," "),d},Bo=function(d){var f;Ho(d);const w=(f=d.querySelectorAll)===null||f===void 0?void 0:f.call(d,"template");w&&qe(w,S=>{Et(S.content)&&Bo(S.content)})},Ho=function(d){d.normalize();const f=Zt(d,!0);let w=f.nextNode();for(;w;)w.data=$o(w.data),w=f.nextNode()},Qt=function(d){const f=L?L(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.removeAttributeNode!="function"||typeof d.getAttributeNode!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.nodeType!==A(d)||d.childNodes!==y(d)},rn=function(d){if(!A||typeof d!="object"||d===null)return null;try{const f=A(d);return typeof f=="number"?f:null}catch{return null}},Et=function(d){return rn(d)===ne.documentFragment},Rt=function(d){return rn(d)!==null};function Pe(E,d,f){E.length!==0&&qe(E,w=>{w.call(e,d,f,Xt)})}const fa=function(d,f,w){return!!(Re&&w===ne.element&&d.hasChildNodes()&&!Rt(d.firstElementChild)&&he(ei,d.textContent)&&he(ei,d.innerHTML)||Re&&xs[f]&&w===ne.element&&ee(d)===Oe&&(Rt(d.firstElementChild)||typeof d.textContent=="string"&&he(ei,d.textContent))||w===ne.processingInstruction||Re&&w===ne.comment&&he(kn,d.data))},Jt=function(d,f){if(d instanceof RegExp)return he(d,f);if(d instanceof Function){for(var w=arguments.length,S=new Array(w>2?w-2:0),R=2;R<w;R++)S[R-2]=arguments[R];return!!d(f,...S)}return!1},ga=function(d,f,w){if(!st[f]&&ln(f)&&Jt(ue.tagNameCheck,f))return!1;if(Do&&!dt[f]&&!dt[pt(f)]){const S=C(d),R=y(d);if(R&&S){const I=R.length;for(let $=I-1;$>=0;--$){const de=d===w?g(R[$],!0):R[$];S.insertBefore(de,k(d))}}}return et(d),!0},an=function(d,f,w,S){return d.length===0?f:f===w||f===S?Ot(f):f},Tt=function(d,f){return d===f||C(d)!==null?!1:(Mo&&Oo(d),!0)},ma=function(d,f){if(ua(d),Pe(j.beforeSanitizeElements,d,null),Tt(d,f))return!0;if(Qt(d))return et(d),!0;const w=ie(F(d)),S=N(d);if(Y=an(j.uponSanitizeElement,Y,Qe,qt),Pe(j.uponSanitizeElement,d,{tagName:w,allowedTags:Y}),Tt(d,f))return!0;if(fa(d,w,S))return et(d),!0;if(st[w]||!(_e.tagCheck instanceof Function&&_e.tagCheck(w))&&!Y[w]){const R=ga(d,w,f);return R===!1&&(Pe(j.afterSanitizeElements,d,null),Tt(d,f))?!0:R}if(S===ne.element&&!sa(d)||(w==="noscript"||w==="noembed"||w==="noframes")&&he(gs,d.innerHTML))return et(d),!0;if(Q&&S===ne.text){const R=d.textContent,I=$o(R);R!==I&&(Pt(e.removed,{element:d.cloneNode()}),d.textContent=I)}return Pe(j.afterSanitizeElements,d,null),Tt(d,f)},sn=function(d,f,w){if(V[f]||on(f,d)||Ui&&(f==="id"||f==="name")&&(w in o||w in ia))return!1;const S=X[f]||_e.attributeCheck instanceof Function&&_e.attributeCheck(f,d);if(v&&he(Ce,f)||Mt&&he(wo,f))return!0;if(!S)return ln(d)&&Jt(ue.tagNameCheck,d)&&Jt(ue.attributeNameCheck,f,d)||f==="is"&&ue.allowCustomizedBuiltInElements&&Jt(ue.tagNameCheck,w);if(ji[f])return!0;const R=eo(w,To,"");return he(Gt,R)||(f==="src"||f==="xlink:href"||f==="href")&&d!=="script"&&Yo(w,"data:")===0&&Ki[d]||U&&!he(Eo,R)?!0:!w},ba=q({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ln=function(d){return!ba[pt(d)]&&he(So,d)},xa=function(d,f,w,S){if(H&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!w)switch(h.getAttributeType(d,f)){case"TrustedHTML":return le(S);case"TrustedScriptURL":return B(S)}return S},va=function(d,f,w,S){try{return w?d.setAttributeNS(w,f,S):d.setAttribute(f,S),Qt(d)?(et(d),!1):!0}catch{return wt(f,d),!1}},dn=function(d,f){return Re&&he(ms,f)?!0:pt(d)==="attributename"&&Yo(f,"href")!==-1},ya=function(d,f){if(Pe(j.beforeSanitizeAttributes,d,null),Tt(d,f))return;const w=d.attributes;if(!w||Qt(d))return;X=an(j.uponSanitizeAttribute,X,Je,Kt);const S={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:X,forceKeepAttr:void 0};let R=w.length;const I=ie(F(d));for(;R--;){const $=w[R],de=$.name,Ge=$.namespaceURI,Ie=$.value,Te=ie(de),Ne=Ie;let me=de==="value"?Ne:Ya(Ne),cn=!1;if(S.attrName=Te,S.attrValue=me,S.keepAttr=!0,S.forceKeepAttr=void 0,Pe(j.uponSanitizeAttribute,d,S),me=S.attrValue,Wi&&(Te==="id"||Te==="name")&&Yo(me,Gi)!==0&&(wt(de,d,$),me=Gi+me,cn=!0),dn(de,me)){wt(de,d,$);continue}if(!S.forceKeepAttr){if(!S.keepAttr){wt(de,d,$);continue}if(!ge&&he(Cn,me)){wt(de,d,$);continue}if(Q&&(me=$o(me)),!sn(I,Te,me)){wt(de,d,$);continue}me=xa(I,Te,Ge,me),me!==Ne&&va(d,de,Ge,me)&&cn&&bn(e.removed)}}Pe(j.afterSanitizeAttributes,d,null),Tt(d,f)},Uo=function(d,f){ma(d,f),ya(d,f),Et(d.content)&&Wo(d.content)},Wo=function(d){let f=null;const w=Zt(d);for(Pe(j.beforeSanitizeShadowDOM,d,null);f=w.nextNode();)if(Pe(j.uponSanitizeShadowNode,f,null),Uo(f,d),N(f)===ne.element){const S=D(f);Et(S)&&(Go(S),Wo(S))}Q&&Ho(d),Pe(j.afterSanitizeShadowDOM,d,null)},Go=function(d){const f=[{node:d,shadow:null}];for(;f.length>0;){const w=f.pop();if(w.shadow){Wo(w.shadow);continue}const S=w.node,R=N(S)===ne.element,I=y(S);if(I)for(let $=I.length-1;$>=0;--$)f.push({node:I[$],shadow:null});if(R){const $=L?L(S):null;if(typeof $=="string"&&ie($)==="template"){const de=S.content;Et(de)&&f.push({node:de,shadow:null})}}if(R){const $=D(S);Et($)&&f.push({node:null,shadow:$},{node:$,shadow:null})}}};return e.sanitize=function(E){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},f=null,w=null,S=null,R=null;if(_o=!E,_o&&(E="<!-->"),typeof E!="string"&&!Rt(E)&&(E=es(E),typeof E!="string"))throw Ke("dirty is not a string, aborting");if(!e.isSupported)return E;ko?(Y=qt,X=Kt):Io(d),e.removed=[];const I=Mo&&typeof E!="string"&&Rt(E);let $=[];const de=lt;if(I){ha(E);const Ne=F(E);if(typeof Ne=="string"){const me=ie(Ne);if(!Y[me]||st[me])throw Fo(E),Ke("root node is forbidden and cannot be sanitized in-place")}if(Qt(E))throw Fo(E),Ke("root node is clobbered and cannot be sanitized in-place");$=No(E),lt=Ko()}else if(Rt(E))f=nn("<!---->"),w=f.ownerDocument.importNode(E,!0),w.nodeType===ne.element&&w.nodeName==="BODY"||w.nodeName==="HTML"?f=w:f.appendChild(w),Go(f);else{if(!xt&&!Q&&!We&&E.indexOf("<")===-1)return De(E);if(f=nn(E),!f)return xt?null:Ao?pe:""}f&&Co&&et(f.firstChild);const Ge=I?E:f;try{I&&Go(E);const Ne=Zt(Ge);for(;S=Ne.nextNode();)Uo(S,Ge);I&&ca(E,$)}catch(Ne){throw I&&(Fo(E),tn(E,$)),Ne}finally{lt=de}if(I){if(tn(E,$))throw Ke("a node selected for removal could not be safely returned; refusing to sanitize in place");return Q&&Bo(E),E}if(xt){if(Q&&Bo(f),Vt)for(R=G.call(f.ownerDocument);f.firstChild;)R.appendChild(f.firstChild);else R=f;return(X.shadowroot||X.shadowrootmode)&&(R=Wt.call(i,R,!0)),R}const Ie=()=>We?f.outerHTML:f.innerHTML;let Te=Ie();return Q&&he(ls,Te)&&(Ho(f),Te=Ie()),We&&Y["!doctype"]&&f.ownerDocument&&f.ownerDocument.doctype&&f.ownerDocument.doctype.name&&he(hs,f.ownerDocument.doctype.name)&&(Te="<!DOCTYPE "+f.ownerDocument.doctype.name+`>
|
|
3
|
+
`+Te),De(Te)},e.setConfig=function(){let E=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Io(E),ko=!0,qt=Y,Kt=X},e.clearConfig=function(){Xt=null,ko=!1,qt=null,Kt=null,H=te,pe=""},e.isValidAttribute=function(E,d,f){Xt||Io({});const w=ie(E),S=ie(d);return typeof f=="string"&&(dn(d,f)||!ge&&he(Cn,f))?!1:sn(w,S,f)},e.addHook=function(E,d){typeof d=="function"&&xe(j,E)&&Pt(j[E],d)},e.removeHook=function(E,d){if(xe(j,E)){if(d!==void 0){const f=qa(j[E],d);return f===-1?void 0:Va(j[E],f,1)[0]}return bn(j[E])}},e.removeHooks=function(E){xe(j,E)&&(j[E]=[])},e.removeAllHooks=function(){j=An()},e}var ws=Dr();const Es={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function Ts(t,e){const o=t.options;return c.resolveBarcodeDesignValue(o.formatter,e,String(o.testData||o.title||""))||"1234567890128"}function Ss(t){return a("div",{class:"print-qrcode",dataset:{codeId:t.id,codeKind:"qrcode"}})}function ks(t){const e=t.options;return a("div",{class:"print-barcode",dataset:{codeId:t.id,codeKind:"barcode"}},[a("svg",{preserveAspectRatio:Es[String(e.fit||"contain")]??"xMidYMid meet",style:{maxWidth:"100%",maxHeight:"100%"}})])}function Cs(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(o=>!Number.isFinite(o))?null:{width:e[2],height:e[3]}}function As(t,e,o){const i=t.options,n=c.barcodeUnitsPerModule(i.barWidth),r=c.barcodeQuietZoneModules(i.barQuietZone),s=l=>{rr(e,Ts(t,o),{format:String(i.barcodeType||"CODE128"),width:n,height:l*n,displayValue:!i.hideTitle,fontSize:(i.fontSize??c.BARCODE_TEXT_FONT_SIZE_MODULES)*n,margin:0,marginLeft:r*n,marginRight:r*n,marginTop:0,marginBottom:c.BARCODE_MARGIN_BOTTOM_MODULES*n});const p=Cs(e);return p?{widthUnits:p.width,heightUnits:p.height}:null};try{const l=c.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:c.barcodeAvailableBoxMm(i.width,i.maxWidth),boxHeightMm:c.barcodeAvailableBoxMm(i.height,i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:s});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 Ds(t,e,o){const i=t.options,n=c.resolveBarcodeDesignValue(i.formatter,o,String(i.testData||i.title||""))||"二维码";e.replaceChildren();try{const r=Ti.browserCodeRenderer.render(n,"qrcode",{qrCodeLevel:String(i.qrCodeLevel??"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),s=document.createElement("img");s.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`,s.alt="qrcode",s.style.width="100%",s.style.height="100%",s.style.objectFit=String(i.fit||"contain"),s.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",s.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",e.appendChild(s)}catch{}}function Ms(t,e,o){for(const i of Array.from(t.querySelectorAll("[data-code-kind]"))){const n=i.dataset.codeId,r=e.find(s=>s.id===n);if(r)if(i.dataset.codeKind==="barcode"){const s=i.querySelector("svg");s&&As(r,s,o)}else Ds(r,i,o)}}const co=new Map;function _s(t){return typeof Node<"u"&&t instanceof Node}function Mr(t,e,o){if(_r(t),typeof e=="string"){o.innerHTML=e;return}if(_s(e)){o.appendChild(e);return}typeof e.node=="string"?o.innerHTML=e.node:o.appendChild(e.node),typeof e.dispose=="function"&&co.set(t,e.dispose)}function _r(t){const e=co.get(t);if(e){co.delete(t);try{e()}catch{}}}function Dn(){for(const t of[...co.keys()])_r(t)}const Rs={header:"题",data:"数",subtotal:"小",summary:"汇"},Ps=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行"},{value:"summary",label:"汇总行"}],ro=3.7795275591,Is=.1,gi=t=>JSON.parse(JSON.stringify(t)),Mn=new WeakMap;function Xe(t){let e=Mn.get(t);return e||(e={menu:null,menuElId:null,anchor:null,layouts:new Map},Mn.set(t,e)),e}function Ut(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function Fs(t,e){const o=t.tableSelection;return!o||o.elementId!==e.id?null:t.selectedElement?.id!==e.id?(t.tableSelection=null,null):o}function Rr(t,e,o,i){const n=Ut(t,o.id);if(!n)return null;const r=o.options;return{store:t,fire:e,el:o,real:n,options:r,rows:r.tableRows??[],colWidths:r.tableColWidths??[],isSelected:t.selectedIds.has(o.id),selection:Fs(t,o),maxTableWidth:Pr(t),designData:i}}function Pr(t){return t.paperSize.width-t.templateData.margins.left-t.templateData.margins.right}function _i(t){return t.options.tableDefaultFontSize??10}function Ir(t){return t.options.tableDefaultColor??"#333333"}function Ls(t,e){let o=0;for(let i=0;i<e;i++)o+=t.rows[i].height;return o}function zs(t,e){return Xe(t.store).layouts.get(t.el.id)?.[e]?.top??Ls(t,e)}function Os(t,e){return Xe(t.store).layouts.get(t.el.id)?.[e]?.height??t.rows[e]?.height??0}function Ns(t){const e=t.options.dataSource;if(e&&Array.isArray(c.DEFAULT_DEMO_DATA[e]))return c.DEFAULT_DEMO_DATA[e];for(const o of Object.values(c.DEFAULT_DEMO_DATA))if(Array.isArray(o))return o}function Fr(t){return t.cellType==="barcode"||t.cellType==="qrcode"}function Lr(t,e){return Fr(e)?c.resolveBarcodeDesignValue(e.formatter,Ns(t)):e.formatter||""}function $s(t,e){const o={designMode:!0,showGhostBorder:t.store.showTableGhostBorder};return{fontFamily:_.resolveCanvasFontFamily(e.fontFamily??t.options.tableDefaultFontFamily),textAlign:e.align??"left",...e.align==="justify"?{textAlignLast:"justify"}:{},verticalAlign:e.valign??"middle",fontSize:(e.fontSize??_i(t))+"pt",fontWeight:e.fontWeight??"normal",color:e.color??Ir(t),backgroundColor:e.backgroundColor??"transparent",borderTop:c.resolveCellBorderCss(e.borders?.top,o),borderRight:c.resolveCellBorderCss(e.borders?.right,o),borderBottom:c.resolveCellBorderCss(e.borders?.bottom,o),borderLeft:c.resolveCellBorderCss(e.borders?.left,o),padding:(e.padding??t.options.tableDefaultPadding??1)+"mm",whiteSpace:e.wordWrap??!0?"pre-wrap":"nowrap",overflow:e.wordWrap??!0?"visible":"hidden"}}function Bs(t,e,o){const i=t.selection;return[!!i&&e>=i.r1&&e<=i.r2&&o>=i.c1&&o<=i.c2?"cell-selected":"",t.rows[e]?.type==="data"?"row-data-bg":""].filter(Boolean).join(" ")}function zr(t){return c.resolveCellTextFit(t)}function Hs(t){return zr(t)!=="autoHeight"}function Us(t,e){return e.fontSize??_i(t)}function go(t,e,o){return c.cellFitCapMm(t.rows,e,o,t.options.tableDefaultPadding??1)}function Ws(t,e,o){return c.cellFitWidthMm(t.colWidths,e,o,t.options.tableDefaultPadding??1)}function Gs(t,e,o){return{maxHeight:go(t,o,e)+"mm",overflow:"hidden",...e.wordWrap===!1?{whiteSpace:"nowrap",textOverflow:"ellipsis"}:{}}}function qs(t,e,o){const i={fitBase:String(Us(t,e)),fitMin:String(c.resolveShrinkMinFontSize(e.shrinkMinFontSize)),fitMm:String(go(t,o,e))};return zr(e)==="shrink"&&(i.fit="shrink"),i}function Ks(t){const e=(t.getAttribute("viewBox")??"").trim().split(/[\s,]+/).map(Number);return e.length!==4||e.some(o=>!Number.isFinite(o))?null:{width:e[2],height:e[3]}}const Vs={contain:"xMidYMid meet",cover:"xMidYMid slice",fill:"none",none:"xMidYMid meet","scale-down":"xMidYMid meet"};function js(t,e,o,i){const n=document.createElement("div");n.className="cell-barcode";const r=document.createElementNS(ka,"svg");n.appendChild(r);const s=Lr(t,i);if(i.cellType==="barcode"){r.setAttribute("preserveAspectRatio",Vs[i.fit||"contain"]??"xMidYMid meet");const l=c.barcodeUnitsPerModule(i.barWidth),p=c.barcodeQuietZoneModules(i.barQuietZone),u=g=>{rr(r,s,{format:i.barcodeType||"CODE128",width:l,height:g*l,displayValue:i.showBarcodeText!==!1,fontSize:(i.barFontSize??c.BARCODE_TEXT_FONT_SIZE_MODULES)*l,margin:0,marginLeft:p*l,marginRight:p*l,marginTop:0,marginBottom:c.BARCODE_MARGIN_BOTTOM_MODULES*l});const T=Ks(r);return T?{widthUnits:T.width,heightUnits:T.height}:null};let h=null;try{h=c.layoutBarcodeSize({barHeightMm:i.barHeight,boxWidthMm:c.barcodeAvailableBoxMm(Ws(t,o,i),i.maxWidth),boxHeightMm:c.barcodeAvailableBoxMm(go(t,e,i),i.maxHeight),dpi:i.printerDpi,barWidth:i.barWidth,measure:u})}catch{h=null}if(!h){r.style.display="none";const g=document.createElement("span");return g.className="cell-barcode-fallback",g.textContent=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=Ti.browserCodeRenderer.render(s,"qrcode",{qrCodeLevel:String(i.qrCodeLevel||"M"),qrQuietZone:typeof i.qrQuietZone=="number"?i.qrQuietZone:void 0}),p=document.createElement("img");p.setAttribute("src",`data:image/svg+xml;charset=utf-8,${encodeURIComponent(l)}`),p.setAttribute("alt","qrcode"),p.style.width="100%",p.style.height="100%",p.style.objectFit=i.fit||"contain",i.objectPosition&&(p.style.objectPosition=i.objectPosition),p.style.maxWidth=i.maxWidth?`${i.maxWidth}mm`:"100%",p.style.maxHeight=i.maxHeight?`${i.maxHeight}mm`:"100%",n.appendChild(p)}catch{}return n}function _n(){const t=document.createElement("div");return t.className="image-placeholder",t.textContent="图片",t}function Ys(t,e){const o=t.formatter||"";if(!o)return"";if(!o.includes("{"))return o;const i=e.designData?.length?e.designData[0]:c.DEFAULT_DEMO_DATA;return c.evaluateTemplate(o,i)}function Xs(t,e,o){const i=document.createElement("div");i.className="cell-image";const n=c.cellImageBoxMm(o.fit,go(t,e,o));n!==void 0&&(i.style.height=`${n}mm`);const r=Ys(o,t);if(!r)return i.appendChild(_n()),i;const s=document.createElement("img");s.setAttribute("src",r),n!==void 0&&(s.style.width="100%",s.style.height="100%"),s.style.objectFit=o.fit||"contain";for(const[l,p]of Object.entries(c.cropStyleDeclarations(o.fit,o.fitScale,o.objectPosition)))s.style[l]=p;return s.style.maxWidth=o.maxWidth?`${o.maxWidth}mm`:"100%",s.style.maxHeight=o.maxHeight?`${o.maxHeight}mm`:"100%",s.addEventListener("error",()=>{s.remove(),i.appendChild(_n())},{once:!0}),i.appendChild(s),i}function Zs(t,e,o,i,n){if(Fr(n))return js(t,o,i,n);if(n.cellType==="image")return Xs(t,o,n);const r=Lr(t,n),s=()=>e.type==="data"?a("span",{class:"data-placeholder",text:r}):r;return Hs(n)?a("div",{class:"cell-fit",style:Gs(t,n,o),dataset:qs(t,n,o)},[s()]):s()}function po(t,e,o){const i={elementId:t.el.id,...c.normalizeSelection(t.rows,e,o)};t.store.setTableSelection(i),t.fire("table-selection-change",{elementId:t.el.id,selection:i})}function Qs(t,e,o,i,n){if(n.button!==0||(t.fire("table-cell-mousedown",{elementId:t.el.id,r:e,c:o,cellId:i,event:n}),!t.isSelected))return;n.stopPropagation();const r=Xe(t.store);n.shiftKey&&t.selection?po(t,{r:t.selection.r1,c:t.selection.c1},{r:e,c:o}):(r.anchor={r:e,c:o},po(t,{r:e,c:o},{r:e,c:o})),document.addEventListener("mouseup",()=>{Xe(t.store).anchor=null},{once:!0})}function Js(t,e,o){const i=Xe(t.store).anchor;i&&po(t,i,{r:e,c:o})}function Ri(t,e){const o=Xe(t);o.menu?.visible&&(o.menu.visible=!1,e("table-menu-close",{elementId:o.menuElId}),t.emit(!1))}function el(t,e,o,i){i.preventDefault(),i.stopPropagation(),t.isSelected||t.store.selectOne(t.el.id);const n=t.selection;n&&e>=n.r1&&e<=n.r2&&o>=n.c1&&o<=n.c2||po(t,{r:e,c:o},{r:e,c:o});const s=Xe(t.store);s.menuElId=t.el.id,s.menu&&(s.menu.x=i.clientX,s.menu.y=i.clientY,s.menu.visible=!0),t.fire("table-cell-contextmenu",{elementId:t.el.id,r:e,c:o,clientX:i.clientX,clientY:i.clientY}),t.store.emit(!1),document.addEventListener("mousedown",()=>Ri(t.store,t.fire),{once:!0})}function Rn(t,e,o){const i=t.reduce((n,r)=>n+r,0)+(t[e]??0);return i>o?`插入后表格总宽 ${Math.round(i*10)/10}mm 超过打印范围宽度 ${o}mm,请先缩小列宽`:null}function tl(t,e){const o=t.real.options.tableRows??[],i=t.real.options.tableColWidths??[],n=e(gi(o),gi(i));return n?(window.alert(n),!1):(t.store.recordHistory(),e(o,i),t.store.setTableSelection(null),c.syncTableElementSize(t.real.options),t.store.emit(),!0)}function Ve(t,e,o){Ri(t.store,t.fire);const i=t.selection;if(!i)return;let n=null;switch(e){case"insert-row-above":n=r=>(c.insertRow(r,i.r1,"above"),null);break;case"insert-row-below":n=r=>(c.insertRow(r,i.r2,"below"),null);break;case"delete-row":n=r=>c.deleteRow(r,i.r1);break;case"insert-col-left":n=(r,s)=>{const l=Rn(s,i.c1,t.maxTableWidth);return l||(c.insertCol(r,s,i.c1,"left"),null)};break;case"insert-col-right":n=(r,s)=>{const l=Rn(s,i.c2,t.maxTableWidth);return l||(c.insertCol(r,s,i.c2,"right"),null)};break;case"delete-col":n=(r,s)=>c.deleteCol(r,s,i.c1);break;case"merge":n=r=>(c.mergeCells(r,i),null);break;case"split":n=r=>(c.splitCells(r,i),null);break;case"set-row-type":n=r=>o?c.setRowType(r,i.r1,o):"未指定行类型";break}n&&tl(t,n)&&t.fire(`table-${e}`,{elementId:t.el.id,...o?{type:o}:{}})}function ol(t){const e=t.selection;if(!e)return!1;for(let o=e.r1;o<=e.r2;o++)for(let i=e.c1;i<=e.c2;i++){const n=t.rows[o]?.cells[i];if(n&&!n.merged&&((n.rowspan??1)>1||(n.colspan??1)>1))return!0}return!1}function il(t){const e=t.selection;if(!e)return;const o=c.findMainCell(t.rows,e.r1,e.c1),i=!t.rows[o.r]?.cells[o.c]?.mergeSameValue;for(let n=e.r1;n<=e.r2;n++)for(let r=e.c1;r<=e.c2;r++){const s=t.rows[n]?.cells[r];s&&!s.merged&&(s.mergeSameValue=i)}t.store.updateElement(t.el.id,{tableRows:t.rows}),Ri(t.store,t.fire)}function Pn(t){const e=t.selection;if(!e)return"未选择单元格";for(let o=e.r1;o<=e.r2;o++)if(t.rows[o]?.type!=="data")return"仅数据行(明细行)支持按值合并";return null}function In(t,e){const o=t.selection;return o?o.r1!==o.r2?"行类型仅支持单行设置":c.setRowType(gi(t.rows),o.r1,e):"未选择单元格"}function $e(t,e,o={}){return a("div",{class:`menu-item${o.disabled?" disabled":""}${o.active?" active":""}`,title:o.title||"",text:t,onClick:()=>{o.disabled||e()}})}const oi=()=>a("div",{class:"menu-divider"});function nl(t,e,o){const i=Xe(t);if(i.menu=o,!o.visible||!i.menuElId)return"";const n=Ut(t,i.menuElId);if(!n||n.printElementType.type!=="table")return"";const r=Rr(t,e,n);if(!r)return"";const s=r.selection?c.canMergeReason(r.rows,r.selection):"未选择单元格",l=r.selection?r.rows[r.selection.r1]?.type??null:null;return a("div",{class:"table-ctx-menu",style:{left:o.x+"px",top:o.y+"px"},onMousedown:p=>p.stopPropagation()},[$e("在上方插入行",()=>Ve(r,"insert-row-above")),$e("在下方插入行",()=>Ve(r,"insert-row-below")),$e("删除行",()=>Ve(r,"delete-row"),{disabled:r.rows.length<=1}),oi(),$e("在左侧插入列",()=>Ve(r,"insert-col-left")),$e("在右侧插入列",()=>Ve(r,"insert-col-right")),$e("删除列",()=>Ve(r,"delete-col"),{disabled:r.colWidths.length<=1}),oi(),$e("合并单元格",()=>Ve(r,"merge"),{disabled:!!s,title:s||""}),$e("拆分单元格",()=>Ve(r,"split"),{disabled:!ol(r)}),$e("按值合并",()=>il(r),{disabled:!!Pn(r),title:Pn(r)||"",active:(()=>{const p=r.selection;if(!p)return!1;const u=c.findMainCell(r.rows,p.r1,p.c1);return r.rows[u.r]?.cells[u.c]?.mergeSameValue===!0})()}),oi(),a("div",{class:"menu-group-title",text:"行类型"}),...Ps.map(p=>$e(p.label,()=>Ve(r,"set-row-type",p.value),{disabled:!!In(r,p.value),title:In(r,p.value)||"",active:l===p.value}))])}let gt=null;function Or(){gt&&(document.removeEventListener("mousemove",Pi),document.removeEventListener("mouseup",Ii),gt.handle.classList.remove("dragging"),gt=null)}function rl(t,e){const o=t.closest(".hiprint-printPaper");return(o&&o.offsetWidth>0?o.getBoundingClientRect().width/o.offsetWidth:0)||(e.scale||100)/100}function al(t,e,o){if(o.button!==0)return;const i=o.currentTarget,n=i.closest(".print-table");if(!n)return;Or();const r=t.real.options.tableColWidths??[];gt={store:t.store,fire:t.fire,elId:t.real.id,boundary:e,startX:o.clientX,startWidth:r[e-1]??0,scale:rl(n,t.store),root:n,wrapper:i.closest(".print-element"),handle:i},i.classList.add("dragging"),t.store.recordHistory(),document.addEventListener("mousemove",Pi),document.addEventListener("mouseup",Ii)}function Pi(t){const e=gt;if(!e)return;const o=Ut(e.store,e.elId),i=o?.options.tableColWidths;if(!o||!i)return;const n=(t.clientX-e.startX)/(e.scale*ro),r=e.boundary-1;i[r]=c.clampResizedColumnWidth(i,r,e.startWidth+n,Pr(e.store)),c.syncTableElementSize(o.options),i.forEach((s,l)=>{const p=e.root.querySelector(`colgroup col:nth-child(${l+1})`);p&&(p.style.width=`${s}mm`)}),e.root.querySelectorAll(".col-resize-handle").forEach((s,l)=>{s.style.left=`${i.slice(0,l+1).reduce((p,u)=>p+u,0)}mm`}),e.wrapper&&(e.wrapper.style.width=`${o.options.width}mm`,e.wrapper.style.height=`${o.options.height}mm`)}function Ii(){document.removeEventListener("mousemove",Pi),document.removeEventListener("mouseup",Ii);const t=gt;if(!t)return;gt=null,t.handle.classList.remove("dragging");const e=Ut(t.store,t.elId);e&&c.syncTableElementSize(e.options),t.store.emit(),t.fire("table-col-resize-end",{elementId:t.elId})}function sl(t,e,o){const i=o.querySelector("table");if(!i)return;const n=i.offsetHeight;if(n<=0)return;const r=Ut(t,e);if(!r)return;let s=!1;const l=n/ro;Math.abs(l-(r.options.height??0))>Is&&(r.options.height=Math.round(l*100)/100,s=!0);const p=i.offsetTop,u=Array.from(i.rows).map(m=>({top:(m.offsetTop-p)/ro,height:m.offsetHeight/ro})),h=Xe(t);ll(h.layouts.get(e),u)||(h.layouts.set(e,u),s=!0),s&&t.emit(!1)}function ll(t,e){return!t||t.length!==e.length?!1:e.every((o,i)=>{const n=t[i];return Math.round(o.top*10)===Math.round(n.top*10)&&Math.round(o.height*10)===Math.round(n.height*10)})}function dl(t,e){const o=document.createComment("pd-table-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const i=o.parentElement;i&&sl(t,e,i)}),o}function cl(t){return t.isSelected&&!t.real.options.locked&&t.colWidths.length>=1}function pl(t){return Array.from({length:t.colWidths.length},(e,o)=>o+1)}function ul(t,e){return t.colWidths.slice(0,e).reduce((o,i)=>o+i,0)}function hl(t,e,o,i){const n=Rr(e,o,t,i);if(!n)return a("div",{class:"print-table"});const r=[a("table",{style:{fontSize:`${_i(n)}pt`,color:Ir(n)}},[a("colgroup",{},n.colWidths.map(s=>a("col",{style:{width:s+"mm"}}))),a("tbody",{},n.rows.map((s,l)=>a("tr",{style:{height:s.height+"mm"}},s.cells.map((p,u)=>p.merged?"":a("td",{rowspan:p.rowspan||1,colspan:p.colspan||1,class:Bs(n,l,u),style:$s(n,p),onMousedown:h=>Qs(n,l,u,p.id,h),onMouseenter:()=>Js(n,l,u),onContextmenu:h=>el(n,l,u,h)},[Zs(n,s,l,u,p)])).filter(Boolean))))])];return cl(n)&&r.push(a("div",{class:"col-resize-layer"},pl(n).map(s=>a("div",{class:"col-resize-handle",role:"separator","aria-label":`列宽手柄${s}`,style:{left:ul(n,s)+"mm"},onMousedown:l=>{l.stopPropagation(),l.preventDefault(),al(n,s,l)}})))),n.isSelected&&r.push(a("div",{class:"row-badges"},n.rows.map((s,l)=>a("span",{class:"row-badge",style:{top:zs(n,l)+"mm",height:Os(n,l)+"mm"},text:Rs[s.type]})))),r.push(dl(e,t.id)),a("div",{class:"print-table design-mode",dataset:{tableId:t.id},onContextmenu:s=>s.preventDefault()},r)}const fl=["黄芪 20g","当归尾 15g","赤芍 10g","川芎 10g","地龙 10g","桃仁 10g","红花 10g"];function mi(t){return Array.isArray(t)&&t.length>0?t:[]}function gl(t,e){const o=c.detectFlowListKey(t,e)??(e?Object.keys(e).find(n=>Array.isArray(e[n])):void 0);if(o)return mi(e?.[o]);const i=c.detectFlowListKey(t,c.DEFAULT_DEMO_DATA);return i?mi(c.DEFAULT_DEMO_DATA[i]):[]}function ml(t,e){const o=t.options,i=typeof o.formatter=="string"?o.formatter:"",n=mi(e)[0],r=gl(i,n);if(r.length===0)return[...fl];if(!i)return r.map(p=>String(p?.name??JSON.stringify(p)));const s=n??{},l=c.detectFlowListKey(i,s)??Object.keys(s).find(p=>Array.isArray(s[p]));return r.map(p=>{try{return c.evaluateTemplate(i,{...s,...p,...l?{[l]:p}:{}})}catch{return i}})}const bl=3.7795275591,xl=.1;function vl(t,e){return t.templateData.elements.find(o=>o.id===e)??null}function yl(t){const e=t.parentElement;if(!e?.classList.contains("print-element"))return 0;const o=getComputedStyle(e);return(parseFloat(o.borderTopWidth)||0)+(parseFloat(o.borderBottomWidth)||0)}function wl(t,e,o){const i=o.offsetHeight+yl(o);if(i<=0)return;const n=vl(t,e);if(!n)return;const r=i/bl;Math.abs(r-(n.options.height??0))>xl&&(n.options.height=Math.round(r*100)/100,t.emit(!1))}function El(t,e){const o=document.createComment("pd-flowlist-measure");return requestAnimationFrame(()=>{if(!o.isConnected)return;const i=o.parentElement;i&&wl(t,e,i)}),o}function Tl(t,e,o){const i=t.options,n=c.resolveFlowColumns(i.flowColumns),r=c.resolveFlowGapX(i.flowGapX),s=c.resolveFlowRowHeight(i.flowRowHeight),l=c.resolveFlowLayoutMode(i.flowLayoutMode)==="dynamic",p=c.resolveFlowPadding(i),u={display:"grid",gridTemplateColumns:`repeat(${n},minmax(0,1fr))`,columnGap:`${r}mm`,gridAutoRows:`minmax(${s}mm,auto)`,width:"100%",...l?{padding:`${p.top}mm ${p.right}mm ${p.bottom}mm ${p.left}mm`,height:"auto",overflow:"visible"}:{height:"100%",overflow:"hidden"},fontSize:`${i.fontSize||12}pt`,fontWeight:i.fontWeight||"normal",color:i.color||"#333",boxSizing:"border-box"};i.fontFamily&&(u.fontFamily=String(i.fontFamily)),i.backgroundColor&&(u.backgroundColor=String(i.backgroundColor));const h=ml(t,e).map(m=>a("div",{class:"print-flow-cell",text:m}));return l&&o&&h.push(El(o,t.id)),a("div",{class:"print-flowlist",style:u},h)}const Fn={top:"flex-start",middle:"center",bottom:"flex-end"},Sl={left:"flex-start",center:"center",right:"flex-end"};function kl(t,e){const o=t.options,i=c.resolveElementMargins(o),n=c.resolveElementBorder(t.printElementType.type,o),r={};if(n?.all&&(r.border=`${n.all.borderWidth} ${n.all.borderStyle} ${n.all.borderColor}`),n)for(const s of c.ELEMENT_BORDER_SIDES){const l=n.edges[s];l&&(r[`border${s.charAt(0).toUpperCase()}${s.slice(1)}`]=`${l.borderWidth} ${l.borderStyle} ${l.borderColor}`)}return{position:"absolute",left:`${o.left}mm`,top:`${o.top}mm`,width:`${o.width}mm`,height:`${o.height}mm`,...i.top!==0?{marginTop:`${i.top}mm`}:{},...i.right!==0?{marginRight:`${i.right}mm`}:{},...i.bottom!==0?{marginBottom:`${i.bottom}mm`}:{},...i.left!==0?{marginLeft:`${i.left}mm`}:{},zIndex:String(o.zIndex||"auto"),...r,...Cl(t,e)}}function Cl(t,e){if(e?.has(t.id))return{};const o=c.resolveElementRotation(t.printElementType.type,t.options);return o===void 0?{}:{rotate:`${o}deg`}}function Ln(t){const e=t.options,o=t.printElementType.type==="longText",i=c.resolveElementTextFit(t.printElementType.type,e),n=e.fontSize||12,r=i==="autoHeight",s={fontSize:`${n}pt`,fontWeight:e.fontWeight||"normal",fontFamily:_.resolveCanvasFontFamily(e.fontFamily),color:e.color||"#333",backgroundColor:e.backgroundColor||"transparent",textAlign:e.textAlign||"left",...e.textAlign==="justify"?{textAlignLast:"justify"}:{},lineHeight:e.lineHeight?`${e.lineHeight}pt`:o?"1.5":"normal",letterSpacing:e.letterSpacing?`${e.letterSpacing}pt`:"normal",width:"100%",height:r?"auto":"100%",boxSizing:"border-box",overflow:r?"visible":"hidden",...o?{wordBreak:"break-all",textIndent:e.longTextIndent?`${e.longTextIndent}em`:"0"}:{textDecoration:e.textDecoration||"none",padding:`${e.contentPaddingTop||0}pt ${e.contentPaddingRight||0}pt ${e.contentPaddingBottom||0}pt ${e.contentPaddingLeft||0}pt`}};c.resolveElementNowrap(e)&&(s.whiteSpace="nowrap",s.textOverflow="ellipsis");const l=c.resolveElementWhiteSpace(e);return l&&(s.whiteSpace=l),e.verticalAlign&&(s.display="flex",e.textAlign==="justify"?(s.flexDirection="column",s.justifyContent=Fn[e.verticalAlign]??"flex-start"):(s.alignItems=Fn[e.verticalAlign]??"flex-start",s.justifyContent=Sl[e.textAlign||"left"]??"flex-start")),{style:s,fit:i}}function zn(t){const e=t.options,o=`${e.borderWidth||.75}pt`,i=e.borderStyle||"solid",n=e.borderColor||"#333";return t.printElementType.type==="hline"?{width:"100%",height:"0",borderTop:`${o} ${i} ${n}`,boxSizing:"border-box"}:{width:"0",height:"100%",borderLeft:`${o} ${i} ${n}`,boxSizing:"border-box"}}function On(t){const e=t.options;return{width:"100%",height:"100%",borderWidth:`${e.borderWidth||1}pt`,borderStyle:e.borderStyle||"solid",borderColor:e.borderColor||"#333",backgroundColor:e.backgroundColor||"transparent",borderRadius:t.printElementType.type==="oval"?"50%":"0",boxSizing:"border-box"}}function Al(t){const e=t.options;return{objectFit:e.fit||"contain",...c.cropStyleDeclarations(e.fit,e.fitScale,e.objectPosition),maxWidth:e.maxWidth?`${e.maxWidth}mm`:"100%",maxHeight:e.maxHeight?`${e.maxHeight}mm`:"100%"}}function Nn(t){const e=t.options,o={fitBase:String(e.fontSize||12),fitMin:String(c.resolveShrinkMinFontSize(e.shrinkMinFontSize))};return c.resolveElementTextFit(t.printElementType.type,e)==="shrink"&&(o.fit="shrink"),o}const Dl={text:t=>{const{style:e}=Ln(t),o=t.options;return a("div",{class:"print-text",style:e,dataset:Nn(t),text:String(o.testData||o.formatter||"")||"文本"})},longText:t=>{const{style:e}=Ln(t),o=t.options;return a("div",{class:"print-longtext",style:e,dataset:Nn(t),text:String(o.formatter||"")||"长文本内容"})},hline:t=>a("div",{class:"print-line",style:zn(t)}),vline:t=>a("div",{class:"print-line",style:zn(t)}),rect:t=>a("div",{class:"print-shape",style:On(t)}),oval:t=>a("div",{class:"print-shape",style:On(t)}),image:(t,e,o)=>{const i=t.options,n=String(i.src??""),r=o?.designData?.length?o.designData[0]:c.DEFAULT_DEMO_DATA,s=n.includes("{")?c.evaluateTemplate(n,r):n;return a("div",{class:"print-image"},[s?a("img",{src:s,style:Al(t)}):a("div",{class:"image-placeholder",text:"图片"})])},qrcode:t=>Ss(t),barcode:t=>ks(t),html:t=>{const e=t.options,o=String(e.formatter??""),i=o?ws.sanitize(c.evaluateTemplate(o,{})):'<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:i})},pageNumber:(t,e)=>{const o=t.options;return a("div",{class:"page-number-element",style:{fontSize:`${o.fontSize||12}pt`,fontWeight:o.fontWeight||"normal",fontFamily:_.resolveCanvasFontFamily(o.fontFamily),color:o.color||"#333",textAlign:o.textAlign||"left",...o.textAlign==="justify"?{textAlignLast:"justify"}:{}},text:e?o.title||"{pageIndex}/{totalPages}":String(o.title||"")})},table:(t,e,o)=>o?hl(t,o.store,o.fire,o.designData):a("div",{class:"print-table"}),flowList:(t,e,o)=>Tl(t,void 0,o?.store)};pr(Dl);function Ml(t,e,o){const i=t.printElementType.type,n=nt(i)?.renderContent;if(n)return n(t,e,o);const r=Ci(i);if(!r)return a("div",{text:i});const s=document.createElement("div");s.className="plugin-kit-canvas",s.style.width="100%",s.style.height="100%";try{Mr(`canvas:${t.id}`,r.ui.renderCanvas({element:t,data:o?.designData?.length?o.designData:[c.DEFAULT_DEMO_DATA],designMode:!0}),s)}catch{s.textContent=String(i)}return s}function Nr(t){return`x:${Math.round(t.left)} y:${Math.round(t.top)} ${Math.round(t.width)}×${Math.round(t.height)}mm`}function _l(t,e,o){const i=t.store,n=i.selectedIds.has(e.id),r=i.previewIds.has(e.id),s=e.options,l=e.zone||"content",p=[Ml(e,!0,{store:i,fire:t.fire,designData:t.host.designData})];return i.draggingIds.has(e.id)&&p.push(a("div",{class:"drag-preview"})),n&&(p.push(a("div",{class:"resize-handles"},c.RESIZE_POINTS.map(u=>a("div",{class:`resize-handle handle-${u}`,dataset:{point:u,elId:e.id},onMousedown:h=>t.fire("resize-start",{event:h,id:e.id,point:u})})))),p.push(a("div",{class:"selected-indicator"},[a("div",{class:"position-label",text:Nr(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:kl(e,o),dataset:{elId:e.id},onMousedown:u=>t.fire("element-mousedown",{event:u,id:e.id}),onContextmenu:u=>{u.preventDefault(),u.stopPropagation(),t.fire("contextmenu",{event:u,id:e.id})}},p)}function bi(t,e){const o=t.margins,i=t.header?.height??10,n=t.footer?.height??10,r=e.width-o.left-o.right;return{header:{left:o.left,top:o.top,width:r,height:i},content:{left:o.left,top:o.top+i,width:r,height:e.height-o.top-o.bottom-i-n},footer:{left:o.left,top:e.height-o.bottom-n,width:r,height:n}}}const Rl='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 .5H20M.5 0V20" fill="none" stroke="rgba(0,0,0,0.08)" stroke-width="1" stroke-dasharray="4 4"/></svg>';function $n(t,e){return t.type==="vertical"?{left:`${t.position}mm`,top:"0",height:`${e.height}mm`,borderLeftColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}:{top:`${t.position}mm`,left:"0",width:`${e.width}mm`,borderTopColor:t.color||"var(--pd-accent-secondary, #f56c6c)"}}function Pl(t,e){const o=_.resolveWatermarkLayout(t.watermark,[],e);return o?a("div",{class:"watermark-layer",style:{opacity:String(o.opacity)}},o.tiles.map(i=>a("svg",{class:"watermark-tile",width:`${i.widthMm}mm`,height:`${i.heightMm}mm`,viewBox:`0 0 ${o.tileWidthPx} ${o.tileHeightPx}`,style:{left:`${i.leftMm}mm`,top:`${i.topMm}mm`}},[a("text",{x:String(o.tileWidthPx/2),y:String(o.tileHeightPx/2),"font-size":String(o.fontSizePx),fill:o.color,"text-anchor":"middle","dominant-baseline":"middle",transform:`rotate(${o.rotate},${o.tileWidthPx/2},${o.tileHeightPx/2})`,text:o.text})]))):""}function ii(t,e,o,i,n,r){const s=t.store,l=[];o!=="content"&&l.push(a("span",{class:"zone-label",text:o==="header"?"页眉":"页脚"}));const p=o==="content"?_.collectFollowMemberIds(n):void 0;if(l.push(...n.map(u=>_l(t,u,p))),o!=="content"){const u=o==="header"?"bottom":"top";l.push(a("div",{class:`zone-resize-handle handle-${u}`,dataset:{zone:o},onMousedown:h=>t.fire("zone-resize",{event:h,zone:o})},[e.zoneResizing===o?a("div",{class:"zone-height-tip",text:`${(o==="header"?s.templateData.header.height:s.templateData.footer.height).toFixed(1)}mm`}):""]))}return a("div",{class:`zone-layer zone-${o} design-mode`,style:{position:"absolute",left:`${i.left}mm`,top:`${i.top}mm`,width:`${i.width}mm`,height:`${i.height}mm`},dataset:{zone:o,paperWidth:String(r.width),paperHeight:String(r.height)}},l.filter(Boolean))}function Il(t){const e=t.currentTarget,o=t.dataTransfer?.types??[],i=o.includes("fieldkey"),n=o.includes("elementtype");if(!i&&!n){e.querySelector(".drop-hint")?.remove();return}i&&(t.ctrlKey||t.metaKey)&&(e.dataset.dropLabelIntent="1");const r=n?"+ 元素":e.dataset.dropLabelIntent?"+ 静态文本":"+ 取值字段";let s=e.querySelector(".drop-hint");s||(s=document.createElement("div"),s.className="drop-hint",e.appendChild(s)),s.textContent=r,s.style.left=`${t.clientX+14}px`,s.style.top=`${t.clientY+18}px`}function $r(t){t&&(t.querySelector(".drop-hint")?.remove(),delete t.dataset.dropLabelIntent)}function Fl(t,e){const o=t.store,i=o.templateData,n=_.getPaperDimensions(i),r=(o.scale||100)/100,s=bi(i,n),l=m=>o.elements.filter(g=>(g.zone||"content")===m),p=a("div",{class:"hiprint-printPaper-content",dataset:{content:""},style:{padding:`${i.margins.top}mm ${i.margins.right}mm ${i.margins.bottom}mm ${i.margins.left}mm`,position:"relative",boxSizing:"border-box",minHeight:`${n.height}mm`}},[o.showGrid?a("div",{class:"grid-bg",style:{backgroundImage:`url("data:image/svg+xml,${encodeURIComponent(Rl)}")`,backgroundSize:"5mm 5mm",backgroundPosition:"0 0"}}):"",...i.watermark&&Object.keys(i.watermark).length?[Pl(i,n)]:[],ii(t,e,"header",s.header,l("header"),n),ii(t,e,"content",s.content,l("content"),n),ii(t,e,"footer",s.footer,l("footer"),n),...o.adsorbGuides.map(m=>a("div",{class:`adsorb-guide guide-${m.type}`,style:$n(m,n)})),...(i.guides??[]).map(m=>a("div",{class:`manual-guide guide-${m.type}`,style:{...$n(m,n),"--guide-hit":`${8/r}px`},dataset:{guideId:String(m.id??"")},onMousedown:g=>t.fire("guide-mousedown",{event:g,id:m.id}),onDblclick:g=>{g.preventDefault(),t.fire("guide-remove",m.id)}}))].filter(Boolean)),u=a("div",{class:"hiprint-printPaper",dataset:{test:"paper"},style:{width:`${n.width}mm`,minHeight:`${n.height}mm`,background:i.pageBackground||"var(--pd-paper, #fff)",boxShadow:"var(--pd-shadow-paper, 0 1px 2px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.08))",overflow:"hidden",position:"relative",transform:`scale(${r})`,transformOrigin:"0 0"}},[...i.designBackground?.src?[a("div",{class:"design-background",style:{width:`${n.width}mm`,height:`${n.height}mm`,left:"0",top:"0",transform:i.designBackground.rotation?`rotate(${i.designBackground.rotation}deg)`:""}},[a("img",{src:i.designBackground.src,draggable:!1,alt:""})])]:[],p]),h=[a("div",{class:"canvas-scroll"},[a("div",{class:"paper-wrapper",style:{width:`${_.mmToPx(n.width)*r}px`,height:`${_.mmToPx(n.height)*r}px`,position:"relative"}},[u])])];if(o.showRuler&&h.push(a("div",{class:"ruler-overlay",style:{transform:`translate(${e.scrollX}px, ${e.scrollY}px)`}},[a("div",{class:"ruler-corner"}),a("canvas",{class:"pd-ruler is-horizontal",dataset:{ruler:"horizontal"},style:{width:`${e.geom.viewW}px`,height:"20px"},onMousedown:m=>t.fire("ruler-mousedown",{event:m,orientation:"horizontal"})}),a("canvas",{class:"pd-ruler is-vertical",dataset:{ruler:"vertical"},style:{width:"20px",height:`${e.geom.viewH}px`},onMousedown:m=>t.fire("ruler-mousedown",{event:m,orientation:"vertical"})})])),e.guidePreview&&h.push(a("div",{class:`ruler-guide-preview guide-${e.guidePreview.type}`,style:e.guidePreview.type==="vertical"?{left:`${e.guidePreview.position}px`,top:"0",height:"100%"}:{top:`${e.guidePreview.position}px`,left:"0",width:"100%"}})),e.marquee.visible&&h.push(a("div",{class:"marquee-selection",style:{left:`${e.marquee.x}px`,top:`${e.marquee.y}px`,width:`${e.marquee.w}px`,height:`${e.marquee.h}px`}})),e.contextMenu.visible){const m=e.contextMenu;h.push(a("div",{class:"context-menu",style:{left:`${e.contextMenu.x+e.contextMenu.flipX}px`,top:`${e.contextMenu.y+e.contextMenu.flipY}px`}},e.contextMenu.targetId?[Fe(t,m,"复制","copy"),Fe(t,m,"剪切","cut"),Fe(t,m,"粘贴","paste",!o.hasClipboard),Fe(t,m,"删除","delete"),a("div",{class:"context-menu-sep"}),Fe(t,m,"置顶","move-layer",!1,"top"),Fe(t,m,"上移","move-layer",!1,"up"),Fe(t,m,"下移","move-layer",!1,"down"),Fe(t,m,"置底","move-layer",!1,"bottom")]:[Fe(t,m,"粘贴","paste-at",!o.hasClipboard),Fe(t,m,"全选","select-all"),Fe(t,m,"取消选择","clear-selection")]))}return a("div",{class:"canvas-area",dataset:{test:"canvas-area"},onDragover:m=>{const g=m;g.preventDefault(),g.dataTransfer&&(g.dataTransfer.dropEffect="copy"),Il(g)},onDragleave:m=>{const g=m.currentTarget,T=m.relatedTarget;(!T||!g.contains(T))&&g.querySelector(".drop-hint")?.remove()},onDrop:m=>{const g=m,T=m.currentTarget,b=T.dataset.dropLabelIntent==="1";$r(T),b&&(g.labelIntent=!0),t.fire("drop",g)},onMousedown:m=>t.fire("canvas-mousedown",m),onMousemove:m=>t.fire("canvas-mousemove",m),onMouseleave:()=>t.fire("canvas-mouseleave"),onWheel:m=>t.fire("wheel",m),onScroll:m=>t.fire("scroll",m),onContextmenu:m=>{m.preventDefault(),t.fire("canvas-contextmenu",m)}},h.filter(Boolean))}function Fe(t,e,o,i,n=!1,r){return a("div",{class:`context-menu-item${n?" disabled":""}`,text:o,onClick:()=>{e.visible=!1,n||t.fire(i,r),t.repaint()}})}const Ll={AlignCenterHorizontal:'<path d="M2 12h20" /><path d="M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4" /><path d="M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4" /><path d="M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1" /><path d="M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1" />',AlignCenterVertical:'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />',AlignEndHorizontal:'<rect width="6" height="16" x="4" y="2" rx="2" /><rect width="6" height="9" x="14" y="9" rx="2" /><path d="M22 22H2" />',AlignEndVertical:'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />',AlignHorizontalSpaceBetween:'<rect width="6" height="14" x="3" y="5" rx="2" /><rect width="6" height="10" x="15" y="7" rx="2" /><path d="M3 2v20" /><path d="M21 2v20" />',AlignStartHorizontal:'<rect width="6" height="16" x="4" y="6" rx="2" /><rect width="6" height="9" x="14" y="6" rx="2" /><path d="M22 2H2" />',AlignStartVertical:'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />',AlignVerticalSpaceBetween:'<rect width="14" height="6" x="5" y="15" rx="2" /><rect width="10" height="6" x="7" y="3" rx="2" /><path d="M2 21h20" /><path d="M2 3h20" />',ArrowDown:'<path d="M12 5v14" /><path d="m19 12-7 7-7-7" />',ArrowDownToLine:'<path d="M12 17V3" /><path d="m6 11 6 6 6-6" /><path d="M19 21H5" />',ArrowUp:'<path d="m5 12 7-7 7 7" /><path d="M12 19V5" />',ArrowUpToLine:'<path d="M5 3h14" /><path d="m18 13-6-6-6 6" /><path d="M12 7v14" />',Barcode:'<path d="M3 5v14" /><path d="M8 5v14" /><path d="M12 5v14" /><path d="M17 5v14" /><path d="M21 5v14" />',Bold:'<path d="M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8" />',ChartArea:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 11.207a.5.5 0 0 1 .146-.353l2-2a.5.5 0 0 1 .708 0l3.292 3.292a.5.5 0 0 0 .708 0l4.292-4.292a.5.5 0 0 1 .854.353V16a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1z" />',ChartBar:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M7 16h8" /><path d="M7 11h12" /><path d="M7 6h3" />',ChartColumn:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="M18 17V9" /><path d="M13 17V5" /><path d="M8 17v-3" />',ChartLine:'<path d="M3 3v16a2 2 0 0 0 2 2h16" /><path d="m19 9-5 5-4-4-3 3" />',ChartPie:'<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z" /><path d="M21.21 15.89A10 10 0 1 1 8 2.83" />',ChartScatter:'<circle cx="7.5" cy="7.5" r=".5" fill="currentColor" /><circle cx="18.5" cy="5.5" r=".5" fill="currentColor" /><circle cx="11.5" cy="11.5" r=".5" fill="currentColor" /><circle cx="7.5" cy="16.5" r=".5" fill="currentColor" /><circle cx="17.5" cy="14.5" r=".5" fill="currentColor" /><path d="M3 3v16a2 2 0 0 0 2 2h16" />',Check:'<path d="M20 6 9 17l-5-5" />',ChevronDown:'<path d="m6 9 6 6 6-6" />',ChevronsLeft:'<path d="m11 17-5-5 5-5" /><path d="m18 17-5-5 5-5" />',ChevronsRight:'<path d="m6 17 5-5-5-5" /><path d="m13 17 5-5-5-5" />',ChevronsUpDown:'<path d="m7 15 5 5 5-5" /><path d="m7 9 5-5 5 5" />',Circle:'<circle cx="12" cy="12" r="10" />',ClipboardPaste:'<path d="M11 14h10" /><path d="M16 4h2a2 2 0 0 1 2 2v1.344" /><path d="m17 18 4-4-4-4" /><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113" /><rect x="8" y="2" width="8" height="4" rx="1" />',Code:'<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />',Copy:'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />',Donut:'<path d="M20.5 10a2.5 2.5 0 0 1-2.4-3H18a2.95 2.95 0 0 1-2.6-4.4 10 10 0 1 0 6.3 7.1c-.3.2-.8.3-1.2.3" /><circle cx="12" cy="12" r="3" />',Ellipsis:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',Eye:'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />',FileText:'<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 9H8" /><path d="M16 13H8" /><path d="M16 17H8" />',Funnel:'<path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" />',Gauge:'<path d="m12 14 4-4" /><path d="M3.34 19a10 10 0 1 1 17.32 0" />',Grid3x3:'<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" /><path d="M9 3v18" /><path d="M15 3v18" />',Group:'<path d="M3 7V5c0-1.1.9-2 2-2h2" /><path d="M17 3h2c1.1 0 2 .9 2 2v2" /><path d="M21 17v2c0 1.1-.9 2-2 2h-2" /><path d="M7 21H5c-1.1 0-2-.9-2-2v-2" /><rect width="7" height="5" x="7" y="7" rx="1" /><rect width="7" height="5" x="10" y="12" rx="1" />',Image:'<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />',Layers:'<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /><path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /><path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',List:'<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />',ListTree:'<path d="M8 5h13" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="M3 10a2 2 0 0 0 2 2h3" /><path d="M3 5v12a2 2 0 0 0 2 2h3" />',Maximize:'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />',Minus:'<path d="M5 12h14" />',PaintBucket:'<path d="M11 7 6 2" /><path d="M18.992 12H2.041" /><path d="M21.145 18.38A3.34 3.34 0 0 1 20 16.5a3.3 3.3 0 0 1-1.145 1.88c-.575.46-.855 1.02-.855 1.595A2 2 0 0 0 20 22a2 2 0 0 0 2-2.025c0-.58-.285-1.13-.855-1.595" /><path d="m8.5 4.5 2.148-2.148a1.205 1.205 0 0 1 1.704 0l7.296 7.296a1.205 1.205 0 0 1 0 1.704l-7.592 7.592a3.615 3.615 0 0 1-5.112 0l-3.888-3.888a3.615 3.615 0 0 1 0-5.112L5.67 7.33" />',Paintbrush:'<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />',QrCode:'<rect width="5" height="5" x="3" y="3" rx="1" /><rect width="5" height="5" x="16" y="3" rx="1" /><rect width="5" height="5" x="3" y="16" rx="1" /><path d="M21 16h-3a2 2 0 0 0-2 2v3" /><path d="M21 21v.01" /><path d="M12 7v3a2 2 0 0 1-2 2H7" /><path d="M3 12h.01" /><path d="M12 3h.01" /><path d="M12 16v.01" /><path d="M16 12h1" /><path d="M21 12v.01" /><path d="M12 21v-1" />',Radar:'<path d="M19.07 4.93A10 10 0 0 0 6.99 3.34" /><path d="M4 6h.01" /><path d="M2.29 9.62A10 10 0 1 0 21.31 8.35" /><path d="M16.24 7.76A6 6 0 1 0 8.23 16.67" /><path d="M12 18h.01" /><path d="M17.99 11.66A6 6 0 0 1 15.77 16.67" /><circle cx="12" cy="12" r="2" /><path d="m13.41 10.59 5.66-5.66" />',Redo2:'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />',RotateCcw:'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />',SeparatorVertical:'<path d="M12 3v18" /><path d="m16 16 4-4-4-4" /><path d="m8 8-4 4 4 4" />',Shapes:'<path d="M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z" /><rect x="3" y="14" width="7" height="7" rx="1" /><circle cx="17.5" cy="17.5" r="3.5" />',Square:'<rect width="18" height="18" x="3" y="3" rx="2" />',Strikethrough:'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />',Table:'<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />',Table2:'<path d="M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18" />',TextAlignCenter:'<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />',TextAlignEnd:'<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />',TextAlignJustify:'<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />',TextAlignStart:'<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />',Trash2:'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />',Type:'<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />',Underline:'<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />',Undo2:'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />',Ungroup:'<rect width="8" height="6" x="5" y="4" rx="1" /><rect width="8" height="6" x="11" y="14" rx="1" />',ZoomIn:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="11" x2="11" y1="8" y2="14" /><line x1="8" x2="14" y1="11" y2="11" />',ZoomOut:'<circle cx="11" cy="11" r="8" /><line x1="21" x2="16.65" y1="21" y2="16.65" /><line x1="8" x2="14" y1="11" y2="11" />'};function ce(t,e=15,o){const i=Ll[t];return i?`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}"${o?` class="${o}"`:""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${i}</svg>`:""}let ft=null;function Fi(t){const e=/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t.trim());if(!e)return null;const o=e[1],i=o.length===3?o.split("").map(n=>n+n).join(""):o;return{r:Number.parseInt(i.slice(0,2),16),g:Number.parseInt(i.slice(2,4),16),b:Number.parseInt(i.slice(4,6),16)}}function Li(t){const e=Fi(t);return e?Br(e):"#000000"}function Br({r:t,g:e,b:o}){return`#${[t,e,o].map(i=>Math.round(Ht(i/255)*255).toString(16).padStart(2,"0")).join("")}`}function zl(t,e,o){const i=t/255,n=e/255,r=o/255,s=Math.max(i,n,r),l=Math.min(i,n,r),p=s-l;let u=0;return p!==0&&(s===i?u=(n-r)/p%6:s===n?u=(r-i)/p+2:u=(i-n)/p+4,u*=60,u<0&&(u+=360)),{h:u,s:s===0?0:p/s,v:s}}function Ol(t,e,o){const i=o*e,n=(t%360+360)%360/60,r=i*(1-Math.abs(n%2-1)),[s,l,p]=n<1?[i,r,0]:n<2?[r,i,0]:n<3?[0,i,r]:n<4?[0,r,i]:n<5?[r,0,i]:[i,0,r],u=o-i;return{r:(s+u)*255,g:(l+u)*255,b:(p+u)*255}}function Nl(t){return((Number.isFinite(t)?t:0)%360+360)%360}function Ht(t){return Math.min(1,Math.max(0,Number.isFinite(t)?t:0))}function $l(t){const e=t.title??"颜色选择";return a("button",{type:"button",class:`preset-color-trigger${t.triggerClass?` ${t.triggerClass}`:""}`,"aria-expanded":"false","aria-haspopup":"dialog",title:e,onClick:o=>{const i=o.currentTarget??o.target,n=i.getRootNode();if(!!ft&&ft.root===n&&ft.title===e&&ft.trigger===i){Nt();return}Nt(),Bl(i,t)}},[a("span",{class:"preset-color-swatch",style:t.value?{background:t.value}:{background:"transparent"}})])}function Nt(){const t=ft;t&&(ft=null,t.teardowns.forEach(e=>e()),t.trigger.setAttribute("aria-expanded","false"),t.panel.remove())}function Bl(t,e){const o=t.getRootNode(),i=o instanceof ShadowRoot?o:document.body,n={root:o,title:e.title??"颜色选择",trigger:t,panel:null,clearable:e.clearable!==!1,onChange:e.onChange,model:e.value||void 0,hue:0,saturation:0,value_:0,hexText:"",dragging:!1,current:null,hex:null,area:null,handle:null,hueRange:null,clearBtn:null,items:[],teardowns:[]};e.value&&Oi(n,e.value)?n.hexText=Li(e.value).toUpperCase():n.hexText=e.value?String(e.value):"",n.panel=ve(Gl(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:c.PRESET_COLORS[s]})),mo(n),Hl(n),Ul(n),ft=n,t.setAttribute("aria-expanded","true")}function Hl(t){const e=t.trigger.getBoundingClientRect(),o=190,i=t.panel.offsetHeight||216,n=8,r=Math.max(n,Math.min(e.left,window.innerWidth-o-n)),s=e.bottom+6,l=s+i>window.innerHeight-n?Math.max(n,e.top-i-6):s;t.panel.style.left=`${r}px`,t.panel.style.top=`${l}px`}function Ul(t){const e=n=>{const r=Wl(n);r.includes(t.trigger)||r.includes(t.panel)||Nt()},o=n=>{n.key==="Escape"&&Nt()},i=()=>Nt();document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",o),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),t.root.addEventListener("scroll",i,!0),t.teardowns.push(()=>document.removeEventListener("pointerdown",e,!0),()=>document.removeEventListener("keydown",o),()=>window.removeEventListener("scroll",i,!0),()=>window.removeEventListener("resize",i),()=>t.root.removeEventListener("scroll",i,!0))}function Wl(t){const e=typeof t.composedPath=="function"?t.composedPath():[];return e.length?e:[t.target]}function Gl(t){return a("div",{class:"preset-color-panel",role:"dialog","aria-label":"颜色选择",style:{position:"fixed"},onPointerdown:e=>e.stopPropagation()},[a("div",{class:"picker-preview"},[a("span",{class:"picker-current"}),a("input",{class:"picker-hex",type:"text",maxlength:7,spellcheck:"false","aria-label":"颜色值",onInput:e=>Kl(t,e.target.value)})]),a("div",{class:"picker-area","aria-label":"自定义颜色",tabindex:0,onPointerdown:e=>Vl(t,e),onKeydown:e=>jl(t,e)},[a("span",{class:"picker-handle"})]),a("input",{class:"picker-hue",type:"range",min:0,max:360,step:1,"aria-label":"色相",onInput:e=>Yl(t,Number(e.target.value)),onChange:()=>Ni(t)}),a("div",{class:"picker-heading"},[a("span",{text:"常用颜色"}),t.clearable?a("button",{type:"button",class:"picker-clear",title:"清除选中的颜色",onClick:()=>uo(t,void 0)},[a("svg",{viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"},[a("path",{d:"M3 3l10 10M13 3L3 13",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round",fill:"none"})]),"清除"]):""].filter(Boolean)),a("div",{class:"preset-color-grid"},c.PRESET_COLORS.map(e=>a("button",{type:"button",class:"preset-color-item",style:{background:e},title:e,"aria-label":e,onClick:()=>ql(t,e)})))])}function zi(t){return Br(Ol(t.hue,t.saturation,t.value_))}function mo(t){const e=zi(t);t.hex.value!==t.hexText&&(t.hex.value=t.hexText),t.current.className=t.model?"picker-current":"picker-current is-empty",t.model?t.current.style.background=e:t.current.style.removeProperty("background"),t.area.style.setProperty("--picker-hue",`${Math.round(t.hue)}deg`),t.handle.style.left=`${t.saturation*100}%`,t.handle.style.top=`${(1-t.value_)*100}%`,t.handle.style.background=e;const o=String(Math.round(t.hue));t.hueRange.value!==o&&(t.hueRange.value=o),t.clearBtn&&(t.clearBtn.disabled=!t.model);for(const i of t.items)i.el.className=t.model&&i.color.toLowerCase()===t.model.toLowerCase()?"preset-color-item active":"preset-color-item"}function Oi(t,e){const o=Fi(e);if(!o)return!1;const i=zl(o.r,o.g,o.b);return t.hue=i.h,t.saturation=i.s,t.value_=i.v,t.hexText=Li(e).toUpperCase(),!0}function At(t,e,o,i){t.hue=Nl(e),t.saturation=Ht(o),t.value_=Ht(i),t.hexText=zi(t).toUpperCase(),mo(t)}function Ni(t){const e=zi(t);t.model=e,mo(t),t.onChange(e)}function uo(t,e){t.model=e,e||(t.hexText=""),mo(t),t.onChange(e)}function ql(t,e){Oi(t,e),uo(t,e)}function Kl(t,e){const o=e.trim();if(!o){t.clearable&&uo(t,void 0);return}Fi(o)&&(Oi(t,o),uo(t,Li(o)))}function Vl(t,e){t.dragging=!0,Bn(t,e);const o=n=>{t.dragging&&Bn(t,n)},i=()=>{t.dragging&&(t.dragging=!1,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),Ni(t))};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)}function Bn(t,e){const o=t.area.getBoundingClientRect();if(!o.width||!o.height)return;const i=Ht((e.clientX-o.left)/o.width),n=Ht(1-(e.clientY-o.top)/o.height);At(t,t.hue,i,n)}function jl(t,e){const o=e.shiftKey?.1:.02;let i=!0;e.key==="ArrowLeft"?At(t,t.hue,t.saturation-o,t.value_):e.key==="ArrowRight"?At(t,t.hue,t.saturation+o,t.value_):e.key==="ArrowUp"?At(t,t.hue,t.saturation,t.value_+o):e.key==="ArrowDown"?At(t,t.hue,t.saturation,t.value_-o):i=!1,i&&(e.preventDefault(),Ni(t))}function Yl(t,e){At(t,e,t.saturation,t.value_)}function oe(t,e,o,i){return a("button",{class:`tb-btn tb-icon${i.on?" on":""}${i.danger?" danger":""}`,type:"button",disabled:!!i.disabled,dataset:{tip:i.tip,...i.test?{test:i.test}:{}},onClick:()=>t.fire(o,i.arg),html:ce(e)})}function ho(t,e,o,i){const n=t.state.openDd===e,r=()=>{t.state.openDd=n?null:e,t.repaint()};return a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${n?" on":""}`,disabled:!!o.disabled,dataset:{test:o.testId??e,tip:o.tip},onClick:r,html:`${o.icon?ce(o.icon):""}${o.text?`<span class="${o.textClass??"tb-btn-text"}">${o.text}</span>`:""}${ce("ChevronDown",12,`tb-dd-arrow${n?" up":""}`)}`}),n?a("div",{class:`tb-dd-panel${o.panelClass?` ${o.panelClass}`:""}`},i):""].filter(Boolean))}function O(t){const e=t.step??1,o=String(e),i=o.indexOf("."),n=i===-1?0:o.length-i-1,r=m=>Number.isFinite(m)?Number(m.toFixed(n)):0,s=m=>{let g=r(m);return t.min!==void 0&&g<t.min&&(g=t.min),t.max!==void 0&&g>t.max&&(g=t.max),g},l=t.value===void 0||t.value===null||!Number.isFinite(t.value)?void 0:r(t.value),p=l??t.min??0,u=m=>{m!==l&&t.onCommit(m)},h=a("input",{class:"pd-input pd-step-input",type:"number",value:l===void 0?"":String(l),min:t.min,max:t.max,step:e,placeholder:t.placeholder,disabled:!!t.disabled,onChange:m=>{const g=m.target,T=(g.value??"").trim();if(T===""){l!==void 0&&(g.value=String(l));return}const b=Number(T);if(!Number.isFinite(b)){g.value=l===void 0?"":String(l);return}const k=s(b);g.value=String(k),u(k)}});return a("div",{class:"pd-stepper"},[a("button",{type:"button",class:"pd-step-btn pd-step-minus",disabled:!!t.disabled||p<=(t.min??-1/0),title:"减小","aria-label":"减小",text:"−",onClick:()=>u(s(p-e))}),h,a("button",{type:"button",class:"pd-step-btn pd-step-plus",disabled:!!t.disabled||p>=(t.max??1/0),title:"增大","aria-label":"增大",text:"+",onClick:()=>u(s(p+e))})])}function W(t,e,o,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),i??""]),e,o?a("p",{class:"pd-hint",text:o}):""].filter(Boolean))}const xi=t=>a("button",{class:"pd-help",type:"button","data-tip":t,"aria-label":"字段说明"});function be(t,e,o,i){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[t,xi(o)]),i??""]),e])}function bt(t){const e=t.base?.[t.propKey],o=t.target?.[t.propKey]!==e,i=t.force===!0||o,n=t.tipOverride??(t.tipValue===void 0?"恢复默认值":`恢复默认值(${t.tipValue}${t.tipUnit?" "+t.tipUnit:""})`),r=t.force?`${n}(应用到全部选中格)`:n;return a("button",{type:"button",class:`pd-reset-btn${o&&!t.force?" is-dirty":""}`,"data-tip":r,"aria-label":r,html:ce("RotateCcw",13),onClick:()=>{i&&(t.write?t.write(e):t.target[t.propKey]=e,t.onReset?.())}})}const He=t=>a("h3",{class:"pd-divider",text:t});function Se(t,e,o="颜色选择",i){return $l({value:t,title:o,triggerClass:i,onChange:n=>e(n)})}function rt(t,e,o,i,n=!1){return a("div",{class:`pd-radio-group${n?" pd-radio-group--2col":""}`,role:"radiogroup"},e.map(r=>a("label",{class:"pd-radio"},[a("input",{type:"radio",name:t,value:r.value,checked:o===r.value,onChange:()=>i(r.value)}),a("span",{text:r.label})])))}function Hr(t,e,o,i={}){const n=document.createElement("select");n.className=i.className??"pd-select",i.width&&(n.style.width=i.width);for(const r of e){const s=document.createElement("option");s.value=r.value,s.textContent=r.label,r.disabled&&(s.disabled=!0),n.appendChild(s)}return n.value=t,e.some(r=>r.value===t)||(n.selectedIndex=-1),n.addEventListener("change",()=>o(n.value)),n}function Xl(t){const e=window.innerHeight;for(let o=t.parentElement;o&&o!==document.body;o=o.parentElement){const i=getComputedStyle(o).overflowY;if(i==="auto"||i==="scroll"||i==="hidden"||i==="clip"){const n=o.getBoundingClientRect();return{top:Math.max(0,n.top),bottom:Math.min(e,n.bottom)}}}return{top:0,bottom:e}}function bo(t){const e=_.normalizeFontCatalog(t.fonts),o=t.placeholder??"默认",i=`font-select-list-${t.id}`,n=F=>{const z=F?.trim();return z?_.findFontOption(e,z)?.label??z:""},r=F=>{const z=_.normalizeFontQuery(F);return e.find(H=>H.label&&_.normalizeFontQuery(H.label)===z)?.family??F},s=()=>{const F=t.value?.trim();return F?_.findFontOption(e,F)?"":F:""},l=F=>{const z=(t.value??"").trim(),ee=(te,ke,x,Z)=>({kind:te,key:ke,label:x,value:Z,selected:(Z??"")===z}),H=F.trim();if(!H){const te=[ee("clear","__clear__",o)],ke=s();ke&&te.push(ee("unknown","__unknown__",`${ke}(未知)`,ke));for(const x of e)te.push(ee("font",x.family,_.fontOptionLabel(x),x.family));return te}const pe=_.filterFontOptions(e,H).map(te=>ee("font",te.family,_.fontOptionLabel(te),te.family));if(!pe.length){const te=r(H);pe.push(ee("free","__free__",`使用「${te}」`,te))}return pe},p=document.createElement("div");p.className="font-select";const u=document.createElement("input");u.className="pd-input font-select-input",u.type="text",u.setAttribute("role","combobox"),u.setAttribute("aria-autocomplete","list"),u.setAttribute("aria-controls",i),u.autocomplete="off",u.placeholder=o,u.disabled=!!t.disabled,u.value=n(t.value);const h=document.createElement("ul");h.id=i,h.className="font-select-list",h.setAttribute("role","listbox");const m=t.state.fontOpen?.id===t.id?t.state.fontOpen:null,g={open:!!m&&!t.disabled,query:m?.query??"",highlighted:m?.highlighted??-1};g.open&&(u.value=g.query);const T=()=>{t.state.fontOpen=g.open?{id:t.id,query:g.query,highlighted:g.highlighted}:null};T();const b=()=>{const F=(t.value??"").trim();return l(g.query).findIndex(z=>(z.value??"")===F)},k=()=>{const F=u.getBoundingClientRect(),z=Xl(u);h.classList.toggle("is-up",c.resolveOverlayPlacement({triggerTop:F.top,triggerBottom:F.bottom,overlayHeight:h.getBoundingClientRect().height,boundaryTop:z.top,boundaryBottom:z.bottom})==="up")},y=()=>{if(!g.open){h.isConnected&&h.remove(),u.setAttribute("aria-expanded","false"),u.setAttribute("aria-activedescendant","");return}h.isConnected||p.appendChild(h);const F=l(g.query);h.replaceChildren(...F.map((z,ee)=>{const H=document.createElement("li");return H.id=`${i}-${ee}`,H.className="font-select-option"+(ee===g.highlighted?" is-active":"")+(z.kind==="unknown"||z.kind==="free"?" is-muted":""),H.setAttribute("role","option"),H.setAttribute("aria-selected",String(z.selected)),H.textContent=z.label,H.addEventListener("mousedown",pe=>{pe.preventDefault(),K(z)}),H})),u.setAttribute("aria-expanded","true"),u.setAttribute("aria-activedescendant",g.highlighted>=0?`${i}-${g.highlighted}`:""),k()},C=()=>{g.open||t.disabled||(g.open=!0,g.query="",g.highlighted=b(),T(),y())},D=()=>{g.open||C()},P=()=>{g.open=!0,g.query=u.value,g.highlighted=l(g.query).length?0:-1,T(),y()},A=F=>{if(!g.open){C();return}const z=l(g.query).length-1;if(z<0)return;g.highlighted=Math.min(Math.max(g.highlighted+F,0),z),T(),y(),h.children[g.highlighted]?.scrollIntoView?.({block:"nearest"})},L=()=>{if(!g.open)return;const F=l(g.query)[g.highlighted];if(F){K(F);return}const z=g.query.trim();if(z){const ee=r(z);K({value:ee})}},K=F=>{g.open=!1,g.query="",g.highlighted=-1,T(),u.value=n(F.value),y(),t.onChange(F.value)},N=()=>{g.open&&(g.open=!1,g.query="",g.highlighted=-1,T(),u.value=n(t.value),y())};return u.addEventListener("focus",C),u.addEventListener("click",D),u.addEventListener("input",P),u.addEventListener("blur",N),u.addEventListener("keydown",F=>{const z=F;z.key==="ArrowDown"?(z.preventDefault(),A(1)):z.key==="ArrowUp"?(z.preventDefault(),A(-1)):z.key==="Enter"?(z.preventDefault(),L()):z.key==="Escape"&&(z.preventDefault(),N())}),p.append(u),y(),g.open&&(u.focus(),u.setSelectionRange(g.query.length,g.query.length)),p}const Zl=[{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"}],Ql={left:"TextAlignStart",center:"TextAlignCenter",right:"TextAlignEnd",justify:"TextAlignJustify"};function ot(t,e,o,i,n={}){return a("button",{type:"button",class:`ft-cell-btn${n.on?" on":""}`,dataset:{test:t,tip:e},disabled:!!n.disabled,onClick:i,html:`<svg viewBox="0 0 18 18" width="18" height="18" aria-hidden="true">${o}</svg>`})}const kt='<rect class="g-faint" x="2.5" y="2.5" width="13" height="13" />',Hn='<rect class="g-solid" x="2.5" y="2.5" width="13" height="13" fill="none" />';function Jl(t){const e=t.format;e.syncBorderDraft();const o=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),p=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"},[ot("preset-none","无边框",`${kt}<line class="g-solid" x1="4" y1="14" x2="14" y2="4" />`,()=>e.applyBorderPreset("none")),ot("preset-all","所有边框",`${Hn}<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")),ot("preset-outer","外侧边框",Hn,()=>e.applyBorderPreset("outer")),ot("preset-inner",s?"内部边框":"内部边框(仅表格单元格可用)",`${kt}<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}),ot("edge-top","上边框",`${kt}<line class="g-solid" x1="2" y1="3" x2="16" y2="3" />`,()=>e.applyEdge("top"),{on:e.edgeOn("top")}),ot("edge-bottom","下边框",`${kt}<line class="g-solid" x1="2" y1="15" x2="16" y2="15" />`,()=>e.applyEdge("bottom"),{on:e.edgeOn("bottom")}),ot("edge-left","左边框",`${kt}<line class="g-solid" x1="3" y1="2" x2="3" y2="16" />`,()=>e.applyEdge("left"),{on:e.edgeOn("left")}),ot("edge-right","右边框",`${kt}<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"},Zl.map(g=>a("button",{type:"button",class:`ft-style-btn${e.borderStyle===g.key?" on":""}`,dataset:{test:`style-${g.key}`,tip:e.borderStyle===g.key?`${g.label}(再点一次取消,线型=无)`:g.label},onClick:()=>{e.toggleBorderStyle(g.key),t.repaint()}},[a("span",{class:"ft-style-line",style:{borderTop:g.preview}})]))),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"粗细"}),a("div",{class:"ft-line-width"},[O({value:e.borderWidth,min:.25,max:5,step:.25,placeholder:e.borderMixed.width?"混合":void 0,onCommit:g=>{e.setBorderWidth(g),t.repaint()}})])]),a("div",{class:"ft-border-style-row"},[a("span",{class:"ft-edge-label",text:"颜色"}),Se(e.borderColor,g=>{e.setBorderColor(g),t.repaint()},"边框颜色")]),e.borderMixedAny?a("p",{class:"pd-hint",text:"当前单元格四边规格不一致:留空的项不谎报,点预设/单边时按缺省档(实线 0.75 / #333333)批写"}):""].filter(Boolean))],m=[a("div",{class:"ft-align-panel",dataset:{test:"align-panel"}},[a("div",{class:"ft-align-row"},[["left","左对齐","TextAlignStart"],["center","水平居中","TextAlignCenter"],["right","右对齐","TextAlignEnd"],["justify","两端对齐(撑满行宽,含末行)","TextAlignJustify"]].map(([g,T,b])=>a("button",{type:"button",class:`ft-cell-btn${o.textAlign===g?" on":""}`,dataset:{test:`align-${g}`,tip:T},disabled:i,onClick:()=>e.applyStyle({textAlign:g}),html:ce(b)}))),a("div",{class:"ft-align-row"},[["top","顶端对齐","ArrowUpToLine"],["middle","垂直居中","ChevronsUpDown"],["bottom","底端对齐","ArrowDownToLine"]].map(([g,T,b])=>a("button",{type:"button",class:`ft-cell-btn${o.verticalAlign===g?" on":""}`,dataset:{test:`valign-${g}`,tip:T},disabled:i,onClick:()=>e.applyStyle({verticalAlign:g}),html:ce(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:p},disabled:l,onClick:()=>{e.painterActive?e.cancelPainter():e.pickPainterSource(!1),t.repaint()},onDblclick:()=>{e.pickPainterSource(!0),t.repaint()},html:ce("Paintbrush")})]),a("div",{class:"tb-ou ft-group",dataset:{unit:"font"}},[a("div",{class:"ft-font"},[bo({id:"ft-font",state:t.state,fonts:t.host.fonts,value:typeof o.fontFamily=="string"?o.fontFamily:void 0,placeholder:o.fontFamily===ht?"混合":"默认",disabled:i,onChange:g=>e.applyStyle({fontFamily:g})})]),a("div",{class:"ft-size",dataset:{test:"font-size"}},[O({value:typeof o.fontSize=="number"?o.fontSize:void 0,min:5,max:72,disabled:i,placeholder:o.fontSize===ht?"混合":"默认",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,T,b,k])=>a("button",{type:"button",class:`ft-btn${o[g]===!0?" on":""}`,dataset:{test:g,tip:u(b)},disabled:g==="bold"?i:n,onClick:k,html:ce(T)}))]),a("div",{class:"tb-ou ft-group",dataset:{unit:"color"}},[a("span",{class:`ft-color-btn${i?" dim":""}`,title:`字体颜色${i?"(需选中或混选文本元素)":""}`},[Se(typeof o.color=="string"?o.color:void 0,g=>e.applyStyle({color:g})),a("span",{class:"ft-glyph",text:"A"})]),a("span",{class:`ft-color-btn${r?" dim":""}`,title:"背景色"},[Se(typeof o.backgroundColor=="string"?o.backgroundColor:void 0,g=>e.applyStyle({backgroundColor:g})),a("span",{class:"ft-glyph",html:ce("PaintBucket",14)})])]),a("div",{class:"tb-ou ft-group",dataset:{unit:"align"}},[ho(t,"align",{icon:Ql[String(o.textAlign)]??"TextAlignStart",text:"对齐",textClass:"ft-btn-text",tip:i?"对齐(需选中文本元素或单元格)":"对齐",disabled:i,testId:"align-dd"},m)]),a("div",{class:"tb-ou ft-group",dataset:{unit:"border"}},[ho(t,"border",{icon:"Grid3x3",text:"边框",textClass:"ft-btn-text",tip:r?"边框(需选中元素)":"边框",disabled:r,testId:"border"},h)])])}const ed="1.5.3";fo.filter(t=>t.material).map(t=>({type:t.type,label:t.label,icon:t.icon}));function xo(t,e){return ce(t??"Shapes",e)||ce("Shapes",e)}function td(t){const e=t.state;if(e.leftCollapsed)return a("div",{class:"left-panel collapsed"},[a("div",{class:"left-collapsed"},[Un("ChevronsRight","展开素材台",()=>{e.leftCollapsed=!1,t.repaint()}),...[["elements","元素","Table2"],["fields","字段","ListTree"],["layers","图层","Layers"]].map(([i,n,r])=>a("button",{type:"button",class:`lc-btn${e.leftTab===i?" on":""}`,title:n,html:xo(r,14),onClick:()=>{e.leftTab=i,e.leftCollapsed=!1,t.repaint()}}))])]);const o=(i,n,r="")=>a("div",{class:`pd-tab-pane${r?` ${r}`:""}`,role:"tabpanel",dataset:{pane:`left:${i}`},style:e.leftTab===i?"":{display:"none"}},n);return a("div",{class:"left-panel"},[a("div",{class:"left-head"},[a("span",{class:"left-title",text:"素材台"}),Un("ChevronsLeft","收起素材台",()=>{e.leftCollapsed=!0,t.repaint()})]),a("div",{class:"pd-tabs left-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...[["elements","元素"],["fields","字段"],["layers","图层"]].map(([i,n])=>a("button",{type:"button",class:`pd-tab${e.leftTab===i?" active":""}`,text:n,onClick:()=>{e.leftTab=i,t.repaint()}}))]),o("elements",id(),"material-grid"),o("fields",[nd(t)]),o("layers",[rd(t)])])])}function Un(t,e,o){return a("button",{type:"button",class:"collapse-btn",title:e,html:xo(t,14),onClick:o})}function od(t,e,o){return a("div",{class:`material-card${c.isWideMaterialLabel(e)?" material-card--wide":""}`,draggable:!0,dataset:{test:`material-${t}`},onDragstart:i=>{const n=i.dataTransfer;n?.setData("elementType",t),n&&(n.effectAllowed="all")}},[a("span",{class:"material-icon","data-icon":o,html:xo(o,14)}),a("span",{class:"material-label",text:e})])}function id(){const t=[];let e;for(const o of hr()){const i=o.group;i&&i!==e&&t.push(a("div",{class:"material-group-title",text:i})),i&&(e=i),t.push(od(o.type,o.label,o.icon))}return[a("div",{class:"panel-title",text:"拖拽元素到画布"}),...t]}function nd(t){const e=t.state,o=c.groupFields(t.store.fields),i=(e.fieldSearch??"").trim().toLowerCase(),n=i?o.map(r=>({...r,fields:r.fields.filter(s=>`${s.fieldLabel}${s.fieldKey}`.toLowerCase().includes(i))})).filter(r=>r.fields.length):o;return a("div",{class:"field-tree-panel"},[a("div",{class:"panel-title",text:"业务字段"}),a("input",{class:"pd-input search-input",type:"search",placeholder:"搜索字段...","aria-label":"搜索字段",value:e.fieldSearch??"",onInput:r=>{e.fieldSearch=r.target.value},onChange:()=>t.repaint()}),a("div",{class:"tree-container"},n.flatMap(r=>{const 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),t.repaint()}},[a("span",{class:"expand-icon",text:s?"▶":"▼"}),a("span",{class:"node-icon",text:r.isList?"📋":"📁"}),a("span",{class:"group-label",text:r.label,"data-tip":r.label})]):"",p=s?[]:r.fields.map(u=>a("div",{class:"field-row",draggable:!0,"data-tip":`${u.fieldLabel} (${u.fieldKey}) · 单击复制字段名 · 拖动中按住 Ctrl(Mac 为 ⌘)切换为插入字段名`,style:{paddingLeft:`${r.key?22:8}px`},onDragstart:h=>{const m=h.dataTransfer;m?.setData("fieldKey",u.fieldKey),m&&(m.effectAllowed="all")},onClick:()=>{c.copyTextToClipboard(u.fieldLabel||u.fieldKey).then(h=>{h&&(e.copiedFieldKey=u.fieldKey,t.repaint(),setTimeout(()=>{e.copiedFieldKey===u.fieldKey&&(e.copiedFieldKey="",t.repaint())},1200))})}},[a("span",{class:"node-icon",text:"📄"}),a("span",{class:"node-meta"},[a("span",{class:"node-label",text:u.fieldLabel}),a("span",{class:"node-key",text:`(${u.fieldKey})`})]),e.copiedFieldKey===u.fieldKey?a("span",{class:"copy-hint",text:"已复制"}):""].filter(Boolean)));return[l,a("div",{},p.filter(Boolean))].filter(Boolean)})),n.length===0?a("p",{class:"pd-empty",text:"暂无字段"}):""].filter(Boolean))}function rd(t){const e=t.store,o=[...e.elements].sort((l,p)=>(p.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:"图层"}),...o.map(l=>{const p=mr(l.printElementType.type);return a("div",{class:`layer-item${e.selectedIds.has(l.id)?" active":""}`,onClick:u=>e.selectElement(l.id,u.ctrlKey||u.metaKey)},[a("span",{class:"layer-icon","data-icon":p??"Shapes",html:xo(p,12)}),a("span",{class:"layer-name",text:l.options.title||l.printElementType.title||l.printElementType.type}),s(l)?a("span",{class:"layer-zone",text:s(l)}):"",a("span",{class:"layer-zindex",text:`z:${l.options.zIndex??0}`})].filter(Boolean))}),o.length?a("div",{class:"layer-actions"},[...[["top","置顶","ArrowUpToLine"],["up","上移","ArrowUp"],["down","下移","ArrowDown"],["bottom","置底","ArrowDownToLine"]].map(([l,p,u])=>a("button",{type:"button",class:"pd-button small",title:p,html:ce(u,14),onClick:()=>t.fire("move-layer",l)}))]):"",n||r?a("div",{class:"layer-actions"},[n?a("button",{type:"button",class:"pd-button small",title:"组合 (Ctrl+G)",html:ce("Group",14),onClick:()=>t.fire("group")}):"",r?a("button",{type:"button",class:"pd-button small",title:"取消组合 (Ctrl+Shift+G)",html:ce("Ungroup",14),onClick:()=>t.fire("ungroup")}):""].filter(Boolean)):""].filter(Boolean))}function ad(t){const e=t.store,o=t.state,i=e.pages.length>1,n=e.pages[e.activePageIndex]?.name||`页面 ${e.activePageIndex+1}`,r=e.tilingEnabled;return a("div",{class:"page-tabs"},[a("div",{class:"page-tabs-list"},e.pages.map((l,p)=>o.renamingPage===p?a("input",{class:"page-tab-rename",dataset:{test:"page-rename-input"},value:o.renameText??"",onInput:u=>{o.renameText=u.target.value},onBlur:()=>s(),onKeydown:u=>{const h=u;if(h.key==="Enter"){s();return}h.key==="Escape"&&(o.renamingPage=null,t.repaint())}}):a("button",{type:"button",class:`page-tab${p===e.activePageIndex?" active":""}`,dataset:{tip:l.name?`${l.name}(双击重命名)`:"双击重命名"},text:l.name||`页面 ${p+1}`,onClick:()=>e.switchPage(p),onDblclick:()=>{o.renamingPage=p,o.renameText=l.name??"",t.repaint()}}))),a("div",{class:"page-tabs-actions"},[a("button",{type:"button",dataset:{test:"add-page",tip:r?"拼版模板仅允许一个设计页面":"新增页面(在当前页后追加空白页)"},disabled:r,text:"+",onClick:()=>t.fire("add-page")}),a("button",{type:"button",dataset:{test:"duplicate-page",tip:r?"拼版模板仅允许一个设计页面":`复制当前页「${n}」`},disabled:r,text:"⧉",onClick:()=>t.fire("duplicate-page")}),a("button",{type:"button",dataset:{test:"delete-page",tip:i?`删除当前页「${n}」`:"仅多页面模板可删除页面"},disabled:!i,text:"✕",onClick:()=>t.fire("delete-page")}),a("button",{type:"button",dataset:{test:"move-left",tip:`前移「${n}」`},disabled:e.activePageIndex<=0,text:"←",onClick:()=>t.fire("move-page",-1)}),a("button",{type:"button",dataset:{test:"move-right",tip:`后移「${n}」`},disabled:e.activePageIndex>=e.pages.length-1,text:"→",onClick:()=>t.fire("move-page",1)})])]);function s(){const l=(o.renameText??"").trim();o.renamingPage!==null&&l&&e.renamePage(o.renamingPage,l),o.renamingPage=null,t.repaint()}}function sd(t){const e=t.store,o=e.templateData,i=c.getPaperDimensions(o),n=o.orientation==="landscape"?"横向":"纵向",r=c.PAPER_PRESETS[o.paperSize]?.label??o.paperSize,s=o.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-item status-version",text:`v${ed}`}),a("span",{class:"status-item status-paper",text:l})])}const ld=Object.keys(c.PAPER_PRESETS).filter(t=>t!=="CUSTOM"&&!c.PAPER_PRESETS[t]?.continuous);function dd(t){const e=document.createElement("label");e.className="pd-button small upload-label";const o=document.createTextNode("上传背景图"),i=document.createElement("input");i.className="visually-hidden",i.type="file",i.accept="image/*",e.append(o,i);const n=r=>{e.className=`pd-button small upload-label${r?" disabled":""}`,i.disabled=r};return i.addEventListener("change",async()=>{const r=i.files?.[0];if(!r)return;if(!r.type.startsWith("image/")){alert("仅支持上传图片文件"),i.value="";return}const s=t.host.uploadDesignBackground;if(!s){alert("设计背景上传能力未配置"),i.value="";return}n(!0),o.textContent="上传中...";try{const l=await s(r);l?t.store.updateTemplateData({designBackground:{src:l,rotation:0}}):alert("设计背景上传失败")}catch(l){alert(l instanceof Error?l.message:"设计背景上传失败")}finally{o.textContent="上传背景图",n(!t.host.uploadDesignBackground),i.value=""}}),t.host.uploadDesignBackground||n(!0),e}function cd(t){const o=t.store.templateData.designBackground,i=o?.rotation??0;return a("div",{class:"design-background-config"},[He("设计背景"),a("p",{class:"design-background-tip",text:"仅设计器显示,用于套打定位,不会出现在预览和打印中"}),o?.src?[a("div",{class:"design-background-path",title:o.src,text:o.src}),a("div",{class:"design-background-actions"},[a("button",{type:"button",class:"pd-button small rotate-btn",text:`旋转(${(i+90)%360}°)`,onClick:()=>t.store.updateTemplateData({designBackground:{...o,rotation:(i+90)%360}})}),a("button",{type:"button",class:"pd-button small remove-btn",text:"移除",onClick:()=>t.store.updateTemplateData({designBackground:void 0})})])]:dd(t)].flat())}function pd(t){const e=t.store,o=e.templateData,i=o.tiling,n={..._.TILE_DEFAULTS,...i??{},enabled:i?.enabled??!1,sheetMargin:{..._.TILE_DEFAULTS.sheetMargin,...i?.sheetMargin??{}}},r=c.isContinuousPaperSize(o.paperSize),s=b=>e.updateTemplateData({tiling:{...n,...b}}),l=b=>bt({target:n,base:_.TILE_DEFAULTS,propKey:b,write:()=>s({[b]:_.TILE_DEFAULTS[b]})}),p=b=>bt({target:n.sheetMargin,base:_.TILE_DEFAULTS.sheetMargin,propKey:b,write:()=>u(b,_.TILE_DEFAULTS.sheetMargin[b])}),u=(b,k)=>s({sheetMargin:{...n.sheetMargin,[b]:k??0}}),h={...o,tiling:n},m=_.validateTiling(h),g=Math.max(_.computeMaxColumns(h),1);let T="";if(!m.length)try{const b=_.computeTileLayout(h),k=_.resolveSheetMm(h),y=n.sheetPaperSize==="CUSTOM"?"自定义":n.sheetPaperSize??"A4",C=n.sheetPaperSize==="CUSTOM"?"":n.sheetOrientation==="landscape"?" 横向":" 纵向";T=`目标纸 ${y}${C} ${k.width}×${k.height}mm · ${b.columns} 列 × ${b.rows} 行 = 每张 ${b.perSheet} 格 · 每格 ${b.tile.width}×${b.tile.height}mm`}catch{T=""}return a("div",{class:"tiling-config",dataset:{test:"tiling-config"}},[He("拼版打印"),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({..._.TILE_DEFAULTS,columns:Math.min(_.TILE_DEFAULTS.columns,Math.max(g,1))})}}),a("span",{text:"启用拼版"})]),r?a("p",{class:"pd-hint tiling-error",text:"连续纸不支持拼版"}):""].filter(Boolean)),n.enabled&&!r?[W("目标纸张",a("select",{class:"pd-select",style:{width:"100%"},onChange:b=>{const k=b.target.value;if(k!=="CUSTOM"){s({sheetPaperSize:k});return}const y=_.resolveSheetMm(h);s({sheetPaperSize:"CUSTOM",sheetCustomWidth:n.sheetCustomWidth??y.width,sheetCustomHeight:n.sheetCustomHeight??y.height})}},[...ld.map(b=>a("option",{value:b,text:c.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"?W("目标纸宽高 (mm)",a("div",{class:"custom-size-grid"},[O({value:Number(n.sheetCustomWidth??0),min:25,max:2e3,onCommit:b=>s({sheetCustomWidth:b})}),a("span",{class:"custom-size-x",text:"×"}),O({value:Number(n.sheetCustomHeight??0),min:25,max:2e3,onCommit:b=>s({sheetCustomHeight:b})})])):W("目标纸方向",rt("tiling-ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],n.sheetOrientation==="landscape"?"landscape":"portrait",b=>s({sheetOrientation:b})),void 0,l("sheetOrientation")),He("拼版留白 (mm)"),a("div",{class:"margin-grid"},[W("上",O({value:n.sheetMargin.top??0,min:0,max:100,onCommit:b=>u("top",b)}),void 0,p("top")),W("下",O({value:n.sheetMargin.bottom??0,min:0,max:100,onCommit:b=>u("bottom",b)}),void 0,p("bottom")),W("左",O({value:n.sheetMargin.left??0,min:0,max:100,onCommit:b=>u("left",b)}),void 0,p("left")),W("右",O({value:n.sheetMargin.right??0,min:0,max:100,onCommit:b=>u("right",b)}),void 0,p("right"))]),He("格间距与列数"),W("横向间距",O({value:n.gapX??0,min:0,max:50,onCommit:b=>s({gapX:b??0})}),void 0,l("gapX")),W("纵向间距",O({value:n.gapY??0,min:0,max:50,onCommit:b=>s({gapY:b??0})}),void 0,l("gapY")),W("列数",O({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&&T?a("p",{class:"pd-hint tiling-summary",text:T}):""]:""].flat().filter(Boolean))}const ud=new Set(c.PROPERTY_REGISTRY.map(t=>t.group)),hd={"table-settings":"content"},Wn=new Map;function $i(t){const e=t??"";let o=Wn.get(e);if(!o){const{groups:i,itemKeys:n}=c.searchProperties(e);o={groups:i,keys:n,searching:!!e.trim()},Wn.set(e,o)}return o}function Bi(t){const e=hd[t]??t;return ud.has(e)?e:""}function fd(t,e){const o=$i(t.state.propSearch);if(!o.searching)return!0;const i=Bi(e);return!i||o.groups.includes(i)}function gd(t,e){const o=$i(t.state.propSearch);return!o.searching||o.keys.has(e)}function Ur(t,e){const o=t.props.style??{};return t.props.style={...o,display:e?"":"none"},t}function M(t,e,o){const i=o.props.dataset??{};return o.props.dataset={...i,propKey:e},Ur(o,gd(t,e))}function md(t,e,o){const i=Bi(e);if(!i)return o;const n=o.props.dataset??{};return o.props.dataset={...n,propGroup:i},Ur(o,fd(t,e))}function Wr(t,e){const o=$i(e);for(const i of Array.from(t.querySelectorAll("[data-prop-group]"))){const n=Bi(i.dataset.propGroup??"");i.style.display=!o.searching||!n||o.groups.includes(n)?"":"none"}for(const i of Array.from(t.querySelectorAll("[data-prop-key]")))i.style.display=!o.searching||o.keys.has(i.dataset.propKey??"")?"":"none"}function bd(t){return a("div",{class:"property-search"},[a("input",{class:"pd-input",type:"search",placeholder:"搜索属性...","aria-label":"搜索属性",value:t.state.propSearch??"",onInput:e=>{const o=e.target,i=o.value;t.state.propSearch=i,Wr(o.getRootNode(),i)}})])}const xd={Document:"≡",Brush:"◧",Setting:"⚙"};function vd(t,e){try{const o=window.localStorage.getItem(`property-group-${t}`);return o===null?e:o==="true"}catch{return e}}function yd(t,e){try{window.localStorage.setItem(`property-group-${t}`,String(e))}catch{}}function we(t,e,o,i,n,r=!0,s=[]){const l=vd(e,r);return md(t,e,a("div",{class:`property-group${l?" is-expanded":""}`},[a("div",{class:"group-header",onClick:()=>{yd(e,!l),t.repaint()}},[a("span",{class:"group-icon",text:xd[i]||"•"}),a("span",{class:"group-title",text:o}),...s,a("span",{class:"expand-icon",text:l?"▾":"▸"})]),a("div",{class:"group-content",style:l?"":{display:"none"}},n.filter(Boolean))]))}function vo(t){return a("form",{class:"pd-form",onSubmit:e=>e.preventDefault()},t.filter(Boolean))}function Gr(t){return t.split(".").flatMap(e=>{const o=e.match(/^([^\[]+)((?:\[\d+\])*)$/);if(!o)return[e];const i=o[1],n=[...o[2].matchAll(/\[(\d+)\]/g)].map(r=>Number(r[1]));return[i,...n]})}function Gn(t,e){return Gr(e).reduce((n,r)=>n==null?"":n[r],t)??""}function Hi(t,e,o,i){const n=Gr(o),r=n.pop(),s=n.reduce((l,p)=>((l[p]===void 0||l[p]===null)&&(l[p]={}),l[p]),e);s[r]=i||void 0,t.recordHistory(),t.emit()}function wd(t,e){const o=t.store;if(e.printElementType.type==="table"&&o.tableSelection?.elementId===e.id){const{r1:i,c1:n}=o.tableSelection,r=(e.options.tableRows??[])[i];if(r)return c.getTableCellBindings(r.type,i,n,e.options.fields?.[0]?.dataSource)}return c.getElementBindings(e)}function Ed(t,e){const o=document.createElement("label");o.className="pd-button small upload-label",ve(a("svg",{class:"pd-icon",viewBox:"0 0 24 24","aria-hidden":"true"},[a("path",{fill:"currentColor",d:"M12 3l4 4h-3v7h-2V7H8zm-7 12h14v5H5Z"})]),o);const i=document.createTextNode("上传图片"),n=document.createElement("input");n.className="visually-hidden",n.type="file",n.accept="image/*",o.append(i,n);const r=p=>{o.className=`pd-button small upload-label${p?" disabled":""}`,n.disabled=p};n.addEventListener("change",async()=>{const p=n.files?.[0];if(!p)return;if(!p.type.startsWith("image/")){alert("仅支持上传图片文件"),n.value="";return}const u=t.host.uploadImage;if(!u){alert("图片上传能力未配置"),n.value="";return}r(!0),i.textContent="上传中...";try{const h=await u(p);h?Hi(t.store,e,"options.src",h):alert("图片上传失败")}catch(h){alert(h instanceof Error?h.message:"图片上传失败")}finally{i.textContent="上传图片",r(!t.host.uploadImage),n.value=""}}),t.host.uploadImage||r(!0);const s=document.createElement("div");s.className="image-content-upload";const l=document.createElement("p");return l.className="upload-tip",l.textContent="支持 jpg/png/gif/bmp/webp/svg 等图片,上传后填入相对路径",s.append(o,l),s}function Td(t,e){const o=i=>t.fire("open-expression",{elementId:e.id,targetPath:i.targetPath,value:Gn(e,i.targetPath)});return we(t,"binding","内容","Document",[...wd(t,e).map(i=>W(i.label,a("input",{class:"pd-input",type:"text",value:Gn(e,i.targetPath),placeholder:i.placeholder||"输入内容,支持 {字段} 表达式",onChange:n=>Hi(t.store,e,i.targetPath,n.target.value),onDblclick:()=>o(i)}))),e.printElementType.type==="image"?Ed(t,e):""].filter(Boolean))}const Lt=new Map;function oo(t){return`${Math.round(t*1e4)/1e4}%`}function qr(t,e){const o=c.parseCropAnchor(e.value),i=o.kind==="custom",n=o.kind==="axes"?o.x:50,r=o.kind==="axes"?o.y:50,s=c.resolveCropPreview(e.src),l=Lt.get(s.src),p={widthMm:e.widthMm,heightMm:e.heightMm,naturalWidth:l?.width,naturalHeight:l?.height,fit:e.fit,scalePct:e.scale},u=c.resolveCropTravel(p),h=c.cropWindow(p,n,r),m=document.createElement("select");m.className="pd-select",m.style.width="100%";for(const k of c.cropPresetOptions(u,n,r)){const y=document.createElement("option");y.value=k.value,y.textContent=k.label,m.appendChild(y)}if(i){const k=document.createElement("option");k.value="custom",k.textContent="自定义(保留原值)",m.appendChild(k)}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[k,y]=m.value.split(",").map(Number);e.onCommit(c.buildCropAnchor(k,y))});const g=c.propertyTip(e.fieldKey),T=[a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[e.label,xi(g)]),e.resetAnchor??""].filter(Boolean)),m])];T.push(a("div",{class:"pd-field",dataset:{field:"ap-img-fit-scale"}},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t"},[c.CROP_SCALE_LABEL,xi(c.propertyTip("ap-img-fit-scale"))]),e.resetScale??""].filter(Boolean)),O({value:e.scale,min:c.CROP_SCALE_MIN,max:c.CROP_SCALE_MAX,step:5,placeholder:"默认 100",onCommit:k=>e.onScaleCommit(k>c.CROP_SCALE_MIN?k:void 0)})]));for(const k of c.cropAxisFields(u,n,r))T.push(a("div",{class:"pd-field",dataset:{field:e.fieldKey}},[a("span",{class:"pd-label",text:k.label}),O({value:k.value,min:0,max:100,step:1,onCommit:y=>e.onCommit(c.buildCropAnchor(k.name==="horizontal"?y:n,k.name==="vertical"?y:r))})]));const b=c.cropAxisNote(u,i);return b&&T.push(a("p",{class:"pd-crop-note",text:b})),s.isSample&&T.push(a("p",{class:"pd-crop-note",text:c.CROP_SAMPLE_NOTE})),T.push(a("div",{class:"pd-crop-preview"},[a("img",{class:"pd-crop-thumb",src:s.src,alt:s.isSample?"示例图":"原图",onLoad:k=>{const y=k.target;if(!(y.naturalWidth>0&&y.naturalHeight>0))return;const C=Lt.get(s.src);C&&C.width===y.naturalWidth&&C.height===y.naturalHeight||(Lt.set(s.src,{width:y.naturalWidth,height:y.naturalHeight}),t.repaint())},onError:()=>{Lt.has(s.src)&&(Lt.delete(s.src),t.repaint())}}),h?a("div",{class:"pd-crop-win",style:{left:oo(h.leftPct),top:oo(h.topPct),width:oo(h.widthPct),height:oo(h.heightPct)}}):""])),a("div",{class:e.containerClass??"pd-crop-anchor"},T)}const ut=t=>Number(t??0),vi=t=>t||void 0;function mt(t,e,o,i,n,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label",...i?{title:i}:{}},[a("span",{class:"pd-label-t",text:t}),n??""].filter(Boolean)),a("input",{class:"pd-switch",type:"checkbox",checked:e,...r?{disabled:!0}:{},onChange:s=>o(s.target.checked)})])}function Kr(t,e,o,i,n=!1,r){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),""].filter(Boolean)),a("select",{class:"pd-select",...n?{style:{width:"100%"}}:{},onChange:s=>i(s.target.value)},o.map(s=>a("option",{value:s.value,text:s.label,selected:s.value===e})))])}function zt(t,e,o,i,n={}){return a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:t}),n.reset??""].filter(Boolean)),Hr(e,o,i,{className:"pd-select",...n.full?{width:"100%"}:{}})])}const Ct=t=>a("p",{class:"pd-hint",text:t}),Sd="多级表头作为一个结构整体重复,勾选后表头区所有行都会在每页顶部重复",kd=[{value:"header",label:"标题行"},{value:"data",label:"数据行"},{value:"subtotal",label:"小计行(每页小计)"},{value:"summary",label:"汇总行"}],Cd=[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],Ad=[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],Dd=[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],Md={value:"__multi__",label:"多选",disabled:!0};function _d(t,e){const o=t.store,i=o.tableSelection,n=e.options.tableRows??[],r=i?n[i.r1]:void 0;if(!i||!r)return we(t,"table-row","行属性","Grid",[]);const s=l=>o.updateElement(e.id,l);return we(t,"table-row","行属性","Grid",[vo([Kr("行类型",r.type,kd,l=>{const p=c.setRowType(n,i.r1,l);if(p){window.alert(p);return}s({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:l=>{r.height=l,s({tableRows:n})}})]),r.type==="header"?mt("表头每页重复",r.repeatOnPage??!1,l=>{c.setHeaderRepeat(n,l),s({tableRows:n})},Sd):""])])}function Rd(t,e){const o=t.store,i=e.options,n=h=>o.updateElement(e.id,h),r=i.tableColWidths??[],s=o.paperSize.width-o.templateData.margins.left-o.templateData.margins.right,l=o.fields.filter(h=>h.fieldType==="list").map(h=>({value:h.fieldKey,label:h.fieldLabel})),p=c.createDefaultOptions("table"),u=h=>bt({target:i,base:p,propKey:h,write:()=>n({[h]:p[h]})});return we(t,"table-settings","表格设置","Grid",[vo([Kr("列表数据源字段",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")]),bo({id:"table-default-font",state:t.state,fonts:t.host.fonts,value:i.tableDefaultFontFamily,placeholder:"默认",onChange:h=>n({tableDefaultFontFamily:h||void 0})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认字号 (pt)"}),u("tableDefaultFontSize")]),O({value:ut(i.tableDefaultFontSize),min:0,max:72,placeholder:"默认",onCommit:h=>n({tableDefaultFontSize:vi(h)})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"默认文字颜色"}),u("tableDefaultColor")]),Se(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:ut(i.tableDefaultPadding),min:0,max:10,step:.5,placeholder:"默认",onCommit:h=>n({tableDefaultPadding:vi(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 T=r.reduce((b,k,y)=>y===m?b:b+k,0);if(T+g>s){const b=Math.max(5,Math.round((s-T)*10)/10);window.alert(`表格总宽不能超过打印范围宽度 ${s}mm,列${m+1} 已调整为 ${b}mm`),r[m]=b}else r[m]=g;n({tableColWidths:r})}})]))])])])}function Pd(t,e){const o=t.store,i=e.options,n=e.printElementType.type==="table",r=l=>o.updateElement(e.id,l),s=[];if(n)s.push(M(t,"pg-enabled",mt("启用分页",i.tablePagination?.enabled??!0,l=>r({tablePagination:{enabled:l}}))));else{const l=i.pagination?.pageable??!0,p=i.pagination?.keepWithNext??!1;s.push(M(t,"pg-pageable",mt("参与分页",l,u=>r({pagination:{pageable:u,keepWithNext:p}})))),s.push(M(t,"pg-keep-with-next",mt("与下元素同页",p,u=>r({pagination:{pageable:l,keepWithNext:u}}))))}return we(t,"pagination","分页配置","Document",[vo(s)],!1)}const ni=new WeakMap,qn=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Id(t,e){const o=t.store,i=o.tableSelection,n=e.options.tableRows??[];if(!i)return we(t,"table-cell","单元格","Menu",[]);const r=c.findMainCell(n,i.r1,i.c1),s=n[r.r]?.cells[r.c];if(!s)return we(t,"table-cell","单元格","Menu",[]);const l=()=>c.collectWritableCells(n,i),p=c.resolveCellGroupMode(n,i),u=p.count,h=p.mode==="multi",m=`${e.id}:${i.r1}:${i.c1}:${i.r2}:${i.c2}`,g=ni.get(o),T=g?.key===m?g:{key:m,border:{},values:{},edges:{}};g?.key!==m&&ni.set(o,T);const b=v=>{ni.set(o,{key:m,border:v.border??T.border,values:v.values??T.values,edges:v.edges??T.edges})},k=(v,U)=>{b({border:{...T.border,[v]:U}}),t.repaint()},y=(v,U)=>{l().forEach(v),h&&U&&b({values:{...T.values,...U}}),o.updateElement(e.id,{tableRows:n})},C=(v,U)=>{y(ge=>{ge[v]=U},{[v]:U})},D=v=>h?T.values[v]:s[v],P=v=>h&&v in T.values,A=h?{width:void 0,style:void 0,color:void 0}:c.resolveCellBorderDisplay(n,i),L=!h&&l().some(v=>!!v.borders&&!!(v.borders.top||v.borders.right||v.borders.bottom||v.borders.left)),K=!h&&!L,N={width:K?0:typeof A.width=="number"?A.width:c.DEFAULT_BORDER.width,style:K?"none":typeof A.style=="string"&&A.style!=="mixed"?A.style:c.DEFAULT_BORDER.style,color:typeof A.color=="string"&&A.color!=="mixed"?A.color:c.DEFAULT_BORDER.color,...T.border},F="__mixed__",z={style:!h&&A.style==="mixed",width:!h&&A.width==="mixed",color:!h&&A.color==="mixed"},ee=z.style&&!("style"in T.border),H=z.width&&!("width"in T.border),pe=z.color&&!("color"in T.border),te=ee||H||pe,ke=ee?F:N.style,x=H?void 0:N.width,Z=pe?void 0:N.color,le=v=>{const U={style:v};v!=="none"&&x===0?U.width=c.DEFAULT_BORDER.width:v==="none"&&!L&&(U.width=0),b({border:{...T.border,...U}}),t.repaint()},De=()=>({...N}),B=h?qn.reduce((v,U)=>(v[U.value]=T.edges[U.value]?"on":"off",v),{}):c.resolveBorderEdgeStates(l().map(v=>v.borders)),Ue=h?"cellType"in T.values?T.values.cellType??"text":c.resolveSharedCellType(n,i):s.cellType??"text",re=Ue==="barcode",ye=Ue==="qrcode",Me=Ue==="image",G=Ue==="text",Ze=re&&!!D("printerDpi"),Wt=c.barcodeBarWidthRecommendText(D("printerDpi"),D("barWidth")),j=h?T.values.textFit:c.resolveCellTextFit(s),yo=h?"cellType"in T.values?T.values.cellType??"text":"":s.cellType||"text",at=v=>h?[Md,...v]:v,Ee=v=>h?"多选":v,Ce=(v,U)=>h?T.values[v]:U,wo=h?D("barcodeType")??"__multi__":s.barcodeType||"CODE128",Eo=h?P("printerDpi")?D("printerDpi")?String(D("printerDpi")):"":"__multi__":s.printerDpi?String(s.printerDpi):"",To=h?D("qrCodeLevel")??"__multi__":s.qrCodeLevel||"M",So=h?D("fit")??"__multi__":s.fit||"contain",Gt=j??"__multi__",Y=c.canMergeReason(n,i);let Qe=!0;for(let v=i.r1;v<=i.r2;v++)if(n[v]?.type!=="data"){Qe=!1;break}const X=Qe?"":"仅数据行(明细行)支持按值合并";let Je=!1;for(let v=i.r1;v<=i.r2&&!Je;v++)for(let U=i.c1;U<=i.c2&&!Je;U++){const ge=n[v]?.cells[U];ge&&!ge.merged&&((ge.rowspan??1)>1||(ge.colspan??1)>1)&&(Je=!0)}const ue=(v,U,ge,Q={},Re)=>a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:v}),Re??""].filter(Boolean)),O({value:U,...Q,onCommit:We=>C(ge,vi(We))})]),st="恢复默认值(跟随表格默认)",V=v=>bt({target:s,base:{},propKey:v,tipOverride:st,force:h,write:()=>C(v,void 0)}),_e=e.options.tableDefaultPadding??1,Mt={width:c.cellFitWidthMm(e.options.tableColWidths??[],r.c,s,_e),height:c.cellFitCapMm(n,r.r,s,_e)};return we(t,"table-cell","单元格","Menu",[vo([h?Ct(`已选 ${u} 格 · 批量设置:不显示单格配置,改动会应用到全部选中格`):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"单元格类型"}),rt("cell-type",[{value:"text",label:"文本"},{value:"barcode",label:"条形码"},{value:"qrcode",label:"二维码"},{value:"image",label:"图片"}],yo,v=>{const U=v==="text"?void 0:v,ge={cellType:v};v!=="barcode"&&Object.assign(ge,{barcodeType:void 0,showBarcodeText:void 0,printerDpi:void 0,barQuietZone:void 0,barHeight:void 0}),v!=="qrcode"&&Object.assign(ge,{qrCodeLevel:void 0,qrQuietZone:void 0}),y(Q=>{Q.cellType=U,v!=="barcode"&&(Q.barcodeType=void 0,Q.showBarcodeText=void 0,Q.printerDpi=void 0,Q.barQuietZone=void 0,Q.barHeight=void 0),v!=="qrcode"&&(Q.qrCodeLevel=void 0,Q.qrQuietZone=void 0)},ge)})]),re?zt("码制",wo,at(Cd),v=>{v!=="__multi__"&&C("barcodeType",v||void 0)}):"",re?mt("显示文本",h?T.values.showBarcodeText===!0:s.showBarcodeText!==!1,v=>C("showBarcodeText",v),void 0,V("showBarcodeText")):"",re?ue("条宽(倍率)",Ce("barWidth",s.barWidth??2),"barWidth",{min:2,max:8,step:.5,placeholder:Ee("")},V("barWidth")):"",re?Ct((Ze?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),单元格放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(Wt?`。${Wt}`:"")):"",re?be("静区 (模块)",O({value:Ce("barQuietZone",s.barQuietZone),min:0,max:20,placeholder:Ee("默认 10"),onCommit:v=>C("barQuietZone",v)}),c.propertyTip("cd-bar-quiet-zone"),V("barQuietZone")):"",re?be("条高 (mm)",O({value:Ce("barHeight",s.barHeight),min:1,max:100,placeholder:Ee("默认 30 模块"),onCommit:v=>C("barHeight",v??void 0)}),c.propertyTip("cd-bar-height"),V("barHeight")):"",re?ue("文本字号(相对条高,条高为 30)",Ce("barFontSize",s.barFontSize??10),"barFontSize",{min:5,max:24,placeholder:Ee("默认 10")},V("barFontSize")):"",re?zt("打印机分辨率",Eo,at([{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}]),v=>{if(v==="__multi__")return;const U=Number(v);C("printerDpi",U>0?U:void 0)},{reset:V("printerDpi")}):"",re?Ct("填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"):"",ye?zt("纠错级别",To,at(Ad),v=>{v!=="__multi__"&&C("qrCodeLevel",v||void 0)},{reset:V("qrCodeLevel")}):"",ye?be("静区 (模块)",O({value:Ce("qrQuietZone",s.qrQuietZone),min:0,max:8,placeholder:Ee("默认 0"),onCommit:v=>C("qrQuietZone",v)}),c.propertyTip("cd-quiet-zone"),V("qrQuietZone")):"",re?Ct("单元格条码尺寸由「条宽」与「打印机分辨率」结算:可用宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"):"",ye||Me?zt("缩放模式",So,at(c.IMAGE_FIT_OPTIONS),v=>{v!=="__multi__"&&C("fit",v)},{reset:V("fit")}):"",Me&&!h&&s.fit==="cover"?qr(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:c.resolveDesignImageSrc(s.formatter),fit:s.fit,containerClass:"pd-cell-anchor",widthMm:Mt.width,heightMm:Mt.height,scale:s.fitScale,value:s.objectPosition,onCommit:v=>C("objectPosition",v),onScaleCommit:v=>C("fitScale",v),resetAnchor:V("objectPosition"),resetScale:V("fitScale")}):"",re||ye||Me?ue("最大宽度 (mm)",Ce("maxWidth",ut(s.maxWidth)),"maxWidth",{min:0,max:200,placeholder:Ee("默认")},V("maxWidth")):"",re||ye||Me?ue("最大高度 (mm)",Ce("maxHeight",ut(s.maxHeight)),"maxHeight",{min:0,max:200,placeholder:Ee("默认")},V("maxHeight")):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"内容"}),a("input",{class:"pd-input",type:"text",value:h?D("formatter")??"":s.formatter||"",placeholder:h?"多选(输入后覆盖全部选中格)":"输入内容,支持 {字段} 表达式",onChange:v=>C("formatter",v.target.value||void 0),onDblclick:()=>t.fire("table-cell-dblclick",{elementId:e.id,r:r.r,c:r.c,cellId:s.id})})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"水平对齐"}),V("align")]),rt("cell-align",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],h?T.values.align??"":s.align||"left",v=>C("align",v))]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"垂直对齐"}),V("valign")]),rt("cell-valign",[{value:"top",label:"上"},{value:"middle",label:"中"},{value:"bottom",label:"下"}],h?T.values.valign??"":s.valign||"top",v=>C("valign",v))]),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:"字体"}),V("fontFamily")]),bo({id:"cell-font",state:t.state,fonts:t.host.fonts,value:h?D("fontFamily"):s.fontFamily,placeholder:Ee("继承默认"),onChange:v=>C("fontFamily",v)})]),ue("字号 (pt)",Ce("fontSize",ut(s.fontSize)),"fontSize",{min:0,max:72,placeholder:Ee("默认")},V("fontSize")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"加粗"}),V("fontWeight")]),a("input",{class:"pd-switch",type:"checkbox",checked:h?T.values.fontWeight==="bold":s.fontWeight==="bold",onChange:v=>C("fontWeight",v.target.checked?"bold":void 0)})]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"文字颜色"}),V("color")]),Se(h?D("color"):s.color,v=>C("color",v),"文字颜色")]),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"背景色"}),V("backgroundColor")]),Se(h?D("backgroundColor"):s.backgroundColor,v=>C("backgroundColor",v),"背景颜色")])]),He("边框"),a("div",{class:"border-style-row"},[Hr(ke,[...ee?[{value:F,label:"混合",disabled:!0}]:[],...c.BORDER_LINE_STYLES],v=>{v!==F&&le(v)},{width:"90px"}),a("div",{style:{width:"112px",flexShrink:"0"}},[O({value:x,min:.25,max:5,step:.25,placeholder:h?"多选":H?"混合":void 0,onCommit:v=>k("width",v)})]),Se(Z,v=>k("color",v),"边框颜色")]),a("div",{class:"pd-button-group border-presets"},[["all","全部"],["outer","外侧"],["inner","内部"],["none","无"]].map(([v,U])=>a("button",{type:"button",class:"pd-button small",text:U,onClick:()=>{c.applyBorderPreset(n,i,N.style==="none"?"none":v,De()),o.updateElement(e.id,{tableRows:n})}}))),a("div",{class:"pd-checkbox-group"},qn.map(v=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",value:v.value,checked:B[v.value]==="on",indeterminate:B[v.value]==="mixed",onChange:U=>{const Q=U.target.checked&&N.style!=="none";h&&b({edges:{...T.edges,[v.value]:Q}}),y(Re=>{c.setCellBorderEdge(Re,v.value,Q?De():null)})}}),a("span",{text:v.label})]))),Ct(h?c.CELL_BORDER_APPLY_HINT_MULTI:te?c.CELL_BORDER_APPLY_HINT_MIXED:c.CELL_BORDER_APPLY_HINT),ue("内边距 (mm)",Ce("padding",ut(s.padding)),"padding",{min:0,max:10,step:.5,placeholder:Ee("默认")},V("padding")),mt("自动换行",h?T.values.wordWrap===!0:s.wordWrap??!0,v=>C("wordWrap",v),void 0,V("wordWrap")),G?zt("文字溢出",Gt,at(Dd),v=>{v!=="__multi__"&&C("textFit",v)},{full:!0,reset:V("textFit")}):"",G&&j==="shrink"?ue("最小字号 (pt)",Ce("shrinkMinFontSize",ut(s.shrinkMinFontSize)),"shrinkMinFontSize",{min:0,max:72,step:.5,placeholder:Ee("默认 6")},V("shrinkMinFontSize")):"",a("div",{class:"merge-card"},[a("div",{class:"merge-card-title",text:"单元格合并"}),a("div",{class:"merge-btns"},[a("button",{type:"button",class:"pd-button small",text:"合并单元格",disabled:!!Y,title:Y||"",onClick:()=>{c.mergeCells(n,i),o.updateElement(e.id,{tableRows:n})}}),a("button",{type:"button",class:"pd-button small",text:"拆分单元格",disabled:!Je,onClick:()=>{c.splitCells(n,i),o.updateElement(e.id,{tableRows:n})}})]),a("div",{class:"merge-card-divider"}),mt("按值合并",h?T.values.mergeSameValue===!0:s.mergeSameValue===!0,v=>C("mergeSameValue",v),X||void 0,Qe?V("mergeSameValue"):void 0,!Qe),Ct("明细相邻行同值时自动纵向合并;跨页时在该页内成段,续页首行重放该值")])])])}const ri=_.WATERMARK_DENSITY_PRESETS;function yi(t){const e=t.trim();return e?/[{}]/.test(e)||/^[A-Za-z_$][\w$]*\s*\(/.test(e)?!0:/^[A-Za-z_$][\w$]*(\.[\w$]+)+$/.test(e):!1}function Fd(t){return t?t.mode==="binding"?t.binding??"":t.content??"":""}function Ld(t){const e=t.store.templateData.watermark,o=Fd(e),i=e?.mode==="binding"||o!==""&&yi(o),n=(()=>{const u=e?.tileWidth??_.WATERMARK_DEFAULTS.tileWidth,h=e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight;for(const[m,g]of Object.entries(ri))if(g.width===u&&g.height===h)return m;return"custom"})(),r=u=>{const h={...e,testData:e?.testData??"",rotate:e?.rotate??_.WATERMARK_DEFAULTS.rotate,color:e?.color||_.WATERMARK_DEFAULTS.color,opacity:e?.opacity??_.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??_.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight};t.store.updateTemplateData({watermark:{...h,...u}})},s=()=>t.fire("open-expression",{elementId:"",targetPath:"watermark.content",value:o}),l={rotate:e?.rotate??_.WATERMARK_DEFAULTS.rotate,color:e?.color||_.WATERMARK_DEFAULTS.color,opacity:e?.opacity??_.WATERMARK_DEFAULTS.opacity,tileWidth:e?.tileWidth??_.WATERMARK_DEFAULTS.tileWidth,tileHeight:e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight},p=u=>bt({target:l,base:_.WATERMARK_DEFAULTS,propKey:u,write:()=>r({[u]:_.WATERMARK_DEFAULTS[u]})});return a("div",{class:"watermark-config"},[He("水印"),a("form",{class:"pd-form",onSubmit:u=>u.preventDefault()},[a("div",{class:"pd-field"},[a("span",{class:"pd-label",text:"水印表达式"}),a("input",{class:"pd-input",type:"text",value:o,placeholder:"直接输入文字,或用表达式:{order.no}、{printDate}",title:"双击或点「编辑表达式」打开表达式弹框",onChange:u=>{const h=u.target.value;r(yi(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?W("测试值",a("input",{class:"pd-input",type:"text",value:e?.testData??"",placeholder:"表达式取不到值时预览显示",onChange:u=>r({testData:u.target.value})})):"",a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"旋转角度"}),p("rotate")]),a("input",{type:"range",class:"pd-range",min:-90,max:90,step:5,value:String(e?.rotate??_.WATERMARK_DEFAULTS.rotate),onChange:u=>r({rotate:Number(u.target.value)})}),a("span",{class:"pd-hint",text:`${e?.rotate??_.WATERMARK_DEFAULTS.rotate}°`})]),W("颜色",Se(e?.color||_.WATERMARK_DEFAULTS.color,u=>r({color:u}),"水印颜色"),void 0,p("color")),a("div",{class:"pd-field"},[a("span",{class:"pd-label"},[a("span",{class:"pd-label-t",text:"透明度"}),p("opacity")]),a("input",{type:"range",class:"pd-range",min:.05,max:.5,step:.05,value:String(e?.opacity??_.WATERMARK_DEFAULTS.opacity),onChange:u=>r({opacity:Number(u.target.value)})}),a("span",{class:"pd-hint",text:(e?.opacity??_.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=ri[h];m&&r({tileWidth:m.width,tileHeight:m.height})}},[...Object.entries(ri).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:"瓦片宽"}),p("tileWidth")]),a("input",{type:"number",class:"pd-input",min:_.WATERMARK_DEFAULTS.minTileWidth,step:10,value:String(e?.tileWidth??_.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:"瓦片高"}),p("tileHeight")]),a("input",{type:"number",class:"pd-input",min:_.WATERMARK_DEFAULTS.minTileHeight,step:10,value:String(e?.tileHeight??_.WATERMARK_DEFAULTS.tileHeight),onChange:u=>r({tileHeight:Number(u.target.value)})})]):""].filter(Boolean))])}function ae(t,e,o,i,n={},r){return W(e,O({value:o,...n,onCommit:i}),void 0,r)}function je(t,e,o,i,n,r,s){const l=document.createElement("select");l.className="pd-select",l.addEventListener("change",()=>n(l.value));for(const p of i){const u=document.createElement("option");u.value=p.value,u.textContent=p.label,l.appendChild(u)}return l.value=o,i.some(p=>p.value===o)||(l.selectedIndex=-1),r?be(e,l,r,s):W(e,l,void 0,s)}function ct(t,e,o,i,n){return W(e,a("input",{type:"checkbox",class:"pd-switch",checked:o,onChange:r=>i(r.target.checked)}),void 0,n)}const zd=[{value:"all",label:"全部"},{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"none",label:"无"}],Od=[{value:"top",label:"上"},{value:"right",label:"右"},{value:"bottom",label:"下"},{value:"left",label:"左"}];function Nd(t,e){const o=t.store,i=e.options,n=e.printElementType.type,r=x=>o.updateElement(e.id,x),s=fr(n),l=s==="text",p=s==="code",u=s==="table",h=u&&o.tableSelection?.elementId===e.id,m=h&&c.resolveCellGroupMode(e.options.tableRows??[],o.tableSelection).mode==="multi",g=[];m||g.push(Td(t,e));const T=c.createDefaultOptions(n),b=(x,Z)=>{const le=c.propertyDefault(Z);return bt({target:i,base:T,propKey:x,tipValue:le?.value,tipUnit:le?.unit,write:()=>r({[x]:T[x]})})};h||g.push(we(t,"position-size","位置与尺寸","Location",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[a("div",{class:"position-grid"},[M(t,"ps-left",ae(t,"X",i.left,x=>r({left:x}),{min:0})),M(t,"ps-top",ae(t,"Y",i.top,x=>r({top:x}),{min:0})),M(t,"ps-width",ae(t,"W",i.width,x=>r({width:x}),{min:4})),M(t,"ps-height",ae(t,"H",i.height,x=>r({height:x}),{min:4}))]),a("h3",{class:"pd-divider",text:"外边距 (mm)"}),a("div",{class:"margin-grid"},[M(t,"ps-margin-top",ae(t,"上",i.marginTop,x=>r({marginTop:x===0?void 0:x}),{},b("marginTop","ps-margin-top"))),M(t,"ps-margin-right",ae(t,"右",i.marginRight,x=>r({marginRight:x===0?void 0:x}),{},b("marginRight","ps-margin-right"))),M(t,"ps-margin-bottom",ae(t,"下",i.marginBottom,x=>r({marginBottom:x===0?void 0:x}),{},b("marginBottom","ps-margin-bottom"))),M(t,"ps-margin-left",ae(t,"左",i.marginLeft,x=>r({marginLeft:x===0?void 0:x}),{},b("marginLeft","ps-margin-left")))])])]));const k=typeof i.rotate=="number"&&Number.isFinite(i.rotate)&&i.rotate!==0?c.normalizeRotationAngle(i.rotate):void 0,y=x=>r({rotate:x===void 0||x===0?void 0:c.normalizeRotationAngle(x)}),C=c.isFreeAngleEditable(n,i),D=c.isRotationExcludedType(n)||c.collectFollowMemberIds(o.elements).has(e.id),P=D?"":M(t,"ap-rotate",be("旋转 (°)",a("div",{class:"pd-rotate-row"},[a("button",{type:"button",class:"pd-rotate-btn",title:"逆时针 90°","aria-label":"逆时针旋转 90 度",text:"↺",onClick:()=>y((k??0)-90)}),a("div",{class:"pd-rotate-stepper"},[O({value:k,min:0,max:359,placeholder:"0",disabled:!C,onCommit:x=>y(x)})]),a("button",{type:"button",class:"pd-rotate-btn",title:"顺时针 90°","aria-label":"顺时针旋转 90 度",text:"↻",onClick:()=>y((k??0)+90)})]),c.propertyTip("ap-rotate"),b("rotate","ap-rotate"))),A=D||C?"":a("p",{class:"pd-hint pd-rotate-note",text:c.CODE_OBLIQUE_NOTE});if(g.push(we(t,"appearance","外观","Brush",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},l?[M(t,"ap-font-family",W("字体",bo({id:"prop-font",state:t.state,fonts:t.host.fonts,value:typeof i.fontFamily=="string"?i.fontFamily:void 0,placeholder:"默认",onChange:x=>r({fontFamily:x})}),void 0,b("fontFamily","ap-font-family"))),M(t,"ap-font-size",ae(t,"字体大小",i.fontSize,x=>r({fontSize:x}),{min:8,max:72},b("fontSize","ap-font-size"))),M(t,"ap-font-weight",je(t,"字体粗细",String(i.fontWeight??""),[{value:"normal",label:"正常"},{value:"bold",label:"粗体"},{value:"bolder",label:"更粗"},{value:"lighter",label:"细体"}],x=>r({fontWeight:x}),void 0,b("fontWeight","ap-font-weight"))),M(t,"ap-align",W("对齐",rt("ta",[{value:"left",label:"左"},{value:"center",label:"中"},{value:"right",label:"右"},{value:"justify",label:"两端"}],i.textAlign||"left",x=>r({textAlign:x})),void 0,b("textAlign","ap-align"))),M(t,"ap-vertical-align",W("垂直对齐",rt("va",[{value:"top",label:"顶"},{value:"middle",label:"中"},{value:"bottom",label:"底"}],i.verticalAlign||"top",x=>r({verticalAlign:x})),void 0,b("verticalAlign","ap-vertical-align"))),a("div",{class:"color-row"},[M(t,"ap-color",W("颜色",Se(i.color,x=>r({color:x}),"字体颜色"),void 0,b("color","ap-color"))),M(t,"ap-bg-color",W("背景色",Se(i.backgroundColor,x=>r({backgroundColor:x}),"背景颜色"),void 0,b("backgroundColor","ap-bg-color")))]),M(t,"ap-line-height",ae(t,"行高",i.lineHeight,x=>r({lineHeight:x||void 0}),{min:0,max:100},b("lineHeight","ap-line-height"))),M(t,"ap-letter-spacing",ae(t,"字间距",i.letterSpacing,x=>r({letterSpacing:x||void 0}),{min:0,max:20,step:.5},b("letterSpacing","ap-letter-spacing"))),M(t,"ap-text-fit",je(t,"文字溢出",c.resolveElementTextFit(n,i),[{value:"clip",label:"截断"},{value:"shrink",label:"自动缩小"},{value:"autoHeight",label:"自适应行高"}],x=>r({textFit:x}),void 0,b("textFit","ap-text-fit"))),i.textFit==="shrink"?M(t,"ap-shrink-min",W("最小字号 (pt)",O({value:i.shrinkMinFontSize,min:1,max:72,step:.5,placeholder:"默认 6",onCommit:x=>r({shrinkMinFontSize:x||void 0})}),void 0,b("shrinkMinFontSize","ap-shrink-min"))):"",n==="longText"?M(t,"ap-long-text-indent",be("首行缩进 (字符)",O({value:i.longTextIndent,min:0,max:10,placeholder:"默认 0",onCommit:x=>r({longTextIndent:x||void 0})}),c.propertyTip("ap-long-text-indent"),b("longTextIndent","ap-long-text-indent"))):"",M(t,"ap-word-wrap",ct(t,"自动换行",i.wordWrap!==!1,x=>r({wordWrap:x?void 0:!1}),b("wordWrap","ap-word-wrap"))),M(t,"ap-keep-line-breaks",ct(t,"保留换行符",i.keepLineBreaks===!0,x=>r({keepLineBreaks:x?!0:void 0}),b("keepLineBreaks","ap-keep-line-breaks"))),P,A]:[n==="image"?M(t,"ap-img-fit",je(t,"缩放模式",String(i.fit??"contain"),c.IMAGE_FIT_OPTIONS,x=>r({fit:x}),c.propertyTip("ap-img-fit"),b("fit","ap-img-fit"))):"",n==="image"&&i.fit==="cover"?M(t,"ap-img-object-position",qr(t,{fieldKey:"ap-img-object-position",label:"裁剪锚点",src:c.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:x=>r({objectPosition:x}),onScaleCommit:x=>r({fitScale:x}),resetAnchor:b("objectPosition","ap-img-object-position"),resetScale:b("fitScale","ap-img-fit-scale")})):"",P,A,n==="flowList"?a("p",{class:"pd-empty",text:"当前元素不支持外观设置"}):""].filter(Boolean))])),p){const x=n==="barcode",Z=String(i.barcodeType||"CODE128").toUpperCase(),le=i.printerDpi?String(i.printerDpi):"",De=c.barcodeBarWidthRecommendText(i.printerDpi,i.barWidth);g.push(we(t,"code","条码设置","Postcard",[a("form",{class:"pd-form",onSubmit:B=>B.preventDefault()},[x?[M(t,"cd-type",je(t,"码制",Z,[{value:"CODE128",label:"CODE128(通用)"},{value:"EAN13",label:"EAN13(商品码)"},{value:"EAN8",label:"EAN8"},{value:"UPC",label:"UPC"},{value:"CODE39",label:"CODE39"},{value:"ITF14",label:"ITF14"}],B=>r({barcodeType:B==="CODE128"?void 0:B}))),M(t,"cd-dpi",je(t,"打印机分辨率",le,[{value:"",label:"不指定(按条宽渲染)"},{value:"203",label:"203 dpi(8 点/mm)"},{value:"300",label:"300 dpi(11.8 点/mm)"},{value:"600",label:"600 dpi(23.6 点/mm)"}],B=>r({printerDpi:Number(B)>0?Number(B):void 0}),void 0,b("printerDpi","cd-dpi"))),M(t,"cd-dpi",a("p",{class:"pd-hint",text:"填写后条宽吸附到整数打印点(消除出纸「条宽忽宽忽窄」):条码先按条宽渲染,可用宽度够就原样落纸,不够才整体等比缩小"})),M(t,"cd-bar-width",ae(t,"条宽(倍率)",i.barWidth??2,B=>r({barWidth:B}),{min:2,max:8,step:.5},b("barWidth","cd-bar-width"))),M(t,"cd-bar-width",a("p",{class:"pd-hint",text:(le?"已设置打印机分辨率:条宽会被吸附到最近的整数打印点(DPI 优先于毫米值),元素框放不下时整体等比缩小":"热敏/针式打印建议 3 及以上:决定条码的落纸尺寸,条越粗出纸后条宽越稳定")+(De?`。${De}`:"")})),M(t,"cd-bar-quiet-zone",be("静区 (模块)",O({value:i.barQuietZone,min:0,max:20,placeholder:"默认 10",onCommit:B=>r({barQuietZone:B})}),c.propertyTip("cd-bar-quiet-zone"),b("barQuietZone","cd-bar-quiet-zone"))),M(t,"cd-bar-height",be("条高 (mm)",O({value:i.barHeight,min:1,max:100,placeholder:"默认 30 模块",onCommit:B=>r({barHeight:B??void 0})}),c.propertyTip("cd-bar-height"),b("barHeight","cd-bar-height"))),M(t,"cd-show-text",ct(t,"显示文本",i.hideTitle!==!0,B=>r({hideTitle:B?void 0:!0}),b("hideTitle","cd-show-text"))),M(t,"cd-font-size",W("文本字号(相对条高,条高为 30)",O({value:i.fontSize,min:5,max:24,placeholder:"默认 10",onCommit:B=>r({fontSize:B||void 0})}),void 0,b("fontSize","cd-font-size")))]:[M(t,"cd-ec-level",je(t,"纠错级别",String(i.qrCodeLevel??"M"),[{value:"L",label:"L(最低,容量大)"},{value:"M",label:"M(推荐)"},{value:"Q",label:"Q"},{value:"H",label:"H(最高)"}],B=>r({qrCodeLevel:B}),void 0,b("qrCodeLevel","cd-ec-level"))),M(t,"cd-quiet-zone",be("静区 (模块)",O({value:i.qrQuietZone,min:0,max:8,placeholder:"默认 0",onCommit:B=>r({qrQuietZone:B})}),c.propertyTip("cd-quiet-zone"),b("qrQuietZone","cd-quiet-zone")))],He("自定义设置"),x?a("p",{class:"pd-hint",text:"条码尺寸由「条宽」与「打印机分辨率」结算:宽度足够时按条宽原样落纸,不足时整体等比缩小;拉伸会把条宽变成非整数,故条形码不提供缩放模式,可用「最大宽高」限制上限。要放大条码:先加条宽倍率,再收窄静区(左右白边会换成条宽),必要时关掉显示文本以让出文本区高度"}):"",x?"":M(t,"cd-fit",je(t,"缩放模式",String(i.fit||"contain"),c.IMAGE_FIT_OPTIONS,B=>r({fit:B||void 0}),void 0,b("fit","cd-fit"))),M(t,"cd-max-width",W("最大宽度 (mm)",O({value:i.maxWidth,min:1,max:200,placeholder:"默认",onCommit:B=>r({maxWidth:B||void 0})}),void 0,b("maxWidth","cd-max-width"))),M(t,"cd-max-height",W("最大高度 (mm)",O({value:i.maxHeight,min:1,max:200,placeholder:"默认",onCommit:B=>r({maxHeight:B||void 0})}),void 0,b("maxHeight","cd-max-height")))].flat().filter(Boolean))]))}if(h&&(g.push(_d(t,e)),g.push(Id(t,e))),u&&g.push(Rd(t,e)),n==="flowList"){const x=c.resolveFlowColumns(i.flowColumns),Z=c.resolveFlowRowHeight(i.flowRowHeight),le=c.resolveFlowGapX(i.flowGapX),De=c.resolveFlowMaxSpan(i.flowMaxSpan,x),B=c.suggestFlowColumns(i.width??0,le,i.fontSize??12),Ue=c.resolveFlowLayoutMode(i.flowLayoutMode),re=Ue==="dynamic",ye=c.resolveFlowPadding(i),Me=(G,Ze)=>{r({[G]:typeof Ze=="number"&&Number.isFinite(Ze)&&Ze>0?Ze:0})};g.push(we(t,"flowList","流式列表","Grid3x3",[a("form",{class:"pd-form",onSubmit:G=>G.preventDefault()},[M(t,"fl-layout-mode",je(t,"布局模式",Ue,[{value:"fixed",label:"固定高度"},{value:"dynamic",label:"动态分页"}],G=>r({flowLayoutMode:G==="dynamic"?"dynamic":"fixed"}),c.propertyTip("fl-layout-mode"))),...re?[M(t,"fl-padding-top",be("上内边距 (mm)",O({value:ye.top,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingTop",G)}),c.propertyTip("fl-padding-top"))),M(t,"fl-padding-right",be("右内边距 (mm)",O({value:ye.right,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingRight",G)}),c.propertyTip("fl-padding-right"))),M(t,"fl-padding-bottom",be("下内边距 (mm)",O({value:ye.bottom,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingBottom",G)}),c.propertyTip("fl-padding-bottom"))),M(t,"fl-padding-left",be("左内边距 (mm)",O({value:ye.left,min:0,max:100,step:.5,onCommit:G=>Me("flowPaddingLeft",G)}),c.propertyTip("fl-padding-left")))]:[],M(t,"fl-columns",be("每行列数",O({value:x,min:1,max:12,onCommit:G=>r({flowColumns:c.resolveFlowColumns(G),flowMaxSpan:c.resolveFlowMaxSpan(i.flowMaxSpan,c.resolveFlowColumns(G))})}),c.propertyTip("fl-columns"))),M(t,"fl-row-height",be("行高 (mm)",O({value:Z,min:3,max:100,step:.5,onCommit:G=>r({flowRowHeight:c.resolveFlowRowHeight(G)})}),c.propertyTip("fl-row-height"))),M(t,"fl-gap-x",be("单元横向间距 (mm)",O({value:le,min:0,max:50,step:.5,onCommit:G=>r({flowGapX:c.resolveFlowGapX(G)})}),c.propertyTip("fl-gap-x"))),M(t,"fl-auto-span",ct(t,"内容过长时跨列",i.flowAutoSpan===!0,G=>{r(G?{flowAutoSpan:G,flowMaxSpan:De}:{flowAutoSpan:G})})),i.flowAutoSpan===!0?M(t,"fl-max-span",be("最多跨几列",O({value:De,min:1,max:x,onCommit:G=>r({flowMaxSpan:c.resolveFlowMaxSpan(G,x)})}),c.propertyTip("fl-max-span"))):"",x>B?a("p",{class:"pd-hint",text:`按当前字号与框宽,${x} 列偏挤(可放约 ${B} 列)。数值保持不变,出纸按 ${x} 列排。`}):""].flat().filter(Boolean))]))}const L=()=>({borderWidth:i.borderWidth,borderStyle:i.borderStyle,borderColor:i.borderColor,borders:i.borders}),K=x=>{const Z=L();c.applyElementBorderPreset(Z,x,c.effectiveElementBorderSpec(Z)),r(Z)},N=x=>{const Z=L();c.setElementBorderEdgeVisible(Z,x,!c.elementBorderEdgeVisible(Z,x)),r(Z)},F=c.resolveElementBorderDisplay(i),z=F.style==="mixed",ee=typeof F.width=="number"?F.width:void 0,H=z||F.style===void 0?"":F.style,pe=typeof F.color=="string"?F.color:void 0,te=(x,Z)=>{const le=L();c.setElementBorderField(le,x,Z),r(le)},ke=z?[{value:"",label:"混合"},...c.BORDER_LINE_STYLES]:[...c.BORDER_LINE_STYLES];return g.push(we(t,"border-bg","边框与背景","Picture",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[M(t,"bb-border-style",je(t,"线型",H,ke,x=>te("borderStyle",x))),a("div",{class:"border-row"},[M(t,"bb-border-width",ae(t,"边框宽度",ee,x=>te("borderWidth",x),{min:0,max:20,step:.25,placeholder:F.width==="mixed"?"混合":void 0},b("borderWidth","bb-border-width"))),M(t,"bb-border-color",W("边框颜色",Se(pe,x=>te("borderColor",x),"边框颜色"),void 0,b("borderColor","bb-border-color")))]),...c.acceptsElementBorder(n)?[a("div",{class:"pd-button-group border-presets"},zd.map(x=>a("button",{type:"button",class:"pd-button small",text:x.label,disabled:x.value==="inner",onClick:()=>K(x.value)}))),a("div",{class:"pd-checkbox-group"},Od.map(x=>a("label",{class:"pd-checkbox"},[a("input",{type:"checkbox",checked:c.elementBorderEdgeVisible(i,x.value),onChange:()=>N(x.value)}),a("span",{text:x.label})]))),a("p",{class:"pd-hint",text:c.ELEMENT_BORDER_APPLY_HINT})]:[],M(t,"bb-bg-color",W("背景色",Se(i.backgroundColor,x=>r({backgroundColor:x}),"背景颜色"),void 0,b("backgroundColor","bb-bg-color")))])])),g.push(Pd(t,e)),g.push(we(t,"advanced","高级设置","Setting",[a("form",{class:"pd-form",onSubmit:x=>x.preventDefault()},[a("div",{class:"advanced-row"},[M(t,"ad-locked",ct(t,"锁定",!!i.locked,x=>r({locked:x}),b("locked","ad-locked"))),M(t,"ad-fixed",ct(t,"每页重复",!!i.repeatOnEveryPage,x=>r({repeatOnEveryPage:x}),b("repeatOnEveryPage","ad-fixed"))),M(t,"ad-fixed-position",ct(t,"每页固定",!!i.fixed,x=>r({fixed:x}),b("fixed","ad-fixed-position")))]),M(t,"ad-z-index",ae(t,"层级",i.zIndex,x=>r({zIndex:x}),{min:0,max:999},b("zIndex","ad-z-index"))),M(t,"ad-delete",a("div",{class:"pd-field"},[a("button",{type:"button",class:"pd-button danger",text:"删除元素",onClick:()=>o.deleteSelected()})]))])],!1,[a("button",{type:"button",class:"group-help",title:"高级设置说明","aria-label":"高级设置说明",text:"?",onClick:x=>{x.stopPropagation(),t.fire("help","advanced-settings")}})])),a("div",{class:"property-content"},g)}function $d(t){const e=t.store,o=e.templateData,i=p=>e.updateTemplateData(p),n=p=>{const u=o.tiling,h=m=>m===90||m===270;if(u?.enabled&&h(p)!==h(o.outputRotation)){const m=_.computeMaxColumns({...o,outputRotation:p});i({outputRotation:p,tiling:{...u,columns:Math.max(m,1)}});return}i({outputRotation:p})},r=[];for(const[p,u]of Object.entries(c.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:p,label:u.label??p})}const s=!c.PAPER_PRESETS[o.paperSize],l=c.isContinuousPaperSize(o.paperSize);return a("form",{class:"pd-form",onSubmit:p=>p.preventDefault()},[He("纸张设置"),W("纸张尺寸",a("select",{class:"pd-select",style:{width:"100%"},onChange:p=>i({paperSize:p.target.value})},[...r.map(p=>a("optgroup",{label:p.group},p.items.map(u=>a("option",{value:u.key,text:u.label,selected:o.paperSize===u.key})))),a("option",{value:"CUSTOM",text:"自定义宽高",selected:s})])),l||s?W(l?"纸宽 (mm)":"自定义宽高 (mm)",a("div",{class:"custom-size-grid"},[O({value:Number(o.customWidth??0),min:25,max:2e3,onCommit:p=>i({customWidth:p})}),...s?[a("span",{class:"custom-size-x",text:"×"}),O({value:Number(o.customHeight??0),min:25,max:2e3,onCommit:p=>i({customHeight:p})})]:[]])):"",l?"":W("纸张方向",rt("ori",[{value:"portrait",label:"纵向"},{value:"landscape",label:"横向"}],o.orientation==="landscape"?"landscape":"portrait",p=>i({orientation:p})),"切换即交换纸张长宽(设计稿内容随之铺在该尺寸上)"),l?"":W("内容旋转角度",rt("rot",[{value:"0",label:"0°"},{value:"90",label:"90°"},{value:"180",label:"180°"},{value:"270",label:"270°"}],String(o.outputRotation??0),p=>n(Number(p)),!0),o.tiling?.enabled?"拼版时每个标签的内容按该角度旋转;90°/270° 时每格占位宽高互换,列数自动铺满新档位上限,行数按互换后重算;0° 为不旋转(默认)":"整页内容旋转对应角度出纸;90°/270° 时纸张长宽互换以贴合内容,内容不变形不裁切;0° 为不旋转(默认)"),W("页面背景色",a("div",{class:"page-bg-row"},[Se(o.pageBackground,p=>i({pageBackground:p}),"页面背景色","page-bg-picker")]),void 0,bt({target:o,base:{pageBackground:void 0},propKey:"pageBackground",write:()=>i({pageBackground:void 0})})),cd(t),e.pages.length>1?"":pd(t),He("页边距 (mm)"),a("div",{class:"margin-grid"},[ae(t,"上",o.margins.top,p=>i({margins:{...o.margins,top:p}}),{min:0,max:50}),ae(t,"下",o.margins.bottom,p=>i({margins:{...o.margins,bottom:p}}),{min:0,max:100}),ae(t,"左",o.margins.left,p=>i({margins:{...o.margins,left:p}}),{min:0,max:50}),ae(t,"右",o.margins.right,p=>i({margins:{...o.margins,right:p}}),{min:0,max:50})]),He("页眉/页脚高度 (mm)"),ae(t,"页眉高度",o.header.height??10,p=>i({header:{...o.header,height:p}}),{min:0,max:100,step:.1}),ae(t,"页脚高度",o.footer.height??10,p=>i({footer:{...o.footer,height:p}}),{min:0,max:100,step:.1}),Ld(t)].filter(Boolean))}function Bd(t,e,o){const i=(t.state.propSearch??"").trim(),n=!i||c.matchKeywords(i,[...o.searchKeywords,o.label]),r=document.createElement("div");if(r.className="property-content",n)try{Mr(`property:${e.id}`,o.ui.renderProperty({element:e,data:t.host.designData?.length?t.host.designData:[c.DEFAULT_DEMO_DATA],fields:t.host.fields??[],update:s=>t.store.updateElement(e.id,s),repaint:()=>t.repaint()}),r)}catch{}return a("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:custom"},style:t.state.propTab==="custom"?"":{display:"none"}},[r])}function Hd(t){const e=t.store,o=t.state,i=e.selectedElement,n=i?ui(i):void 0;if(o.propCollapsed)return a("div",{class:"property-panel collapsed"},[a("div",{class:"prop-collapsed"},[a("button",{type:"button",class:"pc-btn",title:"展开属性台",text:"«",onClick:()=>{o.propCollapsed=!1,t.repaint()}}),...n?[a("button",{type:"button",class:`pc-btn${o.propTab==="custom"?" on":""}`,title:n.label,html:ce(n.icon,14)||ce("Shapes",14),onClick:()=>{o.propTab="custom",o.propCollapsed=!1,t.repaint()}})]:[],...[["element","元素属性","▦"],["page","页面属性","▤"]].map(([s,l,p])=>a("button",{type:"button",class:`pc-btn${o.propTab===s?" on":""}`,title:l,text:p,onClick:()=>{o.propTab=s,o.propCollapsed=!1,t.repaint()}}))])]);const r=i?o.propTab==="custom"&&!n?"element":o.propTab:"page";return a("div",{class:"property-panel"},[a("div",{class:"prop-head"},[a("span",{class:"prop-title",text:"属性台"}),a("button",{type:"button",class:"collapse-btn",title:"收起属性台",text:"»",onClick:()=>{o.propCollapsed=!0,t.repaint()}})]),a("div",{class:"pd-tabs prop-tabs"},[a("div",{class:"pd-tab-bar",role:"tablist"},[...n?[a("button",{type:"button",class:`pd-tab${r==="custom"?" active":""}`,text:n.label,onClick:()=>{o.propTab="custom",t.repaint()}})]:[],a("button",{type:"button",class:`pd-tab${r==="element"?" active":""}`,text:"元素属性",onClick:()=>{o.propTab="element",t.repaint()}}),a("button",{type:"button",class:`pd-tab${r==="page"?" active":""}`,text:"页面属性",onClick:()=>{o.propTab="page",t.repaint()}})]),n&&i?Bd(t,i,n):"",a("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:element"},style:r==="element"?"":{display:"none"}},i?[bd(t),Nd(t,i)]:[a("p",{class:"pd-empty",text:"请在画布中选择一个元素"})]),a("div",{class:"pd-tab-pane",role:"tabpanel",dataset:{pane:"prop:page"},style:r==="page"?"":{display:"none"}},[$d(t)])].filter(Boolean))])}const ai=[{key:"field",text:"📁 字段"},{key:"variable",text:"🔧 变量"},{key:"function",text:"⚡ 函数"}],Kn={field:"搜索字段...",variable:"搜索变量...",function:"搜索函数..."},Ud=[{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()"}],Wd=[{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()"}],Gd=[{name:"MONEY",label:"金额格式化",template:"MONEY()"},{name:"DATE",label:"日期格式化",template:"DATE()"},{name:"UPPER",label:"大写金额",template:"UPPER()"},{name:"IF",label:"条件判断",template:"IF()"}],qd=[{name:"pageIndex",label:"当前页码",template:"{pageIndex}"},{name:"totalPages",label:"总页数",template:"{totalPages}"},{name:"printDate",label:"打印日期",template:"{printDate}"},{name:"printTime",label:"打印时间",template:"{printTime}"}],Kd=[{title:"聚合函数",items:Ud},{title:"数值运算",items:Wd},{title:"格式化函数",items:Gd}],Vd="(输入表达式后预览)",jd="(无法计算)",wi="(表达式错误)";function Vn(t,e){if(!t.trim())return Vd;try{const o={...c.DEFAULT_DEMO_DATA,...e??{},..._.resolveSystemVariables()},i=c.evaluateTemplate(t,o);return i==null?jd:String(i)}catch{return wi}}function jn(t,e){const o=e.trim().toLowerCase();return o?t.filter(i=>i.label.toLowerCase().includes(o)||i.name.toLowerCase().includes(o)):t}function Yd(t,e){const o=t.substring(0,e),i=o.lastIndexOf("{"),n=i!==-1&&!o.slice(i+1).includes("}"),r=o.lastIndexOf("("),s=r!==-1&&!o.slice(r+1).includes(")");return{insideBlock:n,insideParens:s}}const Xd=t=>/[\u4e00-\u9fff]/.test(t),Zd=t=>`字段「${t}」含中文,请用 {${t}} 引用(函数参数内写 ${t});中文可直接在 {} 中使用,无需 data['...'] 方括号`;function Qd(t,e){const o=/^\{\s*([^{}]+?)\s*\}$/.exec(t.trim());if(!o)return null;const i=o[1]??"";return e.find(n=>n.fieldKey===i)??null}function si(t,e){return a("div",{class:"ee-field-info"},[a("span",{class:"ee-item-label",text:t}),a("span",{class:"ee-item-key",text:e})])}function Be(t){return t.currentTarget.getRootNode()}function io(t,e,o){const i=[];return o.forEach((n,r)=>{i.push(n),r<o.length-1&&i.push(a("br"))}),a("div",{class:`ee-help-card ${t}`},[a("div",{class:"ee-help-card-title",text:e}),a("div",{class:"ee-help-card-content"},i)])}function Jd(){return a("div",{class:"ee-help-section"},[a("div",{class:"ee-help-title",text:"帮助信息"}),a("div",{class:"ee-help-grid"},[io("ee-help-field","输入方式",["双击左侧字段、变量、函数即可插入到表达式输入框中","双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名称,当静态文本用","静态数据直接输入即可,如:供应商名称","动态解析字段、变量、函数必须用 {} 包裹","示例:{SUM(supplier.name)}","中文 key 直接写 {字段名},如 {姓名}、{supplier.名称}","注意:只能嵌套一层"]),io("ee-help-function","函数使用",["SUM(字段) - 求和","AVG(字段) - 平均值","COUNT(字段) - 计数","IF(条件, 真值, 假值) - 条件判断","四则运算:{qty * price}、{ADD(qty, 1)}","修约:ROUND 四舍五入 / ROUNDUP 进一 / ROUNDDOWN 去尾 / ROUNDBANK 四舍六入五成双"]),io("ee-help-variable","系统变量",["{pageIndex} - 当前页码","{totalPages} - 总页数","{printDate} - 打印日期"]),io("ee-help-conditional","示例",["静态文本:供应商名称","动态字段:{supplier.name}","函数调用:{SUM(amount)}",'条件判断:{IF(amount>1000, "大单", "小单")}',"运算并修约:{ROUND(qty * price, 2)}"])])])}function ec(t,e){const o={activeTab:"field",searchText:"",expression:e.value||"",binding:e.binding,copiedFieldKey:"",keyHint:""},i=(y,C)=>y.querySelector(C),n=y=>{const C=i(y,".ee-preview");if(!C)return;const D=Vn(o.expression,t.demoData);C.textContent=D,C.classList.toggle("ee-preview-error",D===wi)},r=y=>{const C=i(y,".ee-key-hint");C&&(C.textContent=o.keyHint,C.style.display=o.keyHint?"":"none")},s=()=>{if(o.activeTab==="variable")return jn(qd,o.searchText).map(D=>a("div",{class:"ee-list-item",onDblclick:P=>{const{insideParens:A}=u(P);h(Be(P),A?D.template.replace(/^\{|\}$/g,""):D.template,void 0,"")}},[si(D.label,D.template)]));if(o.activeTab==="function")return Kd.map(D=>a("div",{class:"ee-func-group"},[a("div",{class:"ee-func-group-title",text:D.title}),...jn(D.items,o.searchText).map(P=>a("div",{class:"ee-list-item",onDblclick:A=>{const{insideBlock:L}=u(A),K=L?P.template:`{${P.template}}`;h(Be(A),K,K.indexOf("(")+1,"")}},[si(P.label,`${P.name}()`)]))]));const y=c.filterGroups(c.groupFields(t.fields??[]),o.searchText);if(!y.length)return[a("p",{class:"pd-empty",text:"暂无字段"})];const C=[];for(const D of y){D.key&&C.push(a("div",{class:`ee-field-group${D.isList?" is-list":""}`},[a("span",{class:"ee-field-group-icon",text:D.isList?"📋":"📁"}),a("span",{text:D.label})]));for(const P of D.fields)C.push(a("div",{class:"ee-list-item ee-field-item",style:{paddingLeft:D.key?"22px":"10px"},onDblclick:A=>{const{insideParens:L}=u(A),K=A;if(K.ctrlKey||K.metaKey){const N=P.fieldLabel||P.fieldKey;h(Be(A),L?`"${N}"`:N,void 0,"");return}h(Be(A),L?P.fieldKey:`{${P.fieldKey}}`,void 0,Xd(P.fieldKey)?Zd(P.fieldKey):"")}},[si(P.fieldLabel,P.fieldKey),a("button",{type:"button",class:`ee-copy-btn${o.copiedFieldKey===P.fieldKey?" is-copied":""}`,"data-tip":o.copiedFieldKey===P.fieldKey?"已复制":`复制字段名「${P.fieldLabel}」`,"aria-label":`复制字段名 ${P.fieldLabel}`,html:ce(o.copiedFieldKey===P.fieldKey?"Check":"Copy",13),onClick:A=>{A.stopPropagation(),p(A,P)},onDblclick:A=>A.stopPropagation()})]))}return C},l=y=>{Array.from(y.querySelectorAll(".ee-nav-tab")).forEach((L,K)=>L.classList.toggle("active",ai[K]?.key===o.activeTab));const D=i(y,".ee-content-search .pd-input");if(D){const L=Kn[o.activeTab];D.placeholder!==L&&(D.placeholder=L),D.value!==o.searchText&&(D.value=o.searchText)}const P=i(y,".ee-textarea");P&&P.value!==o.expression&&(P.value=o.expression);const A=i(y,".ee-content-list");if(A){ar(A);for(const L of s())ve(L,A)}n(y),r(y)};function p(y,C){const D=Be(y);c.copyTextToClipboard(C.fieldLabel||C.fieldKey).then(P=>{P&&(o.copiedFieldKey=C.fieldKey,l(D),setTimeout(()=>{o.copiedFieldKey===C.fieldKey&&(o.copiedFieldKey="",l(D))},1200))})}const u=y=>{const D=i(Be(y),".ee-textarea")?.selectionStart??o.expression.length;return Yd(o.expression,D)},h=(y,C,D=C.length,P)=>{P!==void 0&&(o.keyHint=P);const A=i(y,".ee-textarea");if(!A){o.expression+=C,n(y),r(y);return}const L=A.selectionStart??o.expression.length,K=A.selectionEnd??L;o.expression=o.expression.substring(0,L)+C+o.expression.substring(K);const N=L+D;A.value=o.expression,A.focus(),A.selectionStart=A.selectionEnd=N,n(y),r(y)},m=()=>{const y=o.expression;if(o.binding===void 0){t.onApply({formatter:y}),t.onClose();return}const C=Qd(y,t.fields??[]);t.onApply(C?{formatter:y,binding:C.fieldKey,title:C.fieldLabel}:{formatter:y}),t.onClose()},g=a("div",{class:"ee-nav"},[a("div",{class:"ee-nav-title",text:"类型"}),a("div",{class:"ee-nav-tabs"},ai.map((y,C)=>a("div",{class:`ee-nav-tab${o.activeTab===y.key?" active":""}`,text:y.text,onClick:D=>{o.activeTab=ai[C].key,l(Be(D))}})))]),T=a("div",{class:"ee-content"},[a("div",{class:"ee-content-search"},[a("input",{class:"pd-input",placeholder:Kn[o.activeTab],onInput:y=>{o.searchText=y.target.value,l(Be(y))}})]),a("div",{class:"ee-content-list"},s())]),b=Vn(o.expression,t.demoData),k=a("div",{class:"ee-editor"},[a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"表达式编辑"}),a("textarea",{class:"ee-textarea",rows:6,placeholder:"双击左侧字段/变量/函数插入,双击途中按住 Ctrl(Mac 为 ⌘)切换为插入字段名,或直接输入静态内容",text:o.expression,onInput:y=>{o.expression=y.target.value,o.keyHint="",n(Be(y)),r(Be(y))}}),a("div",{class:"pd-hint ee-key-hint",style:{display:"none",color:"var(--pd-accent, #165DFF)"},text:""})]),a("div",{class:"ee-editor-section"},[a("div",{class:"ee-editor-title",text:"预览结果"}),a("div",{class:`ee-preview${b===wi?" ee-preview-error":""}`,text:b})]),Jd()]);return a("div",{class:"pd-dialog-overlay",onKeydown:y=>{y.key==="Escape"&&t.onClose()}},[a("section",{class:"pd-dialog pd-dialog-large",role:"dialog","aria-modal":"true","aria-labelledby":"expression-editor-title"},[a("header",{class:"pd-dialog-header"},[a("strong",{id:"expression-editor-title",text:"编辑表达式"}),a("button",{type:"button",class:"pd-close","aria-label":"关闭",text:"×",onClick:()=>t.onClose()})]),a("div",{class:"expression-editor"},[g,T,k]),a("footer",{class:"pd-dialog-footer"},[a("button",{type:"button",class:"pd-button",text:"取消",onClick:()=>t.onClose()}),a("button",{type:"button",class:"pd-button primary",text:"确定",onClick:()=>m()})])])])}const tc={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-print-platform</p>
|
|
41
41
|
<p><strong>仓库地址:</strong><a href="https://gitee.com/liulong_oschina/worm-print-platform" target="_blank" rel="noopener noreferrer">https://gitee.com/liulong_oschina/worm-print-platform</a></p>
|
|
42
42
|
<p>基于 Vue 3 的可视化打印模板设计器,支持拖拽式模板编辑、表达式数据绑定和浏览器端打印预览。</p>
|
|
43
|
-
`},
|
|
43
|
+
`},oc={id:"features",title:"功能说明",content:`
|
|
44
44
|
<h2>元素类型</h2>
|
|
45
45
|
<table>
|
|
46
46
|
<thead>
|
|
@@ -212,7 +212,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
212
212
|
<li>支持调节水印密度(密/中/疏/自定义瓦片尺寸),以及设置水印颜色</li>
|
|
213
213
|
<li>水印在画布、浏览器预览、服务端 PDF、静默打印四端渲染一致</li>
|
|
214
214
|
</ul>
|
|
215
|
-
`},
|
|
215
|
+
`},ic={id:"advanced-settings",title:"高级设置",content:`
|
|
216
216
|
<h2>高级设置</h2>
|
|
217
217
|
<p>高级设置用于控制元素的编辑保护、跨页展示、重叠顺序和删除操作。这里的设置保存在模板中,但各选项的分页语义不同,应按元素的版式角色选择。</p>
|
|
218
218
|
|
|
@@ -259,7 +259,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
259
259
|
<li><strong>付款申请单右侧附件:</strong>推荐「每页固定」开启、「每页重复」关闭、「参与分页」关闭。这样每页位置一致,也不会挤压付款明细。</li>
|
|
260
260
|
<li><strong>只需要第一页右侧附件:</strong>关闭「每页固定」和「每页重复」,同时关闭「参与分页」。</li>
|
|
261
261
|
</ul>
|
|
262
|
-
`},
|
|
262
|
+
`},nc={id:"shortcuts",title:"快捷键",content:`
|
|
263
263
|
<h2>常用操作</h2>
|
|
264
264
|
<table>
|
|
265
265
|
<thead>
|
|
@@ -329,7 +329,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
329
329
|
<blockquote>
|
|
330
330
|
<p><strong>注意</strong>:当焦点在输入框、文本框、下拉框内时,快捷键不生效。</p>
|
|
331
331
|
</blockquote>
|
|
332
|
-
`},
|
|
332
|
+
`},rc={id:"faq",title:"常见问题",content:`
|
|
333
333
|
<h2>如何调整纸张大小?</h2>
|
|
334
334
|
<ol>
|
|
335
335
|
<li>在右侧面板选择"页面设置"</li>
|
|
@@ -463,7 +463,42 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
463
463
|
<blockquote>
|
|
464
464
|
<p><strong>提示</strong>:水印配置保存在模板 JSON 的 <code>watermark</code> 字段中,仅对当前模板生效。</p>
|
|
465
465
|
</blockquote>
|
|
466
|
-
`},
|
|
466
|
+
`},ac={id:"changelog",title:"更新记录",content:`
|
|
467
|
+
<h2>V1.5.3<small>(2026-11-18)</small></h2>
|
|
468
|
+
|
|
469
|
+
<h3>新增</h3>
|
|
470
|
+
<ul>
|
|
471
|
+
<li><strong>设计器配色可传参控制</strong>:新增 <code>theme</code>(跟随系统 / 浅色 / 深色)与 <code>theme-config</code> 两个参数,传参即优先于 CSS 主题令牌,不必自己覆盖样式变量。优先级为「参数覆盖 > 显式深色/浅色 > 跟随系统 > CSS 令牌」,宿主可只传一个深色开关,也可细调任意颜色。</li>
|
|
472
|
+
</ul>
|
|
473
|
+
|
|
474
|
+
<h3>注意</h3>
|
|
475
|
+
<ul>
|
|
476
|
+
<li><strong>画布保持原样</strong>:内置深色预设只改变设计器外壳,纸张、画布背景、标尺与手柄的颜色不变,预览所见即所得不受换肤影响。若想连画布外围背景一起换色,可显式覆盖 <code>--pd-canvas-bg</code>。</li>
|
|
477
|
+
</ul>
|
|
478
|
+
|
|
479
|
+
<h2>V1.5.2<small>(2026-11-17)</small></h2>
|
|
480
|
+
|
|
481
|
+
<h3>新增</h3>
|
|
482
|
+
<ul>
|
|
483
|
+
<li><strong>动态 base64 图片可在画布直接显示</strong>:图片元素与表格图片单元格里的 <code>{字段}</code> 表达式,现在优先取宿主给的设计态示例数据,不用等到预览或出纸才看到图;未注入示例数据时仍用内置演示图。</li>
|
|
484
|
+
<li><strong>工具栏「预览 / 保存」按钮可隐藏</strong>:宿主可按需隐藏这两个按钮并自行接管出图业务。隐藏只影响按钮显示,保存与预览功能本身照常可用。</li>
|
|
485
|
+
</ul>
|
|
486
|
+
|
|
487
|
+
<h2>V1.5.1<small>(2026-11-16)</small></h2>
|
|
488
|
+
|
|
489
|
+
<h3>发布</h3>
|
|
490
|
+
<ul>
|
|
491
|
+
<li><strong>桌面客户端安装包正式发行</strong>:mac(x64 / arm64)、Windows、Linux(deb / rpm / AppImage)六件安装包随版发布,README 提供直链与校验清单,可按系统直接下载静默打印客户端。</li>
|
|
492
|
+
</ul>
|
|
493
|
+
|
|
494
|
+
<h2>V1.5.0<small>(2026-11-16)</small></h2>
|
|
495
|
+
|
|
496
|
+
<h3>发布</h3>
|
|
497
|
+
<ul>
|
|
498
|
+
<li><strong>第一个稳定版本正式发布</strong>:设计器以零框架的 Web Components 实现为权威版本,npm 包名迁移为 <code>@worm-print-platform/*</code>;Vue 3 用法保留兼容门面,原有接入代码无需重写。</li>
|
|
499
|
+
<li><strong>插件化元素转正</strong>:图表等扩展元素可作为独立插件安装,内置元素与第三方插件在设计器里同权使用。</li>
|
|
500
|
+
</ul>
|
|
501
|
+
|
|
467
502
|
<h2>V1.4.8<small>(2026-11-11)</small></h2>
|
|
468
503
|
|
|
469
504
|
<h3>修复</h3>
|
|
@@ -889,9 +924,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
889
924
|
<blockquote>
|
|
890
925
|
<p>完整更新记录请查阅仓库 <code>docs/中文/CHANGELOG.md</code> 与 <code>docs/en/CHANGELOG.en.md</code>。</p>
|
|
891
926
|
</blockquote>
|
|
892
|
-
`},ao=[Qd,Jd,ec,tc,oc,ic],Kr="worm-print-help-tab",nc="getting-started";function Yn(t){return ao.some(e=>e.id===t)?String(t):""}function rc(t){let e=null;try{e=window.localStorage.getItem(Kr)}catch{e=null}return Yn(t)||Yn(e)||nc}function ac(t){const e=rc(t.initialTab),o=(i,n)=>{const r=i.currentTarget,s=r.closest(".help-modal");if(!s)return;for(const p of Array.from(s.querySelectorAll(".help-tab")))p.classList.toggle("active",p===r);const l=s.querySelector(".help-content");l&&(l.innerHTML=ao.find(p=>p.id===n)?.content??"");try{window.localStorage.setItem(Kr,n)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:i=>{i.target===i.currentTarget&&t.onClose()},onKeydown:i=>{i.key==="Escape"&&t.onClose()}},[a("div",{class:"help-modal"},[a("div",{class:"help-modal-header"},[a("div",{class:"help-modal-title-wrap"},[a("h2",{class:"help-modal-title",text:"帮助文档"}),a("span",{class:"help-modal-project",text:"worm-print-platform"})]),a("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>t.onClose()})]),a("div",{class:"help-modal-body"},[a("div",{class:"help-modal-sidebar"},ao.map(i=>a("button",{type:"button",class:`help-tab${i.id===e?" active":""}`,text:i.title,onClick:n=>o(n,i.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:ao.find(i=>i.id===e)?.content??""})])])])])}function sc(t,e){const o=ve(ac(e),t),i=n=>{n.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",i),o.focus?.(),()=>{document.removeEventListener("keydown",i),o.remove()}}const lc=2,dc=74,Ei=[{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 cc(t){const e=!!t.state.openMore,o=Ei.slice().sort((i,n)=>i.order-n.order).map(i=>a("div",{class:"tb-more-item",dataset:{unit:i.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:i.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${i.id}`,dataset:{unit:i.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{t.state.openMore=!e,t.repaint()},html:`${ce("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ce("ChevronDown",12,"tb-dd-arrow")}`}),a("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[a("div",{class:"tb-menu tb-more-menu"},o)])])])}const Xn=new WeakMap;function Zn(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const o=getComputedStyle(e),i=Number.parseFloat(o.gap)||lc,n=Number.parseFloat(o.paddingLeft)||0,r=Number.parseFloat(o.paddingRight)||0,s=new Map;for(const k of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const y=k.parentElement;y&&!y.classList.contains("tb-more-slot")&&Xn.set(k,{parent:y,next:k.nextSibling}),s.set(k.dataset.unit,k)}for(const k of s.values()){const y=Xn.get(k);!y||k.parentElement===y.parent||(y.next?.parentElement===y.parent?y.parent.insertBefore(k,y.next):y.parent.appendChild(k))}let l=0;for(const k of Array.from(e.children)){if(k.classList.contains("tb-spacer")||k.classList.contains("tb-more-group"))continue;const y=Math.max(k.offsetWidth,k.scrollWidth);y<=0||(l+=y+i)}const p=new Map;for(const[k,y]of s){const C=y.offsetWidth;C>0&&p.set(k,C)}const u=Ei.map(k=>({id:k.id,order:k.order,width:p.get(k.id)??0})),h=u.reduce((k,y)=>k-y.width-i,l),m=e.clientWidth-n-r,{movedIds:g,overflowRemains:S}=c.resolveToolbarOverflow({available:m,pinned:h,moreTriggerWidth:dc,gap:i,units:u});for(const k of Ei){const y=e.querySelector(`.tb-more-item[data-unit="${k.id}"]`),C=e.querySelector(`#tb-more-slot-${k.id}`),D=s.get(k.id);if(!y||!C||!D)continue;const P=g.includes(k.id);P&&D.parentElement!==C&&C.appendChild(D),y.style.display=P?"":"none"}const b=e.querySelector(".tb-more-group");return b&&(b.style.display=g.length>0?"":"none"),e.classList.toggle("is-tight",S),{movedIds:g,overflowRemains:S}}function pc(t,e){const o=t.store,i=o.selectedIds.size>0,n=o.selectedIds.size>1,r=o.selectedElement,s=!i,l=t.isEdit?"编辑模板":"新建模板",p=[a("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[a("div",{class:"tb-menu-label",text:"对齐 / 分布"}),a("div",{class:"tb-menu-grid"},[oe(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!n}),oe(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!n}),oe(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!n}),oe(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!n}),oe(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!n}),oe(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!n}),oe(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!n}),oe(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!n})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[oe(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!i}),oe(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!i}),oe(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!i}),oe(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!i})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[oe(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!n}),oe(t,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],u=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[h("标尺",o.showRuler,"toggle-ruler","显示/隐藏标尺"),h("网格",o.showGrid,"toggle-grid","显示/隐藏网格背景"),h("虚框",o.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),h("吸附",o.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function h(m,g,S,b){return a("button",{type:"button",class:`tb-btn tb-menu-row${g?" on":""}`,dataset:{tip:b},onClick:()=>t.fire(S)},[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"},[oe(t,"Undo2","undo",{tip:"撤销",disabled:!o.canUndo}),oe(t,"Redo2","redo",{tip:"重做",disabled:!o.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[ho(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},p),ho(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},u)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[oe(t,"Maximize","fit-window",{tip:"适应窗口"}),oe(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${o.scale}%`}),oe(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[oe(t,"Copy","copy",{tip:s?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:s,test:"copy"}),oe(t,"ClipboardPaste","paste",{tip:s?"粘贴 (Ctrl+V),需选中元素":o.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:s||!o.hasClipboard,test:"paste"}),oe(t,"Trash2","delete",{tip:s?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:s,danger:!0,test:"delete"})]),cc(t),a("div",{class:"tb-spacer"}),t.showHelp?a("div",{class:"tb-group"},[a("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>t.fire("help")},[a("span",{class:"help-icon",text:"?"})])]):"",(()=>{const m=[t.showPreview!==!1?a("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>t.fire("preview")}):"",t.showSave!==!1?a("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>t.fire("save")}):""].filter(Boolean);return m.length?a("div",{class:"tb-group"},m):""})()].filter(Boolean))}function li(t,e,o){for(const i of e){const n=t.getPropertyValue(i).trim();if(n)return n}return o}function uc(t,e){const o=e.orientation==="horizontal",i=e.geom,n=o?i.viewW:i.viewH;t.style.width=`${o?n:c.RULER_THICKNESS}px`,t.style.height=`${o?c.RULER_THICKNESS:n}px`;const r=t.getContext("2d");if(!r)return;const s=window.devicePixelRatio||1,l=Math.max(0,Math.round(n)),p=c.RULER_THICKNESS;t.width=(o?l:p)*s,t.height=(o?p:l)*s,r.setTransform(s,0,0,s,0,0);const u=getComputedStyle(t),h=li(u,["--pd-ruler-bg"],"#F8F9FC"),m=li(u,["--pd-ruler"],"#9AA1AF"),g=li(u,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=h,r.fillRect(0,0,o?l:p,o?p:l);const S=e.scale>0?e.scale:i.paperScale>0?i.paperScale:1,b=c.mmToPx(1)*S;if(b<=0)return;const k={ctx:r,horizontal:o,viewportPx:n,thickness:p,originPx:o?i.originX:i.originY,pxPerMM:b,paperLengthMM:e.paperLengthMM},y=-k.originPx/b,C=(l-k.originPx)/b,D=c.chooseMajorStepMM(S),P=c.buildRulerTicks(y,C,D);Qn(k,P,m,!0),Qn(k,P,m,!1),Jn(k,0,g),Jn(k,e.paperLengthMM,g);const A=e.cursorPx??null;if(A!==null&&A>=0&&A<=l){if(r.strokeStyle=g,r.lineWidth=1.5,r.beginPath(),o){const F=Math.round(A)+.5;r.moveTo(F,0),r.lineTo(F,p)}else{const F=Math.round(A)+.5;r.moveTo(0,F),r.lineTo(p,F)}r.stroke()}}function Vr(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function Qn(t,e,o,i){const{ctx:n,horizontal:r,paperLengthMM:s}=t;n.strokeStyle=o,n.fillStyle=o,n.globalAlpha=i?.32:1,n.lineWidth=1,n.font="9px ui-monospace, Menlo, monospace",n.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>s)!==i)continue;const u=Vr(t,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 Jn(t,e,o){const{ctx:i,horizontal:n,thickness:r,viewportPx:s}=t,l=Vr(t,e);l<=0||l>=s||(i.strokeStyle=o,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 hc=':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:248px;min-width:248px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.material-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-content:start}.material-grid>.panel-title,.material-grid>.material-group-title,.material-grid>.material-card--wide{grid-column:1 / -1}.material-grid>.panel-title,.material-grid>.material-group-title{margin-bottom:0}.material-grid>.material-card{margin-bottom:0;min-width:0}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-group-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:4px 2px 6px;margin:2px 0 8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{position:relative;display:flex;align-items:center;gap:9px;padding:7px 8px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:7px;background:transparent;cursor:grab;-webkit-user-select:none;user-select:none;transition:background .16s ease,border-color .16s ease,transform .16s ease,box-shadow .16s ease}.material-card:before{content:"";position:absolute;left:0;top:50%;width:2px;height:0;border-radius:2px;background:var(--pd-accent, #165DFF);transform:translateY(-50%);transition:height .16s ease}.material-card:hover{background:var(--pd-hover-tint, #ecf5ff);border-color:#165dff73;transform:translate(2px)}.material-card:hover:before{height:56%}.material-card:active{cursor:grabbing;transform:translate(2px) scale(.985)}.material-icon{width:30px;height:30px;border:0;border-radius:7px;display:flex;align-items:center;justify-content:center;color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));box-shadow:inset 0 0 0 1px #165dff1f;flex-shrink:0;transition:background .16s ease,color .16s ease,box-shadow .16s ease,transform .16s ease}.material-card:hover .material-icon{background:var(--pd-accent, #165DFF);color:#fff;box-shadow:0 2px 6px #165dff47}.material-card:active .material-icon{transform:scale(.92)}.material-label{min-width:0;flex:1;font-size:12.5px;font-weight:500;line-height:1.3;color:var(--pd-text, #2a2e37);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:color .16s ease}.material-card:hover .material-label{color:var(--pd-accent, #165DFF)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.extension-placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;box-sizing:border-box;padding:2px;font-size:11px;line-height:1.4;text-align:center;color:var(--pd-text-muted, #8b909c);background:repeating-linear-gradient(45deg,#f4f6fa,#f4f6fa 6px,#fff 6px 12px);overflow:hidden}.element-margin-guide{position:absolute;box-sizing:border-box;pointer-events:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid,.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.margin-grid{margin-top:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.group-help{flex:0 0 auto;width:18px;height:18px;margin-right:6px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:18px;cursor:pointer}.group-help:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.group-help:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{display:flex;gap:8px}.merge-card{margin-top:8px;padding:8px;border:1px solid var(--pd-border, #dcdfe6);border-radius:6px}.merge-card-title{font-size:12px;font-weight:600;color:var(--pd-text, #303133);margin-bottom:8px}.merge-card-divider{height:1px;background:var(--pd-menu-divider, #ebeef5);margin:8px 0}.merge-card-hint{margin-top:6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #8b909c)}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:304px;min-width:304px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-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}',no=20,fc=".page-tabs, .field-tree-panel, .pd-dialog-overlay",gc=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),er="print-studio:left",tr="print-studio:right";function or(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function ir(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}function di(t){let e=t;if(typeof e=="string")try{e=JSON.parse(e)}catch{return}if(Array.isArray(e))return e.filter(o=>!!o&&typeof o=="object"&&!Array.isArray(o));if(e&&typeof e=="object")return[e]}class Ye extends HTMLElement{root;store;format;unsub=null;unsubPluginUI=null;unsubDefinitions=null;pluginStyleEls=new Map;instanceDisposers=[];measureRaf=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};paneScroll=new Map;marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;helpInitialTab;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";uploadImage;uploadDesignBackground;_designData;set designData(e){this._designData=di(e),this.repaint()}get designData(){return this._designData}_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=hc,this.root.appendChild(e),ve(a("div",{class:"designer-container",dataset:{test:"designer-container"},part:"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()}set showPreview(e){this.setAttribute("show-preview",String(e)),this.repaint()}set showSave(e){this.setAttribute("show-save",String(e)),this.repaint()}static contractVersion=Ai;static getHostContract(){return hi()}getHostContract(){return hi()}static get observedAttributes(){return[...Di]}attributeChangedCallback(e,o,i){if(e==="design-data"){this._designData=i===null?void 0:di(i),this.repaint();return}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(),this.attachPluginUI(),this.attachInstanceListeners();return}const e={},o=this.getAttribute("template");if(o)try{e.initialTemplate=JSON.parse(o)}catch{}const i=this.getAttribute("fields");if(i)try{e.initialFields=JSON.parse(i)}catch{}const n=this.getAttribute("design-data");n&&this._designData===void 0&&(this._designData=di(n)),this.store=new sr(e),this.format=new Da(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners(),this.applyFontFace(),this.repaint(),this.measureRaf=requestAnimationFrame(()=>{this.measureRaf=null,this.measureRuler()})}readChrome(){this.state.leftCollapsed=or(er),this.state.propCollapsed=or(tr),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,ir(er,this.state.leftCollapsed),ir(tr,this.state.propCollapsed))}disconnectedCallback(){this.unsub?.(),this.unsub=null,this.unsubPluginUI?.(),this.unsubPluginUI=null,this.unsubDefinitions?.(),this.unsubDefinitions=null,Dn(),this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Ye.active===this&&(Ye.active=null),zr(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null);for(const e of this.instanceDisposers)e();this.instanceDisposers=[],this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null,this.measureRaf!==null&&(cancelAnimationFrame(this.measureRaf),this.measureRaf=null)}applyFontFace(){const e=_.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}attachPluginUI(){this.unsubPluginUI||(this.unsubPluginUI=ci.subscribeElementUIRegistry(()=>this.repaint())),this.unsubDefinitions||(this.unsubDefinitions=dr(()=>this.repaint()))}syncPluginUIStyles(){const e=new Map;for(const{type:o,ui:i}of ci.getElementUIEntries())i.styles&&e.set(o,i.styles);for(const[o,i]of[...this.pluginStyleEls])e.has(o)||(i.remove(),this.pluginStyleEls.delete(o));for(const[o,i]of e){let n=this.pluginStyleEls.get(o);n||(n=document.createElement("style"),n.setAttribute("data-plugin-ui",o),this.root.appendChild(n),this.pluginStyleEls.set(o,n)),n.textContent!==i&&(n.textContent=i)}}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),o=this.fonts;if(!o?.length)return e;if(Array.isArray(e.pages)){const i=e;return{...i,pages:i.pages.map(n=>({...n,fonts:[...o]}))}}return{...e,fonts:[...o]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const o=this.templateJsonWithFonts();if(Array.isArray(o.pages))try{_.normalizeTemplate(o)}catch(r){window.alert(r instanceof Error?r.message:String(r));return}const i=this.getGeometryWarnings();if(i.length&&!window.confirm(`出纸提示:部分内容超出纸面,打印时会被裁切。
|
|
927
|
+
`},ao=[tc,oc,ic,nc,rc,ac],Vr="worm-print-help-tab",sc="getting-started";function Yn(t){return ao.some(e=>e.id===t)?String(t):""}function lc(t){let e=null;try{e=window.localStorage.getItem(Vr)}catch{e=null}return Yn(t)||Yn(e)||sc}function dc(t){const e=lc(t.initialTab),o=(i,n)=>{const r=i.currentTarget,s=r.closest(".help-modal");if(!s)return;for(const p of Array.from(s.querySelectorAll(".help-tab")))p.classList.toggle("active",p===r);const l=s.querySelector(".help-content");l&&(l.innerHTML=ao.find(p=>p.id===n)?.content??"");try{window.localStorage.setItem(Vr,n)}catch{}};return a("div",{class:"help-modal-overlay",tabindex:"-1",onClick:i=>{i.target===i.currentTarget&&t.onClose()},onKeydown:i=>{i.key==="Escape"&&t.onClose()}},[a("div",{class:"help-modal"},[a("div",{class:"help-modal-header"},[a("div",{class:"help-modal-title-wrap"},[a("h2",{class:"help-modal-title",text:"帮助文档"}),a("span",{class:"help-modal-project",text:"worm-print-platform"})]),a("button",{type:"button",class:"help-modal-close",title:"关闭",text:"×",onClick:()=>t.onClose()})]),a("div",{class:"help-modal-body"},[a("div",{class:"help-modal-sidebar"},ao.map(i=>a("button",{type:"button",class:`help-tab${i.id===e?" active":""}`,text:i.title,onClick:n=>o(n,i.id)}))),a("div",{class:"help-modal-content"},[a("div",{class:"help-content",html:ao.find(i=>i.id===e)?.content??""})])])])])}function cc(t,e){const o=ve(dc(e),t),i=n=>{n.key==="Escape"&&e.onClose()};return document.addEventListener("keydown",i),o.focus?.(),()=>{document.removeEventListener("keydown",i),o.remove()}}const pc=2,uc=74,Ei=[{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 hc(t){const e=!!t.state.openMore,o=Ei.slice().sort((i,n)=>i.order-n.order).map(i=>a("div",{class:"tb-more-item",dataset:{unit:i.id},style:{display:"none"}},[a("div",{class:"tb-menu-label",text:i.label}),a("div",{class:"tb-more-slot",id:`tb-more-slot-${i.id}`,dataset:{unit:i.id}})]));return a("div",{class:"tb-group tb-more-group",style:{display:"none"}},[a("div",{class:"tb-dd"},[a("button",{type:"button",class:`tb-dd-trigger${e?" on":""}`,dataset:{test:"more-dd",tip:"更多"},onClick:()=>{t.state.openMore=!e,t.repaint()},html:`${ce("Ellipsis",15)}<span class="tb-btn-text">更多</span>${ce("ChevronDown",12,"tb-dd-arrow")}`}),a("div",{class:`tb-dd-panel tb-more-panel${e?"":" is-hidden"}`},[a("div",{class:"tb-menu tb-more-menu"},o)])])])}const Xn=new WeakMap;function Zn(t){const e=t.querySelector(".designer-toolbar");if(!e)return{movedIds:[],overflowRemains:!1};const o=getComputedStyle(e),i=Number.parseFloat(o.gap)||pc,n=Number.parseFloat(o.paddingLeft)||0,r=Number.parseFloat(o.paddingRight)||0,s=new Map;for(const k of Array.from(e.querySelectorAll(".tb-ou[data-unit]"))){const y=k.parentElement;y&&!y.classList.contains("tb-more-slot")&&Xn.set(k,{parent:y,next:k.nextSibling}),s.set(k.dataset.unit,k)}for(const k of s.values()){const y=Xn.get(k);!y||k.parentElement===y.parent||(y.next?.parentElement===y.parent?y.parent.insertBefore(k,y.next):y.parent.appendChild(k))}let l=0;for(const k of Array.from(e.children)){if(k.classList.contains("tb-spacer")||k.classList.contains("tb-more-group"))continue;const y=Math.max(k.offsetWidth,k.scrollWidth);y<=0||(l+=y+i)}const p=new Map;for(const[k,y]of s){const C=y.offsetWidth;C>0&&p.set(k,C)}const u=Ei.map(k=>({id:k.id,order:k.order,width:p.get(k.id)??0})),h=u.reduce((k,y)=>k-y.width-i,l),m=e.clientWidth-n-r,{movedIds:g,overflowRemains:T}=c.resolveToolbarOverflow({available:m,pinned:h,moreTriggerWidth:uc,gap:i,units:u});for(const k of Ei){const y=e.querySelector(`.tb-more-item[data-unit="${k.id}"]`),C=e.querySelector(`#tb-more-slot-${k.id}`),D=s.get(k.id);if(!y||!C||!D)continue;const P=g.includes(k.id);P&&D.parentElement!==C&&C.appendChild(D),y.style.display=P?"":"none"}const b=e.querySelector(".tb-more-group");return b&&(b.style.display=g.length>0?"":"none"),e.classList.toggle("is-tight",T),{movedIds:g,overflowRemains:T}}function fc(t,e){const o=t.store,i=o.selectedIds.size>0,n=o.selectedIds.size>1,r=o.selectedElement,s=!i,l=t.isEdit?"编辑模板":"新建模板",p=[a("div",{class:"tb-menu",dataset:{test:"arrange-panel"}},[a("div",{class:"tb-menu-label",text:"对齐 / 分布"}),a("div",{class:"tb-menu-grid"},[oe(t,"AlignStartVertical","align",{arg:"left",tip:"左对齐",disabled:!n}),oe(t,"AlignEndVertical","align",{arg:"right",tip:"右对齐",disabled:!n}),oe(t,"AlignStartHorizontal","align",{arg:"top",tip:"顶对齐",disabled:!n}),oe(t,"AlignEndHorizontal","align",{arg:"bottom",tip:"底对齐",disabled:!n}),oe(t,"AlignCenterVertical","align",{arg:"vertical",tip:"水平居中",disabled:!n}),oe(t,"AlignCenterHorizontal","align",{arg:"horizontal",tip:"垂直居中",disabled:!n}),oe(t,"AlignHorizontalSpaceBetween","align",{arg:"distributeHor",tip:"水平分布",disabled:!n}),oe(t,"AlignVerticalSpaceBetween","align",{arg:"distributeVer",tip:"垂直分布",disabled:!n})]),a("div",{class:"tb-menu-label",text:"层级"}),a("div",{class:"tb-menu-grid"},[oe(t,"ArrowUpToLine","move-layer",{arg:"top",tip:"置顶",disabled:!i}),oe(t,"ArrowUp","move-layer",{arg:"up",tip:"上移一层",disabled:!i}),oe(t,"ArrowDown","move-layer",{arg:"down",tip:"下移一层",disabled:!i}),oe(t,"ArrowDownToLine","move-layer",{arg:"bottom",tip:"置底",disabled:!i})]),a("div",{class:"tb-menu-label",text:"组合"}),a("div",{class:"tb-menu-grid"},[oe(t,"Group","group",{tip:"组合 (Ctrl+G)",disabled:!n}),oe(t,"Ungroup","ungroup",{tip:"取消组合 (Ctrl+Shift+G)",disabled:!r?.options?.groupId})])])],u=[a("div",{class:"tb-menu tb-menu-rows",dataset:{test:"view-panel"}},[h("标尺",o.showRuler,"toggle-ruler","显示/隐藏标尺"),h("网格",o.showGrid,"toggle-grid","显示/隐藏网格背景"),h("虚框",o.showTableGhostBorder,"toggle-table-ghost-border","显示/隐藏无边框表格的虚拟虚线"),h("吸附",o.snapToGrid,"toggle-snap","开启/关闭元素吸附到网格")])];function h(m,g,T,b){return a("button",{type:"button",class:`tb-btn tb-menu-row${g?" on":""}`,dataset:{tip:b},onClick:()=>t.fire(T)},[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"},[oe(t,"Undo2","undo",{tip:"撤销",disabled:!o.canUndo}),oe(t,"Redo2","redo",{tip:"重做",disabled:!o.canRedo})]),e,a("div",{class:"tb-ou tb-group",dataset:{unit:"arrange-view"}},[ho(t,"arrange",{icon:"Layers",text:"排列",tip:"排列",testId:"arrange-dd"},p),ho(t,"view",{icon:"Eye",text:"视图",tip:"视图",testId:"view-dd"},u)]),a("div",{class:"tb-ou tb-group",dataset:{unit:"zoom"}},[oe(t,"Maximize","fit-window",{tip:"适应窗口"}),oe(t,"ZoomOut","zoom",{arg:-10,tip:"缩小"}),a("span",{class:"tb-zoom",text:`${o.scale}%`}),oe(t,"ZoomIn","zoom",{arg:10,tip:"放大"})]),a("div",{class:"tb-ou tb-group",dataset:{unit:"clipboard"}},[oe(t,"Copy","copy",{tip:s?"复制 (Ctrl+C),需选中元素":"复制 (Ctrl+C)",disabled:s,test:"copy"}),oe(t,"ClipboardPaste","paste",{tip:s?"粘贴 (Ctrl+V),需选中元素":o.hasClipboard?"粘贴 (Ctrl+V)":"粘贴 (Ctrl+V),剪贴板为空",disabled:s||!o.hasClipboard,test:"paste"}),oe(t,"Trash2","delete",{tip:s?"删除 (Delete),需选中元素":"删除 (Delete)",disabled:s,danger:!0,test:"delete"})]),hc(t),a("div",{class:"tb-spacer"}),t.showHelp?a("div",{class:"tb-group"},[a("button",{type:"button",class:"help-button",title:"帮助文档",onClick:()=>t.fire("help")},[a("span",{class:"help-icon",text:"?"})])]):"",(()=>{const m=[t.showPreview!==!1?a("button",{type:"button",class:"btn-secondary",dataset:{tip:"预览模板打印效果"},text:"预览",onClick:()=>t.fire("preview")}):"",t.showSave!==!1?a("button",{type:"button",class:"btn-primary",dataset:{tip:"保存模板"},text:"保存",onClick:()=>t.fire("save")}):""].filter(Boolean);return m.length?a("div",{class:"tb-group"},m):""})()].filter(Boolean))}function li(t,e,o){for(const i of e){const n=t.getPropertyValue(i).trim();if(n)return n}return o}function gc(t,e){const o=e.orientation==="horizontal",i=e.geom,n=o?i.viewW:i.viewH;t.style.width=`${o?n:c.RULER_THICKNESS}px`,t.style.height=`${o?c.RULER_THICKNESS:n}px`;const r=t.getContext("2d");if(!r)return;const s=window.devicePixelRatio||1,l=Math.max(0,Math.round(n)),p=c.RULER_THICKNESS;t.width=(o?l:p)*s,t.height=(o?p:l)*s,r.setTransform(s,0,0,s,0,0);const u=getComputedStyle(t),h=li(u,["--pd-ruler-bg"],"#F8F9FC"),m=li(u,["--pd-ruler"],"#9AA1AF"),g=li(u,["--pd-ruler-cursor","--pd-accent"],"#165DFF");r.fillStyle=h,r.fillRect(0,0,o?l:p,o?p:l);const T=e.scale>0?e.scale:i.paperScale>0?i.paperScale:1,b=c.mmToPx(1)*T;if(b<=0)return;const k={ctx:r,horizontal:o,viewportPx:n,thickness:p,originPx:o?i.originX:i.originY,pxPerMM:b,paperLengthMM:e.paperLengthMM},y=-k.originPx/b,C=(l-k.originPx)/b,D=c.chooseMajorStepMM(T),P=c.buildRulerTicks(y,C,D);Qn(k,P,m,!0),Qn(k,P,m,!1),Jn(k,0,g),Jn(k,e.paperLengthMM,g);const A=e.cursorPx??null;if(A!==null&&A>=0&&A<=l){if(r.strokeStyle=g,r.lineWidth=1.5,r.beginPath(),o){const L=Math.round(A)+.5;r.moveTo(L,0),r.lineTo(L,p)}else{const L=Math.round(A)+.5;r.moveTo(0,L),r.lineTo(p,L)}r.stroke()}}function jr(t,e){return Math.round(t.originPx+e*t.pxPerMM)+.5}function Qn(t,e,o,i){const{ctx:n,horizontal:r,paperLengthMM:s}=t;n.strokeStyle=o,n.fillStyle=o,n.globalAlpha=i?.32:1,n.lineWidth=1,n.font="9px ui-monospace, Menlo, monospace",n.textBaseline="top";for(const l of e){if((l.mm<0||l.mm>s)!==i)continue;const u=jr(t,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 Jn(t,e,o){const{ctx:i,horizontal:n,thickness:r,viewportPx:s}=t,l=jr(t,e);l<=0||l>=s||(i.strokeStyle=o,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 mc=':host{display:block;width:100%;height:100%}:host{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);--pd-success: #16a34a;--pd-text-regular: #606266;--pd-fill-light: #f5f7fa;height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.pd-form{display:flex;flex-direction:column;gap:10px;font-size:12px;color:var(--pd-text, #303133)}.pd-field{display:flex;flex-direction:column;gap:4px}.pd-label{font-size:11px;color:var(--pd-text-muted, #909399);display:inline-flex;align-items:center;position:relative;justify-content:space-between;gap:6px}.pd-label-t{display:inline-flex;align-items:center;gap:4px;min-width:0}.pd-reset-btn{flex:none;width:15px;height:15px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-faint, #b4b9c4);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:color .14s ease,border-color .14s ease,background .14s ease}.pd-reset-btn.is-dirty{color:var(--pd-text, #2a2e37)}.pd-reset-btn:hover{color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.pd-help{position:static;display:inline-flex;align-items:center;justify-content:center;flex:none;width:13px;height:13px;margin-left:4px;padding:0;border:1px solid var(--pd-border, #d9dde6);border-radius:50%;background:transparent;color:var(--pd-text-muted, #909399);font-size:9px;line-height:1;cursor:help}.pd-help:before{content:"?";font-weight:600}.pd-help:hover,.pd-help:focus-visible{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF)}.pd-help:after{content:attr(data-tip);position:absolute;top:calc(100% + 6px);left:0;z-index:120;width:196px;padding:5px 7px;border-radius:4px;background:#1e2330e0;color:#fff;font-size:12px;font-weight:400;line-height:1.45;text-align:left;white-space:normal;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .15s ease}.pd-help:hover:after,.pd-help:focus:after{opacity:1;visibility:visible}.pd-hover-tip{position:fixed;z-index:9999;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:#2a2e37eb;color:#fff;font-size:12px;line-height:1.4;width:max-content;max-width:calc(100vw - 16px);box-sizing:border-box;overflow-wrap:anywhere;pointer-events:none}.pd-input,.pd-select,textarea.pd-input{width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);color:inherit;font:inherit;box-sizing:border-box;transition:border-color .14s ease,box-shadow .14s ease}.pd-input:hover,.pd-select:hover{border-color:var(--pd-text-faint, #b4b9c4)}textarea.pd-input{height:auto;min-height:48px;resize:vertical}.pd-input:focus,.pd-select:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.pd-select{appearance:auto}.pd-switch{appearance:none;width:32px;height:18px;margin:0;border:1px solid var(--pd-border, #dcdfe6);border-radius:999px;background:#dcdfe6;position:relative;cursor:pointer;transition:background .2s,border-color .2s}.pd-switch:checked{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF)}.pd-switch:after{content:"";position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .2s}.pd-switch:checked:after{transform:translate(14px)}.pd-range{width:100%;accent-color:var(--pd-accent, #165DFF)}.pd-radio-group,.pd-checkbox-group{display:flex;flex-wrap:wrap;gap:6px}.pd-radio-group--2col{display:grid;grid-template-columns:1fr 1fr}.pd-radio-group--2col>.pd-radio{width:60%;justify-content:flex-start}.pd-radio,.pd-checkbox{display:inline-flex;align-items:center;gap:4px;min-height:24px;padding:0 7px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-input-bg, #fff);cursor:pointer;transition:border-color .14s ease,background .14s ease,color .14s ease}.pd-radio:has(input:checked),.pd-checkbox:has(input:checked){color:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);background:#165dff0f}.pd-button-group{display:inline-flex;gap:4px}.pd-button,.pd-tab{display:inline-flex;align-items:center;justify-content:center;gap:4px;min-height:26px;padding:3px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font:inherit;cursor:pointer;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-button:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-button.primary{background:var(--pd-accent, #165DFF);border-color:var(--pd-accent, #165DFF);color:#fff}.pd-button.danger{background:#f56c6c;border-color:#f56c6c;color:#fff}.pd-button.small{min-height:22px;padding:1px 6px;font-size:11px}.pd-button:disabled{opacity:.55;cursor:not-allowed}.pd-tabs{display:flex;flex-direction:column;min-height:0}.pd-tab-bar{display:flex;gap:4px;padding:8px 12px 0;border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-tab{border:0;border-bottom:2px solid transparent;border-radius:5px 5px 0 0;background:transparent;transition:color .14s ease,background .14s ease}.pd-tab-bar .pd-tab:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pd-tab.active{color:var(--pd-accent, #165DFF);border-bottom-color:var(--pd-accent, #165DFF);background:transparent;font-weight:600}.pd-tab-pane{min-height:0;overflow:auto}.pd-divider{margin:6px 0;font-size:11px;color:var(--pd-text-muted, #909399)}.pd-empty{margin:16px 0;color:var(--pd-text-muted, #909399);text-align:center}.pd-dialog-overlay{position:fixed;inset:0;z-index:2000;display:grid;place-items:center;padding:16px;background:#00000073}.pd-dialog{display:flex;flex-direction:column;width:min(950px,90vw);max-height:90vh;overflow:hidden;background:var(--pd-surface, #fff);border-radius:12px;box-shadow:var(--pd-shadow-md, 0 12px 40px rgba(23, 32, 60, .18))}.pd-dialog-large{width:min(950px,90vw)}.pd-dialog-header,.pd-dialog-footer{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 16px}.pd-dialog-header{border-bottom:1px solid var(--pd-border-soft, #ebeef5)}.pd-dialog-footer{justify-content:flex-end;border-top:1px solid var(--pd-border-soft, #ebeef5)}.pd-close{width:22px;height:22px;border:0;background:transparent;color:var(--pd-text-muted, #909399);font-size:16px;cursor:pointer}.pd-icon{display:inline-flex;width:14px;height:14px}.tb-more-panel{min-width:244px}.designer-container{scrollbar-width:thin;scrollbar-color:var(--pd-scrollbar, rgba(23, 32, 60, .18)) transparent}.designer-container ::-webkit-scrollbar{width:9px;height:9px}.designer-container ::-webkit-scrollbar-track{background:transparent}.designer-container ::-webkit-scrollbar-thumb{background:var(--pd-scrollbar-thumb, rgba(23, 32, 60, .16));border-radius:999px;border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-thumb:hover{background:var(--pd-scrollbar-thumb-hover, rgba(23, 32, 60, .3));border:2px solid transparent;background-clip:content-box}.designer-container ::-webkit-scrollbar-corner{background:transparent}.designer-container button:focus-visible,.designer-container [tabindex]:focus-visible,.designer-container .pd-tab:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}@media(prefers-reduced-motion:reduce){.designer-container *,.designer-container *:before,.designer-container *:after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}.help-button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;cursor:pointer;transition:background-color .15s}.help-button:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-icon{display:flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--pd-accent, #165DFF);color:#fff;font-size:12px;font-weight:600;line-height:1}.tb-dd{position:relative;display:inline-flex}.tb-dd-trigger{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:3px;font-size:12px;transition:background .14s ease,color .14s ease}.tb-dd-trigger:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-dd-trigger:disabled{opacity:.32;cursor:default}.tb-dd-trigger.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.tb-dd-arrow{opacity:.6;transition:transform .14s ease}.tb-dd-arrow.up{transform:rotate(180deg)}.tb-dd-trigger[data-tip]{position:relative}.tb-dd-trigger[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.tb-dd-trigger[data-tip]:hover:after{opacity:1}.tb-dd-panel{position:absolute;top:34px;left:0;background:var(--pd-surface, #fff);border:1px solid var(--pd-border, #d9dde6);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));z-index:200}.tb-dd-panel.is-hidden{display:none}.tb-more-group{flex-shrink:0}.tb-more-menu{display:flex;flex-direction:column;gap:8px;padding:8px;max-height:min(70vh,520px)}.tb-more-item{display:flex;flex-direction:column;gap:4px}.tb-menu-label{font-size:11px;color:var(--pd-text-muted, #8b909c);padding-left:2px}.tb-more-slot{display:flex;align-items:center}.designer-toolbar{display:flex;align-items:center;gap:2px;padding:0 12px;height:50px;background:var(--pd-surface, #ffffff);border-bottom:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 1px 2px #17203c0a,0 6px 16px -12px #17203c40;flex-shrink:0;position:relative;z-index:100}.tb-ou{flex-shrink:0}.designer-toolbar>*{flex-shrink:0}.designer-toolbar>.tb-brand{flex-shrink:1;min-width:0}.tb-title,.tb-title-name,.tb-title-sub,.tb-btn-text,.tb-zoom{white-space:nowrap}.designer-toolbar.is-tight .tb-title{min-width:0;overflow:hidden}.designer-toolbar.is-tight .tb-title-name,.designer-toolbar.is-tight .tb-title-sub{overflow:hidden;text-overflow:ellipsis}.tb-group{display:flex;align-items:center;gap:2px;padding:0 8px}.tb-group+.tb-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.tb-btn{height:30px;min-width:30px;padding:0 8px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:background .14s ease,color .14s ease,border-color .14s ease,box-shadow .14s ease}.tb-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.tb-btn:active{background:var(--pd-border-soft, #e9ecf2)}.tb-btn:disabled{opacity:.32;cursor:default;background:transparent;color:var(--pd-text-faint, #b4b9c4)}.tb-btn.danger:hover:not(:disabled){color:var(--pd-accent-secondary, #f56c6c);background:var(--pd-danger-soft, rgba(245, 108, 108, .1))}.tb-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));font-weight:600}.tb-btn .dot{width:6px;height:6px;border-radius:50%;background:var(--pd-text-faint, #b4b9c4);display:inline-block;transition:background .14s ease,box-shadow .14s ease}.tb-btn.on .dot{background:var(--pd-accent, #165DFF);box-shadow:0 0 0 3px #165dff1f}.tb-icon{font-size:15px;line-height:1}[data-tip]{position:relative}[data-tip]:after{content:attr(data-tip);position:absolute;bottom:-32px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}[data-tip]:hover:after{opacity:1}.tb-mark{width:28px;height:28px;margin-right:2px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;background:linear-gradient(150deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));box-shadow:0 3px 8px #165dff47,inset 0 1px #ffffff38;flex-shrink:0}.tb-mark svg{width:16px;height:16px}.tb-title{display:flex;flex-direction:column;line-height:1.2;padding-left:6px}.tb-title-name{font-size:13px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.2px}.tb-title-sub{font-size:10px;color:var(--pd-text-muted, #8b909c);letter-spacing:.8px}.tb-zoom{font-size:12px;color:var(--pd-text, #2a2e37);font-variant-numeric:tabular-nums;min-width:46px;text-align:center}.tb-spacer{flex:1}.tb-group .tb-dd-trigger{height:30px;min-width:30px;padding:0 8px}.tb-btn-text{font-size:12px}.tb-menu{padding:8px;display:flex;flex-direction:column;gap:4px}.tb-menu-rows{width:148px}.tb-menu-label{padding:2px 4px;font-size:11px;color:var(--pd-text-muted, #8b909c)}.tb-menu-grid{display:grid;grid-template-columns:repeat(4,32px);gap:2px;margin-bottom:4px}.tb-menu-row{justify-content:flex-start;width:100%}.btn-primary,.btn-secondary{height:32px;padding:0 16px;border-radius:7px;font-size:13px;font-weight:600;cursor:pointer;transition:filter .14s ease,background .14s ease,border-color .14s ease,box-shadow .14s ease}.btn-secondary{background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text-muted, #606266);border:1px solid var(--pd-border, #d9dde6)}.btn-secondary:hover{border-color:var(--pd-accent, #165DFF);color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .06))}.btn-primary{background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF));color:#fff;border:none;box-shadow:0 3px 10px #165dff47,inset 0 1px #ffffff2e}.btn-primary:hover{filter:brightness(1.07);box-shadow:0 5px 14px #165dff57,inset 0 1px #ffffff2e}.btn-primary:active{filter:brightness(.97)}.font-select{position:relative}.font-select-input{display:block;width:100%}.font-select-list{position:absolute;top:calc(100% + 4px);left:0;width:100%;min-width:150px;z-index:200;margin:0;max-height:200px;overflow-y:auto;padding:2px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #ffffff);box-shadow:var(--pd-shadow-md, 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07));list-style:none}.font-select-list.is-up{top:auto;bottom:calc(100% + 4px)}.font-select-option{padding:4px 6px;border-radius:4px;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}.font-select-option.is-active{background:var(--pd-sidebar-hover, #f0f3f9)}.font-select-option.is-muted{color:var(--pd-text-muted, #8b909c)}.pd-stepper{display:flex;align-items:center;width:100%}.pd-step-btn{width:26px;height:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .14s ease,border-color .14s ease,color .14s ease}.pd-step-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-step-btn:disabled{opacity:.45;cursor:not-allowed}.pd-step-minus{border-radius:6px 0 0 6px;border-right:none}.pd-step-plus{border-radius:0 6px 6px 0;border-left:none}.pd-step-input.pd-input{border-radius:0;min-width:0;flex:1;text-align:center;-moz-appearance:textfield}.pd-step-input.pd-input::-webkit-outer-spin-button,.pd-step-input.pd-input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.preset-color-trigger{display:flex;align-items:center;width:100%;min-height:26px;padding:1px;border:1px solid var(--pd-border, #d9dde6);border-radius:6px;background:var(--pd-surface, #fff);cursor:pointer;transition:border-color .14s ease,box-shadow .14s ease}.preset-color-trigger:hover,.preset-color-trigger[aria-expanded=true]{border-color:var(--pd-accent, #165DFF)}.preset-color-trigger:focus-visible{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.preset-color-swatch{width:100%;height:22px;border-radius:4px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.preset-color-panel{position:fixed;z-index:3000;width:190px;padding:10px;border:1px solid var(--pd-border, #d9dde6);border-radius:8px;background:var(--pd-surface, #fff);box-shadow:0 8px 24px #17203c29}.picker-preview{display:flex;align-items:center;gap:8px;margin-bottom:8px}.picker-current{flex:0 0 26px;height:24px;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;background-image:linear-gradient(45deg,#e9ecef 25%,transparent 25%,transparent 75%,#e9ecef 75%);background-size:8px 8px;background-position:0 0,4px 4px}.picker-current.is-empty{position:relative;background-color:#fff}.picker-current.is-empty:after{content:"";position:absolute;inset:3px;background:linear-gradient(to top right,transparent calc(50% - .7px),#f53f3f calc(50% - .7px),#f53f3f calc(50% + .7px),transparent calc(50% + .7px));border-radius:3px}.picker-hex{flex:1;min-width:0;height:24px;padding:0 6px;border:1px solid var(--pd-border, #d9dde6);border-radius:5px;color:var(--pd-text, #303133);font:inherit;font-size:11px;text-transform:uppercase}.picker-hex:focus{outline:none;border-color:var(--pd-accent, #165DFF);box-shadow:0 0 0 2px #165dff1f}.picker-area{position:relative;height:100px;border:1px solid rgb(0 0 0 / 12%);border-radius:6px;overflow:hidden;cursor:crosshair;touch-action:none;background:linear-gradient(to top,#000,transparent),linear-gradient(to right,#fff,hsl(var(--picker-hue) 100% 50%))}.picker-handle{position:absolute;width:12px;height:12px;border:2px solid #fff;border-radius:50%;transform:translate(-50%,-50%);box-shadow:0 0 3px #00000073;pointer-events:none}.picker-hue{width:100%;height:14px;margin:10px 0 0;appearance:none;border:1px solid rgb(0 0 0 / 12%);border-radius:999px;background:linear-gradient(to right,red,#ff0,#0f0,#0ff,#00f,#f0f,red);cursor:pointer}.picker-hue::-webkit-slider-thumb{appearance:none;width:12px;height:12px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-hue::-moz-range-thumb{width:8px;height:8px;border:2px solid #fff;border-radius:50%;background:transparent;box-shadow:0 0 3px #00000073}.picker-heading{display:flex;align-items:center;justify-content:space-between;margin-top:10px;margin-bottom:6px;font-size:11px;color:var(--pd-text-muted, #909399)}.picker-clear{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border:none;border-radius:4px;background:transparent;font-size:11px;line-height:1;color:var(--pd-text-muted, #909399);cursor:pointer}.picker-clear:hover:not(:disabled){background:#0000000f;color:var(--pd-danger, #f53f3f)}.picker-clear:disabled{opacity:.45;cursor:not-allowed}.preset-color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px}.preset-color-item{width:22px;height:22px;padding:0;border:1px solid rgb(0 0 0 / 12%);border-radius:5px;cursor:pointer}.preset-color-item.active{box-shadow:0 0 0 2px #fff,0 0 0 3px var(--pd-accent, #165DFF)}.format-toolbar{display:flex;align-items:center;gap:2px;flex-shrink:0;min-width:0}.ft-group{display:flex;align-items:center;gap:2px;padding:0 8px;flex-shrink:0}.ft-group+.ft-group{border-left:1px solid var(--pd-border-soft, #e9ecf2)}.ft-btn{height:28px;min-width:28px;padding:0 5px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:4px;transition:background .14s ease,color .14s ease}.ft-btn:hover:not(:disabled){color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.ft-btn:disabled{opacity:.32;cursor:default}.ft-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.ft-btn-text{font-size:12px}.ft-btn[data-tip]{position:relative}.ft-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:34px;left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:100}.ft-btn[data-tip]:hover:after{opacity:1}.ft-font{width:150px}.ft-size{width:96px}.ft-font .font-select-input,.ft-size .pd-input,.ft-size .pd-step-btn{font-size:12px}.ft-color-btn{position:relative;width:28px;height:28px;display:inline-flex;margin-left:2px}.ft-color-btn.dim{opacity:.35}.ft-color-btn .preset-color-trigger{width:100%;height:100%;min-height:0;padding:0;border:1px solid transparent;border-radius:6px;background:transparent;align-items:flex-end;justify-content:center}.ft-color-btn .preset-color-trigger:hover,.ft-color-btn .preset-color-trigger[aria-expanded=true]{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-color-btn .preset-color-swatch{width:16px;height:4px;margin-bottom:3px;border-radius:1px;background-image:none;border-bottom:1px solid var(--pd-text-faint, #b4b9c4)}.ft-glyph{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding-bottom:7px;font-size:13px;font-weight:700;color:var(--pd-text, #2a2e37);pointer-events:none}.ft-border-panel{width:196px;padding:10px;display:flex;flex-direction:column;gap:8px}.ft-align-panel{padding:6px;display:flex;flex-direction:column;gap:4px}.ft-align-row{display:grid;grid-template-columns:repeat(3,36px);gap:4px}.ft-border-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-cell-btn{height:30px;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:6px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-cell-btn:hover:not(:disabled){background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-border-soft, #e9ecf2)}.ft-cell-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-cell-btn:disabled{opacity:.32;cursor:default}.ft-cell-btn .g-faint{fill:none;stroke:var(--pd-text-faint, #b4b9c4);stroke-width:1;stroke-dasharray:2 2}.ft-cell-btn .g-solid{stroke:currentColor;stroke-width:1.6}.ft-cell-btn[data-tip],.ft-style-btn[data-tip]{position:relative}.ft-cell-btn[data-tip]:after,.ft-style-btn[data-tip]:after{content:attr(data-tip);position:absolute;top:calc(100% + 4px);left:50%;transform:translate(-50%);padding:4px 8px;font-size:12px;font-weight:400;color:#fff;background:#1e2330e0;border-radius:4px;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s ease;z-index:210}.ft-cell-btn[data-tip]:hover:after,.ft-style-btn[data-tip]:hover:after{opacity:1}.ft-style-row{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.ft-style-btn{height:22px;display:inline-flex;align-items:center;justify-content:center;padding:0 4px;border:1px solid transparent;border-radius:5px;background:transparent;color:var(--pd-text, #2a2e37);cursor:pointer}.ft-style-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.ft-style-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));border-color:#165dff59}.ft-style-line{width:100%;height:0}.ft-border-style-row{display:flex;align-items:center;gap:6px}.ft-line-width{width:96px}.ft-edge-label{font-size:12px;color:var(--pd-text-muted, #8b909c);white-space:nowrap;flex-shrink:0}.layer-panel{border-top:1px solid var(--pd-border);padding:8px 12px;height:100%;box-sizing:border-box;overflow-y:auto}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;margin-bottom:8px}.layer-item{display:flex;align-items:center;gap:6px;padding:4px 6px;margin-bottom:2px;border-radius:4px;cursor:pointer;font-size:12px;transition:background .1s}.layer-item:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.layer-item.active{background:#165dff1a;color:var(--pd-accent, #165DFF);box-shadow:inset 2px 0 0 var(--pd-accent, #165DFF)}.layer-icon{width:18px;text-align:center;font-size:12px;color:var(--pd-text-muted, #909399)}.layer-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text, #303133)}.layer-zone{flex-shrink:0;padding:0 4px;font-size:10px;line-height:14px;color:var(--pd-ink-green, #67c23a);background:#67c23a1a;border-radius:3px}.layer-zindex{font-size:10px;color:var(--pd-text-muted, #909399);font-variant-numeric:tabular-nums}.layer-actions{display:flex;gap:4px;margin-top:8px}.field-tree-panel{padding:0}.panel-title{font-size:11px;color:var(--pd-text-muted);text-transform:uppercase;letter-spacing:.5px;padding:4px 0 8px;margin-bottom:8px;border-bottom:1px solid var(--pd-border)}.search-input{margin-bottom:8px}.tree-container{overflow-y:auto;min-height:0}.field-group-header{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .1s}.field-group-header:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.field-group-header.is-list{color:var(--pd-accent, #165DFF);font-weight:500}.expand-icon{width:12px;font-size:8px;flex-shrink:0;color:var(--pd-text-muted, #909399)}.field-row{display:flex;align-items:center;gap:4px;padding:5px 8px;border-radius:4px;font-size:13px;color:var(--pd-text, #303133);cursor:grab;-webkit-user-select:none;user-select:none;transition:background .1s}.field-row:hover{background:var(--pd-sidebar-hover, #f0f2f5)}.node-icon{font-size:14px;flex-shrink:0;filter:saturate(.6);opacity:.9}.node-meta{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:center;column-gap:4px;row-gap:1px}.node-label{flex:1 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.node-key{flex:0 1 auto;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--pd-text-muted, #909399)}.group-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.copy-hint{flex-shrink:0;margin-left:auto;font-size:11px;color:var(--pd-accent, #165DFF);white-space:nowrap}.left-panel{width:248px;min-width:248px;background:var(--pd-sidebar, #ffffff);border-right:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.left-panel.collapsed{width:36px;min-width:36px;border-right:1px solid var(--pd-border-soft, #e9ecf2)}.left-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.lc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.lc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.lc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.left-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.left-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.left-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.left-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.left-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.material-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;align-content:start}.material-grid>.panel-title,.material-grid>.material-group-title,.material-grid>.material-card--wide{grid-column:1 / -1}.material-grid>.panel-title,.material-grid>.material-group-title{margin-bottom:0}.material-grid>.material-card{margin-bottom:0;min-width:0}.panel-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:2px 2px 8px;margin-bottom:10px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-group-title{font-size:11px;color:var(--pd-text-muted, #8b909c);letter-spacing:.6px;padding:4px 2px 6px;margin:2px 0 8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.material-card{position:relative;display:flex;align-items:center;gap:9px;padding:7px 8px;border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:7px;background:transparent;cursor:grab;-webkit-user-select:none;user-select:none;transition:background .16s ease,border-color .16s ease,transform .16s ease,box-shadow .16s ease}.material-card:before{content:"";position:absolute;left:0;top:50%;width:2px;height:0;border-radius:2px;background:var(--pd-accent, #165DFF);transform:translateY(-50%);transition:height .16s ease}.material-card:hover{background:var(--pd-hover-tint, #ecf5ff);border-color:#165dff73;transform:translate(2px)}.material-card:hover:before{height:56%}.material-card:active{cursor:grabbing;transform:translate(2px) scale(.985)}.material-icon{width:30px;height:30px;border:0;border-radius:7px;display:flex;align-items:center;justify-content:center;color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09));box-shadow:inset 0 0 0 1px #165dff1f;flex-shrink:0;transition:background .16s ease,color .16s ease,box-shadow .16s ease,transform .16s ease}.material-card:hover .material-icon{background:var(--pd-accent, #165DFF);color:#fff;box-shadow:0 2px 6px #165dff47}.material-card:active .material-icon{transform:scale(.92)}.material-label{min-width:0;flex:1;font-size:12.5px;font-weight:500;line-height:1.3;color:var(--pd-text, #2a2e37);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:color .16s ease}.material-card:hover .material-label{color:var(--pd-accent, #165DFF)}.print-image{width:100%;height:100%;overflow:hidden}.print-image img{width:100%;height:100%;display:block}.table-ctx-menu{position:fixed;z-index:3000;min-width:140px;padding:4px 0;background:var(--pd-surface, #fff);border:1px solid var(--pd-menu-border, #dcdfe6);border-radius:4px;box-shadow:0 2px 12px #00000026;font-size:13px}.menu-item{padding:5px 14px;cursor:pointer;color:var(--pd-menu-text, #333)}.menu-item:hover{background:var(--pd-menu-hover, #f5f7fa)}.menu-item.disabled{color:var(--pd-menu-disabled, #c0c4cc);cursor:not-allowed}.menu-item.active{color:var(--pd-accent, #165DFF)}.menu-divider{height:1px;margin:4px 0;background:var(--pd-menu-divider, #ebeef5)}.menu-group-title{padding:4px 14px;font-size:12px;color:var(--pd-menu-muted, #909399)}.cell-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-barcode svg{max-width:100%;max-height:100%}.cell-barcode img{max-width:100%;max-height:100%}.cell-barcode-fallback{font-style:italic;opacity:.6}.cell-image{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.cell-image img{max-width:100%;max-height:100%;display:block}.image-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#bbb;font-size:12px;border:1px dashed #ddd;box-sizing:border-box}.print-table{position:relative;width:100%;height:100%}.print-table table{border-collapse:collapse;table-layout:fixed;width:100%}.print-table td{box-sizing:border-box;word-break:normal;overflow-wrap:break-word}.cell-selected{outline:2px solid #165DFF;outline-offset:-2px;background-color:#165dff14}.row-data-bg{background-image:repeating-linear-gradient(45deg,rgba(22,93,255,.04) 0 6px,transparent 6px 12px)}.data-placeholder{color:#909399;font-style:italic}.row-badges{position:absolute;left:-16px;top:0;width:14px}.row-badge{position:absolute;width:14px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#909399;background:#f5f7fa;border-radius:2px}.col-resize-layer{position:absolute;inset:0;pointer-events:none;z-index:3}.col-resize-handle{position:absolute;top:0;bottom:0;width:6px;transform:translate(-50%);cursor:col-resize;pointer-events:auto}.col-resize-handle:after{content:"";position:absolute;top:0;bottom:0;left:50%;border-left:1px solid transparent}.col-resize-handle:hover:after,.col-resize-handle.dragging:after{border-left-color:var(--pd-accent, #165DFF)}.print-barcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-barcode svg{max-width:100%;max-height:100%}.print-qrcode{width:100%;height:100%;display:flex;align-items:center;justify-content:center;overflow:hidden}.print-qrcode img{max-width:100%;max-height:100%}.print-html,.page-number-element{width:100%;height:100%;overflow:hidden}.print-element{box-sizing:border-box;cursor:pointer;-webkit-user-select:none;user-select:none}.extension-placeholder{display:flex;align-items:center;justify-content:center;width:100%;height:100%;box-sizing:border-box;padding:2px;font-size:11px;line-height:1.4;text-align:center;color:var(--pd-text-muted, #8b909c);background:repeating-linear-gradient(45deg,#f4f6fa,#f4f6fa 6px,#fff 6px 12px);overflow:hidden}.element-margin-guide{position:absolute;box-sizing:border-box;pointer-events:none}.print-element.design-mode{outline:1px dashed #C3C9D6}.print-element.design-mode.zone-header,.print-element.design-mode.zone-footer{outline:1px dashed var(--pd-ink-green, #67c23a)}.print-element.selected{outline:1.5px solid var(--pd-accent, #165DFF);background:#165dff0a}.print-element.previewed{outline:1.5px solid rgba(22,93,255,.5);background:#165dff1a}.print-element.design-mode:hover{outline:1px dashed var(--pd-accent, #165DFF)}.print-element.locked{cursor:not-allowed}.print-element.locked:not(.selected){outline:1.5px dashed #999}.print-element.hidden{opacity:.3;pointer-events:none}.print-element.drag-ghost{opacity:.4}.drag-preview{position:absolute;inset:0;border:2px dashed var(--pd-accent, #165DFF);pointer-events:none;z-index:1000;box-sizing:border-box}.selected-indicator{position:absolute;top:-18px;left:0;font-size:10px;white-space:nowrap;pointer-events:none;z-index:20}.position-label{background:var(--pd-accent, #165DFF);color:#fff;padding:1px 6px;border-radius:3px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:10px;font-variant-numeric:tabular-nums;letter-spacing:0;box-shadow:0 2px 6px #00000026}.resize-handles{position:absolute;inset:0;pointer-events:none}.resize-handle{position:absolute;width:7px;height:7px;background:var(--pd-handle, #165DFF);border:1.5px solid #fff;border-radius:2px;box-sizing:border-box;transform:translate(-50%,-50%);box-shadow:0 1px 3px #0000002e;z-index:10;pointer-events:auto}.handle-nw{top:0;left:0;cursor:nw-resize}.handle-n{top:0;left:50%;cursor:n-resize}.handle-ne{top:0;left:100%;cursor:ne-resize}.handle-e{top:50%;left:100%;cursor:e-resize}.handle-se{top:100%;left:100%;cursor:se-resize}.handle-s{top:100%;left:50%;cursor:s-resize}.handle-sw{top:100%;left:0;cursor:sw-resize}.handle-w{top:50%;left:0;cursor:w-resize}.paper-wrapper{display:block}.hiprint-printPaper{transition:transform .15s ease-out}.zone-layer{box-sizing:border-box}.zone-layer.zone-header.design-mode,.zone-layer.zone-footer.design-mode{outline:1px dashed var(--pd-ink-green, #67c23a);background:#67c23a0a}.zone-layer.zone-content.design-mode{outline:1px dashed #C3C9D6}.zone-label{position:absolute;top:2px;right:4px;font-size:9px;color:#909399;pointer-events:none;-webkit-user-select:none;user-select:none}.zone-resize-handle{position:absolute;left:0;width:100%;height:6px;cursor:ns-resize;z-index:5}.zone-resize-handle.handle-bottom{bottom:-3px}.zone-resize-handle.handle-top{top:-3px}.zone-resize-handle:hover{background:#10b98140}.zone-height-tip{position:absolute;right:4px;top:-22px;padding:1px 6px;font-size:11px;color:#fff;background:#10b981;border-radius:3px;white-space:nowrap;pointer-events:none}.design-background{position:absolute;z-index:0;overflow:hidden;pointer-events:none}.design-background img{display:block;width:100%;height:100%;object-fit:fill;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.grid-bg{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:0}.snap-indicator{position:absolute;width:6px;height:6px;background:var(--pd-accent, #165DFF);border-radius:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;animation:snap-pulse-3160f418 .3s ease-out}@keyframes snap-pulse-3160f418{0%{transform:translate(-50%,-50%) scale(2);opacity:.5}to{transform:translate(-50%,-50%) scale(1);opacity:0}}.watermark-layer{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;overflow:hidden;pointer-events:none}.watermark-tile{position:absolute;pointer-events:none}.adsorb-guide{position:absolute;pointer-events:none;z-index:9999}.adsorb-guide.guide-vertical{border-left:1px dashed var(--pd-accent-secondary, #f56c6c)}.adsorb-guide.guide-horizontal{border-top:1px dashed var(--pd-accent-secondary, #f56c6c)}.manual-guide{position:absolute;pointer-events:auto;z-index:9998;cursor:move}.manual-guide.guide-vertical{border-left:1px solid #3B82F6;width:0}.manual-guide.guide-horizontal{border-top:1px solid #3B82F6;height:0}.manual-guide:before{content:"";position:absolute;pointer-events:auto}.manual-guide.guide-vertical:before{top:0;bottom:0;left:50%;width:var(--guide-hit, 8px);transform:translate(-50%)}.manual-guide.guide-horizontal:before{left:0;right:0;top:50%;height:var(--guide-hit, 8px);transform:translateY(-50%)}.manual-guide:hover{border-color:#ef4444!important}.pd-ruler{position:absolute;display:block;pointer-events:auto;cursor:crosshair;z-index:1;background:var(--pd-ruler-bg, #f8f9fc)}.pd-ruler.is-horizontal{box-shadow:0 1px 0 var(--pd-border-soft, #e9ecf2)}.pd-ruler.is-vertical{box-shadow:1px 0 0 var(--pd-border-soft, #e9ecf2)}.canvas-area{flex:1;overflow-x:scroll;overflow-y:auto;scrollbar-gutter:stable;display:flex;background-color:var(--pd-canvas-bg, #e6e9f0);background-image:radial-gradient(circle,rgba(23,32,60,.13) 1px,transparent 1.2px);background-size:20px 20px;background-position:center;padding:44px 28px 32px 44px;position:relative}.canvas-scroll{display:flex;flex-direction:column;align-items:center;gap:20px;position:relative;flex:none;margin:auto;width:fit-content}.marquee-selection{position:fixed;border:1.5px solid rgba(22,93,255,.7);background:#165dff14;border-radius:2px;pointer-events:none;z-index:10000}.drop-hint{position:fixed;z-index:10002;pointer-events:none;padding:2px 8px;border-radius:10px;background:var(--pd-accent, #165dff);color:#fff;font-size:12px;line-height:18px;white-space:nowrap;box-shadow:0 2px 8px #0000002e}.context-menu{position:fixed;background:var(--pd-surface, #ffffff);border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;box-shadow:var(--pd-shadow-md, 0 10px 28px rgba(23, 32, 60, .12));padding:5px;z-index:10001;min-width:132px}.context-menu-item{padding:7px 12px;border-radius:5px;font-size:12.5px;cursor:pointer;color:var(--pd-text, #2a2e37);-webkit-user-select:none;user-select:none;transition:background .12s ease,color .12s ease}.context-menu-item:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.context-menu-item.disabled{color:var(--pd-text-faint, #b4b9c4);cursor:not-allowed}.context-menu-item.disabled:hover{background:transparent;color:var(--pd-text-faint, #b4b9c4)}.context-menu-sep{height:1px;background:var(--pd-border-soft, #e9ecf2);margin:5px 8px}.ruler-overlay{position:absolute;inset:0;pointer-events:none;z-index:60}.ruler-corner{position:absolute;top:0;left:0;width:22px;height:22px;background:var(--pd-ruler-bg, #f8f9fc);box-shadow:1px 1px 0 var(--pd-border-soft, #e9ecf2);z-index:2}.ruler-overlay .pd-ruler.is-horizontal{top:0;left:22px}.ruler-overlay .pd-ruler.is-vertical{top:22px;left:0}.ruler-guide-preview{position:fixed;pointer-events:none;z-index:9997}.ruler-guide-preview.guide-vertical{width:0;border-left:1px dashed var(--pd-accent, #165dff)}.ruler-guide-preview.guide-horizontal{height:0;border-top:1px dashed var(--pd-accent, #165dff)}.property-search{padding:0 0 10px;background:transparent}.property-group{border:1px solid var(--pd-border-soft, #e9ecf2);border-radius:8px;margin-bottom:10px;background:var(--pd-surface, #ffffff);overflow:hidden;transition:border-color .14s ease,box-shadow .14s ease}.property-group:last-child{margin-bottom:2px}.property-group.is-expanded{border-color:var(--pd-border-soft, #e9ecf2)}.group-header{display:flex;align-items:center;padding:9px 12px;cursor:pointer;-webkit-user-select:none;user-select:none;background:var(--pd-field-bg, #f4f6fa);transition:background .14s ease}.group-header:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.property-group.is-expanded .group-header{border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.group-icon{margin-right:8px;color:var(--pd-accent, #165DFF)}.group-title{flex:1;font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:.3px}.expand-icon{color:var(--pd-text-muted, #8b909c);font-size:10px}.group-content{padding:10px 12px 12px;background:var(--pd-surface, #ffffff)}.position-grid,.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.margin-grid{margin-top:8px}.pd-crop-note{margin:0 0 8px;font-size:12px;line-height:1.5;color:var(--pd-text-faint, #6b7280)}.pd-crop-preview{position:relative;overflow:hidden;margin-bottom:8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;line-height:0;width:fit-content;max-width:100%}.pd-crop-thumb{max-width:100%;max-height:96px;display:block}.pd-crop-win{position:absolute;border:1px solid #ff5a5a;box-shadow:0 0 0 999px #0000008c;pointer-events:none}.color-row{display:flex;gap:12px}.color-row>.pd-field{flex:1 1 0;min-width:0}.pd-rotate-row{display:flex;align-items:stretch;width:100%}.pd-rotate-btn{width:26px;flex-shrink:0;border:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);color:var(--pd-text, #2a2e37);font-size:14px;line-height:1;cursor:pointer;transition:background .14s ease,border-color .14s ease}.pd-rotate-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);border-color:var(--pd-text-faint, #b4b9c4)}.pd-rotate-btn:first-child{border-radius:6px 0 0 6px;border-right:none}.pd-rotate-btn:last-child{border-radius:0 6px 6px 0;border-left:none}.pd-rotate-stepper{flex:1;min-width:0}.pd-rotate-stepper .pd-step-minus,.pd-rotate-stepper .pd-step-plus{display:none}.pd-rotate-stepper .pd-step-input.pd-input{border-radius:0}.expression-editor{display:flex;height:450px;gap:0}.ee-nav{width:100px;background:var(--pd-sidebar);border-right:1px solid var(--pd-border);display:flex;flex-direction:column;flex-shrink:0}.ee-nav-title{padding:10px;border-bottom:1px solid var(--pd-border);font-weight:600;font-size:13px;color:var(--pd-text);text-align:center}.ee-nav-tabs{flex:1;display:flex;flex-direction:column;padding:6px;gap:4px}.ee-nav-tab{padding:8px 10px;border-radius:6px;cursor:pointer;font-size:12px;text-align:center;transition:all .2s}.ee-nav-tab.active{background:var(--pd-accent);color:#fff}.ee-nav-tab:not(.active){background:var(--pd-surface, white);border:1px solid var(--pd-border);color:var(--pd-text)}.ee-nav-tab:hover:not(.active){background:var(--pd-hover-tint, #ecf5ff);border-color:var(--pd-accent)}.ee-content{width:300px;display:flex;flex-direction:column;border-right:1px solid var(--pd-border);flex-shrink:0}.ee-content-search{padding:10px;border-bottom:1px solid var(--pd-border)}.ee-content-list{flex:1;padding:8px;overflow-y:auto;min-height:0}.ee-func-group{margin-bottom:12px}.ee-func-group-title{font-size:11px;font-weight:600;color:var(--pd-text-muted);padding:6px 10px;margin-bottom:2px;letter-spacing:.5px}.ee-field-group{display:flex;align-items:center;gap:4px;padding:6px 10px;font-size:12px;font-weight:600;color:var(--pd-text)}.ee-field-group.is-list{color:var(--pd-accent, #165DFF)}.ee-field-group-icon{font-size:13px;filter:saturate(.6)}.ee-list-item{padding:7px 10px;cursor:pointer;border-radius:4px;margin-bottom:2px;transition:background .15s}.ee-field-info{display:flex;flex-direction:column;gap:1px}.ee-field-info .ee-item-label{font-size:12px;color:var(--pd-text)}.ee-field-info .ee-item-key{font-size:10px;color:var(--pd-text-muted);font-family:monospace}.ee-field-item{display:flex;align-items:center;gap:6px}.ee-field-item .ee-field-info{flex:1;min-width:0}.ee-copy-btn{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:1px solid transparent;border-radius:4px;background:transparent;color:var(--pd-text-muted);cursor:pointer;transition:color .15s,background .15s,border-color .15s}.ee-copy-btn:hover{background:var(--pd-surface, white);border-color:var(--pd-border);color:var(--pd-accent)}.ee-copy-btn.is-copied{color:var(--pd-success, #16a34a)}.ee-list-item:hover{background:var(--pd-hover-tint, #ecf5ff)}.ee-editor{flex:1;display:flex;flex-direction:column;background:var(--pd-sidebar);min-width:0}.ee-editor-section{padding:12px;border-bottom:1px solid var(--pd-border)}.ee-editor-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:6px;text-transform:uppercase;letter-spacing:.5px}.ee-textarea{width:100%;border:1px solid var(--pd-border);border-radius:6px;padding:10px;font-family:monospace;font-size:13px;resize:vertical;box-sizing:border-box;min-height:100px}.ee-textarea:focus{outline:none;border-color:var(--pd-accent)}.ee-preview{padding:10px;background:var(--pd-bg);border:1px solid var(--pd-border);border-radius:6px;min-height:30px;font-size:13px;color:var(--pd-text);line-height:1.6;white-space:pre-wrap}.ee-preview-error{color:var(--pd-danger, #e53e3e);background:var(--pd-danger-bg, #fef2f2);border-color:var(--pd-danger-border, #fecaca)}.ee-help-section{flex:1;padding:12px;overflow-y:auto;min-height:0}.ee-help-title{font-size:11px;color:var(--pd-text-muted);margin-bottom:8px;text-transform:uppercase;letter-spacing:.5px}.ee-help-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.ee-help-card{border-radius:6px;padding:10px}.ee-help-card-title{font-size:12px;font-weight:600;margin-bottom:4px}.ee-help-card-content{font-size:11px;line-height:1.5;color:var(--pd-text)}.ee-help-field{background:var(--pd-help-field-bg, #f0f9ff);border:1px solid var(--pd-help-field-line, #bae6fd)}.ee-help-field .ee-help-card-title{color:var(--pd-help-field-ink, #0369a1)}.ee-help-function{background:var(--pd-help-function-bg, #f0fdf4);border:1px solid var(--pd-help-function-line, #bbf7d0)}.ee-help-function .ee-help-card-title{color:var(--pd-help-function-ink, #166534)}.ee-help-variable{background:var(--pd-help-variable-bg, #fefce8);border:1px solid var(--pd-help-variable-line, #fde68a)}.ee-help-variable .ee-help-card-title{color:var(--pd-help-variable-ink, #854d0e)}.ee-help-conditional{background:var(--pd-help-conditional-bg, #fdf2f8);border:1px solid var(--pd-help-conditional-line, #fbcfe8)}.ee-help-conditional .ee-help-card-title{color:var(--pd-help-conditional-ink, #9d174d)}.expression-editor{max-height:min(600px,80vh);overflow-y:auto;padding:16px}.col-width-row{display:flex;align-items:center;gap:8px;margin-bottom:4px;width:100%}.border-row{display:flex;gap:10px}.border-row .pd-field{flex:1;min-width:0}.advanced-row{display:flex;gap:16px}.group-help{flex:0 0 auto;width:18px;height:18px;margin-right:6px;padding:0;border:0;border-radius:50%;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:18px;cursor:pointer}.group-help:hover{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF)}.group-help:focus-visible{outline:2px solid var(--pd-accent, #165DFF);outline-offset:1px}.image-content-upload{display:flex;flex-direction:column;align-items:flex-start;gap:4px;margin-top:4px}.upload-tip{margin:0;font-size:11px;color:var(--pd-text-muted, #909399)}.cell-style-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 8px}.cell-font-field{grid-column:1 / -1;padding-bottom:8px}.border-style-row{display:flex;gap:6px;margin-bottom:8px}.border-presets{margin-bottom:8px}.merge-btns{display:flex;gap:8px}.merge-card{margin-top:8px;padding:8px;border:1px solid var(--pd-border, #dcdfe6);border-radius:6px}.merge-card-title{font-size:12px;font-weight:600;color:var(--pd-text, #303133);margin-bottom:8px}.merge-card-divider{height:1px;background:var(--pd-menu-divider, #ebeef5);margin:8px 0}.merge-card-hint{margin-top:6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #8b909c)}.watermark-config{padding:0 4px}.pd-hint{margin-left:8px;font-size:12px;color:#909399;min-width:32px}.design-background-config{padding:0 4px}.design-background-tip{margin:2px 0 6px;font-size:11px;line-height:1.4;color:var(--pd-text-muted, #909399)}.design-background-path{margin-bottom:6px;padding:4px 6px;font-size:11px;color:var(--pd-text-regular, #606266);background:var(--pd-fill-light, #f5f7fa);border-radius:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.design-background-actions{display:flex;gap:6px}.upload-label{cursor:pointer}.upload-label.disabled{opacity:.6;cursor:not-allowed}.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}.tiling-config{padding:0 4px}.tiling-switch{display:flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}.tiling-error{color:#f56c6c}.tiling-summary{color:var(--pd-text-regular, #606266)}.property-panel{width:304px;min-width:304px;background:var(--pd-sidebar, #ffffff);border-left:1px solid var(--pd-border-soft, #e9ecf2);display:flex;flex-direction:column;overflow:hidden;transition:width .18s ease}.property-panel.collapsed{width:36px;min-width:36px;border-left:1px solid var(--pd-border-soft, #e9ecf2)}.prop-collapsed{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:12px;flex:1}.pc-btn{width:26px;height:26px;border-radius:6px;border:1px solid transparent;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:12px;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .14s ease}.pc-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.pc-btn.on{color:var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.prop-head{display:flex;align-items:center;justify-content:space-between;height:42px;padding:0 12px;flex-shrink:0;border-bottom:1px solid var(--pd-border-soft, #e9ecf2)}.prop-title{font-size:12px;font-weight:600;color:var(--pd-text, #2a2e37);letter-spacing:1.2px;display:inline-flex;align-items:center;gap:7px}.prop-title:before{content:"";width:3px;height:12px;border-radius:2px;background:linear-gradient(180deg,var(--pd-accent-2, #3D7BFF),var(--pd-accent, #165DFF))}.collapse-btn{border:none;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:14px;cursor:pointer;width:24px;height:24px;border-radius:5px;transition:all .14s ease}.collapse-btn:hover{color:var(--pd-text, #2a2e37);background:var(--pd-sidebar-hover, #f0f3f9)}.prop-tabs{flex:1;display:flex;flex-direction:column;overflow:hidden}.prop-tabs .pd-tab-pane{flex:1;min-height:0;overflow-y:auto;padding:12px}.property-content{padding:0}.margin-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}.custom-size-grid{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:4px;width:100%}.custom-size-x{color:var(--pd-text-muted, #8b909c);font-size:12px}.pd-hint{margin:2px 0 6px;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1.4}.page-bg-row{display:flex;align-items:center;gap:8px}.page-bg-picker{flex:1;min-width:0}.status-bar{position:relative;display:flex;align-items:center;gap:20px;height:30px;padding:0 16px;background:var(--pd-surface, #ffffff);border-top:1px solid var(--pd-border-soft, #e9ecf2);box-shadow:0 -1px 2px #17203c08;font-size:11.5px;color:var(--pd-text-muted, #8b909c);-webkit-user-select:none;user-select:none;flex-shrink:0}.status-item{white-space:nowrap;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center}.coord{font-variant-numeric:tabular-nums;color:var(--pd-text, #2a2e37)}.status-paper{margin-left:auto;font-variant-numeric:tabular-nums;color:var(--pd-accent, #165DFF);font-weight:600}.status-version{font-variant-numeric:tabular-nums;color:var(--pd-text-muted, #8b909c)}.help-modal-overlay{position:fixed;inset:0;background:#00000080;display:flex;align-items:center;justify-content:center;z-index:1000}.help-modal{width:800px;max-width:90vw;height:600px;max-height:85vh;background:var(--pd-surface, #ffffff);border-radius:8px;box-shadow:0 4px 24px #00000026;display:flex;flex-direction:column;overflow:hidden}.help-modal-header{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--pd-border, #d9dde6)}.help-modal-title{margin:0;font-size:16px;font-weight:600;color:var(--pd-text, #2a2e37)}.help-modal-title-wrap{display:flex;align-items:center;gap:10px}.help-modal-project{padding:2px 8px;border-radius:4px;background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-size:12px;font-weight:500}.help-modal-close{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border:none;border-radius:4px;background:transparent;color:var(--pd-text-muted, #8b909c);font-size:20px;cursor:pointer;transition:all .15s}.help-modal-close:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.help-modal-body{flex:1;display:flex;overflow:hidden}.help-modal-sidebar{width:160px;padding:12px;border-right:1px solid var(--pd-border, #d9dde6);background:var(--pd-field-bg, #f4f6fa);overflow-y:auto}.help-tab{display:block;width:100%;padding:10px 12px;margin-bottom:4px;border:none;border-radius:4px;background:transparent;color:var(--pd-text, #2a2e37);font-size:13px;text-align:left;cursor:pointer;transition:all .15s}.help-tab:hover{background:var(--pd-sidebar-hover, #f0f3f9)}.help-tab.active{background:var(--pd-accent-soft, rgba(22, 93, 255, .09));color:var(--pd-accent, #165DFF);font-weight:500}.help-modal-content{flex:1;padding:20px;overflow-y:auto}.help-content{font-size:14px;line-height:1.6;color:var(--pd-text, #2a2e37)}.help-content h2{margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--pd-border-soft, #e9ecf2);font-size:18px;font-weight:600}.help-content h3{margin:20px 0 12px;font-size:15px;font-weight:600}.help-content p{margin:0 0 12px}.help-content ul,.help-content ol{margin:0 0 12px;padding-left:24px}.help-content li{margin-bottom:4px}.help-content code{padding:2px 6px;border-radius:3px;background:var(--pd-field-bg, #f4f6fa);font-family:SF Mono,Monaco,monospace;font-size:13px}.help-content pre{margin:0 0 12px;padding:12px;border-radius:4px;background:var(--pd-field-bg, #f4f6fa);overflow-x:auto}.help-content pre code{padding:0;background:transparent}.help-content table{width:100%;margin:0 0 12px;border-collapse:collapse}.help-content th,.help-content td{padding:8px 12px;border:1px solid var(--pd-border, #d9dde6);text-align:left}.help-content th{background:var(--pd-field-bg, #f4f6fa);font-weight:600}.help-content blockquote{margin:0 0 12px;padding:12px 16px;border-left:3px solid var(--pd-accent, #165DFF);background:var(--pd-accent-soft, rgba(22, 93, 255, .09))}.help-modal-enter-active,.help-modal-leave-active{transition:opacity .2s ease}.help-modal-enter-active .help-modal,.help-modal-leave-active .help-modal{transition:transform .2s ease}.help-modal-enter-from,.help-modal-leave-to{opacity:0}.help-modal-enter-from .help-modal,.help-modal-leave-to .help-modal{transform:scale(.95)}.page-tabs{display:flex;align-items:center;gap:8px;padding:4px 12px;background:var(--pd-sidebar, #fff);border-bottom:1px solid var(--pd-border, #d9dde6);flex-shrink:0}.page-tabs-list{display:flex;gap:4px;overflow-x:auto;align-items:center}.page-tab{padding:4px 12px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;white-space:nowrap;color:var(--pd-text, #2a2e37);font-size:12px}.page-tab.active{background:var(--pd-accent, #165DFF);color:#fff}.page-tab-rename{padding:4px 8px;width:96px;border:1px solid var(--pd-accent, #165DFF);border-radius:4px;font-size:12px;color:var(--pd-text, #2a2e37);outline:none}.page-tabs-actions{display:flex;gap:4px;margin-left:auto}.page-tabs-actions button{padding:4px 8px;border:1px solid var(--pd-border, #d9dde6);border-radius:4px;background:transparent;cursor:pointer;color:var(--pd-text-muted, #8b909c);font-size:12px;line-height:1}.page-tabs-actions button:disabled{opacity:.4;cursor:not-allowed}.designer-container{--pd-bg: #f3f5f9;--pd-surface: #ffffff;--pd-field-bg: #f4f6fa;--pd-sidebar: #ffffff;--pd-sidebar-hover: #f0f3f9;--pd-canvas-bg: #e6e9f0;--pd-paper: #FFFFFF;--pd-accent: #165DFF;--pd-accent-2: #3D7BFF;--pd-accent-soft: rgba(22, 93, 255, .09);--pd-accent-secondary: #f56c6c;--pd-danger-soft: rgba(245, 108, 108, .1);--pd-ink-green: #67c23a;--pd-text: #2a2e37;--pd-text-muted: #8b909c;--pd-text-faint: #b4b9c4;--pd-border: #d9dde6;--pd-border-soft: #e9ecf2;--pd-input-bg: #ffffff;--pd-hover-tint: #ecf5ff;--pd-danger: #e53e3e;--pd-danger-bg: #fef2f2;--pd-danger-border: #fecaca;--pd-menu-text: #333;--pd-menu-hover: #f5f7fa;--pd-menu-border: #dcdfe6;--pd-menu-divider: #ebeef5;--pd-menu-muted: #909399;--pd-menu-disabled: #c0c4cc;--pd-scrollbar: rgba(23, 32, 60, .18);--pd-scrollbar-thumb: rgba(23, 32, 60, .16);--pd-scrollbar-thumb-hover: rgba(23, 32, 60, .3);--pd-help-field-bg: #f0f9ff;--pd-help-field-line: #bae6fd;--pd-help-field-ink: #0369a1;--pd-help-function-bg: #f0fdf4;--pd-help-function-line: #bbf7d0;--pd-help-function-ink: #166534;--pd-help-variable-bg: #fefce8;--pd-help-variable-line: #fde68a;--pd-help-variable-ink: #854d0e;--pd-help-conditional-bg: #fdf2f8;--pd-help-conditional-line: #fbcfe8;--pd-help-conditional-ink: #9d174d;--pd-handle: #165DFF;--pd-ruler: #9aa1af;--pd-ruler-bg: #f8f9fc;--pd-ruler-cursor: #165DFF;--pd-radius: 6px;--pd-shadow-sm: 0 1px 2px rgba(23, 32, 60, .05);--pd-shadow-md: 0 2px 8px rgba(23, 32, 60, .06), 0 10px 28px rgba(23, 32, 60, .07);--pd-shadow-paper: 0 0 0 1px rgba(23, 32, 60, .05), 0 1px 2px rgba(23, 32, 60, .06), 0 8px 20px rgba(23, 32, 60, .08), 0 26px 60px rgba(23, 32, 60, .15);--pd-success: #16a34a;--pd-text-regular: #606266;--pd-fill-light: #f5f7fa;height:100%;display:flex;flex-direction:column;background:var(--pd-bg)}.designer-body{flex:1;display:flex;overflow:hidden}.designer-container.format-painting .canvas-area,.designer-container.format-painting .canvas-area *{cursor:copy!important}.print-html-preview{width:100%;height:100%;position:relative;background:#e9ebee}.print-html-preview-iframe{width:100%;height:100%;border:0;background:#fff}.print-html-preview-loading,.print-html-preview-error{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:#909399;font-size:14px}.print-html-preview-error{color:#f56c6c}.print-html-preview-warn{position:absolute;top:8px;left:12px;z-index:2;max-width:62%;padding:4px 8px;border:1px solid #e6a23c;border-radius:4px;background:#faecd1f0;color:#b88230;font-size:12px;line-height:1.5}.print-html-preview-zoom{position:absolute;top:8px;right:12px;z-index:2;display:flex;align-items:center;gap:4px;padding:3px 4px;border:1px solid var(--pd-border-soft, #ebeef5);border-radius:6px;background:#ffffffeb;box-shadow:0 1px 4px #00000014}.print-html-preview-zoom-btn{padding:2px 7px;border:0;border-radius:4px;background:transparent;color:var(--pd-text-muted, #909399);font-size:11px;line-height:18px;cursor:pointer;transition:color .14s ease,background .14s ease}.print-html-preview-zoom-btn:hover{background:var(--pd-sidebar-hover, #f0f3f9);color:var(--pd-text, #2a2e37)}.print-html-preview-zoom-btn.active{background:var(--pd-accent, #165DFF);color:#fff;font-weight:600}.print-html-preview-zoom-note{padding-right:4px;color:var(--pd-text-muted, #909399);font-size:11px}.print-html-preview-zoom-hint{color:#b88230;font-size:11px}.tiling-config .margin-grid,.tiling-config .custom-size-grid{display:block;grid-template-columns:none;gap:normal}.tiling-config .custom-size-x{display:inline;min-width:0;color:inherit}.pd-hint{min-width:auto}.watermark-config .pd-hint{min-width:32px;margin-left:8px;color:#909399}.tiling-config .tiling-error{color:#f56c6c}.tiling-config .tiling-summary{color:var(--pd-text-regular, #606266)}.pd-help{position:static}.pd-help:after{top:calc(100% + 6px);bottom:auto;left:0;transform:none;padding:5px 7px;white-space:normal;z-index:120}.page-tabs [data-tip]:after,.field-tree-panel [data-tip]:after{content:none}',no=20;function er(t){try{const e=JSON.parse(t);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}}const bc=".page-tabs, .field-tree-panel, .pd-dialog-overlay",xc=new Set(["z","y","a","c","x","v","d","g","1","l","r","e","t","b","0"]),tr="print-studio:left",or="print-studio:right";function ir(t){try{return localStorage.getItem(t)==="1"}catch{return!1}}function nr(t,e){try{localStorage.setItem(t,e?"1":"0")}catch{}}function di(t){let e=t;if(typeof e=="string")try{e=JSON.parse(e)}catch{return}if(Array.isArray(e))return e.filter(o=>!!o&&typeof o=="object"&&!Array.isArray(o));if(e&&typeof e=="object")return[e]}class Ye extends HTMLElement{root;store;format;unsub=null;unsubPluginUI=null;unsubDefinitions=null;pluginStyleEls=new Map;instanceDisposers=[];measureRaf=null;state={leftTab:"elements",leftCollapsed:!1,propTab:"page",propCollapsed:!1,openDd:null,openMore:!1,collapsedGroups:new Set,renamingPage:null};geom={originX:0,originY:0,viewW:0,viewH:0,paperScale:1};static active=null;docKeydown=null;docDragend=null;ro=null;roArea=null;toolbarRo=null;scrollPos={x:0,y:0};paneScroll=new Map;marquee={visible:!1,x:0,y:0,w:0,h:0};menu={visible:!1,x:0,y:0,flipX:0,flipY:0,targetId:null};guidePreview=null;zoneResizing=null;tableMenu={visible:!1,x:0,y:0};exprTarget=null;exprMountedFor=null;helpVisible=!1;helpInitialTab;unmountHelp=null;drag=null;snapTimer=null;hoverTipEl=null;hoverTipTimer=null;resize=null;raf=0;lastSelKey="";chromeKey="";_theme="auto";_themeConfig;systemDark=!1;themeMedia=null;onThemeMediaChange=()=>{this.systemDark=this.themeMedia?.matches??!1,this.applyTheme()};appliedThemeTokens=[];uploadImage;uploadDesignBackground;_designData;set designData(e){this._designData=di(e),this.repaint()}get designData(){return this._designData}_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=mc,this.root.appendChild(e),ve(a("div",{class:"designer-container",dataset:{test:"designer-container"},part:"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()}set showPreview(e){this.setAttribute("show-preview",String(e)),this.repaint()}set showSave(e){this.setAttribute("show-save",String(e)),this.repaint()}set theme(e){const o=e==="dark"||e==="light"?e:"auto";this._theme=o,this.setAttribute("theme",o),this.applyTheme()}get theme(){return this._theme}set themeConfig(e){const o=typeof e=="string"?er(e):e;this._themeConfig=o,o===void 0?this.removeAttribute("theme-config"):this.setAttribute("theme-config",JSON.stringify(o)),this.applyTheme()}get themeConfig(){return this._themeConfig}static contractVersion=Ai;static getHostContract(){return hi()}getHostContract(){return hi()}static get observedAttributes(){return[...Di]}attributeChangedCallback(e,o,i){if(e==="design-data"){this._designData=i===null?void 0:di(i),this.repaint();return}if(e==="theme"){this._theme=i==="dark"||i==="light"?i:"auto",this.applyTheme();return}if(e==="theme-config"){this._themeConfig=i?er(i):void 0,this.applyTheme();return}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.attachThemeMedia(),this.applyTheme(),this.store){this.applyFontFace(),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners();return}const e={},o=this.getAttribute("template");if(o)try{e.initialTemplate=JSON.parse(o)}catch{}const i=this.getAttribute("fields");if(i)try{e.initialFields=JSON.parse(i)}catch{}const n=this.getAttribute("design-data");n&&this._designData===void 0&&(this._designData=di(n)),this.store=new lr(e),this.format=new Ma(this.store),this.store.onSelectionChanged=()=>this.format.painterSyncSelection(),this.readChrome(),this.unsub=this.store.subscribe(()=>this.repaint()),this.attachDocKeys(),this.attachPluginUI(),this.attachInstanceListeners(),this.applyFontFace(),this.repaint(),this.measureRaf=requestAnimationFrame(()=>{this.measureRaf=null,this.measureRuler()})}attachThemeMedia(){typeof window>"u"||typeof window.matchMedia!="function"||(this.detachThemeMedia(),this.themeMedia=window.matchMedia("(prefers-color-scheme: dark)"),this.systemDark=this.themeMedia.matches,this.themeMedia.addEventListener("change",this.onThemeMediaChange))}detachThemeMedia(){this.themeMedia?.removeEventListener("change",this.onThemeMediaChange),this.themeMedia=null}applyTheme(){const e=this.root.querySelector(".designer-container");if(!e)return;for(const n of this.appliedThemeTokens)e.style.removeProperty(n);if(this.appliedThemeTokens=[],(this._theme==="dark"||this._theme==="light"?this._theme:this.systemDark?"dark":"light")==="dark")for(const[n,r]of Object.entries(Oa))r!==void 0&&(e.style.setProperty(n,r),this.appliedThemeTokens.push(n));const i=this._themeConfig?.overrides;if(i)for(const[n,r]of Object.entries(i))!n.startsWith("--pd-")||typeof r!="string"||(e.style.setProperty(n,r),this.appliedThemeTokens.includes(n)||this.appliedThemeTokens.push(n))}readChrome(){this.state.leftCollapsed=ir(tr),this.state.propCollapsed=ir(or),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,nr(tr,this.state.leftCollapsed),nr(or,this.state.propCollapsed))}disconnectedCallback(){this.detachThemeMedia(),this.unsub?.(),this.unsub=null,this.unsubPluginUI?.(),this.unsubPluginUI=null,this.unsubDefinitions?.(),this.unsubDefinitions=null,Dn(),this.detachDocKeys(),this.ro?.disconnect(),this.ro=null,this.roArea=null,this.toolbarRo?.disconnect(),this.toolbarRo=null,Ye.active===this&&(Ye.active=null),Or(),this.unmountHelp?.(),this.unmountHelp=null,this.hideHoverTip(),this.snapTimer&&(clearTimeout(this.snapTimer),this.snapTimer=null);for(const e of this.instanceDisposers)e();this.instanceDisposers=[],this.docFontFaceStyle?.remove(),this.docFontFaceStyle=null,this.measureRaf!==null&&(cancelAnimationFrame(this.measureRaf),this.measureRaf=null)}applyFontFace(){const e=_.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}attachPluginUI(){this.unsubPluginUI||(this.unsubPluginUI=ci.subscribeElementUIRegistry(()=>this.repaint())),this.unsubDefinitions||(this.unsubDefinitions=cr(()=>this.repaint()))}syncPluginUIStyles(){const e=new Map;for(const{type:o,ui:i}of ci.getElementUIEntries())i.styles&&e.set(o,i.styles);for(const[o,i]of[...this.pluginStyleEls])e.has(o)||(i.remove(),this.pluginStyleEls.delete(o));for(const[o,i]of e){let n=this.pluginStyleEls.get(o);n||(n=document.createElement("style"),n.setAttribute("data-plugin-ui",o),this.root.appendChild(n),this.pluginStyleEls.set(o,n)),n.textContent!==i&&(n.textContent=i)}}templateJsonWithFonts(){const e=JSON.parse(this.store.getTemplateJson()),o=this.fonts;if(!o?.length)return e;if(Array.isArray(e.pages)){const i=e;return{...i,pages:i.pages.map(n=>({...n,fonts:[...o]}))}}return{...e,fonts:[...o]}}getTemplateJson(){return JSON.stringify(this.templateJsonWithFonts())}loadTemplate(e){this.applyTemplate(e)}save(){const e=this.validateTemplate();if(e.length){window.alert(e[0].message),this.state.propTab="page",this.repaint();return}const o=this.templateJsonWithFonts();if(Array.isArray(o.pages))try{_.normalizeTemplate(o)}catch(r){window.alert(r instanceof Error?r.message:String(r));return}const i=this.getGeometryWarnings();if(i.length&&!window.confirm(`出纸提示:部分内容超出纸面,打印时会被裁切。
|
|
893
928
|
是否接受裁切并继续保存?
|
|
894
929
|
点击“确定”继续保存,点击“取消”返回修改。
|
|
895
930
|
|
|
896
931
|
${i.join(`
|
|
897
|
-
`)}`))return;const n=JSON.stringify(o);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent(Fe.save,{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?_.validateTiling(e):[]}getGeometryWarnings(){return _.collectPrintWarnings(this.store.templateData)}applyTemplate(e){if(!e)return;const o=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(o):this.setAttribute("template",JSON.stringify(o))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(i=>i.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(i=>i.remove());const o=this.exprTarget;ve(Zd({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:i=>this.applyExpression(o,i)},o),this.root),this.exprMountedFor=o}openHelp(e){this.helpInitialTab=e,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=sc(this.root,{initialTab:this.helpInitialTab,onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const o=this.unmountHelp;this.unmountHelp=null,o()}}applyExpression(e,o){const i=o.formatter??"",n=e.targetPath;if(n.startsWith("options.")){if(n.includes("[")){const s=this.store.elements.find(l=>l.id===e.elementId);s&&Hi(this.store,s,n,i);return}const r={[n.slice(8)]:i||void 0};o.title!==void 0&&(r.title=o.title),this.store.updateElement(e.elementId,r);return}if(n==="watermark.content"){const r={...this.store.templateData.watermark};yi(i)?Object.assign(r,{mode:"binding",binding:i,content:""}):Object.assign(r,{mode:"fixed",content:i,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const o=this.store.elements.find(n=>n.id===e);if(!o||(this.store.selectOne(e),this.state.propTab=ui(o)?"custom":"element",o.options.locked))return;const i=fr(o.printElementType.type);i&&this.openExpression({elementId:o.id,targetPath:`options.${i}`,value:String(o.options[i]??"")})}dblEditCell(e){const o=this.store.elements.find(l=>l.id===e.elementId);if(!o||(this.store.selectOne(o.id),this.state.propTab="element",o.options.locked))return;const i=o.options.tableRows??[],n=c.findMainCell(i,e.r,e.c),s=i[n.r]?.cells[n.c];s&&this.openExpression({elementId:o.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,o)=>this.fire(e,o),showHelp:this.getAttribute("show-help")!=="false",showPreview:this.getAttribute("show-preview")!=="false",showSave:this.getAttribute("show-save")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts,designData:this.designData,fields:this.store.fields}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;Dn(),this.syncPluginUIStyles();const e=[...this.store.selectedIds].join(",");if(e!==this.lastSelKey){this.lastSelKey=e;const s=this.store.selectedElement;this.state.propTab=s?ui(s)?"custom":"element":"page"}const o=this.root.querySelector(".designer-container");o.classList.toggle("format-painting",this.format.painterActive);for(const s of o.querySelectorAll("[data-pane]"))s.style.display!=="none"&&this.paneScroll.set(s.dataset.pane,s.scrollTop);rr(o);const i=this.ctx;ve(pc(i,Zl(i)),o),ve(id(i),o),ve(a("div",{class:"designer-body"},[Ql(i),Pl(i,this.canvasUi()),Nd(i)]),o),ve(nd(i),o),Zn(o),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>Zn(o)),this.toolbarRo.observe(o));const n=ol(this.store,(s,l)=>this.fire(s,l),this.tableMenu);n&&ve(n,o),As(this.root,this.store.elements,this.designData),Ur(this.root,this.state.propSearch),this.applyShrinkFit();const r=this.root.querySelector(".canvas-area");r&&(r.scrollLeft=this.scrollPos.x,r.scrollTop=this.scrollPos.y);for(const s of o.querySelectorAll("[data-pane]")){const l=this.paneScroll.get(s.dataset.pane);l!==void 0&&(s.scrollTop=l)}this.syncRulers(),this.persistChrome(),this.applyHostParts(o)}applyHostParts(e){const o={".designer-toolbar":"toolbar",".format-toolbar":"format-bar",".left-panel":"left-panel",".canvas-area":"canvas-area",".property-panel":"property-panel",".status-bar":"status-bar",".page-tabs":"page-tabs"};for(const[i,n]of Object.entries(o)){const r=e.querySelector(i);r&&Mi.includes(n)&&r.setAttribute("part",n)}}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Si.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const o=e.getAttribute("data-fit-base");o?e.style.fontSize=`${o}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),o=this.root.querySelector(".hiprint-printPaper");if(!e||!o)return;const i=e.getBoundingClientRect(),n=o.getBoundingClientRect(),r=(this.store.scale||100)/100,s=n.width/c.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(s-r)<.002?r:s,originX:n.left-i.left-no,originY:n.top-i.top-no,viewW:e.clientWidth-no,viewH:e.clientHeight-no},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,o=c.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";uc(n,{orientation:r,geom:this.geom,scale:i,paperLengthMM:r==="horizontal"?o.width:o.height})}}patchElementDom(){for(const i of this.store.elements){const n=this.root.querySelector(`[data-el-id="${CSS.escape(i.id)}"]`);n&&(n.style.left=`${i.options.left}mm`,n.style.top=`${i.options.top}mm`,n.style.width=`${i.options.width}mm`,n.style.height=`${i.options.height}mm`)}const e=this.root.querySelector(".position-label"),o=this.store.selectedElement;e&&o&&!this.drag&&(e.textContent=Or(o.options))}fire(e,o){const i=this.store;switch(e){case"undo":i.undo();break;case"redo":i.redo();break;case"align":i.alignSelected(o);break;case"move-layer":i.moveLayer(o);break;case"group":i.groupSelected();break;case"ungroup":i.ungroupSelected();break;case"copy":i.copy();break;case"cut":i.cutSelected();break;case"paste":i.paste();break;case"paste-at":i.paste();break;case"delete":i.deleteSelected();break;case"delete-page":i.deletePage(i.activePageIndex);break;case"add-page":i.addPage();break;case"duplicate-page":i.duplicatePage(i.activePageIndex);break;case"move-page":i.movePage(i.activePageIndex,i.activePageIndex+o);break;case"select-all":i.selectAll();break;case"clear-selection":i.clearSelection();break;case"toggle-ruler":i.showRuler=!i.showRuler,this.repaint();break;case"toggle-grid":i.showGrid=!i.showGrid,this.repaint();break;case"toggle-snap":i.snapToGrid=!i.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":i.showTableGhostBorder=!i.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(o>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent(Fe.preview,{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent(Fe.help,{bubbles:!0,composed:!0})),this.openHelp(o);break;case"guide-remove":i.removeGuide(o);break;case"resize-start":this.beginResize(o);break;case"element-mousedown":{const n=o;n.event.button===0&&this.isDoubleTap(`el:${n.id}`,n.event)&&this.fire("element-dblclick",{event:n.event,id:n.id}),this.beginDrag(n);break}case"table-cell-mousedown":{const n=o;this.isDoubleTap(`cell:${n.elementId}:${n.r}:${n.c}`,n.event)&&(this.taps.delete(`el:${n.elementId}`),this.fire("table-cell-dblclick",{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId}));break}case"zone-resize":this.beginZoneResize(o);break;case"guide-mousedown":this.beginGuideDrag(o);break;case"ruler-mousedown":this.beginRulerGuide(o);break;case"canvas-mousedown":this.onCanvasMouseDown(o);break;case"canvas-mousemove":this.onCanvasMouseMove(o);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(o);break;case"contextmenu":this.onElementContextMenu(o);break;case"element-dblclick":{const{id:n}=o;this.dblEditElement(n),this.dispatchEvent(new CustomEvent(Fe.dblclickElement,{detail:n,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const n=o;this.dblEditCell(n),this.dispatchEvent(new CustomEvent(Fe.dblclickCell,{detail:{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(o);break;case"drop":this.onDrop(o);break;case"wheel":this.onWheel(o);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const o=e.dataTransfer,i=o?.getData("elementType"),n=o?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const s={x:r.left,y:r.top};if(i)this.store.addElement(i,{},s);else if(n){const l=this.store.fields.find(p=>p.fieldKey===n);l&&this.store.addFieldElement(l,{},s,e.ctrlKey||e.metaKey||e.labelIntent===!0)}}pointToPaperMm(e){const o=this.root.querySelector(".hiprint-printPaper");if(!o)return null;const i=o.getBoundingClientRect(),n=(this.store.scale||100)/100,r=c.pxToMm((e.clientX-i.left)/n),s=c.pxToMm((e.clientY-i.top)/n);return r<0||s<0?null:{left:r,top:s}}onCanvasMouseDown(e){const o=e.target;(o===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(n=>o.classList.contains(n)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const o=this.pointToPaperMm(e),i=this.root.querySelector("[data-coord]");if(i){if(!o){i.style.display="none";return}i.style.display="",i.textContent=`x:${(o.left-this.store.templateData.margins.left).toFixed(1)} y:${(o.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,o){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=o,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const i=this.root.querySelector(".context-menu");if(!i)return;const n=i.getBoundingClientRect();this.menu.flipX=n.right>window.innerWidth?window.innerWidth-n.right-8:0,this.menu.flipY=n.bottom>window.innerHeight?window.innerHeight-n.bottom-8:0,this.paint()})}startMarquee(e){const o={x:e.clientX,y:e.clientY},i=r=>{this.marquee={visible:!0,x:Math.min(o.x,r.clientX),y:Math.min(o.y,r.clientY),w:Math.abs(r.clientX-o.x),h:Math.abs(r.clientY-o.y)},this.paint()},n=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const s=this.store.elements.filter(l=>{const p=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!p)return!1;const u=p.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,o){const i=this.taps.get(e);return this.taps.set(e,{t:o.timeStamp,x:o.clientX,y:o.clientY}),!i||o.timeStamp-i.t>=500||Math.abs(o.clientX-i.x)>6||Math.abs(o.clientY-i.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const o=e.event;if(o.button!==0)return;const i=this.store;o.stopPropagation();const n=i.elements.find(l=>l.id===e.id);if(!n||(i.selectElement(n.id,o.ctrlKey||o.metaKey),n.options.locked))return;const r=o.altKey?[n.id]:i.dragIds(n.id),s=new Map;for(const l of r){const p=i.elements.find(u=>u.id===l);p&&s.set(l,{left:p.options.left,top:p.options.top})}this.drag={ids:r,primary:n.id,altKey:o.altKey,movedPositions:new Map,startX:o.clientX,startY:o.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 o of Array.from(this.root.querySelectorAll(".print-element"))){const i=e.has(o.dataset.elId??"");o.classList.toggle("drag-ghost",i);const n=o.querySelector(":scope > .drag-preview");i&&!n?ve(a("div",{class:"drag-preview"}),o):!i&&n&&n.remove()}}finishAltClone(e){const o=this.store;o.adsorbGuides=[];const i=o.elements.find(s=>s.id===e.primary),n=e.movedPositions.get(e.primary);if(o.discardLive(),!i||!n)return;const r=JSON.parse(JSON.stringify(i));r.id=c.generateId(),r.options.left=n.left,r.options.top=n.top,r.options.groupId=void 0,o.cloneElement(r)}flashSnapIndicator(e,o){const i=this.root.querySelector(".hiprint-printPaper-content");i&&(i.querySelector(".snap-indicator")?.remove(),ve(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${o}mm`}}),i),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{i.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const o=e.event;o.stopPropagation();const i=this.store.elements.find(n=>n.id===e.id);!i||i.options.locked||(this.resize={id:e.id,point:e.point,startX:o.clientX,startY:o.clientY,origin:{left:i.options.left,top:i.options.top,width:i.options.width,height:i.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const o=e.event.clientY,i=this.store.templateData,n=e.zone==="header"?i.header.height:i.footer.height,r=(this.store.scale||100)/100,s=p=>{const u=c.pxToMm((p.clientY-o)/r),h=Math.max(0,Math.round((n+(e.zone==="header"?u:-u))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...i.header,height:h}}):this.store.updateTemplateData({footer:{...i.footer,height:h}}),this.paint()},l=()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",s),window.addEventListener("mouseup",l)}beginGuideDrag(e){const o=(this.store.templateData.guides??[]).find(h=>h.id===e.id);if(!o)return;const i=c.getPaperDimensions(this.store.templateData),n=o.type==="vertical"?i.width:i.height,r=e.event.clientX,s=e.event.clientY,l=(this.store.scale||100)/100,p=h=>{const m=c.pxToMm((o.type==="vertical"?h.clientX-r:h.clientY-s)/l);this.store.moveGuide(o.id,Math.min(n,Math.max(0,o.position+m))),this.paint()},u=()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",p),window.addEventListener("mouseup",u)}beginRulerGuide(e){const o=e.orientation==="horizontal"?"vertical":"horizontal",i=r=>{this.guidePreview={type:o,position:o==="vertical"?r.clientX:r.clientY},this.paint()},n=r=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const s=this.rulerPointToMM(r,o);this.guidePreview=null,s!==null?this.store.addGuide(o,s):this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}rulerPointToMM(e,o){const i=this.root.querySelector(".hiprint-printPaper");if(!i)return null;const n=i.getBoundingClientRect(),r=c.mmToPx(1)*(this.geom.paperScale||1),s=o==="vertical"?(e.clientX-n.left)/r:(e.clientY-n.top)/r,l=c.getPaperDimensions(this.store.templateData),p=o==="vertical"?l.width:l.height;return s<0||s>p?null:s}applyZoom(e,o,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 p=getComputedStyle(r),u=parseFloat(p.paddingLeft)||0,h=parseFloat(p.paddingTop)||0,m=r.scrollLeft+o-u,g=r.scrollTop+i-h,S=l/s;this.store.setScale(l,n),r.scrollLeft=m*S-o+u,r.scrollTop=g*S-i+h,this.scrollPos={x:r.scrollLeft,y:r.scrollTop}}zoomByStep(e){const o=this.root.querySelector(".canvas-area");o&&this.applyZoom(c.nextWheelScale(this.store.scale,e),o.clientWidth/2,o.clientHeight/2,c.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const o=getComputedStyle(e),i=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0),n=(parseFloat(o.paddingTop)||0)+(parseFloat(o.paddingBottom)||0),r=c.getPaperDimensions(this.store.templateData),s=c.computeFitScale(e.clientWidth-i,e.clientHeight-n,c.mmToPx(r.width),c.mmToPx(r.height));this.applyZoom(s,e.clientWidth/2,e.clientHeight/2,c.FIT_SCALE_MIN_PERCENT)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const o=this.root.querySelector(".canvas-area");if(!o)return;const i=Math.round(this.store.scale),n=c.nextWheelScale(i,e.deltaY>0?-1:1);if(n===i)return;const r=o.getBoundingClientRect();this.applyZoom(n,e.clientX-r.left,e.clientY-r.top,c.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");if(!e)return;this.scrollPos={x:e.scrollLeft,y:e.scrollTop};const o=this.root.querySelector(".ruler-overlay");o&&(o.style.transform=`translate(${this.scrollPos.x}px, ${this.scrollPos.y}px)`),this.syncRulers()}on(e,o,i,n){e.addEventListener(o,i,n),this.instanceDisposers.push(()=>e.removeEventListener(o,i,n))}attachInstanceListeners(){this.instanceDisposers.length||(this.bindPointer(),this.bindKeys(),this.bindPaneScroll())}bindPaneScroll(){this.on(this.root,"scroll",e=>{const o=e.target;if(!(o instanceof HTMLElement))return;const i=o.dataset.pane;i&&this.paneScroll.set(i,o.scrollTop)},!0)}bindPointer(){const e=s=>{const l=this.store;if(!l)return;const u=((l.scale||100)/100||1)*c.mmToPx(1),h=(m,g)=>({dx:m/u,dy:g/u});if(this.drag){const{dx:m,dy:g}=h(s.clientX-this.drag.startX,s.clientY-this.drag.startY);(Math.abs(m)>.05||Math.abs(g)>.05)&&(this.drag.moved=!0);const S=l.elements.find(A=>A.id===this.drag.primary),b=S&&c.resolveElementBoxes(S.options).margin,k=S&&b&&{id:S.id,left:(this.drag.origin.get(S.id)?.left??0)+m,top:(this.drag.origin.get(S.id)?.top??0)+g,width:b.width,height:b.height};let y=null;if(k&&l.snapToGrid!==!1){const A=l.elements.filter(N=>!this.drag.ids.includes(N.id)&&(N.zone||"content")===this.drag.zone).map(N=>({id:N.id,...c.resolveElementBoxes(N.options).margin})),F=bi(l.templateData,l.paperSize)[this.drag.zone],K=c.computeAdsorb(k,A,this.manualGuides());y={left:K.left,top:K.top},l.adsorbGuides=(K.lines??[]).filter(N=>N.position>=0&&N.position<=(N.type==="vertical"?F.width:F.height)),(y.left!==k.left||y.top!==k.top)&&this.flashSnapIndicator(y.left+k.width/2,y.top+k.height/2)}else l.adsorbGuides=[];const C=S?this.drag.origin.get(S.id):void 0,D=y&&C?y.left-C.left:m,P=y&&C?y.top-C.top:g;for(const A of this.drag.ids){const F=this.drag.origin.get(A);if(!F)continue;const K={left:F.left+D,top:F.top+P};this.drag.movedPositions.set(A,K),l.livePatch(A,K)}this.patchElementDom(),l.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:m,dy:g}=h(s.clientX-this.resize.startX,s.clientY-this.resize.startY),S=c.calcResizeRect(this.resize.point,this.resize.origin,m,g,3.5,3.5);l.livePatch(this.resize.id,S),this.patchElementDom()}},o=()=>{const s=!!this.drag,l=this.drag;if(l?.moved&&l.altKey){this.finishAltClone(l),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),s&&(this.store.draggingIds=new Set,this.syncDragGhost()))},i=s=>{const l=s.composedPath(),p=l.some(h=>h.classList?.contains("tb-dd"));this.state.openDd&&!p&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!p&&(this.state.openMore=!1,this.repaint());const u=l.some(h=>h.classList?.contains("context-menu"));this.menu.visible&&!u&&(this.menu.visible=!1,this.repaint())},n=s=>{const p=s.target?.closest?.("[data-tip]");!p||!p.closest(fc)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(p),300))},r=s=>{const l=s,p=l.target?.closest?.("[data-tip]");p&&l.relatedTarget?.closest?.("[data-tip]")!==p&&this.hideHoverTip()};this.on(window,"mousemove",e),this.on(window,"mouseup",o),this.on(this,"pointerdown",i),this.on(this.root,"mouseover",n),this.on(this.root,"mouseout",r)}showHoverTip(e){const o=e.dataset.tip;if(!o)return;this.hideHoverTip();const i=e.getBoundingClientRect(),n=i.left+i.width/2;this.hoverTipEl=ve(a("div",{class:"pd-hover-tip",style:{left:`${n}px`,top:`${i.bottom+6}px`},text:o}),this.root);const r=this.hoverTipEl.offsetWidth/2;if(!r)return;const 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=[],o=[];for(const i of this.store.templateData.guides??[])i.type==="vertical"?e.push(i.position):o.push(i.position);return{vertical:e,horizontal:o}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const i of Array.from(e.querySelectorAll(".adsorb-guide")))i.remove();const o=this.store.paperSize;bi(this.store.templateData,o);for(const i of this.store.adsorbGuides){const n=document.createElement("div");n.className=`adsorb-guide guide-${i.type}`,i.type==="vertical"?n.style.cssText=`left:${i.position}mm;top:0;height:${o.height}mm;border-left-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`:n.style.cssText=`top:${i.position}mm;left:0;width:${o.width}mm;border-top-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(n)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{Ye.active=this};this.on(this,"pointerdown",e),this.on(this,"focusin",e),Ye.active||(Ye.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>Nr(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(e){const o=this.store;if(!o||Ye.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,p=e.key==="ArrowUp"?-s:e.key==="ArrowDown"?s:0;o.moveSelected(l,p);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),o.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const r=e.key.toLowerCase();gc.has(r)&&(e.preventDefault(),r==="z"?e.shiftKey?o.redo():o.undo():r==="y"?o.redo():r==="a"?o.selectAll():r==="c"?o.copy():r==="x"?o.cutSelected():r==="v"?o.paste():r==="d"?o.duplicateSelected():r==="g"?e.shiftKey?o.ungroupSelected():o.groupSelected():r==="1"?o.resetZoom():r==="l"?o.alignSelected("left"):r==="r"?o.alignSelected("right"):r==="e"?o.alignSelected("vertical"):r==="t"?o.alignSelected("top"):r==="b"?o.alignSelected("bottom"):r==="0"&&this.fire("fit-window"))}}function jr(t="print-designer"){return customElements.get(t)||customElements.define(t,Ye),t}function mc(){return jr()}Object.defineProperty(exports,"BUILTIN_ELEMENT_CAPABILITIES",{enumerable:!0,get:()=>c.BUILTIN_ELEMENT_CAPABILITIES});Object.defineProperty(exports,"getElementCapabilities",{enumerable:!0,get:()=>c.getElementCapabilities});Object.defineProperty(exports,"getElementCapabilityTypes",{enumerable:!0,get:()=>c.getElementCapabilityTypes});Object.defineProperty(exports,"registerElementCapabilities",{enumerable:!0,get:()=>c.registerElementCapabilities});Object.defineProperty(exports,"resetElementCapabilities",{enumerable:!0,get:()=>c.resetElementCapabilities});exports.BUILTIN_ELEMENT_DEFINITIONS=fo;exports.DesignerStore=sr;exports.PRINT_DESIGNER_ATTRIBUTES=Di;exports.PRINT_DESIGNER_BOOLEAN_ATTRIBUTES=br;exports.PRINT_DESIGNER_CONTRACT_VERSION=Ai;exports.PRINT_DESIGNER_EVENT=Fe;exports.PRINT_DESIGNER_EVENTS=wr;exports.PRINT_DESIGNER_EVENT_OPTIONS=Fa;exports.PRINT_DESIGNER_METHODS=vr;exports.PRINT_DESIGNER_PARTS=Mi;exports.PRINT_DESIGNER_PROPERTY_NAMES=yr;exports.PRINT_DESIGNER_TAG=mr;exports.PRINT_DESIGNER_THEME_TOKENS=xr;exports.PrintDesignerElement=Ye;exports.TILING_SINGLE_PAGE_TIP=pi;exports.createDefaultTemplate=$t;exports.definePrintDesigner=jr;exports.getElementDblEditableField=fr;exports.getElementDefinition=nt;exports.getElementDefinitions=pr;exports.getElementLayerIcon=gr;exports.getElementPropertyGroup=hr;exports.getHostContract=hi;exports.getMaterialElementDefinitions=ur;exports.registerAll=mc;exports.registerElementDefinition=Ra;exports.registerElementRenderer=Pa;exports.registerElementRenderers=cr;exports.resetElementDefinitions=La;exports.serializePage=ar;exports.subscribeElementDefinitions=dr;exports.toRuntimePool=ki;
|
|
932
|
+
`)}`))return;const n=JSON.stringify(o);this.store.dirty=!1,this.repaint(),this.dispatchEvent(new CustomEvent(Le.save,{detail:n,bubbles:!0,composed:!0}))}validateTemplate(){const e=this.store.templateData;return e.tiling?.enabled===!0?_.validateTiling(e):[]}getGeometryWarnings(){return _.collectPrintWarnings(this.store.templateData)}applyTemplate(e){if(!e)return;const o=typeof e=="string"?JSON.parse(e):e;this.store?this.store.loadTemplate(o):this.setAttribute("template",JSON.stringify(o))}openExpression(e){this.exprTarget=e,this.syncExpression()}closeExpression(){this.exprTarget=null,this.syncExpression()}syncExpression(){const e=Array.from(this.root.querySelectorAll(".pd-dialog-overlay"));if(!this.exprTarget){e.forEach(i=>i.remove()),this.exprMountedFor=null;return}if(this.exprMountedFor===this.exprTarget)return;e.forEach(i=>i.remove());const o=this.exprTarget;ve(ec({fields:this.store.fields,onClose:()=>this.closeExpression(),onApply:i=>this.applyExpression(o,i)},o),this.root),this.exprMountedFor=o}openHelp(e){this.helpInitialTab=e,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=cc(this.root,{initialTab:this.helpInitialTab,onClose:()=>this.closeHelp()});else if(!e&&this.unmountHelp){const o=this.unmountHelp;this.unmountHelp=null,o()}}applyExpression(e,o){const i=o.formatter??"",n=e.targetPath;if(n.startsWith("options.")){if(n.includes("[")){const s=this.store.elements.find(l=>l.id===e.elementId);s&&Hi(this.store,s,n,i);return}const r={[n.slice(8)]:i||void 0};o.title!==void 0&&(r.title=o.title),this.store.updateElement(e.elementId,r);return}if(n==="watermark.content"){const r={...this.store.templateData.watermark};yi(i)?Object.assign(r,{mode:"binding",binding:i,content:""}):Object.assign(r,{mode:"fixed",content:i,binding:""}),this.store.updateTemplateData({watermark:r})}}dblEditElement(e){const o=this.store.elements.find(n=>n.id===e);if(!o||(this.store.selectOne(e),this.state.propTab=ui(o)?"custom":"element",o.options.locked))return;const i=gr(o.printElementType.type);i&&this.openExpression({elementId:o.id,targetPath:`options.${i}`,value:String(o.options[i]??"")})}dblEditCell(e){const o=this.store.elements.find(l=>l.id===e.elementId);if(!o||(this.store.selectOne(o.id),this.state.propTab="element",o.options.locked))return;const i=o.options.tableRows??[],n=c.findMainCell(i,e.r,e.c),s=i[n.r]?.cells[n.c];s&&this.openExpression({elementId:o.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,o)=>this.fire(e,o),showHelp:this.getAttribute("show-help")!=="false",showPreview:this.getAttribute("show-preview")!=="false",showSave:this.getAttribute("show-save")!=="false",isEdit:this.getAttribute("is-edit")==="true",host:{uploadImage:this.uploadImage,uploadDesignBackground:this.uploadDesignBackground,fonts:this.fonts,designData:this.designData,fields:this.store.fields}}}canvasUi(){return{geom:this.geom,marquee:this.marquee,contextMenu:this.menu,guidePreview:this.guidePreview,zoneResizing:this.zoneResizing,scrollX:this.scrollPos.x,scrollY:this.scrollPos.y}}repaint(){this.raf||(this.raf=requestAnimationFrame(()=>{this.raf=0,this.paint()}))}paint(){if(!this.store)return;Dn(),this.syncPluginUIStyles();const e=[...this.store.selectedIds].join(",");if(e!==this.lastSelKey){this.lastSelKey=e;const s=this.store.selectedElement;this.state.propTab=s?ui(s)?"custom":"element":"page"}const o=this.root.querySelector(".designer-container");o.classList.toggle("format-painting",this.format.painterActive);for(const s of o.querySelectorAll("[data-pane]"))s.style.display!=="none"&&this.paneScroll.set(s.dataset.pane,s.scrollTop);ar(o);const i=this.ctx;ve(fc(i,Jl(i)),o),ve(ad(i),o),ve(a("div",{class:"designer-body"},[td(i),Fl(i,this.canvasUi()),Hd(i)]),o),ve(sd(i),o),Zn(o),!this.toolbarRo&&typeof ResizeObserver<"u"&&(this.toolbarRo=new ResizeObserver(()=>Zn(o)),this.toolbarRo.observe(o));const n=nl(this.store,(s,l)=>this.fire(s,l),this.tableMenu);n&&ve(n,o),Ms(this.root,this.store.elements,this.designData),Wr(this.root,this.state.propSearch),this.applyShrinkFit();const r=this.root.querySelector(".canvas-area");r&&(r.scrollLeft=this.scrollPos.x,r.scrollTop=this.scrollPos.y);for(const s of o.querySelectorAll("[data-pane]")){const l=this.paneScroll.get(s.dataset.pane);l!==void 0&&(s.scrollTop=l)}this.syncRulers(),this.persistChrome(),this.applyHostParts(o)}applyHostParts(e){const o={".designer-toolbar":"toolbar",".format-toolbar":"format-bar",".left-panel":"left-panel",".canvas-area":"canvas-area",".property-panel":"property-panel",".status-bar":"status-bar",".page-tabs":"page-tabs"};for(const[i,n]of Object.entries(o)){const r=e.querySelector(i);r&&Mi.includes(n)&&r.setAttribute("part",n)}}applyShrinkFit(){for(const e of Array.from(this.root.querySelectorAll('[data-fit="shrink"]')))Ti.fitTextNode(e);for(const e of Array.from(this.root.querySelectorAll("[data-fit-size]"))){if(e.getAttribute("data-fit")==="shrink")continue;e.removeAttribute("data-fit-size");const o=e.getAttribute("data-fit-base");o?e.style.fontSize=`${o}pt`:e.style.removeProperty("font-size")}}measureRuler(){const e=this.root.querySelector(".canvas-area"),o=this.root.querySelector(".hiprint-printPaper");if(!e||!o)return;const i=e.getBoundingClientRect(),n=o.getBoundingClientRect(),r=(this.store.scale||100)/100,s=n.width/c.mmToPx(this.store.paperSize.width);this.geom={paperScale:Math.abs(s-r)<.002?r:s,originX:n.left-i.left-no,originY:n.top-i.top-no,viewW:e.clientWidth-no,viewH:e.clientHeight-no},this.observeCanvasArea()}observeCanvasArea(){const e=this.root.querySelector(".canvas-area");!e||typeof ResizeObserver>"u"||this.roArea===e||(this.roArea=e,this.ro?.disconnect(),this.ro=new ResizeObserver(()=>this.syncRulers()),this.ro.observe(e))}syncRulers(){this.measureRuler();const e=this.store.templateData,o=c.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";gc(n,{orientation:r,geom:this.geom,scale:i,paperLengthMM:r==="horizontal"?o.width:o.height})}}patchElementDom(){for(const i of this.store.elements){const n=this.root.querySelector(`[data-el-id="${CSS.escape(i.id)}"]`);n&&(n.style.left=`${i.options.left}mm`,n.style.top=`${i.options.top}mm`,n.style.width=`${i.options.width}mm`,n.style.height=`${i.options.height}mm`)}const e=this.root.querySelector(".position-label"),o=this.store.selectedElement;e&&o&&!this.drag&&(e.textContent=Nr(o.options))}fire(e,o){const i=this.store;switch(e){case"undo":i.undo();break;case"redo":i.redo();break;case"align":i.alignSelected(o);break;case"move-layer":i.moveLayer(o);break;case"group":i.groupSelected();break;case"ungroup":i.ungroupSelected();break;case"copy":i.copy();break;case"cut":i.cutSelected();break;case"paste":i.paste();break;case"paste-at":i.paste();break;case"delete":i.deleteSelected();break;case"delete-page":i.deletePage(i.activePageIndex);break;case"add-page":i.addPage();break;case"duplicate-page":i.duplicatePage(i.activePageIndex);break;case"move-page":i.movePage(i.activePageIndex,i.activePageIndex+o);break;case"select-all":i.selectAll();break;case"clear-selection":i.clearSelection();break;case"toggle-ruler":i.showRuler=!i.showRuler,this.repaint();break;case"toggle-grid":i.showGrid=!i.showGrid,this.repaint();break;case"toggle-snap":i.snapToGrid=!i.snapToGrid,this.repaint();break;case"toggle-table-ghost-border":i.showTableGhostBorder=!i.showTableGhostBorder,this.repaint();break;case"fit-window":this.fitToWindow();break;case"zoom":this.zoomByStep(o>0?1:-1);break;case"preview":this.dispatchEvent(new CustomEvent(Le.preview,{detail:this.getTemplateJson(),bubbles:!0,composed:!0}));break;case"save":this.save();break;case"help":this.dispatchEvent(new CustomEvent(Le.help,{bubbles:!0,composed:!0})),this.openHelp(o);break;case"guide-remove":i.removeGuide(o);break;case"resize-start":this.beginResize(o);break;case"element-mousedown":{const n=o;n.event.button===0&&this.isDoubleTap(`el:${n.id}`,n.event)&&this.fire("element-dblclick",{event:n.event,id:n.id}),this.beginDrag(n);break}case"table-cell-mousedown":{const n=o;this.isDoubleTap(`cell:${n.elementId}:${n.r}:${n.c}`,n.event)&&(this.taps.delete(`el:${n.elementId}`),this.fire("table-cell-dblclick",{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId}));break}case"zone-resize":this.beginZoneResize(o);break;case"guide-mousedown":this.beginGuideDrag(o);break;case"ruler-mousedown":this.beginRulerGuide(o);break;case"canvas-mousedown":this.onCanvasMouseDown(o);break;case"canvas-mousemove":this.onCanvasMouseMove(o);break;case"canvas-mouseleave":this.clearCoord();break;case"canvas-contextmenu":this.onContextMenu(o);break;case"contextmenu":this.onElementContextMenu(o);break;case"element-dblclick":{const{id:n}=o;this.dblEditElement(n),this.dispatchEvent(new CustomEvent(Le.dblclickElement,{detail:n,bubbles:!0,composed:!0}));break}case"table-cell-dblclick":{const n=o;this.dblEditCell(n),this.dispatchEvent(new CustomEvent(Le.dblclickCell,{detail:{elementId:n.elementId,r:n.r,c:n.c,cellId:n.cellId},bubbles:!0,composed:!0}));break}case"open-expression":this.openExpression(o);break;case"drop":this.onDrop(o);break;case"wheel":this.onWheel(o);break;case"scroll":this.onScroll();break}}onDrop(e){e.preventDefault();const o=e.dataTransfer,i=o?.getData("elementType"),n=o?.getData("fieldKey"),r=this.pointToPaperMm(e);if(!r)return;const s={x:r.left,y:r.top};if(i)this.store.addElement(i,{},s);else if(n){const l=this.store.fields.find(p=>p.fieldKey===n);l&&this.store.addFieldElement(l,{},s,e.ctrlKey||e.metaKey||e.labelIntent===!0)}}pointToPaperMm(e){const o=this.root.querySelector(".hiprint-printPaper");if(!o)return null;const i=o.getBoundingClientRect(),n=(this.store.scale||100)/100,r=c.pxToMm((e.clientX-i.left)/n),s=c.pxToMm((e.clientY-i.top)/n);return r<0||s<0?null:{left:r,top:s}}onCanvasMouseDown(e){const o=e.target;(o===this.root.querySelector(".canvas-area")||["canvas-scroll","hiprint-printPaper","hiprint-printPaper-content","zone-layer","grid-bg","watermark-layer"].some(n=>o.classList.contains(n)))&&(this.menu.visible=!1,this.state.openDd&&(this.state.openDd=null,this.repaint()),this.state.openMore&&(this.state.openMore=!1,this.repaint()),e.button===0&&(this.store.clearSelection(),this.startMarquee(e)))}onCanvasMouseMove(e){const o=this.pointToPaperMm(e),i=this.root.querySelector("[data-coord]");if(i){if(!o){i.style.display="none";return}i.style.display="",i.textContent=`x:${(o.left-this.store.templateData.margins.left).toFixed(1)} y:${(o.top-this.store.templateData.margins.top).toFixed(1)}mm`}}clearCoord(){const e=this.root.querySelector("[data-coord]");e&&(e.textContent="")}onContextMenu(e){this.openMenu(e,null)}onElementContextMenu(e){this.store.selectedIds.has(e.id)||this.store.selectOne(e.id),this.openMenu(e.event,e.id)}openMenu(e,o){this.menu.x=e.clientX,this.menu.y=e.clientY,this.menu.targetId=o,this.menu.visible=!0,this.menu.flipX=0,this.menu.flipY=0,this.repaint(),requestAnimationFrame(()=>{const i=this.root.querySelector(".context-menu");if(!i)return;const n=i.getBoundingClientRect();this.menu.flipX=n.right>window.innerWidth?window.innerWidth-n.right-8:0,this.menu.flipY=n.bottom>window.innerHeight?window.innerHeight-n.bottom-8:0,this.paint()})}startMarquee(e){const o={x:e.clientX,y:e.clientY},i=r=>{this.marquee={visible:!0,x:Math.min(o.x,r.clientX),y:Math.min(o.y,r.clientY),w:Math.abs(r.clientX-o.x),h:Math.abs(r.clientY-o.y)},this.paint()},n=()=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const r={...this.marquee};if(this.marquee={visible:!1,x:0,y:0,w:0,h:0},r.w>2&&r.h>2){const s=this.store.elements.filter(l=>{const p=this.root.querySelector(`[data-el-id="${CSS.escape(l.id)}"]`);if(!p)return!1;const u=p.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,o){const i=this.taps.get(e);return this.taps.set(e,{t:o.timeStamp,x:o.clientX,y:o.clientY}),!i||o.timeStamp-i.t>=500||Math.abs(o.clientX-i.x)>6||Math.abs(o.clientY-i.y)>6?!1:(this.taps.delete(e),!0)}beginDrag(e){const o=e.event;if(o.button!==0)return;const i=this.store;o.stopPropagation();const n=i.elements.find(l=>l.id===e.id);if(!n||(i.selectElement(n.id,o.ctrlKey||o.metaKey),n.options.locked))return;const r=o.altKey?[n.id]:i.dragIds(n.id),s=new Map;for(const l of r){const p=i.elements.find(u=>u.id===l);p&&s.set(l,{left:p.options.left,top:p.options.top})}this.drag={ids:r,primary:n.id,altKey:o.altKey,movedPositions:new Map,startX:o.clientX,startY:o.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 o of Array.from(this.root.querySelectorAll(".print-element"))){const i=e.has(o.dataset.elId??"");o.classList.toggle("drag-ghost",i);const n=o.querySelector(":scope > .drag-preview");i&&!n?ve(a("div",{class:"drag-preview"}),o):!i&&n&&n.remove()}}finishAltClone(e){const o=this.store;o.adsorbGuides=[];const i=o.elements.find(s=>s.id===e.primary),n=e.movedPositions.get(e.primary);if(o.discardLive(),!i||!n)return;const r=JSON.parse(JSON.stringify(i));r.id=c.generateId(),r.options.left=n.left,r.options.top=n.top,r.options.groupId=void 0,o.cloneElement(r)}flashSnapIndicator(e,o){const i=this.root.querySelector(".hiprint-printPaper-content");i&&(i.querySelector(".snap-indicator")?.remove(),ve(a("div",{class:"snap-indicator",style:{left:`${e}mm`,top:`${o}mm`}}),i),this.snapTimer&&clearTimeout(this.snapTimer),this.snapTimer=setTimeout(()=>{i.querySelector(".snap-indicator")?.remove(),this.snapTimer=null},300))}beginResize(e){const o=e.event;o.stopPropagation();const i=this.store.elements.find(n=>n.id===e.id);!i||i.options.locked||(this.resize={id:e.id,point:e.point,startX:o.clientX,startY:o.clientY,origin:{left:i.options.left,top:i.options.top,width:i.options.width,height:i.options.height}},this.store.dragStart())}beginZoneResize(e){e.event.stopPropagation(),e.event.preventDefault(),this.zoneResizing=e.zone;const o=e.event.clientY,i=this.store.templateData,n=e.zone==="header"?i.header.height:i.footer.height,r=(this.store.scale||100)/100,s=p=>{const u=c.pxToMm((p.clientY-o)/r),h=Math.max(0,Math.round((n+(e.zone==="header"?u:-u))*10)/10);e.zone==="header"?this.store.updateTemplateData({header:{...i.header,height:h}}):this.store.updateTemplateData({footer:{...i.footer,height:h}}),this.paint()},l=()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",l),this.zoneResizing=null,this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",s),window.addEventListener("mouseup",l)}beginGuideDrag(e){const o=(this.store.templateData.guides??[]).find(h=>h.id===e.id);if(!o)return;const i=c.getPaperDimensions(this.store.templateData),n=o.type==="vertical"?i.width:i.height,r=e.event.clientX,s=e.event.clientY,l=(this.store.scale||100)/100,p=h=>{const m=c.pxToMm((o.type==="vertical"?h.clientX-r:h.clientY-s)/l);this.store.moveGuide(o.id,Math.min(n,Math.max(0,o.position+m))),this.paint()},u=()=>{window.removeEventListener("mousemove",p),window.removeEventListener("mouseup",u),this.store.recordHistory(),this.repaint()};window.addEventListener("mousemove",p),window.addEventListener("mouseup",u)}beginRulerGuide(e){const o=e.orientation==="horizontal"?"vertical":"horizontal",i=r=>{this.guidePreview={type:o,position:o==="vertical"?r.clientX:r.clientY},this.paint()},n=r=>{window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",n);const s=this.rulerPointToMM(r,o);this.guidePreview=null,s!==null?this.store.addGuide(o,s):this.repaint()};window.addEventListener("mousemove",i),window.addEventListener("mouseup",n)}rulerPointToMM(e,o){const i=this.root.querySelector(".hiprint-printPaper");if(!i)return null;const n=i.getBoundingClientRect(),r=c.mmToPx(1)*(this.geom.paperScale||1),s=o==="vertical"?(e.clientX-n.left)/r:(e.clientY-n.top)/r,l=c.getPaperDimensions(this.store.templateData),p=o==="vertical"?l.width:l.height;return s<0||s>p?null:s}applyZoom(e,o,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 p=getComputedStyle(r),u=parseFloat(p.paddingLeft)||0,h=parseFloat(p.paddingTop)||0,m=r.scrollLeft+o-u,g=r.scrollTop+i-h,T=l/s;this.store.setScale(l,n),r.scrollLeft=m*T-o+u,r.scrollTop=g*T-i+h,this.scrollPos={x:r.scrollLeft,y:r.scrollTop}}zoomByStep(e){const o=this.root.querySelector(".canvas-area");o&&this.applyZoom(c.nextWheelScale(this.store.scale,e),o.clientWidth/2,o.clientHeight/2,c.MIN_SCALE_PERCENT)}fitToWindow(){const e=this.root.querySelector(".canvas-area");if(!e)return;const o=getComputedStyle(e),i=(parseFloat(o.paddingLeft)||0)+(parseFloat(o.paddingRight)||0),n=(parseFloat(o.paddingTop)||0)+(parseFloat(o.paddingBottom)||0),r=c.getPaperDimensions(this.store.templateData),s=c.computeFitScale(e.clientWidth-i,e.clientHeight-n,c.mmToPx(r.width),c.mmToPx(r.height));this.applyZoom(s,e.clientWidth/2,e.clientHeight/2,c.FIT_SCALE_MIN_PERCENT)}onWheel(e){if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const o=this.root.querySelector(".canvas-area");if(!o)return;const i=Math.round(this.store.scale),n=c.nextWheelScale(i,e.deltaY>0?-1:1);if(n===i)return;const r=o.getBoundingClientRect();this.applyZoom(n,e.clientX-r.left,e.clientY-r.top,c.MIN_SCALE_PERCENT)}onScroll(){const e=this.root.querySelector(".canvas-area");if(!e)return;this.scrollPos={x:e.scrollLeft,y:e.scrollTop};const o=this.root.querySelector(".ruler-overlay");o&&(o.style.transform=`translate(${this.scrollPos.x}px, ${this.scrollPos.y}px)`),this.syncRulers()}on(e,o,i,n){e.addEventListener(o,i,n),this.instanceDisposers.push(()=>e.removeEventListener(o,i,n))}attachInstanceListeners(){this.instanceDisposers.length||(this.bindPointer(),this.bindKeys(),this.bindPaneScroll())}bindPaneScroll(){this.on(this.root,"scroll",e=>{const o=e.target;if(!(o instanceof HTMLElement))return;const i=o.dataset.pane;i&&this.paneScroll.set(i,o.scrollTop)},!0)}bindPointer(){const e=s=>{const l=this.store;if(!l)return;const u=((l.scale||100)/100||1)*c.mmToPx(1),h=(m,g)=>({dx:m/u,dy:g/u});if(this.drag){const{dx:m,dy:g}=h(s.clientX-this.drag.startX,s.clientY-this.drag.startY);(Math.abs(m)>.05||Math.abs(g)>.05)&&(this.drag.moved=!0);const T=l.elements.find(A=>A.id===this.drag.primary),b=T&&c.resolveElementBoxes(T.options).margin,k=T&&b&&{id:T.id,left:(this.drag.origin.get(T.id)?.left??0)+m,top:(this.drag.origin.get(T.id)?.top??0)+g,width:b.width,height:b.height};let y=null;if(k&&l.snapToGrid!==!1){const A=l.elements.filter(N=>!this.drag.ids.includes(N.id)&&(N.zone||"content")===this.drag.zone).map(N=>({id:N.id,...c.resolveElementBoxes(N.options).margin})),L=bi(l.templateData,l.paperSize)[this.drag.zone],K=c.computeAdsorb(k,A,this.manualGuides());y={left:K.left,top:K.top},l.adsorbGuides=(K.lines??[]).filter(N=>N.position>=0&&N.position<=(N.type==="vertical"?L.width:L.height)),(y.left!==k.left||y.top!==k.top)&&this.flashSnapIndicator(y.left+k.width/2,y.top+k.height/2)}else l.adsorbGuides=[];const C=T?this.drag.origin.get(T.id):void 0,D=y&&C?y.left-C.left:m,P=y&&C?y.top-C.top:g;for(const A of this.drag.ids){const L=this.drag.origin.get(A);if(!L)continue;const K={left:L.left+D,top:L.top+P};this.drag.movedPositions.set(A,K),l.livePatch(A,K)}this.patchElementDom(),l.adsorbGuides.length&&this.paintGuidesOnly()}else if(this.resize){const{dx:m,dy:g}=h(s.clientX-this.resize.startX,s.clientY-this.resize.startY),T=c.calcResizeRect(this.resize.point,this.resize.origin,m,g,3.5,3.5);l.livePatch(this.resize.id,T),this.patchElementDom()}},o=()=>{const s=!!this.drag,l=this.drag;if(l?.moved&&l.altKey){this.finishAltClone(l),this.store.dragStop(),this.drag=null,this.store.draggingIds=new Set,this.repaint();return}this.drag?.moved||this.resize?(this.store.adsorbGuides=[],this.store.commitLive(),this.store.dragStop(),this.drag=null,this.resize=null,this.store.draggingIds=new Set,this.repaint()):(this.drag=null,this.store.dragStop(),s&&(this.store.draggingIds=new Set,this.syncDragGhost()))},i=s=>{const l=s.composedPath(),p=l.some(h=>h.classList?.contains("tb-dd"));this.state.openDd&&!p&&(this.state.openDd=null,this.repaint()),this.state.openMore&&!p&&(this.state.openMore=!1,this.repaint());const u=l.some(h=>h.classList?.contains("context-menu"));this.menu.visible&&!u&&(this.menu.visible=!1,this.repaint())},n=s=>{const p=s.target?.closest?.("[data-tip]");!p||!p.closest(bc)||(this.hoverTipTimer&&clearTimeout(this.hoverTipTimer),this.hoverTipTimer=setTimeout(()=>this.showHoverTip(p),300))},r=s=>{const l=s,p=l.target?.closest?.("[data-tip]");p&&l.relatedTarget?.closest?.("[data-tip]")!==p&&this.hideHoverTip()};this.on(window,"mousemove",e),this.on(window,"mouseup",o),this.on(this,"pointerdown",i),this.on(this.root,"mouseover",n),this.on(this.root,"mouseout",r)}showHoverTip(e){const o=e.dataset.tip;if(!o)return;this.hideHoverTip();const i=e.getBoundingClientRect(),n=i.left+i.width/2;this.hoverTipEl=ve(a("div",{class:"pd-hover-tip",style:{left:`${n}px`,top:`${i.bottom+6}px`},text:o}),this.root);const r=this.hoverTipEl.offsetWidth/2;if(!r)return;const 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=[],o=[];for(const i of this.store.templateData.guides??[])i.type==="vertical"?e.push(i.position):o.push(i.position);return{vertical:e,horizontal:o}}paintGuidesOnly(){const e=this.root.querySelector(".hiprint-printPaper-content");if(!e)return;for(const i of Array.from(e.querySelectorAll(".adsorb-guide")))i.remove();const o=this.store.paperSize;bi(this.store.templateData,o);for(const i of this.store.adsorbGuides){const n=document.createElement("div");n.className=`adsorb-guide guide-${i.type}`,i.type==="vertical"?n.style.cssText=`left:${i.position}mm;top:0;height:${o.height}mm;border-left-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`:n.style.cssText=`top:${i.position}mm;left:0;width:${o.width}mm;border-top-color:${i.color||"var(--pd-accent-secondary, #f56c6c)"}`,e.appendChild(n)}}bindKeys(){this.setAttribute("tabindex","0");const e=()=>{Ye.active=this};this.on(this,"pointerdown",e),this.on(this,"focusin",e),Ye.active||(Ye.active=this)}attachDocKeys(){this.docKeydown||(this.docKeydown=e=>this.onGlobalKeydown(e),document.addEventListener("keydown",this.docKeydown),this.docDragend=()=>$r(this.root?.querySelector(".canvas-area")),document.addEventListener("dragend",this.docDragend,!0))}detachDocKeys(){this.docKeydown&&(document.removeEventListener("keydown",this.docKeydown),this.docKeydown=null,this.docDragend&&(document.removeEventListener("dragend",this.docDragend,!0),this.docDragend=null))}onGlobalKeydown(e){const o=this.store;if(!o||Ye.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,p=e.key==="ArrowUp"?-s:e.key==="ArrowDown"?s:0;o.moveSelected(l,p);return}if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),o.deleteSelected();return}if(!(e.ctrlKey||e.metaKey))return;const r=e.key.toLowerCase();xc.has(r)&&(e.preventDefault(),r==="z"?e.shiftKey?o.redo():o.undo():r==="y"?o.redo():r==="a"?o.selectAll():r==="c"?o.copy():r==="x"?o.cutSelected():r==="v"?o.paste():r==="d"?o.duplicateSelected():r==="g"?e.shiftKey?o.ungroupSelected():o.groupSelected():r==="1"?o.resetZoom():r==="l"?o.alignSelected("left"):r==="r"?o.alignSelected("right"):r==="e"?o.alignSelected("vertical"):r==="t"?o.alignSelected("top"):r==="b"?o.alignSelected("bottom"):r==="0"&&this.fire("fit-window"))}}function Yr(t="print-designer"){return customElements.get(t)||customElements.define(t,Ye),t}function vc(){return Yr()}Object.defineProperty(exports,"BUILTIN_ELEMENT_CAPABILITIES",{enumerable:!0,get:()=>c.BUILTIN_ELEMENT_CAPABILITIES});Object.defineProperty(exports,"getElementCapabilities",{enumerable:!0,get:()=>c.getElementCapabilities});Object.defineProperty(exports,"getElementCapabilityTypes",{enumerable:!0,get:()=>c.getElementCapabilityTypes});Object.defineProperty(exports,"registerElementCapabilities",{enumerable:!0,get:()=>c.registerElementCapabilities});Object.defineProperty(exports,"resetElementCapabilities",{enumerable:!0,get:()=>c.resetElementCapabilities});exports.BUILTIN_ELEMENT_DEFINITIONS=fo;exports.DesignerStore=lr;exports.PRINT_DESIGNER_ATTRIBUTES=Di;exports.PRINT_DESIGNER_BOOLEAN_ATTRIBUTES=xr;exports.PRINT_DESIGNER_CONTRACT_VERSION=Ai;exports.PRINT_DESIGNER_EVENT=Le;exports.PRINT_DESIGNER_EVENTS=Er;exports.PRINT_DESIGNER_EVENT_OPTIONS=za;exports.PRINT_DESIGNER_METHODS=yr;exports.PRINT_DESIGNER_PARTS=Mi;exports.PRINT_DESIGNER_PROPERTY_NAMES=wr;exports.PRINT_DESIGNER_TAG=br;exports.PRINT_DESIGNER_THEME_TOKENS=vr;exports.PrintDesignerElement=Ye;exports.TILING_SINGLE_PAGE_TIP=pi;exports.createDefaultTemplate=$t;exports.definePrintDesigner=Yr;exports.getElementDblEditableField=gr;exports.getElementDefinition=nt;exports.getElementDefinitions=ur;exports.getElementLayerIcon=mr;exports.getElementPropertyGroup=fr;exports.getHostContract=hi;exports.getMaterialElementDefinitions=hr;exports.registerAll=vc;exports.registerElementDefinition=Pa;exports.registerElementRenderer=Ia;exports.registerElementRenderers=pr;exports.resetElementDefinitions=La;exports.serializePage=sr;exports.subscribeElementDefinitions=cr;exports.toRuntimePool=ki;
|