@lucablockltd/ultimate-packaging 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -413,6 +413,7 @@ var AUTO_LAYOUT_THEME_CONFIG = {
413
413
  };
414
414
 
415
415
  // src/config.ts
416
+ var DEFAULT_FONT_DIMENSION_SIZE = 4.2;
416
417
  var globalConfig = {};
417
418
  function configurePackaging(config) {
418
419
  globalConfig = config;
@@ -420,6 +421,9 @@ function configurePackaging(config) {
420
421
  function getModelTheme() {
421
422
  return { ...MODEL_THEME_CONFIG, ...globalConfig.modelTheme };
422
423
  }
424
+ function getFontDimensionSize() {
425
+ return globalConfig.fontDimensionSize ?? DEFAULT_FONT_DIMENSION_SIZE;
426
+ }
423
427
  function getAutoLayoutTheme() {
424
428
  return { ...AUTO_LAYOUT_THEME_CONFIG, ...globalConfig.autoLayoutTheme };
425
429
  }
@@ -1011,7 +1015,7 @@ var UNIT_FACTOR = {
1011
1015
  in: 1 / 25.4
1012
1016
  };
1013
1017
  var PX_PER_MM = 96 / 25.4;
1014
- function renderDimension(dim, i) {
1018
+ function renderDimension(dim, i, fs) {
1015
1019
  const { x1, y1, x2, y2, label, orientation, offset } = dim;
1016
1020
  const tick = 1.5;
1017
1021
  if (orientation === "horizontal") {
@@ -1027,7 +1031,7 @@ function renderDimension(dim, i) {
1027
1031
  x: midX,
1028
1032
  y: y - 1.5,
1029
1033
  textAnchor: "middle",
1030
- fontSize: 3.5,
1034
+ fontSize: fs,
1031
1035
  fontFamily: "sans-serif",
1032
1036
  fill: "#000",
1033
1037
  children: label
@@ -1048,7 +1052,7 @@ function renderDimension(dim, i) {
1048
1052
  y: midY - 1,
1049
1053
  textAnchor: "middle",
1050
1054
  dominantBaseline: "central",
1051
- fontSize: 3.5,
1055
+ fontSize: fs,
1052
1056
  fontFamily: "sans-serif",
1053
1057
  fill: "#000",
1054
1058
  transform: `rotate(-90, ${x - 1.5}, ${midY})`,
@@ -1157,7 +1161,7 @@ var DIE_LINE_BECF_1010A = react.forwardRef(
1157
1161
  const svgChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1158
1162
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
1159
1163
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
1160
- isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map(renderDimension) })
1164
+ isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension(d, i, getFontDimensionSize())) })
1161
1165
  ] });
1162
1166
  if (renderAs === "group") {
1163
1167
  return /* @__PURE__ */ jsxRuntime.jsx("g", { children: svgChildren });
@@ -1659,7 +1663,7 @@ var UNIT_FACTOR2 = {
1659
1663
  in: 1 / 25.4
1660
1664
  };
1661
1665
  var PX_PER_MM2 = 96 / 25.4;
1662
- function renderDimension2(dim, i) {
1666
+ function renderDimension2(dim, i, fs) {
1663
1667
  const { x1, y1, x2, y2, label, orientation, offset } = dim;
1664
1668
  const tick = 1.5;
1665
1669
  if (orientation === "horizontal") {
@@ -1675,7 +1679,7 @@ function renderDimension2(dim, i) {
1675
1679
  x: midX,
1676
1680
  y: y - 1.5,
1677
1681
  textAnchor: "middle",
1678
- fontSize: 4.2,
1682
+ fontSize: fs,
1679
1683
  fontFamily: "sans-serif",
1680
1684
  fill: "#000",
1681
1685
  children: label
@@ -1696,7 +1700,7 @@ function renderDimension2(dim, i) {
1696
1700
  y: midY - 1,
1697
1701
  textAnchor: "middle",
1698
1702
  dominantBaseline: "central",
1699
- fontSize: 4.2,
1703
+ fontSize: fs,
1700
1704
  fontFamily: "sans-serif",
1701
1705
  fill: "#000",
1702
1706
  transform: `rotate(-90, ${x - 1.5}, ${midY})`,
@@ -1805,7 +1809,7 @@ var DIE_LINE_BECF_1030A = react.forwardRef(
1805
1809
  const svgChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1806
1810
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
1807
1811
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
1808
- isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map(renderDimension2) })
1812
+ isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension2(d, i, getFontDimensionSize())) })
1809
1813
  ] });
1810
1814
  if (renderAs === "group") {
1811
1815
  return /* @__PURE__ */ jsxRuntime.jsx("g", { children: svgChildren });
@@ -2310,7 +2314,7 @@ var UNIT_FACTOR3 = {
2310
2314
  in: 1 / 25.4
2311
2315
  };
2312
2316
  var PX_PER_MM3 = 96 / 25.4;
2313
- function renderDimension3(dim, i) {
2317
+ function renderDimension3(dim, i, fs) {
2314
2318
  const { x1, y1, x2, y2, label, orientation, offset } = dim;
2315
2319
  const tick = 1.5;
2316
2320
  if (orientation === "horizontal") {
@@ -2326,7 +2330,7 @@ function renderDimension3(dim, i) {
2326
2330
  x: midX,
2327
2331
  y: y - 1.5,
2328
2332
  textAnchor: "middle",
2329
- fontSize: 4.2,
2333
+ fontSize: fs,
2330
2334
  fontFamily: "sans-serif",
2331
2335
  fill: "#000",
2332
2336
  children: label
@@ -2347,7 +2351,7 @@ function renderDimension3(dim, i) {
2347
2351
  y: midY - 1,
2348
2352
  textAnchor: "middle",
2349
2353
  dominantBaseline: "central",
2350
- fontSize: 4.2,
2354
+ fontSize: fs,
2351
2355
  fontFamily: "sans-serif",
2352
2356
  fill: "#000",
2353
2357
  transform: `rotate(-90, ${x - 1.5}, ${midY})`,
@@ -2456,7 +2460,7 @@ var DIE_LINE_BECF_1040A = react.forwardRef(
2456
2460
  const svgChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2457
2461
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
2458
2462
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
2459
- isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map(renderDimension3) })
2463
+ isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension3(d, i, getFontDimensionSize())) })
2460
2464
  ] });
2461
2465
  if (renderAs === "group") {
2462
2466
  return /* @__PURE__ */ jsxRuntime.jsx("g", { children: svgChildren });
@@ -2873,7 +2877,7 @@ var UNIT_FACTOR4 = {
2873
2877
  in: 1 / 25.4
2874
2878
  };
2875
2879
  var PX_PER_MM4 = 96 / 25.4;
2876
- function renderDimension4(dim, i) {
2880
+ function renderDimension4(dim, i, fs) {
2877
2881
  const { x1, y1, x2, y2, label, orientation, offset } = dim;
2878
2882
  const tick = 1.5;
2879
2883
  if (orientation === "horizontal") {
@@ -2889,7 +2893,7 @@ function renderDimension4(dim, i) {
2889
2893
  x: midX,
2890
2894
  y: y - 1.5,
2891
2895
  textAnchor: "middle",
2892
- fontSize: 4.2,
2896
+ fontSize: fs,
2893
2897
  fontFamily: "sans-serif",
2894
2898
  fill: "#000",
2895
2899
  children: label
@@ -2910,7 +2914,7 @@ function renderDimension4(dim, i) {
2910
2914
  y: midY - 1,
2911
2915
  textAnchor: "middle",
2912
2916
  dominantBaseline: "central",
2913
- fontSize: 4.2,
2917
+ fontSize: fs,
2914
2918
  fontFamily: "sans-serif",
2915
2919
  fill: "#000",
2916
2920
  transform: `rotate(-90, ${x - 1.5}, ${midY})`,
@@ -3018,7 +3022,7 @@ var DIE_LINE_BECF_11D01 = react.forwardRef(
3018
3022
  const svgChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3019
3023
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
3020
3024
  /* @__PURE__ */ jsxRuntime.jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
3021
- isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map(renderDimension4) })
3025
+ isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension4(d, i, getFontDimensionSize())) })
3022
3026
  ] });
3023
3027
  if (renderAs === "group") {
3024
3028
  return /* @__PURE__ */ jsxRuntime.jsx("g", { children: svgChildren });
@@ -3132,369 +3136,1761 @@ var MODEL_BECF_11D01 = react.forwardRef(
3132
3136
  }
3133
3137
  );
3134
3138
 
3135
- // src/utils/autoLayout/rasterize.ts
3136
- function rasterizePolygon(points, resolution) {
3137
- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
3138
- for (const p of points) {
3139
- if (p.x < minX) minX = p.x;
3140
- if (p.y < minY) minY = p.y;
3141
- if (p.x > maxX) maxX = p.x;
3142
- if (p.y > maxY) maxY = p.y;
3143
- }
3144
- const offsetX = Math.floor(minX / resolution);
3145
- const offsetY = Math.floor(minY / resolution);
3146
- const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
3147
- const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
3148
- const data = new Uint8Array(w * h);
3149
- for (let gy = 0; gy < h; gy++) {
3150
- const worldY = (offsetY + gy) * resolution + resolution / 2;
3151
- const crossings = [];
3152
- for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
3153
- const yi = points[i].y, yj = points[j].y;
3154
- if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
3155
- const t = (worldY - yi) / (yj - yi);
3156
- crossings.push(points[i].x + t * (points[j].x - points[i].x));
3157
- }
3158
- }
3159
- crossings.sort((a, b) => a - b);
3160
- for (let c = 0; c < crossings.length - 1; c += 2) {
3161
- const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
3162
- const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
3163
- for (let gx = startGx; gx <= endGx; gx++) {
3164
- data[gy * w + gx] = 1;
3165
- }
3166
- }
3167
- }
3168
- return { data, width: w, height: h, offsetX, offsetY };
3139
+ // src/components/dieline/bags-pillows/becf-12101/generate.ts
3140
+ var DIP = 15;
3141
+ var ROPE_R = 3;
3142
+ var ROPE_Y = 20;
3143
+ var D_MAX = 40;
3144
+ function calcD(c, b) {
3145
+ return Math.min(c - 2 - b / 2, D_MAX);
3146
+ }
3147
+ function calcKulak(b) {
3148
+ if (b <= 13) return b - 1;
3149
+ if (b <= 99) return 13;
3150
+ if (b <= 249) return 20;
3151
+ if (b <= 499) return 25;
3152
+ return 30;
3153
+ }
3154
+ function calcX(a) {
3155
+ return Math.min(a / 2, 110);
3156
+ }
3157
+ function getAutoCalcValues(attr) {
3158
+ const { length: A, width: B, height: C, glueArea } = attr;
3159
+ const D = calcD(C, B);
3160
+ const kulak = glueArea ?? calcKulak(B);
3161
+ const X = calcX(A);
3162
+ return { d: D, kulak, dip: DIP, ropeR: ROPE_R, ropeY: ROPE_Y, ropeX: X };
3163
+ }
3164
+ function line5(x1, y1, x2, y2) {
3165
+ return `M${x1} ${y1} L${x2} ${y2}`;
3169
3166
  }
3170
- function canPlace(paperGrid, paperW, paperH, piece, px, py) {
3171
- for (let y = 0; y < piece.height; y++) {
3172
- const paperY = py + y;
3173
- if (paperY < 0 || paperY >= paperH) {
3174
- for (let x = 0; x < piece.width; x++) {
3175
- if (piece.data[y * piece.width + x]) return false;
3176
- }
3167
+ function circlePath(cx, cy, r) {
3168
+ return `M${cx - r} ${cy} A${r} ${r} 0 0 1 ${cx + r} ${cy} A${r} ${r} 0 0 1 ${cx - r} ${cy}`;
3169
+ }
3170
+ function generateBecf12101(attr) {
3171
+ const { length: A, width: B, height: C, glueArea } = attr;
3172
+ const D = calcD(C, B);
3173
+ const kulak = glueArea ?? calcKulak(B);
3174
+ const X = calcX(A);
3175
+ const xFront = kulak;
3176
+ const xSide1 = kulak + A;
3177
+ const xSide1Mid = kulak + A + B / 2;
3178
+ const xBack = kulak + A + B;
3179
+ const xSide2 = kulak + 2 * A + B;
3180
+ const xSide2Mid = kulak + 2 * A + B + B / 2;
3181
+ const xEnd = kulak + 2 * A + 2 * B - 2;
3182
+ const yFoldTop = D;
3183
+ const yFoldBottomStart = D + C - B / 2;
3184
+ const yFoldBottom = D + C;
3185
+ const yBottomFlap = D + C + B / 2;
3186
+ const yEnd = D + C + B / 2 + DIP;
3187
+ const totalWidth = xEnd;
3188
+ const totalHeight = yEnd;
3189
+ const cut = [];
3190
+ const crease = [];
3191
+ cut.push(line5(0, 0, totalWidth, 0));
3192
+ cut.push(line5(totalWidth, 0, totalWidth, totalHeight));
3193
+ cut.push(line5(totalWidth, totalHeight, 0, totalHeight));
3194
+ cut.push(line5(0, totalHeight, 0, 0));
3195
+ cut.push(line5(kulak + B / 2, yBottomFlap, kulak + B / 2, yEnd));
3196
+ cut.push(line5(kulak + A - B / 2, yBottomFlap, kulak + A - B / 2, yEnd));
3197
+ cut.push(line5(kulak + A + B + B / 2, yBottomFlap, kulak + A + B + B / 2, yEnd));
3198
+ cut.push(line5(kulak + 2 * A + B - B / 2, yBottomFlap, kulak + 2 * A + B - B / 2, yEnd));
3199
+ const frontCx = kulak + A / 2;
3200
+ const backCx = kulak + A + B + A / 2;
3201
+ const ropeTopY = yFoldTop - ROPE_Y;
3202
+ const ropeBotY = yFoldTop + ROPE_Y;
3203
+ cut.push(circlePath(frontCx - X / 2, ropeTopY, ROPE_R));
3204
+ cut.push(circlePath(frontCx - X / 2, ropeBotY, ROPE_R));
3205
+ cut.push(circlePath(frontCx + X / 2, ropeTopY, ROPE_R));
3206
+ cut.push(circlePath(frontCx + X / 2, ropeBotY, ROPE_R));
3207
+ cut.push(circlePath(backCx - X / 2, ropeTopY, ROPE_R));
3208
+ cut.push(circlePath(backCx - X / 2, ropeBotY, ROPE_R));
3209
+ cut.push(circlePath(backCx + X / 2, ropeTopY, ROPE_R));
3210
+ cut.push(circlePath(backCx + X / 2, ropeBotY, ROPE_R));
3211
+ crease.push(line5(0, yFoldTop, totalWidth, yFoldTop));
3212
+ crease.push(line5(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
3213
+ crease.push(line5(0, yFoldBottom, totalWidth, yFoldBottom));
3214
+ crease.push(line5(xFront, 0, xFront, totalHeight));
3215
+ crease.push(line5(xSide1, 0, xSide1, totalHeight));
3216
+ crease.push(line5(xSide1Mid, 0, xSide1Mid, totalHeight));
3217
+ crease.push(line5(xBack, 0, xBack, totalHeight));
3218
+ crease.push(line5(xSide2, 0, xSide2, totalHeight));
3219
+ crease.push(line5(xSide2Mid, 0, xSide2Mid, totalHeight));
3220
+ crease.push(line5(0, yFoldBottom - kulak, kulak + B / 2, yBottomFlap));
3221
+ crease.push(line5(kulak + A - B / 2, yBottomFlap, xSide1Mid, yFoldBottomStart));
3222
+ crease.push(line5(xSide1Mid, yFoldBottomStart, kulak + A + B + B / 2, yBottomFlap));
3223
+ crease.push(line5(kulak + 2 * A + B - B / 2, yBottomFlap, xSide2Mid, yFoldBottomStart));
3224
+ crease.push(line5(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
3225
+ return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
3226
+ }
3227
+ function generateOuterContour5(attr) {
3228
+ const { length: A, width: B, height: C, glueArea } = attr;
3229
+ const D = calcD(C, B);
3230
+ const kulak = glueArea ?? calcKulak(B);
3231
+ const totalWidth = kulak + 2 * A + 2 * B - 2;
3232
+ const totalHeight = D + C + B / 2 + DIP;
3233
+ return [
3234
+ { x: 0, y: 0 },
3235
+ { x: totalWidth, y: 0 },
3236
+ { x: totalWidth, y: totalHeight },
3237
+ { x: 0, y: totalHeight }
3238
+ ];
3239
+ }
3240
+ function offsetContour5(points, distance) {
3241
+ const n = points.length;
3242
+ const result = [];
3243
+ for (let i = 0; i < n; i++) {
3244
+ const prev = points[(i - 1 + n) % n];
3245
+ const curr = points[i];
3246
+ const next = points[(i + 1) % n];
3247
+ const e1x = curr.x - prev.x;
3248
+ const e1y = curr.y - prev.y;
3249
+ const e2x = next.x - curr.x;
3250
+ const e2y = next.y - curr.y;
3251
+ const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
3252
+ const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
3253
+ if (len1 === 0 || len2 === 0) {
3254
+ result.push(curr);
3177
3255
  continue;
3178
3256
  }
3179
- for (let x = 0; x < piece.width; x++) {
3180
- if (!piece.data[y * piece.width + x]) continue;
3181
- const paperX = px + x;
3182
- if (paperX < 0 || paperX >= paperW) return false;
3183
- if (paperGrid[paperY * paperW + paperX]) return false;
3257
+ const n1x = e1y / len1;
3258
+ const n1y = -e1x / len1;
3259
+ const n2x = e2y / len2;
3260
+ const n2y = -e2x / len2;
3261
+ const ax = n1x + n2x;
3262
+ const ay = n1y + n2y;
3263
+ const aLen = Math.sqrt(ax * ax + ay * ay);
3264
+ if (aLen < 1e-3) {
3265
+ result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
3266
+ continue;
3184
3267
  }
3268
+ const nx = ax / aLen;
3269
+ const ny = ay / aLen;
3270
+ const dot = n1x * nx + n1y * ny;
3271
+ const d = distance / Math.max(dot, 0.1);
3272
+ result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
3185
3273
  }
3186
- return true;
3274
+ return result;
3187
3275
  }
3188
- function placePiece(paperGrid, paperW, piece, px, py) {
3189
- for (let y = 0; y < piece.height; y++) {
3190
- for (let x = 0; x < piece.width; x++) {
3191
- if (piece.data[y * piece.width + x]) {
3192
- paperGrid[(py + y) * paperW + (px + x)] = 1;
3193
- }
3194
- }
3276
+ function contourToPath5(points) {
3277
+ if (points.length === 0) return "";
3278
+ let d = `M${points[0].x} ${points[0].y}`;
3279
+ for (let i = 1; i < points.length; i++) {
3280
+ d += ` L${points[i].x} ${points[i].y}`;
3195
3281
  }
3282
+ d += " Z";
3283
+ return d;
3196
3284
  }
3197
-
3198
- // src/utils/autoLayout/calculate/shared.ts
3199
- var RESOLUTION = 1;
3200
- function resolveGripperSide(paperWidth, paperHeight) {
3201
- if (paperWidth >= paperHeight) return "bottom";
3202
- return "left";
3203
- }
3204
- function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
3205
- switch (gripperSide) {
3206
- case "bottom":
3207
- return {
3208
- top: colorbarDepth + spacing,
3209
- bottom: paperHeight - griper,
3210
- left: spacing,
3211
- right: paperWidth - spacing
3212
- };
3213
- case "top":
3214
- return {
3215
- top: griper,
3216
- bottom: paperHeight - colorbarDepth - spacing,
3217
- left: spacing,
3218
- right: paperWidth - spacing
3219
- };
3220
- case "left":
3221
- return {
3222
- top: spacing,
3223
- bottom: paperHeight - spacing,
3224
- left: griper,
3225
- right: paperWidth - colorbarDepth - spacing
3226
- };
3227
- case "right":
3228
- return {
3229
- top: spacing,
3230
- bottom: paperHeight - spacing,
3231
- left: colorbarDepth + spacing,
3232
- right: paperWidth - griper
3233
- };
3234
- }
3285
+ function generateDimensions5(attr, unit) {
3286
+ const { length: A, width: B, height: C, glueArea } = attr;
3287
+ const D = calcD(C, B);
3288
+ const kulak = glueArea ?? calcKulak(B);
3289
+ const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
3290
+ const suffix = unit;
3291
+ const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
3292
+ const xFront = kulak;
3293
+ const xSide1 = kulak + A;
3294
+ const xBack = kulak + A + B;
3295
+ const yFoldTop = D;
3296
+ const yFoldBottom = D + C;
3297
+ const yEnd = D + C + B / 2 + DIP;
3298
+ const totalWidth = kulak + 2 * A + 2 * B - 2;
3299
+ const totalHeight = yEnd;
3300
+ const bottomSection = B / 2 + DIP;
3301
+ return [
3302
+ // Overall dimensions (outside)
3303
+ {
3304
+ x1: 0,
3305
+ y1: 0,
3306
+ x2: totalWidth,
3307
+ y2: 0,
3308
+ label: `Overall Width : ${fmt(totalWidth)}`,
3309
+ orientation: "horizontal",
3310
+ offset: -12
3311
+ },
3312
+ {
3313
+ x1: 0,
3314
+ y1: 0,
3315
+ x2: 0,
3316
+ y2: totalHeight,
3317
+ label: `Overall Height : ${fmt(totalHeight)}`,
3318
+ orientation: "vertical",
3319
+ offset: -12
3320
+ },
3321
+ // Height (C) — body area (centered on back panel)
3322
+ {
3323
+ x1: xBack + A * 0.6,
3324
+ y1: yFoldTop,
3325
+ x2: xBack + A * 0.6,
3326
+ y2: yFoldBottom,
3327
+ label: fmt(C),
3328
+ orientation: "vertical",
3329
+ offset: -10
3330
+ },
3331
+ // Top flap (D) (centered on back panel)
3332
+ {
3333
+ x1: xBack + A * 0.6,
3334
+ y1: 0,
3335
+ x2: xBack + A * 0.6,
3336
+ y2: yFoldTop,
3337
+ label: fmt(D),
3338
+ orientation: "vertical",
3339
+ offset: -10
3340
+ },
3341
+ // Bottom section (B/2 + _dip) (centered on back panel)
3342
+ {
3343
+ x1: xBack + A * 0.6,
3344
+ y1: yFoldBottom,
3345
+ x2: xBack + A * 0.6,
3346
+ y2: yEnd,
3347
+ label: fmt(bottomSection),
3348
+ orientation: "vertical",
3349
+ offset: -10
3350
+ },
3351
+ // Length (A) — front panel (centered vertically on body)
3352
+ {
3353
+ x1: xFront,
3354
+ y1: yFoldTop + C * 0.65,
3355
+ x2: xSide1,
3356
+ y2: yFoldTop + C * 0.65,
3357
+ label: fmt(A),
3358
+ orientation: "horizontal",
3359
+ offset: -20
3360
+ },
3361
+ // Width (B) — side panel (centered vertically on body)
3362
+ {
3363
+ x1: xSide1,
3364
+ y1: yFoldTop + C * 0.65,
3365
+ x2: xBack,
3366
+ y2: yFoldTop + C * 0.65,
3367
+ label: fmt(B),
3368
+ orientation: "horizontal",
3369
+ offset: -20
3370
+ },
3371
+ // Glue Area (kulak) — left glue flap width
3372
+ {
3373
+ x1: 0,
3374
+ y1: yFoldTop + C * 0.65,
3375
+ x2: xFront,
3376
+ y2: yFoldTop + C * 0.65,
3377
+ label: fmt(kulak),
3378
+ orientation: "horizontal",
3379
+ offset: -20
3380
+ }
3381
+ ];
3235
3382
  }
3236
- function normalizePoints(points, degrees) {
3237
- const rad = degrees * Math.PI / 180;
3238
- const cos = Math.cos(rad);
3239
- const sin = Math.sin(rad);
3240
- const rotated = points.map((p) => ({
3241
- x: p.x * cos - p.y * sin,
3242
- y: p.x * sin + p.y * cos
3243
- }));
3244
- let minX = Infinity, minY = Infinity;
3245
- for (const p of rotated) {
3246
- if (p.x < minX) minX = p.x;
3247
- if (p.y < minY) minY = p.y;
3383
+ var MODEL_ID5 = "BECF-12101";
3384
+ var UNIT_FACTOR5 = {
3385
+ mm: 1,
3386
+ cm: 0.1,
3387
+ in: 1 / 25.4
3388
+ };
3389
+ var PX_PER_MM5 = 96 / 25.4;
3390
+ function renderDimension5(dim, i, fs) {
3391
+ const { x1, y1, x2, y2, label, orientation, offset } = dim;
3392
+ const tick = 1.5;
3393
+ if (orientation === "horizontal") {
3394
+ const y = y1 + offset;
3395
+ const midX = (x1 + x2) / 2;
3396
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3397
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
3398
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
3399
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
3400
+ /* @__PURE__ */ jsxRuntime.jsx(
3401
+ "text",
3402
+ {
3403
+ x: midX,
3404
+ y: y - 1.5,
3405
+ textAnchor: "middle",
3406
+ fontSize: fs,
3407
+ fontFamily: "sans-serif",
3408
+ fill: "#000",
3409
+ children: label
3410
+ }
3411
+ )
3412
+ ] }, `dim-${i}`);
3248
3413
  }
3249
- return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
3414
+ const x = x1 + offset;
3415
+ const midY = (y1 + y2) / 2;
3416
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3417
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
3418
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
3419
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
3420
+ /* @__PURE__ */ jsxRuntime.jsx(
3421
+ "text",
3422
+ {
3423
+ x: x - 1.5,
3424
+ y: midY - 1,
3425
+ textAnchor: "middle",
3426
+ dominantBaseline: "central",
3427
+ fontSize: fs,
3428
+ fontFamily: "sans-serif",
3429
+ fill: "#000",
3430
+ transform: `rotate(-90, ${x - 1.5}, ${midY})`,
3431
+ children: label
3432
+ }
3433
+ )
3434
+ ] }, `dim-${i}`);
3250
3435
  }
3251
- function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
3252
- const rad = degrees * Math.PI / 180;
3253
- const cos = Math.cos(rad);
3254
- const sin = Math.sin(rad);
3255
- let ocMinX = Infinity, ocMinY = Infinity;
3256
- for (const p of offsetContourPoints) {
3257
- const rx = p.x * cos - p.y * sin;
3436
+ var DIE_LINE_BECF_12101 = react.forwardRef(
3437
+ ({
3438
+ attributes,
3439
+ unit = "mm",
3440
+ isShowDimensions = false,
3441
+ renderAs = "svg"
3442
+ }, ref) => {
3443
+ const theme = react.useMemo(
3444
+ () => getModelTheme(),
3445
+ []
3446
+ );
3447
+ const svgRef = react.useRef(null);
3448
+ const dieline = react.useMemo(() => generateBecf12101(attributes), [attributes]);
3449
+ const dimensions = react.useMemo(
3450
+ () => generateDimensions5(attributes, unit),
3451
+ [attributes, unit]
3452
+ );
3453
+ const factor = UNIT_FACTOR5[unit] ?? 1;
3454
+ const serializeSvg = react.useCallback(
3455
+ (showDimensions) => {
3456
+ const svg = svgRef.current;
3457
+ if (!svg) throw new Error("SVG not mounted");
3458
+ const clone = svg.cloneNode(true);
3459
+ if (!showDimensions) {
3460
+ const dimGroup = clone.querySelector("#dimensions");
3461
+ dimGroup?.remove();
3462
+ }
3463
+ return new XMLSerializer().serializeToString(clone);
3464
+ },
3465
+ []
3466
+ );
3467
+ react.useImperativeHandle(
3468
+ ref,
3469
+ () => {
3470
+ const auto = getAutoCalcValues(attributes);
3471
+ return {
3472
+ getAttributes: () => ({
3473
+ modelId: MODEL_ID5,
3474
+ overallWidth: dieline.viewBox.width * factor,
3475
+ overallHeight: dieline.viewBox.height * factor,
3476
+ length: attributes.length * factor,
3477
+ width: attributes.width * factor,
3478
+ height: attributes.height * factor,
3479
+ glueArea: auto.kulak * factor,
3480
+ d: auto.d * factor,
3481
+ kulak: auto.kulak * factor,
3482
+ dip: auto.dip * factor,
3483
+ ropeR: auto.ropeR * factor,
3484
+ ropeY: auto.ropeY * factor,
3485
+ ropeX: auto.ropeX * factor
3486
+ }),
3487
+ exportImage: async (options) => {
3488
+ const svgStr = serializeSvg(options.isShowDimension);
3489
+ const blob = new Blob([svgStr], {
3490
+ type: "image/svg+xml;charset=utf-8"
3491
+ });
3492
+ const url = URL.createObjectURL(blob);
3493
+ const img = new Image();
3494
+ await new Promise((resolve, reject) => {
3495
+ img.onload = () => resolve();
3496
+ img.onerror = reject;
3497
+ img.src = url;
3498
+ });
3499
+ const canvas = document.createElement("canvas");
3500
+ if (options.originalSize) {
3501
+ canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM5);
3502
+ canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM5);
3503
+ } else {
3504
+ canvas.width = 1920;
3505
+ canvas.height = 1080;
3506
+ }
3507
+ const ctx = canvas.getContext("2d");
3508
+ ctx.fillStyle = "#ffffff";
3509
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
3510
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
3511
+ URL.revokeObjectURL(url);
3512
+ return new Promise((resolve, reject) => {
3513
+ canvas.toBlob(
3514
+ (b) => b ? resolve(b) : reject(new Error("Export failed")),
3515
+ "image/png"
3516
+ );
3517
+ });
3518
+ },
3519
+ exportDimension: async () => {
3520
+ const dimData = generateDimensions5(attributes, unit);
3521
+ return exportDimensionPdf({
3522
+ modelId: MODEL_ID5,
3523
+ dieline,
3524
+ dimensions: dimData,
3525
+ attributes,
3526
+ unit,
3527
+ factor,
3528
+ theme
3529
+ });
3530
+ }
3531
+ };
3532
+ },
3533
+ [attributes, dieline, factor, unit, serializeSvg, theme]
3534
+ );
3535
+ const padding = isShowDimensions ? 15 : 0;
3536
+ const vbX = -padding;
3537
+ const vbY = -padding;
3538
+ const vbW = dieline.viewBox.width + padding * 2;
3539
+ const vbH = dieline.viewBox.height + padding * 2;
3540
+ const svgChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3541
+ /* @__PURE__ */ jsxRuntime.jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
3542
+ /* @__PURE__ */ jsxRuntime.jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
3543
+ isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension5(d, i, getFontDimensionSize())) })
3544
+ ] });
3545
+ if (renderAs === "group") {
3546
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { children: svgChildren });
3547
+ }
3548
+ return /* @__PURE__ */ jsxRuntime.jsx(
3549
+ "svg",
3550
+ {
3551
+ ref: svgRef,
3552
+ xmlns: "http://www.w3.org/2000/svg",
3553
+ viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
3554
+ preserveAspectRatio: "xMidYMid meet",
3555
+ style: { backgroundColor: theme.colorBackground },
3556
+ children: svgChildren
3557
+ }
3558
+ );
3559
+ }
3560
+ );
3561
+ var CANVAS_BECF_12101 = react.forwardRef(
3562
+ (props, ref) => {
3563
+ const dieLineRef = react.useRef(null);
3564
+ const canvasRef = react.useRef(null);
3565
+ const {
3566
+ attributes
3567
+ } = props;
3568
+ const theme = react.useMemo(
3569
+ () => getModelTheme(),
3570
+ []
3571
+ );
3572
+ const dieline = react.useMemo(() => generateBecf12101(attributes), [attributes]);
3573
+ const stablePadding = 15;
3574
+ const viewBox = react.useMemo(
3575
+ () => ({
3576
+ x: -stablePadding,
3577
+ y: -stablePadding,
3578
+ width: dieline.viewBox.width + stablePadding * 2,
3579
+ height: dieline.viewBox.height + stablePadding * 2
3580
+ }),
3581
+ [dieline.viewBox.width, dieline.viewBox.height]
3582
+ );
3583
+ const serializeCanvasSvg = react.useCallback((showDimensions) => {
3584
+ const svg = canvasRef.current?.getSvgElement();
3585
+ if (!svg) throw new Error("SVG not mounted");
3586
+ const clone = svg.cloneNode(true);
3587
+ if (!showDimensions) {
3588
+ const dimGroup = clone.querySelector("#dimensions");
3589
+ dimGroup?.remove();
3590
+ }
3591
+ return new XMLSerializer().serializeToString(clone);
3592
+ }, []);
3593
+ react.useImperativeHandle(ref, () => ({
3594
+ getAttributes: () => dieLineRef.current.getAttributes(),
3595
+ exportImage: async (options) => {
3596
+ const svgStr = serializeCanvasSvg(options.isShowDimension);
3597
+ const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
3598
+ const url = URL.createObjectURL(blob);
3599
+ const img = new Image();
3600
+ await new Promise((resolve, reject) => {
3601
+ img.onload = () => resolve();
3602
+ img.onerror = reject;
3603
+ img.src = url;
3604
+ });
3605
+ const canvas = document.createElement("canvas");
3606
+ if (options.originalSize) {
3607
+ canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM5);
3608
+ canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM5);
3609
+ } else {
3610
+ canvas.width = 1920;
3611
+ canvas.height = 1080;
3612
+ }
3613
+ const ctx = canvas.getContext("2d");
3614
+ ctx.fillStyle = "#ffffff";
3615
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
3616
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
3617
+ URL.revokeObjectURL(url);
3618
+ return new Promise((resolve, reject) => {
3619
+ canvas.toBlob(
3620
+ (b) => b ? resolve(b) : reject(new Error("Export failed")),
3621
+ "image/png"
3622
+ );
3623
+ });
3624
+ },
3625
+ exportDimension: () => dieLineRef.current.exportDimension(),
3626
+ resetView: () => canvasRef.current?.resetView(),
3627
+ fitView: () => canvasRef.current?.fitView()
3628
+ }), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
3629
+ return /* @__PURE__ */ jsxRuntime.jsx(
3630
+ BaseCanvas,
3631
+ {
3632
+ ref: canvasRef,
3633
+ viewBox,
3634
+ backgroundColor: theme.colorBackground,
3635
+ children: /* @__PURE__ */ jsxRuntime.jsx(DIE_LINE_BECF_12101, { ref: dieLineRef, ...props, renderAs: "group" })
3636
+ }
3637
+ );
3638
+ }
3639
+ );
3640
+ var MODEL_BECF_12101 = react.forwardRef(
3641
+ ({ mode = "DIE_LINE", ...props }, ref) => {
3642
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (() => {
3643
+ switch (mode) {
3644
+ case "DIE_LINE":
3645
+ return /* @__PURE__ */ jsxRuntime.jsx(CANVAS_BECF_12101, { ref, ...props });
3646
+ case "3D":
3647
+ return null;
3648
+ case "AUTO_LAYOUT":
3649
+ return /* @__PURE__ */ jsxRuntime.jsx(DIE_LINE_BECF_12101, { ref, ...props });
3650
+ default:
3651
+ return null;
3652
+ }
3653
+ })() });
3654
+ }
3655
+ );
3656
+
3657
+ // src/components/dieline/bags-pillows/becf-12109/generate.ts
3658
+ var DIP2 = 13;
3659
+ var ROPE_R2 = 3;
3660
+ var ROPE_Y2 = 20;
3661
+ var D_MAX2 = 40;
3662
+ var NOTCH_X = 3;
3663
+ var NOTCH_Y = 5;
3664
+ function calcD2(c, b) {
3665
+ return Math.min(c - 2 - b / 2, D_MAX2);
3666
+ }
3667
+ function calcKulak2(b) {
3668
+ if (b <= 13) return b - 1;
3669
+ if (b <= 99) return 13;
3670
+ if (b <= 249) return 20;
3671
+ if (b <= 499) return 25;
3672
+ return 30;
3673
+ }
3674
+ function calcX2(a) {
3675
+ return a / 2;
3676
+ }
3677
+ function getAutoCalcValues2(attr) {
3678
+ const { length: A, width: B, height: C, glueArea } = attr;
3679
+ const D = calcD2(C, B);
3680
+ const kulak = glueArea ?? calcKulak2(B);
3681
+ const X = calcX2(A);
3682
+ return { d: D, kulak, dip: DIP2, ropeR: ROPE_R2, ropeY: ROPE_Y2, ropeX: X };
3683
+ }
3684
+ function line6(x1, y1, x2, y2) {
3685
+ return `M${x1} ${y1} L${x2} ${y2}`;
3686
+ }
3687
+ function circlePath2(cx, cy, r) {
3688
+ return `M${cx - r} ${cy} A${r} ${r} 0 0 1 ${cx + r} ${cy} A${r} ${r} 0 0 1 ${cx - r} ${cy}`;
3689
+ }
3690
+ function generateBecf12109(attr) {
3691
+ const { length: A, width: B, height: C, glueArea } = attr;
3692
+ const D = calcD2(C, B);
3693
+ const kulak = glueArea ?? calcKulak2(B);
3694
+ const X = calcX2(A);
3695
+ const xFront = kulak;
3696
+ const xSide1 = kulak + A;
3697
+ const xSide1Mid = kulak + A + B / 2;
3698
+ const xBack = kulak + A + B;
3699
+ const xSide2 = kulak + 2 * A + B;
3700
+ const xSide2Mid = kulak + 2 * A + B + B / 2;
3701
+ const xEnd = kulak + 2 * A + 2 * B - 2;
3702
+ const yFoldTop = D;
3703
+ const yFoldBottomStart = D + C - B / 2;
3704
+ const yFoldBottom = D + C;
3705
+ const yNotchStart = yFoldBottom + NOTCH_Y;
3706
+ const yEnd = D + C + B / 2 + DIP2;
3707
+ const totalWidth = xEnd;
3708
+ const totalHeight = yEnd;
3709
+ const cut = [];
3710
+ const crease = [];
3711
+ cut.push(line6(0, 0, 0, yFoldBottom - kulak));
3712
+ cut.push(line6(0, 0, totalWidth, 0));
3713
+ cut.push(line6(totalWidth, 0, totalWidth, yFoldBottom));
3714
+ cut.push(line6(0, yFoldBottom - kulak, kulak, yFoldBottom));
3715
+ const boundaries = [xFront, xSide1, xBack, xSide2, xEnd];
3716
+ for (let i = 0; i < boundaries.length; i++) {
3717
+ const xb = boundaries[i];
3718
+ const isFirst = i === 0;
3719
+ const isLast = i === boundaries.length - 1;
3720
+ if (!isFirst) {
3721
+ cut.push(line6(xb - NOTCH_X, yNotchStart, xb - NOTCH_X, totalHeight));
3722
+ cut.push(line6(xb - NOTCH_X, yNotchStart, xb, yFoldBottom));
3723
+ }
3724
+ if (!isLast) {
3725
+ cut.push(line6(xb + NOTCH_X, yNotchStart, xb + NOTCH_X, totalHeight));
3726
+ cut.push(line6(xb + NOTCH_X, yNotchStart, xb, yFoldBottom));
3727
+ }
3728
+ }
3729
+ cut.push(line6(xFront + NOTCH_X, totalHeight, xSide1 - NOTCH_X, totalHeight));
3730
+ cut.push(line6(xSide1 + NOTCH_X, totalHeight, xBack - NOTCH_X, totalHeight));
3731
+ cut.push(line6(xBack + NOTCH_X, totalHeight, xSide2 - NOTCH_X, totalHeight));
3732
+ cut.push(line6(xSide2 + NOTCH_X, totalHeight, xEnd - NOTCH_X, totalHeight));
3733
+ const frontCx = kulak + A / 2;
3734
+ const backCx = kulak + A + B + A / 2;
3735
+ const ropeTopY = yFoldTop - ROPE_Y2;
3736
+ const ropeBotY = yFoldTop + ROPE_Y2;
3737
+ cut.push(circlePath2(frontCx - X / 2, ropeTopY, ROPE_R2));
3738
+ cut.push(circlePath2(frontCx - X / 2, ropeBotY, ROPE_R2));
3739
+ cut.push(circlePath2(frontCx + X / 2, ropeTopY, ROPE_R2));
3740
+ cut.push(circlePath2(frontCx + X / 2, ropeBotY, ROPE_R2));
3741
+ cut.push(circlePath2(backCx - X / 2, ropeTopY, ROPE_R2));
3742
+ cut.push(circlePath2(backCx - X / 2, ropeBotY, ROPE_R2));
3743
+ cut.push(circlePath2(backCx + X / 2, ropeTopY, ROPE_R2));
3744
+ cut.push(circlePath2(backCx + X / 2, ropeBotY, ROPE_R2));
3745
+ crease.push(line6(0, yFoldTop, totalWidth, yFoldTop));
3746
+ crease.push(line6(0, yFoldBottomStart, totalWidth, yFoldBottomStart));
3747
+ crease.push(line6(kulak, yFoldBottom, xEnd, yFoldBottom));
3748
+ crease.push(line6(xFront, 0, xFront, yFoldBottom));
3749
+ crease.push(line6(xSide1, 0, xSide1, yFoldBottom));
3750
+ crease.push(line6(xBack, 0, xBack, yFoldBottom));
3751
+ crease.push(line6(xSide2, 0, xSide2, yFoldBottom));
3752
+ crease.push(line6(xSide1Mid, 0, xSide1Mid, totalHeight));
3753
+ crease.push(line6(xSide2Mid, 0, xSide2Mid, totalHeight));
3754
+ crease.push(line6(xBack, yFoldBottom, xSide1Mid, yFoldBottomStart));
3755
+ crease.push(line6(xSide1Mid, yFoldBottomStart, xSide1, yFoldBottom));
3756
+ crease.push(line6(xSide2Mid, yFoldBottomStart, xSide2, yFoldBottom));
3757
+ crease.push(line6(xSide2Mid, yFoldBottomStart, xEnd, D + C - 2));
3758
+ return { cut, crease, viewBox: { width: totalWidth, height: totalHeight } };
3759
+ }
3760
+ function generateOuterContour6(attr) {
3761
+ const { length: A, width: B, height: C, glueArea } = attr;
3762
+ const D = calcD2(C, B);
3763
+ const kulak = glueArea ?? calcKulak2(B);
3764
+ const totalWidth = kulak + 2 * A + 2 * B - 2;
3765
+ const totalHeight = D + C + B / 2 + DIP2;
3766
+ return [
3767
+ { x: 0, y: 0 },
3768
+ { x: totalWidth, y: 0 },
3769
+ { x: totalWidth, y: totalHeight },
3770
+ { x: 0, y: totalHeight }
3771
+ ];
3772
+ }
3773
+ function offsetContour6(points, distance) {
3774
+ const n = points.length;
3775
+ const result = [];
3776
+ for (let i = 0; i < n; i++) {
3777
+ const prev = points[(i - 1 + n) % n];
3778
+ const curr = points[i];
3779
+ const next = points[(i + 1) % n];
3780
+ const e1x = curr.x - prev.x;
3781
+ const e1y = curr.y - prev.y;
3782
+ const e2x = next.x - curr.x;
3783
+ const e2y = next.y - curr.y;
3784
+ const len1 = Math.sqrt(e1x * e1x + e1y * e1y);
3785
+ const len2 = Math.sqrt(e2x * e2x + e2y * e2y);
3786
+ if (len1 === 0 || len2 === 0) {
3787
+ result.push(curr);
3788
+ continue;
3789
+ }
3790
+ const n1x = e1y / len1;
3791
+ const n1y = -e1x / len1;
3792
+ const n2x = e2y / len2;
3793
+ const n2y = -e2x / len2;
3794
+ const ax = n1x + n2x;
3795
+ const ay = n1y + n2y;
3796
+ const aLen = Math.sqrt(ax * ax + ay * ay);
3797
+ if (aLen < 1e-3) {
3798
+ result.push({ x: curr.x + n1x * distance, y: curr.y + n1y * distance });
3799
+ continue;
3800
+ }
3801
+ const nx = ax / aLen;
3802
+ const ny = ay / aLen;
3803
+ const dot = n1x * nx + n1y * ny;
3804
+ const d = distance / Math.max(dot, 0.1);
3805
+ result.push({ x: curr.x + nx * d, y: curr.y + ny * d });
3806
+ }
3807
+ return result;
3808
+ }
3809
+ function contourToPath6(points) {
3810
+ if (points.length === 0) return "";
3811
+ let d = `M${points[0].x} ${points[0].y}`;
3812
+ for (let i = 1; i < points.length; i++) {
3813
+ d += ` L${points[i].x} ${points[i].y}`;
3814
+ }
3815
+ d += " Z";
3816
+ return d;
3817
+ }
3818
+ function generateDimensions6(attr, unit) {
3819
+ const { length: A, width: B, height: C, glueArea } = attr;
3820
+ const D = calcD2(C, B);
3821
+ const kulak = glueArea ?? calcKulak2(B);
3822
+ const factor = unit === "cm" ? 0.1 : unit === "in" ? 1 / 25.4 : 1;
3823
+ const suffix = unit;
3824
+ const fmt = (v) => `${(v * factor).toFixed(2)} ${suffix}`;
3825
+ const xFront = kulak;
3826
+ const xSide1 = kulak + A;
3827
+ const xBack = kulak + A + B;
3828
+ const yFoldTop = D;
3829
+ const yFoldBottom = D + C;
3830
+ const yEnd = D + C + B / 2 + DIP2;
3831
+ const totalWidth = kulak + 2 * A + 2 * B - 2;
3832
+ const totalHeight = yEnd;
3833
+ const bottomSection = B / 2 + DIP2;
3834
+ return [
3835
+ // Overall dimensions (outside)
3836
+ {
3837
+ x1: 0,
3838
+ y1: 0,
3839
+ x2: totalWidth,
3840
+ y2: 0,
3841
+ label: `Overall Width : ${fmt(totalWidth)}`,
3842
+ orientation: "horizontal",
3843
+ offset: -12
3844
+ },
3845
+ {
3846
+ x1: 0,
3847
+ y1: 0,
3848
+ x2: 0,
3849
+ y2: totalHeight,
3850
+ label: `Overall Height : ${fmt(totalHeight)}`,
3851
+ orientation: "vertical",
3852
+ offset: -12
3853
+ },
3854
+ // Height (C) — body area (centered on back panel)
3855
+ {
3856
+ x1: xBack + A * 0.6,
3857
+ y1: yFoldTop,
3858
+ x2: xBack + A * 0.6,
3859
+ y2: yFoldBottom,
3860
+ label: fmt(C),
3861
+ orientation: "vertical",
3862
+ offset: -10
3863
+ },
3864
+ // Top flap (D) (centered on back panel)
3865
+ {
3866
+ x1: xBack + A * 0.6,
3867
+ y1: 0,
3868
+ x2: xBack + A * 0.6,
3869
+ y2: yFoldTop,
3870
+ label: fmt(D),
3871
+ orientation: "vertical",
3872
+ offset: -10
3873
+ },
3874
+ // Bottom section (B/2 + _dip) (centered on back panel)
3875
+ {
3876
+ x1: xBack + A * 0.6,
3877
+ y1: yFoldBottom,
3878
+ x2: xBack + A * 0.6,
3879
+ y2: yEnd,
3880
+ label: fmt(bottomSection),
3881
+ orientation: "vertical",
3882
+ offset: -10
3883
+ },
3884
+ // Length (A) — front panel (centered vertically on body)
3885
+ {
3886
+ x1: xFront,
3887
+ y1: yFoldTop + C * 0.65,
3888
+ x2: xSide1,
3889
+ y2: yFoldTop + C * 0.65,
3890
+ label: fmt(A),
3891
+ orientation: "horizontal",
3892
+ offset: -20
3893
+ },
3894
+ // Width (B) — side panel (centered vertically on body)
3895
+ {
3896
+ x1: xSide1,
3897
+ y1: yFoldTop + C * 0.65,
3898
+ x2: xBack,
3899
+ y2: yFoldTop + C * 0.65,
3900
+ label: fmt(B),
3901
+ orientation: "horizontal",
3902
+ offset: -20
3903
+ },
3904
+ // Glue Area (kulak) — left glue flap width
3905
+ {
3906
+ x1: 0,
3907
+ y1: yFoldTop + C * 0.65,
3908
+ x2: xFront,
3909
+ y2: yFoldTop + C * 0.65,
3910
+ label: fmt(kulak),
3911
+ orientation: "horizontal",
3912
+ offset: -20
3913
+ }
3914
+ ];
3915
+ }
3916
+ var MODEL_ID6 = "BECF-12109";
3917
+ var UNIT_FACTOR6 = {
3918
+ mm: 1,
3919
+ cm: 0.1,
3920
+ in: 1 / 25.4
3921
+ };
3922
+ var PX_PER_MM6 = 96 / 25.4;
3923
+ function renderDimension6(dim, i, fs) {
3924
+ const { x1, y1, x2, y2, label, orientation, offset } = dim;
3925
+ const tick = 1.5;
3926
+ if (orientation === "horizontal") {
3927
+ const y = y1 + offset;
3928
+ const midX = (x1 + x2) / 2;
3929
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3930
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1, y1: y, x2, y2: y, stroke: "#000", strokeWidth: 0.2 }),
3931
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1, y1: y - tick, x2: x1, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
3932
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x2, y1: y - tick, x2, y2: y + tick, stroke: "#000", strokeWidth: 0.3 }),
3933
+ /* @__PURE__ */ jsxRuntime.jsx(
3934
+ "text",
3935
+ {
3936
+ x: midX,
3937
+ y: y - 1.5,
3938
+ textAnchor: "middle",
3939
+ fontSize: fs,
3940
+ fontFamily: "sans-serif",
3941
+ fill: "#000",
3942
+ children: label
3943
+ }
3944
+ )
3945
+ ] }, `dim-${i}`);
3946
+ }
3947
+ const x = x1 + offset;
3948
+ const midY = (y1 + y2) / 2;
3949
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3950
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x, y1, x2: x, y2, stroke: "#000", strokeWidth: 0.2 }),
3951
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x - tick, y1, x2: x + tick, y2: y1, stroke: "#000", strokeWidth: 0.3 }),
3952
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: x - tick, y1: y2, x2: x + tick, y2, stroke: "#000", strokeWidth: 0.3 }),
3953
+ /* @__PURE__ */ jsxRuntime.jsx(
3954
+ "text",
3955
+ {
3956
+ x: x - 1.5,
3957
+ y: midY - 1,
3958
+ textAnchor: "middle",
3959
+ dominantBaseline: "central",
3960
+ fontSize: fs,
3961
+ fontFamily: "sans-serif",
3962
+ fill: "#000",
3963
+ transform: `rotate(-90, ${x - 1.5}, ${midY})`,
3964
+ children: label
3965
+ }
3966
+ )
3967
+ ] }, `dim-${i}`);
3968
+ }
3969
+ var DIE_LINE_BECF_12109 = react.forwardRef(
3970
+ ({
3971
+ attributes,
3972
+ unit = "mm",
3973
+ isShowDimensions = false,
3974
+ renderAs = "svg"
3975
+ }, ref) => {
3976
+ const theme = react.useMemo(
3977
+ () => getModelTheme(),
3978
+ []
3979
+ );
3980
+ const svgRef = react.useRef(null);
3981
+ const dieline = react.useMemo(() => generateBecf12109(attributes), [attributes]);
3982
+ const dimensions = react.useMemo(
3983
+ () => generateDimensions6(attributes, unit),
3984
+ [attributes, unit]
3985
+ );
3986
+ const factor = UNIT_FACTOR6[unit] ?? 1;
3987
+ const serializeSvg = react.useCallback(
3988
+ (showDimensions) => {
3989
+ const svg = svgRef.current;
3990
+ if (!svg) throw new Error("SVG not mounted");
3991
+ const clone = svg.cloneNode(true);
3992
+ if (!showDimensions) {
3993
+ const dimGroup = clone.querySelector("#dimensions");
3994
+ dimGroup?.remove();
3995
+ }
3996
+ return new XMLSerializer().serializeToString(clone);
3997
+ },
3998
+ []
3999
+ );
4000
+ react.useImperativeHandle(
4001
+ ref,
4002
+ () => {
4003
+ const auto = getAutoCalcValues2(attributes);
4004
+ return {
4005
+ getAttributes: () => ({
4006
+ modelId: MODEL_ID6,
4007
+ overallWidth: dieline.viewBox.width * factor,
4008
+ overallHeight: dieline.viewBox.height * factor,
4009
+ length: attributes.length * factor,
4010
+ width: attributes.width * factor,
4011
+ height: attributes.height * factor,
4012
+ glueArea: auto.kulak * factor,
4013
+ d: auto.d * factor,
4014
+ kulak: auto.kulak * factor,
4015
+ dip: auto.dip * factor,
4016
+ ropeR: auto.ropeR * factor,
4017
+ ropeY: auto.ropeY * factor,
4018
+ ropeX: auto.ropeX * factor
4019
+ }),
4020
+ exportImage: async (options) => {
4021
+ const svgStr = serializeSvg(options.isShowDimension);
4022
+ const blob = new Blob([svgStr], {
4023
+ type: "image/svg+xml;charset=utf-8"
4024
+ });
4025
+ const url = URL.createObjectURL(blob);
4026
+ const img = new Image();
4027
+ await new Promise((resolve, reject) => {
4028
+ img.onload = () => resolve();
4029
+ img.onerror = reject;
4030
+ img.src = url;
4031
+ });
4032
+ const canvas = document.createElement("canvas");
4033
+ if (options.originalSize) {
4034
+ canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
4035
+ canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
4036
+ } else {
4037
+ canvas.width = 1920;
4038
+ canvas.height = 1080;
4039
+ }
4040
+ const ctx = canvas.getContext("2d");
4041
+ ctx.fillStyle = "#ffffff";
4042
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
4043
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
4044
+ URL.revokeObjectURL(url);
4045
+ return new Promise((resolve, reject) => {
4046
+ canvas.toBlob(
4047
+ (b) => b ? resolve(b) : reject(new Error("Export failed")),
4048
+ "image/png"
4049
+ );
4050
+ });
4051
+ },
4052
+ exportDimension: async () => {
4053
+ const dimData = generateDimensions6(attributes, unit);
4054
+ return exportDimensionPdf({
4055
+ modelId: MODEL_ID6,
4056
+ dieline,
4057
+ dimensions: dimData,
4058
+ attributes,
4059
+ unit,
4060
+ factor,
4061
+ theme
4062
+ });
4063
+ }
4064
+ };
4065
+ },
4066
+ [attributes, dieline, factor, unit, serializeSvg, theme]
4067
+ );
4068
+ const padding = isShowDimensions ? 15 : 0;
4069
+ const vbX = -padding;
4070
+ const vbY = -padding;
4071
+ const vbW = dieline.viewBox.width + padding * 2;
4072
+ const vbH = dieline.viewBox.height + padding * 2;
4073
+ const svgChildren = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4074
+ /* @__PURE__ */ jsxRuntime.jsx("g", { id: "crease", children: dieline.crease.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorFoldLine, strokeWidth: 0.5, strokeDasharray: "2,1" }, `c-${i}`)) }),
4075
+ /* @__PURE__ */ jsxRuntime.jsx("g", { id: "cut", children: dieline.cut.map((d, i) => /* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: theme.colorDieLine, strokeWidth: 0.5 }, `t-${i}`)) }),
4076
+ isShowDimensions && /* @__PURE__ */ jsxRuntime.jsx("g", { id: "dimensions", children: dimensions.map((d, i) => renderDimension6(d, i, getFontDimensionSize())) })
4077
+ ] });
4078
+ if (renderAs === "group") {
4079
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { children: svgChildren });
4080
+ }
4081
+ return /* @__PURE__ */ jsxRuntime.jsx(
4082
+ "svg",
4083
+ {
4084
+ ref: svgRef,
4085
+ xmlns: "http://www.w3.org/2000/svg",
4086
+ viewBox: `${vbX} ${vbY} ${vbW} ${vbH}`,
4087
+ preserveAspectRatio: "xMidYMid meet",
4088
+ style: { backgroundColor: theme.colorBackground },
4089
+ children: svgChildren
4090
+ }
4091
+ );
4092
+ }
4093
+ );
4094
+ var CANVAS_BECF_12109 = react.forwardRef(
4095
+ (props, ref) => {
4096
+ const dieLineRef = react.useRef(null);
4097
+ const canvasRef = react.useRef(null);
4098
+ const {
4099
+ attributes
4100
+ } = props;
4101
+ const theme = react.useMemo(
4102
+ () => getModelTheme(),
4103
+ []
4104
+ );
4105
+ const dieline = react.useMemo(() => generateBecf12109(attributes), [attributes]);
4106
+ const stablePadding = 15;
4107
+ const viewBox = react.useMemo(
4108
+ () => ({
4109
+ x: -stablePadding,
4110
+ y: -stablePadding,
4111
+ width: dieline.viewBox.width + stablePadding * 2,
4112
+ height: dieline.viewBox.height + stablePadding * 2
4113
+ }),
4114
+ [dieline.viewBox.width, dieline.viewBox.height]
4115
+ );
4116
+ const serializeCanvasSvg = react.useCallback((showDimensions) => {
4117
+ const svg = canvasRef.current?.getSvgElement();
4118
+ if (!svg) throw new Error("SVG not mounted");
4119
+ const clone = svg.cloneNode(true);
4120
+ if (!showDimensions) {
4121
+ const dimGroup = clone.querySelector("#dimensions");
4122
+ dimGroup?.remove();
4123
+ }
4124
+ return new XMLSerializer().serializeToString(clone);
4125
+ }, []);
4126
+ react.useImperativeHandle(ref, () => ({
4127
+ getAttributes: () => dieLineRef.current.getAttributes(),
4128
+ exportImage: async (options) => {
4129
+ const svgStr = serializeCanvasSvg(options.isShowDimension);
4130
+ const blob = new Blob([svgStr], { type: "image/svg+xml;charset=utf-8" });
4131
+ const url = URL.createObjectURL(blob);
4132
+ const img = new Image();
4133
+ await new Promise((resolve, reject) => {
4134
+ img.onload = () => resolve();
4135
+ img.onerror = reject;
4136
+ img.src = url;
4137
+ });
4138
+ const canvas = document.createElement("canvas");
4139
+ if (options.originalSize) {
4140
+ canvas.width = Math.round(dieline.viewBox.width * PX_PER_MM6);
4141
+ canvas.height = Math.round(dieline.viewBox.height * PX_PER_MM6);
4142
+ } else {
4143
+ canvas.width = 1920;
4144
+ canvas.height = 1080;
4145
+ }
4146
+ const ctx = canvas.getContext("2d");
4147
+ ctx.fillStyle = "#ffffff";
4148
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
4149
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
4150
+ URL.revokeObjectURL(url);
4151
+ return new Promise((resolve, reject) => {
4152
+ canvas.toBlob(
4153
+ (b) => b ? resolve(b) : reject(new Error("Export failed")),
4154
+ "image/png"
4155
+ );
4156
+ });
4157
+ },
4158
+ exportDimension: () => dieLineRef.current.exportDimension(),
4159
+ resetView: () => canvasRef.current?.resetView(),
4160
+ fitView: () => canvasRef.current?.fitView()
4161
+ }), [serializeCanvasSvg, dieline.viewBox.width, dieline.viewBox.height]);
4162
+ return /* @__PURE__ */ jsxRuntime.jsx(
4163
+ BaseCanvas,
4164
+ {
4165
+ ref: canvasRef,
4166
+ viewBox,
4167
+ backgroundColor: theme.colorBackground,
4168
+ children: /* @__PURE__ */ jsxRuntime.jsx(DIE_LINE_BECF_12109, { ref: dieLineRef, ...props, renderAs: "group" })
4169
+ }
4170
+ );
4171
+ }
4172
+ );
4173
+ var MODEL_BECF_12109 = react.forwardRef(
4174
+ ({ mode = "DIE_LINE", ...props }, ref) => {
4175
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (() => {
4176
+ switch (mode) {
4177
+ case "DIE_LINE":
4178
+ return /* @__PURE__ */ jsxRuntime.jsx(CANVAS_BECF_12109, { ref, ...props });
4179
+ case "3D":
4180
+ return null;
4181
+ case "AUTO_LAYOUT":
4182
+ return /* @__PURE__ */ jsxRuntime.jsx(DIE_LINE_BECF_12109, { ref, ...props });
4183
+ default:
4184
+ return null;
4185
+ }
4186
+ })() });
4187
+ }
4188
+ );
4189
+
4190
+ // src/utils/autoLayout/rasterize.ts
4191
+ function rasterizePolygon(points, resolution) {
4192
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
4193
+ for (const p of points) {
4194
+ if (p.x < minX) minX = p.x;
4195
+ if (p.y < minY) minY = p.y;
4196
+ if (p.x > maxX) maxX = p.x;
4197
+ if (p.y > maxY) maxY = p.y;
4198
+ }
4199
+ const offsetX = Math.floor(minX / resolution);
4200
+ const offsetY = Math.floor(minY / resolution);
4201
+ const w = Math.ceil((maxX - offsetX * resolution) / resolution) + 1;
4202
+ const h = Math.ceil((maxY - offsetY * resolution) / resolution) + 1;
4203
+ const data = new Uint8Array(w * h);
4204
+ for (let gy = 0; gy < h; gy++) {
4205
+ const worldY = (offsetY + gy) * resolution + resolution / 2;
4206
+ const crossings = [];
4207
+ for (let i = 0, j = points.length - 1; i < points.length; j = i++) {
4208
+ const yi = points[i].y, yj = points[j].y;
4209
+ if (yi <= worldY && yj > worldY || yj <= worldY && yi > worldY) {
4210
+ const t = (worldY - yi) / (yj - yi);
4211
+ crossings.push(points[i].x + t * (points[j].x - points[i].x));
4212
+ }
4213
+ }
4214
+ crossings.sort((a, b) => a - b);
4215
+ for (let c = 0; c < crossings.length - 1; c += 2) {
4216
+ const startGx = Math.max(0, Math.floor((crossings[c] - offsetX * resolution) / resolution));
4217
+ const endGx = Math.min(w - 1, Math.ceil((crossings[c + 1] - offsetX * resolution) / resolution));
4218
+ for (let gx = startGx; gx <= endGx; gx++) {
4219
+ data[gy * w + gx] = 1;
4220
+ }
4221
+ }
4222
+ }
4223
+ return { data, width: w, height: h, offsetX, offsetY };
4224
+ }
4225
+ function canPlace(paperGrid, paperW, paperH, piece, px, py) {
4226
+ for (let y = 0; y < piece.height; y++) {
4227
+ const paperY = py + y;
4228
+ if (paperY < 0 || paperY >= paperH) {
4229
+ for (let x = 0; x < piece.width; x++) {
4230
+ if (piece.data[y * piece.width + x]) return false;
4231
+ }
4232
+ continue;
4233
+ }
4234
+ for (let x = 0; x < piece.width; x++) {
4235
+ if (!piece.data[y * piece.width + x]) continue;
4236
+ const paperX = px + x;
4237
+ if (paperX < 0 || paperX >= paperW) return false;
4238
+ if (paperGrid[paperY * paperW + paperX]) return false;
4239
+ }
4240
+ }
4241
+ return true;
4242
+ }
4243
+ function placePiece(paperGrid, paperW, piece, px, py) {
4244
+ for (let y = 0; y < piece.height; y++) {
4245
+ for (let x = 0; x < piece.width; x++) {
4246
+ if (piece.data[y * piece.width + x]) {
4247
+ paperGrid[(py + y) * paperW + (px + x)] = 1;
4248
+ }
4249
+ }
4250
+ }
4251
+ }
4252
+
4253
+ // src/utils/autoLayout/calculate/shared.ts
4254
+ var RESOLUTION = 1;
4255
+ function resolveGripperSide(paperWidth, paperHeight) {
4256
+ if (paperWidth >= paperHeight) return "bottom";
4257
+ return "left";
4258
+ }
4259
+ function computeUsableBounds(paperWidth, paperHeight, gripperSide, spacing, griper, colorbarDepth) {
4260
+ switch (gripperSide) {
4261
+ case "bottom":
4262
+ return {
4263
+ top: colorbarDepth + spacing,
4264
+ bottom: paperHeight - griper,
4265
+ left: spacing,
4266
+ right: paperWidth - spacing
4267
+ };
4268
+ case "top":
4269
+ return {
4270
+ top: griper,
4271
+ bottom: paperHeight - colorbarDepth - spacing,
4272
+ left: spacing,
4273
+ right: paperWidth - spacing
4274
+ };
4275
+ case "left":
4276
+ return {
4277
+ top: spacing,
4278
+ bottom: paperHeight - spacing,
4279
+ left: griper,
4280
+ right: paperWidth - colorbarDepth - spacing
4281
+ };
4282
+ case "right":
4283
+ return {
4284
+ top: spacing,
4285
+ bottom: paperHeight - spacing,
4286
+ left: colorbarDepth + spacing,
4287
+ right: paperWidth - griper
4288
+ };
4289
+ }
4290
+ }
4291
+ function normalizePoints(points, degrees) {
4292
+ const rad = degrees * Math.PI / 180;
4293
+ const cos = Math.cos(rad);
4294
+ const sin = Math.sin(rad);
4295
+ const rotated = points.map((p) => ({
4296
+ x: p.x * cos - p.y * sin,
4297
+ y: p.x * sin + p.y * cos
4298
+ }));
4299
+ let minX = Infinity, minY = Infinity;
4300
+ for (const p of rotated) {
4301
+ if (p.x < minX) minX = p.x;
4302
+ if (p.y < minY) minY = p.y;
4303
+ }
4304
+ return rotated.map((p) => ({ x: p.x - minX, y: p.y - minY }));
4305
+ }
4306
+ function computeDielineBBOffset(offsetContourPoints, dielineW, dielineH, degrees) {
4307
+ const rad = degrees * Math.PI / 180;
4308
+ const cos = Math.cos(rad);
4309
+ const sin = Math.sin(rad);
4310
+ let ocMinX = Infinity, ocMinY = Infinity;
4311
+ for (const p of offsetContourPoints) {
4312
+ const rx = p.x * cos - p.y * sin;
3258
4313
  const ry = p.x * sin + p.y * cos;
3259
4314
  if (rx < ocMinX) ocMinX = rx;
3260
4315
  if (ry < ocMinY) ocMinY = ry;
3261
4316
  }
3262
- const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
3263
- let dlMinX = Infinity, dlMinY = Infinity;
3264
- for (const [cx, cy] of corners) {
3265
- const rx = cx * cos - cy * sin;
3266
- const ry = cx * sin + cy * cos;
3267
- if (rx < dlMinX) dlMinX = rx;
3268
- if (ry < dlMinY) dlMinY = ry;
4317
+ const corners = [[0, 0], [dielineW, 0], [0, dielineH], [dielineW, dielineH]];
4318
+ let dlMinX = Infinity, dlMinY = Infinity;
4319
+ for (const [cx, cy] of corners) {
4320
+ const rx = cx * cos - cy * sin;
4321
+ const ry = cx * sin + cy * cos;
4322
+ if (rx < dlMinX) dlMinX = rx;
4323
+ if (ry < dlMinY) dlMinY = ry;
4324
+ }
4325
+ return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
4326
+ }
4327
+ function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWidth, paperHeight, bounds) {
4328
+ const usableLeft = Math.ceil(bounds.left / RESOLUTION);
4329
+ const usableTop = Math.ceil(bounds.top / RESOLUTION);
4330
+ const usableRight = Math.floor(bounds.right / RESOLUTION);
4331
+ const usableBottom = Math.floor(bounds.bottom / RESOLUTION);
4332
+ const paperW = Math.floor(paperWidth / RESOLUTION);
4333
+ const paperH = Math.floor(paperHeight / RESOLUTION);
4334
+ let bestCandidate = { rotation: 0, placements: [], producedPerSheet: 0 };
4335
+ let bestGridPositions = [];
4336
+ let bestBitmapW = 0;
4337
+ let bestBitmapH = 0;
4338
+ for (const deg of [0, 90, 180, 270]) {
4339
+ const rotatedContour = normalizePoints(contourPoints, deg);
4340
+ const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
4341
+ const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
4342
+ const paperGrid = new Uint8Array(paperW * paperH);
4343
+ const placements = [];
4344
+ const gridPositions = [];
4345
+ for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
4346
+ for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
4347
+ if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
4348
+ placePiece(paperGrid, paperW, pieceBitmap, px, py);
4349
+ gridPositions.push({ px, py });
4350
+ placements.push({
4351
+ x: px * RESOLUTION + bbOffset.dx,
4352
+ y: py * RESOLUTION + bbOffset.dy,
4353
+ rotation: deg
4354
+ });
4355
+ }
4356
+ }
4357
+ }
4358
+ if (placements.length > bestCandidate.producedPerSheet) {
4359
+ bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
4360
+ bestGridPositions = gridPositions;
4361
+ bestBitmapW = pieceBitmap.width;
4362
+ bestBitmapH = pieceBitmap.height;
4363
+ }
4364
+ }
4365
+ if (bestCandidate.placements.length > 0) {
4366
+ let gridMinX = Infinity;
4367
+ let gridMinY = Infinity;
4368
+ let gridMaxX = -Infinity;
4369
+ let gridMaxY = -Infinity;
4370
+ for (const { px, py } of bestGridPositions) {
4371
+ if (px < gridMinX) gridMinX = px;
4372
+ if (py < gridMinY) gridMinY = py;
4373
+ if (px + bestBitmapW > gridMaxX) gridMaxX = px + bestBitmapW;
4374
+ if (py + bestBitmapH > gridMaxY) gridMaxY = py + bestBitmapH;
4375
+ }
4376
+ const groupW = gridMaxX - gridMinX;
4377
+ const groupH = gridMaxY - gridMinY;
4378
+ const usableW = usableRight - usableLeft;
4379
+ const usableH = usableBottom - usableTop;
4380
+ const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
4381
+ const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
4382
+ for (const p of bestCandidate.placements) {
4383
+ p.x += offsetX;
4384
+ p.y += offsetY;
4385
+ }
4386
+ }
4387
+ return bestCandidate;
4388
+ }
4389
+
4390
+ // src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
4391
+ var SAMPLE_STEP = 0.1;
4392
+ function buildProfile(points) {
4393
+ let maxX = 0, maxY = 0;
4394
+ for (const p of points) {
4395
+ if (p.x > maxX) maxX = p.x;
4396
+ if (p.y > maxY) maxY = p.y;
4397
+ }
4398
+ const width = maxX, height = maxY;
4399
+ const nY = Math.ceil(height / SAMPLE_STEP) + 1;
4400
+ const nX = Math.ceil(width / SAMPLE_STEP) + 1;
4401
+ const rightX = new Float64Array(nY).fill(-Infinity);
4402
+ const leftX = new Float64Array(nY).fill(Infinity);
4403
+ const bottomY = new Float64Array(nX).fill(-Infinity);
4404
+ const topY = new Float64Array(nX).fill(Infinity);
4405
+ const nPts = points.length;
4406
+ for (let iy = 0; iy < nY; iy++) {
4407
+ const y = iy * SAMPLE_STEP;
4408
+ for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
4409
+ const yj = points[j].y, yk = points[k].y;
4410
+ if (yj <= y && yk > y || yk <= y && yj > y) {
4411
+ const t = (y - yj) / (yk - yj);
4412
+ const x = points[j].x + t * (points[k].x - points[j].x);
4413
+ if (x > rightX[iy]) rightX[iy] = x;
4414
+ if (x < leftX[iy]) leftX[iy] = x;
4415
+ }
4416
+ }
4417
+ }
4418
+ for (let ix = 0; ix < nX; ix++) {
4419
+ const x = ix * SAMPLE_STEP;
4420
+ for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
4421
+ const xj = points[j].x, xk = points[k].x;
4422
+ if (xj <= x && xk > x || xk <= x && xj > x) {
4423
+ const t = (x - xj) / (xk - xj);
4424
+ const y = points[j].y + t * (points[k].y - points[j].y);
4425
+ if (y > bottomY[ix]) bottomY[ix] = y;
4426
+ if (y < topY[ix]) topY[ix] = y;
4427
+ }
4428
+ }
4429
+ }
4430
+ return { width, height, nY, nX, rightX, leftX, bottomY, topY };
4431
+ }
4432
+ function prepareRotation(contourPoints, dielineW, dielineH, deg) {
4433
+ const rotated = normalizePoints(contourPoints, deg);
4434
+ return {
4435
+ profile: buildProfile(rotated),
4436
+ bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
4437
+ deg
4438
+ };
4439
+ }
4440
+ function findMinStepX(a, b, dyMm) {
4441
+ const dySamples = Math.round(dyMm / SAMPLE_STEP);
4442
+ let maxOverlap = -Infinity;
4443
+ for (let ia = 0; ia < a.nY; ia++) {
4444
+ const ib = ia - dySamples;
4445
+ if (ib < 0 || ib >= b.nY) continue;
4446
+ if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
4447
+ const overlap = a.rightX[ia] - b.leftX[ib];
4448
+ if (overlap > maxOverlap) maxOverlap = overlap;
4449
+ }
4450
+ return maxOverlap <= -Infinity ? 0 : maxOverlap;
4451
+ }
4452
+ function findMinStepY(a, b, dxMm) {
4453
+ const dxSamples = Math.round(dxMm / SAMPLE_STEP);
4454
+ let maxOverlap = -Infinity;
4455
+ for (let ia = 0; ia < a.nX; ia++) {
4456
+ const ib = ia - dxSamples;
4457
+ if (ib < 0 || ib >= b.nX) continue;
4458
+ if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
4459
+ const overlap = a.bottomY[ia] - b.topY[ib];
4460
+ if (overlap > maxOverlap) maxOverlap = overlap;
4461
+ }
4462
+ return maxOverlap <= -Infinity ? 0 : maxOverlap;
4463
+ }
4464
+ function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
4465
+ const reach = Math.max(profA.width, profB.width);
4466
+ let maxStep = 0;
4467
+ const nMin = Math.floor((offsetX - reach) / stepX_A);
4468
+ const nMax = Math.ceil((offsetX + reach) / stepX_A);
4469
+ for (let n = nMin; n <= nMax; n++) {
4470
+ const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
4471
+ if (s > maxStep) maxStep = s;
4472
+ }
4473
+ return maxStep;
4474
+ }
4475
+ function emptyResult() {
4476
+ return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
4477
+ }
4478
+ function singleRotGrid(rd, bounds) {
4479
+ const p = rd.profile;
4480
+ const stepX = findMinStepX(p, p, 0);
4481
+ const stepY = findMinStepY(p, p, 0);
4482
+ if (stepX <= 0 || stepY <= 0) return emptyResult();
4483
+ const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
4484
+ const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
4485
+ if (cols === 0 || rows === 0) return emptyResult();
4486
+ const placements = [];
4487
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
4488
+ for (let r = 0; r < rows; r++) {
4489
+ for (let c = 0; c < cols; c++) {
4490
+ const ox = bounds.left + c * stepX;
4491
+ const oy = bounds.top + r * stepY;
4492
+ placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
4493
+ if (ox < minX) minX = ox;
4494
+ if (oy < minY) minY = oy;
4495
+ if (ox + p.width > maxX) maxX = ox + p.width;
4496
+ if (oy + p.height > maxY) maxY = oy + p.height;
4497
+ }
4498
+ }
4499
+ return { placements, count: placements.length, minX, minY, maxX, maxY };
4500
+ }
4501
+ function dualRotGrid(rdA, rdB, offsetX, bounds) {
4502
+ const pA = rdA.profile, pB = rdB.profile;
4503
+ const stepX_A = findMinStepX(pA, pA, 0);
4504
+ const stepX_B = findMinStepX(pB, pB, 0);
4505
+ if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
4506
+ const stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
4507
+ const stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
4508
+ if (stepY_AB + stepY_BA <= 0) return emptyResult();
4509
+ const placements = [];
4510
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
4511
+ let oy = bounds.top;
4512
+ let isRowA = true;
4513
+ while (true) {
4514
+ const rd = isRowA ? rdA : rdB;
4515
+ const p = rd.profile;
4516
+ const stepX = isRowA ? stepX_A : stepX_B;
4517
+ if (oy + p.height > bounds.bottom) break;
4518
+ let sx = isRowA ? bounds.left : bounds.left + offsetX;
4519
+ if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
4520
+ for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
4521
+ placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
4522
+ if (ox < minX) minX = ox;
4523
+ if (oy < minY) minY = oy;
4524
+ if (ox + p.width > maxX) maxX = ox + p.width;
4525
+ if (oy + p.height > maxY) maxY = oy + p.height;
4526
+ }
4527
+ oy += isRowA ? stepY_AB : stepY_BA;
4528
+ isRowA = !isRowA;
4529
+ }
4530
+ if (placements.length === 0) return emptyResult();
4531
+ return { placements, count: placements.length, minX, minY, maxX, maxY };
4532
+ }
4533
+ function centerLayout(result, bounds) {
4534
+ if (result.count === 0) return;
4535
+ const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
4536
+ const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
4537
+ for (const p of result.placements) {
4538
+ p.x += offX;
4539
+ p.y += offY;
4540
+ }
4541
+ }
4542
+ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
4543
+ const rots = [0, 90, 180, 270];
4544
+ const rd = /* @__PURE__ */ new Map();
4545
+ for (const deg of rots) {
4546
+ rd.set(deg, prepareRotation(contourPoints, dielineW, dielineH, deg));
4547
+ }
4548
+ const results = [];
4549
+ for (const deg of rots) {
4550
+ results.push(singleRotGrid(rd.get(deg), bounds));
4551
+ }
4552
+ const pairs = [
4553
+ [0, 180],
4554
+ [90, 270],
4555
+ [0, 90],
4556
+ [0, 270],
4557
+ [90, 180],
4558
+ [180, 270]
4559
+ ];
4560
+ for (const [a, b] of pairs) {
4561
+ const rdA = rd.get(a), rdB = rd.get(b);
4562
+ const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
4563
+ if (stepA <= 0) continue;
4564
+ for (let off = 0; off < stepA; off += 1) {
4565
+ results.push(dualRotGrid(rdA, rdB, off, bounds));
4566
+ results.push(dualRotGrid(rdB, rdA, off, bounds));
4567
+ }
4568
+ }
4569
+ let best = results[0];
4570
+ for (const r of results) {
4571
+ if (r.count > best.count) best = r;
4572
+ }
4573
+ centerLayout(best, bounds);
4574
+ return {
4575
+ rotation: best.placements[0]?.rotation ?? 0,
4576
+ placements: best.placements,
4577
+ producedPerSheet: best.count
4578
+ };
4579
+ }
4580
+
4581
+ // src/utils/autoLayout/calculate/tuck-end-boxes/becf-1030a/index.ts
4582
+ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
4583
+ const rotated = normalizePoints(contourPoints, deg);
4584
+ return {
4585
+ profile: buildProfile(rotated),
4586
+ bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
4587
+ deg
4588
+ };
4589
+ }
4590
+ function pairGrid(rdA, rdB, bounds) {
4591
+ const pA = rdA.profile, pB = rdB.profile;
4592
+ const gapAB = findMinStepX(pA, pB, 0);
4593
+ if (gapAB <= 0) return emptyResult();
4594
+ const pairW = gapAB + pB.width;
4595
+ const pairH = Math.max(pA.height, pB.height);
4596
+ const pairStepX = gapAB + findMinStepX(pB, pA, 0);
4597
+ const pairStepY = Math.max(
4598
+ findMinStepY(pA, pA, 0),
4599
+ findMinStepY(pA, pB, gapAB),
4600
+ findMinStepY(pB, pA, -gapAB),
4601
+ findMinStepY(pB, pB, 0)
4602
+ );
4603
+ if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
4604
+ const usableW = bounds.right - bounds.left;
4605
+ const usableH = bounds.bottom - bounds.top;
4606
+ const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
4607
+ const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
4608
+ if (pairCols === 0 || pairRows === 0) return emptyResult();
4609
+ const placements = [];
4610
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
4611
+ for (let r = 0; r < pairRows; r++) {
4612
+ for (let c = 0; c < pairCols; c++) {
4613
+ const baseX = bounds.left + c * pairStepX;
4614
+ const baseY = bounds.top + r * pairStepY;
4615
+ const oxA = baseX;
4616
+ const oyA = baseY;
4617
+ placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
4618
+ if (oxA < minX) minX = oxA;
4619
+ if (oyA < minY) minY = oyA;
4620
+ if (oxA + pA.width > maxX) maxX = oxA + pA.width;
4621
+ if (oyA + pA.height > maxY) maxY = oyA + pA.height;
4622
+ const oxB = baseX + gapAB;
4623
+ const oyB = baseY;
4624
+ placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
4625
+ if (oxB < minX) minX = oxB;
4626
+ if (oyB < minY) minY = oyB;
4627
+ if (oxB + pB.width > maxX) maxX = oxB + pB.width;
4628
+ if (oyB + pB.height > maxY) maxY = oyB + pB.height;
4629
+ }
3269
4630
  }
3270
- return { dx: dlMinX - ocMinX, dy: dlMinY - ocMinY };
3271
- }
3272
- function computeLayoutForPaperDefault(contourPoints, dielineW, dielineH, paperWidth, paperHeight, bounds) {
3273
- const usableLeft = Math.ceil(bounds.left / RESOLUTION);
3274
- const usableTop = Math.ceil(bounds.top / RESOLUTION);
3275
- const usableRight = Math.floor(bounds.right / RESOLUTION);
3276
- const usableBottom = Math.floor(bounds.bottom / RESOLUTION);
3277
- const paperW = Math.floor(paperWidth / RESOLUTION);
3278
- const paperH = Math.floor(paperHeight / RESOLUTION);
3279
- let bestCandidate = { rotation: 0, placements: [], producedPerSheet: 0 };
3280
- let bestGridPositions = [];
3281
- let bestBitmapW = 0;
3282
- let bestBitmapH = 0;
3283
- for (const deg of [0, 90, 180, 270]) {
3284
- const rotatedContour = normalizePoints(contourPoints, deg);
3285
- const pieceBitmap = rasterizePolygon(rotatedContour, RESOLUTION);
3286
- const bbOffset = computeDielineBBOffset(contourPoints, dielineW, dielineH, deg);
3287
- const paperGrid = new Uint8Array(paperW * paperH);
3288
- const placements = [];
3289
- const gridPositions = [];
3290
- for (let py = usableTop; py <= usableBottom - pieceBitmap.height; py++) {
3291
- for (let px = usableLeft; px <= usableRight - pieceBitmap.width; px++) {
3292
- if (canPlace(paperGrid, paperW, paperH, pieceBitmap, px, py)) {
3293
- placePiece(paperGrid, paperW, pieceBitmap, px, py);
3294
- gridPositions.push({ px, py });
3295
- placements.push({
3296
- x: px * RESOLUTION + bbOffset.dx,
3297
- y: py * RESOLUTION + bbOffset.dy,
3298
- rotation: deg
3299
- });
4631
+ const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
4632
+ const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
4633
+ const gapRight = bounds.right - pairsRightEdge;
4634
+ const gapBottom = bounds.bottom - pairsBottomEdge;
4635
+ const extraRotations = [rdA, rdB];
4636
+ for (const rdExtra of extraRotations) {
4637
+ const pe = rdExtra.profile;
4638
+ if (pe.width <= gapRight) {
4639
+ for (let r = 0; r < pairRows; r++) {
4640
+ const ox = pairsRightEdge;
4641
+ const oy = bounds.top + r * pairStepY;
4642
+ if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
4643
+ placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
4644
+ if (ox + pe.width > maxX) maxX = ox + pe.width;
3300
4645
  }
3301
4646
  }
4647
+ break;
3302
4648
  }
3303
- if (placements.length > bestCandidate.producedPerSheet) {
3304
- bestCandidate = { rotation: deg, placements, producedPerSheet: placements.length };
3305
- bestGridPositions = gridPositions;
3306
- bestBitmapW = pieceBitmap.width;
3307
- bestBitmapH = pieceBitmap.height;
4649
+ }
4650
+ for (const rdExtra of extraRotations) {
4651
+ const pe = rdExtra.profile;
4652
+ if (pe.height <= gapBottom) {
4653
+ for (let c = 0; c < pairCols; c++) {
4654
+ const oxA = bounds.left + c * pairStepX;
4655
+ const oy = pairsBottomEdge;
4656
+ if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
4657
+ placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
4658
+ if (oy + pe.height > maxY) maxY = oy + pe.height;
4659
+ }
4660
+ }
4661
+ break;
3308
4662
  }
3309
4663
  }
3310
- if (bestCandidate.placements.length > 0) {
3311
- let gridMinX = Infinity;
3312
- let gridMinY = Infinity;
3313
- let gridMaxX = -Infinity;
3314
- let gridMaxY = -Infinity;
3315
- for (const { px, py } of bestGridPositions) {
3316
- if (px < gridMinX) gridMinX = px;
3317
- if (py < gridMinY) gridMinY = py;
3318
- if (px + bestBitmapW > gridMaxX) gridMaxX = px + bestBitmapW;
3319
- if (py + bestBitmapH > gridMaxY) gridMaxY = py + bestBitmapH;
4664
+ return { placements, count: placements.length, minX, minY, maxX, maxY };
4665
+ }
4666
+ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
4667
+ const rots = [0, 90, 180, 270];
4668
+ const rd = /* @__PURE__ */ new Map();
4669
+ for (const deg of rots) {
4670
+ rd.set(deg, prepareRotation2(contourPoints, dielineW, dielineH, deg));
4671
+ }
4672
+ const results = [];
4673
+ for (const deg of rots) {
4674
+ results.push(singleRotGrid(rd.get(deg), bounds));
4675
+ }
4676
+ const allPairs = [
4677
+ [0, 180],
4678
+ [90, 270],
4679
+ [0, 90],
4680
+ [0, 270],
4681
+ [90, 180],
4682
+ [180, 270]
4683
+ ];
4684
+ for (const [a, b] of allPairs) {
4685
+ const rdA = rd.get(a), rdB = rd.get(b);
4686
+ const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
4687
+ if (stepA <= 0) continue;
4688
+ for (let off = 0; off < stepA; off += 1) {
4689
+ results.push(dualRotGrid(rdA, rdB, off, bounds));
4690
+ results.push(dualRotGrid(rdB, rdA, off, bounds));
3320
4691
  }
3321
- const groupW = gridMaxX - gridMinX;
3322
- const groupH = gridMaxY - gridMinY;
3323
- const usableW = usableRight - usableLeft;
3324
- const usableH = usableBottom - usableTop;
3325
- const offsetX = ((usableW - groupW) / 2 - (gridMinX - usableLeft)) * RESOLUTION;
3326
- const offsetY = ((usableH - groupH) / 2 - (gridMinY - usableTop)) * RESOLUTION;
3327
- for (const p of bestCandidate.placements) {
3328
- p.x += offsetX;
3329
- p.y += offsetY;
4692
+ }
4693
+ for (const [a, b] of allPairs) {
4694
+ results.push(pairGrid(rd.get(a), rd.get(b), bounds));
4695
+ results.push(pairGrid(rd.get(b), rd.get(a), bounds));
4696
+ }
4697
+ const singleResults = [];
4698
+ const multiResults = [];
4699
+ for (const r of results) {
4700
+ if (r.count === 0) continue;
4701
+ const rotations = new Set(r.placements.map((p) => p.rotation));
4702
+ if (rotations.size > 1) {
4703
+ multiResults.push(r);
4704
+ } else {
4705
+ singleResults.push(r);
3330
4706
  }
3331
4707
  }
3332
- return bestCandidate;
4708
+ function pickBest(arr) {
4709
+ let b = arr[0] ?? emptyResult();
4710
+ let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
4711
+ for (const r of arr) {
4712
+ const area = (r.maxX - r.minX) * (r.maxY - r.minY);
4713
+ if (r.count > b.count || r.count === b.count && area < bArea) {
4714
+ b = r;
4715
+ bArea = area;
4716
+ }
4717
+ }
4718
+ return b;
4719
+ }
4720
+ const bestSingle = pickBest(singleResults);
4721
+ const bestMulti = pickBest(multiResults);
4722
+ const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
4723
+ centerLayout(best, bounds);
4724
+ return {
4725
+ rotation: best.placements[0]?.rotation ?? 0,
4726
+ placements: best.placements,
4727
+ producedPerSheet: best.count
4728
+ };
3333
4729
  }
3334
4730
 
3335
- // src/utils/autoLayout/calculate/tuck-end-boxes/becf-1010a/index.ts
3336
- var SAMPLE_STEP = 0.1;
3337
- function buildProfile(points) {
3338
- let maxX = 0, maxY = 0;
3339
- for (const p of points) {
3340
- if (p.x > maxX) maxX = p.x;
3341
- if (p.y > maxY) maxY = p.y;
4731
+ // src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
4732
+ function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
4733
+ const rotated = normalizePoints(contourPoints, deg);
4734
+ return {
4735
+ profile: buildProfile(rotated),
4736
+ bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
4737
+ deg
4738
+ };
4739
+ }
4740
+ function findPairRowStepY(pA, pB, gapAB, pairStepX) {
4741
+ const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
4742
+ const nMin = Math.floor(-reach / pairStepX) - 1;
4743
+ const nMax = Math.ceil(reach / pairStepX) + 1;
4744
+ let maxStep = 0;
4745
+ for (let n = nMin; n <= nMax; n++) {
4746
+ const dx = n * pairStepX;
4747
+ const s1 = findMinStepY(pA, pA, dx);
4748
+ if (s1 > maxStep) maxStep = s1;
4749
+ const s2 = findMinStepY(pA, pB, dx + gapAB);
4750
+ if (s2 > maxStep) maxStep = s2;
4751
+ const s3 = findMinStepY(pB, pA, dx - gapAB);
4752
+ if (s3 > maxStep) maxStep = s3;
4753
+ const s4 = findMinStepY(pB, pB, dx);
4754
+ if (s4 > maxStep) maxStep = s4;
3342
4755
  }
3343
- const width = maxX, height = maxY;
3344
- const nY = Math.ceil(height / SAMPLE_STEP) + 1;
3345
- const nX = Math.ceil(width / SAMPLE_STEP) + 1;
3346
- const rightX = new Float64Array(nY).fill(-Infinity);
3347
- const leftX = new Float64Array(nY).fill(Infinity);
3348
- const bottomY = new Float64Array(nX).fill(-Infinity);
3349
- const topY = new Float64Array(nX).fill(Infinity);
3350
- const nPts = points.length;
3351
- for (let iy = 0; iy < nY; iy++) {
3352
- const y = iy * SAMPLE_STEP;
3353
- for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
3354
- const yj = points[j].y, yk = points[k].y;
3355
- if (yj <= y && yk > y || yk <= y && yj > y) {
3356
- const t = (y - yj) / (yk - yj);
3357
- const x = points[j].x + t * (points[k].x - points[j].x);
3358
- if (x > rightX[iy]) rightX[iy] = x;
3359
- if (x < leftX[iy]) leftX[iy] = x;
3360
- }
4756
+ return maxStep;
4757
+ }
4758
+ function pairGrid2(rdA, rdB, bounds) {
4759
+ const pA = rdA.profile, pB = rdB.profile;
4760
+ const gapAB = findMinStepX(pA, pB, 0);
4761
+ if (gapAB <= 0) return emptyResult();
4762
+ const pairW = gapAB + pB.width;
4763
+ const pairH = Math.max(pA.height, pB.height);
4764
+ const pairStepX = gapAB + findMinStepX(pB, pA, 0);
4765
+ if (pairStepX <= 0) return emptyResult();
4766
+ const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
4767
+ if (pairStepY <= 0) return emptyResult();
4768
+ const usableW = bounds.right - bounds.left;
4769
+ const usableH = bounds.bottom - bounds.top;
4770
+ const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
4771
+ const pairRows = Math.max(0, Math.floor((usableH - pairH) / pairStepY) + 1);
4772
+ if (pairCols === 0 || pairRows === 0) return emptyResult();
4773
+ const placements = [];
4774
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
4775
+ for (let r = 0; r < pairRows; r++) {
4776
+ for (let c = 0; c < pairCols; c++) {
4777
+ const baseX = bounds.left + c * pairStepX;
4778
+ const baseY = bounds.top + r * pairStepY;
4779
+ placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
4780
+ if (baseX < minX) minX = baseX;
4781
+ if (baseY < minY) minY = baseY;
4782
+ if (baseX + pA.width > maxX) maxX = baseX + pA.width;
4783
+ if (baseY + pA.height > maxY) maxY = baseY + pA.height;
4784
+ const bx = baseX + gapAB;
4785
+ placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
4786
+ if (bx < minX) minX = bx;
4787
+ if (bx + pB.width > maxX) maxX = bx + pB.width;
4788
+ if (baseY + pB.height > maxY) maxY = baseY + pB.height;
3361
4789
  }
3362
4790
  }
3363
- for (let ix = 0; ix < nX; ix++) {
3364
- const x = ix * SAMPLE_STEP;
3365
- for (let j = 0, k = nPts - 1; j < nPts; k = j++) {
3366
- const xj = points[j].x, xk = points[k].x;
3367
- if (xj <= x && xk > x || xk <= x && xj > x) {
3368
- const t = (x - xj) / (xk - xj);
3369
- const y = points[j].y + t * (points[k].y - points[j].y);
3370
- if (y > bottomY[ix]) bottomY[ix] = y;
3371
- if (y < topY[ix]) topY[ix] = y;
4791
+ const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
4792
+ const gapRight = bounds.right - pairsRightEdge;
4793
+ for (const rdExtra of [rdA, rdB]) {
4794
+ const pe = rdExtra.profile;
4795
+ if (pe.width > gapRight) continue;
4796
+ const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
4797
+ const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
4798
+ const extraStepY = Math.max(
4799
+ findMinStepY(pA, pe, dxFromA),
4800
+ findMinStepY(pB, pe, dxFromB),
4801
+ findMinStepY(pe, pe, 0)
4802
+ );
4803
+ if (extraStepY <= 0) continue;
4804
+ const effectiveStepY = Math.max(pairStepY, extraStepY);
4805
+ const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
4806
+ for (let r = 0; r < extraRows; r++) {
4807
+ const ox = pairsRightEdge;
4808
+ const oy = bounds.top + r * effectiveStepY;
4809
+ if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
4810
+ placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
4811
+ if (ox + pe.width > maxX) maxX = ox + pe.width;
4812
+ if (oy + pe.height > maxY) maxY = oy + pe.height;
3372
4813
  }
3373
4814
  }
4815
+ break;
3374
4816
  }
3375
- return { width, height, nY, nX, rightX, leftX, bottomY, topY };
3376
- }
3377
- function prepareRotation(contourPoints, dielineW, dielineH, deg) {
3378
- const rotated = normalizePoints(contourPoints, deg);
3379
- return {
3380
- profile: buildProfile(rotated),
3381
- bbOffset: computeDielineBBOffset(contourPoints, dielineW, dielineH, deg),
3382
- deg
3383
- };
3384
- }
3385
- function findMinStepX(a, b, dyMm) {
3386
- const dySamples = Math.round(dyMm / SAMPLE_STEP);
3387
- let maxOverlap = -Infinity;
3388
- for (let ia = 0; ia < a.nY; ia++) {
3389
- const ib = ia - dySamples;
3390
- if (ib < 0 || ib >= b.nY) continue;
3391
- if (a.rightX[ia] === -Infinity || b.leftX[ib] === Infinity) continue;
3392
- const overlap = a.rightX[ia] - b.leftX[ib];
3393
- if (overlap > maxOverlap) maxOverlap = overlap;
3394
- }
3395
- return maxOverlap <= -Infinity ? 0 : maxOverlap;
3396
- }
3397
- function findMinStepY(a, b, dxMm) {
3398
- const dxSamples = Math.round(dxMm / SAMPLE_STEP);
3399
- let maxOverlap = -Infinity;
3400
- for (let ia = 0; ia < a.nX; ia++) {
3401
- const ib = ia - dxSamples;
3402
- if (ib < 0 || ib >= b.nX) continue;
3403
- if (a.bottomY[ia] === -Infinity || b.topY[ib] === Infinity) continue;
3404
- const overlap = a.bottomY[ia] - b.topY[ib];
3405
- if (overlap > maxOverlap) maxOverlap = overlap;
4817
+ const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
4818
+ const gapBottom = bounds.bottom - pairsBottomEdge;
4819
+ for (const rdExtra of [rdA, rdB]) {
4820
+ const pe = rdExtra.profile;
4821
+ if (pe.height > gapBottom) continue;
4822
+ const extraStepX = findMinStepX(pe, pe, 0);
4823
+ if (extraStepX <= 0) continue;
4824
+ const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
4825
+ const stepFromA = findMinStepY(pA, pe, 0);
4826
+ const stepFromB = findMinStepY(pB, pe, gapAB);
4827
+ if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
4828
+ const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
4829
+ for (let c = 0; c < extraCols; c++) {
4830
+ const ox = bounds.left + c * extraStepX;
4831
+ const oy = pairsBottomEdge;
4832
+ if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
4833
+ placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
4834
+ if (ox + pe.width > maxX) maxX = ox + pe.width;
4835
+ if (oy + pe.height > maxY) maxY = oy + pe.height;
4836
+ }
4837
+ }
4838
+ break;
3406
4839
  }
3407
- return maxOverlap <= -Infinity ? 0 : maxOverlap;
4840
+ return { placements, count: placements.length, minX, minY, maxX, maxY };
3408
4841
  }
3409
- function findMinStepY_multi(profA, stepX_A, profB, offsetX) {
3410
- const reach = Math.max(profA.width, profB.width);
3411
- let maxStep = 0;
3412
- const nMin = Math.floor((offsetX - reach) / stepX_A);
3413
- const nMax = Math.ceil((offsetX + reach) / stepX_A);
3414
- for (let n = nMin; n <= nMax; n++) {
3415
- const s = findMinStepY(profA, profB, offsetX - n * stepX_A);
3416
- if (s > maxStep) maxStep = s;
4842
+ function verticalPairGrid(rdA, rdB, bounds) {
4843
+ const pA = rdA.profile, pB = rdB.profile;
4844
+ const gapAB_Y = findMinStepY(pA, pB, 0);
4845
+ if (gapAB_Y <= 0) return emptyResult();
4846
+ const vpairH = gapAB_Y + pB.height;
4847
+ const vpairW = Math.max(pA.width, pB.width);
4848
+ Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
4849
+ let vpairStepX = 0;
4850
+ {
4851
+ const stepXAA = findMinStepX(pA, pA, 0);
4852
+ const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
4853
+ const stepXBA = findMinStepX(pB, pA, gapAB_Y);
4854
+ const stepXBB = findMinStepX(pB, pB, 0);
4855
+ vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
3417
4856
  }
3418
- return maxStep;
3419
- }
3420
- function emptyResult() {
3421
- return { placements: [], count: 0, minX: 0, minY: 0, maxX: 0, maxY: 0 };
3422
- }
3423
- function singleRotGrid(rd, bounds) {
3424
- const p = rd.profile;
3425
- const stepX = findMinStepX(p, p, 0);
3426
- const stepY = findMinStepY(p, p, 0);
3427
- if (stepX <= 0 || stepY <= 0) return emptyResult();
3428
- const cols = Math.max(0, Math.floor((bounds.right - bounds.left - p.width) / stepX) + 1);
3429
- const rows = Math.max(0, Math.floor((bounds.bottom - bounds.top - p.height) / stepY) + 1);
4857
+ if (vpairStepX <= 0) return emptyResult();
4858
+ const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
4859
+ if (vpairStepY <= 0) return emptyResult();
4860
+ const usableW = bounds.right - bounds.left;
4861
+ const usableH = bounds.bottom - bounds.top;
4862
+ const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
4863
+ const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
3430
4864
  if (cols === 0 || rows === 0) return emptyResult();
3431
4865
  const placements = [];
3432
4866
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
3433
4867
  for (let r = 0; r < rows; r++) {
3434
4868
  for (let c = 0; c < cols; c++) {
3435
- const ox = bounds.left + c * stepX;
3436
- const oy = bounds.top + r * stepY;
3437
- placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
3438
- if (ox < minX) minX = ox;
3439
- if (oy < minY) minY = oy;
3440
- if (ox + p.width > maxX) maxX = ox + p.width;
3441
- if (oy + p.height > maxY) maxY = oy + p.height;
3442
- }
3443
- }
3444
- return { placements, count: placements.length, minX, minY, maxX, maxY };
3445
- }
3446
- function dualRotGrid(rdA, rdB, offsetX, bounds) {
3447
- const pA = rdA.profile, pB = rdB.profile;
3448
- const stepX_A = findMinStepX(pA, pA, 0);
3449
- const stepX_B = findMinStepX(pB, pB, 0);
3450
- if (stepX_A <= 0 || stepX_B <= 0) return emptyResult();
3451
- const stepY_AB = findMinStepY_multi(pA, stepX_A, pB, offsetX);
3452
- const stepY_BA = findMinStepY_multi(pB, stepX_B, pA, -offsetX);
3453
- if (stepY_AB + stepY_BA <= 0) return emptyResult();
3454
- const placements = [];
3455
- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
3456
- let oy = bounds.top;
3457
- let isRowA = true;
3458
- while (true) {
3459
- const rd = isRowA ? rdA : rdB;
3460
- const p = rd.profile;
3461
- const stepX = isRowA ? stepX_A : stepX_B;
3462
- if (oy + p.height > bounds.bottom) break;
3463
- let sx = isRowA ? bounds.left : bounds.left + offsetX;
3464
- if (sx < bounds.left) sx += stepX * Math.ceil((bounds.left - sx) / stepX);
3465
- for (let ox = sx; ox + p.width <= bounds.right; ox += stepX) {
3466
- placements.push({ x: ox + rd.bbOffset.dx, y: oy + rd.bbOffset.dy, rotation: rd.deg });
3467
- if (ox < minX) minX = ox;
3468
- if (oy < minY) minY = oy;
3469
- if (ox + p.width > maxX) maxX = ox + p.width;
3470
- if (oy + p.height > maxY) maxY = oy + p.height;
4869
+ const baseX = bounds.left + c * vpairStepX;
4870
+ const baseY = bounds.top + r * vpairStepY;
4871
+ placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
4872
+ if (baseX < minX) minX = baseX;
4873
+ if (baseY < minY) minY = baseY;
4874
+ if (baseX + pA.width > maxX) maxX = baseX + pA.width;
4875
+ if (baseY + pA.height > maxY) maxY = baseY + pA.height;
4876
+ const by = baseY + gapAB_Y;
4877
+ placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
4878
+ if (by + pB.height > maxY) maxY = by + pB.height;
3471
4879
  }
3472
- oy += isRowA ? stepY_AB : stepY_BA;
3473
- isRowA = !isRowA;
3474
4880
  }
3475
- if (placements.length === 0) return emptyResult();
3476
4881
  return { placements, count: placements.length, minX, minY, maxX, maxY };
3477
4882
  }
3478
- function centerLayout(result, bounds) {
3479
- if (result.count === 0) return;
3480
- const offX = (bounds.right - bounds.left - (result.maxX - result.minX)) / 2 - (result.minX - bounds.left);
3481
- const offY = (bounds.bottom - bounds.top - (result.maxY - result.minY)) / 2 - (result.minY - bounds.top);
3482
- for (const p of result.placements) {
3483
- p.x += offX;
3484
- p.y += offY;
3485
- }
3486
- }
3487
- function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
4883
+ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
3488
4884
  const rots = [0, 90, 180, 270];
3489
4885
  const rd = /* @__PURE__ */ new Map();
3490
4886
  for (const deg of rots) {
3491
- rd.set(deg, prepareRotation(contourPoints, dielineW, dielineH, deg));
4887
+ rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
3492
4888
  }
3493
4889
  const results = [];
3494
4890
  for (const deg of rots) {
3495
4891
  results.push(singleRotGrid(rd.get(deg), bounds));
3496
4892
  }
3497
- const pairs = [
4893
+ const allPairs = [
3498
4894
  [0, 180],
3499
4895
  [90, 270],
3500
4896
  [0, 90],
@@ -3502,7 +4898,7 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
3502
4898
  [90, 180],
3503
4899
  [180, 270]
3504
4900
  ];
3505
- for (const [a, b] of pairs) {
4901
+ for (const [a, b] of allPairs) {
3506
4902
  const rdA = rd.get(a), rdB = rd.get(b);
3507
4903
  const stepA = findMinStepX(rdA.profile, rdA.profile, 0);
3508
4904
  if (stepA <= 0) continue;
@@ -3511,10 +4907,40 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
3511
4907
  results.push(dualRotGrid(rdB, rdA, off, bounds));
3512
4908
  }
3513
4909
  }
3514
- let best = results[0];
4910
+ for (const [a, b] of allPairs) {
4911
+ results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
4912
+ results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
4913
+ }
4914
+ for (const [a, b] of allPairs) {
4915
+ results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
4916
+ results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
4917
+ }
4918
+ const singleResults = [];
4919
+ const multiResults = [];
3515
4920
  for (const r of results) {
3516
- if (r.count > best.count) best = r;
4921
+ if (r.count === 0) continue;
4922
+ const rotations = new Set(r.placements.map((p) => p.rotation));
4923
+ if (rotations.size > 1) {
4924
+ multiResults.push(r);
4925
+ } else {
4926
+ singleResults.push(r);
4927
+ }
4928
+ }
4929
+ function pickBest(arr) {
4930
+ let b = arr[0] ?? emptyResult();
4931
+ let bArea = (b.maxX - b.minX) * (b.maxY - b.minY);
4932
+ for (const r of arr) {
4933
+ const area = (r.maxX - r.minX) * (r.maxY - r.minY);
4934
+ if (r.count > b.count || r.count === b.count && area < bArea) {
4935
+ b = r;
4936
+ bArea = area;
4937
+ }
4938
+ }
4939
+ return b;
3517
4940
  }
4941
+ const bestSingle = pickBest(singleResults);
4942
+ const bestMulti = pickBest(multiResults);
4943
+ const best = bestMulti.count >= bestSingle.count && bestMulti.count > 0 ? bestMulti : bestSingle;
3518
4944
  centerLayout(best, bounds);
3519
4945
  return {
3520
4946
  rotation: best.placements[0]?.rotation ?? 0,
@@ -3523,8 +4949,8 @@ function computeLayoutForPaper(contourPoints, dielineW, dielineH, _paperWidth, _
3523
4949
  };
3524
4950
  }
3525
4951
 
3526
- // src/utils/autoLayout/calculate/tuck-end-boxes/becf-1030a/index.ts
3527
- function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
4952
+ // src/utils/autoLayout/calculate/bags-pillows/becf-12101/index.ts
4953
+ function prepareRotation4(contourPoints, dielineW, dielineH, deg) {
3528
4954
  const rotated = normalizePoints(contourPoints, deg);
3529
4955
  return {
3530
4956
  profile: buildProfile(rotated),
@@ -3532,7 +4958,7 @@ function prepareRotation2(contourPoints, dielineW, dielineH, deg) {
3532
4958
  deg
3533
4959
  };
3534
4960
  }
3535
- function pairGrid(rdA, rdB, bounds) {
4961
+ function pairGrid3(rdA, rdB, bounds) {
3536
4962
  const pA = rdA.profile, pB = rdB.profile;
3537
4963
  const gapAB = findMinStepX(pA, pB, 0);
3538
4964
  if (gapAB <= 0) return emptyResult();
@@ -3608,11 +5034,11 @@ function pairGrid(rdA, rdB, bounds) {
3608
5034
  }
3609
5035
  return { placements, count: placements.length, minX, minY, maxX, maxY };
3610
5036
  }
3611
- function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
5037
+ function computeLayoutForPaper4(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
3612
5038
  const rots = [0, 90, 180, 270];
3613
5039
  const rd = /* @__PURE__ */ new Map();
3614
5040
  for (const deg of rots) {
3615
- rd.set(deg, prepareRotation2(contourPoints, dielineW, dielineH, deg));
5041
+ rd.set(deg, prepareRotation4(contourPoints, dielineW, dielineH, deg));
3616
5042
  }
3617
5043
  const results = [];
3618
5044
  for (const deg of rots) {
@@ -3636,8 +5062,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
3636
5062
  }
3637
5063
  }
3638
5064
  for (const [a, b] of allPairs) {
3639
- results.push(pairGrid(rd.get(a), rd.get(b), bounds));
3640
- results.push(pairGrid(rd.get(b), rd.get(a), bounds));
5065
+ results.push(pairGrid3(rd.get(a), rd.get(b), bounds));
5066
+ results.push(pairGrid3(rd.get(b), rd.get(a), bounds));
3641
5067
  }
3642
5068
  const singleResults = [];
3643
5069
  const multiResults = [];
@@ -3673,8 +5099,8 @@ function computeLayoutForPaper2(contourPoints, dielineW, dielineH, _paperWidth,
3673
5099
  };
3674
5100
  }
3675
5101
 
3676
- // src/utils/autoLayout/calculate/tuck-end-boxes/becf-1040a/index.ts
3677
- function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
5102
+ // src/utils/autoLayout/calculate/bags-pillows/becf-12109/index.ts
5103
+ function prepareRotation5(contourPoints, dielineW, dielineH, deg) {
3678
5104
  const rotated = normalizePoints(contourPoints, deg);
3679
5105
  return {
3680
5106
  profile: buildProfile(rotated),
@@ -3682,34 +5108,20 @@ function prepareRotation3(contourPoints, dielineW, dielineH, deg) {
3682
5108
  deg
3683
5109
  };
3684
5110
  }
3685
- function findPairRowStepY(pA, pB, gapAB, pairStepX) {
3686
- const reach = Math.max(pA.width, pB.width) + Math.abs(gapAB);
3687
- const nMin = Math.floor(-reach / pairStepX) - 1;
3688
- const nMax = Math.ceil(reach / pairStepX) + 1;
3689
- let maxStep = 0;
3690
- for (let n = nMin; n <= nMax; n++) {
3691
- const dx = n * pairStepX;
3692
- const s1 = findMinStepY(pA, pA, dx);
3693
- if (s1 > maxStep) maxStep = s1;
3694
- const s2 = findMinStepY(pA, pB, dx + gapAB);
3695
- if (s2 > maxStep) maxStep = s2;
3696
- const s3 = findMinStepY(pB, pA, dx - gapAB);
3697
- if (s3 > maxStep) maxStep = s3;
3698
- const s4 = findMinStepY(pB, pB, dx);
3699
- if (s4 > maxStep) maxStep = s4;
3700
- }
3701
- return maxStep;
3702
- }
3703
- function pairGrid2(rdA, rdB, bounds) {
5111
+ function pairGrid4(rdA, rdB, bounds) {
3704
5112
  const pA = rdA.profile, pB = rdB.profile;
3705
5113
  const gapAB = findMinStepX(pA, pB, 0);
3706
5114
  if (gapAB <= 0) return emptyResult();
3707
5115
  const pairW = gapAB + pB.width;
3708
5116
  const pairH = Math.max(pA.height, pB.height);
3709
5117
  const pairStepX = gapAB + findMinStepX(pB, pA, 0);
3710
- if (pairStepX <= 0) return emptyResult();
3711
- const pairStepY = findPairRowStepY(pA, pB, gapAB, pairStepX);
3712
- if (pairStepY <= 0) return emptyResult();
5118
+ const pairStepY = Math.max(
5119
+ findMinStepY(pA, pA, 0),
5120
+ findMinStepY(pA, pB, gapAB),
5121
+ findMinStepY(pB, pA, -gapAB),
5122
+ findMinStepY(pB, pB, 0)
5123
+ );
5124
+ if (pairStepX <= 0 || pairStepY <= 0) return emptyResult();
3713
5125
  const usableW = bounds.right - bounds.left;
3714
5126
  const usableH = bounds.bottom - bounds.top;
3715
5127
  const pairCols = Math.max(0, Math.floor((usableW - pairW) / pairStepX) + 1);
@@ -3721,115 +5133,62 @@ function pairGrid2(rdA, rdB, bounds) {
3721
5133
  for (let c = 0; c < pairCols; c++) {
3722
5134
  const baseX = bounds.left + c * pairStepX;
3723
5135
  const baseY = bounds.top + r * pairStepY;
3724
- placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
3725
- if (baseX < minX) minX = baseX;
3726
- if (baseY < minY) minY = baseY;
3727
- if (baseX + pA.width > maxX) maxX = baseX + pA.width;
3728
- if (baseY + pA.height > maxY) maxY = baseY + pA.height;
3729
- const bx = baseX + gapAB;
3730
- placements.push({ x: bx + rdB.bbOffset.dx, y: baseY + rdB.bbOffset.dy, rotation: rdB.deg });
3731
- if (bx < minX) minX = bx;
3732
- if (bx + pB.width > maxX) maxX = bx + pB.width;
3733
- if (baseY + pB.height > maxY) maxY = baseY + pB.height;
5136
+ const oxA = baseX;
5137
+ const oyA = baseY;
5138
+ placements.push({ x: oxA + rdA.bbOffset.dx, y: oyA + rdA.bbOffset.dy, rotation: rdA.deg });
5139
+ if (oxA < minX) minX = oxA;
5140
+ if (oyA < minY) minY = oyA;
5141
+ if (oxA + pA.width > maxX) maxX = oxA + pA.width;
5142
+ if (oyA + pA.height > maxY) maxY = oyA + pA.height;
5143
+ const oxB = baseX + gapAB;
5144
+ const oyB = baseY;
5145
+ placements.push({ x: oxB + rdB.bbOffset.dx, y: oyB + rdB.bbOffset.dy, rotation: rdB.deg });
5146
+ if (oxB < minX) minX = oxB;
5147
+ if (oyB < minY) minY = oyB;
5148
+ if (oxB + pB.width > maxX) maxX = oxB + pB.width;
5149
+ if (oyB + pB.height > maxY) maxY = oyB + pB.height;
3734
5150
  }
3735
5151
  }
3736
5152
  const pairsRightEdge = bounds.left + (pairCols - 1) * pairStepX + pairW;
5153
+ const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
3737
5154
  const gapRight = bounds.right - pairsRightEdge;
3738
- for (const rdExtra of [rdA, rdB]) {
5155
+ const gapBottom = bounds.bottom - pairsBottomEdge;
5156
+ const extraRotations = [rdA, rdB];
5157
+ for (const rdExtra of extraRotations) {
3739
5158
  const pe = rdExtra.profile;
3740
- if (pe.width > gapRight) continue;
3741
- const dxFromB = pairsRightEdge - (bounds.left + (pairCols - 1) * pairStepX + gapAB);
3742
- const dxFromA = pairsRightEdge - bounds.left - (pairCols - 1) * pairStepX;
3743
- const extraStepY = Math.max(
3744
- findMinStepY(pA, pe, dxFromA),
3745
- findMinStepY(pB, pe, dxFromB),
3746
- findMinStepY(pe, pe, 0)
3747
- );
3748
- if (extraStepY <= 0) continue;
3749
- const effectiveStepY = Math.max(pairStepY, extraStepY);
3750
- const extraRows = Math.max(0, Math.floor((usableH - pe.height) / effectiveStepY) + 1);
3751
- for (let r = 0; r < extraRows; r++) {
3752
- const ox = pairsRightEdge;
3753
- const oy = bounds.top + r * effectiveStepY;
3754
- if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
3755
- placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
3756
- if (ox + pe.width > maxX) maxX = ox + pe.width;
3757
- if (oy + pe.height > maxY) maxY = oy + pe.height;
5159
+ if (pe.width <= gapRight) {
5160
+ for (let r = 0; r < pairRows; r++) {
5161
+ const ox = pairsRightEdge;
5162
+ const oy = bounds.top + r * pairStepY;
5163
+ if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
5164
+ placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
5165
+ if (ox + pe.width > maxX) maxX = ox + pe.width;
5166
+ }
3758
5167
  }
5168
+ break;
3759
5169
  }
3760
- break;
3761
5170
  }
3762
- const pairsBottomEdge = bounds.top + (pairRows - 1) * pairStepY + pairH;
3763
- const gapBottom = bounds.bottom - pairsBottomEdge;
3764
- for (const rdExtra of [rdA, rdB]) {
5171
+ for (const rdExtra of extraRotations) {
3765
5172
  const pe = rdExtra.profile;
3766
- if (pe.height > gapBottom) continue;
3767
- const extraStepX = findMinStepX(pe, pe, 0);
3768
- if (extraStepX <= 0) continue;
3769
- const dyFromPairRow = pairsBottomEdge - (bounds.top + (pairRows - 1) * pairStepY);
3770
- const stepFromA = findMinStepY(pA, pe, 0);
3771
- const stepFromB = findMinStepY(pB, pe, gapAB);
3772
- if (dyFromPairRow < stepFromA || dyFromPairRow < stepFromB) continue;
3773
- const extraCols = Math.max(0, Math.floor((usableW - pe.width) / extraStepX) + 1);
3774
- for (let c = 0; c < extraCols; c++) {
3775
- const ox = bounds.left + c * extraStepX;
3776
- const oy = pairsBottomEdge;
3777
- if (ox + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
3778
- placements.push({ x: ox + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
3779
- if (ox + pe.width > maxX) maxX = ox + pe.width;
3780
- if (oy + pe.height > maxY) maxY = oy + pe.height;
5173
+ if (pe.height <= gapBottom) {
5174
+ for (let c = 0; c < pairCols; c++) {
5175
+ const oxA = bounds.left + c * pairStepX;
5176
+ const oy = pairsBottomEdge;
5177
+ if (oxA + pe.width <= bounds.right && oy + pe.height <= bounds.bottom) {
5178
+ placements.push({ x: oxA + rdExtra.bbOffset.dx, y: oy + rdExtra.bbOffset.dy, rotation: rdExtra.deg });
5179
+ if (oy + pe.height > maxY) maxY = oy + pe.height;
5180
+ }
3781
5181
  }
3782
- }
3783
- break;
3784
- }
3785
- return { placements, count: placements.length, minX, minY, maxX, maxY };
3786
- }
3787
- function verticalPairGrid(rdA, rdB, bounds) {
3788
- const pA = rdA.profile, pB = rdB.profile;
3789
- const gapAB_Y = findMinStepY(pA, pB, 0);
3790
- if (gapAB_Y <= 0) return emptyResult();
3791
- const vpairH = gapAB_Y + pB.height;
3792
- const vpairW = Math.max(pA.width, pB.width);
3793
- Math.max(pA.height, pB.height) + Math.abs(gapAB_Y);
3794
- let vpairStepX = 0;
3795
- {
3796
- const stepXAA = findMinStepX(pA, pA, 0);
3797
- const stepXAB = findMinStepX(pA, pB, -gapAB_Y);
3798
- const stepXBA = findMinStepX(pB, pA, gapAB_Y);
3799
- const stepXBB = findMinStepX(pB, pB, 0);
3800
- vpairStepX = Math.max(stepXAA, stepXAB, stepXBA, stepXBB);
3801
- }
3802
- if (vpairStepX <= 0) return emptyResult();
3803
- const vpairStepY = gapAB_Y + findMinStepY(pB, pA, 0);
3804
- if (vpairStepY <= 0) return emptyResult();
3805
- const usableW = bounds.right - bounds.left;
3806
- const usableH = bounds.bottom - bounds.top;
3807
- const cols = Math.max(0, Math.floor((usableW - vpairW) / vpairStepX) + 1);
3808
- const rows = Math.max(0, Math.floor((usableH - vpairH) / vpairStepY) + 1);
3809
- if (cols === 0 || rows === 0) return emptyResult();
3810
- const placements = [];
3811
- let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
3812
- for (let r = 0; r < rows; r++) {
3813
- for (let c = 0; c < cols; c++) {
3814
- const baseX = bounds.left + c * vpairStepX;
3815
- const baseY = bounds.top + r * vpairStepY;
3816
- placements.push({ x: baseX + rdA.bbOffset.dx, y: baseY + rdA.bbOffset.dy, rotation: rdA.deg });
3817
- if (baseX < minX) minX = baseX;
3818
- if (baseY < minY) minY = baseY;
3819
- if (baseX + pA.width > maxX) maxX = baseX + pA.width;
3820
- if (baseY + pA.height > maxY) maxY = baseY + pA.height;
3821
- const by = baseY + gapAB_Y;
3822
- placements.push({ x: baseX + rdB.bbOffset.dx, y: by + rdB.bbOffset.dy, rotation: rdB.deg });
3823
- if (by + pB.height > maxY) maxY = by + pB.height;
5182
+ break;
3824
5183
  }
3825
5184
  }
3826
5185
  return { placements, count: placements.length, minX, minY, maxX, maxY };
3827
5186
  }
3828
- function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
5187
+ function computeLayoutForPaper5(contourPoints, dielineW, dielineH, _paperWidth, _paperHeight, bounds) {
3829
5188
  const rots = [0, 90, 180, 270];
3830
5189
  const rd = /* @__PURE__ */ new Map();
3831
5190
  for (const deg of rots) {
3832
- rd.set(deg, prepareRotation3(contourPoints, dielineW, dielineH, deg));
5191
+ rd.set(deg, prepareRotation5(contourPoints, dielineW, dielineH, deg));
3833
5192
  }
3834
5193
  const results = [];
3835
5194
  for (const deg of rots) {
@@ -3853,12 +5212,8 @@ function computeLayoutForPaper3(contourPoints, dielineW, dielineH, _paperWidth,
3853
5212
  }
3854
5213
  }
3855
5214
  for (const [a, b] of allPairs) {
3856
- results.push(pairGrid2(rd.get(a), rd.get(b), bounds));
3857
- results.push(pairGrid2(rd.get(b), rd.get(a), bounds));
3858
- }
3859
- for (const [a, b] of allPairs) {
3860
- results.push(verticalPairGrid(rd.get(a), rd.get(b), bounds));
3861
- results.push(verticalPairGrid(rd.get(b), rd.get(a), bounds));
5215
+ results.push(pairGrid4(rd.get(a), rd.get(b), bounds));
5216
+ results.push(pairGrid4(rd.get(b), rd.get(a), bounds));
3862
5217
  }
3863
5218
  const singleResults = [];
3864
5219
  const multiResults = [];
@@ -3921,6 +5276,22 @@ function resolveModelFunctions(modelId, attrs) {
3921
5276
  offsetContour: offsetContour4
3922
5277
  };
3923
5278
  }
5279
+ case "BECF-12101": {
5280
+ const a = attrs;
5281
+ return {
5282
+ contour: generateOuterContour5(a),
5283
+ dieline: generateBecf12101(a),
5284
+ offsetContour: offsetContour5
5285
+ };
5286
+ }
5287
+ case "BECF-12109": {
5288
+ const a = attrs;
5289
+ return {
5290
+ contour: generateOuterContour6(a),
5291
+ dieline: generateBecf12109(a),
5292
+ offsetContour: offsetContour6
5293
+ };
5294
+ }
3924
5295
  case "BECF-1010A":
3925
5296
  default: {
3926
5297
  const a = attrs;
@@ -3940,16 +5311,28 @@ function resolveLayoutCalculator(modelId) {
3940
5311
  return computeLayoutForPaper2;
3941
5312
  case "BECF-1040A":
3942
5313
  return computeLayoutForPaper3;
5314
+ case "BECF-12101":
5315
+ return computeLayoutForPaper4;
5316
+ case "BECF-12109":
5317
+ return computeLayoutForPaper5;
3943
5318
  default:
3944
5319
  return computeLayoutForPaperDefault;
3945
5320
  }
3946
5321
  }
3947
- function calculateAutoLayout(config) {
3948
- const { contour, dieline, offsetContour: offsetContour5 } = resolveModelFunctions(
5322
+ function calculateAutoLayout(rawConfig) {
5323
+ const config = {
5324
+ ...rawConfig,
5325
+ layoutDistance: rawConfig.layoutDistance ?? 3,
5326
+ spacing: rawConfig.spacing ?? 5,
5327
+ griper: rawConfig.griper ?? 10,
5328
+ colorbarHeight: rawConfig.colorbarHeight ?? 5,
5329
+ isShowColorbar: rawConfig.isShowColorbar ?? true
5330
+ };
5331
+ const { contour, dieline, offsetContour: offsetContour7 } = resolveModelFunctions(
3949
5332
  config.model.modelId,
3950
5333
  config.model.attributes
3951
5334
  );
3952
- const offsetContourPoints = config.layoutDistance > 0 ? offsetContour5(contour, config.layoutDistance / 2) : contour;
5335
+ const offsetContourPoints = config.layoutDistance > 0 ? offsetContour7(contour, config.layoutDistance / 2) : contour;
3953
5336
  const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
3954
5337
  const computeLayout = resolveLayoutCalculator(config.model.modelId);
3955
5338
  const paperResults = [];
@@ -4294,6 +5677,22 @@ function renderDieLine(modelId, attrs) {
4294
5677
  renderAs: "group"
4295
5678
  }
4296
5679
  );
5680
+ case "BECF-11D01":
5681
+ return /* @__PURE__ */ jsxRuntime.jsx(
5682
+ DIE_LINE_BECF_11D01,
5683
+ {
5684
+ attributes: attrs,
5685
+ renderAs: "group"
5686
+ }
5687
+ );
5688
+ case "BECF-12101":
5689
+ return /* @__PURE__ */ jsxRuntime.jsx(
5690
+ DIE_LINE_BECF_12101,
5691
+ {
5692
+ attributes: attrs,
5693
+ renderAs: "group"
5694
+ }
5695
+ );
4297
5696
  case "BECF-1010A":
4298
5697
  default:
4299
5698
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4343,9 +5742,9 @@ function getTransformedContour(normalizedPoints, x, y, rotation) {
4343
5742
  }
4344
5743
  return translatePolygon(rotated, x - rMinX, y - rMinY);
4345
5744
  }
4346
- function checkCollisions(items, normalizedOffsetContour, paperWidth, paperHeight) {
5745
+ function checkCollisions(items, shrunkContour, paperWidth, paperHeight) {
4347
5746
  const polys = items.map(
4348
- (item) => getTransformedContour(normalizedOffsetContour, item.x, item.y, item.rotation)
5747
+ (item) => getTransformedContour(shrunkContour, item.x, item.y, item.rotation)
4349
5748
  );
4350
5749
  return items.map((item, i) => {
4351
5750
  let colliding = false;
@@ -4403,7 +5802,10 @@ function ModifyLayout({
4403
5802
  const [panX, setPanX] = react.useState(0);
4404
5803
  const [panY, setPanY] = react.useState(0);
4405
5804
  const theme = react.useMemo(() => getAutoLayoutTheme(), []);
4406
- const normalizedOffsetContour = react.useMemo(() => normalizeContour(offsetContourPoints), [offsetContourPoints]);
5805
+ const shrunkContour = react.useMemo(
5806
+ () => normalizeContour(offsetContour(offsetContourPoints, -0.15)),
5807
+ [offsetContourPoints]
5808
+ );
4407
5809
  const pw = paperResult.paperWidth;
4408
5810
  const ph = paperResult.paperHeight;
4409
5811
  const padding = 20;
@@ -4416,7 +5818,7 @@ function ModifyLayout({
4416
5818
  const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
4417
5819
  const layoutDistance = config.layoutDistance;
4418
5820
  react.useEffect(() => {
4419
- setItems((prev) => checkCollisions(prev, normalizedOffsetContour, pw, ph));
5821
+ setItems((prev) => checkCollisions(prev, shrunkContour, pw, ph));
4420
5822
  }, []);
4421
5823
  const itemsRef = react.useRef(items);
4422
5824
  itemsRef.current = items;
@@ -4433,7 +5835,7 @@ function ModifyLayout({
4433
5835
  const updated = prev.map(
4434
5836
  (it) => it.id === dragItemId ? { ...it, x: newX, y: newY } : it
4435
5837
  );
4436
- return checkCollisions(updated, normalizedOffsetContour, pw, ph);
5838
+ return checkCollisions(updated, shrunkContour, pw, ph);
4437
5839
  });
4438
5840
  return;
4439
5841
  }
@@ -4467,7 +5869,7 @@ function ModifyLayout({
4467
5869
  window.removeEventListener("pointerup", handleMouseUp);
4468
5870
  window.removeEventListener("pointercancel", handleMouseUp);
4469
5871
  };
4470
- }, [normalizedOffsetContour, pw, ph, zoom, padding]);
5872
+ }, [shrunkContour, pw, ph, zoom, padding]);
4471
5873
  const handleItemMouseDown = react.useCallback((e, itemId) => {
4472
5874
  e.stopPropagation();
4473
5875
  e.preventDefault();
@@ -4506,9 +5908,9 @@ function ModifyLayout({
4506
5908
  const updated = prev.map(
4507
5909
  (it) => it.id === selectedId ? { ...it, rotation: degrees } : it
4508
5910
  );
4509
- return checkCollisions(updated, normalizedOffsetContour, pw, ph);
5911
+ return checkCollisions(updated, shrunkContour, pw, ph);
4510
5912
  });
4511
- }, [selectedId, normalizedOffsetContour, pw, ph]);
5913
+ }, [selectedId, shrunkContour, pw, ph]);
4512
5914
  const handleAdd = react.useCallback(() => {
4513
5915
  const newItem = {
4514
5916
  id: `item-${nextItemId++}`,
@@ -4519,17 +5921,17 @@ function ModifyLayout({
4519
5921
  };
4520
5922
  setItems((prev) => {
4521
5923
  const updated = [...prev, newItem];
4522
- return checkCollisions(updated, normalizedOffsetContour, pw, ph);
5924
+ return checkCollisions(updated, shrunkContour, pw, ph);
4523
5925
  });
4524
5926
  setSelectedId(newItem.id);
4525
- }, [pw, ph, dielineViewBox, normalizedOffsetContour]);
5927
+ }, [pw, ph, dielineViewBox, shrunkContour]);
4526
5928
  const handleRemove = react.useCallback((itemId) => {
4527
5929
  setItems((prev) => {
4528
5930
  const filtered = prev.filter((it) => it.id !== itemId);
4529
- return checkCollisions(filtered, normalizedOffsetContour, pw, ph);
5931
+ return checkCollisions(filtered, shrunkContour, pw, ph);
4530
5932
  });
4531
5933
  if (selectedId === itemId) setSelectedId(null);
4532
- }, [selectedId, normalizedOffsetContour, pw, ph]);
5934
+ }, [selectedId, shrunkContour, pw, ph]);
4533
5935
  const handleSubmit = react.useCallback(() => {
4534
5936
  const validItems = items.filter((it) => !it.isColliding);
4535
5937
  const placements = validItems.map((it) => ({
@@ -4859,6 +6261,28 @@ function resolveModel(modelId, attrs, layoutDistance) {
4859
6261
  generateContour: (a) => generateOuterContour4(a)
4860
6262
  };
4861
6263
  }
6264
+ case "BECF-12101": {
6265
+ const typedAttrs = attrs;
6266
+ const contour = generateOuterContour5(typedAttrs);
6267
+ return {
6268
+ dieline: generateBecf12101(typedAttrs),
6269
+ contourPath: contourToPath5(contour),
6270
+ offsetContourPoints: layoutDistance > 0 ? offsetContour5(contour, layoutDistance / 2) : contour,
6271
+ generate: (a) => generateBecf12101(a),
6272
+ generateContour: (a) => generateOuterContour5(a)
6273
+ };
6274
+ }
6275
+ case "BECF-12109": {
6276
+ const typedAttrs = attrs;
6277
+ const contour = generateOuterContour6(typedAttrs);
6278
+ return {
6279
+ dieline: generateBecf12109(typedAttrs),
6280
+ contourPath: contourToPath6(contour),
6281
+ offsetContourPoints: layoutDistance > 0 ? offsetContour6(contour, layoutDistance / 2) : contour,
6282
+ generate: (a) => generateBecf12109(a),
6283
+ generateContour: (a) => generateOuterContour6(a)
6284
+ };
6285
+ }
4862
6286
  case "BECF-1010A":
4863
6287
  default: {
4864
6288
  const typedAttrs = attrs;
@@ -4900,6 +6324,22 @@ function renderDieLine2(modelId, attrs) {
4900
6324
  renderAs: "group"
4901
6325
  }
4902
6326
  );
6327
+ case "BECF-12101":
6328
+ return /* @__PURE__ */ jsxRuntime.jsx(
6329
+ DIE_LINE_BECF_12101,
6330
+ {
6331
+ attributes: attrs,
6332
+ renderAs: "group"
6333
+ }
6334
+ );
6335
+ case "BECF-12109":
6336
+ return /* @__PURE__ */ jsxRuntime.jsx(
6337
+ DIE_LINE_BECF_12109,
6338
+ {
6339
+ attributes: attrs,
6340
+ renderAs: "group"
6341
+ }
6342
+ );
4903
6343
  case "BECF-1010A":
4904
6344
  default:
4905
6345
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -4913,7 +6353,7 @@ function renderDieLine2(modelId, attrs) {
4913
6353
  })();
4914
6354
  }
4915
6355
  var PAPER_GAP = 20;
4916
- var PX_PER_MM5 = 96 / 25.4;
6356
+ var PX_PER_MM7 = 96 / 25.4;
4917
6357
  var RESULT_PANEL_HEIGHT = 55;
4918
6358
  var RESULT_GAP = 5;
4919
6359
  function getOpposite2(side) {
@@ -5040,7 +6480,7 @@ function getDielineTransform2(x, y, rotation, w, h) {
5040
6480
  }
5041
6481
  }
5042
6482
  var AUTO_LAYOUT = react.forwardRef(
5043
- ({ config, onResult, onModifiedPapers }, ref) => {
6483
+ ({ config, onResult, onModifiedPapers, isShowSummary = true, isShowAction }, ref) => {
5044
6484
  const canvasRef = react.useRef(null);
5045
6485
  const [result, setResult] = react.useState(null);
5046
6486
  const [modifiedPapers, setModifiedPapers] = react.useState([]);
@@ -5063,7 +6503,7 @@ var AUTO_LAYOUT = react.forwardRef(
5063
6503
  );
5064
6504
  const modelId = config?.model.modelId ?? "";
5065
6505
  const attrs = config?.model.attributes;
5066
- const layoutDistance = config?.layoutDistance ?? 0;
6506
+ const layoutDistance = config?.layoutDistance ?? 3;
5067
6507
  const resolved = react.useMemo(
5068
6508
  () => modelId && attrs ? resolveModel(modelId, attrs, layoutDistance) : null,
5069
6509
  [modelId, attrs, layoutDistance]
@@ -5090,8 +6530,8 @@ var AUTO_LAYOUT = react.forwardRef(
5090
6530
  const svg = document.createElementNS(svgNs, "svg");
5091
6531
  svg.setAttribute("xmlns", svgNs);
5092
6532
  svg.setAttribute("viewBox", `0 0 ${vw} ${vh}`);
5093
- svg.setAttribute("width", String(Math.round(vw * PX_PER_MM5)));
5094
- svg.setAttribute("height", String(Math.round(vh * PX_PER_MM5)));
6533
+ svg.setAttribute("width", String(Math.round(vw * PX_PER_MM7)));
6534
+ svg.setAttribute("height", String(Math.round(vh * PX_PER_MM7)));
5095
6535
  const bg = document.createElementNS(svgNs, "rect");
5096
6536
  bg.setAttribute("width", String(vw));
5097
6537
  bg.setAttribute("height", String(vh));
@@ -5124,8 +6564,8 @@ var AUTO_LAYOUT = react.forwardRef(
5124
6564
  img.src = url;
5125
6565
  });
5126
6566
  const canvas = document.createElement("canvas");
5127
- canvas.width = Math.round(vw * PX_PER_MM5);
5128
- canvas.height = Math.round(vh * PX_PER_MM5);
6567
+ canvas.width = Math.round(vw * PX_PER_MM7);
6568
+ canvas.height = Math.round(vh * PX_PER_MM7);
5129
6569
  const ctx = canvas.getContext("2d");
5130
6570
  ctx.fillStyle = "#ffffff";
5131
6571
  ctx.fillRect(0, 0, canvas.width, canvas.height);
@@ -5144,13 +6584,13 @@ var AUTO_LAYOUT = react.forwardRef(
5144
6584
  if (!paperResult) throw new Error("Invalid paper index");
5145
6585
  const dl = resolved.generate(attrs);
5146
6586
  const cPath = contourToPath(resolved.generateContour(attrs));
5147
- const dist = config.layoutDistance;
6587
+ const dist = config.layoutDistance ?? 3;
5148
6588
  const svgNs = "http://www.w3.org/2000/svg";
5149
6589
  const svg = document.createElementNS(svgNs, "svg");
5150
6590
  svg.setAttribute("xmlns", svgNs);
5151
6591
  svg.setAttribute("viewBox", `0 0 ${paperResult.paperWidth} ${paperResult.paperHeight}`);
5152
- svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM5)));
5153
- svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM5)));
6592
+ svg.setAttribute("width", String(Math.round(paperResult.paperWidth * PX_PER_MM7)));
6593
+ svg.setAttribute("height", String(Math.round(paperResult.paperHeight * PX_PER_MM7)));
5154
6594
  const bg = document.createElementNS(svgNs, "rect");
5155
6595
  bg.setAttribute("width", String(paperResult.paperWidth));
5156
6596
  bg.setAttribute("height", String(paperResult.paperHeight));
@@ -5160,12 +6600,16 @@ var AUTO_LAYOUT = react.forwardRef(
5160
6600
  svg.appendChild(bg);
5161
6601
  const gripperSide = paperResult.gripperSide;
5162
6602
  const colorbarSide = getOpposite2(gripperSide);
5163
- const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
5164
- if (config.isShowColorbar) {
5165
- appendColorbarToSvg(svg, svgNs, colorbarSide, config.colorbarHeight, paperResult.paperWidth, paperResult.paperHeight);
6603
+ const colorbarHeight = config.colorbarHeight ?? 5;
6604
+ const isShowColorbar = config.isShowColorbar ?? true;
6605
+ const spacing = config.spacing ?? 5;
6606
+ const griper = config.griper ?? 10;
6607
+ const cbDepth = isShowColorbar ? colorbarHeight : 0;
6608
+ if (isShowColorbar) {
6609
+ appendColorbarToSvg(svg, svgNs, colorbarSide, colorbarHeight, paperResult.paperWidth, paperResult.paperHeight);
5166
6610
  }
5167
- if (config.spacing > 0) {
5168
- const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight, config.spacing, config.griper, cbDepth);
6611
+ if (spacing > 0) {
6612
+ const rects = getSpacingRects2(gripperSide, paperResult.paperWidth, paperResult.paperHeight, spacing, griper, cbDepth);
5169
6613
  for (const sr of rects) {
5170
6614
  const r = document.createElementNS(svgNs, "rect");
5171
6615
  r.setAttribute("x", String(sr.x));
@@ -5176,8 +6620,8 @@ var AUTO_LAYOUT = react.forwardRef(
5176
6620
  svg.appendChild(r);
5177
6621
  }
5178
6622
  }
5179
- if (config.griper > 0) {
5180
- appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight, config.griper, theme.colorGriper);
6623
+ if (griper > 0) {
6624
+ appendGripperToSvg(svg, svgNs, gripperSide, paperResult.paperWidth, paperResult.paperHeight, griper, theme.colorGriper);
5181
6625
  }
5182
6626
  if (dist > 0) {
5183
6627
  const defs = document.createElementNS(svgNs, "defs");
@@ -5250,8 +6694,8 @@ var AUTO_LAYOUT = react.forwardRef(
5250
6694
  img.src = url;
5251
6695
  });
5252
6696
  const canvas = document.createElement("canvas");
5253
- canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM5);
5254
- canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM5);
6697
+ canvas.width = Math.round(paperResult.paperWidth * PX_PER_MM7);
6698
+ canvas.height = Math.round(paperResult.paperHeight * PX_PER_MM7);
5255
6699
  const ctx = canvas.getContext("2d");
5256
6700
  ctx.fillStyle = theme.colorPaperFill;
5257
6701
  ctx.fillRect(0, 0, canvas.width, canvas.height);
@@ -5279,7 +6723,10 @@ var AUTO_LAYOUT = react.forwardRef(
5279
6723
  unit: "mm",
5280
6724
  format: [pw, ph]
5281
6725
  });
5282
- if (config.isShowColorbar) {
6726
+ const pdfColorbarHeight = config.colorbarHeight ?? 5;
6727
+ const pdfIsShowColorbar = config.isShowColorbar ?? true;
6728
+ const pdfGriper = config.griper ?? 10;
6729
+ if (pdfIsShowColorbar) {
5283
6730
  const BASE_COLORS2 = ["#02FFFF", "#FF00FF", "#FFFF00", "#000000"];
5284
6731
  const FADE_LEVELS2 = [1, 0.8, 0.6, 0.4, 0.2];
5285
6732
  const fadeToWhite2 = (hex, opacity) => {
@@ -5297,7 +6744,7 @@ var AUTO_LAYOUT = react.forwardRef(
5297
6744
  );
5298
6745
  const count = colors.length;
5299
6746
  const isHoriz = colorbarSide === "top" || colorbarSide === "bottom";
5300
- const cbH = config.colorbarHeight;
6747
+ const cbH = pdfColorbarHeight;
5301
6748
  colors.forEach((c, i) => {
5302
6749
  doc.setFillColor(c.r, c.g, c.b);
5303
6750
  if (isHoriz) {
@@ -5311,7 +6758,7 @@ var AUTO_LAYOUT = react.forwardRef(
5311
6758
  }
5312
6759
  });
5313
6760
  }
5314
- if (config.griper > 0) {
6761
+ if (pdfGriper > 0) {
5315
6762
  const hexToRgb2 = (hex) => ({
5316
6763
  r: parseInt(hex.slice(1, 3), 16),
5317
6764
  g: parseInt(hex.slice(3, 5), 16),
@@ -5319,7 +6766,7 @@ var AUTO_LAYOUT = react.forwardRef(
5319
6766
  });
5320
6767
  const gc = hexToRgb2(theme.colorGriper);
5321
6768
  doc.setFillColor(gc.r, gc.g, gc.b);
5322
- const depth = config.griper;
6769
+ const depth = pdfGriper;
5323
6770
  switch (gripperSide) {
5324
6771
  case "bottom":
5325
6772
  doc.rect(0, ph - depth, pw, depth, "F");
@@ -5444,7 +6891,8 @@ var AUTO_LAYOUT = react.forwardRef(
5444
6891
  exportImage,
5445
6892
  exportPdf
5446
6893
  }), [result, getPackedResult, exportDielineImage, exportImage, exportPdf]);
5447
- const paperOriginY = RESULT_PANEL_HEIGHT + RESULT_GAP;
6894
+ const showAction = (action) => !isShowAction || isShowAction.includes(action);
6895
+ const paperOriginY = isShowSummary ? RESULT_PANEL_HEIGHT + RESULT_GAP : 0;
5448
6896
  const viewBox = react.useMemo(() => {
5449
6897
  if (allPapers.length === 0) {
5450
6898
  return { x: 0, y: 0, width: 400, height: 300 };
@@ -5488,7 +6936,7 @@ var AUTO_LAYOUT = react.forwardRef(
5488
6936
  }
5489
6937
  const gripperSide = paperResult.gripperSide;
5490
6938
  const colorbarSide = getOpposite2(gripperSide);
5491
- const cbDepth = config.isShowColorbar ? config.colorbarHeight : 0;
6939
+ const cbDepth = config.isShowColorbar ?? true ? config.colorbarHeight ?? 5 : 0;
5492
6940
  const panelW = paperResult.paperWidth;
5493
6941
  const fontSize = Math.min(4, panelW / 30);
5494
6942
  const padX = fontSize * 1.2;
@@ -5512,148 +6960,150 @@ var AUTO_LAYOUT = react.forwardRef(
5512
6960
  curY += gap;
5513
6961
  const exportBtnY = curY;
5514
6962
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${offsetX}, 0)`, children: [
5515
- /* @__PURE__ */ jsxRuntime.jsx(
5516
- "rect",
5517
- {
5518
- x: 0,
5519
- y: 0,
5520
- width: panelW,
5521
- height: RESULT_PANEL_HEIGHT,
5522
- rx: 2,
5523
- ry: 2,
5524
- fill: "#f8fafc",
5525
- stroke: "#d4dce7",
5526
- strokeWidth: 0.3
5527
- }
5528
- ),
5529
- /* @__PURE__ */ jsxRuntime.jsx("text", { x: padX, y: titleY, fontSize: fontSize + 1, fontWeight: "bold", fill: "#0f172a", children: paperResult.paperName }),
5530
- /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: recY, fontSize, fontWeight: "bold", fill: rank === 1 ? "#10b981" : "#475569", children: [
5531
- "Recommended: #",
5532
- rank
5533
- ] }),
5534
- /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: perSheetY, fontSize, fill: "#475569", children: [
5535
- "Produced per sheet: ",
5536
- paperResult.producedPerSheet,
5537
- " pcs"
5538
- ] }),
5539
- /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: sheetsY, fontSize, fill: "#475569", children: [
5540
- "Sheets needed: ",
5541
- paperResult.independentSheets
5542
- ] }),
5543
- /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: producedY, fontSize, fill: "#475569", children: [
5544
- "Produced: ",
5545
- paperResult.independentSheets * paperResult.producedPerSheet,
5546
- " pcs (excess ",
5547
- paperResult.independentSheets * paperResult.producedPerSheet - (config?.quantity ?? 0),
5548
- ")"
5549
- ] }),
5550
- /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: wasteY, fontSize, fill: "#475569", children: [
5551
- "Waste per sheet: ",
5552
- paperResult.wastePercent,
5553
- "%"
6963
+ isShowSummary && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
6964
+ /* @__PURE__ */ jsxRuntime.jsx(
6965
+ "rect",
6966
+ {
6967
+ x: 0,
6968
+ y: 0,
6969
+ width: panelW,
6970
+ height: RESULT_PANEL_HEIGHT,
6971
+ rx: 2,
6972
+ ry: 2,
6973
+ fill: "#f8fafc",
6974
+ stroke: "#d4dce7",
6975
+ strokeWidth: 0.3
6976
+ }
6977
+ ),
6978
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: padX, y: titleY, fontSize: fontSize + 1, fontWeight: "bold", fill: "#0f172a", children: paperResult.paperName }),
6979
+ /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: recY, fontSize, fontWeight: "bold", fill: rank === 1 ? "#10b981" : "#475569", children: [
6980
+ "Recommended: #",
6981
+ rank
6982
+ ] }),
6983
+ /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: perSheetY, fontSize, fill: "#475569", children: [
6984
+ "Produced per sheet: ",
6985
+ paperResult.producedPerSheet,
6986
+ " pcs"
6987
+ ] }),
6988
+ /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: sheetsY, fontSize, fill: "#475569", children: [
6989
+ "Sheets needed: ",
6990
+ paperResult.independentSheets
6991
+ ] }),
6992
+ /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: producedY, fontSize, fill: "#475569", children: [
6993
+ "Produced: ",
6994
+ paperResult.independentSheets * paperResult.producedPerSheet,
6995
+ " pcs (excess ",
6996
+ paperResult.independentSheets * paperResult.producedPerSheet - (config?.quantity ?? 0),
6997
+ ")"
6998
+ ] }),
6999
+ /* @__PURE__ */ jsxRuntime.jsxs("text", { x: padX, y: wasteY, fontSize, fill: "#475569", children: [
7000
+ "Waste per sheet: ",
7001
+ paperResult.wastePercent,
7002
+ "%"
7003
+ ] }),
7004
+ showAction("EXPORT_SHEET") && /* @__PURE__ */ jsxRuntime.jsxs(
7005
+ "g",
7006
+ {
7007
+ style: { cursor: "pointer" },
7008
+ onPointerDown: (e) => e.stopPropagation(),
7009
+ onClick: () => handleExportImage(paperIdx),
7010
+ children: [
7011
+ /* @__PURE__ */ jsxRuntime.jsx(
7012
+ "rect",
7013
+ {
7014
+ x: padX,
7015
+ y: exportBtnY,
7016
+ width: exportBtnW,
7017
+ height: exportBtnH,
7018
+ rx: 1.5,
7019
+ ry: 1.5,
7020
+ fill: "#0f172a"
7021
+ }
7022
+ ),
7023
+ /* @__PURE__ */ jsxRuntime.jsx(
7024
+ "text",
7025
+ {
7026
+ x: padX + exportBtnW / 2,
7027
+ y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
7028
+ textAnchor: "middle",
7029
+ fontSize,
7030
+ fill: "#fff",
7031
+ style: { pointerEvents: "none" },
7032
+ children: "Export Sheet"
7033
+ }
7034
+ )
7035
+ ]
7036
+ }
7037
+ ),
7038
+ showAction("EXPORT_PDF") && /* @__PURE__ */ jsxRuntime.jsxs(
7039
+ "g",
7040
+ {
7041
+ style: { cursor: "pointer" },
7042
+ onPointerDown: (e) => e.stopPropagation(),
7043
+ onClick: () => handleExportPdf(paperIdx),
7044
+ children: [
7045
+ /* @__PURE__ */ jsxRuntime.jsx(
7046
+ "rect",
7047
+ {
7048
+ x: padX + exportBtnW + fontSize * 2,
7049
+ y: exportBtnY,
7050
+ width: exportBtnW,
7051
+ height: exportBtnH,
7052
+ rx: 1.5,
7053
+ ry: 1.5,
7054
+ fill: "#1e40af"
7055
+ }
7056
+ ),
7057
+ /* @__PURE__ */ jsxRuntime.jsx(
7058
+ "text",
7059
+ {
7060
+ x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
7061
+ y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
7062
+ textAnchor: "middle",
7063
+ fontSize,
7064
+ fill: "#fff",
7065
+ style: { pointerEvents: "none" },
7066
+ children: "Export PDF"
7067
+ }
7068
+ )
7069
+ ]
7070
+ }
7071
+ ),
7072
+ showAction("MODIFY_LAYOUT") && paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
7073
+ "g",
7074
+ {
7075
+ style: { cursor: "pointer" },
7076
+ onPointerDown: (e) => e.stopPropagation(),
7077
+ onClick: () => setModifyingPaper(paperResult),
7078
+ children: [
7079
+ /* @__PURE__ */ jsxRuntime.jsx(
7080
+ "rect",
7081
+ {
7082
+ x: padX + (exportBtnW + fontSize * 2) * 2,
7083
+ y: exportBtnY,
7084
+ width: exportBtnW,
7085
+ height: exportBtnH,
7086
+ rx: 1.5,
7087
+ ry: 1.5,
7088
+ fill: "#7c3aed"
7089
+ }
7090
+ ),
7091
+ /* @__PURE__ */ jsxRuntime.jsx(
7092
+ "text",
7093
+ {
7094
+ x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
7095
+ y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
7096
+ textAnchor: "middle",
7097
+ fontSize,
7098
+ fill: "#fff",
7099
+ style: { pointerEvents: "none" },
7100
+ children: "Modify Layout"
7101
+ }
7102
+ )
7103
+ ]
7104
+ }
7105
+ )
5554
7106
  ] }),
5555
- /* @__PURE__ */ jsxRuntime.jsxs(
5556
- "g",
5557
- {
5558
- style: { cursor: "pointer" },
5559
- onPointerDown: (e) => e.stopPropagation(),
5560
- onClick: () => handleExportImage(paperIdx),
5561
- children: [
5562
- /* @__PURE__ */ jsxRuntime.jsx(
5563
- "rect",
5564
- {
5565
- x: padX,
5566
- y: exportBtnY,
5567
- width: exportBtnW,
5568
- height: exportBtnH,
5569
- rx: 1.5,
5570
- ry: 1.5,
5571
- fill: "#0f172a"
5572
- }
5573
- ),
5574
- /* @__PURE__ */ jsxRuntime.jsx(
5575
- "text",
5576
- {
5577
- x: padX + exportBtnW / 2,
5578
- y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
5579
- textAnchor: "middle",
5580
- fontSize,
5581
- fill: "#fff",
5582
- style: { pointerEvents: "none" },
5583
- children: "Export Sheet"
5584
- }
5585
- )
5586
- ]
5587
- }
5588
- ),
5589
- /* @__PURE__ */ jsxRuntime.jsxs(
5590
- "g",
5591
- {
5592
- style: { cursor: "pointer" },
5593
- onPointerDown: (e) => e.stopPropagation(),
5594
- onClick: () => handleExportPdf(paperIdx),
5595
- children: [
5596
- /* @__PURE__ */ jsxRuntime.jsx(
5597
- "rect",
5598
- {
5599
- x: padX + exportBtnW + fontSize * 2,
5600
- y: exportBtnY,
5601
- width: exportBtnW,
5602
- height: exportBtnH,
5603
- rx: 1.5,
5604
- ry: 1.5,
5605
- fill: "#1e40af"
5606
- }
5607
- ),
5608
- /* @__PURE__ */ jsxRuntime.jsx(
5609
- "text",
5610
- {
5611
- x: padX + exportBtnW + fontSize * 2 + exportBtnW / 2,
5612
- y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
5613
- textAnchor: "middle",
5614
- fontSize,
5615
- fill: "#fff",
5616
- style: { pointerEvents: "none" },
5617
- children: "Export PDF"
5618
- }
5619
- )
5620
- ]
5621
- }
5622
- ),
5623
- paperResult.producedPerSheet > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
5624
- "g",
5625
- {
5626
- style: { cursor: "pointer" },
5627
- onPointerDown: (e) => e.stopPropagation(),
5628
- onClick: () => setModifyingPaper(paperResult),
5629
- children: [
5630
- /* @__PURE__ */ jsxRuntime.jsx(
5631
- "rect",
5632
- {
5633
- x: padX + (exportBtnW + fontSize * 2) * 2,
5634
- y: exportBtnY,
5635
- width: exportBtnW,
5636
- height: exportBtnH,
5637
- rx: 1.5,
5638
- ry: 1.5,
5639
- fill: "#7c3aed"
5640
- }
5641
- ),
5642
- /* @__PURE__ */ jsxRuntime.jsx(
5643
- "text",
5644
- {
5645
- x: padX + (exportBtnW + fontSize * 2) * 2 + exportBtnW / 2,
5646
- y: exportBtnY + exportBtnH / 2 + fontSize * 0.35,
5647
- textAnchor: "middle",
5648
- fontSize,
5649
- fill: "#fff",
5650
- style: { pointerEvents: "none" },
5651
- children: "Modify Layout"
5652
- }
5653
- )
5654
- ]
5655
- }
5656
- ),
5657
7107
  /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(0, ${paperOriginY})`, children: [
5658
7108
  /* @__PURE__ */ jsxRuntime.jsx(
5659
7109
  "rect",
@@ -5665,30 +7115,30 @@ var AUTO_LAYOUT = react.forwardRef(
5665
7115
  strokeWidth: 0.5
5666
7116
  }
5667
7117
  ),
5668
- config.isShowColorbar && /* @__PURE__ */ jsxRuntime.jsx(
7118
+ (config.isShowColorbar ?? true) && /* @__PURE__ */ jsxRuntime.jsx(
5669
7119
  Colorbar,
5670
7120
  {
5671
7121
  side: colorbarSide,
5672
- colorbarHeight: config.colorbarHeight,
7122
+ colorbarHeight: config.colorbarHeight ?? 5,
5673
7123
  paperWidth: paperResult.paperWidth,
5674
7124
  paperHeight: paperResult.paperHeight
5675
7125
  }
5676
7126
  ),
5677
- config.spacing > 0 && getSpacingRects2(
7127
+ (config.spacing ?? 5) > 0 && getSpacingRects2(
5678
7128
  gripperSide,
5679
7129
  paperResult.paperWidth,
5680
7130
  paperResult.paperHeight,
5681
- config.spacing,
5682
- config.griper,
7131
+ config.spacing ?? 5,
7132
+ config.griper ?? 10,
5683
7133
  cbDepth
5684
7134
  ).map((r, i) => /* @__PURE__ */ jsxRuntime.jsx("rect", { x: r.x, y: r.y, width: r.w, height: r.h, fill: theme.colorSpacing }, `sp-${i}`)),
5685
- config.griper > 0 && /* @__PURE__ */ jsxRuntime.jsx(
7135
+ (config.griper ?? 10) > 0 && /* @__PURE__ */ jsxRuntime.jsx(
5686
7136
  Gripper,
5687
7137
  {
5688
7138
  side: gripperSide,
5689
7139
  paperWidth: paperResult.paperWidth,
5690
7140
  paperHeight: paperResult.paperHeight,
5691
- depth: config.griper,
7141
+ depth: config.griper ?? 10,
5692
7142
  fillColor: theme.colorGriper
5693
7143
  }
5694
7144
  ),
@@ -5750,6 +7200,10 @@ var DIE_LINE_LAYOUT = react.forwardRef(
5750
7200
  return /* @__PURE__ */ jsxRuntime.jsx(MODEL_BECF_1040A, { ref, ...props });
5751
7201
  case "BECF-11D01":
5752
7202
  return /* @__PURE__ */ jsxRuntime.jsx(MODEL_BECF_11D01, { ref, ...props });
7203
+ case "BECF-12101":
7204
+ return /* @__PURE__ */ jsxRuntime.jsx(MODEL_BECF_12101, { ref, ...props });
7205
+ case "BECF-12109":
7206
+ return /* @__PURE__ */ jsxRuntime.jsx(MODEL_BECF_12109, { ref, ...props });
5753
7207
  default:
5754
7208
  return null;
5755
7209
  }
@@ -5786,12 +7240,19 @@ var BECF_1040A_DEFAULT_ATTRIBUTES = {
5786
7240
  tuckFlap: 14
5787
7241
  };
5788
7242
 
5789
- // src/statics/standard-boxes/becf-11d01/DEFAULT_ATTRIBUTES.ts
5790
- var BECF_11D01_DEFAULT_ATTRIBUTES = {
7243
+ // src/statics/bags-pillows/becf-12101/DEFAULT_ATTRIBUTES.ts
7244
+ var BECF_12101_DEFAULT_ATTRIBUTES = {
7245
+ length: 100,
7246
+ width: 50,
7247
+ height: 150,
7248
+ glueArea: 13
7249
+ };
7250
+
7251
+ // src/statics/bags-pillows/becf-12109/DEFAULT_ATTRIBUTES.ts
7252
+ var BECF_12109_DEFAULT_ATTRIBUTES = {
5791
7253
  length: 100,
5792
7254
  width: 50,
5793
7255
  height: 150,
5794
- flapHeight: 50,
5795
7256
  glueArea: 13
5796
7257
  };
5797
7258
 
@@ -5818,21 +7279,46 @@ var modelList = [
5818
7279
  dimension: ["DIE_LINE"],
5819
7280
  attributes: { ...BECF_1030A_DEFAULT_ATTRIBUTES }
5820
7281
  },
7282
+ // {
7283
+ // id: "BECF-11D01",
7284
+ // nameEN: "Standard Box BECF-11D01",
7285
+ // nameTH: "กล่องทั่วไป BECF-11D01",
7286
+ // dimension: ["DIE_LINE"],
7287
+ // attributes: { ...BECF_11D01_DEFAULT_ATTRIBUTES },
7288
+ // },
5821
7289
  {
5822
- id: "BECF-11D01",
5823
- nameEN: "Standard Box BECF-11D01",
5824
- nameTH: "\u0E01\u0E25\u0E48\u0E2D\u0E07\u0E17\u0E31\u0E48\u0E27\u0E44\u0E1B BECF-11D01",
7290
+ id: "BECF-12101",
7291
+ nameEN: "SHOPPING BAGS TYPE A",
7292
+ nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 A",
5825
7293
  dimension: ["DIE_LINE"],
5826
- attributes: { ...BECF_11D01_DEFAULT_ATTRIBUTES }
7294
+ attributes: { ...BECF_12101_DEFAULT_ATTRIBUTES }
7295
+ },
7296
+ {
7297
+ id: "BECF-12109",
7298
+ nameEN: "SHOPPING BAGS TYPE B",
7299
+ nameTH: "\u0E16\u0E38\u0E07\u0E23\u0E49\u0E2D\u0E22\u0E40\u0E0A\u0E37\u0E2D\u0E01\u0E40\u0E1B\u0E35\u0E22 \u0E21\u0E31\u0E14\u0E1B\u0E21 B",
7300
+ dimension: ["DIE_LINE"],
7301
+ attributes: { ...BECF_12109_DEFAULT_ATTRIBUTES }
5827
7302
  }
5828
7303
  ];
5829
7304
 
7305
+ // src/statics/standard-boxes/becf-11d01/DEFAULT_ATTRIBUTES.ts
7306
+ var BECF_11D01_DEFAULT_ATTRIBUTES = {
7307
+ length: 100,
7308
+ width: 50,
7309
+ height: 150,
7310
+ flapHeight: 50,
7311
+ glueArea: 13
7312
+ };
7313
+
5830
7314
  exports.AUTO_LAYOUT = AUTO_LAYOUT;
5831
7315
  exports.AUTO_LAYOUT_THEME_CONFIG = AUTO_LAYOUT_THEME_CONFIG;
5832
7316
  exports.BECF_1010A_DEFAULT_ATTRIBUTES = BECF_1010A_DEFAULT_ATTRIBUTES;
5833
7317
  exports.BECF_1030A_DEFAULT_ATTRIBUTES = BECF_1030A_DEFAULT_ATTRIBUTES;
5834
7318
  exports.BECF_1040A_DEFAULT_ATTRIBUTES = BECF_1040A_DEFAULT_ATTRIBUTES;
5835
7319
  exports.BECF_11D01_DEFAULT_ATTRIBUTES = BECF_11D01_DEFAULT_ATTRIBUTES;
7320
+ exports.BECF_12101_DEFAULT_ATTRIBUTES = BECF_12101_DEFAULT_ATTRIBUTES;
7321
+ exports.BECF_12109_DEFAULT_ATTRIBUTES = BECF_12109_DEFAULT_ATTRIBUTES;
5836
7322
  exports.Colorbar = Colorbar;
5837
7323
  exports.DIE_LINE_LAYOUT = DIE_LINE_LAYOUT;
5838
7324
  exports.Gripper = Gripper;
@@ -5840,6 +7326,8 @@ exports.MODEL_BECF_1010A = MODEL_BECF_1010A;
5840
7326
  exports.MODEL_BECF_1030A = MODEL_BECF_1030A;
5841
7327
  exports.MODEL_BECF_1040A = MODEL_BECF_1040A;
5842
7328
  exports.MODEL_BECF_11D01 = MODEL_BECF_11D01;
7329
+ exports.MODEL_BECF_12101 = MODEL_BECF_12101;
7330
+ exports.MODEL_BECF_12109 = MODEL_BECF_12109;
5843
7331
  exports.MODEL_THEME_CONFIG = MODEL_THEME_CONFIG;
5844
7332
  exports.appendColorbarToSvg = appendColorbarToSvg;
5845
7333
  exports.appendGripperToSvg = appendGripperToSvg;