@bluechaine/print-designer 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,26 @@
1
1
  "use strict";
2
+ var _a, _b, _c, _d;
2
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
4
  const vueDemi = require("vue-demi");
4
- const vuePluginHiprint = require("vue-plugin-hiprint");
5
+ const VuePluginHiprint = require("vue-plugin-hiprint");
5
6
  const Vue = require("vue");
7
+ function _interopNamespaceDefault(e) {
8
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
9
+ if (e) {
10
+ for (const k in e) {
11
+ if (k !== "default") {
12
+ const d = Object.getOwnPropertyDescriptor(e, k);
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: () => e[k]
16
+ });
17
+ }
18
+ }
19
+ }
20
+ n.default = e;
21
+ return Object.freeze(n);
22
+ }
23
+ const VuePluginHiprint__namespace = /* @__PURE__ */ _interopNamespaceDefault(VuePluginHiprint);
6
24
  /**
7
25
  * (c) Iconify
8
26
  *
@@ -2668,10 +2686,10 @@ function isIconifyName(value) {
2668
2686
  return !!value && !value.trim().startsWith("<");
2669
2687
  }
2670
2688
  function elementTypeKey(item) {
2671
- var _a, _b;
2672
- const type = String(((_a = item == null ? void 0 : item.printElementType) == null ? void 0 : _a.type) || "");
2689
+ var _a2, _b2;
2690
+ const type = String(((_a2 = item == null ? void 0 : item.printElementType) == null ? void 0 : _a2.type) || "");
2673
2691
  if (type && ELEMENT_ICON_NAMES[type]) return type;
2674
- const tid = String(((_b = item == null ? void 0 : item.printElementType) == null ? void 0 : _b.tid) || "");
2692
+ const tid = String(((_b2 = item == null ? void 0 : item.printElementType) == null ? void 0 : _b2.tid) || "");
2675
2693
  const short = tid.split(".").pop() || type;
2676
2694
  return short && ELEMENT_ICON_NAMES[short] ? short : "text";
2677
2695
  }
@@ -2800,12 +2818,12 @@ function detectPaperType(width, height, list = defaultPaperList) {
2800
2818
  return (match == null ? void 0 : match.type) || "自定义";
2801
2819
  }
2802
2820
  function resolveTemplate(tplId) {
2803
- var _a, _b;
2821
+ var _a2;
2804
2822
  const cached = templateRegistry.get(tplId);
2805
2823
  if (cached) return cached;
2806
2824
  try {
2807
- const lib = ((_a = vuePluginHiprint.hiprint) == null ? void 0 : _a.instance) ?? vuePluginHiprint.hiprint;
2808
- return ((_b = lib == null ? void 0 : lib.getPrintTemplateById) == null ? void 0 : _b.call(lib, tplId)) ?? null;
2825
+ const lib = (hiprint == null ? void 0 : hiprint.instance) ?? hiprint;
2826
+ return ((_a2 = lib == null ? void 0 : lib.getPrintTemplateById) == null ? void 0 : _a2.call(lib, tplId)) ?? null;
2809
2827
  } catch {
2810
2828
  return null;
2811
2829
  }
@@ -2895,11 +2913,11 @@ PaperListOptionItem.prototype.createTarget = function(printTemplate) {
2895
2913
  return wrapper;
2896
2914
  };
2897
2915
  PaperListOptionItem.prototype.getValue = function() {
2898
- var _a, _b, _c;
2916
+ var _a2, _b2, _c2;
2899
2917
  return {
2900
- type: String(((_a = this.typeSelect) == null ? void 0 : _a.val()) || "自定义"),
2901
- width: Number((_b = this.widthInput) == null ? void 0 : _b.val()) || 0,
2902
- height: Number((_c = this.heightInput) == null ? void 0 : _c.val()) || 0
2918
+ type: String(((_a2 = this.typeSelect) == null ? void 0 : _a2.val()) || "自定义"),
2919
+ width: Number((_b2 = this.widthInput) == null ? void 0 : _b2.val()) || 0,
2920
+ height: Number((_c2 = this.heightInput) == null ? void 0 : _c2.val()) || 0
2903
2921
  };
2904
2922
  };
2905
2923
  PaperListOptionItem.prototype.setValue = function(value) {
@@ -2917,8 +2935,8 @@ PaperListOptionItem.prototype.setValue = function(value) {
2917
2935
  this.heightInput.val(value.height || "");
2918
2936
  };
2919
2937
  PaperListOptionItem.prototype.destroy = function() {
2920
- var _a, _b;
2921
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
2938
+ var _a2, _b2;
2939
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
2922
2940
  };
2923
2941
  function OrientOptionItem() {
2924
2942
  this.name = "orient";
@@ -2946,18 +2964,18 @@ OrientOptionItem.prototype.createTarget = function() {
2946
2964
  return this.target;
2947
2965
  };
2948
2966
  OrientOptionItem.prototype.getValue = function() {
2949
- var _a, _b, _c, _d;
2950
- const val = (_d = (_c = (_b = (_a = this.target) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, "select")) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c);
2967
+ var _a2, _b2, _c2, _d2;
2968
+ const val = (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2);
2951
2969
  if (val === "" || val == null) return void 0;
2952
2970
  return parseFloat(String(val));
2953
2971
  };
2954
2972
  OrientOptionItem.prototype.setValue = function(value) {
2955
- var _a, _b, _c, _d;
2956
- (_d = (_c = (_b = (_a = this.target) == null ? void 0 : _a.find) == null ? void 0 : _b.call(_a, "select")) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, value ?? "");
2973
+ var _a2, _b2, _c2, _d2;
2974
+ (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value ?? "");
2957
2975
  };
2958
2976
  OrientOptionItem.prototype.destroy = function() {
2959
- var _a, _b;
2960
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
2977
+ var _a2, _b2;
2978
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
2961
2979
  };
2962
2980
  const WATERMARK_TIME_FORMATS = [
2963
2981
  "YYYY-MM-DD HH:mm:ss",
@@ -3051,10 +3069,10 @@ WatermarkOptionItem.prototype.createTarget = function() {
3051
3069
  return this.target;
3052
3070
  };
3053
3071
  WatermarkOptionItem.prototype.getValue = function() {
3054
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
3055
- const format = (_b = (_a = this.format) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a);
3072
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
3073
+ const format = (_b2 = (_a2 = this.format) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
3056
3074
  return {
3057
- content: ((_d = (_c = this.content) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c)) || "",
3075
+ content: ((_d2 = (_c2 = this.content) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || "",
3058
3076
  fillStyle: ((_f = (_e = this.fillStyle) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e)) || "rgba(184, 184, 184, 0.3)",
3059
3077
  fontSize: `${parseInt(String(((_h = (_g = this.fontSize) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g)) || "14"), 10)}px`,
3060
3078
  rotate: parseInt(String(((_j = (_i = this.rotate) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i)) || "25"), 10),
@@ -3065,10 +3083,10 @@ WatermarkOptionItem.prototype.getValue = function() {
3065
3083
  };
3066
3084
  };
3067
3085
  WatermarkOptionItem.prototype.setValue = function(value) {
3068
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3086
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3069
3087
  if (!value) value = {};
3070
- (_b = (_a = this.content) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a, value.content || "");
3071
- (_d = (_c = this.fillStyle) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, value.fillStyle || "rgba(184, 184, 184, 0.3)");
3088
+ (_b2 = (_a2 = this.content) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.content || "");
3089
+ (_d2 = (_c2 = this.fillStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.fillStyle || "rgba(184, 184, 184, 0.3)");
3072
3090
  try {
3073
3091
  (_f = (_e = this.fillStyle) == null ? void 0 : _e.minicolors) == null ? void 0 : _f.call(_e, {
3074
3092
  format: "rgb",
@@ -3086,8 +3104,8 @@ WatermarkOptionItem.prototype.setValue = function(value) {
3086
3104
  (_r = (_q = this.format) == null ? void 0 : _q.val) == null ? void 0 : _r.call(_q, value.format || "YYYY-MM-DD HH:mm");
3087
3105
  };
3088
3106
  WatermarkOptionItem.prototype.destroy = function() {
3089
- var _a, _b;
3090
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
3107
+ var _a2, _b2;
3108
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
3091
3109
  };
3092
3110
  function PanelBackgroundColorOptionItem() {
3093
3111
  this.name = "backgroundColor";
@@ -3106,21 +3124,21 @@ PanelBackgroundColorOptionItem.prototype.createTarget = function() {
3106
3124
  return this.target;
3107
3125
  };
3108
3126
  PanelBackgroundColorOptionItem.prototype.getValue = function() {
3109
- var _a, _b;
3110
- const val = (_b = (_a = this.input) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a);
3127
+ var _a2, _b2;
3128
+ const val = (_b2 = (_a2 = this.input) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
3111
3129
  return val ? String(val) : void 0;
3112
3130
  };
3113
3131
  PanelBackgroundColorOptionItem.prototype.setValue = function(value) {
3114
- var _a, _b, _c, _d;
3132
+ var _a2, _b2, _c2, _d2;
3115
3133
  const color = value || "#ffffff";
3116
3134
  try {
3117
- (_b = (_a = this.input) == null ? void 0 : _a.minicolors) == null ? void 0 : _b.call(_a, {
3135
+ (_b2 = (_a2 = this.input) == null ? void 0 : _a2.minicolors) == null ? void 0 : _b2.call(_a2, {
3118
3136
  defaultValue: color,
3119
3137
  theme: "bootstrap"
3120
3138
  });
3121
3139
  } catch {
3122
3140
  }
3123
- (_d = (_c = this.input) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, color);
3141
+ (_d2 = (_c2 = this.input) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, color);
3124
3142
  };
3125
3143
  PanelBackgroundColorOptionItem.prototype.css = function(target, value) {
3126
3144
  const $ = getJQuery();
@@ -3133,19 +3151,19 @@ PanelBackgroundColorOptionItem.prototype.css = function(target, value) {
3133
3151
  return null;
3134
3152
  };
3135
3153
  PanelBackgroundColorOptionItem.prototype.destroy = function() {
3136
- var _a, _b;
3137
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
3154
+ var _a2, _b2;
3155
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
3138
3156
  };
3139
3157
  function applyPanelBackgroundColor(panel, color) {
3140
- var _a, _b, _c, _d;
3158
+ var _a2, _b2, _c2, _d2;
3141
3159
  if (!panel) return;
3142
3160
  const value = color || "#ffffff";
3143
3161
  panel.backgroundColor = value;
3144
3162
  const $ = getJQuery();
3145
- const paper = ((_a = panel.designPaper) == null ? void 0 : _a.target) || ((_c = (_b = panel.target) == null ? void 0 : _b.find) == null ? void 0 : _c.call(_b, ".hiprint-printPaper")) || ($ && panel.target ? $(panel.target).find(".hiprint-printPaper") : null);
3163
+ const paper = ((_a2 = panel.designPaper) == null ? void 0 : _a2.target) || ((_c2 = (_b2 = panel.target) == null ? void 0 : _b2.find) == null ? void 0 : _c2.call(_b2, ".hiprint-printPaper")) || ($ && panel.target ? $(panel.target).find(".hiprint-printPaper") : null);
3146
3164
  if (paper == null ? void 0 : paper.css) {
3147
3165
  paper.css("background-color", value);
3148
- } else if ((paper == null ? void 0 : paper.length) && ((_d = paper[0]) == null ? void 0 : _d.style)) {
3166
+ } else if ((paper == null ? void 0 : paper.length) && ((_d2 = paper[0]) == null ? void 0 : _d2.style)) {
3149
3167
  paper[0].style.backgroundColor = value;
3150
3168
  }
3151
3169
  }
@@ -3217,33 +3235,33 @@ PanelLayoutOptionItem.prototype.createTarget = function() {
3217
3235
  return this.target;
3218
3236
  };
3219
3237
  PanelLayoutOptionItem.prototype.getValue = function() {
3220
- var _a, _b, _c, _d;
3238
+ var _a2, _b2, _c2, _d2;
3221
3239
  const num = (el) => {
3222
- var _a2;
3223
- return parseInt(String(((_a2 = el == null ? void 0 : el.val) == null ? void 0 : _a2.call(el)) || 0), 10) || 0;
3240
+ var _a3;
3241
+ return parseInt(String(((_a3 = el == null ? void 0 : el.val) == null ? void 0 : _a3.call(el)) || 0), 10) || 0;
3224
3242
  };
3225
3243
  return {
3226
- layoutType: ((_b = (_a = this.layoutType) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a)) || "column",
3244
+ layoutType: ((_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2)) || "column",
3227
3245
  layoutRowGap: num(this.layoutRowGap),
3228
3246
  layoutColumnGap: num(this.layoutColumnGap),
3229
3247
  paperWidth: num(this.paperWidth),
3230
3248
  paperHeight: num(this.paperHeight),
3231
- paperStyle: ((_d = (_c = this.paperStyle) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c)) || ""
3249
+ paperStyle: ((_d2 = (_c2 = this.paperStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || ""
3232
3250
  };
3233
3251
  };
3234
3252
  PanelLayoutOptionItem.prototype.setValue = function(value) {
3235
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3253
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l;
3236
3254
  if (!value) return;
3237
- (_b = (_a = this.layoutType) == null ? void 0 : _a.val) == null ? void 0 : _b.call(_a, value.layoutType || "column");
3238
- (_d = (_c = this.layoutRowGap) == null ? void 0 : _c.val) == null ? void 0 : _d.call(_c, value.layoutRowGap ?? "");
3255
+ (_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.layoutType || "column");
3256
+ (_d2 = (_c2 = this.layoutRowGap) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.layoutRowGap ?? "");
3239
3257
  (_f = (_e = this.layoutColumnGap) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e, value.layoutColumnGap ?? "");
3240
3258
  (_h = (_g = this.paperWidth) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g, value.paperWidth ?? "");
3241
3259
  (_j = (_i = this.paperHeight) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i, value.paperHeight ?? "");
3242
3260
  (_l = (_k = this.paperStyle) == null ? void 0 : _k.val) == null ? void 0 : _l.call(_k, value.paperStyle ?? "");
3243
3261
  };
3244
3262
  PanelLayoutOptionItem.prototype.destroy = function() {
3245
- var _a, _b;
3246
- (_b = (_a = this.target) == null ? void 0 : _a.remove) == null ? void 0 : _b.call(_a);
3263
+ var _a2, _b2;
3264
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
3247
3265
  };
3248
3266
  function reorderPanelSettingOptions(options, panel, paperList) {
3249
3267
  const {
@@ -3262,11 +3280,11 @@ function reorderPanelSettingOptions(options, panel, paperList) {
3262
3280
  };
3263
3281
  }
3264
3282
  function ensurePaperListSupportOptionsFirst() {
3265
- var _a, _b, _c, _d;
3283
+ var _a2, _b2, _c2;
3266
3284
  try {
3267
3285
  const cfg = window.HIPRINT_CONFIG;
3268
- const instanceOpts = (_c = (_b = (_a = vuePluginHiprint.hiprint) == null ? void 0 : _a.instance) == null ? void 0 : _b.panel) == null ? void 0 : _c.supportOptions;
3269
- const cfgOpts = (_d = cfg == null ? void 0 : cfg.panel) == null ? void 0 : _d.supportOptions;
3286
+ const instanceOpts = (_b2 = (_a2 = hiprint == null ? void 0 : hiprint.instance) == null ? void 0 : _a2.panel) == null ? void 0 : _b2.supportOptions;
3287
+ const cfgOpts = (_c2 = cfg == null ? void 0 : cfg.panel) == null ? void 0 : _c2.supportOptions;
3270
3288
  const opts = instanceOpts || cfgOpts;
3271
3289
  if (!Array.isArray(opts)) return;
3272
3290
  const idx = opts.findIndex((o) => o.name === "paperList");
@@ -3286,8 +3304,8 @@ function ensurePaperListSupportOptionsFirst() {
3286
3304
  }
3287
3305
  }
3288
3306
  function patchPrintTemplatePaperList() {
3289
- var _a;
3290
- const proto = (_a = vuePluginHiprint.hiprint.PrintTemplate) == null ? void 0 : _a.prototype;
3307
+ var _a2;
3308
+ const proto = (_a2 = hiprint.PrintTemplate) == null ? void 0 : _a2.prototype;
3291
3309
  if (!proto || proto.__svpPaperListPatched) return;
3292
3310
  proto.setPaperList = function(list) {
3293
3311
  this._paperList = Array.isArray(list) && list.length ? list : defaultPaperList;
@@ -3298,13 +3316,13 @@ function patchPrintTemplatePaperList() {
3298
3316
  proto.__svpPaperListPatched = true;
3299
3317
  }
3300
3318
  function patchPanelSettingTrigger(onPaperApplied) {
3301
- var _a;
3302
- const bus = (_a = window.hinnn) == null ? void 0 : _a.event;
3319
+ var _a2;
3320
+ const bus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
3303
3321
  if (!bus || bus.__svpPaperListTriggerPatch) return;
3304
3322
  const origTrigger = bus.trigger.bind(bus);
3305
3323
  bus.trigger = function(key, ...args) {
3306
- var _a2;
3307
- if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((_a2 = args[0]) == null ? void 0 : _a2.options)) {
3324
+ var _a3;
3325
+ if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((_a3 = args[0]) == null ? void 0 : _a3.options)) {
3308
3326
  const tplId = key.slice("BuildCustomOptionSettingEventKey_".length);
3309
3327
  const tpl = resolveTemplate(tplId);
3310
3328
  const panel = tpl == null ? void 0 : tpl.editingPanel;
@@ -3335,7 +3353,7 @@ function setupHiprintPaperList(paperList = DEFAULT_PAPER_LIST, onPaperApplied) {
3335
3353
  patchPrintTemplatePaperList();
3336
3354
  patchPanelSettingTrigger(onPaperApplied);
3337
3355
  try {
3338
- vuePluginHiprint.hiprint.setConfig({
3356
+ hiprint.setConfig({
3339
3357
  optionItems: [
3340
3358
  PaperListOptionItem,
3341
3359
  OrientOptionItem,
@@ -3512,13 +3530,13 @@ function applyCustomTableType(current) {
3512
3530
  }
3513
3531
  class SvpElementTypeProvider extends Provider {
3514
3532
  addElementTypes(context) {
3515
- var _a;
3516
- new vuePluginHiprint.defaultElementTypeProvider().addElementTypes(context);
3533
+ var _a2;
3534
+ new VuePluginHiprint.defaultElementTypeProvider().addElementTypes(context);
3517
3535
  if (typeof context.updateElementType === "function") {
3518
3536
  context.updateElementType(TABLE_TID, applyCustomTableType);
3519
3537
  return;
3520
3538
  }
3521
- const current = (_a = context.getElementType) == null ? void 0 : _a.call(context, TABLE_TID);
3539
+ const current = (_a2 = context.getElementType) == null ? void 0 : _a2.call(context, TABLE_TID);
3522
3540
  if (current) applyCustomTableType(current);
3523
3541
  }
3524
3542
  }
@@ -3530,13 +3548,18 @@ function normalizeProviderMap(map) {
3530
3548
  if (!map) return [];
3531
3549
  return Array.isArray(map) ? map : [map];
3532
3550
  }
3551
+ const plugin = VuePluginHiprint__namespace;
3552
+ const hiprint = plugin.hiprint ?? ((_a = plugin.default) == null ? void 0 : _a.hiprint);
3553
+ const defaultElementTypeProvider = plugin.defaultElementTypeProvider ?? ((_b = plugin.default) == null ? void 0 : _b.defaultElementTypeProvider);
3554
+ const autoConnect = plugin.autoConnect ?? ((_c = plugin.default) == null ? void 0 : _c.autoConnect);
3555
+ const disAutoConnect = plugin.disAutoConnect ?? ((_d = plugin.default) == null ? void 0 : _d.disAutoConnect);
3533
3556
  let initialized = false;
3534
3557
  function initHiprint(options = {}) {
3535
- var _a;
3558
+ var _a2;
3536
3559
  const providers = ensureProviders(options.providers);
3537
3560
  if (!initialized) {
3538
3561
  try {
3539
- vuePluginHiprint.hiprint.init({ providers, ...options.config ?? {} });
3562
+ hiprint.init({ providers, ...options.config ?? {} });
3540
3563
  setupHiprintPaperList(
3541
3564
  options.paperList ?? DEFAULT_PAPER_LIST,
3542
3565
  options.onPaperApplied
@@ -3545,12 +3568,12 @@ function initHiprint(options = {}) {
3545
3568
  console.error("[vue3-print-designer] hiprint.init failed", e);
3546
3569
  }
3547
3570
  initialized = true;
3548
- } else if ((_a = options.providers) == null ? void 0 : _a.length) {
3571
+ } else if ((_a2 = options.providers) == null ? void 0 : _a2.length) {
3549
3572
  try {
3550
3573
  options.providers.forEach(
3551
3574
  (p) => {
3552
- var _a2, _b;
3553
- return (_b = (_a2 = vuePluginHiprint.hiprint.PrintElementTypeManager) == null ? void 0 : _a2.build) == null ? void 0 : _b.call(_a2, [p]);
3575
+ var _a3, _b2;
3576
+ return (_b2 = (_a3 = hiprint.PrintElementTypeManager) == null ? void 0 : _a3.build) == null ? void 0 : _b2.call(_a3, [p]);
3554
3577
  }
3555
3578
  );
3556
3579
  } catch (e) {
@@ -3559,11 +3582,11 @@ function initHiprint(options = {}) {
3559
3582
  }
3560
3583
  if (options.autoConnect === false) {
3561
3584
  try {
3562
- vuePluginHiprint.disAutoConnect();
3585
+ disAutoConnect();
3563
3586
  } catch (_) {
3564
3587
  }
3565
3588
  }
3566
- return vuePluginHiprint.hiprint;
3589
+ return hiprint;
3567
3590
  }
3568
3591
  function buildByHtml(selectors) {
3569
3592
  if (typeof window === "undefined") return;
@@ -3577,13 +3600,474 @@ function buildByHtml(selectors) {
3577
3600
  const $els = $(sel);
3578
3601
  if ($els.length) {
3579
3602
  try {
3580
- vuePluginHiprint.hiprint.PrintElementTypeManager.buildByHtml($els);
3603
+ hiprint.PrintElementTypeManager.buildByHtml($els);
3581
3604
  } catch (e) {
3582
3605
  console.warn("[vue3-print-designer] buildByHtml failed", sel, e);
3583
3606
  }
3584
3607
  }
3585
3608
  });
3586
3609
  }
3610
+ function normalizePrinterList(raw) {
3611
+ if (!Array.isArray(raw)) return [];
3612
+ return raw.map((item) => {
3613
+ if (typeof item === "string") {
3614
+ return { name: item, displayName: item };
3615
+ }
3616
+ if (!item || typeof item !== "object") return null;
3617
+ const record = item;
3618
+ const name = String(record.name ?? record.Name ?? "");
3619
+ if (!name) return null;
3620
+ return {
3621
+ ...record,
3622
+ name,
3623
+ displayName: String(record.displayName ?? record.DisplayName ?? name),
3624
+ isDefault: Boolean(record.isDefault ?? record.IsDefault ?? record.default)
3625
+ };
3626
+ }).filter((item) => item != null);
3627
+ }
3628
+ function normalizeClientList(raw) {
3629
+ if (!Array.isArray(raw)) return [];
3630
+ return raw.filter((item) => item && typeof item === "object");
3631
+ }
3632
+ function buildPrint2Payload(options) {
3633
+ if (!options) {
3634
+ return { printer: "", title: "print" };
3635
+ }
3636
+ const {
3637
+ printer,
3638
+ title,
3639
+ client,
3640
+ printByFragments,
3641
+ generateHTMLInterval,
3642
+ fragmentSize,
3643
+ sendInterval,
3644
+ ...rest
3645
+ } = options;
3646
+ return {
3647
+ printer: printer ?? "",
3648
+ title: title ?? "print",
3649
+ ...client != null ? { client } : {},
3650
+ ...printByFragments != null ? { printByFragments } : {},
3651
+ ...generateHTMLInterval != null ? { generateHTMLInterval } : {},
3652
+ ...fragmentSize != null ? { fragmentSize } : {},
3653
+ ...sendInterval != null ? { sendInterval } : {},
3654
+ ...rest
3655
+ };
3656
+ }
3657
+ function readSocketConnected() {
3658
+ try {
3659
+ const ws = hiprint.hiwebSocket;
3660
+ if (!ws) return false;
3661
+ if (ws.opened === true || ws.connected === true) return true;
3662
+ if (typeof ws.isConnected === "function" && ws.isConnected()) return true;
3663
+ return false;
3664
+ } catch {
3665
+ return false;
3666
+ }
3667
+ }
3668
+ const _PrintClient = class _PrintClient {
3669
+ constructor() {
3670
+ this.status = { connected: false };
3671
+ this.initConfig = {};
3672
+ this.connectPromise = null;
3673
+ this.connectionCallbacks = /* @__PURE__ */ new Set();
3674
+ this.printSuccessCallbacks = /* @__PURE__ */ new Set();
3675
+ this.printErrorCallbacks = /* @__PURE__ */ new Set();
3676
+ }
3677
+ static getInstance() {
3678
+ if (!_PrintClient.instance) _PrintClient.instance = new _PrintClient();
3679
+ return _PrintClient.instance;
3680
+ }
3681
+ connect(options = {}) {
3682
+ if (typeof window === "undefined") {
3683
+ const status = { connected: false, message: "PrintClient requires a browser environment." };
3684
+ this.updateStatus(status);
3685
+ return Promise.resolve(status);
3686
+ }
3687
+ if (this.getStatus().connected) {
3688
+ return Promise.resolve(this.getStatus());
3689
+ }
3690
+ if (this.connectPromise) return this.connectPromise;
3691
+ this.connectPromise = new Promise((resolve) => {
3692
+ var _a2;
3693
+ const timeoutMs = options.timeout ?? 1e4;
3694
+ let settled = false;
3695
+ const finish = (status) => {
3696
+ if (settled) return;
3697
+ settled = true;
3698
+ window.clearTimeout(timer);
3699
+ this.connectPromise = null;
3700
+ this.updateStatus(status);
3701
+ resolve(status);
3702
+ };
3703
+ const timer = window.setTimeout(() => {
3704
+ finish({
3705
+ connected: false,
3706
+ message: "Connection timeout. Is electron-hiprint running?"
3707
+ });
3708
+ }, timeoutMs);
3709
+ const config = { ...this.initConfig };
3710
+ if (options.host) config.host = options.host;
3711
+ if (options.token) config.token = options.token;
3712
+ this.initConfig = config;
3713
+ initHiprint({
3714
+ providers: ensureProviders(),
3715
+ autoConnect: false,
3716
+ config
3717
+ });
3718
+ try {
3719
+ if (options.host && typeof ((_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.setHost) === "function") {
3720
+ hiprint.hiwebSocket.setHost(options.host, options.token);
3721
+ }
3722
+ } catch (e) {
3723
+ console.warn("[print-designer] hiwebSocket.setHost failed", e);
3724
+ }
3725
+ try {
3726
+ autoConnect((status, msg) => {
3727
+ const message = typeof msg === "string" ? msg : msg != null ? String(msg) : status ? void 0 : "Failed to connect to print client.";
3728
+ finish({ connected: !!status, message });
3729
+ });
3730
+ } catch (e) {
3731
+ finish({
3732
+ connected: false,
3733
+ message: e instanceof Error ? e.message : String(e)
3734
+ });
3735
+ }
3736
+ });
3737
+ return this.connectPromise;
3738
+ }
3739
+ disconnect() {
3740
+ try {
3741
+ disAutoConnect();
3742
+ } catch {
3743
+ }
3744
+ this.connectPromise = null;
3745
+ this.updateStatus({ connected: false, message: "Disconnected." });
3746
+ }
3747
+ getStatus() {
3748
+ const socketConnected = readSocketConnected();
3749
+ if (socketConnected && !this.status.connected) {
3750
+ this.status = { connected: true };
3751
+ }
3752
+ if (!socketConnected && this.status.connected) {
3753
+ this.status = { connected: false, message: this.status.message ?? "Disconnected." };
3754
+ }
3755
+ return { ...this.status };
3756
+ }
3757
+ getPrinterList() {
3758
+ var _a2, _b2;
3759
+ try {
3760
+ const list = (_b2 = (_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.getPrinterList) == null ? void 0 : _b2.call(_a2);
3761
+ return normalizePrinterList(list);
3762
+ } catch {
3763
+ return [];
3764
+ }
3765
+ }
3766
+ getClients() {
3767
+ try {
3768
+ const ws = hiprint.hiwebSocket;
3769
+ if (!ws) return [];
3770
+ if (Array.isArray(ws.clients)) return normalizeClientList(ws.clients);
3771
+ if (typeof ws.getClients === "function") {
3772
+ return normalizeClientList(ws.getClients());
3773
+ }
3774
+ return [];
3775
+ } catch {
3776
+ return [];
3777
+ }
3778
+ }
3779
+ async printByTemplate(template, printData, options) {
3780
+ initHiprint({
3781
+ providers: ensureProviders(),
3782
+ autoConnect: false,
3783
+ config: this.initConfig
3784
+ });
3785
+ const instance = new hiprint.PrintTemplate({ template });
3786
+ return this.printByInstance(instance, printData, options);
3787
+ }
3788
+ async printByInstance(printTemplate, printData, options) {
3789
+ if (!this.getStatus().connected) {
3790
+ throw new Error("[print-designer] Print client is not connected. Call connect() first.");
3791
+ }
3792
+ if (typeof (printTemplate == null ? void 0 : printTemplate.print2) !== "function") {
3793
+ throw new Error("[print-designer] print2 is not available on the template instance.");
3794
+ }
3795
+ return new Promise((resolve, reject) => {
3796
+ var _a2, _b2;
3797
+ const onSuccess = (data2) => {
3798
+ cleanup();
3799
+ this.notifyPrintSuccess(data2);
3800
+ resolve();
3801
+ };
3802
+ const onError = (data2) => {
3803
+ cleanup();
3804
+ this.notifyPrintError(data2);
3805
+ reject(data2 instanceof Error ? data2 : new Error(String(data2 ?? "Print failed")));
3806
+ };
3807
+ const cleanup = () => {
3808
+ var _a3, _b3;
3809
+ try {
3810
+ (_a3 = printTemplate.off) == null ? void 0 : _a3.call(printTemplate, "printSuccess", onSuccess);
3811
+ } catch {
3812
+ }
3813
+ try {
3814
+ (_b3 = printTemplate.off) == null ? void 0 : _b3.call(printTemplate, "printError", onError);
3815
+ } catch {
3816
+ }
3817
+ };
3818
+ try {
3819
+ (_a2 = printTemplate.on) == null ? void 0 : _a2.call(printTemplate, "printSuccess", onSuccess);
3820
+ (_b2 = printTemplate.on) == null ? void 0 : _b2.call(printTemplate, "printError", onError);
3821
+ printTemplate.print2(printData, buildPrint2Payload(options));
3822
+ } catch (e) {
3823
+ cleanup();
3824
+ reject(e);
3825
+ }
3826
+ });
3827
+ }
3828
+ onConnectionChange(callback2) {
3829
+ this.connectionCallbacks.add(callback2);
3830
+ return () => {
3831
+ this.connectionCallbacks.delete(callback2);
3832
+ };
3833
+ }
3834
+ onPrintSuccess(callback2) {
3835
+ this.printSuccessCallbacks.add(callback2);
3836
+ return () => {
3837
+ this.printSuccessCallbacks.delete(callback2);
3838
+ };
3839
+ }
3840
+ onPrintError(callback2) {
3841
+ this.printErrorCallbacks.add(callback2);
3842
+ return () => {
3843
+ this.printErrorCallbacks.delete(callback2);
3844
+ };
3845
+ }
3846
+ updateStatus(status) {
3847
+ this.status = status;
3848
+ this.notifyConnectionChange(status);
3849
+ }
3850
+ notifyConnectionChange(status) {
3851
+ this.connectionCallbacks.forEach((cb) => {
3852
+ try {
3853
+ cb(status);
3854
+ } catch (e) {
3855
+ console.error("[print-designer] connection listener failed", e);
3856
+ }
3857
+ });
3858
+ }
3859
+ notifyPrintSuccess(data2) {
3860
+ this.printSuccessCallbacks.forEach((cb) => {
3861
+ try {
3862
+ cb(data2);
3863
+ } catch (e) {
3864
+ console.error("[print-designer] printSuccess listener failed", e);
3865
+ }
3866
+ });
3867
+ }
3868
+ notifyPrintError(data2) {
3869
+ this.printErrorCallbacks.forEach((cb) => {
3870
+ try {
3871
+ cb(data2);
3872
+ } catch (e) {
3873
+ console.error("[print-designer] printError listener failed", e);
3874
+ }
3875
+ });
3876
+ }
3877
+ };
3878
+ _PrintClient.instance = null;
3879
+ let PrintClient = _PrintClient;
3880
+ function getPrintClient() {
3881
+ return PrintClient.getInstance();
3882
+ }
3883
+ function resolvePreviewHtml(value) {
3884
+ if (value == null || value === false) return "";
3885
+ if (typeof value === "string") return value;
3886
+ const any = value;
3887
+ if (typeof any.html === "function") {
3888
+ try {
3889
+ const html = any.html();
3890
+ if (typeof html === "string") return html;
3891
+ } catch {
3892
+ }
3893
+ }
3894
+ if (Array.isArray(value)) {
3895
+ return value.map((item) => resolvePreviewHtml(item)).join("");
3896
+ }
3897
+ if (typeof any.length === "number" && any.length > 0 && any[0] != null) {
3898
+ return resolvePreviewHtml(any[0]);
3899
+ }
3900
+ if (any.target != null) {
3901
+ return resolvePreviewHtml(any.target);
3902
+ }
3903
+ return "";
3904
+ }
3905
+ function collectHostStyles() {
3906
+ if (typeof document === "undefined") return "";
3907
+ const parts = [];
3908
+ document.querySelectorAll('link[rel="stylesheet"]').forEach((el) => {
3909
+ const href = el.getAttribute("href");
3910
+ if (!href) return;
3911
+ const media = el.getAttribute("media");
3912
+ const mediaAttr = media ? ` media="${media}"` : "";
3913
+ parts.push(`<link rel="stylesheet" href="${href}"${mediaAttr}>`);
3914
+ if (media && /print/i.test(media) && href.includes("print-lock.css")) {
3915
+ parts.push(`<link rel="stylesheet" href="${href}">`);
3916
+ }
3917
+ });
3918
+ document.querySelectorAll("style").forEach((el) => {
3919
+ parts.push(`<style>${el.textContent ?? ""}</style>`);
3920
+ });
3921
+ return parts.join("\n");
3922
+ }
3923
+ function buildIframeDocument(args) {
3924
+ const handlerStyles = args.styleHandler ? args.styleHandler() : "";
3925
+ const hostStyles = args.importCss ? collectHostStyles() : "";
3926
+ return `<!DOCTYPE html>
3927
+ <html>
3928
+ <head>
3929
+ <meta charset="UTF-8">
3930
+ <title>${args.title}</title>
3931
+ ${hostStyles}
3932
+ ${handlerStyles}
3933
+ </head>
3934
+ <body>${args.html}</body>
3935
+ </html>`;
3936
+ }
3937
+ function printIframe(args) {
3938
+ if (typeof document === "undefined" || typeof window === "undefined") {
3939
+ return Promise.resolve();
3940
+ }
3941
+ const previous = document.getElementById("svp_batch_print_iframe");
3942
+ if (previous == null ? void 0 : previous.parentNode) previous.parentNode.removeChild(previous);
3943
+ const iframe = document.createElement("iframe");
3944
+ iframe.id = "svp_batch_print_iframe";
3945
+ iframe.setAttribute(
3946
+ "style",
3947
+ "visibility: hidden; height: 0; width: 0; position: absolute; border: 0;"
3948
+ );
3949
+ document.body.appendChild(iframe);
3950
+ const cleanup = () => {
3951
+ try {
3952
+ if (iframe.parentNode) iframe.parentNode.removeChild(iframe);
3953
+ } catch {
3954
+ }
3955
+ };
3956
+ return new Promise((resolve) => {
3957
+ let triggered = false;
3958
+ const trigger = () => {
3959
+ if (triggered) return;
3960
+ triggered = true;
3961
+ try {
3962
+ const win = iframe.contentWindow;
3963
+ if (!win) {
3964
+ cleanup();
3965
+ resolve();
3966
+ return;
3967
+ }
3968
+ const finish = () => {
3969
+ var _a2;
3970
+ (_a2 = args.callback) == null ? void 0 : _a2.call(args);
3971
+ setTimeout(() => {
3972
+ cleanup();
3973
+ resolve();
3974
+ }, 500);
3975
+ };
3976
+ const onAfterPrint = () => {
3977
+ win.removeEventListener("afterprint", onAfterPrint);
3978
+ finish();
3979
+ };
3980
+ win.addEventListener("afterprint", onAfterPrint);
3981
+ try {
3982
+ win.focus();
3983
+ win.print();
3984
+ } catch (e) {
3985
+ console.error("[batch-print] window.print failed", e);
3986
+ finish();
3987
+ }
3988
+ setTimeout(finish, 6e4);
3989
+ } catch (e) {
3990
+ console.error("[batch-print] trigger failed", e);
3991
+ cleanup();
3992
+ resolve();
3993
+ }
3994
+ };
3995
+ iframe.onload = () => {
3996
+ waitForImages(iframe.contentDocument, trigger);
3997
+ };
3998
+ setTimeout(() => {
3999
+ if (!triggered) trigger();
4000
+ }, args.timeout);
4001
+ const doc = iframe.contentDocument;
4002
+ const docString = buildIframeDocument(args);
4003
+ if (doc) {
4004
+ doc.open();
4005
+ doc.write(docString);
4006
+ doc.close();
4007
+ } else {
4008
+ iframe.srcdoc = docString;
4009
+ }
4010
+ });
4011
+ }
4012
+ function waitForImages(doc, done, attempt = 0) {
4013
+ if (!doc) {
4014
+ done();
4015
+ return;
4016
+ }
4017
+ const imgs = doc.getElementsByTagName("img");
4018
+ let ready = true;
4019
+ for (let i = 0; i < imgs.length; i++) {
4020
+ const img = imgs[i];
4021
+ if (!img.src || img.src.indexOf("base64") >= 0) continue;
4022
+ if (img.complete && (img.naturalWidth ?? 1) > 0) continue;
4023
+ ready = false;
4024
+ break;
4025
+ }
4026
+ if (ready || attempt >= 10) {
4027
+ done();
4028
+ return;
4029
+ }
4030
+ setTimeout(() => waitForImages(doc, done, attempt + 1), 500);
4031
+ }
4032
+ function pageWrap(html, withBreak) {
4033
+ const breakStyle = withBreak ? ' style="page-break-after: always; break-after: page;"' : "";
4034
+ return `<div class="svp-batch-page"${breakStyle}>${html}</div>`;
4035
+ }
4036
+ async function batchPrint(printTemplate, printDataList, options = {}) {
4037
+ if (!printTemplate || typeof printTemplate.getHtml !== "function") {
4038
+ throw new Error("[batch-print] printTemplate.getHtml is required.");
4039
+ }
4040
+ const list = Array.isArray(printDataList) ? printDataList : [printDataList];
4041
+ if (!list.length) {
4042
+ throw new Error("[batch-print] printDataList is empty.");
4043
+ }
4044
+ const copies = Math.max(1, Math.floor(options.copies ?? 1));
4045
+ const pageBreak = options.pageBreak !== false;
4046
+ const title = options.title ?? "print";
4047
+ const expanded = [];
4048
+ for (const item of list) {
4049
+ for (let i = 0; i < copies; i++) expanded.push(item);
4050
+ }
4051
+ const fragments = [];
4052
+ for (let i = 0; i < expanded.length; i++) {
4053
+ const raw = printTemplate.getHtml(expanded[i]);
4054
+ const html = resolvePreviewHtml(raw);
4055
+ if (!html) continue;
4056
+ const isLast = i === expanded.length - 1;
4057
+ fragments.push(pageWrap(html, pageBreak && !isLast));
4058
+ }
4059
+ if (!fragments.length) {
4060
+ throw new Error("[batch-print] No HTML produced from print data.");
4061
+ }
4062
+ await printIframe({
4063
+ html: fragments.join("\n"),
4064
+ title,
4065
+ styleHandler: options.styleHandler,
4066
+ importCss: options.importCss !== false,
4067
+ callback: options.callback,
4068
+ timeout: Math.max(500, options.timeout ?? 1500)
4069
+ });
4070
+ }
3587
4071
  class PluginManager {
3588
4072
  constructor() {
3589
4073
  this.hooks = /* @__PURE__ */ new Map();
@@ -3594,12 +4078,12 @@ class PluginManager {
3594
4078
  this.plugins = [];
3595
4079
  plugins.forEach((p) => this.register(p));
3596
4080
  }
3597
- register(plugin) {
3598
- var _a;
3599
- if (!plugin || !Array.isArray(plugin.hooks)) return;
3600
- this.plugins.push(plugin);
3601
- (_a = plugin.init) == null ? void 0 : _a.call(plugin, plugin.config ?? {});
3602
- plugin.hooks.forEach((h) => {
4081
+ register(plugin2) {
4082
+ var _a2;
4083
+ if (!plugin2 || !Array.isArray(plugin2.hooks)) return;
4084
+ this.plugins.push(plugin2);
4085
+ (_a2 = plugin2.init) == null ? void 0 : _a2.call(plugin2, plugin2.config ?? {});
4086
+ plugin2.hooks.forEach((h) => {
3603
4087
  const arr = this.hooks.get(h.hook) ?? [];
3604
4088
  arr.push(h);
3605
4089
  arr.sort((a, b) => (a.priority ?? 100) - (b.priority ?? 100));
@@ -3610,8 +4094,8 @@ class PluginManager {
3610
4094
  return this.plugins.slice();
3611
4095
  }
3612
4096
  has(hook) {
3613
- var _a;
3614
- return (((_a = this.hooks.get(hook)) == null ? void 0 : _a.length) ?? 0) > 0;
4097
+ var _a2;
4098
+ return (((_a2 = this.hooks.get(hook)) == null ? void 0 : _a2.length) ?? 0) > 0;
3615
4099
  }
3616
4100
  /** Run all callbacks sequentially. Returns the array of results. */
3617
4101
  async run(hook, ...args) {
@@ -3736,9 +4220,9 @@ class HistoryController {
3736
4220
  this.onChanged = onChanged;
3737
4221
  }
3738
4222
  applySnapshot(tpl, json, panelIndex) {
3739
- var _a, _b, _c;
4223
+ var _a2, _b2, _c2;
3740
4224
  if (!(tpl == null ? void 0 : tpl.update) || json == null) return;
3741
- const index2 = panelIndex ?? ((_a = tpl.editingPanel) == null ? void 0 : _a.index) ?? ((_c = (_b = tpl.printPanels) == null ? void 0 : _b[0]) == null ? void 0 : _c.index) ?? 0;
4225
+ const index2 = panelIndex ?? ((_a2 = tpl.editingPanel) == null ? void 0 : _a2.index) ?? ((_c2 = (_b2 = tpl.printPanels) == null ? void 0 : _b2[0]) == null ? void 0 : _c2.index) ?? 0;
3742
4226
  tpl.update(json, index2);
3743
4227
  }
3744
4228
  refreshFromTemplate() {
@@ -3793,9 +4277,9 @@ class HistoryController {
3793
4277
  this.finishChange();
3794
4278
  }
3795
4279
  jump(index2) {
3796
- var _a;
4280
+ var _a2;
3797
4281
  const tpl = this.getTpl();
3798
- if (!(tpl == null ? void 0 : tpl.history) || !((_a = tpl.historyList) == null ? void 0 : _a[index2])) return;
4282
+ if (!(tpl == null ? void 0 : tpl.history) || !((_a2 = tpl.historyList) == null ? void 0 : _a2[index2])) return;
3799
4283
  tpl.historyPos = index2;
3800
4284
  const entry = tpl.historyList[index2];
3801
4285
  this.applySnapshot(tpl, entry == null ? void 0 : entry.json);
@@ -3828,9 +4312,9 @@ class HistoryController {
3828
4312
  this.finishChange();
3829
4313
  }
3830
4314
  finishChange() {
3831
- var _a;
4315
+ var _a2;
3832
4316
  this.refreshFromTemplate();
3833
- (_a = this.onChanged) == null ? void 0 : _a.call(this);
4317
+ (_a2 = this.onChanged) == null ? void 0 : _a2.call(this);
3834
4318
  }
3835
4319
  }
3836
4320
  function normalize(e) {
@@ -3861,8 +4345,8 @@ class ShortcutsController {
3861
4345
  mount() {
3862
4346
  if (typeof window === "undefined" || this.handler) return;
3863
4347
  this.handler = (e) => {
3864
- var _a, _b;
3865
- if (((_b = (_a = this.options).beforeDispatch) == null ? void 0 : _b.call(_a, e)) === false) return;
4348
+ var _a2, _b2;
4349
+ if (((_b2 = (_a2 = this.options).beforeDispatch) == null ? void 0 : _b2.call(_a2, e)) === false) return;
3866
4350
  const t = e.target;
3867
4351
  if (t && (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable)) {
3868
4352
  const combo2 = normalize(e);
@@ -4012,7 +4496,7 @@ function openJsonEditorModal(options) {
4012
4496
  });
4013
4497
  ta.addEventListener("scroll", syncScroll);
4014
4498
  modal.addEventListener("click", (e) => {
4015
- var _a;
4499
+ var _a2;
4016
4500
  const act = e.target.dataset.act;
4017
4501
  if (act === "cancel") close(null);
4018
4502
  else if (act === "clear") {
@@ -4021,7 +4505,7 @@ function openJsonEditorModal(options) {
4021
4505
  syncLines();
4022
4506
  ta.focus();
4023
4507
  } else if (act === "copy") {
4024
- (_a = navigator.clipboard) == null ? void 0 : _a.writeText(ta.value).catch(() => {
4508
+ (_a2 = navigator.clipboard) == null ? void 0 : _a2.writeText(ta.value).catch(() => {
4025
4509
  ta.focus();
4026
4510
  ta.select();
4027
4511
  try {
@@ -4215,7 +4699,19 @@ const zhCN = {
4215
4699
  printDataAddRow: "添加一行",
4216
4700
  printDataDeleteRow: "删除",
4217
4701
  printDataFieldKey: "字段",
4218
- paper: "纸张"
4702
+ paper: "纸张",
4703
+ browserPrint: "浏览器打印",
4704
+ silentPrint: "静默打印",
4705
+ batchPrint: "批量打印",
4706
+ batchPrinting: "正在准备…",
4707
+ batchCopies: "每条份数",
4708
+ batchHint: "共 {rows} 条数据 × 每条份数 = 合计 {total} 页(无需客户端)",
4709
+ printClientConnected: "打印客户端已连接",
4710
+ printClientDisconnected: "打印客户端未连接",
4711
+ printClientConnect: "连接客户端",
4712
+ printClientDisconnect: "断开连接",
4713
+ printClientNoPrinters: "未检测到打印机",
4714
+ defaultPrinter: "默认"
4219
4715
  },
4220
4716
  header: {
4221
4717
  title: "打印设计器"
@@ -4318,7 +4814,19 @@ const enUS = {
4318
4814
  printDataAddRow: "Add row",
4319
4815
  printDataDeleteRow: "Delete",
4320
4816
  printDataFieldKey: "Field",
4321
- paper: "Paper"
4817
+ paper: "Paper",
4818
+ browserPrint: "Browser Print",
4819
+ silentPrint: "Silent Print",
4820
+ batchPrint: "Batch Print",
4821
+ batchPrinting: "Preparing…",
4822
+ batchCopies: "Copies per record",
4823
+ batchHint: "{rows} records × copies = {total} pages (no client required)",
4824
+ printClientConnected: "Print client connected",
4825
+ printClientDisconnected: "Print client disconnected",
4826
+ printClientConnect: "Connect Client",
4827
+ printClientDisconnect: "Disconnect",
4828
+ printClientNoPrinters: "No printers found",
4829
+ defaultPrinter: "Default"
4322
4830
  },
4323
4831
  header: {
4324
4832
  title: "Print Designer"
@@ -4556,8 +5064,21 @@ const _DesignerUtils = class _DesignerUtils {
4556
5064
  setConfig(config) {
4557
5065
  if (config) Object.assign(this.options, { config });
4558
5066
  }
4559
- setConnect(connect, _callback) {
5067
+ setConnect(connect, callback2) {
5068
+ var _a2, _b2;
4560
5069
  this.options.connect = connect;
5070
+ const client = getPrintClient();
5071
+ if (connect) {
5072
+ void client.connect({
5073
+ host: (_a2 = this.options.config) == null ? void 0 : _a2.host,
5074
+ token: (_b2 = this.options.config) == null ? void 0 : _b2.token
5075
+ }).then((status) => {
5076
+ callback2 == null ? void 0 : callback2(status.connected, status.message);
5077
+ });
5078
+ return;
5079
+ }
5080
+ client.disconnect();
5081
+ callback2 == null ? void 0 : callback2(false);
4561
5082
  }
4562
5083
  initProviders(providers) {
4563
5084
  initHiprint({
@@ -4566,9 +5087,9 @@ const _DesignerUtils = class _DesignerUtils {
4566
5087
  config: this.options.config,
4567
5088
  paperList: this.options.paperList,
4568
5089
  onPaperApplied: () => {
4569
- var _a, _b;
5090
+ var _a2, _b2;
4570
5091
  try {
4571
- (_b = (_a = this.ruler) == null ? void 0 : _a.redraw) == null ? void 0 : _b.call(_a);
5092
+ (_b2 = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b2.call(_a2);
4572
5093
  } catch {
4573
5094
  }
4574
5095
  }
@@ -4583,7 +5104,7 @@ const _DesignerUtils = class _DesignerUtils {
4583
5104
  list.forEach((m) => {
4584
5105
  try {
4585
5106
  const $els = $(m.container);
4586
- if ($els.length) vuePluginHiprint.hiprint.PrintElementTypeManager.buildByHtml($els);
5107
+ if ($els.length) hiprint.PrintElementTypeManager.buildByHtml($els);
4587
5108
  } catch (e) {
4588
5109
  console.warn("buildByProvider", e);
4589
5110
  }
@@ -4596,20 +5117,20 @@ const _DesignerUtils = class _DesignerUtils {
4596
5117
  // PrintTemplate lifecycle
4597
5118
  // -------------------------------------------------------------------------
4598
5119
  newPrintTemplate(template) {
4599
- const tpl = new vuePluginHiprint.hiprint.PrintTemplate({ template });
5120
+ const tpl = new hiprint.PrintTemplate({ template });
4600
5121
  return tpl;
4601
5122
  }
4602
5123
  newDesigner(options, designOptions = {}) {
4603
- var _a, _b;
5124
+ var _a2, _b2;
4604
5125
  if (this.printTemplate) {
4605
5126
  this.unbindSelectionEvents();
4606
5127
  this.unbindZoomEvents();
4607
5128
  try {
4608
- (_b = (_a = this.printTemplate).clear) == null ? void 0 : _b.call(_a);
5129
+ (_b2 = (_a2 = this.printTemplate).clear) == null ? void 0 : _b2.call(_a2);
4609
5130
  } catch (_) {
4610
5131
  }
4611
5132
  }
4612
- const tpl = new vuePluginHiprint.hiprint.PrintTemplate({
5133
+ const tpl = new hiprint.PrintTemplate({
4613
5134
  template: options.template,
4614
5135
  settingContainer: options.settingContainer ? options.settingContainer : `#${SETTING_CONTAINER_ID}`,
4615
5136
  paginationContainer: options.paginationContainer,
@@ -4617,19 +5138,19 @@ const _DesignerUtils = class _DesignerUtils {
4617
5138
  history: options.history ?? true,
4618
5139
  onImageChooseClick: options.onImageChooseClick,
4619
5140
  onZoomChange: (scale) => {
4620
- var _a2;
5141
+ var _a3;
4621
5142
  setZoom(scale);
4622
- (_a2 = options.onZoomChange) == null ? void 0 : _a2.call(options, scale);
5143
+ (_a3 = options.onZoomChange) == null ? void 0 : _a3.call(options, scale);
4623
5144
  },
4624
5145
  onPanelAddClick: options.onPanelAddClick,
4625
5146
  onFunctionClick: options.onFunctionClick,
4626
5147
  onDataChanged: (type, json) => {
4627
- var _a2;
5148
+ var _a3;
4628
5149
  this.history.refreshFromTemplate();
4629
5150
  this.refreshSelection();
4630
5151
  this.reapplyElementTransforms();
4631
5152
  designerStore.uiPulse += 1;
4632
- (_a2 = options.onDataChanged) == null ? void 0 : _a2.call(options, type, json);
5153
+ (_a3 = options.onDataChanged) == null ? void 0 : _a3.call(options, type, json);
4633
5154
  },
4634
5155
  onUpdateError: options.onUpdateError
4635
5156
  });
@@ -4662,28 +5183,28 @@ const _DesignerUtils = class _DesignerUtils {
4662
5183
  return tpl;
4663
5184
  }
4664
5185
  unbindSelectionEvents() {
4665
- var _a;
4666
- (_a = this.selectionEventCleanup) == null ? void 0 : _a.call(this);
5186
+ var _a2;
5187
+ (_a2 = this.selectionEventCleanup) == null ? void 0 : _a2.call(this);
4667
5188
  this.selectionEventCleanup = null;
4668
5189
  }
4669
5190
  unbindZoomEvents() {
4670
- var _a;
4671
- (_a = this.zoomEventCleanup) == null ? void 0 : _a.call(this);
5191
+ var _a2;
5192
+ (_a2 = this.zoomEventCleanup) == null ? void 0 : _a2.call(this);
4672
5193
  this.zoomEventCleanup = null;
4673
5194
  }
4674
5195
  /** Keep store/ruler in sync when hiprint paper scale changes (e.g. zoom toolbar). */
4675
5196
  bindZoomEvents(tpl) {
4676
- var _a;
5197
+ var _a2;
4677
5198
  this.unbindZoomEvents();
4678
- const paper = (_a = tpl == null ? void 0 : tpl.editingPanel) == null ? void 0 : _a.designPaper;
5199
+ const paper = (_a2 = tpl == null ? void 0 : tpl.editingPanel) == null ? void 0 : _a2.designPaper;
4679
5200
  if (!(paper == null ? void 0 : paper.subscribePaperBaseInfoChanged)) return;
4680
5201
  const onPaperInfo = (info) => {
4681
- var _a2, _b;
5202
+ var _a3, _b2;
4682
5203
  if (typeof (info == null ? void 0 : info.scale) !== "number" || !(info.scale > 0)) return;
4683
5204
  const next = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, info.scale));
4684
5205
  if (Math.abs(next - this.state.zoom) < 1e-3) return;
4685
5206
  setZoom(next);
4686
- (_b = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b.call(_a2);
5207
+ (_b2 = (_a3 = this.ruler) == null ? void 0 : _a3.redraw) == null ? void 0 : _b2.call(_a3);
4687
5208
  };
4688
5209
  paper.subscribePaperBaseInfoChanged(onPaperInfo);
4689
5210
  this.zoomEventCleanup = () => {
@@ -4694,23 +5215,23 @@ const _DesignerUtils = class _DesignerUtils {
4694
5215
  };
4695
5216
  }
4696
5217
  syncZoomFromTemplate() {
4697
- var _a, _b;
5218
+ var _a2, _b2;
4698
5219
  setZoom(this.getZoom());
4699
- (_b = (_a = this.ruler) == null ? void 0 : _a.redraw) == null ? void 0 : _b.call(_a);
5220
+ (_b2 = (_a2 = this.ruler) == null ? void 0 : _a2.redraw) == null ? void 0 : _b2.call(_a2);
4700
5221
  }
4701
5222
  readTemplateScale() {
4702
- var _a, _b, _c;
5223
+ var _a2, _b2, _c2;
4703
5224
  const tpl = this.printTemplate;
4704
5225
  if (!tpl) return null;
4705
- const scale = ((_b = (_a = tpl.editingPanel) == null ? void 0 : _a.designPaper) == null ? void 0 : _b.scale) ?? ((_c = tpl.editingPanel) == null ? void 0 : _c.scale) ?? tpl.scale;
5226
+ const scale = ((_b2 = (_a2 = tpl.editingPanel) == null ? void 0 : _a2.designPaper) == null ? void 0 : _b2.scale) ?? ((_c2 = tpl.editingPanel) == null ? void 0 : _c2.scale) ?? tpl.scale;
4706
5227
  return typeof scale === "number" && scale > 0 ? scale : null;
4707
5228
  }
4708
5229
  /** Sync Vue selection state when hiprint selects / deselects print elements. */
4709
5230
  bindSelectionEvents(tpl) {
4710
- var _a;
5231
+ var _a2;
4711
5232
  this.unbindSelectionEvents();
4712
5233
  if (typeof window === "undefined" || !tpl) return;
4713
- const eventBus = (_a = window.hinnn) == null ? void 0 : _a.event;
5234
+ const eventBus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
4714
5235
  const tplId = tpl.id ?? tpl.templateId;
4715
5236
  if (!eventBus || tplId == null) return;
4716
5237
  const selectKey = `PrintElementSelectEventKey_${tplId}`;
@@ -4752,9 +5273,9 @@ const _DesignerUtils = class _DesignerUtils {
4752
5273
  };
4753
5274
  }
4754
5275
  refreshPrintTemplate() {
4755
- var _a, _b;
5276
+ var _a2, _b2;
4756
5277
  try {
4757
- (_b = (_a = this.printTemplate) == null ? void 0 : _a.refresh) == null ? void 0 : _b.call(_a);
5278
+ (_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.refresh) == null ? void 0 : _b2.call(_a2);
4758
5279
  } catch (_) {
4759
5280
  }
4760
5281
  this.reapplyElementTransforms();
@@ -4801,7 +5322,7 @@ const _DesignerUtils = class _DesignerUtils {
4801
5322
  });
4802
5323
  }
4803
5324
  refreshSelection() {
4804
- var _a, _b, _c, _d;
5325
+ var _a2, _b2, _c2, _d2;
4805
5326
  const tpl = this.printTemplate;
4806
5327
  if (!tpl) {
4807
5328
  setSelection({ count: 0, ids: [], elements: [] });
@@ -4809,15 +5330,15 @@ const _DesignerUtils = class _DesignerUtils {
4809
5330
  }
4810
5331
  let els = [];
4811
5332
  try {
4812
- els = ((_a = tpl.getSelectEls) == null ? void 0 : _a.call(tpl)) ?? [];
5333
+ els = ((_a2 = tpl.getSelectEls) == null ? void 0 : _a2.call(tpl)) ?? [];
4813
5334
  } catch {
4814
5335
  }
4815
5336
  if (!els.length) {
4816
- els = ((_d = (_c = (_b = tpl.editingPanel) == null ? void 0 : _b.printElements) == null ? void 0 : _c.filter) == null ? void 0 : _d.call(_c, (e) => {
4817
- var _a2, _b2, _c2, _d2;
5337
+ els = ((_d2 = (_c2 = (_b2 = tpl.editingPanel) == null ? void 0 : _b2.printElements) == null ? void 0 : _c2.filter) == null ? void 0 : _d2.call(_c2, (e) => {
5338
+ var _a3, _b3, _c3, _d3;
4818
5339
  if (e == null ? void 0 : e.selected) return true;
4819
5340
  try {
4820
- return !!((_b2 = (_a2 = e == null ? void 0 : e.designTarget) == null ? void 0 : _a2.hasClass) == null ? void 0 : _b2.call(_a2, "hiprint-printElement-selected")) || !!((_d2 = (_c2 = e == null ? void 0 : e.designTarget) == null ? void 0 : _c2.hasClass) == null ? void 0 : _d2.call(_c2, "selected"));
5341
+ return !!((_b3 = (_a3 = e == null ? void 0 : e.designTarget) == null ? void 0 : _a3.hasClass) == null ? void 0 : _b3.call(_a3, "hiprint-printElement-selected")) || !!((_d3 = (_c3 = e == null ? void 0 : e.designTarget) == null ? void 0 : _c3.hasClass) == null ? void 0 : _d3.call(_c3, "selected"));
4821
5342
  } catch {
4822
5343
  return false;
4823
5344
  }
@@ -4831,25 +5352,25 @@ const _DesignerUtils = class _DesignerUtils {
4831
5352
  }
4832
5353
  /** Select a print element from auxiliary panels (page structure, etc.). */
4833
5354
  selectPrintElement(item) {
4834
- var _a, _b, _c, _d, _e, _f, _g;
5355
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
4835
5356
  const tpl = this.printTemplate;
4836
5357
  if (!tpl || !item) return;
4837
5358
  const $ = typeof window !== "undefined" ? window.$ || window.jQuery : null;
4838
5359
  const dt = $ == null ? void 0 : $(item.designTarget);
4839
5360
  if ($ && (dt == null ? void 0 : dt.length)) {
4840
- (_b = (_a = tpl.editingPanel) == null ? void 0 : _a.printElements) == null ? void 0 : _b.forEach((el) => {
5361
+ (_b2 = (_a2 = tpl.editingPanel) == null ? void 0 : _a2.printElements) == null ? void 0 : _b2.forEach((el) => {
4841
5362
  if (el === item) return;
4842
5363
  const target = $(el.designTarget);
4843
5364
  if (!(target == null ? void 0 : target.length)) return;
4844
5365
  target.children("div[panelindex]").removeClass("selected").css({ display: "none" });
4845
5366
  });
4846
- const type = String(((_c = item.printElementType) == null ? void 0 : _c.type) || "");
5367
+ const type = String(((_c2 = item.printElementType) == null ? void 0 : _c2.type) || "");
4847
5368
  if (type.includes("table")) {
4848
5369
  dt.find("tr:first td:first").trigger("click");
4849
5370
  } else {
4850
5371
  dt.children("div[panelindex]").addClass("selected").css({ display: "block" });
4851
5372
  try {
4852
- (_f = (_e = (_d = dt.data("hidraggable")) == null ? void 0 : _d.options) == null ? void 0 : _e.onBeforeSelectAllDrag) == null ? void 0 : _f.call(dt[0], {});
5373
+ (_f = (_e = (_d2 = dt.data("hidraggable")) == null ? void 0 : _d2.options) == null ? void 0 : _e.onBeforeSelectAllDrag) == null ? void 0 : _f.call(dt[0], {});
4853
5374
  } catch {
4854
5375
  }
4855
5376
  }
@@ -4872,10 +5393,10 @@ const _DesignerUtils = class _DesignerUtils {
4872
5393
  const $ = typeof window !== "undefined" ? window.$ || window.jQuery : null;
4873
5394
  if (!$) return;
4874
5395
  items.forEach((item) => {
4875
- var _a, _b, _c, _d;
5396
+ var _a2, _b2, _c2, _d2;
4876
5397
  const dt = $(item.designTarget);
4877
5398
  if (!(dt == null ? void 0 : dt.length)) return;
4878
- const type = String(((_a = item.printElementType) == null ? void 0 : _a.type) || "");
5399
+ const type = String(((_a2 = item.printElementType) == null ? void 0 : _a2.type) || "");
4879
5400
  if (type.includes("table")) {
4880
5401
  dt.find("tr:first td:first").trigger("click");
4881
5402
  return;
@@ -4883,7 +5404,7 @@ const _DesignerUtils = class _DesignerUtils {
4883
5404
  dt.children("div[panelindex]").addClass("selected").css({ display: "block" });
4884
5405
  try {
4885
5406
  const dom = dt[0];
4886
- (_d = (_c = (_b = dt.data("hidraggable")) == null ? void 0 : _b.options) == null ? void 0 : _c.onBeforeSelectAllDrag) == null ? void 0 : _d.call(dom, {});
5407
+ (_d2 = (_c2 = (_b2 = dt.data("hidraggable")) == null ? void 0 : _b2.options) == null ? void 0 : _c2.onBeforeSelectAllDrag) == null ? void 0 : _d2.call(dom, {});
4887
5408
  } catch {
4888
5409
  }
4889
5410
  });
@@ -4897,9 +5418,9 @@ const _DesignerUtils = class _DesignerUtils {
4897
5418
  // Persistence / IO
4898
5419
  // -------------------------------------------------------------------------
4899
5420
  getTemplateJson() {
4900
- var _a, _b;
5421
+ var _a2, _b2;
4901
5422
  try {
4902
- return ((_b = (_a = this.printTemplate) == null ? void 0 : _a.getJson) == null ? void 0 : _b.call(_a)) ?? null;
5423
+ return ((_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.getJson) == null ? void 0 : _b2.call(_a2)) ?? null;
4903
5424
  } catch {
4904
5425
  return null;
4905
5426
  }
@@ -4908,11 +5429,11 @@ const _DesignerUtils = class _DesignerUtils {
4908
5429
  return `tpl:${this.options.templateKey || "default"}`;
4909
5430
  }
4910
5431
  save() {
4911
- var _a, _b;
5432
+ var _a2, _b2;
4912
5433
  const json = this.getTemplateJson();
4913
5434
  if (!json) return;
4914
5435
  const key = this.options.templateKey || "default";
4915
- const blocked = ((_b = (_a = this.options.events) == null ? void 0 : _a.onSave) == null ? void 0 : _b.call(_a, key, json)) === false;
5436
+ const blocked = ((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onSave) == null ? void 0 : _b2.call(_a2, key, json)) === false;
4916
5437
  if (blocked) return;
4917
5438
  writeJSON(this.templateStorageKey(), json);
4918
5439
  }
@@ -4925,9 +5446,9 @@ const _DesignerUtils = class _DesignerUtils {
4925
5446
  return openJsonEditorModal(options);
4926
5447
  }
4927
5448
  async edit() {
4928
- var _a, _b;
5449
+ var _a2, _b2;
4929
5450
  const json = this.getTemplateJson();
4930
- if (((_b = (_a = this.options.events) == null ? void 0 : _a.onEdit) == null ? void 0 : _b.call(_a, json)) === false) return;
5451
+ if (((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onEdit) == null ? void 0 : _b2.call(_a2, json)) === false) return;
4931
5452
  try {
4932
5453
  const next = await this.openJsonEditor({
4933
5454
  title: translate("designer.editTemplate"),
@@ -4947,8 +5468,8 @@ const _DesignerUtils = class _DesignerUtils {
4947
5468
  }
4948
5469
  }
4949
5470
  async editData() {
4950
- var _a, _b, _c;
4951
- if (((_b = (_a = this.options.events) == null ? void 0 : _a.onEditData) == null ? void 0 : _b.call(_a, this.printData)) === false) return;
5471
+ var _a2, _b2, _c2;
5472
+ if (((_b2 = (_a2 = this.options.events) == null ? void 0 : _a2.onEditData) == null ? void 0 : _b2.call(_a2, this.printData)) === false) return;
4952
5473
  try {
4953
5474
  const schema = extractTemplateFields(this.getTemplateJson());
4954
5475
  const host = this.printDataEditor;
@@ -4973,7 +5494,7 @@ const _DesignerUtils = class _DesignerUtils {
4973
5494
  });
4974
5495
  if (next == null) return;
4975
5496
  this.setPrintData(next);
4976
- (_c = this.onPrintDataChange) == null ? void 0 : _c.call(this, next);
5497
+ (_c2 = this.onPrintDataChange) == null ? void 0 : _c2.call(this, next);
4977
5498
  } catch (e) {
4978
5499
  console.error("[vue3-print-designer] edit print data failed", e);
4979
5500
  }
@@ -4998,8 +5519,8 @@ const _DesignerUtils = class _DesignerUtils {
4998
5519
  input.type = "file";
4999
5520
  input.accept = ".json,application/json";
5000
5521
  input.onchange = () => {
5001
- var _a;
5002
- const file = (_a = input.files) == null ? void 0 : _a[0];
5522
+ var _a2;
5523
+ const file = (_a2 = input.files) == null ? void 0 : _a2[0];
5003
5524
  if (!file) return;
5004
5525
  const reader = new FileReader();
5005
5526
  reader.onload = () => {
@@ -5016,15 +5537,15 @@ const _DesignerUtils = class _DesignerUtils {
5016
5537
  }
5017
5538
  /** Import onto existing paper(s) without creating extra panels. */
5018
5539
  applyImportTemplateJson(json) {
5019
- var _a, _b, _c, _d, _e;
5540
+ var _a2, _b2, _c2, _d2, _e;
5020
5541
  const tpl = this.printTemplate;
5021
5542
  const currentJson = this.getTemplateJson();
5022
- if (!(tpl == null ? void 0 : tpl.update) || !((_a = currentJson == null ? void 0 : currentJson.panels) == null ? void 0 : _a.length)) {
5543
+ if (!(tpl == null ? void 0 : tpl.update) || !((_a2 = currentJson == null ? void 0 : currentJson.panels) == null ? void 0 : _a2.length)) {
5023
5544
  this.applyTemplateJson(json);
5024
5545
  return;
5025
5546
  }
5026
5547
  const merged = mergeImportOntoCurrentPanels(currentJson, json);
5027
- const activeIndex = ((_b = tpl.editingPanel) == null ? void 0 : _b.index) ?? ((_d = (_c = tpl.printPanels) == null ? void 0 : _c[0]) == null ? void 0 : _d.index) ?? 0;
5548
+ const activeIndex = ((_b2 = tpl.editingPanel) == null ? void 0 : _b2.index) ?? ((_d2 = (_c2 = tpl.printPanels) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.index) ?? 0;
5028
5549
  try {
5029
5550
  tpl.update(merged, activeIndex);
5030
5551
  } catch (e) {
@@ -5039,33 +5560,53 @@ const _DesignerUtils = class _DesignerUtils {
5039
5560
  if (nextJson) (_e = this.onTemplateChange) == null ? void 0 : _e.call(this, nextJson);
5040
5561
  }
5041
5562
  applyTemplateJson(json) {
5042
- var _a;
5563
+ var _a2;
5043
5564
  this.newDesigner(
5044
5565
  { template: json, history: true, dataMode: 1 },
5045
5566
  this.options.designOptions || {}
5046
5567
  );
5047
- (_a = this.onTemplateChange) == null ? void 0 : _a.call(this, json);
5568
+ (_a2 = this.onTemplateChange) == null ? void 0 : _a2.call(this, json);
5048
5569
  }
5049
5570
  getPrinterList() {
5050
- var _a, _b;
5051
- try {
5052
- return ((_b = (_a = vuePluginHiprint.hiprint.hiwebSocket) == null ? void 0 : _a.getPrinterList) == null ? void 0 : _b.call(_a)) ?? [];
5053
- } catch {
5054
- return [];
5571
+ return getPrintClient().getPrinterList();
5572
+ }
5573
+ getPrintClientStatus() {
5574
+ return getPrintClient().getStatus();
5575
+ }
5576
+ /**
5577
+ * Browser-side batch print. Combines records into a single print job —
5578
+ * works without electron-hiprint. `printDataList` can be a single
5579
+ * object or an array; each record can also be printed multiple times
5580
+ * via `options.copies`.
5581
+ */
5582
+ async batchPrint(printDataList, options) {
5583
+ if (!this.printTemplate) {
5584
+ throw new Error("[print-designer] No active print template.");
5585
+ }
5586
+ const data2 = printDataList ?? this.printData ?? {};
5587
+ const list = Array.isArray(data2) ? data2 : [data2];
5588
+ await this.plugins.run("beforePrint", this.printTemplate, this);
5589
+ await batchPrint(this.printTemplate, list, options);
5590
+ }
5591
+ async print2(printData, options) {
5592
+ const data2 = printData ?? this.printData;
5593
+ if (!this.printTemplate) {
5594
+ throw new Error("[print-designer] No active print template.");
5055
5595
  }
5596
+ return getPrintClient().printByInstance(this.printTemplate, data2, options);
5056
5597
  }
5057
5598
  // -------------------------------------------------------------------------
5058
5599
  // Zoom / view-port helpers
5059
5600
  // -------------------------------------------------------------------------
5060
5601
  setZoom(value) {
5061
- var _a, _b, _c, _d;
5602
+ var _a2, _b2, _c2, _d2;
5062
5603
  const scale = Math.max(ZOOM_MIN, Math.min(ZOOM_MAX, Number.isFinite(value) ? value : 1));
5063
5604
  setZoom(scale);
5064
5605
  try {
5065
- (_b = (_a = this.printTemplate) == null ? void 0 : _a.zoom) == null ? void 0 : _b.call(_a, scale);
5606
+ (_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.zoom) == null ? void 0 : _b2.call(_a2, scale);
5066
5607
  } catch (_) {
5067
5608
  }
5068
- (_d = (_c = this.ruler) == null ? void 0 : _c.redraw) == null ? void 0 : _d.call(_c);
5609
+ (_d2 = (_c2 = this.ruler) == null ? void 0 : _c2.redraw) == null ? void 0 : _d2.call(_c2);
5069
5610
  }
5070
5611
  getZoom() {
5071
5612
  const scale = this.readTemplateScale();
@@ -5087,10 +5628,10 @@ const _DesignerUtils = class _DesignerUtils {
5087
5628
  return this.getZoom() > ZOOM_MIN + 1e-3;
5088
5629
  }
5089
5630
  adaptToSize() {
5090
- var _a;
5631
+ var _a2;
5091
5632
  if (typeof window === "undefined") return;
5092
5633
  const host = document.getElementById(DESIGN_CONTAINER_ID);
5093
- const paper = (_a = host == null ? void 0 : host.querySelector) == null ? void 0 : _a.call(host, ".hiprint-printPanel, .hiprint-printPaper");
5634
+ const paper = (_a2 = host == null ? void 0 : host.querySelector) == null ? void 0 : _a2.call(host, ".hiprint-printPanel, .hiprint-printPaper");
5094
5635
  if (!host || !paper) return;
5095
5636
  const hostRect = host.getBoundingClientRect();
5096
5637
  const zoom = Math.max(ZOOM_MIN, this.getZoom());
@@ -5109,24 +5650,24 @@ const _DesignerUtils = class _DesignerUtils {
5109
5650
  return [...this.getPanelElements()];
5110
5651
  }
5111
5652
  getSelectedElements() {
5112
- var _a;
5653
+ var _a2;
5113
5654
  const tpl = this.printTemplate;
5114
5655
  if (!tpl) return [];
5115
5656
  let els = [];
5116
5657
  try {
5117
- els = ((_a = tpl.getSelectEls) == null ? void 0 : _a.call(tpl)) ?? [];
5658
+ els = ((_a2 = tpl.getSelectEls) == null ? void 0 : _a2.call(tpl)) ?? [];
5118
5659
  } catch {
5119
5660
  }
5120
5661
  if (!els.length) els = this.state.selection.elements;
5121
5662
  return els.filter(Boolean);
5122
5663
  }
5123
5664
  getPanelElements() {
5124
- var _a, _b;
5125
- return ((_b = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel) == null ? void 0 : _b.printElements) ?? [];
5665
+ var _a2, _b2;
5666
+ return ((_b2 = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel) == null ? void 0 : _b2.printElements) ?? [];
5126
5667
  }
5127
5668
  getExplicitZIndex(el) {
5128
- var _a;
5129
- const raw = (_a = el == null ? void 0 : el.options) == null ? void 0 : _a.zIndex;
5669
+ var _a2;
5670
+ const raw = (_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.zIndex;
5130
5671
  if (raw != null && raw !== "" && Number.isFinite(Number(raw))) return Number(raw);
5131
5672
  return null;
5132
5673
  }
@@ -5134,7 +5675,7 @@ const _DesignerUtils = class _DesignerUtils {
5134
5675
  this.updateElementOption(el, "zIndex", zIndex, true);
5135
5676
  }
5136
5677
  updateElementOption(el, name, value, silent = true) {
5137
- var _a;
5678
+ var _a2;
5138
5679
  try {
5139
5680
  if (typeof (el == null ? void 0 : el.updateOption) === "function") {
5140
5681
  el.updateOption(name, value, silent);
@@ -5144,34 +5685,34 @@ const _DesignerUtils = class _DesignerUtils {
5144
5685
  }
5145
5686
  try {
5146
5687
  el.options[name] = value;
5147
- (_a = el.updateDesignViewFromOptions) == null ? void 0 : _a.call(el);
5688
+ (_a2 = el.updateDesignViewFromOptions) == null ? void 0 : _a2.call(el);
5148
5689
  return true;
5149
5690
  } catch {
5150
5691
  }
5151
5692
  return false;
5152
5693
  }
5153
5694
  getElementFontSize(el) {
5154
- var _a, _b;
5155
- const raw = (_a = el == null ? void 0 : el.options) == null ? void 0 : _a.fontSize;
5695
+ var _a2, _b2;
5696
+ const raw = (_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.fontSize;
5156
5697
  const size = Number(raw);
5157
5698
  if (Number.isFinite(size) && size > 0) return size;
5158
- const typeDefault = Number((_b = el == null ? void 0 : el.printElementType) == null ? void 0 : _b.fontSize);
5699
+ const typeDefault = Number((_b2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _b2.fontSize);
5159
5700
  return Number.isFinite(typeDefault) && typeDefault > 0 ? typeDefault : 12;
5160
5701
  }
5161
5702
  resolveElementTid(el) {
5162
- var _a, _b;
5163
- const tid = ((_a = el == null ? void 0 : el.printElementType) == null ? void 0 : _a.tid) ?? (el == null ? void 0 : el.tid);
5703
+ var _a2, _b2;
5704
+ const tid = ((_a2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _a2.tid) ?? (el == null ? void 0 : el.tid);
5164
5705
  if (tid) return String(tid);
5165
- const type = String(((_b = el == null ? void 0 : el.printElementType) == null ? void 0 : _b.type) || "");
5706
+ const type = String(((_b2 = el == null ? void 0 : el.printElementType) == null ? void 0 : _b2.type) || "");
5166
5707
  if (!type) return null;
5167
5708
  return `defaultModule.${type}`;
5168
5709
  }
5169
5710
  serializeElement(el) {
5170
- var _a, _b;
5711
+ var _a2, _b2;
5171
5712
  if (!el) return null;
5172
5713
  try {
5173
5714
  const tid = this.resolveElementTid(el);
5174
- const optionsSource = ((_b = (_a = el.options) == null ? void 0 : _a.getPrintElementOptionEntity) == null ? void 0 : _b.call(_a)) ?? el.options ?? {};
5715
+ const optionsSource = ((_b2 = (_a2 = el.options) == null ? void 0 : _a2.getPrintElementOptionEntity) == null ? void 0 : _b2.call(_a2)) ?? el.options ?? {};
5175
5716
  const options = JSON.parse(JSON.stringify(optionsSource));
5176
5717
  const printElementType = el.printElementType ? JSON.parse(JSON.stringify(el.printElementType)) : void 0;
5177
5718
  if (!tid && !(printElementType == null ? void 0 : printElementType.type)) return null;
@@ -5188,15 +5729,15 @@ const _DesignerUtils = class _DesignerUtils {
5188
5729
  return copy;
5189
5730
  }
5190
5731
  insertElementEntity(entity, initSizeByHtml = false) {
5191
- var _a, _b, _c, _d, _e, _f, _g, _h;
5192
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
5732
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
5733
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5193
5734
  const tpl = this.printTemplate;
5194
- if (!panel || !(entity == null ? void 0 : entity.tid) && !((_b = entity == null ? void 0 : entity.printElementType) == null ? void 0 : _b.type)) return null;
5735
+ if (!panel || !(entity == null ? void 0 : entity.tid) && !((_b2 = entity == null ? void 0 : entity.printElementType) == null ? void 0 : _b2.type)) return null;
5195
5736
  try {
5196
- const type = (_c = panel.getPrintElementTypeByEntity) == null ? void 0 : _c.call(panel, entity);
5737
+ const type = (_c2 = panel.getPrintElementTypeByEntity) == null ? void 0 : _c2.call(panel, entity);
5197
5738
  if (!(type == null ? void 0 : type.createPrintElement)) return null;
5198
5739
  const el = type.createPrintElement(entity.options);
5199
- (_d = el.setTemplateId) == null ? void 0 : _d.call(el, tpl.id ?? tpl.templateId);
5740
+ (_d2 = el.setTemplateId) == null ? void 0 : _d2.call(el, tpl.id ?? tpl.templateId);
5200
5741
  (_e = el.setPanel) == null ? void 0 : _e.call(el, panel);
5201
5742
  (_f = panel.appendDesignPrintElement) == null ? void 0 : _f.call(panel, panel.designPaper, el, initSizeByHtml);
5202
5743
  panel.printElements.push(el);
@@ -5212,7 +5753,7 @@ const _DesignerUtils = class _DesignerUtils {
5212
5753
  }
5213
5754
  /** Insert a new canvas element by hiprint `tid` (e.g. `defaultModule.text`). */
5214
5755
  addElementByTid(tid, options = {}) {
5215
- var _a;
5756
+ var _a2;
5216
5757
  const left = Number.isFinite(options.left) ? Number(options.left) : 60;
5217
5758
  const top = Number.isFinite(options.top) ? Number(options.top) : 60;
5218
5759
  const el = this.insertElementEntity({ tid, options: { left, top } }, true);
@@ -5220,20 +5761,20 @@ const _DesignerUtils = class _DesignerUtils {
5220
5761
  this.markTemplateChanged("新增元素");
5221
5762
  this.selectPrintElement(el);
5222
5763
  const json = this.getTemplateJson();
5223
- if (json) (_a = this.onTemplateChange) == null ? void 0 : _a.call(this, json);
5764
+ if (json) (_a2 = this.onTemplateChange) == null ? void 0 : _a2.call(this, json);
5224
5765
  return el;
5225
5766
  }
5226
5767
  /** Clone a live print element using hiprint's native clone path. */
5227
5768
  duplicateElement(el, delta = 10) {
5228
- var _a, _b, _c, _d, _e, _f, _g;
5229
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
5769
+ var _a2, _b2, _c2, _d2, _e, _f, _g;
5770
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5230
5771
  const tpl = this.printTemplate;
5231
5772
  if (!panel || !tpl || !el) return null;
5232
5773
  try {
5233
5774
  let copy = null;
5234
5775
  if (typeof el.clone === "function") {
5235
5776
  copy = el.clone();
5236
- } else if ((_b = el.printElementType) == null ? void 0 : _b.createPrintElement) {
5777
+ } else if ((_b2 = el.printElementType) == null ? void 0 : _b2.createPrintElement) {
5237
5778
  copy = el.printElementType.createPrintElement();
5238
5779
  Object.keys(el.options || {}).forEach((key) => {
5239
5780
  copy.options[key] = el.options[key];
@@ -5246,8 +5787,8 @@ const _DesignerUtils = class _DesignerUtils {
5246
5787
  else copy.options.left = left;
5247
5788
  if (typeof copy.options.setTop === "function") copy.options.setTop(top);
5248
5789
  else copy.options.top = top;
5249
- (_c = copy.setTemplateId) == null ? void 0 : _c.call(copy, tpl.id ?? tpl.templateId);
5250
- (_d = copy.setPanel) == null ? void 0 : _d.call(copy, panel);
5790
+ (_c2 = copy.setTemplateId) == null ? void 0 : _c2.call(copy, tpl.id ?? tpl.templateId);
5791
+ (_d2 = copy.setPanel) == null ? void 0 : _d2.call(copy, panel);
5251
5792
  (_e = panel.appendDesignPrintElement) == null ? void 0 : _e.call(panel, panel.designPaper, copy, false);
5252
5793
  panel.printElements.push(copy);
5253
5794
  (_f = copy.design) == null ? void 0 : _f.call(copy, void 0, panel.designPaper);
@@ -5261,15 +5802,15 @@ const _DesignerUtils = class _DesignerUtils {
5261
5802
  }
5262
5803
  }
5263
5804
  setElementDraggable(el, draggable) {
5264
- var _a, _b, _c, _d;
5805
+ var _a2, _b2, _c2, _d2;
5265
5806
  if (!(el == null ? void 0 : el.options)) return;
5266
5807
  el.options.draggable = draggable;
5267
5808
  try {
5268
- (_b = (_a = el.designTarget) == null ? void 0 : _a.hidraggable) == null ? void 0 : _b.call(_a, "update", { draggable });
5809
+ (_b2 = (_a2 = el.designTarget) == null ? void 0 : _a2.hidraggable) == null ? void 0 : _b2.call(_a2, "update", { draggable });
5269
5810
  } catch {
5270
5811
  }
5271
5812
  try {
5272
- (_d = (_c = el.designTarget) == null ? void 0 : _c.hireizeable) == null ? void 0 : _d.call(_c, "update", { draggable });
5813
+ (_d2 = (_c2 = el.designTarget) == null ? void 0 : _c2.hireizeable) == null ? void 0 : _d2.call(_c2, "update", { draggable });
5273
5814
  } catch {
5274
5815
  }
5275
5816
  }
@@ -5290,13 +5831,13 @@ const _DesignerUtils = class _DesignerUtils {
5290
5831
  ];
5291
5832
  }
5292
5833
  syncPanelElementOrder(ordered) {
5293
- var _a, _b;
5294
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
5834
+ var _a2, _b2;
5835
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5295
5836
  if (!panel) return;
5296
5837
  panel.printElements = ordered;
5297
5838
  try {
5298
5839
  const $ = window.jQuery || window.$;
5299
- const container = ((_b = panel.designPaper) == null ? void 0 : _b.target) ?? panel.target;
5840
+ const container = ((_b2 = panel.designPaper) == null ? void 0 : _b2.target) ?? panel.target;
5300
5841
  if ($ && (container == null ? void 0 : container.length)) {
5301
5842
  ordered.forEach((el) => {
5302
5843
  if (el == null ? void 0 : el.designTarget) $(el.designTarget).appendTo(container);
@@ -5306,37 +5847,37 @@ const _DesignerUtils = class _DesignerUtils {
5306
5847
  }
5307
5848
  }
5308
5849
  getPanelSizePt(panel) {
5309
- var _a;
5850
+ var _a2;
5310
5851
  const hinnn = window.hinnn;
5311
5852
  const mmW = Number((panel == null ? void 0 : panel.width) ?? (panel == null ? void 0 : panel.mmwidth) ?? 0);
5312
5853
  const mmH = Number((panel == null ? void 0 : panel.height) ?? (panel == null ? void 0 : panel.mmheight) ?? 0);
5313
- if ((_a = hinnn == null ? void 0 : hinnn.mm) == null ? void 0 : _a.toPt) {
5854
+ if ((_a2 = hinnn == null ? void 0 : hinnn.mm) == null ? void 0 : _a2.toPt) {
5314
5855
  return { width: hinnn.mm.toPt(mmW), height: hinnn.mm.toPt(mmH) };
5315
5856
  }
5316
5857
  return { width: mmW, height: mmH };
5317
5858
  }
5318
5859
  getElementRect(el) {
5319
- var _a, _b, _c, _d;
5860
+ var _a2, _b2, _c2, _d2;
5320
5861
  const opts = el == null ? void 0 : el.options;
5321
5862
  if (!opts) return null;
5322
- const left = Number(((_a = opts.getLeft) == null ? void 0 : _a.call(opts)) ?? opts.left ?? 0);
5323
- const top = Number(((_b = opts.getTop) == null ? void 0 : _b.call(opts)) ?? opts.top ?? 0);
5324
- const width = Number(((_c = opts.getWidth) == null ? void 0 : _c.call(opts)) ?? opts.width ?? 0);
5325
- const height = Number(((_d = opts.getHeight) == null ? void 0 : _d.call(opts)) ?? opts.height ?? 0);
5863
+ const left = Number(((_a2 = opts.getLeft) == null ? void 0 : _a2.call(opts)) ?? opts.left ?? 0);
5864
+ const top = Number(((_b2 = opts.getTop) == null ? void 0 : _b2.call(opts)) ?? opts.top ?? 0);
5865
+ const width = Number(((_c2 = opts.getWidth) == null ? void 0 : _c2.call(opts)) ?? opts.width ?? 0);
5866
+ const height = Number(((_d2 = opts.getHeight) == null ? void 0 : _d2.call(opts)) ?? opts.height ?? 0);
5326
5867
  return { el, left, top, width, height, right: left + width, bottom: top + height };
5327
5868
  }
5328
5869
  applyElementPosition(el, left, top) {
5329
- var _a, _b, _c, _d, _e, _f, _g, _h;
5870
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
5330
5871
  const opts = el == null ? void 0 : el.options;
5331
5872
  if (!opts) return;
5332
- const width = Number(((_a = opts.getWidth) == null ? void 0 : _a.call(opts)) ?? opts.width ?? 0);
5333
- const height = Number(((_b = opts.getHeight) == null ? void 0 : _b.call(opts)) ?? opts.height ?? 0);
5873
+ const width = Number(((_a2 = opts.getWidth) == null ? void 0 : _a2.call(opts)) ?? opts.width ?? 0);
5874
+ const height = Number(((_b2 = opts.getHeight) == null ? void 0 : _b2.call(opts)) ?? opts.height ?? 0);
5334
5875
  try {
5335
5876
  if (typeof el.updateSizeAndPositionOptions === "function") {
5336
5877
  el.updateSizeAndPositionOptions(left, top, width, height);
5337
5878
  } else {
5338
- (_c = opts.setLeft) == null ? void 0 : _c.call(opts, left);
5339
- (_d = opts.setTop) == null ? void 0 : _d.call(opts, top);
5879
+ (_c2 = opts.setLeft) == null ? void 0 : _c2.call(opts, left);
5880
+ (_d2 = opts.setTop) == null ? void 0 : _d2.call(opts, top);
5340
5881
  (_e = opts.copyDesignTopFromTop) == null ? void 0 : _e.call(opts);
5341
5882
  }
5342
5883
  } catch {
@@ -5352,14 +5893,14 @@ const _DesignerUtils = class _DesignerUtils {
5352
5893
  }
5353
5894
  }
5354
5895
  markTemplateChanged(label = HISTORY_PARAM) {
5355
- var _a, _b, _c;
5896
+ var _a2, _b2;
5356
5897
  const tpl = this.printTemplate;
5357
5898
  if (!tpl) return;
5358
5899
  try {
5359
- const lib = ((_a = vuePluginHiprint.hiprint) == null ? void 0 : _a.instance) ?? ((_b = window.HiPrintlib) == null ? void 0 : _b.instance);
5900
+ const lib = (hiprint == null ? void 0 : hiprint.instance) ?? ((_a2 = window.HiPrintlib) == null ? void 0 : _a2.instance);
5360
5901
  if (lib) lib.changed = true;
5361
5902
  const tplId = tpl.id ?? tpl.templateId;
5362
- const bus = (_c = window.hinnn) == null ? void 0 : _c.event;
5903
+ const bus = (_b2 = window.hinnn) == null ? void 0 : _b2.event;
5363
5904
  if (bus && tplId != null) bus.trigger(`hiprintTemplateDataChanged_${tplId}`, label);
5364
5905
  } catch {
5365
5906
  }
@@ -5367,7 +5908,7 @@ const _DesignerUtils = class _DesignerUtils {
5367
5908
  this.history.refreshFromTemplate();
5368
5909
  }
5369
5910
  align(side) {
5370
- var _a;
5911
+ var _a2;
5371
5912
  const tpl = this.printTemplate;
5372
5913
  if (!tpl) return;
5373
5914
  const rects = this.getSelectedElements().map((el) => this.getElementRect(el)).filter(Boolean);
@@ -5377,7 +5918,7 @@ const _DesignerUtils = class _DesignerUtils {
5377
5918
  let refRight;
5378
5919
  let refBottom;
5379
5920
  if (rects.length === 1) {
5380
- const panel = tpl.editingPanel ?? ((_a = rects[0].el) == null ? void 0 : _a.panel);
5921
+ const panel = tpl.editingPanel ?? ((_a2 = rects[0].el) == null ? void 0 : _a2.panel);
5381
5922
  const { width, height } = this.getPanelSizePt(panel);
5382
5923
  refLeft = 0;
5383
5924
  refTop = 0;
@@ -5423,9 +5964,9 @@ const _DesignerUtils = class _DesignerUtils {
5423
5964
  callOnSelection(method, ...args) {
5424
5965
  const els = this.state.selection.elements;
5425
5966
  els.forEach((el) => {
5426
- var _a;
5967
+ var _a2;
5427
5968
  try {
5428
- (_a = el == null ? void 0 : el[method]) == null ? void 0 : _a.call(el, ...args);
5969
+ (_a2 = el == null ? void 0 : el[method]) == null ? void 0 : _a2.call(el, ...args);
5429
5970
  } catch (_) {
5430
5971
  }
5431
5972
  });
@@ -5490,15 +6031,15 @@ const _DesignerUtils = class _DesignerUtils {
5490
6031
  isSelectionLocked() {
5491
6032
  const selected = this.getSelectedElements();
5492
6033
  return selected.length > 0 && selected.every((el) => {
5493
- var _a;
5494
- return ((_a = el == null ? void 0 : el.options) == null ? void 0 : _a.draggable) === false;
6034
+ var _a2;
6035
+ return ((_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.draggable) === false;
5495
6036
  });
5496
6037
  }
5497
6038
  isSelectionUnlocked() {
5498
6039
  const selected = this.getSelectedElements();
5499
6040
  return selected.length > 0 && selected.every((el) => {
5500
- var _a;
5501
- return ((_a = el == null ? void 0 : el.options) == null ? void 0 : _a.draggable) !== false;
6041
+ var _a2;
6042
+ return ((_a2 = el == null ? void 0 : el.options) == null ? void 0 : _a2.draggable) !== false;
5502
6043
  });
5503
6044
  }
5504
6045
  setLock(locked) {
@@ -5549,17 +6090,17 @@ const _DesignerUtils = class _DesignerUtils {
5549
6090
  designerStore.uiPulse += 1;
5550
6091
  }
5551
6092
  delete() {
5552
- var _a;
6093
+ var _a2;
5553
6094
  const selected = this.getSelectedElements();
5554
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
6095
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5555
6096
  if (!panel || !selected.length) return;
5556
6097
  selected.forEach((el) => {
5557
- var _a2, _b;
6098
+ var _a3, _b2;
5558
6099
  try {
5559
- (_a2 = panel.deletePrintElement) == null ? void 0 : _a2.call(panel, el);
6100
+ (_a3 = panel.deletePrintElement) == null ? void 0 : _a3.call(panel, el);
5560
6101
  } catch {
5561
6102
  try {
5562
- (_b = el == null ? void 0 : el.delete) == null ? void 0 : _b.call(el);
6103
+ (_b2 = el == null ? void 0 : el.delete) == null ? void 0 : _b2.call(el);
5563
6104
  } catch {
5564
6105
  }
5565
6106
  }
@@ -5569,15 +6110,15 @@ const _DesignerUtils = class _DesignerUtils {
5569
6110
  }
5570
6111
  /** Delete a single element from the structure panel or other auxiliary UI. */
5571
6112
  deletePrintElement(item) {
5572
- var _a, _b, _c;
6113
+ var _a2, _b2, _c2;
5573
6114
  if (!item) return;
5574
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
6115
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5575
6116
  if (!panel) return;
5576
6117
  try {
5577
- (_b = panel.deletePrintElement) == null ? void 0 : _b.call(panel, item);
6118
+ (_b2 = panel.deletePrintElement) == null ? void 0 : _b2.call(panel, item);
5578
6119
  } catch {
5579
6120
  try {
5580
- (_c = item == null ? void 0 : item.delete) == null ? void 0 : _c.call(item);
6121
+ (_c2 = item == null ? void 0 : item.delete) == null ? void 0 : _c2.call(item);
5581
6122
  } catch {
5582
6123
  }
5583
6124
  }
@@ -5602,14 +6143,14 @@ const _DesignerUtils = class _DesignerUtils {
5602
6143
  this.markTemplateChanged(HISTORY_ALIGN);
5603
6144
  }
5604
6145
  clearPanel() {
5605
- var _a;
5606
- const panel = (_a = this.printTemplate) == null ? void 0 : _a.editingPanel;
6146
+ var _a2;
6147
+ const panel = (_a2 = this.printTemplate) == null ? void 0 : _a2.editingPanel;
5607
6148
  if (!panel) return;
5608
6149
  const list = (panel.printElements ?? []).slice();
5609
6150
  list.forEach((el) => {
5610
- var _a2;
6151
+ var _a3;
5611
6152
  try {
5612
- (_a2 = panel.deletePrintElement) == null ? void 0 : _a2.call(panel, el);
6153
+ (_a3 = panel.deletePrintElement) == null ? void 0 : _a3.call(panel, el);
5613
6154
  } catch (_) {
5614
6155
  }
5615
6156
  });
@@ -5861,14 +6402,14 @@ function useRuler(opts) {
5861
6402
  });
5862
6403
  }
5863
6404
  vueDemi.onMounted(() => {
5864
- var _a;
6405
+ var _a2;
5865
6406
  const scroller = opts.scrollerEl();
5866
6407
  scrollHandler = () => schedule();
5867
6408
  scroller == null ? void 0 : scroller.addEventListener("scroll", scrollHandler, { passive: true });
5868
6409
  if (typeof ResizeObserver !== "undefined") {
5869
6410
  resizeObserver = new ResizeObserver(() => schedule());
5870
6411
  if (scroller) resizeObserver.observe(scroller);
5871
- const workspace = (_a = opts.workspaceEl) == null ? void 0 : _a.call(opts);
6412
+ const workspace = (_a2 = opts.workspaceEl) == null ? void 0 : _a2.call(opts);
5872
6413
  if (workspace) resizeObserver.observe(workspace);
5873
6414
  const host = document.getElementById(DESIGN_CONTAINER_ID);
5874
6415
  if (host) resizeObserver.observe(host);
@@ -7820,12 +8361,12 @@ const _hoisted_4$a = {
7820
8361
  const _hoisted_5$a = { class: "svp-header__center" };
7821
8362
  const _hoisted_6$6 = ["title"];
7822
8363
  const _hoisted_7$6 = ["title"];
7823
- const _hoisted_8$4 = ["title"];
7824
- const _hoisted_9$3 = ["title"];
7825
- const _hoisted_10$2 = ["title"];
7826
- const _hoisted_11$1 = ["title"];
7827
- const _hoisted_12$1 = ["title", "onClick"];
7828
- const _hoisted_13$1 = { class: "svp-header__aside svp-header__aside--right" };
8364
+ const _hoisted_8$5 = ["title"];
8365
+ const _hoisted_9$4 = ["title"];
8366
+ const _hoisted_10$3 = ["title"];
8367
+ const _hoisted_11$2 = ["title"];
8368
+ const _hoisted_12$2 = ["title", "onClick"];
8369
+ const _hoisted_13$2 = { class: "svp-header__aside svp-header__aside--right" };
7829
8370
  function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7830
8371
  const _component_SvpIcon = Vue.resolveComponent("SvpIcon");
7831
8372
  return Vue.openBlock(), Vue.createElementBlock("header", _hoisted_1$c, [
@@ -7876,7 +8417,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7876
8417
  size: 22
7877
8418
  }, null, 8, ["icon"]),
7878
8419
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.exportFile")), 1)
7879
- ], 8, _hoisted_8$4),
8420
+ ], 8, _hoisted_8$5),
7880
8421
  Vue.createElementVNode("button", {
7881
8422
  type: "button",
7882
8423
  class: "svp-header__menu",
@@ -7888,7 +8429,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7888
8429
  size: 22
7889
8430
  }, null, 8, ["icon"]),
7890
8431
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.importFile")), 1)
7891
- ], 8, _hoisted_9$3),
8432
+ ], 8, _hoisted_9$4),
7892
8433
  Vue.createElementVNode("button", {
7893
8434
  type: "button",
7894
8435
  class: "svp-header__menu",
@@ -7900,7 +8441,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7900
8441
  size: 22
7901
8442
  }, null, 8, ["icon"]),
7902
8443
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.save")), 1)
7903
- ], 8, _hoisted_10$2),
8444
+ ], 8, _hoisted_10$3),
7904
8445
  Vue.createElementVNode("button", {
7905
8446
  type: "button",
7906
8447
  class: "svp-header__menu",
@@ -7912,7 +8453,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7912
8453
  size: 22
7913
8454
  }, null, 8, ["icon"]),
7914
8455
  Vue.createElementVNode("span", null, Vue.toDisplayString(_ctx.t("designer.preview")), 1)
7915
- ], 8, _hoisted_11$1),
8456
+ ], 8, _hoisted_11$2),
7916
8457
  _ctx.showElementBar ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
7917
8458
  _cache[6] || (_cache[6] = Vue.createElementVNode("span", {
7918
8459
  class: "svp-header__divider",
@@ -7932,12 +8473,12 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
7932
8473
  size: 18
7933
8474
  }, null, 8, ["icon"])) : Vue.createCommentVNode("", true),
7934
8475
  Vue.createElementVNode("span", null, Vue.toDisplayString(item.label), 1)
7935
- ], 8, _hoisted_12$1);
8476
+ ], 8, _hoisted_12$2);
7936
8477
  }), 128))
7937
8478
  ], 64)) : Vue.createCommentVNode("", true)
7938
8479
  ])
7939
8480
  ]),
7940
- Vue.createElementVNode("div", _hoisted_13$1, [
8481
+ Vue.createElementVNode("div", _hoisted_13$2, [
7941
8482
  Vue.renderSlot(_ctx.$slots, "right")
7942
8483
  ])
7943
8484
  ]);
@@ -7981,8 +8522,8 @@ const _sfc_main$b = vueDemi.defineComponent({
7981
8522
  designerStore.lang = next;
7982
8523
  }
7983
8524
  function onToolbarMouseDown(e) {
7984
- var _a;
7985
- if ((_a = e.target) == null ? void 0 : _a.closest("button")) {
8525
+ var _a2;
8526
+ if ((_a2 = e.target) == null ? void 0 : _a2.closest("button")) {
7986
8527
  e.preventDefault();
7987
8528
  }
7988
8529
  }
@@ -8192,105 +8733,210 @@ function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
8192
8733
  ], 32);
8193
8734
  }
8194
8735
  const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b]]);
8195
- function resolvePreviewHtml(value) {
8196
- if (value == null || value === false) return "";
8197
- if (typeof value === "string") return value;
8198
- const any = value;
8199
- if (typeof any.html === "function") {
8200
- try {
8201
- const html = any.html();
8202
- if (typeof html === "string") return html;
8203
- } catch {
8204
- }
8205
- }
8206
- if (Array.isArray(value)) {
8207
- return value.map((item) => resolvePreviewHtml(item)).join("");
8208
- }
8209
- if (typeof any.length === "number" && any.length > 0 && any[0] != null) {
8210
- return resolvePreviewHtml(any[0]);
8211
- }
8212
- if (any.target != null) {
8213
- return resolvePreviewHtml(any.target);
8214
- }
8215
- return "";
8216
- }
8217
8736
  const _sfc_main$a = vueDemi.defineComponent({
8218
8737
  name: "SvpPreview",
8219
8738
  props: {
8220
8739
  options: { type: Object, default: () => ({}) }
8221
8740
  },
8222
8741
  setup(props, { expose }) {
8742
+ var _a2;
8223
8743
  const { t } = useI18n();
8224
8744
  const utils = useDesigner();
8225
8745
  const visible = vueDemi.ref(false);
8226
8746
  const html = vueDemi.ref("");
8227
- const opts = vueDemi.reactive({ showPdf: true, showImg: true, showPrint2: true, ...props.options });
8747
+ const opts = vueDemi.reactive({
8748
+ showPdf: true,
8749
+ showImg: true,
8750
+ showBrowserPrint: true,
8751
+ showPrint2: false,
8752
+ showBatchPrint: true,
8753
+ showPrintClient: false,
8754
+ ...props.options
8755
+ });
8756
+ const clientStatus = vueDemi.ref({ connected: false });
8757
+ const printers = vueDemi.ref([]);
8758
+ const selectedPrinter = vueDemi.ref("");
8759
+ const connecting = vueDemi.ref(false);
8760
+ const batchCopies = vueDemi.ref(Math.max(1, Math.floor(((_a2 = props.options) == null ? void 0 : _a2.defaultCopies) ?? 1)));
8761
+ const batchPrinting = vueDemi.ref(false);
8228
8762
  const tpl = vueDemi.computed(() => utils.printTemplate);
8229
8763
  const canExportPdf = vueDemi.computed(() => {
8230
- var _a;
8764
+ var _a3;
8231
8765
  if (opts.showPdf === false) return false;
8232
- return typeof ((_a = tpl.value) == null ? void 0 : _a.toPdf) === "function";
8766
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toPdf) === "function";
8233
8767
  });
8234
8768
  const canExportImage = vueDemi.computed(() => {
8235
- var _a;
8769
+ var _a3;
8236
8770
  if (opts.showImg === false) return false;
8237
- return typeof ((_a = tpl.value) == null ? void 0 : _a.toImage) === "function";
8771
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toImage) === "function";
8238
8772
  });
8239
- const canPrint = vueDemi.computed(() => {
8240
- var _a;
8241
- if (opts.showPrint2 === false) return false;
8242
- return typeof ((_a = tpl.value) == null ? void 0 : _a.print) === "function";
8773
+ const canBrowserPrint = vueDemi.computed(() => {
8774
+ var _a3;
8775
+ if (opts.showBrowserPrint === false) return false;
8776
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.print) === "function";
8243
8777
  });
8778
+ const canSilentPrint = vueDemi.computed(() => {
8779
+ var _a3;
8780
+ if (opts.showPrint2 === false || opts.showSilentPrint === false) return false;
8781
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.print2) === "function";
8782
+ });
8783
+ const showPrintClientBar = vueDemi.computed(() => {
8784
+ if (opts.showPrintClient === true) return true;
8785
+ return canSilentPrint.value;
8786
+ });
8787
+ const canBatchPrint = vueDemi.computed(() => {
8788
+ var _a3;
8789
+ if (opts.showBatchPrint === false) return false;
8790
+ return typeof ((_a3 = tpl.value) == null ? void 0 : _a3.getHtml) === "function";
8791
+ });
8792
+ const batchDataRows = vueDemi.computed(() => {
8793
+ const data2 = utils.printData;
8794
+ if (Array.isArray(data2)) return data2.length;
8795
+ return data2 == null ? 0 : 1;
8796
+ });
8797
+ const batchTotalPages = vueDemi.computed(() => {
8798
+ const copies = Math.max(1, Math.floor(batchCopies.value || 1));
8799
+ return batchDataRows.value * copies;
8800
+ });
8801
+ const batchHintText = vueDemi.computed(() => {
8802
+ const template = t("designer.batchHint");
8803
+ return template.replace("{rows}", String(batchDataRows.value)).replace("{total}", String(batchTotalPages.value));
8804
+ });
8805
+ function formatPrinterLabel(printer) {
8806
+ const label = printer.displayName || printer.name;
8807
+ return printer.isDefault ? `${label} (${t("designer.defaultPrinter")})` : label;
8808
+ }
8809
+ function syncDefaultPrinter(list) {
8810
+ if (!list.length) {
8811
+ selectedPrinter.value = "";
8812
+ return;
8813
+ }
8814
+ if (selectedPrinter.value && list.some((item) => item.name === selectedPrinter.value)) {
8815
+ return;
8816
+ }
8817
+ const fallback = list.find((item) => item.isDefault) ?? list[0];
8818
+ selectedPrinter.value = (fallback == null ? void 0 : fallback.name) ?? "";
8819
+ }
8820
+ function refreshClientState() {
8821
+ clientStatus.value = utils.getPrintClientStatus();
8822
+ if (!clientStatus.value.connected) {
8823
+ printers.value = [];
8824
+ return;
8825
+ }
8826
+ printers.value = utils.getPrinterList();
8827
+ syncDefaultPrinter(printers.value);
8828
+ }
8244
8829
  function open(content) {
8245
- var _a, _b;
8246
- const raw = content !== void 0 ? content : (_b = (_a = tpl.value) == null ? void 0 : _a.getHtml) == null ? void 0 : _b.call(_a, utils.printData);
8830
+ var _a3, _b2;
8831
+ const raw = content !== void 0 ? content : (_b2 = (_a3 = tpl.value) == null ? void 0 : _a3.getHtml) == null ? void 0 : _b2.call(_a3, utils.printData);
8247
8832
  html.value = resolvePreviewHtml(raw);
8248
8833
  visible.value = true;
8834
+ refreshClientState();
8249
8835
  utils.plugins.run("onPreview", html.value, utils).catch(() => {
8250
8836
  });
8251
8837
  }
8252
8838
  function close() {
8253
8839
  visible.value = false;
8254
8840
  }
8841
+ async function toggleConnect() {
8842
+ if (connecting.value) return;
8843
+ connecting.value = true;
8844
+ try {
8845
+ if (clientStatus.value.connected) {
8846
+ await new Promise((resolve) => {
8847
+ utils.setConnect(false, () => resolve());
8848
+ });
8849
+ } else {
8850
+ await new Promise((resolve) => {
8851
+ utils.setConnect(true, () => resolve());
8852
+ });
8853
+ }
8854
+ refreshClientState();
8855
+ } finally {
8856
+ connecting.value = false;
8857
+ }
8858
+ }
8255
8859
  async function onPrint() {
8256
- var _a, _b;
8860
+ var _a3, _b2;
8257
8861
  await utils.plugins.run("beforePrint", tpl.value, utils);
8258
8862
  try {
8259
- (_b = (_a = tpl.value) == null ? void 0 : _a.print) == null ? void 0 : _b.call(_a, utils.printData);
8863
+ (_b2 = (_a3 = tpl.value) == null ? void 0 : _a3.print) == null ? void 0 : _b2.call(_a3, utils.printData);
8864
+ } catch (e) {
8865
+ console.error(e);
8866
+ }
8867
+ }
8868
+ async function onSilentPrint() {
8869
+ const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "silent");
8870
+ if (results.some((r) => r === false)) return;
8871
+ try {
8872
+ await utils.print2(utils.printData, {
8873
+ printer: selectedPrinter.value,
8874
+ title: t("designer.silentPrint")
8875
+ });
8260
8876
  } catch (e) {
8261
8877
  console.error(e);
8262
8878
  }
8263
8879
  }
8264
8880
  async function onPdf() {
8265
- var _a;
8881
+ var _a3;
8266
8882
  const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "pdf");
8267
8883
  if (results.some((r) => r === false)) return;
8268
8884
  try {
8269
- if (typeof ((_a = tpl.value) == null ? void 0 : _a.toPdf) === "function") tpl.value.toPdf(utils.printData);
8885
+ if (typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toPdf) === "function") tpl.value.toPdf(utils.printData);
8270
8886
  } catch (e) {
8271
8887
  console.error(e);
8272
8888
  }
8273
8889
  }
8274
8890
  async function onImage() {
8275
- var _a;
8891
+ var _a3;
8276
8892
  const results = await utils.plugins.run("beforePrint2", tpl.value, utils, "image");
8277
8893
  if (results.some((r) => r === false)) return;
8278
8894
  try {
8279
- if (typeof ((_a = tpl.value) == null ? void 0 : _a.toImage) === "function") tpl.value.toImage(utils.printData);
8895
+ if (typeof ((_a3 = tpl.value) == null ? void 0 : _a3.toImage) === "function") tpl.value.toImage(utils.printData);
8280
8896
  } catch (e) {
8281
8897
  console.error(e);
8282
8898
  }
8283
8899
  }
8900
+ async function onBatchPrint() {
8901
+ if (batchPrinting.value) return;
8902
+ const data2 = utils.printData;
8903
+ const list = Array.isArray(data2) ? data2 : [data2];
8904
+ if (!list.length) return;
8905
+ const copies = Math.max(1, Math.floor(batchCopies.value || 1));
8906
+ batchPrinting.value = true;
8907
+ try {
8908
+ await utils.batchPrint(list, { copies, title: t("designer.batchPrint") });
8909
+ } catch (e) {
8910
+ console.error(e);
8911
+ } finally {
8912
+ batchPrinting.value = false;
8913
+ }
8914
+ }
8284
8915
  expose({ open, close });
8285
8916
  return {
8286
8917
  t,
8287
8918
  visible,
8288
8919
  html,
8920
+ clientStatus,
8921
+ printers,
8922
+ selectedPrinter,
8923
+ batchCopies,
8924
+ batchPrinting,
8925
+ batchDataRows,
8926
+ batchTotalPages,
8927
+ batchHintText,
8289
8928
  canExportPdf,
8290
8929
  canExportImage,
8291
- canPrint,
8930
+ canBrowserPrint,
8931
+ canSilentPrint,
8932
+ canBatchPrint,
8933
+ showPrintClientBar,
8934
+ formatPrinterLabel,
8292
8935
  close,
8936
+ toggleConnect,
8293
8937
  onPrint,
8938
+ onSilentPrint,
8939
+ onBatchPrint,
8294
8940
  onPdf,
8295
8941
  onImage
8296
8942
  };
@@ -8305,12 +8951,28 @@ const _hoisted_6$4 = {
8305
8951
  key: 1,
8306
8952
  class: "svp-preview__empty"
8307
8953
  };
8308
- const _hoisted_7$4 = { class: "svp-dialog__footer svp-preview__footer" };
8954
+ const _hoisted_7$4 = {
8955
+ key: 0,
8956
+ class: "svp-preview__print-bar"
8957
+ };
8958
+ const _hoisted_8$4 = ["value"];
8959
+ const _hoisted_9$3 = {
8960
+ key: 1,
8961
+ class: "svp-preview__printer-empty"
8962
+ };
8963
+ const _hoisted_10$2 = {
8964
+ key: 1,
8965
+ class: "svp-preview__print-bar svp-preview__batch-bar"
8966
+ };
8967
+ const _hoisted_11$1 = { class: "svp-preview__batch-label" };
8968
+ const _hoisted_12$1 = { class: "svp-preview__batch-hint" };
8969
+ const _hoisted_13$1 = { class: "svp-dialog__footer svp-preview__footer" };
8970
+ const _hoisted_14$1 = ["disabled"];
8309
8971
  function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
8310
8972
  return _ctx.visible ? (Vue.openBlock(), Vue.createElementBlock("div", {
8311
8973
  key: 0,
8312
8974
  class: "svp-dialog-mask",
8313
- onClick: _cache[5] || (_cache[5] = Vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["self"]))
8975
+ onClick: _cache[10] || (_cache[10] = Vue.withModifiers((...args) => _ctx.close && _ctx.close(...args), ["self"]))
8314
8976
  }, [
8315
8977
  Vue.createElementVNode("div", _hoisted_1$a, [
8316
8978
  Vue.createElementVNode("div", _hoisted_2$9, [
@@ -8329,29 +8991,86 @@ function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
8329
8991
  innerHTML: _ctx.html
8330
8992
  }, null, 8, _hoisted_5$8)) : (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_6$4, Vue.toDisplayString(_ctx.t("panel.empty")), 1))
8331
8993
  ]),
8332
- Vue.createElementVNode("div", _hoisted_7$4, [
8333
- _ctx.canExportPdf ? (Vue.openBlock(), Vue.createElementBlock("button", {
8994
+ _ctx.showPrintClientBar ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_7$4, [
8995
+ Vue.createElementVNode("span", {
8996
+ class: Vue.normalizeClass(["svp-preview__status", { "is-connected": _ctx.clientStatus.connected }])
8997
+ }, Vue.toDisplayString(_ctx.clientStatus.connected ? _ctx.t("designer.printClientConnected") : _ctx.t("designer.printClientDisconnected")), 3),
8998
+ Vue.createElementVNode("button", {
8999
+ type: "button",
9000
+ class: "svp-btn",
9001
+ onClick: _cache[1] || (_cache[1] = (...args) => _ctx.toggleConnect && _ctx.toggleConnect(...args))
9002
+ }, Vue.toDisplayString(_ctx.clientStatus.connected ? _ctx.t("designer.printClientDisconnect") : _ctx.t("designer.printClientConnect")), 1),
9003
+ _ctx.clientStatus.connected && _ctx.printers.length ? Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("select", {
8334
9004
  key: 0,
9005
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.selectedPrinter = $event),
9006
+ class: "svp-preview__printer-select"
9007
+ }, [
9008
+ (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(_ctx.printers, (printer) => {
9009
+ return Vue.openBlock(), Vue.createElementBlock("option", {
9010
+ key: printer.name,
9011
+ value: printer.name
9012
+ }, Vue.toDisplayString(_ctx.formatPrinterLabel(printer)), 9, _hoisted_8$4);
9013
+ }), 128))
9014
+ ], 512)), [
9015
+ [Vue.vModelSelect, _ctx.selectedPrinter]
9016
+ ]) : _ctx.clientStatus.connected ? (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_9$3, Vue.toDisplayString(_ctx.t("designer.printClientNoPrinters")), 1)) : Vue.createCommentVNode("", true)
9017
+ ])) : Vue.createCommentVNode("", true),
9018
+ _ctx.canBatchPrint ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_10$2, [
9019
+ Vue.createElementVNode("label", _hoisted_11$1, [
9020
+ Vue.createTextVNode(Vue.toDisplayString(_ctx.t("designer.batchCopies")) + " ", 1),
9021
+ Vue.withDirectives(Vue.createElementVNode("input", {
9022
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.batchCopies = $event),
9023
+ type: "number",
9024
+ min: "1",
9025
+ max: "999",
9026
+ class: "svp-preview__batch-input"
9027
+ }, null, 512), [
9028
+ [
9029
+ Vue.vModelText,
9030
+ _ctx.batchCopies,
9031
+ void 0,
9032
+ { number: true }
9033
+ ]
9034
+ ])
9035
+ ]),
9036
+ Vue.createElementVNode("span", _hoisted_12$1, Vue.toDisplayString(_ctx.batchHintText), 1)
9037
+ ])) : Vue.createCommentVNode("", true),
9038
+ Vue.createElementVNode("div", _hoisted_13$1, [
9039
+ _ctx.canBatchPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
9040
+ key: 0,
9041
+ type: "button",
9042
+ class: "svp-btn is-primary",
9043
+ disabled: _ctx.batchPrinting,
9044
+ onClick: _cache[4] || (_cache[4] = (...args) => _ctx.onBatchPrint && _ctx.onBatchPrint(...args))
9045
+ }, Vue.toDisplayString(_ctx.batchPrinting ? _ctx.t("designer.batchPrinting") : _ctx.t("designer.batchPrint")), 9, _hoisted_14$1)) : Vue.createCommentVNode("", true),
9046
+ _ctx.canSilentPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
9047
+ key: 1,
9048
+ type: "button",
9049
+ class: "svp-btn",
9050
+ onClick: _cache[5] || (_cache[5] = (...args) => _ctx.onSilentPrint && _ctx.onSilentPrint(...args))
9051
+ }, Vue.toDisplayString(_ctx.t("designer.silentPrint")), 1)) : Vue.createCommentVNode("", true),
9052
+ _ctx.canBrowserPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
9053
+ key: 2,
9054
+ type: "button",
9055
+ class: "svp-btn",
9056
+ onClick: _cache[6] || (_cache[6] = (...args) => _ctx.onPrint && _ctx.onPrint(...args))
9057
+ }, Vue.toDisplayString(_ctx.t("designer.browserPrint")), 1)) : Vue.createCommentVNode("", true),
9058
+ _ctx.canExportPdf ? (Vue.openBlock(), Vue.createElementBlock("button", {
9059
+ key: 3,
8335
9060
  type: "button",
8336
9061
  class: "svp-btn",
8337
- onClick: _cache[1] || (_cache[1] = (...args) => _ctx.onPdf && _ctx.onPdf(...args))
9062
+ onClick: _cache[7] || (_cache[7] = (...args) => _ctx.onPdf && _ctx.onPdf(...args))
8338
9063
  }, Vue.toDisplayString(_ctx.t("designer.pdf")), 1)) : Vue.createCommentVNode("", true),
8339
9064
  _ctx.canExportImage ? (Vue.openBlock(), Vue.createElementBlock("button", {
8340
- key: 1,
9065
+ key: 4,
8341
9066
  type: "button",
8342
9067
  class: "svp-btn",
8343
- onClick: _cache[2] || (_cache[2] = (...args) => _ctx.onImage && _ctx.onImage(...args))
9068
+ onClick: _cache[8] || (_cache[8] = (...args) => _ctx.onImage && _ctx.onImage(...args))
8344
9069
  }, Vue.toDisplayString(_ctx.t("designer.image")), 1)) : Vue.createCommentVNode("", true),
8345
- _ctx.canPrint ? (Vue.openBlock(), Vue.createElementBlock("button", {
8346
- key: 2,
8347
- type: "button",
8348
- class: "svp-btn is-primary",
8349
- onClick: _cache[3] || (_cache[3] = (...args) => _ctx.onPrint && _ctx.onPrint(...args))
8350
- }, Vue.toDisplayString(_ctx.t("designer.print")), 1)) : Vue.createCommentVNode("", true),
8351
9070
  Vue.createElementVNode("button", {
8352
9071
  type: "button",
8353
9072
  class: "svp-btn",
8354
- onClick: _cache[4] || (_cache[4] = (...args) => _ctx.close && _ctx.close(...args))
9073
+ onClick: _cache[9] || (_cache[9] = (...args) => _ctx.close && _ctx.close(...args))
8355
9074
  }, Vue.toDisplayString(_ctx.t("designer.cancel")), 1)
8356
9075
  ])
8357
9076
  ])
@@ -8444,10 +9163,10 @@ const _sfc_main$9 = vueDemi.defineComponent({
8444
9163
  if (ta && lines) lines.scrollTop = ta.scrollTop;
8445
9164
  }
8446
9165
  function doClear() {
8447
- var _a;
9166
+ var _a2;
8448
9167
  text.value = variant.value === "template" ? JSON.stringify(EMPTY_TEMPLATE_JSON, null, 2) : "{}";
8449
9168
  error.value = "";
8450
- (_a = textareaRef.value) == null ? void 0 : _a.focus();
9169
+ (_a2 = textareaRef.value) == null ? void 0 : _a2.focus();
8451
9170
  }
8452
9171
  async function doCopy() {
8453
9172
  try {
@@ -8998,25 +9717,25 @@ const _sfc_main$7 = vueDemi.defineComponent({
8998
9717
  },
8999
9718
  emits: ["update:visible", "close"],
9000
9719
  setup(props, { emit }) {
9001
- var _a, _b;
9720
+ var _a2, _b2;
9002
9721
  const boxRef = vueDemi.ref(null);
9003
9722
  const { t } = useI18n();
9004
9723
  const designerUi = useDesignerUi();
9005
9724
  const styleOverrides = vueDemi.computed(() => props.styleOptionKey ? resolvePanelDragBoxOptions(props.styleOptionKey, designerUi == null ? void 0 : designerUi.styleOption.value) : null);
9006
9725
  const resolvedTitle = vueDemi.computed(() => {
9007
- var _a2;
9008
- return ((_a2 = styleOverrides.value) == null ? void 0 : _a2.title) || props.title;
9726
+ var _a3;
9727
+ return ((_a3 = styleOverrides.value) == null ? void 0 : _a3.title) || props.title;
9009
9728
  });
9010
9729
  const draggable = vueDemi.computed(() => {
9011
- var _a2;
9012
- return ((_a2 = styleOverrides.value) == null ? void 0 : _a2.draggable) ?? true;
9730
+ var _a3;
9731
+ return ((_a3 = styleOverrides.value) == null ? void 0 : _a3.draggable) ?? true;
9013
9732
  });
9014
9733
  const showFold = vueDemi.computed(() => props.foldable);
9015
9734
  const showClose = vueDemi.computed(() => props.closable ?? !!props.panelKey);
9016
9735
  const dragBoxOptions = vueDemi.reactive({
9017
9736
  key: props.storageKey || void 0,
9018
- layoutKey: ((_a = styleOverrides.value) == null ? void 0 : _a.layoutKey) || props.layoutKey || void 0,
9019
- layoutSpec: (_b = styleOverrides.value) == null ? void 0 : _b.layoutSpec,
9737
+ layoutKey: ((_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutKey) || props.layoutKey || void 0,
9738
+ layoutSpec: (_b2 = styleOverrides.value) == null ? void 0 : _b2.layoutSpec,
9020
9739
  defaultX: props.defaultX,
9021
9740
  defaultY: props.defaultY,
9022
9741
  defaultWidth: props.width,
@@ -9033,8 +9752,8 @@ const _sfc_main$7 = vueDemi.defineComponent({
9033
9752
  }, { immediate: true });
9034
9753
  vueDemi.watch(
9035
9754
  () => {
9036
- var _a2;
9037
- return (_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutSpec;
9755
+ var _a3;
9756
+ return (_a3 = styleOverrides.value) == null ? void 0 : _a3.layoutSpec;
9038
9757
  },
9039
9758
  (spec) => {
9040
9759
  dragBoxOptions.layoutSpec = spec;
@@ -9042,8 +9761,8 @@ const _sfc_main$7 = vueDemi.defineComponent({
9042
9761
  );
9043
9762
  vueDemi.watch(
9044
9763
  () => {
9045
- var _a2;
9046
- return (_a2 = styleOverrides.value) == null ? void 0 : _a2.layoutKey;
9764
+ var _a3;
9765
+ return (_a3 = styleOverrides.value) == null ? void 0 : _a3.layoutKey;
9047
9766
  },
9048
9767
  (key) => {
9049
9768
  dragBoxOptions.layoutKey = key || props.layoutKey || void 0;
@@ -9067,8 +9786,8 @@ const _sfc_main$7 = vueDemi.defineComponent({
9067
9786
  }
9068
9787
  );
9069
9788
  const boxStyle = vueDemi.computed(() => {
9070
- var _a2;
9071
- const extra = { ...((_a2 = styleOverrides.value) == null ? void 0 : _a2.boxStyleExtra) ?? {} };
9789
+ var _a3;
9790
+ const extra = { ...((_a3 = styleOverrides.value) == null ? void 0 : _a3.boxStyleExtra) ?? {} };
9072
9791
  const isFixed = extra.position === "fixed";
9073
9792
  if (!isFixed) {
9074
9793
  delete extra.left;
@@ -9085,11 +9804,11 @@ const _sfc_main$7 = vueDemi.defineComponent({
9085
9804
  };
9086
9805
  });
9087
9806
  const bodyStyle = vueDemi.computed(() => {
9088
- var _a2;
9807
+ var _a3;
9089
9808
  return {
9090
9809
  padding: props.bodyPadding || void 0,
9091
9810
  ...props.bodyStyleExtra,
9092
- ...(_a2 = styleOverrides.value) == null ? void 0 : _a2.bodyStyleExtra
9811
+ ...(_a3 = styleOverrides.value) == null ? void 0 : _a3.bodyStyleExtra
9093
9812
  };
9094
9813
  });
9095
9814
  function onClose() {
@@ -9312,11 +10031,11 @@ const _sfc_main$5 = vueDemi.defineComponent({
9312
10031
  });
9313
10032
  }
9314
10033
  function refresh() {
9315
- var _a;
10034
+ var _a2;
9316
10035
  const map = miniMapRef.value;
9317
10036
  const host = document.getElementById(DESIGN_CONTAINER_ID);
9318
10037
  const scroller = host == null ? void 0 : host.parentElement;
9319
- const paper = (_a = host == null ? void 0 : host.querySelector) == null ? void 0 : _a.call(host, ".hiprint-printPaper");
10038
+ const paper = (_a2 = host == null ? void 0 : host.querySelector) == null ? void 0 : _a2.call(host, ".hiprint-printPaper");
9320
10039
  if (!map || !scroller || !paper) return;
9321
10040
  const mapW = map.clientWidth;
9322
10041
  const mapH = map.clientHeight;
@@ -9796,10 +10515,10 @@ const _sfc_main$1 = vueDemi.defineComponent({
9796
10515
  }
9797
10516
  };
9798
10517
  const activeTheme = vueDemi.computed(() => {
9799
- var _a, _b;
10518
+ var _a2, _b2;
9800
10519
  if (typeof props.theme === "string") return props.theme;
9801
- if (Array.isArray(props.theme)) return ((_a = props.theme[0]) == null ? void 0 : _a.theme) || "svpLight";
9802
- return ((_b = props.theme) == null ? void 0 : _b.theme) || "svpLight";
10520
+ if (Array.isArray(props.theme)) return ((_a2 = props.theme[0]) == null ? void 0 : _a2.theme) || "svpLight";
10521
+ return ((_b2 = props.theme) == null ? void 0 : _b2.theme) || "svpLight";
9803
10522
  });
9804
10523
  const { redraw: redrawRuler } = useRuler({
9805
10524
  canvasX: () => rulerXRef.value,
@@ -9816,9 +10535,9 @@ const _sfc_main$1 = vueDemi.defineComponent({
9816
10535
  return Array.isArray(json) && json.length > 0;
9817
10536
  }
9818
10537
  function resolveInitialTemplate() {
9819
- var _a;
10538
+ var _a2;
9820
10539
  if (templateHasPanels(props.template)) return props.template;
9821
- const saved = (_a = utils.loadSaved) == null ? void 0 : _a.call(utils);
10540
+ const saved = (_a2 = utils.loadSaved) == null ? void 0 : _a2.call(utils);
9822
10541
  if (saved && templateHasPanels(saved)) return saved;
9823
10542
  return props.template;
9824
10543
  }
@@ -9845,7 +10564,7 @@ const _sfc_main$1 = vueDemi.defineComponent({
9845
10564
  applyStyleOption(props.styleOption);
9846
10565
  }
9847
10566
  function buildDesigner() {
9848
- var _a;
10567
+ var _a2;
9849
10568
  utils.newDesigner(
9850
10569
  {
9851
10570
  template: resolveInitialTemplate(),
@@ -9862,13 +10581,13 @@ const _sfc_main$1 = vueDemi.defineComponent({
9862
10581
  utils.plugins.run("onDesigned", payload).catch(() => {
9863
10582
  });
9864
10583
  utils.setPreview(previewRef.value);
9865
- if ((_a = props.designOptions) == null ? void 0 : _a.adaptToSize) {
10584
+ if ((_a2 = props.designOptions) == null ? void 0 : _a2.adaptToSize) {
9866
10585
  requestAnimationFrame(() => utils.adaptToSize());
9867
10586
  }
9868
10587
  }
9869
10588
  let resizeHandler = null;
9870
10589
  vueDemi.onMounted(async () => {
9871
- var _a;
10590
+ var _a2;
9872
10591
  setLocale(props.lang);
9873
10592
  designerStore.lang = props.lang;
9874
10593
  designerStore.theme = activeTheme.value;
@@ -9884,10 +10603,13 @@ const _sfc_main$1 = vueDemi.defineComponent({
9884
10603
  utils.buildByHtml();
9885
10604
  } catch {
9886
10605
  }
9887
- if ((_a = props.designOptions) == null ? void 0 : _a.adaptToSize) {
10606
+ if ((_a2 = props.designOptions) == null ? void 0 : _a2.adaptToSize) {
9888
10607
  resizeHandler = () => utils.adaptToSize();
9889
10608
  window.addEventListener("resize", resizeHandler);
9890
10609
  }
10610
+ if (props.autoConnect) {
10611
+ utils.setConnect(true);
10612
+ }
9891
10613
  });
9892
10614
  vueDemi.onBeforeUnmount(() => {
9893
10615
  utils.shortcuts.unmount();
@@ -9926,8 +10648,8 @@ const _sfc_main$1 = vueDemi.defineComponent({
9926
10648
  utils.import();
9927
10649
  }
9928
10650
  function handlePreview() {
9929
- var _a, _b;
9930
- (_b = (_a = previewRef.value) == null ? void 0 : _a.open) == null ? void 0 : _b.call(_a);
10651
+ var _a2, _b2;
10652
+ (_b2 = (_a2 = previewRef.value) == null ? void 0 : _a2.open) == null ? void 0 : _b2.call(_a2);
9931
10653
  }
9932
10654
  return {
9933
10655
  DESIGN_CONTAINER_ID,
@@ -10095,7 +10817,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
10095
10817
  }
10096
10818
  const Ruler = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
10097
10819
  const pluginApiPdf = (opts = {}) => {
10098
- const plugin = {
10820
+ const plugin2 = {
10099
10821
  name: "plugin-api-pdf",
10100
10822
  description: "Exports the current template as a PDF document.",
10101
10823
  config: { ...opts },
@@ -10129,10 +10851,10 @@ const pluginApiPdf = (opts = {}) => {
10129
10851
  }
10130
10852
  ]
10131
10853
  };
10132
- return plugin;
10854
+ return plugin2;
10133
10855
  };
10134
10856
  const pluginApiImage = (opts = {}) => {
10135
- const plugin = {
10857
+ const plugin2 = {
10136
10858
  name: "plugin-api-image",
10137
10859
  description: "Exports the current template as PNG / JPEG.",
10138
10860
  config: { type: "png", ...opts },
@@ -10159,7 +10881,7 @@ const pluginApiImage = (opts = {}) => {
10159
10881
  }
10160
10882
  ]
10161
10883
  };
10162
- return plugin;
10884
+ return plugin2;
10163
10885
  };
10164
10886
  function defaultEditor(source, ctx) {
10165
10887
  return new Promise((resolve) => {
@@ -10200,7 +10922,7 @@ function defaultEditor(source, ctx) {
10200
10922
  }
10201
10923
  const pluginViewCodeEdit = (opts = {}) => {
10202
10924
  const editor = opts.editor ?? defaultEditor;
10203
- const plugin = {
10925
+ const plugin2 = {
10204
10926
  name: "plugin-view-code-edit",
10205
10927
  description: "Provides a small in-browser editor for `function` options.",
10206
10928
  config: { ...opts },
@@ -10210,18 +10932,18 @@ const pluginViewCodeEdit = (opts = {}) => {
10210
10932
  name: "editor-create-print-element",
10211
10933
  priority: 100,
10212
10934
  run: async (option, _printElement, _ev) => {
10213
- var _a;
10935
+ var _a2;
10214
10936
  if (!option || typeof option !== "object") return;
10215
10937
  if (option.type !== "function" && option.editor !== "code") return;
10216
10938
  const next = await editor(String(option.value ?? ""), { name: option.name ?? "function" });
10217
10939
  if (next == null) return;
10218
10940
  option.value = next;
10219
- (_a = option == null ? void 0 : option.onChange) == null ? void 0 : _a.call(option, next);
10941
+ (_a2 = option == null ? void 0 : option.onChange) == null ? void 0 : _a2.call(option, next);
10220
10942
  }
10221
10943
  }
10222
10944
  ]
10223
10945
  };
10224
- return plugin;
10946
+ return plugin2;
10225
10947
  };
10226
10948
  const index = {
10227
10949
  install(app) {
@@ -10232,14 +10954,6 @@ const index = {
10232
10954
  app.component("SvpDragBox", DragBox);
10233
10955
  }
10234
10956
  };
10235
- Object.defineProperty(exports, "defaultElementTypeProvider", {
10236
- enumerable: true,
10237
- get: () => vuePluginHiprint.defaultElementTypeProvider
10238
- });
10239
- Object.defineProperty(exports, "hiprint", {
10240
- enumerable: true,
10241
- get: () => vuePluginHiprint.hiprint
10242
- });
10243
10957
  exports.DEFAULT_ELEMENT_CATALOGUE = DEFAULT_ELEMENT_CATALOGUE;
10244
10958
  exports.DEFAULT_FONT_LIST = DEFAULT_FONT_LIST;
10245
10959
  exports.DEFAULT_PAPER_LIST = DEFAULT_PAPER_LIST;
@@ -10274,6 +10988,7 @@ exports.PageHistoryPanel = PageHistoryPanel;
10274
10988
  exports.PageStructurePanel = PageStructurePanel;
10275
10989
  exports.PluginManager = PluginManager;
10276
10990
  exports.Preview = Preview;
10991
+ exports.PrintClient = PrintClient;
10277
10992
  exports.PropertiesPanel = PropertiesPanel;
10278
10993
  exports.Provider = Provider;
10279
10994
  exports.Ruler = Ruler;
@@ -10289,16 +11004,22 @@ exports.ZOOM_MAX = ZOOM_MAX;
10289
11004
  exports.ZOOM_MIN = ZOOM_MIN;
10290
11005
  exports.ZOOM_STEP = ZOOM_STEP;
10291
11006
  exports.applyStyleOption = applyStyleOption;
11007
+ exports.autoConnect = autoConnect;
11008
+ exports.batchPrint = batchPrint;
10292
11009
  exports.buildByHtml = buildByHtml;
10293
11010
  exports.buildPrintDataFromForm = buildPrintDataFromForm;
10294
11011
  exports.createPrintDataFormState = createPrintDataFormState;
10295
11012
  exports.default = index;
11013
+ exports.defaultElementTypeProvider = defaultElementTypeProvider;
10296
11014
  exports.designerStore = designerStore;
11015
+ exports.disAutoConnect = disAutoConnect;
10297
11016
  exports.elementTypeKey = elementTypeKey;
10298
11017
  exports.enUS = enUS;
10299
11018
  exports.extractTemplateFields = extractTemplateFields;
10300
11019
  exports.getLocaleList = getLocaleList;
11020
+ exports.getPrintClient = getPrintClient;
10301
11021
  exports.headerElementsFromCatalogue = headerElementsFromCatalogue;
11022
+ exports.hiprint = hiprint;
10302
11023
  exports.iconForElement = iconForElement;
10303
11024
  exports.iconForElementKey = iconForElementKey;
10304
11025
  exports.iconForHeaderTab = iconForHeaderTab;