{
  "version": 3,
  "sources": ["/cdn/shop/t/5/assets/custom-artwork-cropper-geometry.js?psv=home-personalizer-v1-20260819"],
  "sourcesContent": ["(() => {\n  const clamp = (value, minimum, maximum) => Math.min(maximum, Math.max(minimum, value));\n\n  const fitCrop = (bounds, ratio, coverage = 0.72) => {\n    const safeCoverage = clamp(coverage, 0.2, 1);\n    let width = bounds.width * safeCoverage;\n    let height = width / ratio;\n    if (height > bounds.height * safeCoverage) {\n      height = bounds.height * safeCoverage;\n      width = height * ratio;\n    }\n    return {\n      x: bounds.x + (bounds.width - width) / 2,\n      y: bounds.y + (bounds.height - height) / 2,\n      width,\n      height,\n    };\n  };\n\n  const moveCrop = (crop, deltaX, deltaY, bounds) => ({\n    ...crop,\n    x: clamp(crop.x + deltaX, bounds.x, bounds.x + bounds.width - crop.width),\n    y: clamp(crop.y + deltaY, bounds.y, bounds.y + bounds.height - crop.height),\n  });\n\n  const resizeCrop = (crop, corner, pointer, bounds, ratio, minimumSize = 72) => {\n    const fixed = {\n      nw: { x: crop.x + crop.width, y: crop.y + crop.height },\n      ne: { x: crop.x, y: crop.y + crop.height },\n      sw: { x: crop.x + crop.width, y: crop.y },\n      se: { x: crop.x, y: crop.y },\n    }[corner];\n    if (!fixed) return crop;\n\n    const horizontalDirection = corner.endsWith('e') ? 1 : -1;\n    const verticalDirection = corner.startsWith('s') ? 1 : -1;\n    const maximumWidthX = horizontalDirection > 0\n      ? bounds.x + bounds.width - fixed.x\n      : fixed.x - bounds.x;\n    const maximumHeightY = verticalDirection > 0\n      ? bounds.y + bounds.height - fixed.y\n      : fixed.y - bounds.y;\n    const maximumWidth = Math.min(maximumWidthX, maximumHeightY * ratio);\n    const desiredWidthFromX = Math.abs(pointer.x - fixed.x);\n    const desiredWidthFromY = Math.abs(pointer.y - fixed.y) * ratio;\n    const width = clamp(Math.max(desiredWidthFromX, desiredWidthFromY), minimumSize, maximumWidth);\n    const height = width / ratio;\n\n    return {\n      x: horizontalDirection > 0 ? fixed.x : fixed.x - width,\n      y: verticalDirection > 0 ? fixed.y : fixed.y - height,\n      width,\n      height,\n    };\n  };\n\n  const resizeCropFree = (crop, corner, pointer, bounds, minimumSize = 72) => {\n    const fixed = {\n      nw: { x: crop.x + crop.width, y: crop.y + crop.height },\n      ne: { x: crop.x, y: crop.y + crop.height },\n      sw: { x: crop.x + crop.width, y: crop.y },\n      se: { x: crop.x, y: crop.y },\n    }[corner];\n    if (!fixed) return crop;\n\n    const horizontalDirection = corner.endsWith('e') ? 1 : -1;\n    const verticalDirection = corner.startsWith('s') ? 1 : -1;\n    const maximumWidth = horizontalDirection > 0\n      ? bounds.x + bounds.width - fixed.x\n      : fixed.x - bounds.x;\n    const maximumHeight = verticalDirection > 0\n      ? bounds.y + bounds.height - fixed.y\n      : fixed.y - bounds.y;\n    const width = clamp(Math.abs(pointer.x - fixed.x), Math.min(minimumSize, maximumWidth), maximumWidth);\n    const height = clamp(Math.abs(pointer.y - fixed.y), Math.min(minimumSize, maximumHeight), maximumHeight);\n\n    return {\n      x: horizontalDirection > 0 ? fixed.x : fixed.x - width,\n      y: verticalDirection > 0 ? fixed.y : fixed.y - height,\n      width,\n      height,\n    };\n  };\n\n  const matchRatio = (ratio, candidates, tolerance = 0.01) => {\n    if (!Number.isFinite(ratio) || ratio <= 0) return '';\n    let closest = '';\n    let closestDifference = Number.POSITIVE_INFINITY;\n    Object.entries(candidates || {}).forEach(([name, candidate]) => {\n      if (!Number.isFinite(candidate) || candidate <= 0) return;\n      const difference = Math.abs(ratio - candidate) / candidate;\n      if (difference >= closestDifference) return;\n      closest = name;\n      closestDifference = difference;\n    });\n    return closestDifference <= tolerance ? closest : '';\n  };\n\n  const toSourceRect = (crop, displayedImage, naturalWidth, naturalHeight) => {\n    const scaleX = naturalWidth / displayedImage.width;\n    const scaleY = naturalHeight / displayedImage.height;\n    return {\n      x: clamp((crop.x - displayedImage.x) * scaleX, 0, naturalWidth),\n      y: clamp((crop.y - displayedImage.y) * scaleY, 0, naturalHeight),\n      width: clamp(crop.width * scaleX, 1, naturalWidth),\n      height: clamp(crop.height * scaleY, 1, naturalHeight),\n    };\n  };\n\n  globalThis.PosterCropGeometry = { clamp, fitCrop, moveCrop, resizeCrop, resizeCropFree, matchRatio, toSourceRect };\n})();\n"],
  "mappings": "CAAC,IAAM,CACL,MAAM,MAAQ,CAAC,MAAO,QAAS,UAAY,KAAK,IAAI,QAAS,KAAK,IAAI,QAAS,KAAK,CAAC,EAE/E,QAAU,CAAC,OAAQ,MAAO,SAAW,MAAS,CAClD,MAAM,aAAe,MAAM,SAAU,GAAK,CAAC,EAC3C,IAAI,MAAQ,OAAO,MAAQ,aACvB,OAAS,MAAQ,MACrB,OAAI,OAAS,OAAO,OAAS,eAC3B,OAAS,OAAO,OAAS,aACzB,MAAQ,OAAS,OAEZ,CACL,EAAG,OAAO,GAAK,OAAO,MAAQ,OAAS,EACvC,EAAG,OAAO,GAAK,OAAO,OAAS,QAAU,EACzC,MACA,MACF,CACF,EAEM,SAAW,CAAC,KAAM,OAAQ,OAAQ,UAAY,CAClD,GAAG,KACH,EAAG,MAAM,KAAK,EAAI,OAAQ,OAAO,EAAG,OAAO,EAAI,OAAO,MAAQ,KAAK,KAAK,EACxE,EAAG,MAAM,KAAK,EAAI,OAAQ,OAAO,EAAG,OAAO,EAAI,OAAO,OAAS,KAAK,MAAM,CAC5E,GAEM,WAAa,CAAC,KAAM,OAAQ,QAAS,OAAQ,MAAO,YAAc,KAAO,CAC7E,MAAM,MAAQ,CACZ,GAAI,CAAE,EAAG,KAAK,EAAI,KAAK,MAAO,EAAG,KAAK,EAAI,KAAK,MAAO,EACtD,GAAI,CAAE,EAAG,KAAK,EAAG,EAAG,KAAK,EAAI,KAAK,MAAO,EACzC,GAAI,CAAE,EAAG,KAAK,EAAI,KAAK,MAAO,EAAG,KAAK,CAAE,EACxC,GAAI,CAAE,EAAG,KAAK,EAAG,EAAG,KAAK,CAAE,CAC7B,EAAE,MAAM,EACR,GAAI,CAAC,MAAO,OAAO,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