embroidery-qc-image 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,7 +22,7 @@ const exampleConfig = {
22
22
  sides: [
23
23
  {
24
24
  print_side: "Chest",
25
- postitions: [
25
+ positions: [
26
26
  {
27
27
  type: "TEXT" as const,
28
28
  text: "Brian <3",
@@ -52,7 +52,7 @@ const exampleConfig = {
52
52
  },
53
53
  {
54
54
  print_side: "Sleeve",
55
- postitions: [
55
+ positions: [
56
56
  {
57
57
  type: "TEXT" as const,
58
58
  text: "Ayanna",
@@ -109,7 +109,7 @@ interface EmbroideryQCConfig {
109
109
 
110
110
  interface Side {
111
111
  print_side: string; // e.g., "Chest", "Sleeve"
112
- postitions: Position[]; // Array of positions to render (note: "postitions" spelling)
112
+ positions: Position[]; // Array of positions to render
113
113
  }
114
114
 
115
115
  type Position = TextPosition | IconPosition;
@@ -1 +1 @@
1
- {"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAC5D,OAAO,yBAAyB,CAAC;AA2EjC,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAo8BvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAC5D,OAAO,yBAAyB,CAAC;AA2EjC,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAs8BvD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,13 +12,13 @@ interface TextPosition {
12
12
  }
13
13
  interface IconPosition {
14
14
  type: 'ICON';
15
- icon: string;
15
+ icon: number;
16
16
  layer_colors: string[];
17
17
  }
18
18
  type Position = TextPosition | IconPosition;
19
19
  interface Side {
20
20
  print_side: string;
21
- postitions: Position[];
21
+ positions: Position[];
22
22
  }
23
23
  interface EmbroideryQCConfig {
24
24
  image_url?: string;
package/dist/index.esm.js CHANGED
@@ -111,7 +111,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
111
111
  return;
112
112
  const fontsToLoad = new Set();
113
113
  config.sides.forEach((side) => {
114
- side.postitions.forEach((position) => {
114
+ side.positions.forEach((position) => {
115
115
  if (position.type === "TEXT" && position.font) {
116
116
  fontsToLoad.add(position.font);
117
117
  }
@@ -159,9 +159,9 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
159
159
  }
160
160
  // Load icons
161
161
  config.sides.forEach((side) => {
162
- side.postitions.forEach((position) => {
163
- if (position.type === "ICON") {
164
- const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;
162
+ side.positions.forEach((position) => {
163
+ if (position.type === "ICON" && position.icon !== 0) {
164
+ const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;
165
165
  if (!imageRefs.current.has(iconUrl)) {
166
166
  const img = new Image();
167
167
  img.crossOrigin = "anonymous";
@@ -246,7 +246,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
246
246
  const seenFlorals = new Set();
247
247
  if (config.sides) {
248
248
  config.sides.forEach((side) => {
249
- side.postitions.forEach((position) => {
249
+ side.positions.forEach((position) => {
250
250
  if (position.type === "TEXT" && position.floral_pattern) {
251
251
  const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;
252
252
  if (!seenFlorals.has(floralUrl)) {
@@ -428,7 +428,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
428
428
  const textGroups = [];
429
429
  let currentGroup = null;
430
430
  let currentProps = null;
431
- side.postitions.forEach((position) => {
431
+ side.positions.forEach((position) => {
432
432
  if (position.type === "TEXT") {
433
433
  if (!currentGroup ||
434
434
  currentProps.font !== position.font ||
@@ -471,7 +471,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
471
471
  ctx.restore();
472
472
  // Compute side-level uniform properties across all TEXT positions
473
473
  const allTextPositions = [];
474
- side.postitions.forEach((position) => {
474
+ side.positions.forEach((position) => {
475
475
  if (position.type === "TEXT")
476
476
  allTextPositions.push(position);
477
477
  });
@@ -516,7 +516,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
516
516
  });
517
517
  // Render ICON titles/values (no images here)
518
518
  currentY += 30 * scaleFactor; // minimal spacing before icon labels
519
- side.postitions.forEach((position) => {
519
+ side.positions.forEach((position) => {
520
520
  if (position.type === "ICON") {
521
521
  currentY += renderIconLabels(ctx, position, padding, currentY, sideWidth, scaleFactor);
522
522
  currentY += 10 * scaleFactor;
@@ -713,11 +713,13 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
713
713
  ctx.textBaseline = "top";
714
714
  ctx.fillStyle = "#444444";
715
715
  let cursorY = y;
716
- const iconText = `Icon: ${position.icon}`;
716
+ const iconText = position.icon === 0
717
+ ? `Icon: icon mặc định theo file thêu`
718
+ : `Icon: ${position.icon}`;
717
719
  const iconResult = fillTextWrapped(ctx, iconText, x, cursorY, maxWidth, fontSize + lineGap);
718
720
  // draw icon image inline with text, preserve aspect ratio; match line height
719
- const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;
720
- {
721
+ if (position.icon !== 0) {
722
+ const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;
721
723
  const img = imageRefs.current.get(iconUrl);
722
724
  if (img && img.complete && img.naturalHeight > 0) {
723
725
  const swatchH = fontSize;
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/components/EmbroideryQCImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { useState, useEffect, useRef } from \"react\";\r\nimport { EmbroideryQCImageProps, Position } from \"../types\";\r\nimport \"./EmbroideryQCImage.css\";\r\n\r\n// Color mapping\r\nconst COLOR_MAP: Record<string, string> = {\r\n \"Army (1394)\": \"#4B5320\",\r\n Army: \"#4B5320\",\r\n \"Black (8)\": \"#000000\",\r\n Black: \"#000000\",\r\n \"Bubblegum (1309)\": \"#FFC1CC\",\r\n Bubblegum: \"#FFC1CC\",\r\n \"Carolina Blue (1274)\": \"#7BAFD4\",\r\n \"Carolina Blue\": \"#7BAFD4\",\r\n \"Celadon (1098)\": \"#ACE1AF\",\r\n Celadon: \"#ACE1AF\",\r\n \"Coffee Bean (1145)\": \"#6F4E37\",\r\n \"Coffee Bean\": \"#6F4E37\",\r\n \"Daffodil (1180)\": \"#FFFF31\",\r\n Daffodil: \"#FFFF31\",\r\n \"Dark Gray (1131)\": \"#A9A9A9\",\r\n \"Dark Gray\": \"#A9A9A9\",\r\n \"Doe Skin Beige (1344)\": \"#F5E6D3\",\r\n \"Doe Skin Beige\": \"#F5E6D3\",\r\n \"Dusty Blue (1373)\": \"#6699CC\",\r\n \"Dusty Blue\": \"#6699CC\",\r\n \"Forest Green (1397)\": \"#228B22\",\r\n \"Forest Green\": \"#228B22\",\r\n \"Gold (1425)\": \"#FFD700\",\r\n Gold: \"#FFD700\",\r\n \"Gray (1118)\": \"#808080\",\r\n Gray: \"#808080\",\r\n \"Ivory (1072)\": \"#FFFFF0\",\r\n Ivory: \"#FFFFF0\",\r\n \"Lavender (1032)\": \"#E6E6FA\",\r\n Lavender: \"#E6E6FA\",\r\n \"Light Denim (1133)\": \"#B0C4DE\",\r\n \"Light Denim\": \"#B0C4DE\",\r\n \"Light Salmon (1018)\": \"#FFA07A\",\r\n \"Light Salmon\": \"#FFA07A\",\r\n \"Maroon (1374)\": \"#800000\",\r\n Maroon: \"#800000\",\r\n \"Navy Blue (1044)\": \"#000080\",\r\n \"Navy Blue\": \"#000080\",\r\n \"Olive Green (1157)\": \"#556B2F\",\r\n \"Olive Green\": \"#556B2F\",\r\n \"Orange (1278)\": \"#FFA500\",\r\n Orange: \"#FFA500\",\r\n \"Peach Blush (1053)\": \"#FFCCCB\",\r\n \"Peach Blush\": \"#FFCCCB\",\r\n \"Pink (1148)\": \"#FFC0CB\",\r\n Pink: \"#FFC0CB\",\r\n \"Purple (1412)\": \"#800080\",\r\n Purple: \"#800080\",\r\n \"Red (1037)\": \"#FF0000\",\r\n Red: \"#FF0000\",\r\n \"Silver Sage (1396)\": \"#A8A8A8\",\r\n \"Silver Sage\": \"#A8A8A8\",\r\n \"Summer Sky (1432)\": \"#87CEEB\",\r\n \"Summer Sky\": \"#87CEEB\",\r\n \"Terra Cotta (1477)\": \"#E2725B\",\r\n \"Terra Cotta\": \"#E2725B\",\r\n \"Sand (1055)\": \"#F4A460\",\r\n Sand: \"#F4A460\",\r\n \"White (9)\": \"#FFFFFF\",\r\n White: \"#FFFFFF\",\r\n};\r\n\r\nconst FONT_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/fonts\";\r\nconst ICON_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/icons\";\r\nconst FLORAL_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/florals\";\r\nconst THREAD_COLOR_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/thread-colors\";\r\n\r\nconst EmbroideryQCImage: React.FC<EmbroideryQCImageProps> = ({\r\n config,\r\n className = \"\",\r\n style = {},\r\n}) => {\r\n const [canvasSize] = useState({ width: 4200, height: 4800 });\r\n const [loadedFonts, setLoadedFonts] = useState<Set<string>>(new Set());\r\n const [imagesLoaded, setImagesLoaded] = useState(0);\r\n const canvasRef = useRef<HTMLCanvasElement>(null);\r\n const imageRefs = useRef<Map<string, HTMLImageElement>>(new Map());\r\n\r\n // Load fonts\r\n useEffect(() => {\r\n const loadFonts = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n const fontsToLoad = new Set<string>();\r\n config.sides.forEach((side) => {\r\n side.postitions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.font) {\r\n fontsToLoad.add(position.font);\r\n }\r\n });\r\n });\r\n\r\n for (const fontName of fontsToLoad) {\r\n if (loadedFonts.has(fontName)) continue;\r\n\r\n try {\r\n await loadFont(fontName);\r\n setLoadedFonts((prev) => new Set(prev).add(fontName));\r\n } catch (error) {\r\n console.warn(`Could not load font ${fontName}:`, error);\r\n }\r\n }\r\n };\r\n\r\n loadFonts();\r\n }, [config.sides, loadedFonts]);\r\n\r\n // Load images\r\n useEffect(() => {\r\n const loadImages = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n // Load mockup image (not background). It will be drawn at bottom-right.\r\n if (config.image_url) {\r\n // Try with CORS first. If it fails (no CORS headers), retry without CORS\r\n const loadMockup = (useCors: boolean) => {\r\n const img = new Image();\r\n if (useCors) img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n imageRefs.current.set(\"mockup\", img);\r\n setImagesLoaded((prev) => prev + 1);\r\n };\r\n img.onerror = () => {\r\n if (useCors) {\r\n // Retry without CORS; canvas may become tainted on export\r\n loadMockup(false);\r\n }\r\n };\r\n img.src = config.image_url as string;\r\n };\r\n loadMockup(true);\r\n }\r\n\r\n // Load icons\r\n config.sides.forEach((side) => {\r\n side.postitions.forEach((position) => {\r\n if (position.type === \"ICON\") {\r\n const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;\r\n if (!imageRefs.current.has(iconUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = iconUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(iconUrl, img);\r\n }\r\n }\r\n\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!imageRefs.current.has(floralUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = floralUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(floralUrl, img);\r\n }\r\n }\r\n\r\n // Load thread color images for TEXT positions\r\n if (position.type === \"TEXT\") {\r\n // Load color image if position has color\r\n if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n }\r\n\r\n // Load character color images\r\n if (\r\n position.character_colors &&\r\n position.character_colors.length > 0\r\n ) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n }\r\n\r\n // Load thread color images for ICON positions\r\n if (position.type === \"ICON\" && position.layer_colors) {\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n });\r\n });\r\n };\r\n\r\n loadImages();\r\n }, [config]);\r\n\r\n // Render canvas\r\n useEffect(() => {\r\n const renderCanvas = () => {\r\n if (!canvasRef.current || !config.sides || config.sides.length === 0) {\r\n return;\r\n }\r\n\r\n const canvas = canvasRef.current;\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return;\r\n\r\n canvas.width = canvasSize.width;\r\n canvas.height = canvasSize.height;\r\n\r\n // Clear with white background\r\n ctx.fillStyle = \"#FFFFFF\";\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n\r\n // Collect floral images (for later drawing)\r\n const floralAssets: HTMLImageElement[] = [];\r\n const seenFlorals = new Set<string>();\r\n if (config.sides) {\r\n config.sides.forEach((side) => {\r\n side.postitions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!seenFlorals.has(floralUrl)) {\r\n const img = imageRefs.current.get(floralUrl);\r\n if (img && img.complete && img.naturalWidth > 0) {\r\n floralAssets.push(img);\r\n seenFlorals.add(floralUrl);\r\n }\r\n }\r\n }\r\n });\r\n });\r\n }\r\n\r\n // Helper function to draw mockup and florals\r\n const drawMockupAndFlorals = () => {\r\n const mockupImg = imageRefs.current.get(\"mockup\");\r\n const margin = 40; // small padding\r\n let mockupBox: { x: number; y: number; w: number; h: number } | null =\r\n null;\r\n if (mockupImg && mockupImg.complete && mockupImg.naturalWidth > 0) {\r\n const maxTargetWidth = Math.min(1800, canvas.width * 0.375);\r\n const maxTargetHeight = canvas.height * 0.375;\r\n const scale = Math.min(\r\n maxTargetWidth / mockupImg.naturalWidth,\r\n maxTargetHeight / mockupImg.naturalHeight\r\n );\r\n const targetWidth = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalWidth * scale)\r\n );\r\n const targetHeight = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalHeight * scale)\r\n );\r\n const targetX = canvas.width - margin - targetWidth;\r\n const targetY = canvas.height - margin - targetHeight;\r\n mockupBox = {\r\n x: targetX,\r\n y: targetY,\r\n w: targetWidth,\r\n h: targetHeight,\r\n };\r\n ctx.drawImage(mockupImg, targetX, targetY, targetWidth, targetHeight);\r\n }\r\n\r\n // Draw florals to the left of mockup\r\n if (mockupBox && floralAssets.length > 0) {\r\n const spacing = 300;\r\n const targetHeight = mockupBox.h;\r\n const floralFixedH = Math.min(900, targetHeight);\r\n let currentX = mockupBox.x - spacing;\r\n for (let i = floralAssets.length - 1; i >= 0; i--) {\r\n const img = floralAssets[i];\r\n const ratio = img.naturalWidth / Math.max(1, img.naturalHeight);\r\n const h = floralFixedH;\r\n const w = Math.max(1, Math.floor(h * ratio));\r\n currentX -= w;\r\n const y = mockupBox.y + (targetHeight - h);\r\n ctx.drawImage(img, currentX, y, w, h);\r\n currentX -= spacing;\r\n }\r\n }\r\n };\r\n\r\n // New approach: Draw images first (bottom layer), then text on top\r\n // This allows text to overlay images when needed\r\n\r\n // Pass 1: Measure actual height with original size (use offscreen canvas for measurement)\r\n const measureCanvas = document.createElement(\"canvas\");\r\n measureCanvas.width = canvas.width;\r\n measureCanvas.height = canvas.height;\r\n const measureCtx = measureCanvas.getContext(\"2d\");\r\n if (!measureCtx) return;\r\n\r\n // Set up measurement context\r\n measureCtx.font = ctx.font;\r\n measureCtx.textAlign = ctx.textAlign;\r\n measureCtx.textBaseline = ctx.textBaseline;\r\n\r\n let measureY = 40;\r\n const measureSpacing = 100;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n measureCtx,\r\n side,\r\n measureY,\r\n canvas.width,\r\n 1\r\n );\r\n measureY += sideHeight + measureSpacing;\r\n });\r\n const totalMeasuredHeight = measureY; // Total height used\r\n\r\n // Calculate scale factor - only scale down when necessary\r\n // Keep original font sizes (no scale up) - font size is the maximum\r\n const topPadding = 40;\r\n // No bottom padding - content can go to bottom, mockup will overlay\r\n const targetContentHeight = canvas.height - topPadding;\r\n\r\n // Only scale down if content exceeds canvas height\r\n // Never scale up - preserve original font sizes\r\n let scaleFactor = 1;\r\n if (totalMeasuredHeight > targetContentHeight) {\r\n // Scale down to fit exactly\r\n scaleFactor = targetContentHeight / totalMeasuredHeight;\r\n scaleFactor = Math.max(0.5, scaleFactor); // Minimum scale to prevent tiny fonts\r\n }\r\n // If content fits, keep scaleFactor = 1 (original font sizes)\r\n\r\n // Draw mockup and florals first (bottom layer)\r\n drawMockupAndFlorals();\r\n\r\n // Draw content on top (top layer) - text will overlay images if needed\r\n let currentY = topPadding * scaleFactor;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n ctx,\r\n side,\r\n currentY,\r\n canvas.width,\r\n scaleFactor\r\n );\r\n currentY += sideHeight + measureSpacing * scaleFactor;\r\n });\r\n };\r\n\r\n // Delay rendering to ensure fonts and images are loaded\r\n const timer = setTimeout(renderCanvas, 100);\r\n return () => clearTimeout(timer);\r\n }, [config, canvasSize, loadedFonts, imagesLoaded]);\r\n\r\n // Helper function to wrap and draw text with word wrapping\r\n // Returns: { height: number, lastLineWidth: number, lastLineY: number }\r\n const fillTextWrapped = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): { height: number; lastLineWidth: number; lastLineY: number } => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n let currentLine = words[0];\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n currentLine = word;\r\n } else {\r\n currentLine = testLine;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line) => {\r\n ctx.fillText(line, x, currentY);\r\n currentY += lineHeight;\r\n });\r\n\r\n const lastLineWidth = ctx.measureText(lines[lines.length - 1]).width;\r\n const lastLineY = y + (lines.length - 1) * lineHeight;\r\n\r\n return {\r\n height: lines.length * lineHeight,\r\n lastLineWidth,\r\n lastLineY,\r\n };\r\n };\r\n\r\n // Helper to wrap and draw multi-color text (for character_colors)\r\n const fillTextWrappedMultiColor = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n colors: string[],\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): number => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n const lineStartIndices: number[] = [0];\r\n let currentLine = words[0];\r\n let currentCharIndex = words[0].length;\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n lineStartIndices.push(currentCharIndex + 1); // +1 for space\r\n currentLine = word;\r\n currentCharIndex += word.length + 1;\r\n } else {\r\n currentLine = testLine;\r\n currentCharIndex += word.length + 1;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line, lineIdx) => {\r\n let currentX = x;\r\n const startCharIdx = lineIdx > 0 ? lineStartIndices[lineIdx] : 0;\r\n for (let i = 0; i < line.length; i++) {\r\n const char = line[i];\r\n const globalCharIdx = startCharIdx + i;\r\n const colorIndex = globalCharIdx % colors.length;\r\n const color = colors[colorIndex];\r\n ctx.fillStyle = COLOR_MAP[color] || \"#000000\";\r\n ctx.fillText(char, currentX, currentY);\r\n currentX += ctx.measureText(char).width;\r\n }\r\n currentY += lineHeight;\r\n });\r\n\r\n return lines.length * lineHeight;\r\n };\r\n\r\n const renderSide = (\r\n ctx: CanvasRenderingContext2D,\r\n side: any,\r\n startY: number,\r\n width: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n let currentY = startY;\r\n const padding = 40 * scaleFactor;\r\n const sideWidth = width - 2 * padding;\r\n const sectionHeight = 200 * scaleFactor;\r\n\r\n // No background section anymore - just white background\r\n\r\n // Group positions by common properties for optimization\r\n const textGroups: Array<{\r\n positions: Array<Position & { type: \"TEXT\" }>;\r\n properties: any;\r\n }> = [];\r\n let currentGroup: Array<Position & { type: \"TEXT\" }> | null = null;\r\n let currentProps: any = null;\r\n\r\n side.postitions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") {\r\n if (\r\n !currentGroup ||\r\n currentProps.font !== position.font ||\r\n currentProps.text_shape !== position.text_shape ||\r\n currentProps.color !== position.color ||\r\n currentProps.character_colors?.join(\",\") !==\r\n position.character_colors?.join(\",\")\r\n ) {\r\n // Start new group\r\n if (currentGroup) {\r\n textGroups.push({\r\n positions: currentGroup,\r\n properties: currentProps,\r\n });\r\n }\r\n currentGroup = [position];\r\n currentProps = {\r\n font: position.font,\r\n text_shape: position.text_shape,\r\n color: position.color,\r\n character_colors: position.character_colors,\r\n };\r\n } else {\r\n currentGroup.push(position);\r\n }\r\n }\r\n });\r\n\r\n if (currentGroup) {\r\n textGroups.push({ positions: currentGroup, properties: currentProps });\r\n }\r\n\r\n // Draw side header\r\n ctx.save();\r\n const headerFontSize = 200 * scaleFactor;\r\n ctx.font = `bold ${headerFontSize}px Times New Roman`;\r\n ctx.fillStyle = \"#000000\";\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n const headerResult = fillTextWrapped(\r\n ctx,\r\n side.print_side.toUpperCase(),\r\n padding,\r\n currentY,\r\n sideWidth,\r\n headerFontSize\r\n );\r\n currentY += headerResult.height + 50 * scaleFactor;\r\n ctx.restore();\r\n\r\n // Compute side-level uniform properties across all TEXT positions\r\n const allTextPositions: Array<Position & { type: \"TEXT\" }> = [];\r\n side.postitions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") allTextPositions.push(position as any);\r\n });\r\n\r\n const sideFonts = new Set(allTextPositions.map((p) => (p as any).font));\r\n const sideShapes = new Set(\r\n allTextPositions.map((p) => (p as any).text_shape)\r\n );\r\n const sideFlorals = new Set(\r\n allTextPositions.map((p) => (p as any).floral_pattern ?? \"None\")\r\n );\r\n const colorKeyOf = (p: any) =>\r\n p.character_colors && p.character_colors.length > 0\r\n ? p.character_colors.join(\",\")\r\n : p.color ?? \"None\";\r\n const sideColors = new Set(allTextPositions.map((p) => colorKeyOf(p)));\r\n\r\n const sideUniform = {\r\n font: sideFonts.size === 1,\r\n shape: sideShapes.size === 1,\r\n floral: sideFlorals.size === 1,\r\n color: sideColors.size === 1,\r\n };\r\n\r\n // Render side-level labels once for uniform properties\r\n currentY += renderSideUniformLabels(\r\n ctx,\r\n {\r\n font: sideUniform.font ? [...sideFonts][0] : null,\r\n shape: sideUniform.shape ? [...sideShapes][0] : null,\r\n floral: sideUniform.floral ? [...sideFlorals][0] : null,\r\n color: sideUniform.color ? [...sideColors][0] : null,\r\n },\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n\r\n // Render text groups first\r\n let sideTextCounter = 1;\r\n textGroups.forEach((group, groupIndex) => {\r\n group.positions.forEach((position, index) => {\r\n if (index === 0 && groupIndex !== 0) currentY += 50 * scaleFactor;\r\n const drawnHeight = renderText(\r\n ctx,\r\n position,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n sideTextCounter,\r\n {\r\n font: !sideUniform.font,\r\n shape: !sideUniform.shape,\r\n floral: !sideUniform.floral,\r\n color: !sideUniform.color,\r\n },\r\n scaleFactor\r\n );\r\n sideTextCounter += 1;\r\n // add padding only if something was actually drawn\r\n if (drawnHeight > 0) {\r\n currentY += drawnHeight + 40 * scaleFactor;\r\n }\r\n });\r\n });\r\n\r\n // Render ICON titles/values (no images here)\r\n currentY += 30 * scaleFactor; // minimal spacing before icon labels\r\n side.postitions.forEach((position: Position) => {\r\n if (position.type === \"ICON\") {\r\n currentY += renderIconLabels(\r\n ctx,\r\n position as any,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n currentY += 10 * scaleFactor;\r\n }\r\n });\r\n\r\n return Math.max(currentY - startY, sectionHeight);\r\n };\r\n\r\n const renderSideUniformLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n values: {\r\n font: string | null;\r\n shape: string | null;\r\n floral: string | null;\r\n color: string | null;\r\n },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 20 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n let rendered = 0;\r\n if (values.font) {\r\n const fontText = `Font: ${values.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.shape && values.shape !== \"None\") {\r\n const shapeText = `Kiểu chữ: ${values.shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.color && values.color !== \"None\") {\r\n const colorText = `Màu chỉ: ${values.color}`;\r\n // Reserve space for swatches (estimate: max 5 swatches × 200px each = 1000px)\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n // Draw swatches inline for side-level color, preserving aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor;\r\n const swatchY = result.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n const colorTokens = values.color.includes(\",\")\r\n ? values.color.split(\",\").map((s) => s.trim())\r\n : [values.color];\r\n colorTokens.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.floral && values.floral !== \"None\") {\r\n const floralText = `Mẫu hoa: ${values.floral}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (rendered > 0) cursorY += 50 * scaleFactor; // extra gap before first text line\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const renderText = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"TEXT\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n displayIndex: number,\r\n showLabels: {\r\n font: boolean;\r\n shape: boolean;\r\n floral: boolean;\r\n color: boolean;\r\n },\r\n scaleFactor: number = 1\r\n ): number => {\r\n ctx.save();\r\n\r\n // Info labels\r\n // Unified font sizing for labels and content (side title uses its own larger size)\r\n const infoLineGap = 30 * scaleFactor;\r\n const labelFontFamily = \"Arial\";\r\n // Use a unified content font size for both labels and text content\r\n const fontSize = 180 * scaleFactor;\r\n const infoFontSize = fontSize;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let currentYCursor = y;\r\n let drawnHeight = 0; // accumulate only when something is actually drawn\r\n\r\n // Text value with unified font size\r\n let displayText = position.text;\r\n if (position.change_character_to_heart && displayText.includes(\"<3\")) {\r\n displayText = displayText.replace(/<3/g, \"❤\");\r\n }\r\n\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n\r\n // Label for text line\r\n const textLabel = `Text ${displayIndex}: `;\r\n ctx.font = `bold ${fontSize}px ${labelFontFamily}`;\r\n const labelWidth = ctx.measureText(textLabel).width;\r\n ctx.fillStyle = \"#444444\";\r\n ctx.fillText(textLabel, x, currentYCursor);\r\n\r\n // Calculate available width for text content\r\n const textMaxWidth = maxWidth - labelWidth;\r\n\r\n // Handle character_colors (alternating colors)\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n // Switch to content font\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n const textHeight = fillTextWrappedMultiColor(\r\n ctx,\r\n displayText,\r\n position.character_colors,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textHeight;\r\n drawnHeight += textHeight;\r\n } else {\r\n // No color specified\r\n // Draw text in content font, black (non-bold)\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n ctx.fillStyle = COLOR_MAP[position.color ?? \"None\"] || \"#000000\";\r\n const textResult = fillTextWrapped(\r\n ctx,\r\n displayText,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textResult.height;\r\n drawnHeight += textResult.height;\r\n }\r\n\r\n // After text, print Kiểu chữ (when not uniform), then Font and Color as needed\r\n currentYCursor += infoLineGap;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.fillStyle = \"#444444\";\r\n if (showLabels.shape && position.text_shape) {\r\n const shapeLabelAfter = `Kiểu chữ: ${position.text_shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeLabelAfter,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.font && position.font) {\r\n const fontLabel = `Font: ${position.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontLabel,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.color) {\r\n let colorLabelValue = \"None\";\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n colorLabelValue = position.character_colors.join(\", \");\r\n } else if (position.color) {\r\n colorLabelValue = position.color;\r\n }\r\n if (colorLabelValue !== \"None\") {\r\n const colorLabel = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorLabel,\r\n x,\r\n currentYCursor,\r\n textMaxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n\r\n // Draw color swatch images inline with Color label for TEXT, preserve aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(infoFontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n result.lastLineY + Math.floor(infoFontSize / 2 - swatchH / 2);\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n } else if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n }\r\n }\r\n\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n }\r\n\r\n // Show floral label after color block when not uniform at side level\r\n if (showLabels.floral && position.floral_pattern) {\r\n const floralText = `Mẫu hoa: ${position.floral_pattern}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n\r\n // (Floral per-position label is printed above the text when needed; avoid duplicate after text)\r\n\r\n ctx.restore();\r\n return drawnHeight;\r\n };\r\n\r\n const renderIconLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"ICON\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 30 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n const iconText = `Icon: ${position.icon}`;\r\n const iconResult = fillTextWrapped(\r\n ctx,\r\n iconText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n // draw icon image inline with text, preserve aspect ratio; match line height\r\n const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;\r\n {\r\n const img = imageRefs.current.get(iconUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const swatchH = fontSize;\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n // Put icon on last line of wrapped text\r\n const iconX =\r\n x + Math.ceil(iconResult.lastLineWidth) + 100 * scaleFactor;\r\n const iconY =\r\n iconResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n ctx.drawImage(img, iconX, iconY, swatchW, swatchH);\r\n }\r\n }\r\n cursorY += iconResult.height;\r\n\r\n // Draw color line only when there are layer colors\r\n if (position.layer_colors && position.layer_colors.length > 0) {\r\n const colorLabelValue = position.layer_colors.join(\", \");\r\n const colorText = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const colorResult = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n\r\n // Draw color swatch images (only for icon)\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025); // 75% of previous size\r\n let swatchX =\r\n x + Math.ceil(colorResult.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n colorResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor; // spacing between swatches\r\n }\r\n });\r\n cursorY += colorResult.height;\r\n }\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const loadFont = (fontName: string): Promise<void> => {\r\n return new Promise((resolve, reject) => {\r\n // Try to load from CDN\r\n const fontUrl = `${FONT_BASE_URL}/${encodeURIComponent(fontName)}.woff2`;\r\n const fontFace = new FontFace(fontName, `url(${fontUrl})`);\r\n\r\n fontFace\r\n .load()\r\n .then((loadedFont) => {\r\n document.fonts.add(loadedFont);\r\n resolve();\r\n })\r\n .catch(() => {\r\n // Font loading failed, will use fallback\r\n console.warn(`Could not load font ${fontName} from CDN`);\r\n resolve(); // Still resolve to not block rendering\r\n });\r\n });\r\n };\r\n\r\n return (\r\n <div className={`render-embroidery${className ? ` ${className}` : \"\"}`} style={style}>\r\n <canvas ref={canvasRef} className=\"render-embroidery-canvas\" />\r\n </div>\r\n );\r\n};\r\n\r\nexport default EmbroideryQCImage;\r\n"],"names":["_jsx"],"mappings":";;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IA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QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC;AAC9B,gBAAA,OAAO,EAAE;AACX,YAAA,CAAC;iBACA,KAAK,CAAC,MAAK;;AAEV,gBAAA,OAAO,CAAC,IAAI,CAAC,uBAAuB,QAAQ,CAAA,SAAA,CAAW,CAAC;gBACxD,OAAO,EAAE,CAAC;AACZ,YAAA,CAAC,CAAC;AACN,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC;AAED,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,oBAAoB,SAAS,GAAG,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,GAAG,EAAE,CAAA,CAAE,EAAE,KAAK,EAAE,KAAK,EAAA,QAAA,EAClFA,gBAAQ,GAAG,EAAE,SAAS,EAAE,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAA,CAC3D;AAEV;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.esm.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/components/EmbroideryQCImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { useState, useEffect, useRef } from \"react\";\r\nimport { EmbroideryQCImageProps, Position } from \"../types\";\r\nimport \"./EmbroideryQCImage.css\";\r\n\r\n// Color mapping\r\nconst COLOR_MAP: Record<string, string> = {\r\n \"Army (1394)\": \"#4B5320\",\r\n Army: \"#4B5320\",\r\n \"Black (8)\": \"#000000\",\r\n Black: \"#000000\",\r\n \"Bubblegum (1309)\": \"#FFC1CC\",\r\n Bubblegum: \"#FFC1CC\",\r\n \"Carolina Blue (1274)\": \"#7BAFD4\",\r\n \"Carolina Blue\": \"#7BAFD4\",\r\n \"Celadon (1098)\": \"#ACE1AF\",\r\n Celadon: \"#ACE1AF\",\r\n \"Coffee Bean (1145)\": \"#6F4E37\",\r\n \"Coffee Bean\": \"#6F4E37\",\r\n \"Daffodil (1180)\": \"#FFFF31\",\r\n Daffodil: \"#FFFF31\",\r\n \"Dark Gray (1131)\": \"#A9A9A9\",\r\n \"Dark Gray\": \"#A9A9A9\",\r\n \"Doe Skin Beige (1344)\": \"#F5E6D3\",\r\n \"Doe Skin Beige\": \"#F5E6D3\",\r\n \"Dusty Blue (1373)\": \"#6699CC\",\r\n \"Dusty Blue\": \"#6699CC\",\r\n \"Forest Green (1397)\": \"#228B22\",\r\n \"Forest Green\": \"#228B22\",\r\n \"Gold (1425)\": \"#FFD700\",\r\n Gold: \"#FFD700\",\r\n \"Gray (1118)\": \"#808080\",\r\n Gray: \"#808080\",\r\n \"Ivory (1072)\": \"#FFFFF0\",\r\n Ivory: \"#FFFFF0\",\r\n \"Lavender (1032)\": \"#E6E6FA\",\r\n Lavender: \"#E6E6FA\",\r\n \"Light Denim (1133)\": \"#B0C4DE\",\r\n \"Light Denim\": \"#B0C4DE\",\r\n \"Light Salmon (1018)\": \"#FFA07A\",\r\n \"Light Salmon\": \"#FFA07A\",\r\n \"Maroon (1374)\": \"#800000\",\r\n Maroon: \"#800000\",\r\n \"Navy Blue (1044)\": \"#000080\",\r\n \"Navy Blue\": \"#000080\",\r\n \"Olive Green (1157)\": \"#556B2F\",\r\n \"Olive Green\": \"#556B2F\",\r\n \"Orange (1278)\": \"#FFA500\",\r\n Orange: \"#FFA500\",\r\n \"Peach Blush (1053)\": \"#FFCCCB\",\r\n \"Peach Blush\": \"#FFCCCB\",\r\n \"Pink (1148)\": \"#FFC0CB\",\r\n Pink: \"#FFC0CB\",\r\n \"Purple (1412)\": \"#800080\",\r\n Purple: \"#800080\",\r\n \"Red (1037)\": \"#FF0000\",\r\n Red: \"#FF0000\",\r\n \"Silver Sage (1396)\": \"#A8A8A8\",\r\n \"Silver Sage\": \"#A8A8A8\",\r\n \"Summer Sky (1432)\": \"#87CEEB\",\r\n \"Summer Sky\": \"#87CEEB\",\r\n \"Terra Cotta (1477)\": \"#E2725B\",\r\n \"Terra Cotta\": \"#E2725B\",\r\n \"Sand (1055)\": \"#F4A460\",\r\n Sand: \"#F4A460\",\r\n \"White (9)\": \"#FFFFFF\",\r\n White: \"#FFFFFF\",\r\n};\r\n\r\nconst FONT_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/fonts\";\r\nconst ICON_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/icons\";\r\nconst FLORAL_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/florals\";\r\nconst THREAD_COLOR_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/thread-colors\";\r\n\r\nconst EmbroideryQCImage: React.FC<EmbroideryQCImageProps> = ({\r\n config,\r\n className = \"\",\r\n style = {},\r\n}) => {\r\n const [canvasSize] = useState({ width: 4200, height: 4800 });\r\n const [loadedFonts, setLoadedFonts] = useState<Set<string>>(new Set());\r\n const [imagesLoaded, setImagesLoaded] = useState(0);\r\n const canvasRef = useRef<HTMLCanvasElement>(null);\r\n const imageRefs = useRef<Map<string, HTMLImageElement>>(new Map());\r\n\r\n // Load fonts\r\n useEffect(() => {\r\n const loadFonts = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n const fontsToLoad = new Set<string>();\r\n config.sides.forEach((side) => {\r\n side.positions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.font) {\r\n fontsToLoad.add(position.font);\r\n }\r\n });\r\n });\r\n\r\n for (const fontName of fontsToLoad) {\r\n if (loadedFonts.has(fontName)) continue;\r\n\r\n try {\r\n await loadFont(fontName);\r\n setLoadedFonts((prev) => new Set(prev).add(fontName));\r\n } catch (error) {\r\n console.warn(`Could not load font ${fontName}:`, error);\r\n }\r\n }\r\n };\r\n\r\n loadFonts();\r\n }, [config.sides, loadedFonts]);\r\n\r\n // Load images\r\n useEffect(() => {\r\n const loadImages = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n // Load mockup image (not background). It will be drawn at bottom-right.\r\n if (config.image_url) {\r\n // Try with CORS first. If it fails (no CORS headers), retry without CORS\r\n const loadMockup = (useCors: boolean) => {\r\n const img = new Image();\r\n if (useCors) img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n imageRefs.current.set(\"mockup\", img);\r\n setImagesLoaded((prev) => prev + 1);\r\n };\r\n img.onerror = () => {\r\n if (useCors) {\r\n // Retry without CORS; canvas may become tainted on export\r\n loadMockup(false);\r\n }\r\n };\r\n img.src = config.image_url as string;\r\n };\r\n loadMockup(true);\r\n }\r\n\r\n // Load icons\r\n config.sides.forEach((side) => {\r\n side.positions.forEach((position) => {\r\n if (position.type === \"ICON\" && position.icon !== 0) {\r\n const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;\r\n if (!imageRefs.current.has(iconUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = iconUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(iconUrl, img);\r\n }\r\n }\r\n\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!imageRefs.current.has(floralUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = floralUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(floralUrl, img);\r\n }\r\n }\r\n\r\n // Load thread color images for TEXT positions\r\n if (position.type === \"TEXT\") {\r\n // Load color image if position has color\r\n if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n }\r\n\r\n // Load character color images\r\n if (\r\n position.character_colors &&\r\n position.character_colors.length > 0\r\n ) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n }\r\n\r\n // Load thread color images for ICON positions\r\n if (position.type === \"ICON\" && position.layer_colors) {\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n });\r\n });\r\n };\r\n\r\n loadImages();\r\n }, [config]);\r\n\r\n // Render canvas\r\n useEffect(() => {\r\n const renderCanvas = () => {\r\n if (!canvasRef.current || !config.sides || config.sides.length === 0) {\r\n return;\r\n }\r\n\r\n const canvas = canvasRef.current;\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return;\r\n\r\n canvas.width = canvasSize.width;\r\n canvas.height = canvasSize.height;\r\n\r\n // Clear with white background\r\n ctx.fillStyle = \"#FFFFFF\";\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n\r\n // Collect floral images (for later drawing)\r\n const floralAssets: HTMLImageElement[] = [];\r\n const seenFlorals = new Set<string>();\r\n if (config.sides) {\r\n config.sides.forEach((side) => {\r\n side.positions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!seenFlorals.has(floralUrl)) {\r\n const img = imageRefs.current.get(floralUrl);\r\n if (img && img.complete && img.naturalWidth > 0) {\r\n floralAssets.push(img);\r\n seenFlorals.add(floralUrl);\r\n }\r\n }\r\n }\r\n });\r\n });\r\n }\r\n\r\n // Helper function to draw mockup and florals\r\n const drawMockupAndFlorals = () => {\r\n const mockupImg = imageRefs.current.get(\"mockup\");\r\n const margin = 40; // small padding\r\n let mockupBox: { x: number; y: number; w: number; h: number } | null =\r\n null;\r\n if (mockupImg && mockupImg.complete && mockupImg.naturalWidth > 0) {\r\n const maxTargetWidth = Math.min(1800, canvas.width * 0.375);\r\n const maxTargetHeight = canvas.height * 0.375;\r\n const scale = Math.min(\r\n maxTargetWidth / mockupImg.naturalWidth,\r\n maxTargetHeight / mockupImg.naturalHeight\r\n );\r\n const targetWidth = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalWidth * scale)\r\n );\r\n const targetHeight = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalHeight * scale)\r\n );\r\n const targetX = canvas.width - margin - targetWidth;\r\n const targetY = canvas.height - margin - targetHeight;\r\n mockupBox = {\r\n x: targetX,\r\n y: targetY,\r\n w: targetWidth,\r\n h: targetHeight,\r\n };\r\n ctx.drawImage(mockupImg, targetX, targetY, targetWidth, targetHeight);\r\n }\r\n\r\n // Draw florals to the left of mockup\r\n if (mockupBox && floralAssets.length > 0) {\r\n const spacing = 300;\r\n const targetHeight = mockupBox.h;\r\n const floralFixedH = Math.min(900, targetHeight);\r\n let currentX = mockupBox.x - spacing;\r\n for (let i = floralAssets.length - 1; i >= 0; i--) {\r\n const img = floralAssets[i];\r\n const ratio = img.naturalWidth / Math.max(1, img.naturalHeight);\r\n const h = floralFixedH;\r\n const w = Math.max(1, Math.floor(h * ratio));\r\n currentX -= w;\r\n const y = mockupBox.y + (targetHeight - h);\r\n ctx.drawImage(img, currentX, y, w, h);\r\n currentX -= spacing;\r\n }\r\n }\r\n };\r\n\r\n // New approach: Draw images first (bottom layer), then text on top\r\n // This allows text to overlay images when needed\r\n\r\n // Pass 1: Measure actual height with original size (use offscreen canvas for measurement)\r\n const measureCanvas = document.createElement(\"canvas\");\r\n measureCanvas.width = canvas.width;\r\n measureCanvas.height = canvas.height;\r\n const measureCtx = measureCanvas.getContext(\"2d\");\r\n if (!measureCtx) return;\r\n\r\n // Set up measurement context\r\n measureCtx.font = ctx.font;\r\n measureCtx.textAlign = ctx.textAlign;\r\n measureCtx.textBaseline = ctx.textBaseline;\r\n\r\n let measureY = 40;\r\n const measureSpacing = 100;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n measureCtx,\r\n side,\r\n measureY,\r\n canvas.width,\r\n 1\r\n );\r\n measureY += sideHeight + measureSpacing;\r\n });\r\n const totalMeasuredHeight = measureY; // Total height used\r\n\r\n // Calculate scale factor - only scale down when necessary\r\n // Keep original font sizes (no scale up) - font size is the maximum\r\n const topPadding = 40;\r\n // No bottom padding - content can go to bottom, mockup will overlay\r\n const targetContentHeight = canvas.height - topPadding;\r\n\r\n // Only scale down if content exceeds canvas height\r\n // Never scale up - preserve original font sizes\r\n let scaleFactor = 1;\r\n if (totalMeasuredHeight > targetContentHeight) {\r\n // Scale down to fit exactly\r\n scaleFactor = targetContentHeight / totalMeasuredHeight;\r\n scaleFactor = Math.max(0.5, scaleFactor); // Minimum scale to prevent tiny fonts\r\n }\r\n // If content fits, keep scaleFactor = 1 (original font sizes)\r\n\r\n // Draw mockup and florals first (bottom layer)\r\n drawMockupAndFlorals();\r\n\r\n // Draw content on top (top layer) - text will overlay images if needed\r\n let currentY = topPadding * scaleFactor;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n ctx,\r\n side,\r\n currentY,\r\n canvas.width,\r\n scaleFactor\r\n );\r\n currentY += sideHeight + measureSpacing * scaleFactor;\r\n });\r\n };\r\n\r\n // Delay rendering to ensure fonts and images are loaded\r\n const timer = setTimeout(renderCanvas, 100);\r\n return () => clearTimeout(timer);\r\n }, [config, canvasSize, loadedFonts, imagesLoaded]);\r\n\r\n // Helper function to wrap and draw text with word wrapping\r\n // Returns: { height: number, lastLineWidth: number, lastLineY: number }\r\n const fillTextWrapped = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): { height: number; lastLineWidth: number; lastLineY: number } => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n let currentLine = words[0];\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n currentLine = word;\r\n } else {\r\n currentLine = testLine;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line) => {\r\n ctx.fillText(line, x, currentY);\r\n currentY += lineHeight;\r\n });\r\n\r\n const lastLineWidth = ctx.measureText(lines[lines.length - 1]).width;\r\n const lastLineY = y + (lines.length - 1) * lineHeight;\r\n\r\n return {\r\n height: lines.length * lineHeight,\r\n lastLineWidth,\r\n lastLineY,\r\n };\r\n };\r\n\r\n // Helper to wrap and draw multi-color text (for character_colors)\r\n const fillTextWrappedMultiColor = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n colors: string[],\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): number => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n const lineStartIndices: number[] = [0];\r\n let currentLine = words[0];\r\n let currentCharIndex = words[0].length;\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n lineStartIndices.push(currentCharIndex + 1); // +1 for space\r\n currentLine = word;\r\n currentCharIndex += word.length + 1;\r\n } else {\r\n currentLine = testLine;\r\n currentCharIndex += word.length + 1;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line, lineIdx) => {\r\n let currentX = x;\r\n const startCharIdx = lineIdx > 0 ? lineStartIndices[lineIdx] : 0;\r\n for (let i = 0; i < line.length; i++) {\r\n const char = line[i];\r\n const globalCharIdx = startCharIdx + i;\r\n const colorIndex = globalCharIdx % colors.length;\r\n const color = colors[colorIndex];\r\n ctx.fillStyle = COLOR_MAP[color] || \"#000000\";\r\n ctx.fillText(char, currentX, currentY);\r\n currentX += ctx.measureText(char).width;\r\n }\r\n currentY += lineHeight;\r\n });\r\n\r\n return lines.length * lineHeight;\r\n };\r\n\r\n const renderSide = (\r\n ctx: CanvasRenderingContext2D,\r\n side: any,\r\n startY: number,\r\n width: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n let currentY = startY;\r\n const padding = 40 * scaleFactor;\r\n const sideWidth = width - 2 * padding;\r\n const sectionHeight = 200 * scaleFactor;\r\n\r\n // No background section anymore - just white background\r\n\r\n // Group positions by common properties for optimization\r\n const textGroups: Array<{\r\n positions: Array<Position & { type: \"TEXT\" }>;\r\n properties: any;\r\n }> = [];\r\n let currentGroup: Array<Position & { type: \"TEXT\" }> | null = null;\r\n let currentProps: any = null;\r\n\r\n side.positions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") {\r\n if (\r\n !currentGroup ||\r\n currentProps.font !== position.font ||\r\n currentProps.text_shape !== position.text_shape ||\r\n currentProps.color !== position.color ||\r\n currentProps.character_colors?.join(\",\") !==\r\n position.character_colors?.join(\",\")\r\n ) {\r\n // Start new group\r\n if (currentGroup) {\r\n textGroups.push({\r\n positions: currentGroup,\r\n properties: currentProps,\r\n });\r\n }\r\n currentGroup = [position];\r\n currentProps = {\r\n font: position.font,\r\n text_shape: position.text_shape,\r\n color: position.color,\r\n character_colors: position.character_colors,\r\n };\r\n } else {\r\n currentGroup.push(position);\r\n }\r\n }\r\n });\r\n\r\n if (currentGroup) {\r\n textGroups.push({ positions: currentGroup, properties: currentProps });\r\n }\r\n\r\n // Draw side header\r\n ctx.save();\r\n const headerFontSize = 200 * scaleFactor;\r\n ctx.font = `bold ${headerFontSize}px Times New Roman`;\r\n ctx.fillStyle = \"#000000\";\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n const headerResult = fillTextWrapped(\r\n ctx,\r\n side.print_side.toUpperCase(),\r\n padding,\r\n currentY,\r\n sideWidth,\r\n headerFontSize\r\n );\r\n currentY += headerResult.height + 50 * scaleFactor;\r\n ctx.restore();\r\n\r\n // Compute side-level uniform properties across all TEXT positions\r\n const allTextPositions: Array<Position & { type: \"TEXT\" }> = [];\r\n side.positions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") allTextPositions.push(position as any);\r\n });\r\n\r\n const sideFonts = new Set(allTextPositions.map((p) => (p as any).font));\r\n const sideShapes = new Set(\r\n allTextPositions.map((p) => (p as any).text_shape)\r\n );\r\n const sideFlorals = new Set(\r\n allTextPositions.map((p) => (p as any).floral_pattern ?? \"None\")\r\n );\r\n const colorKeyOf = (p: any) =>\r\n p.character_colors && p.character_colors.length > 0\r\n ? p.character_colors.join(\",\")\r\n : p.color ?? \"None\";\r\n const sideColors = new Set(allTextPositions.map((p) => colorKeyOf(p)));\r\n\r\n const sideUniform = {\r\n font: sideFonts.size === 1,\r\n shape: sideShapes.size === 1,\r\n floral: sideFlorals.size === 1,\r\n color: sideColors.size === 1,\r\n };\r\n\r\n // Render side-level labels once for uniform properties\r\n currentY += renderSideUniformLabels(\r\n ctx,\r\n {\r\n font: sideUniform.font ? [...sideFonts][0] : null,\r\n shape: sideUniform.shape ? [...sideShapes][0] : null,\r\n floral: sideUniform.floral ? [...sideFlorals][0] : null,\r\n color: sideUniform.color ? [...sideColors][0] : null,\r\n },\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n\r\n // Render text groups first\r\n let sideTextCounter = 1;\r\n textGroups.forEach((group, groupIndex) => {\r\n group.positions.forEach((position, index) => {\r\n if (index === 0 && groupIndex !== 0) currentY += 50 * scaleFactor;\r\n const drawnHeight = renderText(\r\n ctx,\r\n position,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n sideTextCounter,\r\n {\r\n font: !sideUniform.font,\r\n shape: !sideUniform.shape,\r\n floral: !sideUniform.floral,\r\n color: !sideUniform.color,\r\n },\r\n scaleFactor\r\n );\r\n sideTextCounter += 1;\r\n // add padding only if something was actually drawn\r\n if (drawnHeight > 0) {\r\n currentY += drawnHeight + 40 * scaleFactor;\r\n }\r\n });\r\n });\r\n\r\n // Render ICON titles/values (no images here)\r\n currentY += 30 * scaleFactor; // minimal spacing before icon labels\r\n side.positions.forEach((position: Position) => {\r\n if (position.type === \"ICON\") {\r\n currentY += renderIconLabels(\r\n ctx,\r\n position as any,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n currentY += 10 * scaleFactor;\r\n }\r\n });\r\n\r\n return Math.max(currentY - startY, sectionHeight);\r\n };\r\n\r\n const renderSideUniformLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n values: {\r\n font: string | null;\r\n shape: string | null;\r\n floral: string | null;\r\n color: string | null;\r\n },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 20 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n let rendered = 0;\r\n if (values.font) {\r\n const fontText = `Font: ${values.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.shape && values.shape !== \"None\") {\r\n const shapeText = `Kiểu chữ: ${values.shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.color && values.color !== \"None\") {\r\n const colorText = `Màu chỉ: ${values.color}`;\r\n // Reserve space for swatches (estimate: max 5 swatches × 200px each = 1000px)\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n // Draw swatches inline for side-level color, preserving aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor;\r\n const swatchY = result.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n const colorTokens = values.color.includes(\",\")\r\n ? values.color.split(\",\").map((s) => s.trim())\r\n : [values.color];\r\n colorTokens.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.floral && values.floral !== \"None\") {\r\n const floralText = `Mẫu hoa: ${values.floral}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (rendered > 0) cursorY += 50 * scaleFactor; // extra gap before first text line\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const renderText = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"TEXT\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n displayIndex: number,\r\n showLabels: {\r\n font: boolean;\r\n shape: boolean;\r\n floral: boolean;\r\n color: boolean;\r\n },\r\n scaleFactor: number = 1\r\n ): number => {\r\n ctx.save();\r\n\r\n // Info labels\r\n // Unified font sizing for labels and content (side title uses its own larger size)\r\n const infoLineGap = 30 * scaleFactor;\r\n const labelFontFamily = \"Arial\";\r\n // Use a unified content font size for both labels and text content\r\n const fontSize = 180 * scaleFactor;\r\n const infoFontSize = fontSize;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let currentYCursor = y;\r\n let drawnHeight = 0; // accumulate only when something is actually drawn\r\n\r\n // Text value with unified font size\r\n let displayText = position.text;\r\n if (position.change_character_to_heart && displayText.includes(\"<3\")) {\r\n displayText = displayText.replace(/<3/g, \"❤\");\r\n }\r\n\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n\r\n // Label for text line\r\n const textLabel = `Text ${displayIndex}: `;\r\n ctx.font = `bold ${fontSize}px ${labelFontFamily}`;\r\n const labelWidth = ctx.measureText(textLabel).width;\r\n ctx.fillStyle = \"#444444\";\r\n ctx.fillText(textLabel, x, currentYCursor);\r\n\r\n // Calculate available width for text content\r\n const textMaxWidth = maxWidth - labelWidth;\r\n\r\n // Handle character_colors (alternating colors)\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n // Switch to content font\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n const textHeight = fillTextWrappedMultiColor(\r\n ctx,\r\n displayText,\r\n position.character_colors,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textHeight;\r\n drawnHeight += textHeight;\r\n } else {\r\n // No color specified\r\n // Draw text in content font, black (non-bold)\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n ctx.fillStyle = COLOR_MAP[position.color ?? \"None\"] || \"#000000\";\r\n const textResult = fillTextWrapped(\r\n ctx,\r\n displayText,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textResult.height;\r\n drawnHeight += textResult.height;\r\n }\r\n\r\n // After text, print Kiểu chữ (when not uniform), then Font and Color as needed\r\n currentYCursor += infoLineGap;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.fillStyle = \"#444444\";\r\n if (showLabels.shape && position.text_shape) {\r\n const shapeLabelAfter = `Kiểu chữ: ${position.text_shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeLabelAfter,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.font && position.font) {\r\n const fontLabel = `Font: ${position.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontLabel,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.color) {\r\n let colorLabelValue = \"None\";\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n colorLabelValue = position.character_colors.join(\", \");\r\n } else if (position.color) {\r\n colorLabelValue = position.color;\r\n }\r\n if (colorLabelValue !== \"None\") {\r\n const colorLabel = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorLabel,\r\n x,\r\n currentYCursor,\r\n textMaxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n\r\n // Draw color swatch images inline with Color label for TEXT, preserve aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(infoFontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n result.lastLineY + Math.floor(infoFontSize / 2 - swatchH / 2);\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n } else if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n }\r\n }\r\n\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n }\r\n\r\n // Show floral label after color block when not uniform at side level\r\n if (showLabels.floral && position.floral_pattern) {\r\n const floralText = `Mẫu hoa: ${position.floral_pattern}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n\r\n // (Floral per-position label is printed above the text when needed; avoid duplicate after text)\r\n\r\n ctx.restore();\r\n return drawnHeight;\r\n };\r\n\r\n const renderIconLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"ICON\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 30 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n const iconText = position.icon === 0 \r\n ? `Icon: icon mặc định theo file thêu` \r\n : `Icon: ${position.icon}`;\r\n const iconResult = fillTextWrapped(\r\n ctx,\r\n iconText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n // draw icon image inline with text, preserve aspect ratio; match line height\r\n if (position.icon !== 0) {\r\n const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;\r\n const img = imageRefs.current.get(iconUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const swatchH = fontSize;\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n // Put icon on last line of wrapped text\r\n const iconX =\r\n x + Math.ceil(iconResult.lastLineWidth) + 100 * scaleFactor;\r\n const iconY =\r\n iconResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n ctx.drawImage(img, iconX, iconY, swatchW, swatchH);\r\n }\r\n }\r\n cursorY += iconResult.height;\r\n\r\n // Draw color line only when there are layer colors\r\n if (position.layer_colors && position.layer_colors.length > 0) {\r\n const colorLabelValue = position.layer_colors.join(\", \");\r\n const colorText = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const colorResult = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n\r\n // Draw color swatch images (only for icon)\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025); // 75% of previous size\r\n let swatchX =\r\n x + Math.ceil(colorResult.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n colorResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor; // spacing between swatches\r\n }\r\n });\r\n cursorY += colorResult.height;\r\n }\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const loadFont = (fontName: string): Promise<void> => {\r\n return new Promise((resolve, reject) => {\r\n // Try to load from CDN\r\n const fontUrl = `${FONT_BASE_URL}/${encodeURIComponent(fontName)}.woff2`;\r\n const fontFace = new FontFace(fontName, `url(${fontUrl})`);\r\n\r\n fontFace\r\n .load()\r\n .then((loadedFont) => {\r\n document.fonts.add(loadedFont);\r\n resolve();\r\n })\r\n .catch(() => {\r\n // Font loading failed, will use fallback\r\n console.warn(`Could not load font ${fontName} from CDN`);\r\n resolve(); // Still resolve to not block rendering\r\n });\r\n });\r\n };\r\n\r\n return (\r\n <div className={`render-embroidery${className ? `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SAAS,CAAA,CAAE,GAAG,EAAE,CAAA,CAAE,EAAE,KAAK,EAAE,KAAK,EAAA,QAAA,EAClFA,gBAAQ,GAAG,EAAE,SAAS,EAAE,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAA,CAC3D;AAEV;;;;","x_google_ignoreList":[0]}
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
113
113
  return;
114
114
  const fontsToLoad = new Set();
115
115
  config.sides.forEach((side) => {
116
- side.postitions.forEach((position) => {
116
+ side.positions.forEach((position) => {
117
117
  if (position.type === "TEXT" && position.font) {
118
118
  fontsToLoad.add(position.font);
119
119
  }
@@ -161,9 +161,9 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
161
161
  }
162
162
  // Load icons
163
163
  config.sides.forEach((side) => {
164
- side.postitions.forEach((position) => {
165
- if (position.type === "ICON") {
166
- const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;
164
+ side.positions.forEach((position) => {
165
+ if (position.type === "ICON" && position.icon !== 0) {
166
+ const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;
167
167
  if (!imageRefs.current.has(iconUrl)) {
168
168
  const img = new Image();
169
169
  img.crossOrigin = "anonymous";
@@ -248,7 +248,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
248
248
  const seenFlorals = new Set();
249
249
  if (config.sides) {
250
250
  config.sides.forEach((side) => {
251
- side.postitions.forEach((position) => {
251
+ side.positions.forEach((position) => {
252
252
  if (position.type === "TEXT" && position.floral_pattern) {
253
253
  const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;
254
254
  if (!seenFlorals.has(floralUrl)) {
@@ -430,7 +430,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
430
430
  const textGroups = [];
431
431
  let currentGroup = null;
432
432
  let currentProps = null;
433
- side.postitions.forEach((position) => {
433
+ side.positions.forEach((position) => {
434
434
  if (position.type === "TEXT") {
435
435
  if (!currentGroup ||
436
436
  currentProps.font !== position.font ||
@@ -473,7 +473,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
473
473
  ctx.restore();
474
474
  // Compute side-level uniform properties across all TEXT positions
475
475
  const allTextPositions = [];
476
- side.postitions.forEach((position) => {
476
+ side.positions.forEach((position) => {
477
477
  if (position.type === "TEXT")
478
478
  allTextPositions.push(position);
479
479
  });
@@ -518,7 +518,7 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
518
518
  });
519
519
  // Render ICON titles/values (no images here)
520
520
  currentY += 30 * scaleFactor; // minimal spacing before icon labels
521
- side.postitions.forEach((position) => {
521
+ side.positions.forEach((position) => {
522
522
  if (position.type === "ICON") {
523
523
  currentY += renderIconLabels(ctx, position, padding, currentY, sideWidth, scaleFactor);
524
524
  currentY += 10 * scaleFactor;
@@ -715,11 +715,13 @@ const EmbroideryQCImage = ({ config, className = "", style = {}, }) => {
715
715
  ctx.textBaseline = "top";
716
716
  ctx.fillStyle = "#444444";
717
717
  let cursorY = y;
718
- const iconText = `Icon: ${position.icon}`;
718
+ const iconText = position.icon === 0
719
+ ? `Icon: icon mặc định theo file thêu`
720
+ : `Icon: ${position.icon}`;
719
721
  const iconResult = fillTextWrapped(ctx, iconText, x, cursorY, maxWidth, fontSize + lineGap);
720
722
  // draw icon image inline with text, preserve aspect ratio; match line height
721
- const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;
722
- {
723
+ if (position.icon !== 0) {
724
+ const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;
723
725
  const img = imageRefs.current.get(iconUrl);
724
726
  if (img && img.complete && img.naturalHeight > 0) {
725
727
  const swatchH = fontSize;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/components/EmbroideryQCImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { useState, useEffect, useRef } from \"react\";\r\nimport { EmbroideryQCImageProps, Position } from \"../types\";\r\nimport \"./EmbroideryQCImage.css\";\r\n\r\n// Color mapping\r\nconst COLOR_MAP: Record<string, string> = {\r\n \"Army (1394)\": \"#4B5320\",\r\n Army: \"#4B5320\",\r\n \"Black (8)\": \"#000000\",\r\n Black: \"#000000\",\r\n \"Bubblegum (1309)\": \"#FFC1CC\",\r\n Bubblegum: \"#FFC1CC\",\r\n \"Carolina Blue (1274)\": \"#7BAFD4\",\r\n \"Carolina Blue\": \"#7BAFD4\",\r\n \"Celadon (1098)\": \"#ACE1AF\",\r\n Celadon: \"#ACE1AF\",\r\n \"Coffee Bean (1145)\": \"#6F4E37\",\r\n \"Coffee Bean\": \"#6F4E37\",\r\n \"Daffodil (1180)\": \"#FFFF31\",\r\n Daffodil: \"#FFFF31\",\r\n \"Dark Gray (1131)\": \"#A9A9A9\",\r\n \"Dark Gray\": \"#A9A9A9\",\r\n \"Doe Skin Beige (1344)\": \"#F5E6D3\",\r\n \"Doe Skin Beige\": \"#F5E6D3\",\r\n \"Dusty Blue (1373)\": \"#6699CC\",\r\n \"Dusty Blue\": \"#6699CC\",\r\n \"Forest Green (1397)\": \"#228B22\",\r\n \"Forest Green\": \"#228B22\",\r\n \"Gold (1425)\": \"#FFD700\",\r\n Gold: \"#FFD700\",\r\n \"Gray (1118)\": \"#808080\",\r\n Gray: \"#808080\",\r\n \"Ivory (1072)\": \"#FFFFF0\",\r\n Ivory: \"#FFFFF0\",\r\n \"Lavender (1032)\": \"#E6E6FA\",\r\n Lavender: \"#E6E6FA\",\r\n \"Light Denim (1133)\": \"#B0C4DE\",\r\n \"Light Denim\": \"#B0C4DE\",\r\n \"Light Salmon (1018)\": \"#FFA07A\",\r\n \"Light Salmon\": \"#FFA07A\",\r\n \"Maroon (1374)\": \"#800000\",\r\n Maroon: \"#800000\",\r\n \"Navy Blue (1044)\": \"#000080\",\r\n \"Navy Blue\": \"#000080\",\r\n \"Olive Green (1157)\": \"#556B2F\",\r\n \"Olive Green\": \"#556B2F\",\r\n \"Orange (1278)\": \"#FFA500\",\r\n Orange: \"#FFA500\",\r\n \"Peach Blush (1053)\": \"#FFCCCB\",\r\n \"Peach Blush\": \"#FFCCCB\",\r\n \"Pink (1148)\": \"#FFC0CB\",\r\n Pink: \"#FFC0CB\",\r\n \"Purple (1412)\": \"#800080\",\r\n Purple: \"#800080\",\r\n \"Red (1037)\": \"#FF0000\",\r\n Red: \"#FF0000\",\r\n \"Silver Sage (1396)\": \"#A8A8A8\",\r\n \"Silver Sage\": \"#A8A8A8\",\r\n \"Summer Sky (1432)\": \"#87CEEB\",\r\n \"Summer Sky\": \"#87CEEB\",\r\n \"Terra Cotta (1477)\": \"#E2725B\",\r\n \"Terra Cotta\": \"#E2725B\",\r\n \"Sand (1055)\": \"#F4A460\",\r\n Sand: \"#F4A460\",\r\n \"White (9)\": \"#FFFFFF\",\r\n White: \"#FFFFFF\",\r\n};\r\n\r\nconst FONT_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/fonts\";\r\nconst ICON_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/icons\";\r\nconst FLORAL_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/florals\";\r\nconst THREAD_COLOR_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/thread-colors\";\r\n\r\nconst EmbroideryQCImage: React.FC<EmbroideryQCImageProps> = ({\r\n config,\r\n className = \"\",\r\n style = {},\r\n}) => {\r\n const [canvasSize] = useState({ width: 4200, height: 4800 });\r\n const [loadedFonts, setLoadedFonts] = useState<Set<string>>(new Set());\r\n const [imagesLoaded, setImagesLoaded] = useState(0);\r\n const canvasRef = useRef<HTMLCanvasElement>(null);\r\n const imageRefs = useRef<Map<string, HTMLImageElement>>(new Map());\r\n\r\n // Load fonts\r\n useEffect(() => {\r\n const loadFonts = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n const fontsToLoad = new Set<string>();\r\n config.sides.forEach((side) => {\r\n side.postitions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.font) {\r\n fontsToLoad.add(position.font);\r\n }\r\n });\r\n });\r\n\r\n for (const fontName of fontsToLoad) {\r\n if (loadedFonts.has(fontName)) continue;\r\n\r\n try {\r\n await loadFont(fontName);\r\n setLoadedFonts((prev) => new Set(prev).add(fontName));\r\n } catch (error) {\r\n console.warn(`Could not load font ${fontName}:`, error);\r\n }\r\n }\r\n };\r\n\r\n loadFonts();\r\n }, [config.sides, loadedFonts]);\r\n\r\n // Load images\r\n useEffect(() => {\r\n const loadImages = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n // Load mockup image (not background). It will be drawn at bottom-right.\r\n if (config.image_url) {\r\n // Try with CORS first. If it fails (no CORS headers), retry without CORS\r\n const loadMockup = (useCors: boolean) => {\r\n const img = new Image();\r\n if (useCors) img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n imageRefs.current.set(\"mockup\", img);\r\n setImagesLoaded((prev) => prev + 1);\r\n };\r\n img.onerror = () => {\r\n if (useCors) {\r\n // Retry without CORS; canvas may become tainted on export\r\n loadMockup(false);\r\n }\r\n };\r\n img.src = config.image_url as string;\r\n };\r\n loadMockup(true);\r\n }\r\n\r\n // Load icons\r\n config.sides.forEach((side) => {\r\n side.postitions.forEach((position) => {\r\n if (position.type === \"ICON\") {\r\n const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;\r\n if (!imageRefs.current.has(iconUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = iconUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(iconUrl, img);\r\n }\r\n }\r\n\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!imageRefs.current.has(floralUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = floralUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(floralUrl, img);\r\n }\r\n }\r\n\r\n // Load thread color images for TEXT positions\r\n if (position.type === \"TEXT\") {\r\n // Load color image if position has color\r\n if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n }\r\n\r\n // Load character color images\r\n if (\r\n position.character_colors &&\r\n position.character_colors.length > 0\r\n ) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n }\r\n\r\n // Load thread color images for ICON positions\r\n if (position.type === \"ICON\" && position.layer_colors) {\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n });\r\n });\r\n };\r\n\r\n loadImages();\r\n }, [config]);\r\n\r\n // Render canvas\r\n useEffect(() => {\r\n const renderCanvas = () => {\r\n if (!canvasRef.current || !config.sides || config.sides.length === 0) {\r\n return;\r\n }\r\n\r\n const canvas = canvasRef.current;\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return;\r\n\r\n canvas.width = canvasSize.width;\r\n canvas.height = canvasSize.height;\r\n\r\n // Clear with white background\r\n ctx.fillStyle = \"#FFFFFF\";\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n\r\n // Collect floral images (for later drawing)\r\n const floralAssets: HTMLImageElement[] = [];\r\n const seenFlorals = new Set<string>();\r\n if (config.sides) {\r\n config.sides.forEach((side) => {\r\n side.postitions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!seenFlorals.has(floralUrl)) {\r\n const img = imageRefs.current.get(floralUrl);\r\n if (img && img.complete && img.naturalWidth > 0) {\r\n floralAssets.push(img);\r\n seenFlorals.add(floralUrl);\r\n }\r\n }\r\n }\r\n });\r\n });\r\n }\r\n\r\n // Helper function to draw mockup and florals\r\n const drawMockupAndFlorals = () => {\r\n const mockupImg = imageRefs.current.get(\"mockup\");\r\n const margin = 40; // small padding\r\n let mockupBox: { x: number; y: number; w: number; h: number } | null =\r\n null;\r\n if (mockupImg && mockupImg.complete && mockupImg.naturalWidth > 0) {\r\n const maxTargetWidth = Math.min(1800, canvas.width * 0.375);\r\n const maxTargetHeight = canvas.height * 0.375;\r\n const scale = Math.min(\r\n maxTargetWidth / mockupImg.naturalWidth,\r\n maxTargetHeight / mockupImg.naturalHeight\r\n );\r\n const targetWidth = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalWidth * scale)\r\n );\r\n const targetHeight = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalHeight * scale)\r\n );\r\n const targetX = canvas.width - margin - targetWidth;\r\n const targetY = canvas.height - margin - targetHeight;\r\n mockupBox = {\r\n x: targetX,\r\n y: targetY,\r\n w: targetWidth,\r\n h: targetHeight,\r\n };\r\n ctx.drawImage(mockupImg, targetX, targetY, targetWidth, targetHeight);\r\n }\r\n\r\n // Draw florals to the left of mockup\r\n if (mockupBox && floralAssets.length > 0) {\r\n const spacing = 300;\r\n const targetHeight = mockupBox.h;\r\n const floralFixedH = Math.min(900, targetHeight);\r\n let currentX = mockupBox.x - spacing;\r\n for (let i = floralAssets.length - 1; i >= 0; i--) {\r\n const img = floralAssets[i];\r\n const ratio = img.naturalWidth / Math.max(1, img.naturalHeight);\r\n const h = floralFixedH;\r\n const w = Math.max(1, Math.floor(h * ratio));\r\n currentX -= w;\r\n const y = mockupBox.y + (targetHeight - h);\r\n ctx.drawImage(img, currentX, y, w, h);\r\n currentX -= spacing;\r\n }\r\n }\r\n };\r\n\r\n // New approach: Draw images first (bottom layer), then text on top\r\n // This allows text to overlay images when needed\r\n\r\n // Pass 1: Measure actual height with original size (use offscreen canvas for measurement)\r\n const measureCanvas = document.createElement(\"canvas\");\r\n measureCanvas.width = canvas.width;\r\n measureCanvas.height = canvas.height;\r\n const measureCtx = measureCanvas.getContext(\"2d\");\r\n if (!measureCtx) return;\r\n\r\n // Set up measurement context\r\n measureCtx.font = ctx.font;\r\n measureCtx.textAlign = ctx.textAlign;\r\n measureCtx.textBaseline = ctx.textBaseline;\r\n\r\n let measureY = 40;\r\n const measureSpacing = 100;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n measureCtx,\r\n side,\r\n measureY,\r\n canvas.width,\r\n 1\r\n );\r\n measureY += sideHeight + measureSpacing;\r\n });\r\n const totalMeasuredHeight = measureY; // Total height used\r\n\r\n // Calculate scale factor - only scale down when necessary\r\n // Keep original font sizes (no scale up) - font size is the maximum\r\n const topPadding = 40;\r\n // No bottom padding - content can go to bottom, mockup will overlay\r\n const targetContentHeight = canvas.height - topPadding;\r\n\r\n // Only scale down if content exceeds canvas height\r\n // Never scale up - preserve original font sizes\r\n let scaleFactor = 1;\r\n if (totalMeasuredHeight > targetContentHeight) {\r\n // Scale down to fit exactly\r\n scaleFactor = targetContentHeight / totalMeasuredHeight;\r\n scaleFactor = Math.max(0.5, scaleFactor); // Minimum scale to prevent tiny fonts\r\n }\r\n // If content fits, keep scaleFactor = 1 (original font sizes)\r\n\r\n // Draw mockup and florals first (bottom layer)\r\n drawMockupAndFlorals();\r\n\r\n // Draw content on top (top layer) - text will overlay images if needed\r\n let currentY = topPadding * scaleFactor;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n ctx,\r\n side,\r\n currentY,\r\n canvas.width,\r\n scaleFactor\r\n );\r\n currentY += sideHeight + measureSpacing * scaleFactor;\r\n });\r\n };\r\n\r\n // Delay rendering to ensure fonts and images are loaded\r\n const timer = setTimeout(renderCanvas, 100);\r\n return () => clearTimeout(timer);\r\n }, [config, canvasSize, loadedFonts, imagesLoaded]);\r\n\r\n // Helper function to wrap and draw text with word wrapping\r\n // Returns: { height: number, lastLineWidth: number, lastLineY: number }\r\n const fillTextWrapped = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): { height: number; lastLineWidth: number; lastLineY: number } => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n let currentLine = words[0];\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n currentLine = word;\r\n } else {\r\n currentLine = testLine;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line) => {\r\n ctx.fillText(line, x, currentY);\r\n currentY += lineHeight;\r\n });\r\n\r\n const lastLineWidth = ctx.measureText(lines[lines.length - 1]).width;\r\n const lastLineY = y + (lines.length - 1) * lineHeight;\r\n\r\n return {\r\n height: lines.length * lineHeight,\r\n lastLineWidth,\r\n lastLineY,\r\n };\r\n };\r\n\r\n // Helper to wrap and draw multi-color text (for character_colors)\r\n const fillTextWrappedMultiColor = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n colors: string[],\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): number => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n const lineStartIndices: number[] = [0];\r\n let currentLine = words[0];\r\n let currentCharIndex = words[0].length;\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n lineStartIndices.push(currentCharIndex + 1); // +1 for space\r\n currentLine = word;\r\n currentCharIndex += word.length + 1;\r\n } else {\r\n currentLine = testLine;\r\n currentCharIndex += word.length + 1;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line, lineIdx) => {\r\n let currentX = x;\r\n const startCharIdx = lineIdx > 0 ? lineStartIndices[lineIdx] : 0;\r\n for (let i = 0; i < line.length; i++) {\r\n const char = line[i];\r\n const globalCharIdx = startCharIdx + i;\r\n const colorIndex = globalCharIdx % colors.length;\r\n const color = colors[colorIndex];\r\n ctx.fillStyle = COLOR_MAP[color] || \"#000000\";\r\n ctx.fillText(char, currentX, currentY);\r\n currentX += ctx.measureText(char).width;\r\n }\r\n currentY += lineHeight;\r\n });\r\n\r\n return lines.length * lineHeight;\r\n };\r\n\r\n const renderSide = (\r\n ctx: CanvasRenderingContext2D,\r\n side: any,\r\n startY: number,\r\n width: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n let currentY = startY;\r\n const padding = 40 * scaleFactor;\r\n const sideWidth = width - 2 * padding;\r\n const sectionHeight = 200 * scaleFactor;\r\n\r\n // No background section anymore - just white background\r\n\r\n // Group positions by common properties for optimization\r\n const textGroups: Array<{\r\n positions: Array<Position & { type: \"TEXT\" }>;\r\n properties: any;\r\n }> = [];\r\n let currentGroup: Array<Position & { type: \"TEXT\" }> | null = null;\r\n let currentProps: any = null;\r\n\r\n side.postitions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") {\r\n if (\r\n !currentGroup ||\r\n currentProps.font !== position.font ||\r\n currentProps.text_shape !== position.text_shape ||\r\n currentProps.color !== position.color ||\r\n currentProps.character_colors?.join(\",\") !==\r\n position.character_colors?.join(\",\")\r\n ) {\r\n // Start new group\r\n if (currentGroup) {\r\n textGroups.push({\r\n positions: currentGroup,\r\n properties: currentProps,\r\n });\r\n }\r\n currentGroup = [position];\r\n currentProps = {\r\n font: position.font,\r\n text_shape: position.text_shape,\r\n color: position.color,\r\n character_colors: position.character_colors,\r\n };\r\n } else {\r\n currentGroup.push(position);\r\n }\r\n }\r\n });\r\n\r\n if (currentGroup) {\r\n textGroups.push({ positions: currentGroup, properties: currentProps });\r\n }\r\n\r\n // Draw side header\r\n ctx.save();\r\n const headerFontSize = 200 * scaleFactor;\r\n ctx.font = `bold ${headerFontSize}px Times New Roman`;\r\n ctx.fillStyle = \"#000000\";\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n const headerResult = fillTextWrapped(\r\n ctx,\r\n side.print_side.toUpperCase(),\r\n padding,\r\n currentY,\r\n sideWidth,\r\n headerFontSize\r\n );\r\n currentY += headerResult.height + 50 * scaleFactor;\r\n ctx.restore();\r\n\r\n // Compute side-level uniform properties across all TEXT positions\r\n const allTextPositions: Array<Position & { type: \"TEXT\" }> = [];\r\n side.postitions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") allTextPositions.push(position as any);\r\n });\r\n\r\n const sideFonts = new Set(allTextPositions.map((p) => (p as any).font));\r\n const sideShapes = new Set(\r\n allTextPositions.map((p) => (p as any).text_shape)\r\n );\r\n const sideFlorals = new Set(\r\n allTextPositions.map((p) => (p as any).floral_pattern ?? \"None\")\r\n );\r\n const colorKeyOf = (p: any) =>\r\n p.character_colors && p.character_colors.length > 0\r\n ? p.character_colors.join(\",\")\r\n : p.color ?? \"None\";\r\n const sideColors = new Set(allTextPositions.map((p) => colorKeyOf(p)));\r\n\r\n const sideUniform = {\r\n font: sideFonts.size === 1,\r\n shape: sideShapes.size === 1,\r\n floral: sideFlorals.size === 1,\r\n color: sideColors.size === 1,\r\n };\r\n\r\n // Render side-level labels once for uniform properties\r\n currentY += renderSideUniformLabels(\r\n ctx,\r\n {\r\n font: sideUniform.font ? [...sideFonts][0] : null,\r\n shape: sideUniform.shape ? [...sideShapes][0] : null,\r\n floral: sideUniform.floral ? [...sideFlorals][0] : null,\r\n color: sideUniform.color ? [...sideColors][0] : null,\r\n },\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n\r\n // Render text groups first\r\n let sideTextCounter = 1;\r\n textGroups.forEach((group, groupIndex) => {\r\n group.positions.forEach((position, index) => {\r\n if (index === 0 && groupIndex !== 0) currentY += 50 * scaleFactor;\r\n const drawnHeight = renderText(\r\n ctx,\r\n position,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n sideTextCounter,\r\n {\r\n font: !sideUniform.font,\r\n shape: !sideUniform.shape,\r\n floral: !sideUniform.floral,\r\n color: !sideUniform.color,\r\n },\r\n scaleFactor\r\n );\r\n sideTextCounter += 1;\r\n // add padding only if something was actually drawn\r\n if (drawnHeight > 0) {\r\n currentY += drawnHeight + 40 * scaleFactor;\r\n }\r\n });\r\n });\r\n\r\n // Render ICON titles/values (no images here)\r\n currentY += 30 * scaleFactor; // minimal spacing before icon labels\r\n side.postitions.forEach((position: Position) => {\r\n if (position.type === \"ICON\") {\r\n currentY += renderIconLabels(\r\n ctx,\r\n position as any,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n currentY += 10 * scaleFactor;\r\n }\r\n });\r\n\r\n return Math.max(currentY - startY, sectionHeight);\r\n };\r\n\r\n const renderSideUniformLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n values: {\r\n font: string | null;\r\n shape: string | null;\r\n floral: string | null;\r\n color: string | null;\r\n },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 20 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n let rendered = 0;\r\n if (values.font) {\r\n const fontText = `Font: ${values.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.shape && values.shape !== \"None\") {\r\n const shapeText = `Kiểu chữ: ${values.shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.color && values.color !== \"None\") {\r\n const colorText = `Màu chỉ: ${values.color}`;\r\n // Reserve space for swatches (estimate: max 5 swatches × 200px each = 1000px)\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n // Draw swatches inline for side-level color, preserving aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor;\r\n const swatchY = result.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n const colorTokens = values.color.includes(\",\")\r\n ? values.color.split(\",\").map((s) => s.trim())\r\n : [values.color];\r\n colorTokens.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.floral && values.floral !== \"None\") {\r\n const floralText = `Mẫu hoa: ${values.floral}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (rendered > 0) cursorY += 50 * scaleFactor; // extra gap before first text line\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const renderText = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"TEXT\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n displayIndex: number,\r\n showLabels: {\r\n font: boolean;\r\n shape: boolean;\r\n floral: boolean;\r\n color: boolean;\r\n },\r\n scaleFactor: number = 1\r\n ): number => {\r\n ctx.save();\r\n\r\n // Info labels\r\n // Unified font sizing for labels and content (side title uses its own larger size)\r\n const infoLineGap = 30 * scaleFactor;\r\n const labelFontFamily = \"Arial\";\r\n // Use a unified content font size for both labels and text content\r\n const fontSize = 180 * scaleFactor;\r\n const infoFontSize = fontSize;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let currentYCursor = y;\r\n let drawnHeight = 0; // accumulate only when something is actually drawn\r\n\r\n // Text value with unified font size\r\n let displayText = position.text;\r\n if (position.change_character_to_heart && displayText.includes(\"<3\")) {\r\n displayText = displayText.replace(/<3/g, \"❤\");\r\n }\r\n\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n\r\n // Label for text line\r\n const textLabel = `Text ${displayIndex}: `;\r\n ctx.font = `bold ${fontSize}px ${labelFontFamily}`;\r\n const labelWidth = ctx.measureText(textLabel).width;\r\n ctx.fillStyle = \"#444444\";\r\n ctx.fillText(textLabel, x, currentYCursor);\r\n\r\n // Calculate available width for text content\r\n const textMaxWidth = maxWidth - labelWidth;\r\n\r\n // Handle character_colors (alternating colors)\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n // Switch to content font\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n const textHeight = fillTextWrappedMultiColor(\r\n ctx,\r\n displayText,\r\n position.character_colors,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textHeight;\r\n drawnHeight += textHeight;\r\n } else {\r\n // No color specified\r\n // Draw text in content font, black (non-bold)\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n ctx.fillStyle = COLOR_MAP[position.color ?? \"None\"] || \"#000000\";\r\n const textResult = fillTextWrapped(\r\n ctx,\r\n displayText,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textResult.height;\r\n drawnHeight += textResult.height;\r\n }\r\n\r\n // After text, print Kiểu chữ (when not uniform), then Font and Color as needed\r\n currentYCursor += infoLineGap;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.fillStyle = \"#444444\";\r\n if (showLabels.shape && position.text_shape) {\r\n const shapeLabelAfter = `Kiểu chữ: ${position.text_shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeLabelAfter,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.font && position.font) {\r\n const fontLabel = `Font: ${position.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontLabel,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.color) {\r\n let colorLabelValue = \"None\";\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n colorLabelValue = position.character_colors.join(\", \");\r\n } else if (position.color) {\r\n colorLabelValue = position.color;\r\n }\r\n if (colorLabelValue !== \"None\") {\r\n const colorLabel = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorLabel,\r\n x,\r\n currentYCursor,\r\n textMaxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n\r\n // Draw color swatch images inline with Color label for TEXT, preserve aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(infoFontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n result.lastLineY + Math.floor(infoFontSize / 2 - swatchH / 2);\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n } else if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n }\r\n }\r\n\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n }\r\n\r\n // Show floral label after color block when not uniform at side level\r\n if (showLabels.floral && position.floral_pattern) {\r\n const floralText = `Mẫu hoa: ${position.floral_pattern}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n\r\n // (Floral per-position label is printed above the text when needed; avoid duplicate after text)\r\n\r\n ctx.restore();\r\n return drawnHeight;\r\n };\r\n\r\n const renderIconLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"ICON\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 30 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n const iconText = `Icon: ${position.icon}`;\r\n const iconResult = fillTextWrapped(\r\n ctx,\r\n iconText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n // draw icon image inline with text, preserve aspect ratio; match line height\r\n const iconUrl = `${ICON_BASE_URL}/${position.icon}.png`;\r\n {\r\n const img = imageRefs.current.get(iconUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const swatchH = fontSize;\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n // Put icon on last line of wrapped text\r\n const iconX =\r\n x + Math.ceil(iconResult.lastLineWidth) + 100 * scaleFactor;\r\n const iconY =\r\n iconResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n ctx.drawImage(img, iconX, iconY, swatchW, swatchH);\r\n }\r\n }\r\n cursorY += iconResult.height;\r\n\r\n // Draw color line only when there are layer colors\r\n if (position.layer_colors && position.layer_colors.length > 0) {\r\n const colorLabelValue = position.layer_colors.join(\", \");\r\n const colorText = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const colorResult = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n\r\n // Draw color swatch images (only for icon)\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025); // 75% of previous size\r\n let swatchX =\r\n x + Math.ceil(colorResult.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n colorResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor; // spacing between swatches\r\n }\r\n });\r\n cursorY += colorResult.height;\r\n }\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const loadFont = (fontName: string): Promise<void> => {\r\n return new Promise((resolve, reject) => {\r\n // Try to load from CDN\r\n const fontUrl = `${FONT_BASE_URL}/${encodeURIComponent(fontName)}.woff2`;\r\n const fontFace = new FontFace(fontName, `url(${fontUrl})`);\r\n\r\n fontFace\r\n .load()\r\n .then((loadedFont) => {\r\n document.fonts.add(loadedFont);\r\n resolve();\r\n })\r\n .catch(() => {\r\n // Font loading failed, will use fallback\r\n console.warn(`Could not load font ${fontName} from CDN`);\r\n resolve(); // Still resolve to not block rendering\r\n });\r\n });\r\n };\r\n\r\n return (\r\n <div className={`render-embroidery${className ? ` ${className}` : \"\"}`} style={style}>\r\n <canvas ref={canvasRef} className=\"render-embroidery-canvas\" />\r\n </div>\r\n );\r\n};\r\n\r\nexport default EmbroideryQCImage;\r\n"],"names":["useState","useRef","useEffect","_jsx"],"mappings":";;;;;AAAA,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE;AAC/B,EAAE,KAAK,GAAG,KAAK,MAAM,GAAG,GAAG,GAAG,EAAE;AAChC,EAAE,IAAI,QAAQ,GAAG,GAAG,CAAC,QAAQ;;AAE7B,EAAE,IAAY,OAAO,QAAQ,KAAK,WAAW,EAAE,EAAE,OAAO,CAAC;;AAEzD,EAAE,IAAI,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtE,EAAE,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC;AAC7C,EAAE,KAAK,CAAC,IAAI,GAAG,UAAU;;AAEzB,EAAE,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC1B,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;AACzB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC;AAC/C,IAAI,CA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AAO,EAAE;AACX,YAAA,CAAC;iBACA,KAAK,CAAC,MAAK;;AAEV,gBAAA,OAAO,CAAC,IAAI,CAAC,uBAAuB,QAAQ,CAAA,SAAA,CAAW,CAAC;gBACxD,OAAO,EAAE,CAAC;AACZ,YAAA,CAAC,CAAC;AACN,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC;AAED,IAAA,QACEC,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,oBAAoB,SAAS,GAAG,CAAA,CAAA,EAAI,SAAS,CAAA,CAAE,GAAG,EAAE,CAAA,CAAE,EAAE,KAAK,EAAE,KAAK,EAAA,QAAA,EAClFA,2BAAQ,GAAG,EAAE,SAAS,EAAE,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAA,CAC3D;AAEV;;;;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.js","sources":["../node_modules/style-inject/dist/style-inject.es.js","../src/components/EmbroideryQCImage.tsx"],"sourcesContent":["function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","import React, { useState, useEffect, useRef } from \"react\";\r\nimport { EmbroideryQCImageProps, Position } from \"../types\";\r\nimport \"./EmbroideryQCImage.css\";\r\n\r\n// Color mapping\r\nconst COLOR_MAP: Record<string, string> = {\r\n \"Army (1394)\": \"#4B5320\",\r\n Army: \"#4B5320\",\r\n \"Black (8)\": \"#000000\",\r\n Black: \"#000000\",\r\n \"Bubblegum (1309)\": \"#FFC1CC\",\r\n Bubblegum: \"#FFC1CC\",\r\n \"Carolina Blue (1274)\": \"#7BAFD4\",\r\n \"Carolina Blue\": \"#7BAFD4\",\r\n \"Celadon (1098)\": \"#ACE1AF\",\r\n Celadon: \"#ACE1AF\",\r\n \"Coffee Bean (1145)\": \"#6F4E37\",\r\n \"Coffee Bean\": \"#6F4E37\",\r\n \"Daffodil (1180)\": \"#FFFF31\",\r\n Daffodil: \"#FFFF31\",\r\n \"Dark Gray (1131)\": \"#A9A9A9\",\r\n \"Dark Gray\": \"#A9A9A9\",\r\n \"Doe Skin Beige (1344)\": \"#F5E6D3\",\r\n \"Doe Skin Beige\": \"#F5E6D3\",\r\n \"Dusty Blue (1373)\": \"#6699CC\",\r\n \"Dusty Blue\": \"#6699CC\",\r\n \"Forest Green (1397)\": \"#228B22\",\r\n \"Forest Green\": \"#228B22\",\r\n \"Gold (1425)\": \"#FFD700\",\r\n Gold: \"#FFD700\",\r\n \"Gray (1118)\": \"#808080\",\r\n Gray: \"#808080\",\r\n \"Ivory (1072)\": \"#FFFFF0\",\r\n Ivory: \"#FFFFF0\",\r\n \"Lavender (1032)\": \"#E6E6FA\",\r\n Lavender: \"#E6E6FA\",\r\n \"Light Denim (1133)\": \"#B0C4DE\",\r\n \"Light Denim\": \"#B0C4DE\",\r\n \"Light Salmon (1018)\": \"#FFA07A\",\r\n \"Light Salmon\": \"#FFA07A\",\r\n \"Maroon (1374)\": \"#800000\",\r\n Maroon: \"#800000\",\r\n \"Navy Blue (1044)\": \"#000080\",\r\n \"Navy Blue\": \"#000080\",\r\n \"Olive Green (1157)\": \"#556B2F\",\r\n \"Olive Green\": \"#556B2F\",\r\n \"Orange (1278)\": \"#FFA500\",\r\n Orange: \"#FFA500\",\r\n \"Peach Blush (1053)\": \"#FFCCCB\",\r\n \"Peach Blush\": \"#FFCCCB\",\r\n \"Pink (1148)\": \"#FFC0CB\",\r\n Pink: \"#FFC0CB\",\r\n \"Purple (1412)\": \"#800080\",\r\n Purple: \"#800080\",\r\n \"Red (1037)\": \"#FF0000\",\r\n Red: \"#FF0000\",\r\n \"Silver Sage (1396)\": \"#A8A8A8\",\r\n \"Silver Sage\": \"#A8A8A8\",\r\n \"Summer Sky (1432)\": \"#87CEEB\",\r\n \"Summer Sky\": \"#87CEEB\",\r\n \"Terra Cotta (1477)\": \"#E2725B\",\r\n \"Terra Cotta\": \"#E2725B\",\r\n \"Sand (1055)\": \"#F4A460\",\r\n Sand: \"#F4A460\",\r\n \"White (9)\": \"#FFFFFF\",\r\n White: \"#FFFFFF\",\r\n};\r\n\r\nconst FONT_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/fonts\";\r\nconst ICON_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/icons\";\r\nconst FLORAL_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/florals\";\r\nconst THREAD_COLOR_BASE_URL =\r\n \"https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/thread-colors\";\r\n\r\nconst EmbroideryQCImage: React.FC<EmbroideryQCImageProps> = ({\r\n config,\r\n className = \"\",\r\n style = {},\r\n}) => {\r\n const [canvasSize] = useState({ width: 4200, height: 4800 });\r\n const [loadedFonts, setLoadedFonts] = useState<Set<string>>(new Set());\r\n const [imagesLoaded, setImagesLoaded] = useState(0);\r\n const canvasRef = useRef<HTMLCanvasElement>(null);\r\n const imageRefs = useRef<Map<string, HTMLImageElement>>(new Map());\r\n\r\n // Load fonts\r\n useEffect(() => {\r\n const loadFonts = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n const fontsToLoad = new Set<string>();\r\n config.sides.forEach((side) => {\r\n side.positions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.font) {\r\n fontsToLoad.add(position.font);\r\n }\r\n });\r\n });\r\n\r\n for (const fontName of fontsToLoad) {\r\n if (loadedFonts.has(fontName)) continue;\r\n\r\n try {\r\n await loadFont(fontName);\r\n setLoadedFonts((prev) => new Set(prev).add(fontName));\r\n } catch (error) {\r\n console.warn(`Could not load font ${fontName}:`, error);\r\n }\r\n }\r\n };\r\n\r\n loadFonts();\r\n }, [config.sides, loadedFonts]);\r\n\r\n // Load images\r\n useEffect(() => {\r\n const loadImages = async () => {\r\n if (!config.sides || config.sides.length === 0) return;\r\n\r\n // Load mockup image (not background). It will be drawn at bottom-right.\r\n if (config.image_url) {\r\n // Try with CORS first. If it fails (no CORS headers), retry without CORS\r\n const loadMockup = (useCors: boolean) => {\r\n const img = new Image();\r\n if (useCors) img.crossOrigin = \"anonymous\";\r\n img.onload = () => {\r\n imageRefs.current.set(\"mockup\", img);\r\n setImagesLoaded((prev) => prev + 1);\r\n };\r\n img.onerror = () => {\r\n if (useCors) {\r\n // Retry without CORS; canvas may become tainted on export\r\n loadMockup(false);\r\n }\r\n };\r\n img.src = config.image_url as string;\r\n };\r\n loadMockup(true);\r\n }\r\n\r\n // Load icons\r\n config.sides.forEach((side) => {\r\n side.positions.forEach((position) => {\r\n if (position.type === \"ICON\" && position.icon !== 0) {\r\n const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;\r\n if (!imageRefs.current.has(iconUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = iconUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(iconUrl, img);\r\n }\r\n }\r\n\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!imageRefs.current.has(floralUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = floralUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(floralUrl, img);\r\n }\r\n }\r\n\r\n // Load thread color images for TEXT positions\r\n if (position.type === \"TEXT\") {\r\n // Load color image if position has color\r\n if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n }\r\n\r\n // Load character color images\r\n if (\r\n position.character_colors &&\r\n position.character_colors.length > 0\r\n ) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n }\r\n\r\n // Load thread color images for ICON positions\r\n if (position.type === \"ICON\" && position.layer_colors) {\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n if (!imageRefs.current.has(threadColorUrl)) {\r\n const img = new Image();\r\n img.crossOrigin = \"anonymous\";\r\n img.src = threadColorUrl;\r\n img.onload = () => setImagesLoaded((prev) => prev + 1);\r\n imageRefs.current.set(threadColorUrl, img);\r\n }\r\n });\r\n }\r\n });\r\n });\r\n };\r\n\r\n loadImages();\r\n }, [config]);\r\n\r\n // Render canvas\r\n useEffect(() => {\r\n const renderCanvas = () => {\r\n if (!canvasRef.current || !config.sides || config.sides.length === 0) {\r\n return;\r\n }\r\n\r\n const canvas = canvasRef.current;\r\n const ctx = canvas.getContext(\"2d\");\r\n if (!ctx) return;\r\n\r\n canvas.width = canvasSize.width;\r\n canvas.height = canvasSize.height;\r\n\r\n // Clear with white background\r\n ctx.fillStyle = \"#FFFFFF\";\r\n ctx.fillRect(0, 0, canvas.width, canvas.height);\r\n\r\n // Collect floral images (for later drawing)\r\n const floralAssets: HTMLImageElement[] = [];\r\n const seenFlorals = new Set<string>();\r\n if (config.sides) {\r\n config.sides.forEach((side) => {\r\n side.positions.forEach((position) => {\r\n if (position.type === \"TEXT\" && position.floral_pattern) {\r\n const floralUrl = `${FLORAL_BASE_URL}/${position.floral_pattern}.png`;\r\n if (!seenFlorals.has(floralUrl)) {\r\n const img = imageRefs.current.get(floralUrl);\r\n if (img && img.complete && img.naturalWidth > 0) {\r\n floralAssets.push(img);\r\n seenFlorals.add(floralUrl);\r\n }\r\n }\r\n }\r\n });\r\n });\r\n }\r\n\r\n // Helper function to draw mockup and florals\r\n const drawMockupAndFlorals = () => {\r\n const mockupImg = imageRefs.current.get(\"mockup\");\r\n const margin = 40; // small padding\r\n let mockupBox: { x: number; y: number; w: number; h: number } | null =\r\n null;\r\n if (mockupImg && mockupImg.complete && mockupImg.naturalWidth > 0) {\r\n const maxTargetWidth = Math.min(1800, canvas.width * 0.375);\r\n const maxTargetHeight = canvas.height * 0.375;\r\n const scale = Math.min(\r\n maxTargetWidth / mockupImg.naturalWidth,\r\n maxTargetHeight / mockupImg.naturalHeight\r\n );\r\n const targetWidth = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalWidth * scale)\r\n );\r\n const targetHeight = Math.max(\r\n 1,\r\n Math.floor(mockupImg.naturalHeight * scale)\r\n );\r\n const targetX = canvas.width - margin - targetWidth;\r\n const targetY = canvas.height - margin - targetHeight;\r\n mockupBox = {\r\n x: targetX,\r\n y: targetY,\r\n w: targetWidth,\r\n h: targetHeight,\r\n };\r\n ctx.drawImage(mockupImg, targetX, targetY, targetWidth, targetHeight);\r\n }\r\n\r\n // Draw florals to the left of mockup\r\n if (mockupBox && floralAssets.length > 0) {\r\n const spacing = 300;\r\n const targetHeight = mockupBox.h;\r\n const floralFixedH = Math.min(900, targetHeight);\r\n let currentX = mockupBox.x - spacing;\r\n for (let i = floralAssets.length - 1; i >= 0; i--) {\r\n const img = floralAssets[i];\r\n const ratio = img.naturalWidth / Math.max(1, img.naturalHeight);\r\n const h = floralFixedH;\r\n const w = Math.max(1, Math.floor(h * ratio));\r\n currentX -= w;\r\n const y = mockupBox.y + (targetHeight - h);\r\n ctx.drawImage(img, currentX, y, w, h);\r\n currentX -= spacing;\r\n }\r\n }\r\n };\r\n\r\n // New approach: Draw images first (bottom layer), then text on top\r\n // This allows text to overlay images when needed\r\n\r\n // Pass 1: Measure actual height with original size (use offscreen canvas for measurement)\r\n const measureCanvas = document.createElement(\"canvas\");\r\n measureCanvas.width = canvas.width;\r\n measureCanvas.height = canvas.height;\r\n const measureCtx = measureCanvas.getContext(\"2d\");\r\n if (!measureCtx) return;\r\n\r\n // Set up measurement context\r\n measureCtx.font = ctx.font;\r\n measureCtx.textAlign = ctx.textAlign;\r\n measureCtx.textBaseline = ctx.textBaseline;\r\n\r\n let measureY = 40;\r\n const measureSpacing = 100;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n measureCtx,\r\n side,\r\n measureY,\r\n canvas.width,\r\n 1\r\n );\r\n measureY += sideHeight + measureSpacing;\r\n });\r\n const totalMeasuredHeight = measureY; // Total height used\r\n\r\n // Calculate scale factor - only scale down when necessary\r\n // Keep original font sizes (no scale up) - font size is the maximum\r\n const topPadding = 40;\r\n // No bottom padding - content can go to bottom, mockup will overlay\r\n const targetContentHeight = canvas.height - topPadding;\r\n\r\n // Only scale down if content exceeds canvas height\r\n // Never scale up - preserve original font sizes\r\n let scaleFactor = 1;\r\n if (totalMeasuredHeight > targetContentHeight) {\r\n // Scale down to fit exactly\r\n scaleFactor = targetContentHeight / totalMeasuredHeight;\r\n scaleFactor = Math.max(0.5, scaleFactor); // Minimum scale to prevent tiny fonts\r\n }\r\n // If content fits, keep scaleFactor = 1 (original font sizes)\r\n\r\n // Draw mockup and florals first (bottom layer)\r\n drawMockupAndFlorals();\r\n\r\n // Draw content on top (top layer) - text will overlay images if needed\r\n let currentY = topPadding * scaleFactor;\r\n config.sides.forEach((side) => {\r\n const sideHeight = renderSide(\r\n ctx,\r\n side,\r\n currentY,\r\n canvas.width,\r\n scaleFactor\r\n );\r\n currentY += sideHeight + measureSpacing * scaleFactor;\r\n });\r\n };\r\n\r\n // Delay rendering to ensure fonts and images are loaded\r\n const timer = setTimeout(renderCanvas, 100);\r\n return () => clearTimeout(timer);\r\n }, [config, canvasSize, loadedFonts, imagesLoaded]);\r\n\r\n // Helper function to wrap and draw text with word wrapping\r\n // Returns: { height: number, lastLineWidth: number, lastLineY: number }\r\n const fillTextWrapped = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): { height: number; lastLineWidth: number; lastLineY: number } => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n let currentLine = words[0];\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n currentLine = word;\r\n } else {\r\n currentLine = testLine;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line) => {\r\n ctx.fillText(line, x, currentY);\r\n currentY += lineHeight;\r\n });\r\n\r\n const lastLineWidth = ctx.measureText(lines[lines.length - 1]).width;\r\n const lastLineY = y + (lines.length - 1) * lineHeight;\r\n\r\n return {\r\n height: lines.length * lineHeight,\r\n lastLineWidth,\r\n lastLineY,\r\n };\r\n };\r\n\r\n // Helper to wrap and draw multi-color text (for character_colors)\r\n const fillTextWrappedMultiColor = (\r\n ctx: CanvasRenderingContext2D,\r\n text: string,\r\n colors: string[],\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n lineHeight: number\r\n ): number => {\r\n const words = text.split(\" \");\r\n const lines: string[] = [];\r\n const lineStartIndices: number[] = [0];\r\n let currentLine = words[0];\r\n let currentCharIndex = words[0].length;\r\n\r\n for (let i = 1; i < words.length; i++) {\r\n const word = words[i];\r\n const testLine = currentLine + \" \" + word;\r\n const metrics = ctx.measureText(testLine);\r\n if (metrics.width > maxWidth && currentLine.length > 0) {\r\n lines.push(currentLine);\r\n lineStartIndices.push(currentCharIndex + 1); // +1 for space\r\n currentLine = word;\r\n currentCharIndex += word.length + 1;\r\n } else {\r\n currentLine = testLine;\r\n currentCharIndex += word.length + 1;\r\n }\r\n }\r\n lines.push(currentLine);\r\n\r\n let currentY = y;\r\n lines.forEach((line, lineIdx) => {\r\n let currentX = x;\r\n const startCharIdx = lineIdx > 0 ? lineStartIndices[lineIdx] : 0;\r\n for (let i = 0; i < line.length; i++) {\r\n const char = line[i];\r\n const globalCharIdx = startCharIdx + i;\r\n const colorIndex = globalCharIdx % colors.length;\r\n const color = colors[colorIndex];\r\n ctx.fillStyle = COLOR_MAP[color] || \"#000000\";\r\n ctx.fillText(char, currentX, currentY);\r\n currentX += ctx.measureText(char).width;\r\n }\r\n currentY += lineHeight;\r\n });\r\n\r\n return lines.length * lineHeight;\r\n };\r\n\r\n const renderSide = (\r\n ctx: CanvasRenderingContext2D,\r\n side: any,\r\n startY: number,\r\n width: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n let currentY = startY;\r\n const padding = 40 * scaleFactor;\r\n const sideWidth = width - 2 * padding;\r\n const sectionHeight = 200 * scaleFactor;\r\n\r\n // No background section anymore - just white background\r\n\r\n // Group positions by common properties for optimization\r\n const textGroups: Array<{\r\n positions: Array<Position & { type: \"TEXT\" }>;\r\n properties: any;\r\n }> = [];\r\n let currentGroup: Array<Position & { type: \"TEXT\" }> | null = null;\r\n let currentProps: any = null;\r\n\r\n side.positions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") {\r\n if (\r\n !currentGroup ||\r\n currentProps.font !== position.font ||\r\n currentProps.text_shape !== position.text_shape ||\r\n currentProps.color !== position.color ||\r\n currentProps.character_colors?.join(\",\") !==\r\n position.character_colors?.join(\",\")\r\n ) {\r\n // Start new group\r\n if (currentGroup) {\r\n textGroups.push({\r\n positions: currentGroup,\r\n properties: currentProps,\r\n });\r\n }\r\n currentGroup = [position];\r\n currentProps = {\r\n font: position.font,\r\n text_shape: position.text_shape,\r\n color: position.color,\r\n character_colors: position.character_colors,\r\n };\r\n } else {\r\n currentGroup.push(position);\r\n }\r\n }\r\n });\r\n\r\n if (currentGroup) {\r\n textGroups.push({ positions: currentGroup, properties: currentProps });\r\n }\r\n\r\n // Draw side header\r\n ctx.save();\r\n const headerFontSize = 200 * scaleFactor;\r\n ctx.font = `bold ${headerFontSize}px Times New Roman`;\r\n ctx.fillStyle = \"#000000\";\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n const headerResult = fillTextWrapped(\r\n ctx,\r\n side.print_side.toUpperCase(),\r\n padding,\r\n currentY,\r\n sideWidth,\r\n headerFontSize\r\n );\r\n currentY += headerResult.height + 50 * scaleFactor;\r\n ctx.restore();\r\n\r\n // Compute side-level uniform properties across all TEXT positions\r\n const allTextPositions: Array<Position & { type: \"TEXT\" }> = [];\r\n side.positions.forEach((position: Position) => {\r\n if (position.type === \"TEXT\") allTextPositions.push(position as any);\r\n });\r\n\r\n const sideFonts = new Set(allTextPositions.map((p) => (p as any).font));\r\n const sideShapes = new Set(\r\n allTextPositions.map((p) => (p as any).text_shape)\r\n );\r\n const sideFlorals = new Set(\r\n allTextPositions.map((p) => (p as any).floral_pattern ?? \"None\")\r\n );\r\n const colorKeyOf = (p: any) =>\r\n p.character_colors && p.character_colors.length > 0\r\n ? p.character_colors.join(\",\")\r\n : p.color ?? \"None\";\r\n const sideColors = new Set(allTextPositions.map((p) => colorKeyOf(p)));\r\n\r\n const sideUniform = {\r\n font: sideFonts.size === 1,\r\n shape: sideShapes.size === 1,\r\n floral: sideFlorals.size === 1,\r\n color: sideColors.size === 1,\r\n };\r\n\r\n // Render side-level labels once for uniform properties\r\n currentY += renderSideUniformLabels(\r\n ctx,\r\n {\r\n font: sideUniform.font ? [...sideFonts][0] : null,\r\n shape: sideUniform.shape ? [...sideShapes][0] : null,\r\n floral: sideUniform.floral ? [...sideFlorals][0] : null,\r\n color: sideUniform.color ? [...sideColors][0] : null,\r\n },\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n\r\n // Render text groups first\r\n let sideTextCounter = 1;\r\n textGroups.forEach((group, groupIndex) => {\r\n group.positions.forEach((position, index) => {\r\n if (index === 0 && groupIndex !== 0) currentY += 50 * scaleFactor;\r\n const drawnHeight = renderText(\r\n ctx,\r\n position,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n sideTextCounter,\r\n {\r\n font: !sideUniform.font,\r\n shape: !sideUniform.shape,\r\n floral: !sideUniform.floral,\r\n color: !sideUniform.color,\r\n },\r\n scaleFactor\r\n );\r\n sideTextCounter += 1;\r\n // add padding only if something was actually drawn\r\n if (drawnHeight > 0) {\r\n currentY += drawnHeight + 40 * scaleFactor;\r\n }\r\n });\r\n });\r\n\r\n // Render ICON titles/values (no images here)\r\n currentY += 30 * scaleFactor; // minimal spacing before icon labels\r\n side.positions.forEach((position: Position) => {\r\n if (position.type === \"ICON\") {\r\n currentY += renderIconLabels(\r\n ctx,\r\n position as any,\r\n padding,\r\n currentY,\r\n sideWidth,\r\n scaleFactor\r\n );\r\n currentY += 10 * scaleFactor;\r\n }\r\n });\r\n\r\n return Math.max(currentY - startY, sectionHeight);\r\n };\r\n\r\n const renderSideUniformLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n values: {\r\n font: string | null;\r\n shape: string | null;\r\n floral: string | null;\r\n color: string | null;\r\n },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 20 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n let rendered = 0;\r\n if (values.font) {\r\n const fontText = `Font: ${values.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.shape && values.shape !== \"None\") {\r\n const shapeText = `Kiểu chữ: ${values.shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.color && values.color !== \"None\") {\r\n const colorText = `Màu chỉ: ${values.color}`;\r\n // Reserve space for swatches (estimate: max 5 swatches × 200px each = 1000px)\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n // Draw swatches inline for side-level color, preserving aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor;\r\n const swatchY = result.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n const colorTokens = values.color.includes(\",\")\r\n ? values.color.split(\",\").map((s) => s.trim())\r\n : [values.color];\r\n colorTokens.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (values.floral && values.floral !== \"None\") {\r\n const floralText = `Mẫu hoa: ${values.floral}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n cursorY += result.height;\r\n rendered++;\r\n }\r\n if (rendered > 0) cursorY += 50 * scaleFactor; // extra gap before first text line\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const renderText = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"TEXT\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n displayIndex: number,\r\n showLabels: {\r\n font: boolean;\r\n shape: boolean;\r\n floral: boolean;\r\n color: boolean;\r\n },\r\n scaleFactor: number = 1\r\n ): number => {\r\n ctx.save();\r\n\r\n // Info labels\r\n // Unified font sizing for labels and content (side title uses its own larger size)\r\n const infoLineGap = 30 * scaleFactor;\r\n const labelFontFamily = \"Arial\";\r\n // Use a unified content font size for both labels and text content\r\n const fontSize = 180 * scaleFactor;\r\n const infoFontSize = fontSize;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let currentYCursor = y;\r\n let drawnHeight = 0; // accumulate only when something is actually drawn\r\n\r\n // Text value with unified font size\r\n let displayText = position.text;\r\n if (position.change_character_to_heart && displayText.includes(\"<3\")) {\r\n displayText = displayText.replace(/<3/g, \"❤\");\r\n }\r\n\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n\r\n // Label for text line\r\n const textLabel = `Text ${displayIndex}: `;\r\n ctx.font = `bold ${fontSize}px ${labelFontFamily}`;\r\n const labelWidth = ctx.measureText(textLabel).width;\r\n ctx.fillStyle = \"#444444\";\r\n ctx.fillText(textLabel, x, currentYCursor);\r\n\r\n // Calculate available width for text content\r\n const textMaxWidth = maxWidth - labelWidth;\r\n\r\n // Handle character_colors (alternating colors)\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n // Switch to content font\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n const textHeight = fillTextWrappedMultiColor(\r\n ctx,\r\n displayText,\r\n position.character_colors,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textHeight;\r\n drawnHeight += textHeight;\r\n } else {\r\n // No color specified\r\n // Draw text in content font, black (non-bold)\r\n ctx.font = `${fontSize}px ${position.font}`;\r\n ctx.fillStyle = COLOR_MAP[position.color ?? \"None\"] || \"#000000\";\r\n const textResult = fillTextWrapped(\r\n ctx,\r\n displayText,\r\n x + labelWidth,\r\n currentYCursor,\r\n textMaxWidth,\r\n fontSize\r\n );\r\n currentYCursor += textResult.height;\r\n drawnHeight += textResult.height;\r\n }\r\n\r\n // After text, print Kiểu chữ (when not uniform), then Font and Color as needed\r\n currentYCursor += infoLineGap;\r\n ctx.font = `${infoFontSize}px ${labelFontFamily}`;\r\n ctx.fillStyle = \"#444444\";\r\n if (showLabels.shape && position.text_shape) {\r\n const shapeLabelAfter = `Kiểu chữ: ${position.text_shape}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n shapeLabelAfter,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.font && position.font) {\r\n const fontLabel = `Font: ${position.font}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n fontLabel,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n if (showLabels.color) {\r\n let colorLabelValue = \"None\";\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n colorLabelValue = position.character_colors.join(\", \");\r\n } else if (position.color) {\r\n colorLabelValue = position.color;\r\n }\r\n if (colorLabelValue !== \"None\") {\r\n const colorLabel = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const result = fillTextWrapped(\r\n ctx,\r\n colorLabel,\r\n x,\r\n currentYCursor,\r\n textMaxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n\r\n // Draw color swatch images inline with Color label for TEXT, preserve aspect ratio; 75% of previous size\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(infoFontSize * 2.025);\r\n let swatchX = x + Math.ceil(result.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n result.lastLineY + Math.floor(infoFontSize / 2 - swatchH / 2);\r\n if (position.character_colors && position.character_colors.length > 0) {\r\n position.character_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor;\r\n }\r\n });\r\n } else if (position.color) {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${position.color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n }\r\n }\r\n\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n }\r\n\r\n // Show floral label after color block when not uniform at side level\r\n if (showLabels.floral && position.floral_pattern) {\r\n const floralText = `Mẫu hoa: ${position.floral_pattern}`;\r\n const result = fillTextWrapped(\r\n ctx,\r\n floralText,\r\n x,\r\n currentYCursor,\r\n maxWidth,\r\n infoFontSize + infoLineGap\r\n );\r\n currentYCursor += result.height;\r\n drawnHeight += result.height;\r\n }\r\n\r\n // (Floral per-position label is printed above the text when needed; avoid duplicate after text)\r\n\r\n ctx.restore();\r\n return drawnHeight;\r\n };\r\n\r\n const renderIconLabels = (\r\n ctx: CanvasRenderingContext2D,\r\n position: Position & { type: \"ICON\" },\r\n x: number,\r\n y: number,\r\n maxWidth: number,\r\n scaleFactor: number = 1\r\n ): number => {\r\n const labelFontFamily = \"Arial\";\r\n const fontSize = 180 * scaleFactor;\r\n const lineGap = 30 * scaleFactor;\r\n ctx.save();\r\n ctx.font = `${fontSize}px ${labelFontFamily}`;\r\n ctx.textAlign = \"left\";\r\n ctx.textBaseline = \"top\";\r\n ctx.fillStyle = \"#444444\";\r\n\r\n let cursorY = y;\r\n const iconText = position.icon === 0 \r\n ? `Icon: icon mặc định theo file thêu` \r\n : `Icon: ${position.icon}`;\r\n const iconResult = fillTextWrapped(\r\n ctx,\r\n iconText,\r\n x,\r\n cursorY,\r\n maxWidth,\r\n fontSize + lineGap\r\n );\r\n // draw icon image inline with text, preserve aspect ratio; match line height\r\n if (position.icon !== 0) {\r\n const iconUrl = `${ICON_BASE_URL}/Icon ${position.icon}.png`;\r\n const img = imageRefs.current.get(iconUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const swatchH = fontSize;\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n // Put icon on last line of wrapped text\r\n const iconX =\r\n x + Math.ceil(iconResult.lastLineWidth) + 100 * scaleFactor;\r\n const iconY =\r\n iconResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n ctx.drawImage(img, iconX, iconY, swatchW, swatchH);\r\n }\r\n }\r\n cursorY += iconResult.height;\r\n\r\n // Draw color line only when there are layer colors\r\n if (position.layer_colors && position.layer_colors.length > 0) {\r\n const colorLabelValue = position.layer_colors.join(\", \");\r\n const colorText = `Màu chỉ: ${colorLabelValue}`;\r\n // Reserve space for swatches\r\n const swatchReserved = 1000 * scaleFactor;\r\n const textMaxWidth = Math.max(\r\n 400 * scaleFactor,\r\n maxWidth - swatchReserved\r\n );\r\n const colorResult = fillTextWrapped(\r\n ctx,\r\n colorText,\r\n x,\r\n cursorY,\r\n textMaxWidth,\r\n fontSize + lineGap\r\n );\r\n\r\n // Draw color swatch images (only for icon)\r\n // Position swatches after the last line of wrapped text\r\n const swatchH = Math.floor(fontSize * 2.025); // 75% of previous size\r\n let swatchX =\r\n x + Math.ceil(colorResult.lastLineWidth) + 100 * scaleFactor; // spacing after text\r\n const swatchY =\r\n colorResult.lastLineY + Math.floor(fontSize / 2 - swatchH / 2);\r\n position.layer_colors.forEach((color) => {\r\n const threadColorUrl = `${THREAD_COLOR_BASE_URL}/${color}.png`;\r\n const img = imageRefs.current.get(threadColorUrl);\r\n if (img && img.complete && img.naturalHeight > 0) {\r\n const ratio = img.naturalWidth / img.naturalHeight;\r\n const swatchW = Math.max(1, Math.floor(swatchH * ratio));\r\n ctx.drawImage(img, swatchX, swatchY, swatchW, swatchH);\r\n swatchX += swatchW + 25 * scaleFactor; // spacing between swatches\r\n }\r\n });\r\n cursorY += colorResult.height;\r\n }\r\n\r\n ctx.restore();\r\n return cursorY - y;\r\n };\r\n\r\n const loadFont = (fontName: string): Promise<void> => {\r\n return new Promise((resolve, reject) => {\r\n // Try to load from CDN\r\n const fontUrl = `${FONT_BASE_URL}/${encodeURIComponent(fontName)}.woff2`;\r\n const fontFace = new FontFace(fontName, `url(${fontUrl})`);\r\n\r\n fontFace\r\n .load()\r\n .then((loadedFont) => {\r\n document.fonts.add(loadedFont);\r\n resolve();\r\n })\r\n .catch(() => {\r\n // Font loading failed, will use fallback\r\n console.warn(`Could not load font ${fontName} from CDN`);\r\n resolve(); // Still resolve to not block rendering\r\n });\r\n });\r\n };\r\n\r\n return (\r\n <div className={`render-embroidery${className ? ` ${className}` : \"\"}`} style={style}>\r\n <canvas ref={canvasRef} className=\"render-embroidery-canvas\" />\r\n </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AAE,KAAK,EAAE,KAAK,EAAA,QAAA,EAClFA,2BAAQ,GAAG,EAAE,SAAS,EAAE,SAAS,EAAC,0BAA0B,EAAA,CAAG,EAAA,CAC3D;AAEV;;;;","x_google_ignoreList":[0]}
@@ -10,13 +10,13 @@ export interface TextPosition {
10
10
  }
11
11
  export interface IconPosition {
12
12
  type: 'ICON';
13
- icon: string;
13
+ icon: number;
14
14
  layer_colors: string[];
15
15
  }
16
16
  export type Position = TextPosition | IconPosition;
17
17
  export interface Side {
18
18
  print_side: string;
19
- postitions: Position[];
19
+ positions: Position[];
20
20
  }
21
21
  export interface EmbroideryQCConfig {
22
22
  image_url?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,yBAAyB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEnD,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,QAAQ,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,yBAAyB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC;AAEnD,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embroidery-qc-image",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "React component for rendering embroidery QC images",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",