@yorab/react-paint 0.11.21 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +8 -9
  2. package/dist/canvas/components/Canvas.d.ts +12 -11
  3. package/dist/canvas/components/EditTextBox.d.ts +1 -2
  4. package/dist/canvas/constants/app.d.ts +12 -0
  5. package/dist/canvas/constants/zoom.d.ts +5 -0
  6. package/dist/canvas/hooks/useComponent.d.ts +4 -3
  7. package/dist/canvas/hooks/useDrawableCanvas.d.ts +14 -9
  8. package/dist/canvas/hooks/useKeyboard.d.ts +8 -2
  9. package/dist/canvas/hooks/usePinchZoomAndMove.d.ts +17 -0
  10. package/dist/canvas/hooks/useReactPaint.d.ts +40 -27
  11. package/dist/canvas/hooks/useResizeObserver.d.ts +1 -1
  12. package/dist/canvas/hooks/useShapes.d.ts +2 -2
  13. package/dist/canvas/hooks/useZoom.d.ts +21 -0
  14. package/dist/canvas/utils/file.d.ts +5 -1
  15. package/dist/canvas/utils/grid.d.ts +1 -1
  16. package/dist/canvas/utils/intersect.d.ts +12 -3
  17. package/dist/canvas/utils/selection/lineSelection.d.ts +1 -1
  18. package/dist/canvas/utils/selection/rectSelection.d.ts +1 -1
  19. package/dist/canvas/utils/shapes/brush.d.ts +2 -2
  20. package/dist/canvas/utils/shapes/circle.d.ts +2 -2
  21. package/dist/canvas/utils/shapes/curve.d.ts +3 -2
  22. package/dist/canvas/utils/shapes/ellipse.d.ts +2 -2
  23. package/dist/canvas/utils/shapes/index.d.ts +4 -3
  24. package/dist/canvas/utils/shapes/line.d.ts +1 -1
  25. package/dist/canvas/utils/shapes/path.d.ts +2 -2
  26. package/dist/canvas/utils/shapes/picture.d.ts +2 -2
  27. package/dist/canvas/utils/shapes/polygon.d.ts +3 -2
  28. package/dist/canvas/utils/shapes/rectangle.d.ts +3 -3
  29. package/dist/canvas/utils/shapes/text.d.ts +2 -2
  30. package/dist/canvas/utils/transform.d.ts +3 -2
  31. package/dist/canvas/utils/trigo.d.ts +2 -0
  32. package/dist/canvas/utils/zoom.d.ts +58 -0
  33. package/dist/common/types/Canvas.d.ts +8 -0
  34. package/dist/common/types/Mode.d.ts +8 -2
  35. package/dist/common/types/Shapes.d.ts +3 -1
  36. package/dist/common/types/tools.d.ts +4 -7
  37. package/dist/common/utils/util.d.ts +2 -0
  38. package/dist/editor/components/common/Modal.d.ts +3 -2
  39. package/dist/editor/components/common/Panel.d.ts +3 -1
  40. package/dist/editor/components/settings/ClosedPointsField.d.ts +10 -0
  41. package/dist/editor/components/settings/Layouts.d.ts +3 -2
  42. package/dist/editor/components/settings/SettingsBar.d.ts +6 -3
  43. package/dist/editor/components/settings/ZoomButton.d.ts +8 -0
  44. package/dist/editor/components/toolbox/ExportModal.d.ts +7 -0
  45. package/dist/editor/components/toolbox/MenuGroup.d.ts +3 -3
  46. package/dist/editor/components/toolbox/Toolbar.d.ts +5 -5
  47. package/dist/editor/constants/icons.d.ts +4 -4
  48. package/dist/editor/hooks/useDrag.d.ts +2 -2
  49. package/dist/react-paint.css +1 -1
  50. package/dist/react-paint.js +1249 -1038
  51. package/dist/react-paint.umd.cjs +1 -1
  52. package/package.json +18 -23
@@ -1,509 +1,565 @@
1
- import Fi, { useState as $, useEffect as G, useRef as J, useCallback as F, useMemo as Ni, useImperativeHandle as S1, useTransition as Ri } from "react";
2
- import { jsx as p, jsxs as R, Fragment as pe } from "react/jsx-runtime";
3
- const Ii = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>', Rt = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', It = '<svg><path d="M10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333ZM10 16.583Q12.75 16.583 14.667 14.667Q16.583 12.75 16.583 10Q16.583 7.25 14.667 5.333Q12.75 3.417 10 3.417Q7.25 3.417 5.333 5.333Q3.417 7.25 3.417 10Q3.417 12.75 5.333 14.667Q7.25 16.583 10 16.583ZM10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Z"/></svg>', Wt = '<svg><path d="M12.25 18.333V16.167L6.833 13.458H2.5V8.208H6.25L8.25 5.917V1.667H13.5V6.917H9.708L7.75 9.146V11.958L12.25 14.208V13.083H17.5V18.333Z"/></svg>', Wi = '<svg><path d="M4.125 5.083V3.333H7.062L7.896 2.5H12.104L12.938 3.333H15.875V5.083ZM6.75 17.5Q6.021 17.5 5.51 16.99Q5 16.479 5 15.75V5.958H15V15.75Q15 16.479 14.49 16.99Q13.979 17.5 13.25 17.5Z"/></svg>', qt = '<svg><path d="M10 17.5Q7.208 17.5 5.271 15.594Q3.333 13.688 3.333 10.958Q3.333 9.583 3.854 8.396Q4.375 7.208 5.292 6.292L10 1.667L14.688 6.292Q15.604 7.208 16.135 8.396Q16.667 9.583 16.667 10.958Q16.667 13.688 14.719 15.594Q12.771 17.5 10 17.5ZM5.146 11.667H14.854Q15.083 10.188 14.552 9.146Q14.021 8.104 13.479 7.562L10 4.125L6.521 7.562Q5.979 8.104 5.448 9.146Q4.917 10.188 5.146 11.667Z"/></svg>', zt = '<svg><path d="M4.792 15.083 8.333 11.542 9.833 13.021 11.667 10.708 15.167 15.083ZM6.667 8.417Q5.938 8.417 5.427 7.906Q4.917 7.396 4.917 6.667Q4.917 5.938 5.427 5.427Q5.938 4.917 6.667 4.917Q7.396 4.917 7.906 5.427Q8.417 5.938 8.417 6.667Q8.417 7.396 7.906 7.906Q7.396 8.417 6.667 8.417ZM4.167 18.333Q3.125 18.333 2.396 17.604Q1.667 16.875 1.667 15.833V4.167Q1.667 3.125 2.396 2.396Q3.125 1.667 4.167 1.667H15.833Q16.875 1.667 17.604 2.396Q18.333 3.125 18.333 4.167V15.833Q18.333 16.875 17.604 17.604Q16.875 18.333 15.833 18.333ZM4.167 16.583H15.833Q16.146 16.583 16.365 16.365Q16.583 16.146 16.583 15.833V4.167Q16.583 3.854 16.365 3.635Q16.146 3.417 15.833 3.417H4.167Q3.854 3.417 3.635 3.635Q3.417 3.854 3.417 4.167V15.833Q3.417 16.146 3.635 16.365Q3.854 16.583 4.167 16.583Z"/></svg>', zi = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', Oi = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', $i = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>', Jt = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>', Kt = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', ei = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', ti = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', ii = '<svg ><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM17 14.562 5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562Z"/></svg>', ce = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Fe = [0, 1, 2], ni = [[1, 0], [1, 2], [4, 6]], rt = "serif", b1 = 2, Ui = 3, C1 = 4, ee = "react-paint-", Ot = { type: "picture", id: `${ee}picture`, icon: zt, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, Bi = { type: "brush", id: `${ee}brush`, icon: Ii, label: "Brosse", settings: { strokeColor: { values: ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Fe, default: 0 } } }, Gi = { type: "line", id: `${ee}line`, icon: Oi, label: "Ligne", settings: { strokeColor: { values: ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, Xi = { type: "polygon", id: `${ee}polygon`, icon: Wt, label: "Polygone", settings: { strokeColor: { values: ce, default: "black" }, fillColor: { values: ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, Yi = { type: "curve", id: `${ee}curve`, icon: $i, label: "Courbe", settings: { strokeColor: { values: ce, default: "black" }, fillColor: { values: ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 }, pointsCount: { min: 3, max: 10, step: 1, default: 3 } } }, ji = { type: "rect", id: `${ee}rect`, icon: Rt, label: "Rectangle", settings: { strokeColor: { values: ce, default: "black" }, fillColor: { values: ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, _i = { type: "square", id: `${ee}square`, icon: Rt, label: "Carré", settings: { strokeColor: { values: ce, default: "black" }, fillColor: { values: ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, qi = { type: "circle", id: `${ee}circle`, icon: It, label: "Cercle", settings: { strokeColor: { values: ce, default: "black" }, fillColor: { values: ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, Ji = { type: "ellipse", id: `${ee}ellipse`, icon: It, label: "Ellipse", settings: { strokeColor: { values: ce, default: "black" }, fillColor: { values: ce, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, Ki = { type: "text", id: `${ee}text`, icon: zi, label: "Texte", settings: { strokeColor: { values: ce, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: rt }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Ae = { id: `${ee}selection`, type: "selection", icon: '<svg><path d="M8.0145 11.1707C8.38484 10.9914 8.82183 11.1558 8.99959 11.5295L10.7031 15.2591L12.0363 14.6238L10.3254 10.9017C10.1476 10.528 10.3106 10.0795 10.6809 9.90761L10.8883 9.84782L12.5918 9.51148L6.48133 4.33192V12.389L7.82934 11.2903L8.0145 11.1707ZM10.6587 16.9258C10.2883 17.1052 9.84395 16.9482 9.67359 16.5745L8.05894 13.0318L6.19988 14.5416C6.07396 14.6462 5.91842 14.706 5.74066 14.706C5.54423 14.706 5.35584 14.6272 5.21694 14.4871C5.07803 14.3469 5 14.1568 5 13.9586V2.74741C5 2.54919 5.07803 2.35908 5.21694 2.21891C5.35584 2.07874 5.54423 2 5.74066 2C5.91842 2 6.08878 2.06727 6.21469 2.1719L6.2221 2.16443L14.7323 9.36947C15.0508 9.63854 15.0879 10.1094 14.8286 10.4233C14.7175 10.5579 14.562 10.6475 14.4064 10.6774L12.0659 11.1408L13.6954 14.6761C13.888 15.0498 13.7102 15.4908 13.3399 15.6627L10.6587 16.9258Z"/></svg>', label: "Sélection" }, Xe = { id: `${ee}undo`, type: "undo", icon: '<svg><path d="M11.708 15.833H5.854V14.083H11.708Q13 14.083 13.958 13.292Q14.917 12.5 14.917 11.271Q14.917 10.042 13.958 9.24Q13 8.438 11.708 8.438H6.667L8.792 10.562L7.562 11.792L3.333 7.562L7.562 3.333L8.792 4.562L6.667 6.688H11.708Q13.729 6.688 15.198 7.99Q16.667 9.292 16.667 11.25Q16.667 13.208 15.198 14.521Q13.729 15.833 11.708 15.833Z"/></svg>', label: "Undo" }, Ye = { id: `${ee}redo`, type: "redo", icon: '<svg><path d="M8.292 15.833Q6.271 15.833 4.802 14.521Q3.333 13.208 3.333 11.25Q3.333 9.292 4.802 7.99Q6.271 6.688 8.292 6.688H13.333L11.208 4.562L12.438 3.333L16.667 7.562L12.438 11.792L11.208 10.562L13.333 8.438H8.292Q7 8.438 6.042 9.229Q5.083 10.021 5.083 11.25Q5.083 12.5 6.042 13.292Q7 14.083 8.292 14.083H14.146V15.833Z"/></svg>', label: "Redo" }, je = { id: `${ee}clear`, type: "clear", icon: '<svg><path d="M7.854 13.812 10 11.688 12.125 13.812 13.354 12.604 11.208 10.458 13.354 8.312 12.125 7.104 10 9.229 7.854 7.104 6.625 8.312 8.771 10.458 6.625 12.604ZM5.896 17.5Q5.167 17.5 4.656 16.99Q4.146 16.479 4.146 15.75V5.125H3.333V3.375H7.542V2.5H12.458V3.375H16.667V5.125H15.833V15.75Q15.833 16.479 15.323 16.99Q14.812 17.5 14.083 17.5Z"/></svg>', label: "Clear" }, kt = { id: `${ee}export`, type: "export", icon: '<svg><path d="M10 13.271 5.708 8.979 6.958 7.729 9.125 9.896V3.333H10.875V9.896L13.042 7.729L14.292 8.979ZM5.083 16.667Q4.354 16.667 3.844 16.156Q3.333 15.646 3.333 14.917V12.5H5.083V14.917Q5.083 14.917 5.083 14.917Q5.083 14.917 5.083 14.917H14.917Q14.917 14.917 14.917 14.917Q14.917 14.917 14.917 14.917V12.5H16.667V14.917Q16.667 15.646 16.156 16.156Q15.646 16.667 14.917 16.667Z"/></svg>', label: "Export PNG" }, ai = { id: `${ee}load`, type: "loadfile", icon: '<svg><path d="M3.417 16.667Q2.729 16.667 2.198 16.135Q1.667 15.604 1.667 14.917V5.083Q1.667 4.396 2.198 3.865Q2.729 3.333 3.417 3.333H8.25L9.917 5H16.667Q17.354 5 17.844 5.531Q18.333 6.062 18.333 6.75H3.417V14.917Q3.417 14.917 3.417 14.917Q3.417 14.917 3.417 14.917L5.438 8.5H19.583L17.396 15.479Q17.229 16.021 16.802 16.344Q16.375 16.667 15.833 16.667Z"/></svg>', label: "Load project" }, Lt = { id: `${ee}save`, type: "savefile", icon: '<svg><path d="M17.5 5.833V15.75Q17.5 16.479 16.99 16.99Q16.479 17.5 15.75 17.5H4.25Q3.521 17.5 3.01 16.99Q2.5 16.479 2.5 15.75V4.25Q2.5 3.521 3.01 3.01Q3.521 2.5 4.25 2.5H14.167ZM10 14.917Q11.062 14.917 11.823 14.156Q12.583 13.396 12.583 12.333Q12.583 11.271 11.823 10.51Q11.062 9.75 10 9.75Q8.938 9.75 8.177 10.51Q7.417 11.271 7.417 12.333Q7.417 13.396 8.177 14.156Q8.938 14.917 10 14.917ZM5.021 8.396H12.521V5.021H5.021Z"/></svg>', label: "Save project" }, si = { id: `${ee}upload-picture`, type: "uploadpicture", icon: zt, label: "Upload picture" }, e1 = 2, t1 = "blue", Te = 14, i1 = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], n1 = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"], a1 = "react-paint-canvas-drawcanvas", s1 = "react-paint-canvas-selectioncanvas", oi = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [Bi, Gi, Xi, Yi, ji, _i, qi, Ji, Ot, Ki], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !1, withSkeleton: !0, canvasSelectionPadding: 0 }, w1 = { canvasBackgroundColor: "white", canvasSelectionColor: t1, canvasSelectionWidth: e1 }, o1 = (e, i) => !!(e.target instanceof Node && i) && i.contains(e.target), ut = 300, Zt = (e, i) => {
4
- const t = { ...i };
5
- for (const n of e) delete t[n];
6
- return t;
7
- }, de = (e, i, t) => {
8
- const n = Array.isArray(t) ? [...t] : { ...t }, s = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
9
- return s.reduce((a, r, o) => (a[r] = Et(a[r]) ? { ...a[r] } : Array.isArray(a[r]) ? [...a[r]] : a[r] === void 0 || a[r] === null ? {} : a[r], o === s.length - 1 && (a[r] = i), a[r]), n), n;
10
- }, Et = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, xe = (e, i, t) => {
11
- if (!Et(i) || !Et(t)) return t;
12
- const n = { ...i };
13
- for (const s in t) t.hasOwnProperty(s) && (n.hasOwnProperty(s) ? n[s] = e(n[s], t[s], s) ?? xe(e, n[s], t[s]) : n[s] = t[s]);
1
+ import en, { useState as I, useEffect as q, useRef as j, useCallback as R, useMemo as tn, useImperativeHandle as ea, useTransition as nn } from "react";
2
+ import { jsx as p, jsxs as O, Fragment as xe } from "react/jsx-runtime";
3
+ const an = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>', Kt = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', Jt = '<svg><path d="M10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333ZM10 16.583Q12.75 16.583 14.667 14.667Q16.583 12.75 16.583 10Q16.583 7.25 14.667 5.333Q12.75 3.417 10 3.417Q7.25 3.417 5.333 5.333Q3.417 7.25 3.417 10Q3.417 12.75 5.333 14.667Q7.25 16.583 10 16.583ZM10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Q10 10 10 10Z"/></svg>', ei = '<svg><path d="M12.25 18.333V16.167L6.833 13.458H2.5V8.208H6.25L8.25 5.917V1.667H13.5V6.917H9.708L7.75 9.146V11.958L12.25 14.208V13.083H17.5V18.333Z"/></svg>', sn = '<svg><path d="M4.125 5.083V3.333H7.062L7.896 2.5H12.104L12.938 3.333H15.875V5.083ZM6.75 17.5Q6.021 17.5 5.51 16.99Q5 16.479 5 15.75V5.958H15V15.75Q15 16.479 14.49 16.99Q13.979 17.5 13.25 17.5Z"/></svg>', hi = '<svg><path d="M10 17.5Q7.208 17.5 5.271 15.594Q3.333 13.688 3.333 10.958Q3.333 9.583 3.854 8.396Q4.375 7.208 5.292 6.292L10 1.667L14.688 6.292Q15.604 7.208 16.135 8.396Q16.667 9.583 16.667 10.958Q16.667 13.688 14.719 15.594Q12.771 17.5 10 17.5ZM5.146 11.667H14.854Q15.083 10.188 14.552 9.146Q14.021 8.104 13.479 7.562L10 4.125L6.521 7.562Q5.979 8.104 5.448 9.146Q4.917 10.188 5.146 11.667Z"/></svg>', ti = '<svg><path d="M4.792 15.083 8.333 11.542 9.833 13.021 11.667 10.708 15.167 15.083ZM6.667 8.417Q5.938 8.417 5.427 7.906Q4.917 7.396 4.917 6.667Q4.917 5.938 5.427 5.427Q5.938 4.917 6.667 4.917Q7.396 4.917 7.906 5.427Q8.417 5.938 8.417 6.667Q8.417 7.396 7.906 7.906Q7.396 8.417 6.667 8.417ZM4.167 18.333Q3.125 18.333 2.396 17.604Q1.667 16.875 1.667 15.833V4.167Q1.667 3.125 2.396 2.396Q3.125 1.667 4.167 1.667H15.833Q16.875 1.667 17.604 2.396Q18.333 3.125 18.333 4.167V15.833Q18.333 16.875 17.604 17.604Q16.875 18.333 15.833 18.333ZM4.167 16.583H15.833Q16.146 16.583 16.365 16.365Q16.583 16.146 16.583 15.833V4.167Q16.583 3.854 16.365 3.635Q16.146 3.417 15.833 3.417H4.167Q3.854 3.417 3.635 3.635Q3.417 3.854 3.417 4.167V15.833Q3.417 16.146 3.635 16.365Q3.854 16.583 4.167 16.583Z"/></svg>', on = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', rn = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', ln = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>', ui = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>', pi = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', gi = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', fi = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM10 16.583Q10.896 16.583 11.708 16.365Q12.521 16.146 13.25 15.729L4.292 6.75Q3.875 7.479 3.646 8.292Q3.417 9.104 3.417 10Q3.417 12.729 5.344 14.656Q7.271 16.583 10 16.583ZM17 14.562 15.708 13.271Q16.125 12.542 16.354 11.719Q16.583 10.896 16.583 10Q16.583 7.271 14.656 5.344Q12.729 3.417 10 3.417Q9.104 3.417 8.292 3.646Q7.479 3.875 6.75 4.292L5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562ZM11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771Q11.229 8.771 11.229 8.771ZM8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Q8.771 11.229 8.771 11.229Z"/></svg>', vi = '<svg><path d="M16.354 18.833 14.521 17Q13.542 17.646 12.396 17.99Q11.25 18.333 10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.729 2.01 7.594Q2.354 6.458 3 5.458L1.167 3.625L2.396 2.396L17.583 17.604ZM17 14.562 5.458 3Q6.458 2.354 7.594 2.01Q8.729 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.271 17.979 12.417Q17.625 13.562 17 14.562Z"/></svg>', dn = '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Zm-40-60v-80h-80v-80h80v-80h80v80h80v80h-80v80h-80Z"/></svg>', ue = ["transparent", "black", "white", "red", "green", "blue", "yellow"], Fe = [0, 1, 2], mi = [[1, 0], [1, 2], [4, 6]], ut = "serif", ta = 2, cn = 3, ia = 4, ae = "react-paint-", ii = { type: "picture", id: `${ae}picture`, icon: ti, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, hn = { type: "brush", id: `${ae}brush`, icon: an, label: "Brosse", settings: { strokeColor: { values: ue, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: Fe, default: 0 } } }, un = { type: "line", id: `${ae}line`, icon: rn, label: "Ligne", settings: { strokeColor: { values: ue, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, pn = { type: "polygon", id: `${ae}polygon`, icon: ei, label: "Polygone", settings: { strokeColor: { values: ue, default: "black" }, fillColor: { values: ue, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 }, closedPoints: { default: 0 } } }, gn = { type: "curve", id: `${ae}curve`, icon: ln, label: "Courbe", settings: { strokeColor: { values: ue, default: "black" }, fillColor: { values: ue, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 }, closedPoints: { default: 0 } } }, fn = { type: "rect", id: `${ae}rect`, icon: Kt, label: "Rectangle", settings: { strokeColor: { values: ue, default: "black" }, fillColor: { values: ue, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, vn = { type: "square", id: `${ae}square`, icon: Kt, label: "Carré", settings: { strokeColor: { values: ue, default: "black" }, fillColor: { values: ue, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, mn = { type: "circle", id: `${ae}circle`, icon: Jt, label: "Cercle", settings: { strokeColor: { values: ue, default: "black" }, fillColor: { values: ue, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, yn = { type: "ellipse", id: `${ae}ellipse`, icon: Jt, label: "Ellipse", settings: { strokeColor: { values: ue, default: "black" }, fillColor: { values: ue, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: Fe, default: 0 } } }, Qn = { type: "text", id: `${ae}text`, icon: on, label: "Texte", settings: { strokeColor: { values: ue, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: ut }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Ae = { id: `${ae}selection`, type: "selection", icon: '<svg><path d="M8.0145 11.1707C8.38484 10.9914 8.82183 11.1558 8.99959 11.5295L10.7031 15.2591L12.0363 14.6238L10.3254 10.9017C10.1476 10.528 10.3106 10.0795 10.6809 9.90761L10.8883 9.84782L12.5918 9.51148L6.48133 4.33192V12.389L7.82934 11.2903L8.0145 11.1707ZM10.6587 16.9258C10.2883 17.1052 9.84395 16.9482 9.67359 16.5745L8.05894 13.0318L6.19988 14.5416C6.07396 14.6462 5.91842 14.706 5.74066 14.706C5.54423 14.706 5.35584 14.6272 5.21694 14.4871C5.07803 14.3469 5 14.1568 5 13.9586V2.74741C5 2.54919 5.07803 2.35908 5.21694 2.21891C5.35584 2.07874 5.54423 2 5.74066 2C5.91842 2 6.08878 2.06727 6.21469 2.1719L6.2221 2.16443L14.7323 9.36947C15.0508 9.63854 15.0879 10.1094 14.8286 10.4233C14.7175 10.5579 14.562 10.6475 14.4064 10.6774L12.0659 11.1408L13.6954 14.6761C13.888 15.0498 13.7102 15.4908 13.3399 15.6627L10.6587 16.9258Z"/></svg>', label: "Sélection" }, je = { id: `${ae}undo`, type: "undo", icon: '<svg><path d="M11.708 15.833H5.854V14.083H11.708Q13 14.083 13.958 13.292Q14.917 12.5 14.917 11.271Q14.917 10.042 13.958 9.24Q13 8.438 11.708 8.438H6.667L8.792 10.562L7.562 11.792L3.333 7.562L7.562 3.333L8.792 4.562L6.667 6.688H11.708Q13.729 6.688 15.198 7.99Q16.667 9.292 16.667 11.25Q16.667 13.208 15.198 14.521Q13.729 15.833 11.708 15.833Z"/></svg>', label: "Undo" }, Ke = { id: `${ae}redo`, type: "redo", icon: '<svg><path d="M8.292 15.833Q6.271 15.833 4.802 14.521Q3.333 13.208 3.333 11.25Q3.333 9.292 4.802 7.99Q6.271 6.688 8.292 6.688H13.333L11.208 4.562L12.438 3.333L16.667 7.562L12.438 11.792L11.208 10.562L13.333 8.438H8.292Q7 8.438 6.042 9.229Q5.083 10.021 5.083 11.25Q5.083 12.5 6.042 13.292Q7 14.083 8.292 14.083H14.146V15.833Z"/></svg>', label: "Redo" }, Je = { id: `${ae}clear`, type: "clear", icon: '<svg><path d="M7.854 13.812 10 11.688 12.125 13.812 13.354 12.604 11.208 10.458 13.354 8.312 12.125 7.104 10 9.229 7.854 7.104 6.625 8.312 8.771 10.458 6.625 12.604ZM5.896 17.5Q5.167 17.5 4.656 16.99Q4.146 16.479 4.146 15.75V5.125H3.333V3.375H7.542V2.5H12.458V3.375H16.667V5.125H15.833V15.75Q15.833 16.479 15.323 16.99Q14.812 17.5 14.083 17.5Z"/></svg>', label: "Clear" }, Nt = { id: `${ae}export`, type: "export", icon: '<svg><path d="M10 13.271 5.708 8.979 6.958 7.729 9.125 9.896V3.333H10.875V9.896L13.042 7.729L14.292 8.979ZM5.083 16.667Q4.354 16.667 3.844 16.156Q3.333 15.646 3.333 14.917V12.5H5.083V14.917Q5.083 14.917 5.083 14.917Q5.083 14.917 5.083 14.917H14.917Q14.917 14.917 14.917 14.917Q14.917 14.917 14.917 14.917V12.5H16.667V14.917Q16.667 15.646 16.156 16.156Q15.646 16.667 14.917 16.667Z"/></svg>', label: "Export PNG" }, yi = { id: `${ae}load`, type: "loadfile", icon: '<svg><path d="M3.417 16.667Q2.729 16.667 2.198 16.135Q1.667 15.604 1.667 14.917V5.083Q1.667 4.396 2.198 3.865Q2.729 3.333 3.417 3.333H8.25L9.917 5H16.667Q17.354 5 17.844 5.531Q18.333 6.062 18.333 6.75H3.417V14.917Q3.417 14.917 3.417 14.917Q3.417 14.917 3.417 14.917L5.438 8.5H19.583L17.396 15.479Q17.229 16.021 16.802 16.344Q16.375 16.667 15.833 16.667Z"/></svg>', label: "Load project" }, Rt = { id: `${ae}save`, type: "savefile", icon: '<svg><path d="M17.5 5.833V15.75Q17.5 16.479 16.99 16.99Q16.479 17.5 15.75 17.5H4.25Q3.521 17.5 3.01 16.99Q2.5 16.479 2.5 15.75V4.25Q2.5 3.521 3.01 3.01Q3.521 2.5 4.25 2.5H14.167ZM10 14.917Q11.062 14.917 11.823 14.156Q12.583 13.396 12.583 12.333Q12.583 11.271 11.823 10.51Q11.062 9.75 10 9.75Q8.938 9.75 8.177 10.51Q7.417 11.271 7.417 12.333Q7.417 13.396 8.177 14.156Q8.938 14.917 10 14.917ZM5.021 8.396H12.521V5.021H5.021Z"/></svg>', label: "Save project" }, Ot = { id: `${ae}move`, type: "move", icon: '<svg viewBox="0 -960 960 960"><path d="M412-48q-21.95 0-40.98-9Q352-66 338-83L48-434l27-28q17-17 41.5-20.5T162-473l126 74v-381q0-15.3 10.29-25.65Q308.58-816 323.79-816t25.71 10.35Q360-795.3 360-780v300h80v-396q0-15.3 10.29-25.65Q460.58-912 475.79-912t25.71 10.35Q512-891.3 512-876v396h80v-348q0-15.3 10.29-25.65Q612.58-864 627.79-864t25.71 10.35Q664-843.3 664-828v348h80v-252q0-15.3 10.29-25.65Q764.58-768 779.79-768t25.71 10.35Q816-747.3 816-732v540q0 60-42 102T672-48H412Z"/></svg>', label: "Move" }, Qi = { id: `${ae}upload-picture`, type: "uploadpicture", icon: ti, label: "Upload picture" }, Sn = 2, bn = "blue", Xe = 14, wn = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], Cn = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle"], xn = "react-paint-canvas-drawcanvas", Mn = "react-paint-canvas-selectioncanvas", Si = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, availableTools: [hn, un, pn, gn, fn, vn, mn, yn, ii, Qn], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !1, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never" }, na = { canvasBackgroundColor: "white", canvasSelectionColor: bn, canvasSelectionWidth: Sn }, kn = (e, t) => !!(e.target instanceof Node && t) && t.contains(e.target), xt = 300, Xt = (e, t) => {
4
+ const i = { ...t };
5
+ for (const n of e) delete i[n];
6
+ return i;
7
+ }, me = (e, t, i) => {
8
+ const n = Array.isArray(i) ? [...i] : { ...i }, s = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
9
+ return s.reduce((a, o, r) => (a[o] = Yt(a[o]) ? { ...a[o] } : Array.isArray(a[o]) ? [...a[o]] : a[o] === void 0 || a[o] === null ? {} : a[o], r === s.length - 1 && (a[o] = t), a[o]), n), n;
10
+ }, Yt = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Ve = (e, t, i) => {
11
+ if (!Yt(t) || !Yt(i)) return i;
12
+ const n = { ...t };
13
+ for (const s in i) i.hasOwnProperty(s) && (n.hasOwnProperty(s) ? n[s] = e(n[s], i[s], s) ?? Ve(e, n[s], i[s]) : n[s] = i[s]);
14
14
  return n;
15
- }, r1 = (e, i) => {
16
- if (e === i) return !0;
17
- if (typeof e != "object" || typeof i != "object" || e === null || i === null) return !1;
18
- const t = Object.keys(e), n = Object.keys(i);
19
- if (t.length !== n.length) return !1;
20
- for (const s of t) if (!n.includes(s) || !r1(e[s], i[s])) return !1;
15
+ }, Pn = (e, t) => {
16
+ if (e === t) return !0;
17
+ if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
18
+ const i = Object.keys(e), n = Object.keys(t);
19
+ if (i.length !== n.length) return !1;
20
+ for (const s of i) if (!n.includes(s) || !Pn(e[s], t[s])) return !1;
21
21
  return !0;
22
- }, Vt = {}, re = (e = "") => (Vt[e] || (Vt[e] = 0), `${e}${++Vt[e]}`), $t = (e) => e.filter((i) => i != null), l1 = (e) => {
23
- e.lineCap = "round", e.lineJoin = "round";
24
- }, ze = (e, i = {}) => {
25
- const { lineCap: t = "round", fillColor: n = "transparent", opacity: s = 100, strokeColor: a = t1, lineWidth: r = e1, lineDash: o = 0 } = i;
26
- e.lineCap = t, e.globalAlpha = s / 100, e.fillStyle = n, e.strokeStyle = a, e.lineWidth = r, e.setLineDash(o === 0 ? [] : [ni[o][0] * r, ni[o][1] * r]);
27
- }, Ut = (e, i, t, n) => {
28
- e.save(), e.scale(i.canvasSize.scaleRatio, i.canvasSize.scaleRatio), e.translate(i.canvasOffset[0], i.canvasOffset[1]), t && n && (e.translate(n[0], n[1]), e.rotate(t), e.translate(-n[0], -n[1]));
29
- }, gt = (e) => {
22
+ }, It = {}, ce = (e = "") => (It[e] || (It[e] = 0), `${e}${++It[e]}`), Ie = (e, t, i) => Math.max(t, Math.min(e, i)), Ln = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), Vn = (e) => {
23
+ e.reset(), e.lineCap = "round", e.lineJoin = "round";
24
+ }, Ye = (e, t = {}) => {
25
+ const { lineCap: i = "round", fillColor: n = "transparent", opacity: s = 100, strokeColor: a = bn, lineWidth: o = Sn, lineDash: r = 0 } = t;
26
+ e.lineCap = i, e.globalAlpha = s / 100, e.fillStyle = n, e.strokeStyle = a, e.lineWidth = o, e.setLineDash(r === 0 ? [] : [mi[r][0] * o, mi[r][1] * o]);
27
+ }, ni = (e, t, i, n) => {
28
+ e.save(), e.scale(t.canvasSize.scaleRatio, t.canvasSize.scaleRatio), e.translate(t.canvasOffset[0], t.canvasOffset[1]), i && n && (e.translate(n[0], n[1]), e.rotate(i), e.translate(-n[0], -n[1]));
29
+ }, ai = (e) => {
30
+ const t = new Path2D();
31
+ return t.rect(e.x, e.y, e.width, e.height), t;
32
+ }, Mt = (e) => {
33
+ const t = new Path2D();
34
+ return t.arc(e.x, e.y, e.radius, 0, 2 * Math.PI), t;
35
+ }, dt = (e) => {
36
+ const t = new Path2D();
37
+ return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t;
38
+ }, Hn = (e) => {
39
+ const t = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
40
+ if (t.length < 2) return;
30
41
  const i = new Path2D();
31
- return i.rect(e.x, e.y, e.width, e.height), i;
32
- }, vt = (e) => {
33
- const i = new Path2D();
34
- return i.arc(e.x, e.y, e.radius, 0, 2 * Math.PI), i;
35
- }, Dt = (e) => {
36
- const i = new Path2D();
37
- return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i;
38
- }, x1 = (e) => {
39
- const i = new Path2D();
40
- return i.moveTo(...e.points[0]), i.lineTo(...e.points[1]), i.lineTo(...e.points[2]), i.lineTo(...e.points[0]), i;
41
- }, Bt = (e, i, t, n = !1) => {
42
- const { borders: s } = q(i, t);
43
- return { border: gt(s), shapePath: e, anchors: [...i.points.map((a, r) => n && r > 0 && r < i.points.length - 1 ? gt({ x: a[0] - 7, y: a[1] - 7, width: Te / t.canvasSize.scaleRatio, height: Te / t.canvasSize.scaleRatio }) : vt({ x: a[0], y: a[1], radius: 7 / t.canvasSize.scaleRatio }))] };
44
- }, Je = (e, i) => {
45
- const t = ((n, { brushAlgo: s }) => {
46
- if (n.points.length < 1 || n.style?.strokeColor === "transparent") return;
47
- const a = n.points.flat(), r = a.map((c) => c[0]), o = a.map((c) => c[1]), l = Math.min(...r), h = Math.min(...o), d = new Path2D();
48
- for (const c of n.points) {
49
- if (!c.length) return;
50
- if (c.length === 1) d.rect(...Qe(c[0], l, h, n.scaleX, n.scaleY), 1, 1);
51
- else if (d.moveTo(...Qe(c[0], l, h, n.scaleX, n.scaleY)), s === "quadratic") {
52
- for (let u = 0; u < c.slice(1).length - 2; u++) {
53
- const g = Qe(c[u], l, h, n.scaleX, n.scaleY), f = Qe(c[u + 1], l, h, n.scaleX, n.scaleY), x = (g[0] + f[0]) / 2, w = (g[1] + f[1]) / 2;
54
- d.quadraticCurveTo(...g, x, w);
55
- }
56
- d.quadraticCurveTo(...Qe(c[c.length - 2], l, h, n.scaleX, n.scaleY), ...Qe(c[c.length - 1], l, h, n.scaleX, n.scaleY));
57
- } else for (const u of c.slice(1)) d.lineTo(...Qe(u, l, h, n.scaleX, n.scaleY));
58
- }
59
- return d;
60
- })(e, i);
61
- return { ...e, path: t, selection: Ke(t, e, i) };
62
- }, M1 = Je, Ft = (e) => 180 * e / Math.PI, d1 = (e, i) => {
63
- const t = i.x - Math.min(Math.max(i.x, e.x), e.x + e.width), n = i.y - Math.min(Math.max(i.y, e.y), e.y + e.height);
64
- return Math.sqrt(t * t + n * n) <= i.radius;
65
- }, ve = ({ origin: e = [0, 0], point: i, rotation: t }) => {
66
- const n = [i[0] - e[0], i[1] - e[1]], s = n[1] * Math.cos(t) - n[0] * Math.sin(t);
67
- return [n[1] * Math.sin(t) + n[0] * Math.cos(t) + e[0], s + e[1]];
68
- }, ri = (e) => (e + 2 * Math.PI) % (2 * Math.PI), li = ({ targetVector: [e, i], radian: t = !0, originVector: n }) => {
69
- const s = ri(Math.atan2(i[1] - e[1], i[0] - e[0]));
42
+ i.moveTo(...t[0]);
43
+ for (const n of t.slice(1)) i.lineTo(...n);
44
+ return t.length > 2 && e.style?.closedPoints === 1 && i.lineTo(...t[0]), i;
45
+ }, aa = (e) => {
46
+ const t = new Path2D();
47
+ return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t.lineTo(...e.points[2]), t.lineTo(...e.points[0]), t;
48
+ }, qt = (e) => 180 * e / Math.PI, Zn = (e, t) => {
49
+ const i = t.x - Math.min(Math.max(t.x, e.x), e.x + e.width), n = t.y - Math.min(Math.max(t.y, e.y), e.y + e.height);
50
+ return Math.sqrt(i * i + n * n) <= t.radius;
51
+ }, be = ({ origin: e = [0, 0], point: t, rotation: i }) => {
52
+ const n = [t[0] - e[0], t[1] - e[1]], s = n[1] * Math.cos(i) - n[0] * Math.sin(i);
53
+ return [n[1] * Math.sin(i) + n[0] * Math.cos(i) + e[0], s + e[1]];
54
+ }, bi = (e) => (e + 2 * Math.PI) % (2 * Math.PI), wi = ({ targetVector: [e, t], radian: i = !0, originVector: n }) => {
55
+ const s = bi(Math.atan2(t[1] - e[1], t[0] - e[0]));
70
56
  if (n) {
71
- const [a, r] = n, o = Math.atan2(r[1] - a[1], r[0] - a[0]), l = ri(s - o);
72
- return t ? l : Ft(l);
57
+ const [a, o] = n, r = Math.atan2(o[1] - a[1], o[0] - a[0]), l = bi(s - r);
58
+ return i ? l : qt(l);
73
59
  }
74
- return t ? s : Ft(s);
75
- }, De = (e, i = 2) => Math.round(e * 10 ** i) / 10 ** i, Qe = (e, i, t, n = 1, s = 1) => [i + (e[0] - i) * n, t + (e[1] - t) * s], B = (e, i, t = 0) => {
76
- if (!i.gridGap) return De(e);
77
- const n = e + t, s = n >= 0 ? i.gridGap : -i.gridGap;
78
- return n + s / 2 - (n + s / 2) % s - t;
79
- }, k1 = (e, i, t = 0) => i.gridGap ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : De(e, 3), L1 = (e, i, t, n, s, a) => {
80
- switch (n.mode) {
81
- case "brush":
82
- return ((r, o, l) => {
83
- const h = { ...r, points: de(r.points.length - 1, [...r.points[r.points.length - 1], [Math.round(o[0]), Math.round(o[1])]], r.points) };
84
- return Je(h, l);
85
- })(i, t, s);
86
- case "translate":
87
- return Nt(t, n.originalShape, n.cursorStartPosition, s);
88
- case "rotate":
89
- return O1(i, t, n.originalShape, n.cursorStartPosition, n.center, s);
90
- case "resize":
91
- return $1(e, i, t, n.originalShape, n, s, a);
92
- default:
93
- return i;
94
- }
95
- }, Ke = (e, i, t) => {
96
- const { borders: n } = q(i, t);
97
- return { border: gt(n), shapePath: e, line: Dt({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / t.canvasSize.scaleRatio]] }), anchors: [vt({ x: n.x + n.width / 2, y: n.y - 23 / t.canvasSize.scaleRatio, radius: 7 / t.canvasSize.scaleRatio }), ...i1.map((s) => vt({ x: n.x + n.width * s[0], y: n.y + n.height * s[1], radius: 7 / t.canvasSize.scaleRatio }))] };
98
- }, di = ({ borderStart: e, borderSize: i, vector: t, settings: n, invertedAxe: s, anchor: a }) => {
60
+ return i ? s : qt(s);
61
+ }, Tn = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), ct = (e, t) => [(e[0] + t[0]) / 2, (e[1] + t[1]) / 2], tt = (e, t, i) => {
62
+ const { borders: n } = J(t, i);
63
+ return { border: ai(n), shapePath: e, line: dt({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: [Mt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...wn.map((s) => Mt({ x: n.x + n.width * s[0], y: n.y + n.height * s[1], radius: 7 / i.canvasSize.scaleRatio }))] };
64
+ }, Ci = ({ borderStart: e, borderSize: t, vector: i, settings: n, invertedAxe: s, anchor: a }) => {
99
65
  switch (a) {
100
66
  case 0: {
101
67
  if (s) {
102
- const o = i - 2 * n.selectionPadding;
103
- return [e + o, t - o];
68
+ const r = t - 2 * n.selectionPadding;
69
+ return [e + r, i - r];
104
70
  }
105
- const r = Math.max(2 * n.selectionPadding, i - t);
106
- return [e + i - r, r];
71
+ const o = Math.max(2 * n.selectionPadding, t - i);
72
+ return [e + t - o, o];
107
73
  }
108
74
  case 0.5:
109
- return [e, i];
75
+ return [e, t];
110
76
  case 1:
111
77
  if (s) {
112
- const r = i + t;
113
- return [e + r, 2 * n.selectionPadding - r];
78
+ const o = t + i;
79
+ return [e + o, 2 * n.selectionPadding - o];
114
80
  }
115
- return [e, Math.max(2 * n.selectionPadding, i + t)];
81
+ return [e, Math.max(2 * n.selectionPadding, t + i)];
116
82
  default:
117
83
  return [0, 0];
118
84
  }
119
- }, ci = ({ borderX: e, borderWidth: i, borderY: t, borderHeight: n, center: s, originalShape: a }) => {
120
- const r = [e + i / 2 - s[0], t + n / 2 - s[1]], [o, l] = ve({ point: r, rotation: -a.rotation });
121
- return { borderX: De(e + o - r[0]), borderWidth: De(i), borderY: De(t + l - r[1]), borderHeight: De(n) };
122
- }, Ge = (e, i, t, n, s = !1) => {
123
- const { center: a, borders: r } = q(i, n), o = ve({ origin: a, point: e, rotation: i.rotation }), l = t.anchor[0] === 0 && o[0] >= r.x + r.width || t.anchor[0] === 1 && o[0] <= r.x, h = t.anchor[1] === 0 && o[1] >= r.y + r.height || t.anchor[1] === 1 && o[1] <= r.y, d = [B(o[0], n, t.anchor[0] === 0 && !l || t.anchor[0] === 1 && l ? n.selectionPadding : -n.selectionPadding), B(o[1], n, t.anchor[1] === 0 && !h || t.anchor[1] === 1 && h ? n.selectionPadding : -n.selectionPadding)], c = n.gridGap ? [t.anchor[0] === 0 ? r.x : t.anchor[0] === 0.5 ? r.x + r.width / 2 : r.x + r.width, t.anchor[1] === 0 ? r.y : t.anchor[1] === 0.5 ? r.y + r.height / 2 : r.y + r.height] : ve({ origin: a, point: t.cursorStartPosition, rotation: i.rotation }), u = [d[0] - c[0], d[1] - c[1]], [g, f] = di({ borderStart: r.x, borderSize: r.width, vector: u[0], settings: n, invertedAxe: l, anchor: t.anchor[0] }), [x, w] = di({ borderStart: r.y, borderSize: r.height, vector: u[1], settings: n, invertedAxe: h, anchor: t.anchor[1] });
124
- if (s) {
125
- const Q = ((L, b, k, P, E, H, T, C, V, I) => {
126
- const { selectionPadding: y } = I, N = (b.width - 2 * y || 1) / (b.height - 2 * y || 1), M = (E - 2 * y) / (T - 2 * y);
127
- let A, Z, v, m;
128
- return V.anchor[0] !== 0.5 && V.anchor[1] !== 0.5 ? M < N ? (Z = H, m = T, v = (T - 2 * y) * N + 2 * y, A = V.anchor[0] === 0 ? b.width - L[0] > y ? b.x + (b.width - v) : b.x + b.width - 2 * y : b.width + L[0] > y ? b.x : b.x - v + 2 * y) : (A = P, v = E, m = (E - 2 * y) / N + 2 * y, Z = V.anchor[1] === 0 ? b.height - L[1] > y ? b.y + (b.height - m) : b.y + b.height - 2 * y : b.height + L[1] > y ? b.y : b.y - m + 2 * y) : V.anchor[0] !== 0.5 ? (A = P, v = E, m = (E - 2 * y) / N + 2 * y, Z = b.y + (b.height - m) / 2) : (Z = H, m = T, v = (T - 2 * y) * N + 2 * y, A = b.x + (b.width - v) / 2), { borderX: A, borderWidth: v, borderY: Z, borderHeight: m, center: k, originalShape: C };
129
- })(u, r, a, g, f, x, w, i, t, n);
130
- return ci(Q);
85
+ }, _e = (e, t, i, n, s = !1, a = !1) => {
86
+ const { center: o, borders: r } = J(t, n), l = be({ origin: o, point: e, rotation: t.rotation }), c = i.anchor[0] === 0 && l[0] >= r.x + r.width || i.anchor[0] === 1 && l[0] <= r.x, h = i.anchor[1] === 0 && l[1] >= r.y + r.height || i.anchor[1] === 1 && l[1] <= r.y, d = [$(l[0], n, i.anchor[0] === 0 && !c || i.anchor[0] === 1 && c ? n.selectionPadding : -n.selectionPadding), $(l[1], n, i.anchor[1] === 0 && !h || i.anchor[1] === 1 && h ? n.selectionPadding : -n.selectionPadding)], u = n.gridGap ? [i.anchor[0] === 0 ? r.x : i.anchor[0] === 0.5 ? r.x + r.width / 2 : r.x + r.width, i.anchor[1] === 0 ? r.y : i.anchor[1] === 0.5 ? r.y + r.height / 2 : r.y + r.height] : be({ origin: o, point: i.cursorStartPosition, rotation: t.rotation }), g = [d[0] - u[0], d[1] - u[1]], [f, w] = Ci({ borderStart: r.x, borderSize: r.width, vector: g[0], settings: n, invertedAxe: c, anchor: i.anchor[0] }), [C, x] = Ci({ borderStart: r.y, borderSize: r.height, vector: g[1], settings: n, invertedAxe: h, anchor: i.anchor[1] }), b = s ? ((M, v, Q, H, Z, E, D, P, W, N) => {
87
+ const { selectionPadding: z } = N, B = (v.width - 2 * z || 1) / (v.height - 2 * z || 1), U = (Z - 2 * z) / (D - 2 * z);
88
+ let L, m, y, S;
89
+ return W.anchor[0] !== 0.5 && W.anchor[1] !== 0.5 ? U < B ? (m = E, S = D, y = (D - 2 * z) * B + 2 * z, L = W.anchor[0] === 0 ? v.width - M[0] > z ? v.x + (v.width - y) : v.x + v.width - 2 * z : v.width + M[0] > z ? v.x : v.x - y + 2 * z) : (L = H, y = Z, S = (Z - 2 * z) / B + 2 * z, m = W.anchor[1] === 0 ? v.height - M[1] > z ? v.y + (v.height - S) : v.y + v.height - 2 * z : v.height + M[1] > z ? v.y : v.y - S + 2 * z) : W.anchor[0] !== 0.5 ? (L = H, y = Z, S = (Z - 2 * z) / B + 2 * z, m = v.y + (v.height - S) / 2) : (m = E, S = D, y = (D - 2 * z) * B + 2 * z, L = v.x + (v.width - y) / 2), { borderX: L, borderWidth: y, borderY: m, borderHeight: S, center: Q, originalShape: P };
90
+ })(g, r, o, f, w, C, x, t, i, n) : { borderX: f, borderWidth: w, borderY: C, borderHeight: x, center: o, originalShape: t };
91
+ return (({ borderX: M, borderWidth: v, borderY: Q, borderHeight: H, center: Z, originalShape: E }) => {
92
+ const D = [M + v / 2 - Z[0], Q + H / 2 - Z[1]], [P, W] = be({ point: D, rotation: -E.rotation });
93
+ return { borderX: Oe(M + P - D[0]), borderWidth: Oe(v), borderY: Oe(Q + W - D[1]), borderHeight: Oe(H) };
94
+ })(a ? ((M, v, Q, H) => {
95
+ const Z = v.x + v.width / 2, E = v.y + v.height / 2, D = Q ? 2 * M.borderWidth + v.width : Math.abs(v.width + 2 * (M.borderWidth - v.width)), P = H ? 2 * M.borderHeight + v.height : Math.abs(v.height + 2 * (M.borderHeight - v.height));
96
+ return { ...M, borderHeight: P, borderWidth: D, borderX: Z - D / 2, borderY: E - P / 2 };
97
+ })(b, r, c, h) : b);
98
+ }, it = (e, t) => {
99
+ const i = ((n, { brushAlgo: s }) => {
100
+ if (n.points.length < 1 || n.style?.strokeColor === "transparent") return;
101
+ const a = n.points.flat(), o = a.map((d) => d[0]), r = a.map((d) => d[1]), l = Math.min(...o), c = Math.min(...r), h = new Path2D();
102
+ for (const d of n.points) {
103
+ if (!d.length) return;
104
+ if (d.length === 1) h.rect(...Me(d[0], l, c, n.scaleX, n.scaleY), 1, 1);
105
+ else if (h.moveTo(...Me(d[0], l, c, n.scaleX, n.scaleY)), s === "quadratic") {
106
+ for (let u = 0; u < d.slice(1).length - 2; u++) {
107
+ const g = Me(d[u], l, c, n.scaleX, n.scaleY), f = Me(d[u + 1], l, c, n.scaleX, n.scaleY), w = (g[0] + f[0]) / 2, C = (g[1] + f[1]) / 2;
108
+ h.quadraticCurveTo(...g, w, C);
109
+ }
110
+ h.quadraticCurveTo(...Me(d[d.length - 2], l, c, n.scaleX, n.scaleY), ...Me(d[d.length - 1], l, c, n.scaleX, n.scaleY));
111
+ } else for (const u of d.slice(1)) h.lineTo(...Me(u, l, c, n.scaleX, n.scaleY));
112
+ }
113
+ return h;
114
+ })(e, t);
115
+ return { ...e, path: i, selection: tt(i, e, t) };
116
+ }, sa = it, Oe = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, Me = (e, t, i, n = 1, s = 1) => [t + (e[0] - t) * n, i + (e[1] - i) * s], $ = (e, t, i = 0) => {
117
+ if (!t.gridGap) return Oe(e);
118
+ const n = e + i, s = n >= 0 ? t.gridGap : -t.gridGap;
119
+ return n + s / 2 - (n + s / 2) % s - i;
120
+ }, oa = (e, t, i) => t.gridGap || i ? e + Math.PI / 18 / 2 - (e + Math.PI / 18 / 2) % (Math.PI / 18) : Oe(e, 3), ze = (e, t) => t ? [Math.abs(e[0]) > Math.abs(e[1]) ? e[0] : 0, Math.abs(e[1]) > Math.abs(e[0]) ? e[1] : 0] : e, ra = (e, t, i, n, s, a, o) => {
121
+ switch (n.mode) {
122
+ case "brush":
123
+ return ((r, l, c) => {
124
+ const h = { ...r, points: me(r.points.length - 1, [...r.points[r.points.length - 1], [Math.round(l[0]), Math.round(l[1])]], r.points) };
125
+ return it(h, c);
126
+ })(t, i, s);
127
+ case "translate":
128
+ return jt(i, n.originalShape, n.cursorStartPosition, s, a);
129
+ case "rotate":
130
+ return wa(t, i, n.originalShape, n.cursorStartPosition, n.center, s, a);
131
+ case "resize":
132
+ return Ca(e, t, i, n.originalShape, n, s, a, o);
133
+ default:
134
+ return t;
131
135
  }
132
- return ci({ borderX: g, borderWidth: f, borderY: x, borderHeight: w, center: a, originalShape: i });
133
- }, ft = (e, i) => {
134
- const t = vt(e);
135
- return { ...e, path: t, selection: Ke(t, e, i) };
136
- }, V1 = ft, Pt = (e, i, t) => {
137
- const { clientX: n = 0, clientY: s = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {}, a = i?.getBoundingClientRect() ?? { left: 0, top: 0, width: t.canvasSize.width, height: t.canvasSize.height };
138
- return [(n - a.left) * (t.canvasSize.width / a.width) / t.canvasSize.scaleRatio, (s - a.top) * (t.canvasSize.height / a.height) / t.canvasSize.scaleRatio];
139
- }, hi = (e) => "touches" in e, Oe = (e, i, [t, n], [s, a]) => ve({ origin: [t - s, n - a], point: e, rotation: i }), dt = (e, i, t) => t ? d1(e, { x: i[0], y: i[1], radius: t }) : ((n, s) => s[0] >= n.x && s[0] <= n.x + n.width && s[1] >= n.y && s[1] <= n.y + n.height)(e, i), st = (e, i, t, n = !1, s = 0) => {
136
+ }, zn = (e) => {
137
+ const { clientX: t = 0, clientY: i = 0 } = "touches" in e && e.touches[0] ? e.touches[0] : "changedTouches" in e && e.changedTouches[0] ? e.changedTouches[0] : "clientX" in e ? e : {};
138
+ return { clientX: t, clientY: i };
139
+ }, mt = (e, t, i) => {
140
+ const { clientX: n, clientY: s } = zn(e), a = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
141
+ return [(n - a.left) * (i.canvasSize.width / a.width) / i.canvasSize.scaleRatio - i.canvasOffset[0], (s - a.top) * (i.canvasSize.height / a.height) / i.canvasSize.scaleRatio - i.canvasOffset[1]];
142
+ }, lt = (e) => "touches" in e, He = (e, t, [i, n]) => be({ origin: [i, n], point: e, rotation: t }), yt = (e, t, i) => i ? Zn(e, { x: t[0], y: t[1], radius: i }) : ((n, s) => s[0] >= n.x && s[0] <= n.x + n.width && s[1] >= n.y && s[1] <= n.y + n.height)(e, t), ht = (e, t, i, n = !1, s = 0) => {
140
143
  if (e.locked) return !1;
141
- const { canvasSize: { scaleRatio: a } } = t, { borders: r, center: o } = q(e, t), l = Oe(i, e.rotation, o, t.canvasOffset);
144
+ const { canvasSize: { scaleRatio: a } } = i, { borders: o, center: r } = J(e, i), l = He(t, e.rotation, r);
142
145
  if (n) if (e.type === "line" || e.type === "polygon" || e.type === "curve") {
143
- for (let h = 0; h < e.points.length; h++) if (dt({ x: e.points[h][0] - 7 / a, y: e.points[h][1] - 7 / a, width: Te / a, height: Te / a }, l, s)) return { mode: "resize", anchor: h };
146
+ for (let c = 0; c < e.points.length; c++) if (yt({ x: e.points[c][0] - 7 / a, y: e.points[c][1] - 7 / a, width: Xe / a, height: Xe / a }, l, s)) return { mode: "resize", anchor: c };
144
147
  } else {
145
- if (dt({ x: r.x + r.width / 2 - 7 / a, y: r.y - Te / a - 16 / a, width: Te / a, height: Te / a }, l, s)) return { mode: "rotate" };
146
- for (const h of i1) if (dt({ x: r.x + r.width * h[0] - 7 / a, y: r.y + r.height * h[1] - 7 / a, width: Te / a, height: Te / a }, l, s)) return { mode: "resize", anchor: h };
148
+ if (yt({ x: o.x + o.width / 2 - 7 / a, y: o.y - Xe / a - 16 / a, width: Xe / a, height: Xe / a }, l, s)) return { mode: "rotate" };
149
+ for (const c of wn) if (yt({ x: o.x + o.width * c[0] - 7 / a, y: o.y + o.height * c[1] - 7 / a, width: Xe / a, height: Xe / a }, l, s)) return { mode: "resize", anchor: c };
147
150
  }
148
- return !!dt(r, l, s) && { mode: "translate" };
149
- }, c1 = (e, i, t, n) => {
150
- if (i.locked) return !1;
151
- const { center: s } = q(i, n), a = Oe(t, i.rotation, s, n.canvasOffset);
152
- return "path" in i && i.path ? i.style?.fillColor && i.style?.fillColor !== "transparent" ? !!e.isPointInPath(i.path, a[0], a[1]) && { mode: "translate" } : (e.lineWidth = (i.style?.lineWidth ?? 0) + 15, !!e.isPointInStroke(i.path, a[0], a[1]) && { mode: "translate" }) : st(i, t, n, !1);
151
+ return !!yt(o, l, s) && { mode: "translate" };
152
+ }, An = (e, t, i, n) => {
153
+ if (t.locked) return !1;
154
+ const { center: s } = J(t, n), a = He(i, t.rotation, s);
155
+ return "path" in t && t.path ? t.style?.fillColor && t.style?.fillColor !== "transparent" ? !!e.isPointInPath(t.path, a[0], a[1]) && { mode: "translate" } : (e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!e.isPointInStroke(t.path, a[0], a[1]) && { mode: "translate" }) : ht(t, i, n, !1);
153
156
  };
154
- function pi(e, i) {
155
- const t = Math.max(e.x, i.x), n = Math.max(e.y, i.y), s = Math.min(e.x + (e.width || 1), i.x + (i.width || 1)), a = Math.min(e.y + (e.height || 1), i.y + (i.height || 1));
156
- if (t < s && n < a) return { x: t, y: n, width: s - t, height: a - n };
157
+ function Gt(e, t) {
158
+ const i = Math.max(e.x, t.x), n = Math.max(e.y, t.y), s = Math.min(e.x + (e.width || 1), t.x + (t.width || 1)), a = Math.min(e.y + (e.height || 1), t.y + (t.height || 1));
159
+ if (i < s && n < a) return { x: i, y: n, width: s - i, height: a - n };
157
160
  }
158
- const ui = ({ ctx: e, path: i, rect: t, offset: n, checkFill: s }) => {
159
- for (let a = 0; a < n; a += n / 2) for (let r = 0; r < n; r += n / 2) for (let o = a + t.x; o < t.x + t.width; o += n) for (let l = r + t.y; l < t.y + t.height; l += n) if (s ? e.isPointInPath(i, o, l) : e.isPointInStroke(i, o, l)) return !0;
161
+ const xi = ({ ctx: e, path: t, rect: i, offset: n, checkFill: s }) => {
162
+ for (let a = 0; a < n; a += n / 2) for (let o = 0; o < n; o += n / 2) for (let r = a + i.x; r < i.x + i.width; r += n) for (let l = o + i.y; l < i.y + i.height; l += n) if (s ? e.isPointInPath(t, r, l) : e.isPointInStroke(t, r, l)) return !0;
160
163
  return !1;
161
- }, _e = (e, i) => {
162
- const t = ((n) => {
163
- if (n.points.length < 1) return;
164
- const s = new Path2D();
165
- s.moveTo(...n.points[0]);
166
- for (const a of n.points.slice(1)) s.lineTo(...a);
167
- return s.lineTo(...n.points[0]), s;
168
- })(e);
169
- return { ...e, path: t, selection: Bt(t, e, i) };
170
- }, P1 = _e, h1 = (e, i) => {
171
- const t = Math.min(...e.points.map((a) => a[0])) - i.selectionPadding, n = Math.max(...e.points.map((a) => a[0])) + i.selectionPadding, s = Math.min(...e.points.map((a) => a[1])) - i.selectionPadding;
172
- return { x: t, width: n - t, y: s, height: Math.max(...e.points.map((a) => a[1])) + i.selectionPadding - s };
173
- }, qe = (e, i) => {
174
- const t = ((n) => {
175
- if (n.points.length < 3) return;
176
- const s = new Path2D();
177
- s.moveTo(...n.points[0]);
178
- for (let a = 1; a < n.points.length - 1; a++) s.quadraticCurveTo(...n.points[a], n.points.length - 2 === a ? n.points[a + 1][0] : (n.points[a + 1][0] - n.points[a][0]) / 2 + n.points[a][0], n.points.length - 2 === a ? n.points[a + 1][1] : (n.points[a + 1][1] - n.points[a][1]) / 2 + n.points[a][1]);
179
- return s;
164
+ }, si = (e, t, i) => {
165
+ const { borders: n } = J(t, i);
166
+ return { border: ai(n), shapePath: e, anchors: [...t.points.map((s) => Mt({ x: s[0], y: s[1], radius: 7 / i.canvasSize.scaleRatio }))] };
167
+ }, fe = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], Mi = ({ size: e, zoom: t, newOffset: [i, n], canvasSize: s }) => e === "infinite" ? { zoom: t, offset: [i, n] } : t < 1 ? { zoom: t, offset: [-(s.realWidth - s.realWidth / t) / 2, -(s.realHeight - s.realHeight / t) / 2] } : { zoom: t, offset: [Ie(i, s.realWidth / t - s.realWidth, 0), Ie(n, s.realHeight / t - s.realHeight, 0)] }, _t = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: n, zoom: s, centerPoint: a }) => {
168
+ const o = e === "fixed" && s < 1 ? [t.realWidth / 2, t.realHeight / 2] : a, r = i[0] - (o[0] / n - o[0] / s), l = i[1] - (o[1] / n - o[1] / s);
169
+ return { offset: e === "infinite" ? [r, l] : s < 1 ? [-(t.realWidth - t.realWidth / s) / 2, -(t.realHeight - t.realHeight / s) / 2] : [Ie(r, t.realWidth / s - t.realWidth, 0), Ie(l, t.realHeight / s - t.realHeight, 0)], zoom: s };
170
+ }, En = (e) => {
171
+ const { canvasSize: { width: t, height: i, scaleRatioWithNoZoom: n }, canvasZoom: s, canvasOffset: a } = e;
172
+ return { x: a[0] * s * n, y: a[1] * s * n, width: t * s, height: i * s };
173
+ }, Dn = (e, t) => {
174
+ const { canvasZoom: i, size: n } = t;
175
+ if (n !== "fixed" || i >= 1) return;
176
+ const s = En(t);
177
+ e.beginPath(), e.rect(s.x, s.y, s.width, s.height), e.closePath(), e.clip();
178
+ }, Qt = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, kt = (e, t) => {
179
+ const i = Mt(e);
180
+ return { ...e, path: i, selection: tt(i, e, t) };
181
+ }, la = kt, nt = (e, t) => {
182
+ const i = Hn(e);
183
+ return { ...e, path: i, selection: si(i, e, t) };
184
+ }, da = nt, Wn = (e, t) => {
185
+ const i = Math.min(...e.points.map((a) => a[0])) - t.selectionPadding, n = Math.max(...e.points.map((a) => a[0])) + t.selectionPadding, s = Math.min(...e.points.map((a) => a[1])) - t.selectionPadding;
186
+ return { x: i, width: n - i, y: s, height: Math.max(...e.points.map((a) => a[1])) + t.selectionPadding - s };
187
+ }, Nn = (e, t, i) => {
188
+ if (t < 0 || t > e.points.length - 1) return e;
189
+ const n = [...e.points.slice(0, t + 1), [ct(e.points[t], e.points[t === e.points.length - 1 ? 0 : t + 1])[0], ct(e.points[t], e.points[t === e.points.length - 1 ? 0 : t + 1])[1]], ...e.points.slice(t + 1)];
190
+ return nt({ ...e, points: n }, i);
191
+ }, ki = (e, t, i, n = !1) => {
192
+ const s = [$(t[0], i), $(t[1], i)], { center: a } = J(e, i), o = He(s, e.rotation, a), r = { ...e, points: n ? e.points : [...e.points, o], tempPoint: n ? o : void 0 };
193
+ return nt(r, i);
194
+ }, at = (e, t) => {
195
+ const i = ((n) => {
196
+ const s = n.tempPoint ? [...n.points, n.tempPoint] : n.points;
197
+ if (s.length < 2) return;
198
+ if (s.length < 3) return Hn(n);
199
+ const a = n.style?.closedPoints === 1 && s.length > 2, o = a ? [s[s.length - 2], ...s, s[0], s[1]] : [s[0], ...s, s[s.length - 1]], r = new Path2D();
200
+ r.moveTo(...s[0]);
201
+ for (let l = 1; l < o.length - 2; l++) {
202
+ const c = o[l - 1], h = o[l], d = o[l + 1], u = o[l + 2], g = h[0] + (d[0] - c[0]) / 6, f = h[1] + (d[1] - c[1]) / 6, w = d[0] - (u[0] - h[0]) / 6, C = d[1] - (u[1] - h[1]) / 6;
203
+ r.bezierCurveTo(g, f, w, C, d[0], d[1]);
204
+ }
205
+ return a && r.closePath(), r;
180
206
  })(e);
181
- return { ...e, path: t, selection: Bt(t, e, i, !0) };
182
- }, H1 = qe, T1 = h1, mt = (e, i) => {
183
- const t = ((n) => {
207
+ return { ...e, path: i, selection: si(i, e, t) };
208
+ }, ca = at, ha = Wn, Rn = (e, t, i) => {
209
+ if (t < 0 || t > e.points.length - 1) return e;
210
+ const n = [...e.points.slice(0, t + 1), [ct(e.points[t], e.points[t === e.points.length - 1 ? 0 : t + 1])[0], ct(e.points[t], e.points[t === e.points.length - 1 ? 0 : t + 1])[1]], ...e.points.slice(t + 1)];
211
+ return at({ ...e, points: n }, i);
212
+ }, Pi = (e, t, i, n = !1) => {
213
+ const s = [$(t[0], i), $(t[1], i)], { center: a } = J(e, i), o = He(s, e.rotation, a), r = { ...e, points: n ? e.points : [...e.points, o], tempPoint: n ? o : void 0 };
214
+ return at(r, i);
215
+ }, Pt = (e, t) => {
216
+ const i = ((n) => {
184
217
  const s = new Path2D();
185
218
  return s.ellipse(n.x, n.y, n.radiusX, n.radiusY, 0, 0, 2 * Math.PI), s;
186
219
  })(e);
187
- return { ...e, path: t, selection: Ke(t, e, i) };
188
- }, A1 = mt, gi = (e) => {
189
- return t = { ...e, type: "triangle" }, { ...t, path: x1(t) };
190
- var t;
191
- }, Z1 = (e, i) => {
192
- e.globalAlpha !== 0 && i.path && (i.style?.fillColor !== "transparent" && e.fill(i.path), i.style?.strokeColor !== "transparent" && e.stroke(i.path));
193
- }, yt = (e, i) => {
194
- const t = [];
220
+ return { ...e, path: i, selection: tt(i, e, t) };
221
+ }, ua = Pt, Li = (e) => {
222
+ return i = { ...e, type: "triangle" }, { ...i, path: aa(i) };
223
+ var i;
224
+ }, pa = (e, t) => {
225
+ e.globalAlpha !== 0 && t.path && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
226
+ }, Lt = (e, t) => {
227
+ const i = [];
195
228
  let n;
196
229
  if (e.style?.lineArrow === 1 || e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
197
- const s = Math.PI / 2 - li({ targetVector: [e.points[0], e.points[1]] });
198
- e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || t.push(gi(vi(e.points[0], s, e.style))), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || t.push(gi(vi(e.points[1], s + Math.PI, e.style)));
199
- const a = (({ line: r, size: o, direction: l }) => {
200
- const h = Math.PI / 2 - li({ targetVector: [r.points[0], r.points[1]] }), d = [r.points[0][0] + (r.points[1][0] - r.points[0][0]) / 2, r.points[0][1] + (r.points[1][1] - r.points[0][1]) / 2];
201
- let c, u;
230
+ const s = Math.PI / 2 - wi({ targetVector: [e.points[0], e.points[1]] });
231
+ e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(Li(Vi(e.points[0], s, e.style))), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(Li(Vi(e.points[1], s + Math.PI, e.style)));
232
+ const a = (({ line: o, size: r, direction: l }) => {
233
+ const c = Math.PI / 2 - wi({ targetVector: [o.points[0], o.points[1]] }), h = [o.points[0][0] + (o.points[1][0] - o.points[0][0]) / 2, o.points[0][1] + (o.points[1][1] - o.points[0][1]) / 2];
234
+ let d, u;
202
235
  if (["start", "both"].includes(l)) {
203
- const g = ve({ point: r.points[0], origin: d, rotation: -h });
204
- c = ve({ point: [g[0], g[1] + o], origin: d, rotation: h });
205
- } else c = [...r.points[0]];
236
+ const g = be({ point: o.points[0], origin: h, rotation: -c });
237
+ d = be({ point: [g[0], g[1] + r], origin: h, rotation: c });
238
+ } else d = [...o.points[0]];
206
239
  if (["end", "both"].includes(l)) {
207
- const g = ve({ point: r.points[1], origin: d, rotation: -h });
208
- u = ve({ point: [g[0], g[1] - o], origin: d, rotation: h });
209
- } else u = [...r.points[1]];
210
- return { points: [c, u] };
240
+ const g = be({ point: o.points[1], origin: h, rotation: -c });
241
+ u = be({ point: [g[0], g[1] - r], origin: h, rotation: c });
242
+ } else u = [...o.points[1]];
243
+ return { points: [d, u] };
211
244
  })({ line: e, size: 10 + 2 * (e.style?.lineWidth ?? 0), direction: e.style?.lineArrow === 1 ? "start" : e.style?.lineArrow === 2 ? "end" : "both" });
212
- n = Dt(a);
213
- } else n = Dt(e);
214
- return { ...e, path: n, selection: Bt(n, e, i), arrows: t, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" } };
215
- }, E1 = yt, vi = (e, i, t) => {
216
- const n = [ve({ point: [0, 0], rotation: i }), ve({ point: [-(5 + (t.lineWidth ?? 0)), 10 + 2 * (t.lineWidth ?? 0)], rotation: i }), ve({ point: [5 + (t.lineWidth ?? 0), 10 + 2 * (t.lineWidth ?? 0)], rotation: i })];
217
- return { points: [[e[0] + n[0][0], e[1] + n[0][1]], [e[0] + n[1][0], e[1] + n[1][1]], [e[0] + n[2][0], e[1] + n[2][1]]], style: { ...t, fillColor: t.strokeColor, strokeColor: "transparent" } };
218
- }, Qt = (e, i) => {
219
- const t = gt(e);
220
- return { ...e, path: t, selection: Ke(t, e, i) };
221
- }, D1 = Qt, F1 = (e, i) => {
222
- e.globalAlpha !== 0 && i.path && (i.style?.fillColor !== "transparent" && e.fill(i.path), i.style?.strokeColor !== "transparent" && e.stroke(i.path));
223
- }, fi = (e, i) => ({ x: e.x - i.selectionPadding, width: e.width + 2 * i.selectionPadding, y: e.y - i.selectionPadding, height: e.height + 2 * i.selectionPadding }), mi = (e, i, t, n, [s, a] = [!1, !1]) => ((r, o, [l, h], [d, c]) => ve({ origin: [l - d, h - c], point: r, rotation: -o }))([e[0] === 0.5 ? t.x + t.width / 2 : e[0] === 0 ? t.x + (s ? 0 : t.width) : t.x + (s ? t.width : 0), e[1] === 0.5 ? t.y + t.height / 2 : e[1] === 0 ? t.y + (a ? 0 : t.height) : t.y + (a ? t.height : 0)], t.rotation, i, n.canvasOffset), St = (e, i) => ({ ...e, selection: Ke(void 0, e, i) }), N1 = St, Ht = (e, i, t, n, s) => {
224
- const [a, r] = ((o, l, h, d, c = !1) => {
225
- if (!(o && l && d && h)) return [ut, ut];
226
- const u = o / l;
227
- if (u > h / d) {
228
- const f = c ? h : Math.min(o, h);
245
+ n = dt(a);
246
+ } else n = dt(e);
247
+ return { ...e, path: n, selection: si(n, e, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" } };
248
+ }, ga = Lt, Vi = (e, t, i) => {
249
+ const n = [be({ point: [0, 0], rotation: t }), be({ point: [-(5 + (i.lineWidth ?? 0)), 10 + 2 * (i.lineWidth ?? 0)], rotation: t }), be({ point: [5 + (i.lineWidth ?? 0), 10 + 2 * (i.lineWidth ?? 0)], rotation: t })];
250
+ return { points: [[e[0] + n[0][0], e[1] + n[0][1]], [e[0] + n[1][0], e[1] + n[1][1]], [e[0] + n[2][0], e[1] + n[2][1]]], style: { ...i, fillColor: i.strokeColor, strokeColor: "transparent" } };
251
+ }, Vt = (e, t) => {
252
+ const i = ai(e);
253
+ return { ...e, path: i, selection: tt(i, e, t) };
254
+ }, fa = Vt, va = (e, t) => {
255
+ e.globalAlpha !== 0 && t.path && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
256
+ }, Hi = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), Zi = (e, t, i, [n, s] = [!1, !1]) => ((a, o, [r, l]) => be({ origin: [r, l], point: a, rotation: -o }))([e[0] === 0.5 ? i.x + i.width / 2 : e[0] === 0 ? i.x + (n ? 0 : i.width) : i.x + (n ? i.width : 0), e[1] === 0.5 ? i.y + i.height / 2 : e[1] === 0 ? i.y + (s ? 0 : i.height) : i.y + (s ? i.height : 0)], i.rotation, t), Ht = (e, t) => ({ ...e, selection: tt(void 0, e, t) }), ma = Ht, Ft = (e, t, i, n, s) => {
257
+ const [a, o] = ((r, l, c, h, d = !1) => {
258
+ if (!(r && l && h && c)) return [xt, xt];
259
+ const u = r / l;
260
+ if (u > c / h) {
261
+ const f = d ? c : Math.min(r, c);
229
262
  return [f, f / u];
230
263
  }
231
- const g = c ? d : Math.min(l, d);
264
+ const g = d ? h : Math.min(l, h);
232
265
  return [g * u, g];
233
- })(e.width, e.height, t, n, !0);
234
- return St({ toolId: Ot.id, type: "picture", id: re("picture_"), x: (t - a) / 2, y: (n - r) / 2, width: a, height: r, src: i, img: e, rotation: 0 }, s);
235
- }, R1 = (e, i, t, n) => new Promise((s, a) => {
236
- const r = new Image();
237
- r.onerror = () => {
266
+ })(e.width, e.height, i, n, !0);
267
+ return Ht({ toolId: ii.id, type: "picture", id: ce("picture_"), x: -s.canvasOffset[0] + s.canvasSize.realWidth / s.canvasZoom / 2 - a / 2, y: -s.canvasOffset[1] + s.canvasSize.realHeight / s.canvasZoom / 2 - o / 2, width: a, height: o, src: t, img: e, rotation: 0 }, s);
268
+ }, ya = (e, t, i, n) => new Promise((s, a) => {
269
+ const o = new Image();
270
+ o.onerror = () => {
238
271
  a(new Error("Some images could not be loaded"));
239
272
  }, setTimeout(() => {
240
273
  a(new Error("Timeout while loading images"));
241
- }, 4e3), e instanceof File ? ((o, l, h, d, c, u) => {
242
- g1(h) ? h.text().then((g) => {
243
- const f = u1(g);
244
- o.onload = async () => {
245
- URL.revokeObjectURL(o.src);
246
- const x = Ht(o, g, d, c, u);
247
- l(x);
248
- }, o.src = f;
249
- }) : (o.onload = async () => {
250
- URL.revokeObjectURL(o.src);
251
- const g = Ht(o, o.src, d, c, u);
274
+ }, 4e3), e instanceof File ? ((r, l, c, h, d, u) => {
275
+ Fn(c) ? c.text().then((g) => {
276
+ const f = In(g);
277
+ r.onload = async () => {
278
+ URL.revokeObjectURL(r.src);
279
+ const w = Ft(r, g, h, d, u);
280
+ l(w);
281
+ }, r.src = f;
282
+ }) : (r.onload = async () => {
283
+ URL.revokeObjectURL(r.src);
284
+ const g = Ft(r, r.src, h, d, u);
252
285
  l(g);
253
- }, o.src = URL.createObjectURL(h));
254
- })(r, s, e, i, t, n) : ((o, l, h, d, c, u) => {
255
- o.onload = () => {
256
- URL.revokeObjectURL(o.src);
257
- const g = Ht(o, h, d, c, u);
286
+ }, r.src = URL.createObjectURL(c));
287
+ })(o, s, e, t, i, n) : ((r, l, c, h, d, u) => {
288
+ r.onload = () => {
289
+ URL.revokeObjectURL(r.src);
290
+ const g = Ft(r, c, h, d, u);
258
291
  l(g);
259
- }, v1(h).then((g) => {
260
- o.src = g;
292
+ }, $n(c).then((g) => {
293
+ r.src = g;
261
294
  }).catch(() => {
262
- o.src = "";
295
+ r.src = "";
263
296
  });
264
- })(r, s, e, i, t, n);
265
- }), Tt = ["Texte"], bt = (e, i) => ({ ...e, selection: Ke(void 0, e, i) }), I1 = bt, Gt = (e, i, t, n, s, a = rt) => {
297
+ })(o, s, e, t, i, n);
298
+ }), $t = ["Texte"], Zt = (e, t) => ({ ...e, selection: tt(void 0, e, t) }), Qa = Zt, oi = (e, t, i, n, s, a = ut) => {
266
299
  e.font = `${s ? "italic" : ""} ${n ? "bold" : ""} 1px ${a}`;
267
- const r = i.map((o) => t / e.measureText(o).width);
268
- return Math.min(...r) || 36;
269
- }, W1 = (e, i, t, n) => {
270
- const s = { ...i, value: t }, a = ((f, x, w, Q, L, b = rt) => {
271
- f.font = `${L ? "italic" : ""} ${Q ? "bold" : ""} ${w}px ${b}`;
272
- const k = x.map((P) => f.measureText(P).width);
273
- return Math.max(...k) || 20;
274
- })(e, s.value, s.fontSize, s.style?.fontBold ?? !1, s.style?.fontItalic ?? !1, s.style?.fontFamily), r = s.fontSize * s.value.length, o = { ...s, width: a, height: r }, { center: l } = q(i, n), { center: h } = q(o, n), [d, c] = mi([1, 1], l, i, n), [u, g] = mi([1, 1], h, o, n, [!1, !1]);
275
- return { ...o, x: o.x - (u - d), y: o.y - (g - c) };
276
- }, yi = (e, i, t, n) => {
277
- const s = [B(t[0], n), B(t[1], n)];
278
- switch (i.type) {
300
+ const o = t.map((r) => i / e.measureText(r).width);
301
+ return Math.min(...o) || 36;
302
+ }, Sa = (e, t, i, n) => {
303
+ const s = { ...t, value: i }, a = ((f, w, C, x, b, M = ut) => {
304
+ f.font = `${b ? "italic" : ""} ${x ? "bold" : ""} ${C}px ${M}`;
305
+ const v = w.map((Q) => f.measureText(Q).width);
306
+ return Math.max(...v) || 20;
307
+ })(e, s.value, s.fontSize, s.style?.fontBold ?? !1, s.style?.fontItalic ?? !1, s.style?.fontFamily), o = s.fontSize * s.value.length, r = { ...s, width: a, height: o }, { center: l } = J(t, n), { center: c } = J(r, n), [h, d] = Zi([1, 1], l, t), [u, g] = Zi([1, 1], c, r, [!1, !1]);
308
+ return { ...r, x: r.x - (u - h), y: r.y - (g - d) };
309
+ }, Ti = (e, t, i, n) => {
310
+ const s = [$(i[0], n), $(i[1], n)];
311
+ switch (t.type) {
279
312
  case "brush":
280
- return ((a, r, o) => Je({ toolId: a.id, type: a.type, id: re(`${a.type}_`), points: [[r]], rotation: 0, scaleX: 1, scaleY: 1, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, o))(i, s, n);
313
+ return ((a, o, r) => it({ toolId: a.id, type: a.type, id: ce(`${a.type}_`), points: [[o]], rotation: 0, scaleX: 1, scaleY: 1, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, r))(t, s, n);
281
314
  case "line":
282
- return ((a, r, o) => {
283
- const l = { toolId: a.id, type: a.type, id: re(`${a.type}_`), points: [r, r], rotation: 0, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, lineArrow: a.settings.lineArrow.default } };
284
- return yt(l, o);
285
- })(i, s, n);
315
+ return ((a, o, r) => {
316
+ const l = { toolId: a.id, type: a.type, id: ce(`${a.type}_`), points: [o, o], rotation: 0, style: { opacity: a.settings.opacity.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, lineArrow: a.settings.lineArrow.default } };
317
+ return Lt(l, r);
318
+ })(t, s, n);
286
319
  case "polygon":
287
- return ((a, r, o) => _e({ toolId: a.id, type: a.type, id: re(`${a.type}_`), points: new Array(a.settings.pointsCount.default).fill(r), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, pointsCount: a.settings.pointsCount.default } }, o))(i, s, n);
320
+ return ((a, o, r) => nt({ toolId: a.id, type: a.type, id: ce(`${a.type}_`), points: new Array(2).fill(o), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, closedPoints: a.settings.closedPoints.default } }, r))(t, s, n);
288
321
  case "curve":
289
- return ((a, r, o) => qe({ toolId: a.id, type: a.type, id: re(`${a.type}_`), points: new Array(a.settings.pointsCount.default).fill(r), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, pointsCount: a.settings.pointsCount.default } }, o))(i, s, n);
322
+ return ((a, o, r) => at({ toolId: a.id, type: a.type, id: ce(`${a.type}_`), points: new Array(2).fill(o), rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default, closedPoints: a.settings.closedPoints.default } }, r))(t, s, n);
290
323
  case "rect":
291
324
  case "square":
292
- return ((a, r, o, l = 0, h = 0) => {
293
- const d = { toolId: a.id, type: a.type, id: re(`${a.type}_`), x: r[0], y: r[1], width: l, height: h, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } };
294
- return Qt(d, o);
295
- })(i, s, n);
325
+ return ((a, o, r, l = 0, c = 0) => {
326
+ const h = { toolId: a.id, type: a.type, id: ce(`${a.type}_`), x: o[0], y: o[1], width: l, height: c, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } };
327
+ return Vt(h, r);
328
+ })(t, s, n);
296
329
  case "text":
297
- return ((a, r, o, l) => {
298
- const h = Gt(a, Tt, 150, r.settings?.fontBold.default ?? !1, r.settings?.fontItalic.default ?? !1, r.settings.fontFamily.default), d = h * (Tt.length || 1);
299
- return bt({ toolId: r.id, type: r.type, id: re(`${r.type}_`), x: o[0] - 150, y: o[1] - d, value: Tt, fontSize: h, width: 150, height: d, rotation: 0, style: { opacity: r.settings.opacity.default, strokeColor: r.settings.strokeColor.default, fontFamily: r.settings.fontFamily.default, fontItalic: r.settings.fontItalic.default, fontBold: r.settings.fontBold.default } }, l);
300
- })(e, i, s, n);
330
+ return ((a, o, r, l) => {
331
+ const c = oi(a, $t, 150, o.settings?.fontBold.default ?? !1, o.settings?.fontItalic.default ?? !1, o.settings.fontFamily.default), h = c * ($t.length || 1);
332
+ return Zt({ toolId: o.id, type: o.type, id: ce(`${o.type}_`), x: r[0] - 150, y: r[1] - h, value: $t, fontSize: c, width: 150, height: h, rotation: 0, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, fontFamily: o.settings.fontFamily.default, fontItalic: o.settings.fontItalic.default, fontBold: o.settings.fontBold.default } }, l);
333
+ })(e, t, s, n);
301
334
  case "ellipse":
302
- return ((a, r, o) => mt({ toolId: a.id, type: a.type, id: re(`${a.type}_`), x: r[0], y: r[1], radiusX: 0, radiusY: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, o))(i, s, n);
335
+ return ((a, o, r) => Pt({ toolId: a.id, type: a.type, id: ce(`${a.type}_`), x: o[0], y: o[1], radiusX: 0, radiusY: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, r))(t, s, n);
303
336
  case "circle":
304
- return ((a, r, o) => ft({ toolId: a.id, type: a.type, id: re(`${a.type}_`), x: r[0], y: r[1], radius: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, o))(i, s, n);
337
+ return ((a, o, r) => kt({ toolId: a.id, type: a.type, id: ce(`${a.type}_`), x: o[0], y: o[1], radius: 0, rotation: 0, style: { opacity: a.settings.opacity.default, fillColor: a.settings.fillColor.default, strokeColor: a.settings.strokeColor.default, lineWidth: a.settings.lineWidth.default, lineDash: a.settings.lineDash.default } }, r))(t, s, n);
305
338
  }
306
- }, p1 = (e, i, t) => {
307
- if (i.visible === !1) return;
308
- const { center: n } = q(i, t);
309
- switch (Ut(e, t, i.rotation, n), ze(e, i.style), i.type) {
310
- case "brush":
311
- ((s, a) => {
312
- a.points.length < 1 || !a.path || s.globalAlpha !== 0 && a.style?.strokeColor !== "transparent" && s.globalAlpha !== 0 && s.stroke(a.path);
313
- })(e, i);
314
- break;
315
- case "text":
316
- ((s, a) => {
317
- if (s.globalAlpha !== 0 && a.style?.strokeColor && a.style.strokeColor !== "transparent") {
318
- s.font = `${a.style?.fontItalic ? "italic" : ""} ${a.style?.fontBold ? "bold" : ""} ${a.fontSize}px ${a.style?.fontFamily ?? rt}`, s.textBaseline = "top", s.fillStyle = a.style.strokeColor;
319
- for (let r = 0; r < a.value.length; r++) s.fillText(a.value[r], a.x, a.y + r * a.fontSize, a.width);
320
- }
321
- })(e, i);
322
- break;
323
- case "line":
324
- ((s, a) => {
325
- if (s.globalAlpha !== 0 && a.path) {
326
- a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path);
327
- for (const r of a.arrows ?? []) ze(s, r.style), Z1(s, r);
328
- }
329
- })(e, i);
330
- break;
331
- case "polygon":
332
- ((s, a) => {
333
- a.path && s.globalAlpha !== 0 && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
334
- })(e, i);
335
- break;
336
- case "curve":
337
- ((s, a) => {
338
- a.path && s.globalAlpha !== 0 && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
339
- })(e, i);
340
- break;
341
- case "circle":
342
- ((s, a) => {
343
- s.globalAlpha !== 0 && a.path && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
344
- })(e, i);
345
- break;
346
- case "ellipse":
347
- ((s, a) => {
348
- s.globalAlpha !== 0 && a.path && (a.style?.fillColor !== "transparent" && s.fill(a.path), a.style?.strokeColor !== "transparent" && s.stroke(a.path));
349
- })(e, i);
350
- break;
351
- case "rect":
352
- case "square":
353
- F1(e, i);
354
- break;
355
- case "picture":
356
- ((s, a) => {
357
- s.globalAlpha !== 0 && (s.beginPath(), s.drawImage(a.img, a.x, a.y, a.width, a.height));
358
- })(e, i);
339
+ }, On = (e, t, i) => {
340
+ if (t.visible === !1) return;
341
+ const { center: n, outerBorders: s } = J(t, i), a = ((o) => {
342
+ const { canvasSize: { width: r, height: l, scaleRatioWithNoZoom: c }, canvasZoom: h, canvasOffset: d } = o;
343
+ return { x: -d[0], y: -d[1], width: r / h / c, height: l / h / c };
344
+ })(i);
345
+ if (Gt(s, a)) {
346
+ switch (ni(e, i, t.rotation, n), Ye(e, t.style), t.type) {
347
+ case "brush":
348
+ ((o, r) => {
349
+ r.points.length < 1 || !r.path || o.globalAlpha !== 0 && r.style?.strokeColor !== "transparent" && o.globalAlpha !== 0 && o.stroke(r.path);
350
+ })(e, t);
351
+ break;
352
+ case "text":
353
+ ((o, r) => {
354
+ if (o.globalAlpha !== 0 && r.style?.strokeColor && r.style.strokeColor !== "transparent") {
355
+ o.font = `${r.style?.fontItalic ? "italic" : ""} ${r.style?.fontBold ? "bold" : ""} ${r.fontSize}px ${r.style?.fontFamily ?? ut}`, o.textBaseline = "top", o.fillStyle = r.style.strokeColor;
356
+ for (let l = 0; l < r.value.length; l++) o.fillText(r.value[l], r.x, r.y + l * r.fontSize, r.width);
357
+ }
358
+ })(e, t);
359
+ break;
360
+ case "line":
361
+ ((o, r) => {
362
+ if (o.globalAlpha !== 0 && r.path) {
363
+ r.style?.fillColor !== "transparent" && o.fill(r.path), r.style?.strokeColor !== "transparent" && o.stroke(r.path);
364
+ for (const l of r.arrows ?? []) Ye(o, l.style), pa(o, l);
365
+ }
366
+ })(e, t);
367
+ break;
368
+ case "polygon":
369
+ ((o, r) => {
370
+ r.path && o.globalAlpha !== 0 && (r.style?.fillColor !== "transparent" && o.fill(r.path), r.style?.strokeColor !== "transparent" && o.stroke(r.path));
371
+ })(e, t);
372
+ break;
373
+ case "curve":
374
+ ((o, r) => {
375
+ r.path && o.globalAlpha !== 0 && (r.style?.fillColor !== "transparent" && o.fill(r.path), r.style?.strokeColor !== "transparent" && o.stroke(r.path));
376
+ })(e, t);
377
+ break;
378
+ case "circle":
379
+ ((o, r) => {
380
+ o.globalAlpha !== 0 && r.path && (r.style?.fillColor !== "transparent" && o.fill(r.path), r.style?.strokeColor !== "transparent" && o.stroke(r.path));
381
+ })(e, t);
382
+ break;
383
+ case "ellipse":
384
+ ((o, r) => {
385
+ o.globalAlpha !== 0 && r.path && (r.style?.fillColor !== "transparent" && o.fill(r.path), r.style?.strokeColor !== "transparent" && o.stroke(r.path));
386
+ })(e, t);
387
+ break;
388
+ case "rect":
389
+ case "square":
390
+ va(e, t);
391
+ break;
392
+ case "picture":
393
+ ((o, r) => {
394
+ o.globalAlpha !== 0 && (o.beginPath(), o.drawImage(r.img, r.x, r.y, r.width, r.height));
395
+ })(e, t);
396
+ }
397
+ e.restore();
359
398
  }
360
- e.restore();
361
- }, z1 = (e, i) => {
399
+ }, ba = (e, t) => {
362
400
  switch (e.type) {
363
401
  case "brush":
364
- return ((t, { selectionPadding: n }) => {
365
- const s = t.points.flat(), a = Math.min(...s.map((d) => d[0])), r = Math.min(...s.map((d) => d[1])), o = s.map((d) => Qe(d, a, r, t.scaleX, t.scaleY)), l = Math.max(...o.map((d) => d[0])) + n, h = Math.max(...o.map((d) => d[1])) + n;
366
- return { x: a - n, width: l - a + n, y: r - n, height: h - r + n };
367
- })(e, i);
402
+ return ((i, { selectionPadding: n }) => {
403
+ const s = i.points.flat(), a = Math.min(...s.map((h) => h[0])), o = Math.min(...s.map((h) => h[1])), r = s.map((h) => Me(h, a, o, i.scaleX, i.scaleY)), l = Math.max(...r.map((h) => h[0])) + n, c = Math.max(...r.map((h) => h[1])) + n;
404
+ return { x: a - n, width: l - a + n, y: o - n, height: c - o + n };
405
+ })(e, t);
368
406
  case "line":
369
- return ((t, n) => ({ x: Math.min(t.points[0][0], t.points[1][0]) - n.selectionPadding, width: Math.abs(t.points[0][0] - t.points[1][0]) + 2 * n.selectionPadding, y: Math.min(t.points[0][1], t.points[1][1]) - n.selectionPadding, height: Math.abs(t.points[0][1] - t.points[1][1]) + 2 * n.selectionPadding }))(e, i);
407
+ return ((i, n) => ({ x: Math.min(i.points[0][0], i.points[1][0]) - n.selectionPadding, width: Math.abs(i.points[0][0] - i.points[1][0]) + 2 * n.selectionPadding, y: Math.min(i.points[0][1], i.points[1][1]) - n.selectionPadding, height: Math.abs(i.points[0][1] - i.points[1][1]) + 2 * n.selectionPadding }))(e, t);
370
408
  case "polygon":
371
- return h1(e, i);
409
+ return Wn(e, t);
372
410
  case "curve":
373
- return T1(e, i);
411
+ return ha(e, t);
374
412
  case "circle":
375
- return ((t, n) => ({ x: t.x - t.radius - n.selectionPadding, width: 2 * (t.radius + n.selectionPadding), y: t.y - t.radius - n.selectionPadding, height: 2 * (t.radius + n.selectionPadding) }))(e, i);
413
+ return ((i, n) => ({ x: i.x - i.radius - n.selectionPadding, width: 2 * (i.radius + n.selectionPadding), y: i.y - i.radius - n.selectionPadding, height: 2 * (i.radius + n.selectionPadding) }))(e, t);
376
414
  case "ellipse":
377
- return ((t, n) => ({ x: t.x - t.radiusX - n.selectionPadding, width: 2 * (t.radiusX + n.selectionPadding), y: t.y - t.radiusY - n.selectionPadding, height: 2 * (t.radiusY + n.selectionPadding) }))(e, i);
415
+ return ((i, n) => ({ x: i.x - i.radiusX - n.selectionPadding, width: 2 * (i.radiusX + n.selectionPadding), y: i.y - i.radiusY - n.selectionPadding, height: 2 * (i.radiusY + n.selectionPadding) }))(e, t);
378
416
  case "rect":
379
417
  case "square":
380
- return fi(e, i);
418
+ return Hi(e, t);
381
419
  case "text":
382
- return ((t, n) => ({ x: t.x - n.selectionPadding, width: t.width + 2 * n.selectionPadding, y: t.y - n.selectionPadding, height: t.height + 2 * n.selectionPadding }))(e, i);
420
+ return ((i, n) => ({ x: i.x - n.selectionPadding, width: i.width + 2 * n.selectionPadding, y: i.y - n.selectionPadding, height: i.height + 2 * n.selectionPadding }))(e, t);
383
421
  case "picture":
384
- return ((t, n) => fi(t, n))(e, i);
422
+ return ((i, n) => Hi(i, n))(e, t);
385
423
  default:
386
424
  return { x: 0, y: 0, width: 100, height: 100 };
387
425
  }
388
- }, q = (e, i) => {
389
- const t = z1(e, i), n = ((s) => [s.x + s.width / 2, s.y + s.height / 2])(t);
390
- return { borders: t, center: n };
391
- }, O1 = (e, i, t, n, s, a) => {
392
- const r = s[0] - n[0], o = s[1] - n[1], l = s[0] - i[0], h = s[1] - i[1], d = t.rotation + Math.atan2(h, l) - Math.atan2(o, r);
393
- return { ...e, rotation: k1(d, a) };
394
- }, $1 = (e, i, t, n, s, a, r) => {
426
+ }, J = (e, t) => {
427
+ const i = ba(e, t), n = { x: i.x - (e.style?.lineWidth ?? 0), y: i.y - (e.style?.lineWidth ?? 0), width: i.width + 2 * (e.style?.lineWidth ?? 0), height: i.height + 2 * (e.style?.lineWidth ?? 0) }, s = ((a) => [a.x + a.width / 2, a.y + a.height / 2])(i);
428
+ return { borders: i, outerBorders: n, center: s };
429
+ }, wa = (e, t, i, n, s, a, o) => {
430
+ const r = s[0] - n[0], l = s[1] - n[1], c = s[0] - t[0], h = s[1] - t[1], d = i.rotation + Math.atan2(h, c) - Math.atan2(l, r);
431
+ return { ...e, rotation: oa(d, a, o) };
432
+ }, Ca = (e, t, i, n, s, a, o, r) => {
395
433
  switch (n.type) {
396
434
  case "line":
397
- return ((o, l, h, d) => {
398
- const c = [B(o[0], d), B(o[1], d)], { center: u } = q(l, d), g = Oe(c, l.rotation, u, d.canvasOffset), f = de(["points", h.anchor], g, l);
399
- return yt(f, d);
400
- })(t, n, s, a);
435
+ return ((l, c, h, d) => {
436
+ const u = [$(l[0], d), $(l[1], d)], { center: g } = J(c, d), f = He(u, c.rotation, g), w = me(["points", h.anchor], f, c);
437
+ return Lt(w, d);
438
+ })(i, n, s, a);
401
439
  case "polygon":
402
- return ((o, l, h, d) => {
403
- const c = [B(o[0], d), B(o[1], d)], { center: u } = q(l, d), g = Oe(c, l.rotation, u, d.canvasOffset), f = de(["points", h.anchor], g, l);
404
- return _e(f, d);
405
- })(t, n, s, a);
440
+ return ((l, c, h, d) => {
441
+ const u = [$(l[0], d), $(l[1], d)], { center: g } = J(c, d), f = He(u, c.rotation, g), w = me(["points", h.anchor], f, c);
442
+ return nt(w, d);
443
+ })(i, n, s, a);
406
444
  case "curve":
407
- return ((o, l, h, d) => {
408
- const c = [B(o[0], d), B(o[1], d)], { center: u } = q(l, d), g = Oe(c, l.rotation, u, d.canvasOffset), f = de(["points", h.anchor], g, l);
409
- return qe(f, d);
410
- })(t, n, s, a);
445
+ return ((l, c, h, d) => {
446
+ const u = [$(l[0], d), $(l[1], d)], { center: g } = J(c, d), f = He(u, c.rotation, g), w = me(["points", h.anchor], f, c);
447
+ return at(w, d);
448
+ })(i, n, s, a);
411
449
  case "brush":
412
- return ((o, l, h, d, c) => {
413
- const { borders: u } = q({ ...l, scaleX: 1, scaleY: 1 }, d), { borders: g } = q(l, d), { borderX: f, borderHeight: x, borderY: w, borderWidth: Q } = Ge(o, l, h, d, c), L = Math.max(0, u.width - 2 * d.selectionPadding), b = Math.max(0, u.height - 2 * d.selectionPadding), k = Math.max(0, Q - 2 * d.selectionPadding), P = Math.max(0, x - 2 * d.selectionPadding), E = L ? k / L : 1, H = b ? P / b : 1;
414
- if (!L || !b) return l;
415
- const T = De(f - g.x), C = De(w - g.y);
416
- return Je({ ...l, points: l.points.map((V) => V.map(([I, y]) => [I + T, y + C])), scaleX: E, scaleY: H }, d);
417
- })(t, n, s, a, r);
450
+ return ((l, c, h, d, u, g) => {
451
+ const { borders: f } = J({ ...c, scaleX: 1, scaleY: 1 }, d), { borders: w } = J(c, d), { borderX: C, borderHeight: x, borderY: b, borderWidth: M } = _e(l, c, h, d, u, g), v = Math.max(0, f.width - 2 * d.selectionPadding), Q = Math.max(0, f.height - 2 * d.selectionPadding), H = Math.max(0, M - 2 * d.selectionPadding), Z = Math.max(0, x - 2 * d.selectionPadding), E = v ? H / v : 1, D = Q ? Z / Q : 1;
452
+ if (!v || !Q) return c;
453
+ const P = Oe(C - w.x), W = Oe(b - w.y);
454
+ return it({ ...c, points: c.points.map((N) => N.map(([z, B]) => [z + P, B + W])), scaleX: E, scaleY: D }, d);
455
+ })(i, n, s, a, o, r);
418
456
  case "circle":
419
- return ((o, l, h, d) => {
420
- const { borderX: c, borderHeight: u, borderY: g, borderWidth: f } = Ge(o, l, h, d, !0);
421
- return ft({ ...l, radius: Math.max(0, f / 2 - d.selectionPadding), x: c + f / 2, y: g + u / 2 }, d);
422
- })(t, n, s, a);
457
+ return ((l, c, h, d, u) => {
458
+ const { borderX: g, borderHeight: f, borderY: w, borderWidth: C } = _e(l, c, h, d, !0, u);
459
+ return kt({ ...c, radius: Math.max(0, C / 2 - d.selectionPadding), x: g + C / 2, y: w + f / 2 }, d);
460
+ })(i, n, s, a, r);
423
461
  case "ellipse":
424
- return ((o, l, h, d, c = !1) => {
425
- const { borderX: u, borderHeight: g, borderY: f, borderWidth: x } = Ge(o, l, h, d, c);
426
- return mt({ ...l, radiusX: Math.max(0, x / 2 - d.selectionPadding), radiusY: Math.max(0, g / 2 - d.selectionPadding), x: u + x / 2, y: f + g / 2 }, d);
427
- })(t, n, s, a, r);
462
+ return ((l, c, h, d, u = !1, g = !1) => {
463
+ const { borderX: f, borderHeight: w, borderY: C, borderWidth: x } = _e(l, c, h, d, u, g);
464
+ return Pt({ ...c, radiusX: Math.max(0, x / 2 - d.selectionPadding), radiusY: Math.max(0, w / 2 - d.selectionPadding), x: f + x / 2, y: C + w / 2 }, d);
465
+ })(i, n, s, a, o, r);
428
466
  case "rect":
429
467
  case "square":
430
- return ((o, l, h, d, c = !1) => {
431
- const { borderX: u, borderHeight: g, borderY: f, borderWidth: x } = Ge(o, l, h, d, c);
432
- return Qt({ ...l, width: Math.max(0, x - 2 * d.selectionPadding), height: Math.max(0, g - 2 * d.selectionPadding), x: u + d.selectionPadding, y: f + d.selectionPadding }, d);
433
- })(t, n, s, a, i.type === "square" || r);
468
+ return ((l, c, h, d, u = !1, g = !1) => {
469
+ const { borderX: f, borderHeight: w, borderY: C, borderWidth: x } = _e(l, c, h, d, u, g);
470
+ return Vt({ ...c, width: Math.max(0, x - 2 * d.selectionPadding), height: Math.max(0, w - 2 * d.selectionPadding), x: f + d.selectionPadding, y: C + d.selectionPadding }, d);
471
+ })(i, n, s, a, t.type === "square" || o, r);
434
472
  case "text":
435
- return ((o, l, h, d, c) => {
436
- const { borderX: u, borderHeight: g, borderY: f, borderWidth: x } = Ge(l, h, d, c, !0), w = bt({ ...h, width: Math.max(0, x - 2 * c.selectionPadding), height: Math.max(0, g - 2 * c.selectionPadding), x: u + c.selectionPadding, y: f + c.selectionPadding }, c);
437
- return { ...w, fontSize: Gt(o, w.value, w.width, w.style?.fontBold ?? !1, w.style?.fontItalic ?? !1, w.style?.fontFamily) };
438
- })(e, t, n, s, a);
473
+ return ((l, c, h, d, u, g) => {
474
+ const { borderX: f, borderHeight: w, borderY: C, borderWidth: x } = _e(c, h, d, u, !0, g), b = Zt({ ...h, width: Math.max(0, x - 2 * u.selectionPadding), height: Math.max(0, w - 2 * u.selectionPadding), x: f + u.selectionPadding, y: C + u.selectionPadding }, u);
475
+ return { ...b, fontSize: oi(l, b.value, b.width, b.style?.fontBold ?? !1, b.style?.fontItalic ?? !1, b.style?.fontFamily) };
476
+ })(e, i, n, s, a, r);
439
477
  case "picture":
440
- return ((o, l, h, d) => {
441
- const { borderX: c, borderHeight: u, borderY: g, borderWidth: f } = Ge(o, l, h, d, !0);
442
- return St({ ...l, width: Math.max(0, f - 2 * d.selectionPadding), height: Math.max(0, u - 2 * d.selectionPadding), x: c + d.selectionPadding, y: g + d.selectionPadding }, d);
443
- })(t, n, s, a);
478
+ return ((l, c, h, d, u) => {
479
+ const { borderX: g, borderHeight: f, borderY: w, borderWidth: C } = _e(l, c, h, d, !0, u);
480
+ return Ht({ ...c, width: Math.max(0, C - 2 * d.selectionPadding), height: Math.max(0, f - 2 * d.selectionPadding), x: g + d.selectionPadding, y: w + d.selectionPadding }, d);
481
+ })(i, n, s, a, r);
444
482
  default:
445
483
  return n;
446
484
  }
447
- }, Nt = (e, i, t, n) => {
448
- switch (i.type) {
485
+ }, jt = (e, t, i, n, s) => {
486
+ switch (t.type) {
449
487
  case "rect":
450
488
  case "square":
451
- return ((s, a, r, o) => Qt({ ...a, x: B(a.x + s[0] - r[0], o), y: B(a.y + s[1] - r[1], o) }, o))(e, i, t, n);
489
+ return ((a, o, r, l, c) => {
490
+ const h = ze([a[0] - r[0], a[1] - r[1]], c);
491
+ return Vt({ ...o, x: $(o.x + h[0], l), y: $(o.y + h[1], l) }, l);
492
+ })(e, t, i, n, s);
452
493
  case "ellipse":
453
- return ((s, a, r, o) => mt({ ...a, x: B(a.x + s[0] - r[0], o), y: B(a.y + s[1] - r[1], o) }, o))(e, i, t, n);
494
+ return ((a, o, r, l, c) => {
495
+ const h = ze([a[0] - r[0], a[1] - r[1]], c);
496
+ return Pt({ ...o, x: $(o.x + h[0], l), y: $(o.y + h[1], l) }, l);
497
+ })(e, t, i, n, s);
454
498
  case "circle":
455
- return ((s, a, r, o) => ft({ ...a, x: B(a.x + s[0] - r[0], o), y: B(a.y + s[1] - r[1], o) }, o))(e, i, t, n);
499
+ return ((a, o, r, l, c) => {
500
+ const h = ze([a[0] - r[0], a[1] - r[1]], c);
501
+ return kt({ ...o, x: $(o.x + h[0], l), y: $(o.y + h[1], l) }, l);
502
+ })(e, t, i, n, s);
456
503
  case "picture":
457
- return ((s, a, r, o) => St({ ...a, x: B(a.x + s[0] - r[0], o), y: B(a.y + s[1] - r[1], o) }, o))(e, i, t, n);
504
+ return ((a, o, r, l, c) => {
505
+ const h = ze([a[0] - r[0], a[1] - r[1]], c);
506
+ return Ht({ ...o, x: $(o.x + h[0], l), y: $(o.y + h[1], l) }, l);
507
+ })(e, t, i, n, s);
458
508
  case "text":
459
- return ((s, a, r, o) => bt({ ...a, x: B(a.x + s[0] - r[0], o), y: B(a.y + s[1] - r[1], o) }, o))(e, i, t, n);
509
+ return ((a, o, r, l, c) => {
510
+ const h = ze([a[0] - r[0], a[1] - r[1]], c);
511
+ return Zt({ ...o, x: $(o.x + h[0], l), y: $(o.y + h[1], l) }, l);
512
+ })(e, t, i, n, s);
460
513
  case "line":
461
- return ((s, a, r, o) => yt({ ...a, points: a.points.map(([l, h]) => [B(l + s[0] - r[0], o), B(h + s[1] - r[1], o)]) }, o))(e, i, t, n);
514
+ return ((a, o, r, l, c) => {
515
+ const h = ze([a[0] - r[0], a[1] - r[1]], c);
516
+ return Lt({ ...o, points: o.points.map(([d, u]) => [$(d + h[0], l), $(u + h[1], l)]) }, l);
517
+ })(e, t, i, n, s);
462
518
  case "polygon":
463
- return ((s, a, r, o) => {
464
- const { borders: l } = q(a, o);
465
- return _e({ ...a, points: a.points.map(([h, d]) => o.gridGap ? [h + B(l.x + s[0] - r[0], o) - l.x, d + B(l.y + s[1] - r[1], o) - l.y] : [B(h + s[0] - r[0], o), B(d + s[1] - r[1], o)]) }, o);
466
- })(e, i, t, n);
519
+ return ((a, o, r, l, c) => {
520
+ const h = ze([a[0] - r[0], a[1] - r[1]], c), { borders: d } = J(o, l);
521
+ return nt({ ...o, points: o.points.map(([u, g]) => l.gridGap ? [u + $(d.x + h[0], l) - d.x, g + $(d.y + h[1], l) - d.y] : [$(u + a[0] - r[0], l), $(g + a[1] - r[1], l)]) }, l);
522
+ })(e, t, i, n, s);
467
523
  case "curve":
468
- return ((s, a, r, o) => {
469
- const { borders: l } = q(a, o);
470
- return qe({ ...a, points: a.points.map(([h, d]) => o.gridGap ? [h + B(l.x + s[0] - r[0], o) - l.x, d + B(l.y + s[1] - r[1], o) - l.y] : [B(h + s[0] - r[0], o), B(d + s[1] - r[1], o)]) }, o);
471
- })(e, i, t, n);
524
+ return ((a, o, r, l, c) => {
525
+ const { borders: h } = J(o, l), d = ze([a[0] - r[0], a[1] - r[1]], c);
526
+ return at({ ...o, points: o.points.map(([u, g]) => l.gridGap ? [u + $(h.x + d[0], l) - h.x, g + $(h.y + d[1], l) - h.y] : [$(u + d[0], l), $(g + d[1], l)]) }, l);
527
+ })(e, t, i, n, s);
472
528
  case "brush":
473
- return ((s, a, r, o) => {
474
- const { borders: l } = q(a, o), h = o.gridGap ? B(l.x + s[0] - r[0], o) - l.x : s[0] - r[0], d = o.gridGap ? B(l.y + s[1] - r[1], o) - l.y : s[1] - r[1];
475
- return Je({ ...a, points: a.points.map((c) => c.map(([u, g]) => [u + h, g + d])) }, o);
476
- })(e, i, t, n);
529
+ return ((a, o, r, l, c) => {
530
+ const { borders: h } = J(o, l), d = ze([a[0] - r[0], a[1] - r[1]], c), u = l.gridGap ? $(h.x + d[0], l) - h.x : d[0], g = l.gridGap ? $(h.y + d[1], l) - h.y : d[1];
531
+ return it({ ...o, points: o.points.map((f) => f.map(([w, C]) => [w + u, C + g])) }, l);
532
+ })(e, t, i, n, s);
477
533
  default:
478
- return i;
534
+ return t;
479
535
  }
480
- }, ot = (e, i) => {
536
+ }, et = (e, t) => {
481
537
  switch (e.type) {
482
538
  case "rect":
483
539
  case "square":
484
- return D1(e, i);
540
+ return fa(e, t);
485
541
  case "ellipse":
486
- return A1(e, i);
542
+ return ua(e, t);
487
543
  case "circle":
488
- return V1(e, i);
544
+ return la(e, t);
489
545
  case "picture":
490
- return N1(e, i);
546
+ return ma(e, t);
491
547
  case "text":
492
- return I1(e, i);
548
+ return Qa(e, t);
493
549
  case "line":
494
- return E1(e, i);
550
+ return ga(e, t);
495
551
  case "polygon":
496
- return P1(e, i);
552
+ return da(e, t);
497
553
  case "curve":
498
- return H1(e, i);
554
+ return ca(e, t);
499
555
  case "brush":
500
- return M1(e, i);
556
+ return sa(e, t);
501
557
  default:
502
558
  return e;
503
559
  }
504
- }, Qi = ({ ctx: e, shape: i, settings: t, selectionWidth: n, selectionColor: s, withAnchors: a = !0 }) => {
505
- const { center: r } = q(i, t);
506
- switch (Ut(e, t, i.rotation, r), i.type) {
560
+ }, zi = ({ ctx: e, shape: t, settings: i, selectionWidth: n, selectionColor: s, withAnchors: a = !0 }) => {
561
+ const { center: o } = J(t, i);
562
+ switch (ni(e, i, t.rotation, o), t.type) {
507
563
  case "rect":
508
564
  case "square":
509
565
  case "circle":
@@ -511,794 +567,949 @@ const ui = ({ ctx: e, path: i, rect: t, offset: n, checkFill: s }) => {
511
567
  case "picture":
512
568
  case "text":
513
569
  case "brush":
514
- ((o, l, h, d, c, u) => {
515
- if (l.selection && (ze(o, { fillColor: "transparent", strokeColor: h, lineWidth: d / c.canvasSize.scaleRatio }), l.selection.shapePath ? o.stroke(l.selection.shapePath) : o.stroke(l.selection.border), u && !l.locked)) {
516
- l.selection.shapePath && o.stroke(l.selection.border), o.stroke(l.selection.line), ze(o, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / c.canvasSize.scaleRatio });
517
- for (const g of l.selection.anchors) o.fill(g), o.stroke(g);
570
+ ((r, l, c, h, d, u) => {
571
+ if (l.selection && (Ye(r, { fillColor: "transparent", strokeColor: c, lineWidth: h / d.canvasSize.scaleRatio }), l.selection.shapePath ? r.stroke(l.selection.shapePath) : r.stroke(l.selection.border), u && !l.locked)) {
572
+ l.selection.shapePath && r.stroke(l.selection.border), r.stroke(l.selection.line), Ye(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / d.canvasSize.scaleRatio });
573
+ for (const g of l.selection.anchors) r.fill(g), r.stroke(g);
518
574
  }
519
- })(e, i, s, n, t, a);
575
+ })(e, t, s, n, i, a);
520
576
  break;
521
577
  case "polygon":
522
578
  case "line":
523
579
  case "curve":
524
- (({ ctx: o, shape: l, withAnchors: h, selectionWidth: d, selectionColor: c, settings: u }) => {
525
- if (l.selection && (ze(o, { fillColor: "transparent", strokeColor: c, lineWidth: d / u.canvasSize.scaleRatio }), l.selection.shapePath && o.stroke(l.selection.shapePath), h && !l.locked)) {
526
- ze(o, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio });
527
- for (const g of l.selection.anchors) o.fill(g), o.stroke(g);
580
+ (({ ctx: r, shape: l, withAnchors: c, selectionWidth: h, selectionColor: d, settings: u }) => {
581
+ if (l.selection && (Ye(r, { fillColor: "transparent", strokeColor: d, lineWidth: h / u.canvasSize.scaleRatio }), l.selection.shapePath && r.stroke(l.selection.shapePath), c && !l.locked)) {
582
+ Ye(r, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio });
583
+ for (const g of l.selection.anchors) r.fill(g), r.stroke(g);
528
584
  }
529
- })({ ctx: e, shape: i, withAnchors: a, selectionWidth: n, selectionColor: s, settings: t });
585
+ })({ ctx: e, shape: t, withAnchors: a, selectionWidth: n, selectionColor: s, settings: i });
530
586
  }
531
587
  e.restore();
532
- }, U1 = ({ ctx: e, selectionFrame: i, settings: t }) => {
533
- Ut(e, t), ((n, s, a) => {
534
- ze(n, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / a.canvasSize.scaleRatio }), n.fillRect(s[0][0], s[0][1], s[1][0] - s[0][0], s[1][1] - s[0][1]), n.strokeRect(s[0][0], s[0][1], s[1][0] - s[0][0], s[1][1] - s[0][1]);
535
- })(e, i, t), e.restore();
536
- }, u1 = (e) => {
537
- const i = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0], t = i.getAttribute("width"), n = i.getAttribute("height");
588
+ }, xa = ({ ctx: e, selectionFrame: t, settings: i }) => {
589
+ ni(e, i), ((n, s, a) => {
590
+ Ye(n, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / a.canvasSize.scaleRatio }), n.fillRect(s[0][0], s[0][1], s[1][0] - s[0][0], s[1][1] - s[0][1]), n.strokeRect(s[0][0], s[0][1], s[1][0] - s[0][0], s[1][1] - s[0][1]);
591
+ })(e, t, i), e.restore();
592
+ }, ri = (e) => e.filter((t) => t != null), In = (e) => {
593
+ const t = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0], i = t.getAttribute("width"), n = t.getAttribute("height");
538
594
  let s;
539
- if (t || n) s = e;
595
+ if (i || n) s = e;
540
596
  else {
541
- const r = i.getAttribute("viewBox") ?? "0 0 300 300", [, , o, l] = r.split(" ");
542
- i.setAttribute("width", o ?? ut), i.setAttribute("height", l ?? ut), s = new XMLSerializer().serializeToString(i);
597
+ const o = t.getAttribute("viewBox") ?? "0 0 300 300", [, , r, l] = o.split(" ");
598
+ t.setAttribute("width", r ?? xt), t.setAttribute("height", l ?? xt), s = new XMLSerializer().serializeToString(t);
543
599
  }
544
600
  const a = new Blob([s], { type: "image/svg+xml" });
545
601
  return URL.createObjectURL(a);
546
- }, g1 = (e) => (e instanceof File ? e.name : e).includes(".svg"), v1 = (e) => g1(e) ? fetch(e).then((i) => i.text()).then((i) => u1(i)) : fetch(e).then((i) => i.blob()).then((i) => URL.createObjectURL(i)), Si = (e, i) => {
547
- const t = document.createElement("a");
548
- t.href = e, t.download = i, document.body.appendChild(t), t.click(), document.body.removeChild(t);
549
- }, B1 = (e) => e.src.includes("<svg") ? e.src : ((i) => {
550
- const t = document.createElement("canvas");
551
- t.width = i.width, t.height = i.height;
552
- const n = t.getContext("2d");
553
- return n ? (n.drawImage(i, 0, 0), t.toDataURL("image/png")) : "";
554
- })(e.img), bi = (e, i, t, n) => {
555
- const s = document.createElement("canvas");
556
- s.width = i, s.height = t;
557
- const a = s.getContext("2d");
558
- if (!a) return "";
559
- a.clearRect(0, 0, i, t), l1(a);
560
- for (let r = e.length - 1; r >= 0; r--) p1(a, e[r], de(["canvasSize", "scaleRatio"], 1, n));
561
- return s.toDataURL("image/png");
562
- }, G1 = (e, i, t) => {
563
- return s = Xt(e, i, t), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(s))}`;
602
+ }, Fn = (e) => (e instanceof File ? e.name : e).includes(".svg"), $n = (e) => Fn(e) ? fetch(e).then((t) => t.text()).then((t) => In(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), Ai = (e, t) => {
603
+ const i = document.createElement("a");
604
+ i.href = e, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
605
+ }, Ma = (e) => e.src.includes("<svg") ? e.src : ((t) => {
606
+ const i = document.createElement("canvas");
607
+ i.width = t.width, i.height = t.height;
608
+ const n = i.getContext("2d");
609
+ return n ? (n.drawImage(t, 0, 0), i.toDataURL("image/png")) : "";
610
+ })(e.img), Bt = ({ shapes: e, settings: t }) => {
611
+ const i = document.createElement("canvas"), n = i.getContext("2d");
612
+ if (!n) throw new Error("No context found for canvas");
613
+ const { realHeight: s, realWidth: a } = t.canvasSize;
614
+ i.width = a, i.height = s, n.clearRect(0, 0, a, s), Vn(n);
615
+ for (let o = e.length - 1; o >= 0; o--) On(n, e[o], t);
616
+ return i.toDataURL("image/png");
617
+ }, Ei = ({ shapes: e, settings: t, view: i }) => {
618
+ if (i === "fitToShapes" && !e.length) throw new Error("No image found to export");
619
+ if (i === "fitToShapes") {
620
+ const s = e.map((h) => {
621
+ const d = J(h, t).borders, u = (h.style?.lineWidth ?? 0) / 2;
622
+ return { minX: d.x - u, minY: d.y - u, maxX: d.x + d.width + u, maxY: d.y + d.height + u };
623
+ }), a = Math.min(...s.map((h) => h.minX)), o = Math.max(...s.map((h) => h.maxX)), r = Math.min(...s.map((h) => h.minY)), l = Math.max(...s.map((h) => h.maxY)), c = { ...t, canvasOffset: [-a, -r], canvasZoom: 1, canvasSize: { realWidth: o - a, realHeight: l - r, width: o - a, height: l - r, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
624
+ return Bt({ shapes: e, settings: c });
625
+ }
626
+ if (i === "defaultView") {
627
+ const s = { ...t, canvasOffset: [0, 0], canvasZoom: 1, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
628
+ return Bt({ shapes: e, settings: s });
629
+ }
630
+ const n = { ...t, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: t.canvasZoom, scaleRatioWithNoZoom: 1 } };
631
+ return Bt({ shapes: e, settings: n });
632
+ }, ka = (e, t, i) => {
633
+ return s = li(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(s))}`;
564
634
  var s;
565
- }, X1 = (e) => {
566
- const i = ["img", "id", "selection", "path", "arrows"];
567
- return e.map((t) => t.type !== "picture" || t.src.startsWith("http") ? Zt(i, t) : Zt(i, { ...t, src: B1(t) }));
568
- }, Xt = (e, i, t) => ({ shapes: X1(e), config: { width: i, height: t } }), Ci = (e, i) => ot({ ...e, id: re(`${e.type}_`) }, i), Y1 = (e, i, t) => {
569
- const n = J([]), s = J({ dataChanged: [] }), [a, r] = $(void 0), [o, l] = $(void 0), [h, d] = $(void 0), [c, u] = $({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), g = c.cursor > 0, f = c.cursor < c.states.length - 1, x = n.current.length > 0, w = F(() => {
570
- u((v) => r1(v.states[v.cursor].shapes, n.current) ? v : { states: [...v.states.slice(0, v.cursor + 1), { shapes: n.current, selectedShape: o, source: "user" }], cursor: v.cursor + 1 });
571
- }, [o]), Q = F((v) => {
572
- n.current = [v, ...n.current];
573
- }, []), L = F((v, m, S) => {
574
- if (v.target && "className" in v.target && ![a1, s1].includes(v.target.className)) return void d(void 0);
575
- const W = n.current.find((z) => z.id === o?.id ? !!st(o, S, e) : !!c1(m, z, S, e));
576
- d(W);
577
- }, [e, o]), b = F(async (v, m = 300, S = 300) => {
578
- const W = await R1(v, m, S, e);
579
- return Q(W), w(), W;
580
- }, [Q, w, e]), k = F((v, m = !1) => {
581
- n.current = n.current.map((S) => S.id === o?.id ? v : S), l((S) => S?.id === v.id ? v : S), m && w();
582
- }, [o, w]), P = F((v) => {
583
- const m = v.map((S) => Zt(["chosen"], S));
584
- n.current = m, w();
585
- }, [w]), E = F((v) => {
586
- l((m) => m?.id === v.id ? void 0 : m), n.current = n.current.filter((m) => m.id !== v.id), w();
587
- }, [w]), H = F((v) => {
588
- u((m) => {
589
- const S = v(m);
590
- return n.current = m.states[S].shapes, l(m.states[S].selectedShape), de("cursor", S, m);
635
+ }, Pa = (e) => {
636
+ const t = ["img", "id", "selection", "path", "arrows", "tempPoint"];
637
+ return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? Xt(t, i) : Xt(t, { ...i, src: Ma(i) }));
638
+ }, li = (e, t, i) => ({ shapes: Pa(e), config: { width: t, height: i } }), Di = (e, t) => et({ ...e, id: ce(`${e.type}_`) }, t), La = (e, t, i) => {
639
+ const n = j([]), s = j({ dataChanged: [] }), [a, o] = I(void 0), [r, l] = I(void 0), [c, h] = I(void 0), [d, u] = I({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), g = d.cursor > 0, f = d.cursor < d.states.length - 1, w = n.current.length > 0, C = R(() => {
640
+ u((m) => Pn(m.states[m.cursor].shapes, n.current) ? m : { states: [...m.states.slice(0, m.cursor + 1), { shapes: n.current, selectedShape: r, source: "user" }], cursor: m.cursor + 1 });
641
+ }, [r]), x = R((m) => {
642
+ n.current = [m, ...n.current];
643
+ }, []), b = R((m, y, S, V) => {
644
+ if (m.target && "className" in m.target && ![xn, Mn].includes(m.target.className) || !V) return void h(void 0);
645
+ const T = n.current.find((k) => k.id === r?.id ? !!ht(r, S, e) : !!An(y, k, S, e));
646
+ h(T);
647
+ }, [e, r]), M = R(async (m, y = 300, S = 300) => {
648
+ const V = await ya(m, y, S, e);
649
+ return x(V), C(), V;
650
+ }, [x, C, e]), v = R((m, y = !1) => {
651
+ n.current = n.current.map((S) => S.id === r?.id ? m : S), l((S) => S?.id === m.id ? m : S), y && C();
652
+ }, [r, C]), Q = R((m) => {
653
+ const y = m.map((S) => Xt(["chosen"], S));
654
+ n.current = y, C();
655
+ }, [C]), H = R((m) => {
656
+ l((y) => y?.id === m.id ? void 0 : y), n.current = n.current.filter((y) => y.id !== m.id), C();
657
+ }, [C]), Z = R((m) => {
658
+ u((y) => {
659
+ const S = m(y);
660
+ return n.current = y.states[S].shapes, l(y.states[S].selectedShape), me("cursor", S, y);
591
661
  });
592
- }, []), T = F(() => {
593
- H((v) => Math.max(0, v.cursor - 1));
594
- }, [H]), C = F(() => {
595
- H((v) => Math.min(v.states.length - 1, v.cursor + 1));
596
- }, [H]), V = F((v, m) => {
597
- l(void 0), n.current = v, u((S) => m.clearHistory ? { states: [{ shapes: v, selectedShape: void 0, source: m.source }], cursor: 0 } : { states: [...S.states.slice(0, S.cursor + 1), { shapes: v, selectedShape: void 0, source: m.source }], cursor: S.cursor + 1 });
598
- }, []), I = F((v, m) => {
599
- const S = n.current, W = S.findIndex((U) => U.id === v), z = S.findIndex((U) => U.id === m);
600
- var O, X, D;
601
- P((O = S, D = z, (X = W) < 0 || D < 0 || X > O.length - 1 || D > O.length - 1 ? O : X < D ? [...O.slice(0, X), ...O.slice(X + 1, D + 1), O[X], ...O.slice(D + 1, O.length)] : [...O.slice(0, D), O[X], ...O.slice(D, X), ...O.slice(X + 1, O.length)]));
602
- }, [P]), y = F((v) => {
603
- const m = n.current, S = m.findIndex((z) => z.id === v.id);
662
+ }, []), E = R(() => {
663
+ Z((m) => Math.max(0, m.cursor - 1));
664
+ }, [Z]), D = R(() => {
665
+ Z((m) => Math.min(m.states.length - 1, m.cursor + 1));
666
+ }, [Z]), P = R((m, y) => {
667
+ l(void 0), n.current = m, u((S) => y.clearHistory ? { states: [{ shapes: m, selectedShape: void 0, source: y.source }], cursor: 0 } : { states: [...S.states.slice(0, S.cursor + 1), { shapes: m, selectedShape: void 0, source: y.source }], cursor: S.cursor + 1 });
668
+ }, []), W = R((m, y) => {
669
+ const S = n.current, V = S.findIndex((te) => te.id === m), T = S.findIndex((te) => te.id === y);
670
+ var k, F, A;
671
+ Q((k = S, A = T, (F = V) < 0 || A < 0 || F > k.length - 1 || A > k.length - 1 ? k : F < A ? [...k.slice(0, F), ...k.slice(F + 1, A + 1), k[F], ...k.slice(A + 1, k.length)] : [...k.slice(0, A), k[F], ...k.slice(A, F), ...k.slice(F + 1, k.length)]));
672
+ }, [Q]), N = R((m) => {
673
+ const y = n.current, S = y.findIndex((T) => T.id === m.id);
604
674
  if (S < 0) return;
605
- const W = de("visible", v.visible === !1, v);
606
- l((z) => z?.id === W.id ? W : z), P(de(S, W, m));
607
- }, [P]), N = F((v) => {
608
- const m = n.current, S = m.findIndex((z) => z.id === v.id);
675
+ const V = me("visible", m.visible === !1, m);
676
+ l((T) => T?.id === V.id ? V : T), Q(me(S, V, y));
677
+ }, [Q]), z = R((m) => {
678
+ const y = n.current, S = y.findIndex((T) => T.id === m.id);
609
679
  if (S < 0) return;
610
- const W = de("locked", !v.locked, v);
611
- l((z) => z?.id === W.id ? W : z), P(de(S, W, m));
612
- }, [P]), M = F((v, m) => {
613
- s.current.hasOwnProperty(v) && (s.current[v] = [...s.current[v], m]);
614
- }, []), A = F((v, m) => {
615
- if (s.current.hasOwnProperty(v)) if (m) {
616
- const S = s.current[v].findIndex((W) => W === m);
617
- s.current[v] = [...s.current[v].slice(0, S), ...s.current[v].slice(S + 1)];
618
- } else s.current[v] = [];
680
+ const V = me("locked", !m.locked, m);
681
+ l((T) => T?.id === V.id ? V : T), Q(me(S, V, y));
682
+ }, [Q]), B = R((m, y) => {
683
+ s.current.hasOwnProperty(m) && (s.current[m] = [...s.current[m], y]);
684
+ }, []), U = R((m, y) => {
685
+ if (s.current.hasOwnProperty(m)) if (y) {
686
+ const S = s.current[m].indexOf(y);
687
+ s.current[m] = [...s.current[m].slice(0, S), ...s.current[m].slice(S + 1)];
688
+ } else s.current[m] = [];
619
689
  }, []);
620
- G(() => {
621
- const v = c.states[c.cursor], m = Xt(v.shapes, i, t);
622
- for (const S of s.current.dataChanged) S(m, v.source);
623
- }, [i, t, c]), G(() => {
624
- n.current = n.current.map((v) => ot(v, e)), l((v) => v === void 0 ? void 0 : n.current.find((m) => m.id === v.id));
690
+ q(() => {
691
+ const m = d.states[d.cursor], y = li(m.shapes, t, i);
692
+ for (const S of s.current.dataChanged) S(y, m.source);
693
+ }, [t, i, d]), q(() => {
694
+ n.current = n.current.map((m) => et(m, e)), l((m) => m === void 0 ? void 0 : et(m, e));
625
695
  }, [e]);
626
- const Z = F((v, m) => {
627
- r((S) => {
628
- const W = [S?.[0] ?? [m[0], m[1]], [m[0], m[1]]], z = n.current.filter((O) => ((X, D, U, le) => {
629
- const { selectionPadding: te, canvasOffset: ie } = le, { center: fe, borders: Me } = q(D, le), ne = Oe(U[0], D.rotation, fe, ie), _ = Oe(U[1], D.rotation, fe, ie), Se = Math.round(Math.min(ne[0], _[0]) - te / 2), Ze = Math.round(Math.max(ne[0], _[0]) + te), ke = Math.round(Math.min(ne[1], _[1]) - te / 2), me = { x: Se, y: ke, width: Ze - Se, height: Math.round(Math.max(ne[1], _[1]) + te) - ke }, be = pi(Me, me);
630
- if (!be) return !1;
631
- if (Me.width <= 1 || Me.height <= 1 || !("path" in D) || !D.path) return !0;
632
- if (X.lineWidth = (D.style?.lineWidth ?? 0) + 10, D.type === "brush") {
633
- const oe = D.points.flat(), Le = Math.min(...oe.map((he) => he[0])), Ne = Math.min(...oe.map((he) => he[1]));
634
- for (const he of D.points) {
635
- if (he.length < 1) break;
636
- if (he.length < 2) {
637
- const ye = Qe(he[0], Le, Ne, D.scaleX, D.scaleY);
638
- if (d1(be, { x: ye[0], y: ye[1], radius: (D.style?.lineWidth ?? 1) / 2 })) return !0;
696
+ const L = R((m, y) => {
697
+ o((S) => {
698
+ const V = [S?.[0] ?? [y[0], y[1]], [y[0], y[1]]], T = n.current.filter((k) => ((F, A, te, ne) => {
699
+ const { selectionPadding: Y } = ne, { center: K, borders: G } = J(A, ne), oe = He(te[0], A.rotation, K), ee = He(te[1], A.rotation, K), ie = Math.round(Math.min(oe[0], ee[0]) - Y / 2), ye = Math.round(Math.max(oe[0], ee[0]) + Y), we = Math.round(Math.min(oe[1], ee[1]) - Y / 2), se = { x: ie, y: we, width: ye - ie, height: Math.round(Math.max(oe[1], ee[1]) + Y) - we }, Qe = Gt(G, se);
700
+ if (!Qe) return !1;
701
+ if (G.width <= 1 || G.height <= 1 || !("path" in A) || !A.path) return !0;
702
+ if (F.lineWidth = (A.style?.lineWidth ?? 0) + 10, A.type === "brush") {
703
+ const De = A.points.flat(), he = Math.min(...De.map((pe) => pe[0])), We = Math.min(...De.map((pe) => pe[1]));
704
+ for (const pe of A.points) {
705
+ if (pe.length < 1) break;
706
+ if (pe.length < 2) {
707
+ const re = Me(pe[0], he, We, A.scaleX, A.scaleY);
708
+ if (Zn(Qe, { x: re[0], y: re[1], radius: (A.style?.lineWidth ?? 1) / 2 })) return !0;
639
709
  }
640
- for (let ye = 0; ye < he.length - 1; ye++) {
641
- const ae = Qe(he[ye], Le, Ne, D.scaleX, D.scaleY), Ve = Qe(he[ye + 1], Le, Ne, D.scaleX, D.scaleY), $e = pi({ x: Math.min(ae[0], Ve[0]), y: Math.min(ae[1], Ve[1]), width: Math.abs(ae[0] - Ve[0]), height: Math.abs(ae[1] - Ve[1]) }, me);
642
- if ($e) {
643
- const Pe = new Path2D();
644
- if (Pe.moveTo(...ae), Pe.lineTo(...Ve), ui({ ctx: X, path: Pe, rect: $e, offset: 10, checkFill: !1 })) return !0;
710
+ for (let re = 0; re < pe.length - 1; re++) {
711
+ const Ze = Me(pe[re], he, We, A.scaleX, A.scaleY), ke = Me(pe[re + 1], he, We, A.scaleX, A.scaleY), Ge = Gt({ x: Math.min(Ze[0], ke[0]), y: Math.min(Ze[1], ke[1]), width: Math.abs(Ze[0] - ke[0]), height: Math.abs(Ze[1] - ke[1]) }, se);
712
+ if (Ge) {
713
+ const Ne = new Path2D();
714
+ if (Ne.moveTo(...Ze), Ne.lineTo(...ke), xi({ ctx: F, path: Ne, rect: Ge, offset: 10, checkFill: !1 })) return !0;
645
715
  }
646
716
  }
647
717
  }
648
718
  return !1;
649
719
  }
650
- const Ee = !(!D.style?.fillColor || D.style?.fillColor === "transparent");
651
- return ui({ ctx: X, path: D.path, rect: be, offset: 10, checkFill: Ee });
652
- })(v, O, W, e));
653
- return l(z?.[0]), W;
720
+ const Ee = !(!A.style?.fillColor || A.style?.fillColor === "transparent");
721
+ return xi({ ctx: F, path: A.path, rect: Qe, offset: 10, checkFill: Ee });
722
+ })(m, k, V, e));
723
+ return l(T?.[0]), V;
654
724
  });
655
725
  }, [e]);
656
- return { registerEvent: M, unregisterEvent: A, shapesRef: n, selectedShape: o, hoveredShape: h, selectionFrame: a, setSelectionFrame: r, refreshSelectedShapes: Z, addShape: Q, addPictureShape: b, moveShapes: I, saveShapes: w, setSelectedShape: l, refreshHoveredShape: L, toggleShapeVisibility: y, toggleShapeLock: N, removeShape: E, updateShape: k, backwardShape: T, forwardShape: C, clearShapes: V, canGoBackward: g, canGoForward: f, canClear: x };
657
- }, wi = (e, i = !1) => {
658
- const t = (s, a) => {
726
+ return { registerEvent: B, unregisterEvent: U, shapesRef: n, selectedShape: r, hoveredShape: c, selectionFrame: a, setSelectionFrame: o, refreshSelectedShapes: L, addShape: x, addPictureShape: M, moveShapes: W, saveShapes: C, setSelectedShape: l, refreshHoveredShape: b, toggleShapeVisibility: N, toggleShapeLock: z, removeShape: H, updateShape: v, backwardShape: E, forwardShape: D, clearShapes: P, canGoBackward: g, canGoForward: f, canClear: w };
727
+ }, Wi = (e) => {
728
+ const t = [e[0].clientX, e[0].clientY], i = [e[1].clientX, e[1].clientY];
729
+ return { diff: Tn(t, i), center: ct(t, i) };
730
+ }, Va = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: n, setCanvasTransformation: s }) => {
731
+ const a = j([]), [o, r] = I(a.current.length > 0), l = j(null), c = j(t);
732
+ c.current = t;
733
+ const h = R(({ startDiff: d, startZoom: u, startCenter: g, startOffset: f, currentDiff: w, currentCenter: C, isMoving: x, isZooming: b }) => {
734
+ if (!e || !w || !d) return;
735
+ const M = (({ canvasBoundingRect: v, canvasSize: Q, size: H, startDiff: Z, startZoom: E, startCenter: D, startOffset: P, currentDiff: W, currentCenter: N, isMoving: z, isZooming: B }) => {
736
+ const U = B ? Ie(W / Z * E, fe[0], fe[fe.length - 1]) : E, L = z ? [P[0] + (N[0] - D[0]) * (Q.width / v.width) / Q.scaleRatio / E, P[1] + (N[1] - D[1]) * (Q.height / v.height) / Q.scaleRatio / E] : [P[0], P[1]], m = [(N[0] - v.left) / Q.scaleRatio, (N[1] - v.top) / Q.scaleRatio];
737
+ return _t({ size: H, canvasSize: Q, currentOffset: L, currentZoom: E, zoom: U, centerPoint: m });
738
+ })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: n, startDiff: d, startZoom: u, startCenter: g, startOffset: f, currentDiff: w, currentCenter: C, isMoving: x, isZooming: b });
739
+ s(M);
740
+ }, [e, i, n, s]);
741
+ q(() => {
742
+ if (!e) return;
743
+ const d = (u) => {
744
+ if (a.current = [...a.current, u], r(a.current.length > 0), a.current.length === 2) {
745
+ u.stopPropagation();
746
+ const { diff: g, center: f } = Wi(a.current);
747
+ l.current = { startDiff: g, startCenter: f, startZoom: c.current.zoom, startOffset: c.current.offset, isMoving: !1, isZooming: !1 };
748
+ }
749
+ };
750
+ return e.addEventListener("pointerdown", d), () => {
751
+ e.removeEventListener("pointerdown", d);
752
+ };
753
+ }, [e]), q(() => {
754
+ if (!o) return;
755
+ const d = (g) => {
756
+ const f = a.current.findIndex((w) => w.pointerId === g.pointerId);
757
+ if (f > -1 && (a.current[f] = g), a.current.length === 2 && l.current) {
758
+ const { diff: w, center: C } = Wi(a.current), x = l.current.isZooming || ((M, v) => Math.abs(M - v.startDiff) > 30)(w, l.current), b = l.current.isMoving || x || ((M, v) => Math.abs(Tn(M, v.startCenter)) > 10)(C, l.current);
759
+ l.current = { ...l.current, isMoving: b, isZooming: x }, h({ ...l.current, currentDiff: w, currentCenter: C });
760
+ }
761
+ }, u = (g) => {
762
+ a.current = a.current.filter((f) => f.pointerId !== g.pointerId), r(a.current.length > 0);
763
+ };
764
+ return document.addEventListener("pointermove", d), document.addEventListener("pointerup", u), document.addEventListener("pointerout", u), document.addEventListener("pointercancel", u), document.addEventListener("pointerleave", u), () => {
765
+ document.removeEventListener("pointermove", d), document.removeEventListener("pointerup", u), document.removeEventListener("pointerout", u), document.removeEventListener("pointercancel", u), document.removeEventListener("pointerleave", u);
766
+ };
767
+ }, [o, h]);
768
+ }, Ha = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: n }) => {
769
+ const [s, a] = I({ offset: [0, 0], zoom: 1 }), o = j(0), r = R((c) => {
770
+ a(({ zoom: h }) => Mi({ zoom: h, size: t, canvasSize: e, newOffset: c }));
771
+ }, [e, t]), l = R((c) => {
772
+ a(({ offset: h, zoom: d }) => (({ size: u, canvasSize: g, currentOffset: f, currentZoom: w, action: C }) => {
773
+ const x = C === "default" ? fe[4] : C === "zoom" ? fe[Ie(fe.length - 1 - fe.slice(0).reverse().findIndex((M) => M <= w) + 1, 0, fe.length - 1)] : fe[Ie(fe.findIndex((M) => M >= w) - 1, 0, fe.length - 1)], b = [g.realWidth / 2, g.realHeight / 2];
774
+ return _t({ size: u, canvasSize: g, currentOffset: f, currentZoom: w, zoom: x, centerPoint: b });
775
+ })({ size: t, canvasSize: e, currentOffset: h, currentZoom: d, action: c }));
776
+ }, [e, t]);
777
+ return Va({ canvasElt: n, canvasTransformation: s, canvasSize: e, size: t, setCanvasTransformation: a }), q(() => {
778
+ if (!i || !n) return;
779
+ const c = (h) => {
780
+ const d = h.ctrlKey, { deltaX: u, deltaY: g } = ((x, b) => {
781
+ const M = Math.abs(x.deltaY) < 50 && b < 50, v = x.ctrlKey, Q = Ln() && M && v;
782
+ switch (x.deltaMode) {
783
+ case WheelEvent.DOM_DELTA_LINE:
784
+ return { deltaX: 16 * x.deltaX, deltaY: 16 * x.deltaY };
785
+ case WheelEvent.DOM_DELTA_PAGE:
786
+ return { deltaX: x.deltaX * window.innerHeight, deltaY: x.deltaY * window.innerHeight };
787
+ default:
788
+ return Q ? { deltaX: 5 * x.deltaX, deltaY: 5 * x.deltaY } : { deltaX: x.deltaX, deltaY: x.deltaY };
789
+ }
790
+ })(h, h.timeStamp - o.current);
791
+ if (o.current = h.timeStamp, d) {
792
+ h.preventDefault();
793
+ const x = ((b, M, v) => {
794
+ const { clientX: Q, clientY: H } = zn(b), Z = M.getBoundingClientRect();
795
+ return [(Q - Z.left) / v.scaleRatio, (H - Z.top) / v.scaleRatio];
796
+ })(h, n, e);
797
+ return void a(({ offset: b, zoom: M }) => (({ size: v, canvasSize: Q, currentOffset: H, currentZoom: Z, delta: E, centerPoint: D }) => {
798
+ const P = Ie(Z * (1 - E / 1e3), fe[0], fe[fe.length - 1]);
799
+ return _t({ size: v, canvasSize: Q, currentOffset: H, currentZoom: Z, zoom: P, centerPoint: D });
800
+ })({ size: t, canvasSize: e, currentOffset: b, currentZoom: M, delta: g, centerPoint: x }));
801
+ }
802
+ const f = h.shiftKey, [w, C] = f ? [g, u] : [u, g];
803
+ a(({ offset: x, zoom: b }) => {
804
+ const M = [x[0] - w / b, x[1] - C / b], v = Mi({ zoom: b, size: t, canvasSize: e, newOffset: M });
805
+ return v.offset[0] === x[0] && v.offset[1] === x[1] || h.preventDefault(), v;
806
+ });
807
+ };
808
+ return n.addEventListener("wheel", c, { passive: !1 }), () => {
809
+ n.removeEventListener("wheel", c);
810
+ };
811
+ }, [n, t, e, i]), { setCanvasTransformation: a, setCanvasOffset: r, setCanvasZoom: l, canvasTransformation: s };
812
+ }, Ni = (e, t = !1) => {
813
+ const i = (s, a) => {
659
814
  if (Array.isArray(s)) return a;
660
815
  }, n = e.map((s) => {
661
816
  if (typeof s != "object") return null;
662
817
  switch (s.type) {
663
818
  case "brush":
664
- return xe(t, Bi, s);
819
+ return Ve(i, hn, s);
665
820
  case "circle":
666
- return xe(t, qi, s);
821
+ return Ve(i, mn, s);
667
822
  case "curve":
668
- return xe(t, Yi, s);
823
+ return Ve(i, gn, s);
669
824
  case "ellipse":
670
- return xe(t, Ji, s);
825
+ return Ve(i, yn, s);
671
826
  case "line":
672
- return xe(t, Gi, s);
827
+ return Ve(i, un, s);
673
828
  case "polygon":
674
- return xe(t, Xi, s);
829
+ return Ve(i, pn, s);
675
830
  case "rect":
676
- return xe(t, ji, s);
831
+ return Ve(i, fn, s);
677
832
  case "square":
678
- return xe(t, _i, s);
833
+ return Ve(i, vn, s);
679
834
  case "text":
680
- return xe(t, Ki, s);
835
+ return Ve(i, Qn, s);
681
836
  }
682
837
  return null;
683
838
  });
684
- return $t(i ? [...n, Ot] : n);
685
- }, An = ({ width: e = 1e3, height: i = 600, shapes: t, mode: n = "editor", disabled: s = !1, options: a = oi } = {}) => {
686
- const { layersManipulation: r, brushAlgo: o, isBrushShapeDoneOnMouseUp: l, grid: h, canGrow: d, canShrink: c, withExport: u, withLoadAndSave: g, withUploadPicture: f, withUrlPicture: x, withSkeleton: w, withFrameSelection: Q, clearCallback: L, availableTools: b, canvasSelectionPadding: k } = { ...oi, ...a }, P = n !== "viewer", E = s || !P, H = J(null), T = J(null), C = J(!1), V = F((j) => {
687
- H.current = j;
688
- }, []), [I, y] = $(Ae), [N, M] = $(h), [A, Z] = $({ width: e, height: i, scaleRatio: 1 }), [v, m] = $([0, 0]), S = Ni(() => ({ brushAlgo: o, isBrushShapeDoneOnMouseUp: l, canvasSize: A, canvasOffset: v, gridGap: N, selectionPadding: k }), [k, N, o, l, v, A]), [W, z] = $(wi(b, f || x)), { isInsideComponent: O } = (({ disabled: j, componentRef: Ce }) => {
689
- const [it, Ie] = $(!1);
690
- return G(() => {
691
- if (!j) {
692
- const He = (We) => {
693
- Ie(o1(We, Ce.current));
839
+ return ri(t ? [...n, ii] : n);
840
+ }, ms = ({ width: e = 1e3, height: t = 600, shapes: i, mode: n = "editor", disabled: s = !1, options: a = Si } = {}) => {
841
+ const { layersManipulation: o, brushAlgo: r, isBrushShapeDoneOnMouseUp: l, grid: c, canGrow: h, canShrink: d, withExport: u, withLoadAndSave: g, withUploadPicture: f, withUrlPicture: w, withSkeleton: C, withFrameSelection: x, clearCallback: b, availableTools: M, canvasSelectionPadding: v, size: Q, canZoom: H } = { ...Si, ...a }, Z = n !== "viewer", E = j(null), D = j(null), P = j(!1), W = R((_) => {
842
+ E.current = _;
843
+ }, []), [N, z] = I(void 0), [B, U] = I(Ae), [L, m] = I({ mode: "default" }), [y, S] = I(c), [V, T] = I({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), k = H === "always" && !s, { canvasTransformation: F, setCanvasTransformation: A, setCanvasOffset: te, setCanvasZoom: ne } = Ha({ canvasSize: V, size: Q, canvasElt: D.current, zoomEnabled: k }), { offset: Y, zoom: K } = F, G = tn(() => ({ brushAlgo: r, isBrushShapeDoneOnMouseUp: l, canvasSize: { realWidth: V.realWidth, realHeight: V.realHeight, width: V.width, height: V.height, scaleRatioWithNoZoom: V.scaleRatio, scaleRatio: V.scaleRatio * K }, size: Q, canvasOffset: Y, canvasZoom: K, gridGap: y, selectionPadding: v, features: { edition: Z && !s, zoom: k } }), [v, y, r, l, K, Y, V, Q, s, k, Z]), [oe, ee] = I(Ni(M, f || w)), { isInsideComponent: ie } = (({ settings: _, componentRef: ge }) => {
844
+ const [st, Be] = I(!1), Ue = !_.features.edition && !_.features.zoom;
845
+ return q(() => {
846
+ if (!Ue) {
847
+ const Pe = (ot) => {
848
+ Be(kn(ot, ge.current));
694
849
  };
695
- return document.addEventListener("mousedown", He, { passive: !0 }), document.addEventListener("touchstart", He, { passive: !0 }), () => {
696
- document.removeEventListener("mousedown", He), document.removeEventListener("touchstart", He);
850
+ return document.addEventListener("mousedown", Pe, { passive: !0 }), document.addEventListener("touchstart", Pe, { passive: !0 }), () => {
851
+ document.removeEventListener("mousedown", Pe), document.removeEventListener("touchstart", Pe);
697
852
  };
698
853
  }
699
- Ie(!1);
700
- }, [j, Ce]), { isInsideComponent: it };
701
- })({ disabled: E, componentRef: H }), { registerEvent: X, unregisterEvent: D, shapesRef: U, selectedShape: le, selectionFrame: te, hoveredShape: ie, addShape: fe, addPictureShape: Me, moveShapes: ne, setSelectedShape: _, setSelectionFrame: Se, refreshSelectedShapes: Ze, refreshHoveredShape: ke, removeShape: me, updateShape: be, backwardShape: Ee, forwardShape: oe, clearShapes: Le, saveShapes: Ne, toggleShapeVisibility: he, toggleShapeLock: ye, canGoBackward: ae, canGoForward: Ve, canClear: $e } = Y1(S, e, i), Pe = F((j) => {
702
- _(void 0), y(j);
703
- }, [_]), Ue = F((j, Ce) => {
704
- Le(j, Ce), Pe(Ae), m([0, 0]);
705
- }, [Pe, Le]), lt = F((j) => {
706
- y(Ae), _(j);
707
- }, [_]), Ct = F(() => {
708
- const j = G1(U.current, e, i);
709
- if (!j) throw new Error("L'encodage a échoué");
710
- Si(j, "drawing.json");
711
- }, [U, e, i]), wt = F(() => {
712
- const j = bi(U.current, e, i, S);
713
- if (!j) throw new Error();
714
- Si(j, "drawing.png");
715
- }, [U, e, i, S]), xt = F(() => T.current ? bi(U.current, e, i, S) : void 0, [U, e, i, S]), K = F(() => Xt(U.current, e, i), [U, e, i]);
716
- G(() => {
717
- O || _(void 0);
718
- }, [O, _]);
719
- const se = F(async (j, Ce) => {
720
- const it = await (async (Ie, He) => {
721
- if (!Ie) return [];
722
- const We = [], Mt = $t(Ie.map((ue) => {
723
- if (!ue || !n1.includes(ue.type)) return null;
724
- if (ue.type === "picture") {
725
- const we = new Image(), y1 = new Promise((nt, Q1) => {
726
- we.onload = () => {
727
- URL.revokeObjectURL(we.src), nt();
728
- }, we.onerror = () => {
729
- Q1(new Error("Some images could not be loaded"));
854
+ Be(!1);
855
+ }, [Ue, ge]), { isInsideComponent: st };
856
+ })({ settings: G, componentRef: E }), { registerEvent: ye, unregisterEvent: we, shapesRef: se, selectedShape: Qe, selectionFrame: Ee, hoveredShape: De, addShape: he, addPictureShape: We, moveShapes: pe, setSelectedShape: re, setSelectionFrame: Ze, refreshSelectedShapes: ke, refreshHoveredShape: Ge, removeShape: Ne, updateShape: Ce, backwardShape: pt, forwardShape: gt, clearShapes: ft, saveShapes: At, toggleShapeVisibility: Et, toggleShapeLock: Dt, canGoBackward: le, canGoForward: de, canClear: vt } = La(G, e, t), Te = R((_) => {
857
+ re(void 0), U(_);
858
+ }, [re]);
859
+ q(() => {
860
+ if (L.mode === "preview") return () => m((_) => _.mode === "preview" ? { mode: "default" } : _);
861
+ }, [Qe?.id, L.mode === "preview"]);
862
+ const Re = R((_, ge) => {
863
+ ft(_, ge), Te(Ae), A({ offset: [0, 0], zoom: 1 });
864
+ }, [Te, ft, A]), di = R((_) => {
865
+ re((ge) => (ge?.id !== _.id && U(Ae), _));
866
+ }, [re]), Un = R(() => {
867
+ const _ = ka(se.current, e, t);
868
+ if (!_) throw new Error("L'encodage a échoué");
869
+ Ai(_, "drawing.json");
870
+ }, [se, e, t]), Xn = R((_) => {
871
+ const ge = Ei({ shapes: se.current, settings: G, view: _ });
872
+ Ai(ge, "drawing.png");
873
+ }, [se, G]), Yn = R((_) => Ei({ shapes: se.current, settings: G, view: _ }), [se, G]), qn = R(() => li(se.current, e, t), [se, e, t]);
874
+ q(() => {
875
+ ie || re(void 0);
876
+ }, [ie, re]);
877
+ const $e = R(async (_, ge) => {
878
+ const st = await (async (Be, Ue) => {
879
+ if (!Be) return [];
880
+ const Pe = [], ot = ri(Be.map((Se) => {
881
+ if (!Se || !Cn.includes(Se.type)) return null;
882
+ if (Se.type === "picture") {
883
+ const Le = new Image(), Kn = new Promise((rt, Jn) => {
884
+ Le.onload = () => {
885
+ URL.revokeObjectURL(Le.src), rt();
886
+ }, Le.onerror = () => {
887
+ Jn(new Error("Some images could not be loaded"));
730
888
  };
731
889
  });
732
- if (We.push(y1), ue.src.startsWith("http")) v1(ue.src).then((nt) => {
733
- we.src = nt;
890
+ if (Pe.push(Kn), Se.src.startsWith("http")) $n(Se.src).then((rt) => {
891
+ Le.src = rt;
734
892
  }).catch(() => {
735
- we.src = "";
893
+ Le.src = "";
736
894
  });
737
- else if (ue.src.includes("<svg")) {
738
- const nt = new Blob([ue.src], { type: "image/svg+xml" });
739
- we.src = URL.createObjectURL(nt);
740
- } else we.src = ue.src;
741
- return Ci({ ...ue, img: we }, He);
895
+ else if (Se.src.includes("<svg")) {
896
+ const rt = new Blob([Se.src], { type: "image/svg+xml" });
897
+ Le.src = URL.createObjectURL(rt);
898
+ } else Le.src = Se.src;
899
+ return Di({ ...Se, img: Le }, Ue);
742
900
  }
743
- return Ci(ue, He);
901
+ return Di(Se, Ue);
744
902
  }));
745
- return await Promise.all(We), Mt;
746
- })(j, S);
747
- Ue(it, Ce);
748
- }, [Ue, S]), Be = J();
749
- Be.current = se;
750
- const Re = F((j = [], Ce = !0) => {
751
- Be.current?.(j, { clearHistory: Ce, source: "remote" });
903
+ return await Promise.all(Pe), ot;
904
+ })(_, G);
905
+ Re(st, ge);
906
+ }, [Re, G]), Wt = j($e);
907
+ Wt.current = $e;
908
+ const Gn = R((_ = [], ge = !0) => {
909
+ Wt.current?.(_, { clearHistory: ge, source: "remote" });
752
910
  }, []);
753
- G(() => {
754
- C.current || (C.current = !0, t && Be.current?.(t, { clearHistory: !0, source: "remote" }));
755
- }, [t]);
756
- const tt = F(async (j) => {
757
- const Ce = await (async (it) => new Promise((Ie, He) => {
758
- const We = new FileReader();
759
- We.onload = (Mt) => {
760
- const ue = Mt.target?.result;
761
- if (!ue) return He("Impossible de récupérer les données du fichier");
762
- const we = JSON.parse(ue);
763
- Ie(we);
764
- }, We.readAsText(it);
765
- }))(j);
766
- await se(Ce.shapes ?? [], { clearHistory: !0, source: "remote" });
767
- }, [se]), m1 = F(() => {
768
- typeof L != "string" ? se(L(), { clearHistory: !1, source: "user" }) : L === "defaultShapes" && t !== void 0 ? se(t, { clearHistory: !1, source: "user" }) : Ue([], { clearHistory: !1, source: "user" });
769
- }, [Ue, se, t, L]);
770
- G(() => {
771
- z(wi(b, f || x));
772
- }, [b, f, x]);
773
- const _t = { canvas: T, editor: H, setEditor: V };
774
- return { editorProps: { shapesRef: U, addPictureShape: Me, moveShapes: ne, toggleShapeVisibility: he, toggleShapeLock: ye, canGoBackward: ae, canGoForward: Ve, canClear: $e, selectedShape: le, removeShape: me, updateShape: be, backwardShape: Ee, forwardShape: oe, refs: _t, width: e, height: i, canvasSize: A, selectTool: Pe, selectShape: lt, activeTool: I, setActiveTool: y, setAvailableTools: z, isEditMode: P, isDisabled: E, availableTools: W, gridGap: N, setGridGap: M, loadFile: tt, exportPicture: wt, exportData: Ct, clearCanvas: m1, settings: S, canvas: { canGrow: d, canShrink: c, layersManipulation: r, withExport: u, withLoadAndSave: g, withUploadPicture: f, withUrlPicture: x } }, canvasProps: { shapesRef: U, selectedShape: le, selectionFrame: te, hoveredShape: ie, addShape: fe, setSelectedShape: _, setSelectionFrame: Se, refreshSelectedShapes: Ze, refreshHoveredShape: ke, removeShape: me, updateShape: be, backwardShape: Ee, forwardShape: oe, saveShapes: Ne, refs: _t, width: e, height: i, settings: S, canvasSize: A, setCanvasSize: Z, setCanvasOffset: m, selectShape: lt, activeTool: I, setActiveTool: y, isInsideComponent: O, isEditMode: P, isDisabled: E, canvas: { withSkeleton: w, withFrameSelection: Q, canGrow: d, canShrink: c } }, registerEvent: X, unregisterEvent: D, resetCanvas: Re, getCurrentImage: xt, getCurrentData: K };
775
- }, j1 = (e, i, t, n, s, a, r) => {
776
- let o = !1;
911
+ q(() => {
912
+ P.current || (P.current = !0, i && Wt.current?.(i, { clearHistory: !0, source: "remote" }));
913
+ }, [i]);
914
+ const _n = R(async (_) => {
915
+ const ge = await (async (st) => new Promise((Be, Ue) => {
916
+ const Pe = new FileReader();
917
+ Pe.onload = (ot) => {
918
+ const Se = ot.target?.result;
919
+ if (!Se) return Ue("Impossible de récupérer les données du fichier");
920
+ const Le = JSON.parse(Se);
921
+ Be(Le);
922
+ }, Pe.readAsText(st);
923
+ }))(_);
924
+ await $e(ge.shapes ?? [], { clearHistory: !0, source: "remote" });
925
+ }, [$e]), jn = R(() => {
926
+ typeof b != "string" ? $e(b(), { clearHistory: !1, source: "user" }) : b === "defaultShapes" && i !== void 0 ? $e(i, { clearHistory: !1, source: "user" }) : Re([], { clearHistory: !1, source: "user" });
927
+ }, [Re, $e, i, b]);
928
+ q(() => {
929
+ ee(Ni(M, f || w));
930
+ }, [M, f, w]);
931
+ const ci = { canvas: D, editor: E, setEditor: W };
932
+ return { annotationsProps: { style: { "user-select": "none", "touch-action": "none", transformOrigin: "left top", transform: "scale(var(--react-paint-canvas-zoom)) translate(calc(var(--react-paint-canvas-offset-x) * 100% / var(--react-paint-app-canvaswidth)), calc(var(--react-paint-canvas-offset-y) * 100% / var(--react-paint-app-canvasheight)))", "--react-paint-canvas-zoom": G.canvasZoom, "--react-paint-canvas-offset-x": G.canvasOffset[0], "--react-paint-canvas-offset-y": G.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: se, addPictureShape: We, moveShapes: pe, toggleShapeVisibility: Et, toggleShapeLock: Dt, canGoBackward: le, canGoForward: de, canClear: vt, selectedShape: Qe, removeShape: Ne, updateShape: Ce, backwardShape: pt, forwardShape: gt, refs: ci, width: e, height: t, selectTool: Te, selectShape: di, activeTool: B, setActiveTool: U, setAvailableTools: ee, isEditMode: Z, availableTools: oe, gridGap: y, setGridGap: S, loadFile: _n, exportPicture: Xn, exportData: Un, clearCanvas: jn, settings: G, setCanvasZoom: ne, canvas: { canGrow: h, canShrink: d, layersManipulation: o, withExport: u, withLoadAndSave: g, withUploadPicture: f, withUrlPicture: w } }, canvasProps: { shapesRef: se, selectedShape: Qe, selectionFrame: Ee, hoveredShape: De, addShape: he, setSelectedShape: re, setSelectionFrame: Ze, refreshSelectedShapes: ke, refreshHoveredShape: Ge, removeShape: Ne, updateShape: Ce, backwardShape: pt, forwardShape: gt, saveShapes: At, refs: ci, width: e, height: t, settings: G, setCanvasSize: T, setCanvasOffset: te, setCanvasZoom: ne, selectShape: di, activeTool: B, setActiveTool: U, isInsideComponent: ie, isEditMode: Z, canvas: { withSkeleton: C, withFrameSelection: x, canGrow: h, canShrink: d }, canvasOffsetStartData: N, setCanvasOffsetStartData: z, selectionMode: L, setSelectionMode: m }, registerEvent: ye, unregisterEvent: we, resetCanvas: Gn, getCurrentImage: Yn, getCurrentData: qn, setCanvasOffset: te, setCanvasZoom: ne };
933
+ }, Za = (e, t, i, n, s, a, o) => {
934
+ let r = !1;
777
935
  if (s) {
778
- o = st(s, t, n, !0, a ? 20 : void 0);
779
- const h = ((d, c, u, g) => {
780
- if (d.mode === "translate") return { mode: "translate", cursorStartPosition: u, originalShape: c };
781
- if (d.mode === "rotate") {
782
- const { center: f } = q(c, g);
783
- return { mode: "rotate", cursorStartPosition: u, originalShape: c, center: [f[0], f[1]] };
936
+ r = ht(s, i, n, !0, a ? 20 : void 0);
937
+ const c = ((h, d, u, g) => {
938
+ if (h.mode === "translate") return { mode: "translate", cursorStartPosition: u, originalShape: d };
939
+ if (h.mode === "rotate") {
940
+ const { center: f } = J(d, g);
941
+ return { mode: "rotate", cursorStartPosition: u, originalShape: d, center: [f[0], f[1]] };
784
942
  }
785
- return d.mode === "resize" ? { mode: "resize", cursorStartPosition: u, originalShape: c, anchor: d.anchor } : void 0;
786
- })(o || { mode: "default" }, s, t, n);
787
- if (h?.mode === "resize" || h?.mode === "rotate") return { shape: s, mode: h };
943
+ return h.mode === "resize" ? { mode: "resize", isCreating: !1, cursorStartPosition: u, originalShape: d, anchor: h.anchor } : void 0;
944
+ })(r || { mode: "default" }, s, i, n);
945
+ if (c?.mode === "resize" || c?.mode === "rotate") return { shape: s, mode: c };
788
946
  }
789
- const l = i.find((h) => h.id === s?.id ? !!o : !!c1(e, h, t, n));
790
- return l ? { shape: l, mode: { mode: "translate", cursorStartPosition: t, originalShape: l } } : { shape: void 0, mode: { mode: r ? "selectionFrame" : "default" } };
791
- }, _1 = ({ disabled: e = !1, addShape: i, drawCanvasRef: t, setActiveTool: n, refreshHoveredShape: s, shapes: a, selectionMode: r, activeTool: o, isInsideComponent: l, setCanvasOffset: h, selectedShape: d, selectionCanvasRef: c, canvasOffsetStartPosition: u, refreshSelectedShapes: g, setSelectedShape: f, setSelectionFrame: x, setCanvasOffsetStartPosition: w, updateSingleShape: Q, saveShapes: L, setSelectionMode: b, settings: k, isShiftPressed: P, withFrameSelection: E }) => {
792
- const [H, T] = $({ mode: "default" }), { registerDoubleClickEvent: C, unRegisterDoubleClickEvent: V } = (() => {
793
- const y = J(void 0), N = J(void 0), M = (A) => {
794
- const Z = (/* @__PURE__ */ new Date()).getTime();
795
- y.current && Z < y.current + 300 && N.current?.(A), y.current = (/* @__PURE__ */ new Date()).getTime();
947
+ const l = t.find((c) => c.id === s?.id ? !!r : !!An(e, c, i, n));
948
+ return l ? { shape: l, mode: { mode: "translate", cursorStartPosition: i, originalShape: l } } : { shape: void 0, mode: { mode: o ? "selectionFrame" : "default" } };
949
+ }, Ta = ({ addShape: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: n, shapes: s, selectionMode: a, activeTool: o, isInsideComponent: r, setCanvasOffset: l, selectedShape: c, canvasOffsetStartData: h, refreshSelectedShapes: d, setSelectedShape: u, setSelectionFrame: g, setCanvasOffsetStartData: f, updateSingleShape: w, saveShapes: C, setSelectionMode: x, settings: b, isShiftPressed: M, isAltPressed: v, withFrameSelection: Q }) => {
950
+ const [H, Z] = I({ mode: "default" }), { registerDoubleClickEvent: E, unRegisterDoubleClickEvent: D } = (() => {
951
+ const L = j(void 0), m = j(void 0), y = (S) => {
952
+ const V = Date.now();
953
+ L.current && V < L.current + 300 && m.current?.(S), L.current = Date.now();
796
954
  };
797
- return { registerDoubleClickEvent: (A, Z) => {
798
- N.current = Z, A.addEventListener("click", M), A.addEventListener("touchend", M);
799
- }, unRegisterDoubleClickEvent: (A) => {
800
- A.removeEventListener("click", M), A.removeEventListener("touchend", M);
955
+ return { registerDoubleClickEvent: (S, V) => {
956
+ m.current = V, S.addEventListener("click", y), S.addEventListener("touchend", y);
957
+ }, unRegisterDoubleClickEvent: (S) => {
958
+ S.removeEventListener("click", y), S.removeEventListener("touchend", y);
801
959
  } };
802
- })();
803
- G(() => {
804
- const y = (N) => ((M, A, Z, v, m, S, W, z, O, X, D, U, le) => {
805
- const te = A.current?.getContext("2d");
806
- if (!te) return;
807
- const ie = Pt(M, A.current, U);
808
- if (Z.type !== "move" || S === void 0) if (m.mode !== "selectionFrame") {
809
- if (hi(M) || z(M, te, ie, U), v !== void 0 && !v.locked) if (m.mode === "default" || m.mode === "textedition") W(st(v, ie, U, !0) || { mode: "default" });
810
- else {
811
- const fe = A.current?.getContext("2d");
812
- if (!fe) return;
813
- O(L1(fe, v, ie, m, U, le));
814
- }
815
- } else D(te, ie, U);
816
- else X([ie[0] - S[0], ie[1] - S[1]]);
817
- })(N, c, o, d, r, u, T, s, Q, h, g, k, P);
818
- if (l) return document.addEventListener("mousemove", y), document.addEventListener("touchmove", y), () => {
819
- document.removeEventListener("mousemove", y), document.removeEventListener("touchmove", y);
820
- };
821
- }, [l, c, d, r, u, Q, o, h, s, g, k, P]);
822
- const { isBrushShapeDoneOnMouseUp: I } = k;
823
- return G(() => {
824
- const y = () => {
825
- r.mode !== "textedition" && r.mode !== "default" && (r.mode === "brush" && I && f(void 0), b({ mode: "default" }), x(void 0), L());
826
- };
827
- return l && (document.addEventListener("mouseup", y), document.addEventListener("touchend", y)), () => {
828
- l && (document.removeEventListener("mouseup", y), document.removeEventListener("touchend", y));
829
- };
830
- }, [l, r, I, L, x, b, f]), G(() => {
831
- const y = c.current;
960
+ })(), P = j(null);
961
+ P.current = (L) => ((m, y, S, V, T, k, F, A, te, ne, Y, K, G, oe) => {
962
+ if (lt(m) && m.touches.length > 1) return;
963
+ const ee = y.current?.getContext("2d");
964
+ if (!ee) return;
965
+ const ie = mt(m, y.current, Y);
966
+ if (T !== void 0) return void te([ie[0] + Y.canvasOffset[0] - T.start[0], ie[1] + Y.canvasOffset[1] - T.start[1]]);
967
+ if (V.mode === "selectionFrame") return void ne(ee, ie, Y);
968
+ if (V.mode === "preview") {
969
+ if (S?.type === "curve") return void oe(Pi(S, ie, Y, !0));
970
+ if (S?.type === "polygon") return void oe(ki(S, ie, Y, !0));
971
+ }
972
+ const ye = Qt(ie, Y);
973
+ if (lt(m) || F(m, ee, ie, ye), S === void 0 || S.locked) k({ mode: "default", outOfView: !ye });
974
+ else if (V.mode === "default" || V.mode === "textedition") {
975
+ if (!ye) return void k({ mode: "default" });
976
+ k(ht(S, ie, Y, !0) || { mode: "default" });
977
+ } else {
978
+ const we = y.current?.getContext("2d");
979
+ if (!we) return;
980
+ A(ra(we, S, ie, V, Y, K, G));
981
+ }
982
+ })(L, t, c, a, h, Z, n, w, l, d, b, M, v, u), q(() => {
983
+ if (r) {
984
+ const L = (m) => P.current?.(m);
985
+ return document.addEventListener("mousemove", L), document.addEventListener("touchmove", L), () => {
986
+ document.removeEventListener("mousemove", L), document.removeEventListener("touchmove", L);
987
+ };
988
+ }
989
+ }, [r]);
990
+ const { isBrushShapeDoneOnMouseUp: W } = b, N = j(null);
991
+ N.current = (L) => {
992
+ if (!(lt(L) && L.touches.length > 1)) {
993
+ if ("button" in L && L.button === 2) return u(void 0), i(Ae), x({ mode: "default" }), void g(void 0);
994
+ if (h) f(void 0);
995
+ else if (a.mode !== "textedition" && a.mode !== "preview") return a.mode !== "resize" || !a.isCreating || c?.type !== "polygon" && c?.type !== "curve" ? void (a.mode !== "default" && (a.mode === "brush" && W && u(void 0), x({ mode: "default" }), g(void 0), C())) : (x({ mode: "preview" }), void C());
996
+ }
997
+ }, q(() => {
998
+ if (r) {
999
+ const L = (m) => N.current?.(m);
1000
+ return document.addEventListener("mouseup", L), document.addEventListener("touchend", L), () => {
1001
+ document.removeEventListener("mouseup", L), document.removeEventListener("touchend", L);
1002
+ };
1003
+ }
1004
+ }, [r]);
1005
+ const z = !b.features.edition && b.features.zoom, B = !b.features.edition && !b.features.zoom, U = j(null);
1006
+ return U.current = (L, m) => {
1007
+ if (L.preventDefault(), lt(L) && L.touches.length > 1) return;
1008
+ const y = m?.getContext("2d");
832
1009
  if (!y) return;
833
- const N = y.getContext("2d");
834
- if (!N || e) return;
835
- const M = (A) => {
836
- A.preventDefault();
837
- const Z = Pt(A, c.current, k);
838
- if (o.type === "selection") {
839
- const { shape: v, mode: m } = j1(N, a, Z, k, d, hi(A), E);
840
- f(v), b(m), m.mode === "selectionFrame" && x([[Z[0], Z[1]], [Z[0], Z[1]]]);
841
- } else if (o.type === "move") w(Z);
842
- else if (n1.some((v) => v === o.type)) {
843
- const v = t.current?.getContext("2d");
844
- if (!v) return;
845
- if (o.type === "brush") {
846
- if (d?.type === "brush") {
847
- const m = ((S, W, z) => {
848
- const O = { ...S, points: de(S.points.length, [[Math.round(W[0]), Math.round(W[1])]], S.points) };
849
- return Je(O, z);
850
- })(d, Z, k);
851
- Q(m);
1010
+ const S = mt(L, t.current, b), V = "button" in L && L.button === 1;
1011
+ if (!("button" in L && L.button === 2)) {
1012
+ if (V || o.type === "move") f({ start: S, originalOffset: b.canvasOffset });
1013
+ else if (!z) {
1014
+ if (!Qt(S, b)) return u(void 0), void x({ mode: "default" });
1015
+ if (o.type === "selection") {
1016
+ const { shape: T, mode: k } = Za(y, s, S, b, c, lt(L), Q);
1017
+ u(T), x(k), k.mode === "selectionFrame" && g([[S[0], S[1]], [S[0], S[1]]]);
1018
+ } else if (Cn.some((T) => T === o.type)) {
1019
+ const T = t.current?.getContext("2d");
1020
+ if (!T) return;
1021
+ if (o.type === "brush") {
1022
+ if (c?.type === "brush") {
1023
+ const k = ((F, A, te) => {
1024
+ const ne = { ...F, points: me(F.points.length, [[Math.round(A[0]), Math.round(A[1])]], F.points) };
1025
+ return it(ne, te);
1026
+ })(c, S, b);
1027
+ w(k);
1028
+ } else {
1029
+ const k = Ti(T, o, S, b);
1030
+ if (!k) return;
1031
+ e(k), u(k);
1032
+ }
1033
+ x({ mode: "brush" });
1034
+ } else if (a.mode !== "preview" || c?.type !== "polygon" && c?.type !== "curve") {
1035
+ if (o.type !== "picture") {
1036
+ const k = Ti(T, o, S, b);
1037
+ e(k), o.type !== "polygon" && o.type !== "curve" && i(Ae), u(k), x({ mode: "resize", isCreating: !0, cursorStartPosition: [S[0] + b.selectionPadding, S[1] + b.selectionPadding], originalShape: k, anchor: k.type === "line" ? 0 : k.type === "polygon" || k.type === "curve" ? k.points.length - 1 : [1, 1] });
1038
+ }
852
1039
  } else {
853
- const m = yi(v, o, Z, k);
854
- if (!m) return;
855
- i(m), f(m);
1040
+ const k = c?.type === "polygon" ? ki(c, S, b) : Pi(c, S, b);
1041
+ u(k), w(k, !0);
856
1042
  }
857
- b({ mode: "brush" });
858
- } else if (o.type !== "picture") {
859
- const m = yi(v, o, Z, k);
860
- i(m), n(Ae), f(m), b({ mode: "resize", cursorStartPosition: [Z[0] + k.selectionPadding, Z[1] + k.selectionPadding], originalShape: m, anchor: o.type === "line" || o.type === "polygon" || o.type === "curve" ? 0 : [1, 1] });
861
1043
  }
862
1044
  }
1045
+ }
1046
+ }, q(() => {
1047
+ if (B) return;
1048
+ const L = t.current;
1049
+ if (!L) return;
1050
+ const m = (y) => U.current?.(y, L);
1051
+ return L.addEventListener("mousedown", m, { passive: !1 }), L.addEventListener("touchstart", m, { passive: !1 }), () => {
1052
+ L.removeEventListener("mousedown", m), L.removeEventListener("touchstart", m);
863
1053
  };
864
- return y.addEventListener("mousedown", M, { passive: !1 }), y.addEventListener("touchstart", M, { passive: !1 }), () => {
865
- y.removeEventListener("mousedown", M), y.removeEventListener("touchstart", M);
866
- };
867
- }, [e, c, t, d, o, w, a, Q, i, n, f, b, x, k, E]), G(() => {
868
- const y = c.current;
869
- if (y)
870
- return l ? (C(y, (N) => {
871
- if (o.type === "selection" && d?.type === "text") {
872
- const M = Pt(N, c.current, k);
873
- st(d, M, k) && b({ mode: "textedition", defaultValue: d.value });
1054
+ }, [B, t]), q(() => {
1055
+ const L = t.current, m = t.current?.getContext("2d");
1056
+ if (!(!L || !m))
1057
+ return r ? (E(L, (y) => {
1058
+ if (o.type === "selection") {
1059
+ if (c?.type === "text") {
1060
+ const S = mt(y, t.current, b);
1061
+ return Qt(S, b) ? void (ht(c, S, b) && x({ mode: "textedition", defaultValue: c.value })) : void 0;
1062
+ }
1063
+ if (c?.type === "polygon" || c?.type === "curve") {
1064
+ const S = mt(y, t.current, b);
1065
+ if (!Qt(S, b)) return;
1066
+ const V = ((T, k, F, A, te = 50) => {
1067
+ if (k.locked || k.points.length < 2) return !1;
1068
+ const { center: ne } = J(k, A), Y = He(F, k.rotation, ne);
1069
+ T.lineWidth = (k.style?.lineWidth ?? 0) + te / A.canvasZoom;
1070
+ for (let K = 0; K < k.points.length; K++) {
1071
+ if (K === k.points.length - 1) {
1072
+ if (!k.style?.closedPoints) return !1;
1073
+ const oe = dt({ points: [k.points[K], k.points[0]] });
1074
+ if (T.isPointInStroke(oe, Y[0], Y[1])) return { lineIndex: K };
1075
+ }
1076
+ const G = dt({ points: [k.points[K], k.points[K + 1]] });
1077
+ if (T.isPointInStroke(G, Y[0], Y[1])) return { lineIndex: K };
1078
+ }
1079
+ return !1;
1080
+ })(m, c, S, b);
1081
+ return void (V && w(c?.type === "polygon" ? Nn(c, V.lineIndex, b) : Rn(c, V.lineIndex, b)));
1082
+ }
874
1083
  }
875
1084
  }), () => {
876
- V(y);
1085
+ D(L);
877
1086
  }) : void 0;
878
- }, [C, V, l, c, o, d, b, k]), { hoverMode: H };
879
- }, f1 = (e) => e.childNodes.length ? Array.from(e.childNodes).map((i) => f1(i)).join("") : e.nodeValue ?? "", q1 = ({ disabled: e = !1, scaleRatio: i, shape: t, defaultValue: n, updateValue: s, saveShapes: a, settings: r }) => {
880
- const o = J(null), l = J(a);
881
- G(() => {
1087
+ }, [w, E, D, r, t, o, c, x, b]), { hoverMode: H };
1088
+ }, Bn = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => Bn(t)).join("") : e.nodeValue ?? "", za = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: n, saveShapes: s, settings: a }) => {
1089
+ const o = j(null), r = j(s);
1090
+ q(() => {
882
1091
  if (!o.current) return;
883
- const d = o.current, c = (u) => {
884
- u.preventDefault();
885
- const g = u.clipboardData?.getData("text/plain");
886
- document.execCommand("insertText", !1, g);
1092
+ const c = o.current, h = (d) => {
1093
+ d.preventDefault();
1094
+ const u = d.clipboardData?.getData("text/plain");
1095
+ document.execCommand("insertText", !1, u);
887
1096
  };
888
- d.addEventListener("paste", c), d.innerText = "";
889
- for (const u of n) {
890
- const g = document.createElement("div");
891
- u === "" ? g.innerHTML = "<br/>" : g.innerText = u, d.appendChild(g);
1097
+ c.addEventListener("paste", h), c.innerText = "";
1098
+ for (const d of i) {
1099
+ const u = document.createElement("div");
1100
+ d === "" ? u.innerHTML = "<br/>" : u.innerText = d, c.appendChild(u);
892
1101
  }
893
- return d.focus(), () => {
894
- d.removeEventListener("paste", c);
1102
+ return c.focus(), () => {
1103
+ c.removeEventListener("paste", h);
895
1104
  };
896
- }, [n]), G(() => {
897
- const d = l.current;
1105
+ }, [i]), q(() => {
1106
+ const c = r.current;
898
1107
  return () => {
899
- d();
1108
+ c();
900
1109
  };
901
1110
  }, []);
902
- const h = Ni(() => {
903
- const { borders: d, center: c } = q(t, r);
904
- return ve({ point: [d.x, d.y], rotation: -t.rotation, origin: c });
905
- }, [t, r]);
906
- return p("div", { className: "react-paint-editor-toolbox-edittextbox", ref: o, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (d) => {
907
- const c = Array.from(d.target.childNodes).map((u) => f1(u));
908
- s(c);
909
- }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${h[0] * i}px, ${h[1] * i}px, 0) rotate(${Ft(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * i + "px", "--react-paint-editor-toolbox-edittextbox-padding": r.selectionPadding * i + "px", "--react-paint-editor-toolbox-edittextbox-color": t.style?.strokeColor ?? "inherit", "--react-paint-editor-toolbox-edittextbox-opacity": (t.style?.opacity ?? 100) / 100, "--react-paint-editor-toolbox-edittextbox-fontfamily": t.style?.fontFamily ?? rt } });
910
- }, J1 = (e, i, t, n, s) => {
911
- const { canvasSize: { width: a, height: r } } = t;
912
- e.clearRect(0, 0, a, r), l1(e), t.gridGap && ((o, l, h, d) => {
913
- const { gridGap: c, canvasOffset: u, canvasSize: { scaleRatio: g } } = d;
914
- o.strokeStyle = "rgb(220,220,220)", o.lineWidth = 1, o.save(), o.scale(g, g), o.beginPath();
915
- const f = -u[0] % c, x = -u[1] % c, w = Math.ceil(l / g / c), Q = Math.ceil(h / g / c);
916
- for (let L = 0; L < w; L++) o.moveTo(f + (L + 1) * c, x), o.lineTo(f + (L + 1) * c, x + h / g);
917
- for (let L = 0; L < Q; L++) o.moveTo(f, x + (L + 1) * c), o.lineTo(f + l / g, x + (L + 1) * c);
918
- o.stroke(), o.restore();
919
- })(e, a, r, t);
920
- for (let o = n.length - 1; o >= 0; o--) i.mode === "textedition" && n[o] === s || p1(e, n[o], t);
921
- }, K1 = Fi.forwardRef(({ canGrow: e, disabled: i = !1, canvasSize: t, shapes: n, addShape: s, updateSingleShape: a, selectedShape: r, setSelectedShape: o, setSelectionFrame: l, hoveredShape: h, selectionFrame: d, refreshHoveredShape: c, refreshSelectedShapes: u, saveShapes: g, activeTool: f, setActiveTool: x, canvasOffsetStartPosition: w, setCanvasOffsetStartPosition: Q, setCanvasOffset: L, isInsideComponent: b, selectionMode: k, setSelectionMode: P, selectionWidth: E, selectionColor: H, settings: T, isEditMode: C, isShiftPressed: V, withFrameSelection: I, withSkeleton: y }, N) => {
922
- const M = J(null), A = J(null);
923
- S1(N, () => M.current);
924
- const { hoverMode: Z } = _1({ disabled: i, addShape: s, drawCanvasRef: M, setActiveTool: x, shapes: n, selectionMode: k, activeTool: f, isInsideComponent: b, setCanvasOffset: L, selectedShape: r, selectionCanvasRef: A, canvasOffsetStartPosition: w, setSelectedShape: o, setSelectionFrame: l, refreshHoveredShape: c, refreshSelectedShapes: u, setCanvasOffsetStartPosition: Q, updateSingleShape: a, saveShapes: g, setSelectionMode: P, isShiftPressed: V, withFrameSelection: I, settings: T }), v = F((m) => {
925
- if (r?.type !== "text") return;
926
- const S = M.current?.getContext("2d");
927
- if (!S) return;
928
- const W = ot(W1(S, r, m, T), T);
929
- a(W);
930
- }, [a, r, T]);
931
- return G(() => {
932
- const m = M.current?.getContext("2d");
933
- m && window.requestAnimationFrame(() => J1(m, k, T, n, r));
934
- }, [n, k, r, T]), G(() => {
935
- const m = A.current?.getContext("2d");
936
- m && window.requestAnimationFrame(() => ((S, W, z, O, X, D, U, le, te, ie) => {
937
- S.clearRect(0, 0, z.canvasSize.width, z.canvasSize.height), ie && le && le.id !== U?.id && O.type === "selection" && W.mode === "default" && Qi({ ctx: S, shape: le, settings: z, selectionWidth: X, selectionColor: D, withAnchors: !1 }), U && O.type !== "brush" && Qi({ ctx: S, shape: U, settings: z, selectionWidth: X, selectionColor: D, withAnchors: W.mode !== "textedition" }), te && U1({ ctx: S, selectionFrame: te, settings: z });
938
- })(m, k, T, f, E, H, r, h, d, y));
939
- }, [h, d, k, r, f, T, E, H, y]), p("div", { className: "react-paint-canvas-box", children: R("div", { className: "react-paint-canvas-container", "data-grow": e, children: [p("canvas", { className: a1, ref: M, "data-grow": e, width: t.width, height: t.height }), C && p("canvas", { className: s1, ref: A, width: t.width, height: t.height, "data-grow": e, style: { "--react-paint-canvas-cursor": f.type !== "selection" && f.type !== "move" || Z.mode === "resize" ? "crosshair" : f.type === "move" || Z.mode === "translate" ? "move" : Z.mode === "rotate" ? "grab" : "default" } }), C && k.mode === "textedition" && r?.type === "text" && p(q1, { scaleRatio: t.scaleRatio, disabled: i, shape: r, defaultValue: k.defaultValue, updateValue: v, saveShapes: g, settings: T })] }) });
940
- }), xi = "ArrowUp", Mi = "ArrowDown", ki = "ArrowLeft", Li = "ArrowRight", en = "Delete", tn = "Backspace", nn = "Escape", Vi = "Shift", an = "z", sn = "Z", on = "y", rn = "Y", Pi = "copy", Hi = "paste", ln = ({ isInsideComponent: e, selectedShape: i, isEditingText: t, settings: n, setSelectedShape: s, removeShape: a, pasteShape: r, updateShape: o, backwardShape: l, forwardShape: h, setShiftPressed: d }) => {
941
- const [c, u] = $(void 0);
942
- return G(() => {
943
- const g = (Q) => {
944
- i && (t || (Q.preventDefault(), u({ ...i })));
945
- }, f = (Q) => {
946
- c && (t || (Q.preventDefault(), r(((L, b) => ({ ...Nt([20, 20], L, [0, 0], b), id: re(`${L.type}_`) }))(c, n))));
947
- }, x = (Q) => {
948
- Q.key === Vi && d(!1);
949
- }, w = (Q) => {
1111
+ const l = tn(() => {
1112
+ const { borders: c, center: h } = J(t, a);
1113
+ return be({ point: [c.x, c.y], rotation: -t.rotation, origin: h });
1114
+ }, [t, a]);
1115
+ return p("div", { className: "react-paint-editor-toolbox-edittextbox", ref: o, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: !e, onInput: (c) => {
1116
+ const h = Array.from(c.target.childNodes).map((d) => Bn(d));
1117
+ n(h);
1118
+ }, style: { "--react-paint-editor-toolbox-edittextbox-transform": `translate3D(${(l[0] + a.canvasOffset[0]) * a.canvasSize.scaleRatio}px, ${(l[1] + a.canvasOffset[1]) * a.canvasSize.scaleRatio}px, 0) rotate(${qt(t.rotation)}deg)`, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * a.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-padding": a.selectionPadding * a.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-color": t.style?.strokeColor ?? "inherit", "--react-paint-editor-toolbox-edittextbox-opacity": (t.style?.opacity ?? 100) / 100, "--react-paint-editor-toolbox-edittextbox-fontfamily": t.style?.fontFamily ?? ut } });
1119
+ }, Aa = (e, t, i, n, s) => {
1120
+ Vn(e), ((a, o) => {
1121
+ const { canvasZoom: r, size: l, canvasSize: { width: c, height: h } } = o;
1122
+ if (l !== "fixed" || r >= 1) return;
1123
+ a.fillStyle = "#f5f5f5", a.fillRect(0, 0, c, h);
1124
+ const d = En(o);
1125
+ a.clearRect(d.x, d.y, d.width, d.height), Dn(a, o);
1126
+ })(e, i), ((a, o) => {
1127
+ const { canvasSize: { width: r, height: l }, gridGap: c, canvasOffset: h, canvasSize: { scaleRatio: d } } = o;
1128
+ if (!c) return;
1129
+ a.strokeStyle = "rgb(220,220,220)", a.lineWidth = 1, a.save(), a.scale(d, d), a.beginPath();
1130
+ const u = h[0] % c, g = h[1] % c, f = Math.ceil(r / d / c) + 2, w = Math.ceil(l / d / c) + 2;
1131
+ for (let C = -5; C < f; C++) a.moveTo(u + (C + 1) * c, g - c), a.lineTo(u + (C + 1) * c, g + l / d + c);
1132
+ for (let C = -5; C < w; C++) a.moveTo(u - c, g + (C + 1) * c), a.lineTo(u + r / d + c, g + (C + 1) * c);
1133
+ a.stroke(), a.restore();
1134
+ })(e, i);
1135
+ for (let a = n.length - 1; a >= 0; a--) t.mode === "textedition" && n[a] === s || On(e, n[a].id === s?.id ? s : n[a], i);
1136
+ }, Ea = en.forwardRef(({ canGrow: e, shapes: t, addShape: i, updateSingleShape: n, selectedShape: s, setSelectedShape: a, setSelectionFrame: o, hoveredShape: r, selectionFrame: l, refreshHoveredShape: c, refreshSelectedShapes: h, saveShapes: d, activeTool: u, setActiveTool: g, canvasOffsetStartData: f, setCanvasOffsetStartData: w, setCanvasOffset: C, isInsideComponent: x, selectionMode: b, setSelectionMode: M, selectionWidth: v, selectionColor: Q, settings: H, isEditMode: Z, isShiftPressed: E, isAltPressed: D, withFrameSelection: P, withSkeleton: W }, N) => {
1137
+ const z = j(null), B = j(null), U = H.canvasSize, L = Z;
1138
+ ea(N, () => z.current);
1139
+ const { hoverMode: m } = Ta({ addShape: i, drawCanvasRef: z, setActiveTool: g, shapes: t, selectionMode: b, activeTool: u, isInsideComponent: x, setCanvasOffset: C, selectedShape: s, canvasOffsetStartData: f, setCanvasOffsetStartData: w, setSelectedShape: a, setSelectionFrame: o, refreshHoveredShape: c, refreshSelectedShapes: h, updateSingleShape: n, saveShapes: d, setSelectionMode: M, isShiftPressed: E, isAltPressed: D, withFrameSelection: P, settings: H }), y = R((V) => {
1140
+ if (s?.type !== "text") return;
1141
+ const T = z.current?.getContext("2d");
1142
+ if (!T) return;
1143
+ const k = et(Sa(T, s, V, H), H);
1144
+ n(k);
1145
+ }, [n, s, H]), S = (V) => {
1146
+ if (Z) return V.preventDefault(), V.stopPropagation(), !1;
1147
+ };
1148
+ return q(() => {
1149
+ const V = z.current?.getContext("2d");
1150
+ V && window.requestAnimationFrame(() => Aa(V, b, H, t, s));
1151
+ }, [t, b, s, H]), q(() => {
1152
+ const V = B.current?.getContext("2d");
1153
+ V && window.requestAnimationFrame(() => ((T, k, F, A, te, ne, Y, K, G, oe) => {
1154
+ T.reset(), Dn(T, F), oe && K && K.id !== Y?.id && A.type === "selection" && k.mode === "default" && zi({ ctx: T, shape: K, settings: F, selectionWidth: te, selectionColor: ne, withAnchors: !1 }), Y && A.type !== "brush" && zi({ ctx: T, shape: Y, settings: F, selectionWidth: te, selectionColor: ne, withAnchors: k.mode !== "textedition" }), G && xa({ ctx: T, selectionFrame: G, settings: F });
1155
+ })(V, b, H, u, v, Q, s, r, l, W));
1156
+ }, [r, l, b, s, u, H, v, Q, W]), p("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": f ? "grabbing" : m.outOfView ? "default" : u.type !== "selection" && u.type !== "move" || m.mode === "resize" ? "crosshair" : m.mode === "translate" ? "move" : m.mode === "rotate" || u.type === "move" ? "grab" : "default" }, children: O("div", { className: "react-paint-canvas-container", "data-grow": e, children: [p("canvas", { className: xn, ref: z, "data-grow": e, width: U.width, height: U.height, onContextMenu: S }), L && p("canvas", { className: Mn, ref: B, width: U.width, height: U.height, "data-grow": e, onContextMenu: S }), Z && b.mode === "textedition" && s?.type === "text" && p(za, { disabled: !H.features.edition, shape: s, defaultValue: b.defaultValue, updateValue: y, saveShapes: d, settings: H })] }) });
1157
+ }), Ri = "ArrowUp", Oi = "ArrowDown", Ii = "ArrowLeft", Fi = "ArrowRight", Da = "Delete", Wa = "Backspace", Na = "Escape", $i = "Shift", Bi = "Alt", Ui = "Option", Ra = "z", Oa = "Z", Ia = "y", Fa = "Y", Xi = "copy", Yi = "paste", $a = ({ isInsideComponent: e, selectedShape: t, isEditingText: i, settings: n, setSelectedShape: s, setActiveTool: a, setSelectionMode: o, setSelectionFrame: r, removeShape: l, pasteShape: c, updateShape: h, backwardShape: d, forwardShape: u, setShiftPressed: g, setAltPressed: f }) => {
1158
+ const [w, C] = I(void 0);
1159
+ return q(() => {
1160
+ const x = (Q) => {
1161
+ t && (i || (Q.preventDefault(), C({ ...t })));
1162
+ }, b = (Q) => {
1163
+ w && (i || (Q.preventDefault(), c(((H, Z) => ({ ...jt([20, 20], H, [0, 0], Z, !1), id: ce(`${H.type}_`) }))(w, n))));
1164
+ }, M = (Q) => {
1165
+ switch (Q.key) {
1166
+ case $i:
1167
+ g(!1);
1168
+ break;
1169
+ case Bi:
1170
+ case Ui:
1171
+ f(!1);
1172
+ }
1173
+ }, v = (Q) => {
950
1174
  if (Q.metaKey || Q.ctrlKey) {
951
- if (Q.key === sn || Q.key === an) return Q.preventDefault(), Q.stopPropagation(), void l();
952
- if (Q.key === rn || Q.key === on) return Q.preventDefault(), Q.stopPropagation(), void h();
1175
+ if (Q.key === Oa || Q.key === Ra) return Q.preventDefault(), Q.stopPropagation(), void (Q.shiftKey ? u() : d());
1176
+ if (!Ln() && (Q.key === Fa || Q.key === Ia)) return Q.preventDefault(), Q.stopPropagation(), void u();
953
1177
  }
954
- if (Q.key === Vi) return void d(!0);
955
- if (!i) return;
956
- if (Q.key === nn) return void s(void 0);
957
- if (t) return;
958
- const L = { [ki]: [n.gridGap ? -n.gridGap : -1, 0], [Li]: [n.gridGap ? n.gridGap : 1, 0], [Mi]: [0, n.gridGap ? n.gridGap : 1], [xi]: [0, n.gridGap ? -n.gridGap : -1] };
1178
+ if (Q.key === $i) return Q.preventDefault(), Q.stopPropagation(), void g(!0);
1179
+ if (Q.key === Bi || Q.key === Ui) return Q.preventDefault(), Q.stopPropagation(), void f(!0);
1180
+ if (!t) return;
1181
+ if (Q.key === Na) return s(void 0), a(Ae), o({ mode: "default" }), void r(void 0);
1182
+ if (i) return;
1183
+ const H = { [Ii]: [n.gridGap ? -n.gridGap : -1, 0], [Fi]: [n.gridGap ? n.gridGap : 1, 0], [Oi]: [0, n.gridGap ? n.gridGap : 1], [Ri]: [0, n.gridGap ? -n.gridGap : -1] };
959
1184
  switch (Q.key) {
960
- case ki:
961
- case Li:
962
- case Mi:
963
- case xi:
964
- Q.preventDefault(), Q.stopPropagation(), o(Nt(L[Q.key], i, [0, 0], n));
1185
+ case Ii:
1186
+ case Fi:
1187
+ case Oi:
1188
+ case Ri:
1189
+ Q.preventDefault(), Q.stopPropagation(), h(jt(H[Q.key], t, [0, 0], n, !1));
965
1190
  break;
966
- case en:
967
- case tn:
968
- Q.preventDefault(), Q.stopPropagation(), a(i);
1191
+ case Da:
1192
+ case Wa:
1193
+ Q.preventDefault(), Q.stopPropagation(), l(t);
969
1194
  }
970
1195
  };
971
- if (e) return document.addEventListener("keydown", w), document.addEventListener("keyup", x), document.addEventListener(Pi, g), document.addEventListener(Hi, f), () => {
972
- document.removeEventListener("keydown", w), document.removeEventListener("keyup", x), document.removeEventListener(Pi, g), document.removeEventListener(Hi, f);
1196
+ if (e) return document.addEventListener("keydown", v), document.addEventListener("keyup", M), document.addEventListener(Xi, x), document.addEventListener(Yi, b), () => {
1197
+ document.removeEventListener("keydown", v), document.removeEventListener("keyup", M), document.removeEventListener(Xi, x), document.removeEventListener(Yi, b);
973
1198
  };
974
- }, [e, c, t, i, n, o, a, s, r, l, h, d]), {};
975
- }, Zn = ({ options: e, className: i, style: t, canvasProps: n }) => {
976
- const { shapesRef: s, selectedShape: a, selectionFrame: r, hoveredShape: o, addShape: l, setSelectedShape: h, setSelectionFrame: d, refreshSelectedShapes: c, refreshHoveredShape: u, removeShape: g, updateShape: f, backwardShape: x, forwardShape: w, saveShapes: Q, refs: L, width: b, height: k, settings: P, canvasSize: E, setCanvasSize: H, setCanvasOffset: T, selectShape: C, activeTool: V, setActiveTool: I, isInsideComponent: y, isEditMode: N, isDisabled: M, canvas: { withSkeleton: A, withFrameSelection: Z, canGrow: v, canShrink: m } } = n, { canvasBackgroundColor: S, canvasSelectionColor: W, canvasSelectionWidth: z } = { ...w1, ...e }, O = J(null), [X, D] = $(void 0), [U, le] = $({ mode: "default" }), [te, ie] = $(!1), fe = F((ne) => {
977
- l(ne), C(ne);
978
- }, [l, C]), Me = F((ne) => {
979
- const _ = ne / b;
980
- H({ width: ne, height: k * _, scaleRatio: _ });
981
- }, [b, k, H]);
982
- return ln({ isInsideComponent: y, isEditingText: U.mode === "textedition", settings: P, selectedShape: a, setSelectedShape: h, removeShape: g, pasteShape: fe, updateShape: f, backwardShape: x, forwardShape: w, setShiftPressed: ie }), (({ onResized: ne, element: _ }) => {
983
- G(() => {
984
- const Se = _.current;
985
- if (!Se) return;
986
- const Ze = new ResizeObserver((ke) => {
987
- const me = ke?.[0]?.borderBoxSize?.[0], { width: be, height: Ee } = me ? { width: me.inlineSize, height: me.blockSize } : ke?.[0].contentRect ?? {};
988
- ne(be, Ee);
1199
+ }, [e, w, i, t, n, h, l, s, c, d, u, g, f, a, o, r]), {};
1200
+ }, ys = ({ options: e, className: t, style: i, canvasProps: n }) => {
1201
+ const { shapesRef: s, selectedShape: a, selectionFrame: o, hoveredShape: r, addShape: l, setSelectedShape: c, setSelectionFrame: h, refreshSelectedShapes: d, refreshHoveredShape: u, removeShape: g, updateShape: f, backwardShape: w, forwardShape: C, saveShapes: x, refs: b, width: M, height: v, settings: Q, setCanvasSize: H, setCanvasOffset: Z, selectShape: E, activeTool: D, setActiveTool: P, isInsideComponent: W, isEditMode: N, canvas: { withSkeleton: z, withFrameSelection: B, canGrow: U, canShrink: L }, canvasOffsetStartData: m, setCanvasOffsetStartData: y, selectionMode: S, setSelectionMode: V } = n, { canvasBackgroundColor: T, canvasSelectionColor: k, canvasSelectionWidth: F } = { ...na, ...e }, A = j(null), [te, ne] = I(!1), [Y, K] = I(!1), G = R((ee) => {
1202
+ l(ee), E(ee);
1203
+ }, [l, E]), oe = R((ee) => {
1204
+ H({ realWidth: M, realHeight: v, width: ee, height: v * ee / M, scaleRatio: ee / M });
1205
+ }, [M, v, H]);
1206
+ return $a({ isInsideComponent: W, isEditingText: S.mode === "textedition", settings: Q, selectedShape: a, setSelectedShape: c, removeShape: g, pasteShape: G, updateShape: f, backwardShape: w, forwardShape: C, setShiftPressed: ne, setAltPressed: K, setActiveTool: P, setSelectionMode: V, setSelectionFrame: h }), (({ onResized: ee, element: ie }) => {
1207
+ q(() => {
1208
+ const ye = ie.current;
1209
+ if (!ye) return;
1210
+ const we = new ResizeObserver((se) => {
1211
+ const Qe = se?.[0]?.borderBoxSize?.[0], { width: Ee, height: De } = Qe ? { width: Qe.inlineSize, height: Qe.blockSize } : se?.[0].contentRect ?? {};
1212
+ ee(Ee, De);
989
1213
  });
990
- return Ze.observe(Se), () => {
991
- Ze.unobserve(Se);
1214
+ return we.observe(ye), () => {
1215
+ we.unobserve(ye);
992
1216
  };
993
- }, [_, ne]);
994
- })({ element: O, onResized: Me }), p("div", { ref: O, className: "react-paint-app-row" + (i ? ` ${i}` : ""), "data-grow": v, "data-shrink": m, style: { "--react-paint-app-row-width": E.width, "--react-paint-app-canvaswidth": `${b}px`, "--react-paint-app-row-aspectratio": `calc(${E.width} / ${E.height})`, "--react-paint-app-canvas-bg": S, ...t }, children: p(K1, { ref: L.canvas, canGrow: v, disabled: M, isInsideComponent: y, activeTool: V, setActiveTool: I, canvasOffsetStartPosition: X, setCanvasOffsetStartPosition: D, shapes: s.current, addShape: l, updateSingleShape: f, selectedShape: a, selectionFrame: r, setSelectedShape: h, setSelectionFrame: d, hoveredShape: o, refreshHoveredShape: u, refreshSelectedShapes: c, settings: P, setCanvasOffset: T, saveShapes: Q, canvasSize: E, selectionMode: U, setSelectionMode: le, selectionColor: W, selectionWidth: z, isEditMode: N, isShiftPressed: te, withFrameSelection: Z, withSkeleton: A }) });
995
- }, dn = ({ isLoading: e = !1 }) => {
996
- const [i, t] = $("hidden");
997
- return G(() => {
1217
+ }, [ie, ee]);
1218
+ })({ element: A, onResized: oe }), p("div", { ref: A, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": U, "data-shrink": L, style: { "--react-paint-app-row-width": Q.canvasSize.width, "--react-paint-app-canvaswidth": M, "--react-paint-app-canvasheight": v, "--react-paint-app-row-aspectratio": `calc(${Q.canvasSize.width} / ${Q.canvasSize.height})`, "--react-paint-app-canvas-bg": T, ...i }, children: p(Ea, { ref: b.canvas, canGrow: U, isInsideComponent: W, activeTool: D, setActiveTool: P, canvasOffsetStartData: m, setCanvasOffsetStartData: y, shapes: s.current, addShape: l, updateSingleShape: f, selectedShape: a, selectionFrame: o, setSelectedShape: c, setSelectionFrame: h, hoveredShape: r, refreshHoveredShape: u, refreshSelectedShapes: d, settings: Q, setCanvasOffset: Z, saveShapes: x, selectionMode: S, setSelectionMode: V, selectionColor: k, selectionWidth: F, isEditMode: N, isShiftPressed: te, isAltPressed: Y, withFrameSelection: B, withSkeleton: z }) });
1219
+ }, Ba = ({ isLoading: e = !1 }) => {
1220
+ const [t, i] = I("hidden");
1221
+ return q(() => {
998
1222
  if (!e) {
999
- t("fadeOut");
1000
- const n = setTimeout(() => t("hidden"), 300);
1223
+ i("fadeOut");
1224
+ const n = setTimeout(() => i("hidden"), 300);
1001
1225
  return () => {
1002
1226
  clearTimeout(n);
1003
1227
  };
1004
1228
  }
1005
- t("visible");
1006
- }, [e]), i === "hidden" ? null : p("div", { className: "react-paint-editor-loading", "data-loading": i, style: { "--react-paint-editor-loading-zindex": b1, "--react-paint-editor-loading-transition-duration": "300ms" }, children: R("div", { className: "react-paint-editor-loader", children: [p("div", {}), p("div", {}), p("div", {}), p("div", {})] }) });
1007
- }, cn = "infos", hn = 4e3, pn = ({ type: e, text: i, duration: t }) => {
1008
- const [n, s] = $(!1);
1009
- return G(() => {
1229
+ i("visible");
1230
+ }, [e]), t === "hidden" ? null : p("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": ta, "--react-paint-editor-loading-transition-duration": "300ms" }, children: O("div", { className: "react-paint-editor-loader", children: [p("div", {}), p("div", {}), p("div", {}), p("div", {})] }) });
1231
+ }, Ua = "infos", Xa = 4e3, Ya = ({ type: e, text: t, duration: i }) => {
1232
+ const [n, s] = I(!1);
1233
+ return q(() => {
1010
1234
  const a = setTimeout(() => {
1011
1235
  s(!0);
1012
- }, 100), r = setTimeout(() => {
1236
+ }, 100), o = setTimeout(() => {
1013
1237
  s(!1);
1014
- }, t - 500 - 100);
1238
+ }, i - 500 - 100);
1015
1239
  return () => {
1016
- clearTimeout(a), clearTimeout(r);
1240
+ clearTimeout(a), clearTimeout(o);
1017
1241
  };
1018
- }, [t]), p("div", { className: "react-paint-editor-snackbar", "data-is-shown": +n, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: i });
1019
- }, un = ({ snackbarList: e }) => p("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": C1 }, children: e.map((i) => p(pn, { ...i }, i.id)) }), Y = Fi.forwardRef((e, i) => {
1242
+ }, [i]), p("div", { className: "react-paint-editor-snackbar", "data-is-shown": +n, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: t });
1243
+ }, qa = ({ snackbarList: e }) => p("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": ia }, children: e.map((t) => p(Ya, { ...t }, t.id)) }), X = en.forwardRef((e, t) => {
1020
1244
  if (e.type === "file" || e.type === "color") {
1021
- const { hidden: d = !1, disabled: c = !1, selected: u = !1, icon: g, children: f, className: x = "", title: w, onClick: Q, ...L } = e;
1022
- return R("label", { className: `react-paint-editor-button ${x}`, title: w, onClick: Q, "data-disabled": +c, "data-selected": +u, "data-hidden": +d, children: [p("input", { ref: i, disabled: c, ...L }), R("span", { className: "react-paint-editor-button-content", children: [f && p("span", { className: "react-paint-editor-button-children", children: f }), g && p("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: g } })] })] });
1245
+ const { hidden: h = !1, disabled: d = !1, selected: u = !1, icon: g, children: f, className: w = "", title: C, onClick: x, ...b } = e;
1246
+ return O("label", { className: `react-paint-editor-button ${w}`, title: C, onClick: x, "data-disabled": +d, "data-selected": +u, "data-hidden": +h, children: [p("input", { ref: t, disabled: d, ...b }), O("span", { className: "react-paint-editor-button-content", children: [f && p("span", { className: "react-paint-editor-button-children", children: f }), g && p("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: g } })] })] });
1023
1247
  }
1024
- const { hidden: t = !1, disabled: n = !1, selected: s = !1, icon: a, children: r, type: o = "button", className: l = "", ...h } = e;
1025
- return p("button", { className: `react-paint-editor-button ${l}`, ref: i, disabled: n, "data-disabled": +n, "data-selected": +s, "data-hidden": +t, type: o, ...h, children: R("span", { className: "react-paint-editor-button-content", children: [r && p("span", { className: "react-paint-editor-button-children", children: r }), a && p("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: a } })] }) });
1026
- }), et = ({ children: e, title: i = "", className: t = "", position: n = "bottom", fitContainer: s = !1, alignment: a = "center" }) => R("div", { className: `react-paint-editor-panel ${t}`, "data-fitcontainer": s, "data-position": n, "data-alignment": a, style: { "--react-paint-editor-panel-zindex": Ui }, children: [i && p("h3", { className: "react-paint-editor-panel-title", children: i }), e] }), gn = (e) => {
1248
+ const { hidden: i = !1, disabled: n = !1, selected: s = !1, icon: a, children: o, type: r = "button", className: l = "", ...c } = e;
1249
+ return p("button", { className: `react-paint-editor-button ${l}`, ref: t, disabled: n, "data-disabled": +n, "data-selected": +s, "data-hidden": +i, type: r, ...c, children: O("span", { className: "react-paint-editor-button-content", children: [o && p("span", { className: "react-paint-editor-button-children", children: o }), a && p("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: a } })] }) });
1250
+ }), qe = ({ children: e, title: t = "", className: i = "", position: n = "bottom", fitContainer: s = !1, alignment: a = "center", style: o, ...r }) => O("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": s, "data-position": n, "data-alignment": a, style: { ...o, "--react-paint-editor-panel-zindex": cn }, ...r, children: [t && p("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), Ga = (e) => {
1027
1251
  switch (e) {
1028
1252
  case "brush":
1029
- return Ii;
1253
+ return an;
1030
1254
  case "line":
1031
- return Oi;
1255
+ return rn;
1032
1256
  case "polygon":
1033
- return Wt;
1257
+ return ei;
1034
1258
  case "curve":
1035
- return $i;
1259
+ return ln;
1036
1260
  case "rect":
1037
1261
  case "square":
1038
- return Rt;
1262
+ return Kt;
1039
1263
  case "circle":
1040
1264
  case "ellipse":
1041
- return It;
1265
+ return Jt;
1042
1266
  case "text":
1043
- return zi;
1267
+ return on;
1044
1268
  case "picture":
1045
- return zt;
1269
+ return ti;
1046
1270
  case "triangle":
1047
1271
  return "";
1048
1272
  }
1049
- }, vn = ({ disabled: e = !1, shape: i, selected: t, layoutDragging: n, toggleShapeVisibility: s, toggleShapeLock: a, setLayoutDragging: r, handleRemove: o, handleSelect: l, onMoveShapes: h }) => {
1050
- const d = J(null), { isOver: c } = (({ disabled: u = !1, ref: g, shape: f, layoutDragging: x, setLayoutDragging: w, handleSelect: Q, onMoveShapes: L }) => {
1051
- const [b, k] = $(!1);
1052
- return G(() => {
1053
- x || k(!1);
1054
- }, [x]), G(() => {
1055
- const P = g.current;
1056
- if (!P) return;
1057
- const E = () => {
1058
- w(void 0);
1059
- }, H = (y) => (y.preventDefault && y.preventDefault(), !1), T = (y) => {
1060
- Q(f), y.dataTransfer && (y.dataTransfer.effectAllowed = "move", y.dataTransfer.setData("draggableShapeId", f.id), w(f.id));
1061
- }, C = () => {
1062
- x !== f.id && k(!0);
1063
- }, V = () => {
1064
- k(!1);
1065
- }, I = (y) => (y.stopPropagation(), y.dataTransfer && L(y.dataTransfer.getData("draggableShapeId"), f.id), !1);
1066
- return u || (P.addEventListener("dragstart", T), P.addEventListener("dragend", E), P.addEventListener("dragover", H), P.addEventListener("dragenter", C), P.addEventListener("dragleave", V), P.addEventListener("drop", I)), () => {
1067
- u || (P.removeEventListener("dragstart", T), P.removeEventListener("dragend", E), P.removeEventListener("dragover", H), P.removeEventListener("dragenter", C), P.removeEventListener("dragleave", V), P.removeEventListener("drop", I));
1273
+ }, _a = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: n, toggleShapeVisibility: s, toggleShapeLock: a, setLayoutDragging: o, handleRemove: r, handleSelect: l, onMoveShapes: c }) => {
1274
+ const h = j(null), { isOver: d } = (({ disabled: u = !1, ref: g, shape: f, layoutDragging: w, setLayoutDragging: C, handleSelect: x, onMoveShapes: b }) => {
1275
+ const [M, v] = I(!1);
1276
+ return q(() => {
1277
+ w || v(!1);
1278
+ }, [w]), q(() => {
1279
+ const Q = g.current;
1280
+ if (!Q) return;
1281
+ const H = () => {
1282
+ C(void 0);
1283
+ }, Z = (N) => (N.preventDefault && N.preventDefault(), !1), E = (N) => {
1284
+ x(f), N.dataTransfer && (N.dataTransfer.effectAllowed = "move", N.dataTransfer.setData("draggableShapeId", f.id), C(f.id));
1285
+ }, D = () => {
1286
+ w !== f.id && v(!0);
1287
+ }, P = () => {
1288
+ v(!1);
1289
+ }, W = (N) => (N.stopPropagation(), N.dataTransfer && b(N.dataTransfer.getData("draggableShapeId"), f.id), !1);
1290
+ return u || (Q.addEventListener("dragstart", E), Q.addEventListener("dragend", H), Q.addEventListener("dragover", Z), Q.addEventListener("dragenter", D), Q.addEventListener("dragleave", P), Q.addEventListener("drop", W)), () => {
1291
+ u || (Q.removeEventListener("dragstart", E), Q.removeEventListener("dragend", H), Q.removeEventListener("dragover", Z), Q.removeEventListener("dragenter", D), Q.removeEventListener("dragleave", P), Q.removeEventListener("drop", W));
1068
1292
  };
1069
- }, [u, g, f, w, Q, L, x]), { isOver: b };
1070
- })({ disabled: e, ref: d, shape: i, layoutDragging: n, setLayoutDragging: r, handleSelect: l, onMoveShapes: h });
1071
- return R("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === i.id), "data-is-over": +c, onClick: (u) => {
1072
- e || (u.preventDefault(), u.stopPropagation(), l(i));
1073
- }, "data-selected": +t, ref: d, children: [p("span", { dangerouslySetInnerHTML: { __html: gn(i.type) } }), p("span", { children: i.id }), p("div", { className: "react-paint-editor-layouts-separator" }), p(Y, { className: "react-paint-editor-layouts-visible-button", title: i.visible ? "Hide" : "Show", "data-visible": i.visible !== !1, disabled: e, selected: t, onClick: (u) => {
1074
- e || (u.preventDefault(), u.stopPropagation(), s(i));
1075
- }, icon: i.visible === !1 ? '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>' : '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>' }), p(Y, { className: "react-paint-editor-layouts-locked-button", title: i.locked ? "Locked" : "Unlocked", "data-locked": !!i.locked, disabled: e, selected: t, onClick: (u) => {
1076
- e || (u.preventDefault(), u.stopPropagation(), a(i));
1077
- }, icon: i.locked ? '<svg><path d="M10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H5.792V5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833ZM10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042V6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' : '<svg><path d="M5.792 5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' }), p(Y, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1078
- e || (u.preventDefault(), u.stopPropagation(), o(i));
1079
- }, icon: Wi })] });
1080
- }, fn = ({ gridFormat: e, setGridFormat: i, disabled: t = !1, shapes: n, removeShape: s, toggleShapeVisibility: a, toggleShapeLock: r, selectedShape: o, moveShapes: l, selectShape: h, isLayoutPanelShown: d }) => {
1081
- const [c, u] = $(void 0);
1082
- return d ? p(et, { alignment: "right", className: "react-paint-editor-layouts-panel", children: p("div", { className: "react-paint-editor-layouts-panel-content", children: R("div", { className: "react-paint-editor-layouts-scrolling-content", children: [R("div", { className: "react-paint-editor-layouts-row", children: [p("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), p(Y, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === "none", disabled: t, onClick: () => i("none") }), ["small", "medium", "large"].map((g) => p(Y, { className: "react-paint-editor-layouts-grid-button", selected: e === g, disabled: t, onClick: () => i(g), children: g.charAt(0).toUpperCase() }, g))] }), p("hr", {}), p("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? p("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((g) => p(vn, { shape: g, disabled: t, layoutDragging: c, setLayoutDragging: u, selected: o?.id === g.id, handleSelect: h, handleRemove: s, onMoveShapes: l, toggleShapeVisibility: a, toggleShapeLock: r }, g.id)) })] }) }) }) : null;
1083
- }, Yt = ({ children: e, onClose: i, position: t = "center", className: n = "" }) => R("div", { className: "react-paint-editor-modal", "data-position": t, style: { "--react-paint-editor-modal-zindex": Ui }, children: [p("div", { className: "react-paint-editor-modal-mask", onClick: i }), p("div", { className: `react-paint-editor-modal-panel ${n}`, children: e })] }), ct = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez une couleur", mode: n = "fill", disabled: s = !1, values: a, field: r, value: o = "", valueChanged: l }) => {
1084
- const [h] = $(re("settings_")), d = e === h;
1085
- return a.length ? R(pe, { children: [p(Y, { selected: d, title: t, disabled: s, onClick: () => {
1086
- i((c) => c === h ? void 0 : h);
1087
- }, icon: o === "transparent" ? n === "fill" ? ii : ti : void 0, children: o !== "transparent" && p("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": o } }) }), d && p(et, { title: t, alignment: "left", children: R("div", { className: "react-paint-editor-colorfield-wrapper", children: [a.map((c, u) => p(Y, { title: c, selected: c === o, color: c, icon: c === "transparent" ? n === "fill" ? ii : ti : void 0, onClick: () => {
1088
- l(r, c);
1089
- }, children: c !== "transparent" && p("div", { className: "react-paint-editor-colorfield-color", color: c, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": c } }) }, c)), p(Y, { type: "color", title: "Custom color", selected: !a.includes(o), value: o, onChange: (c) => {
1090
- const u = +c.target.value;
1091
- l(r, Number.isNaN(u) ? c.target.value : u);
1092
- }, children: p("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": a.includes(o) ? "var(--react-paint-editor-app-font-color)" : o }, children: p("span", { dangerouslySetInnerHTML: { __html: '<svg><path d="M9.958 18.333Q8.25 18.333 6.74 17.677Q5.229 17.021 4.104 15.885Q2.979 14.75 2.323 13.229Q1.667 11.708 1.667 10Q1.667 8.271 2.333 6.75Q3 5.229 4.156 4.104Q5.312 2.979 6.854 2.323Q8.396 1.667 10.125 1.667Q11.771 1.667 13.26 2.25Q14.75 2.833 15.875 3.854Q17 4.875 17.667 6.26Q18.333 7.646 18.333 9.25Q18.333 11.688 16.792 12.948Q15.25 14.208 13.188 14.208H11.75Q11.625 14.208 11.562 14.281Q11.5 14.354 11.5 14.458Q11.5 14.688 11.812 15.219Q12.125 15.75 12.125 16.458Q12.125 17.458 11.51 17.896Q10.896 18.333 9.958 18.333ZM5.458 10.875Q6 10.875 6.375 10.5Q6.75 10.125 6.75 9.583Q6.75 9.042 6.375 8.667Q6 8.292 5.458 8.292Q4.917 8.292 4.542 8.667Q4.167 9.042 4.167 9.583Q4.167 10.125 4.542 10.5Q4.917 10.875 5.458 10.875ZM7.917 7.583Q8.458 7.583 8.833 7.208Q9.208 6.833 9.208 6.292Q9.208 5.75 8.833 5.375Q8.458 5 7.917 5Q7.375 5 7 5.375Q6.625 5.75 6.625 6.292Q6.625 6.833 7 7.208Q7.375 7.583 7.917 7.583ZM12.021 7.583Q12.562 7.583 12.938 7.208Q13.312 6.833 13.312 6.292Q13.312 5.75 12.938 5.375Q12.562 5 12.021 5Q11.479 5 11.104 5.375Q10.729 5.75 10.729 6.292Q10.729 6.833 11.104 7.208Q11.479 7.583 12.021 7.583ZM14.479 10.875Q15.021 10.875 15.396 10.5Q15.771 10.125 15.771 9.583Q15.771 9.042 15.396 8.667Q15.021 8.292 14.479 8.292Q13.938 8.292 13.562 8.667Q13.188 9.042 13.188 9.583Q13.188 10.125 13.562 10.5Q13.938 10.875 14.479 10.875Z"/></svg>' } }) }) })] }) })] }) : null;
1093
- }, mn = ({ disabled: e = !1, selectedShape: i, removeShape: t }) => p(Y, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1094
- t(i);
1095
- }, icon: Wi }), jt = ({ CustomOption: e, selectedSettings: i, setSelectedSettings: t, title: n = "Choisissez l'option", disabled: s = !1, field: a, icon: r, values: o, defaultValue: l, valueChanged: h }) => {
1096
- const [d] = $(re("settings_")), c = i === d;
1097
- return o.length ? R(pe, { children: [p(Y, { selected: c, title: n, icon: r, disabled: s, onClick: () => {
1098
- t((u) => u === d ? void 0 : d);
1099
- } }), c && p(et, { title: n, alignment: "left", fitContainer: !0, children: p("div", { className: "react-paint-editor-selectfield-wrapper", children: o.map((u) => p(Y, { title: `${u}`, onClick: () => ((g) => {
1100
- h(a, g);
1293
+ }, [u, g, f, C, x, b, w]), { isOver: M };
1294
+ })({ disabled: e, ref: h, shape: t, layoutDragging: n, setLayoutDragging: o, handleSelect: l, onMoveShapes: c });
1295
+ return O("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === t.id), "data-is-over": +d, onClick: (u) => {
1296
+ e || (u.preventDefault(), u.stopPropagation(), l(t));
1297
+ }, "data-selected": +i, ref: h, tabIndex: -1, children: [p("span", { dangerouslySetInnerHTML: { __html: Ga(t.type) } }), p("span", { children: t.id }), p("div", { className: "react-paint-editor-layouts-separator" }), p(X, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (u) => {
1298
+ e || (u.preventDefault(), u.stopPropagation(), s(t));
1299
+ }, icon: t.visible === !1 ? '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>' : '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>' }), p(X, { className: "react-paint-editor-layouts-locked-button", title: t.locked ? "Locked" : "Unlocked", "data-locked": !!t.locked, disabled: e, selected: i, onClick: (u) => {
1300
+ e || (u.preventDefault(), u.stopPropagation(), a(t));
1301
+ }, icon: t.locked ? '<svg><path d="M10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H5.792V5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833ZM10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042V6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' : '<svg><path d="M5.792 5.042Q5.792 3.271 7.01 2.052Q8.229 0.833 10 0.833Q11.771 0.833 12.99 2.052Q14.208 3.271 14.208 5.042V6.667H14.917Q15.646 6.667 16.156 7.177Q16.667 7.688 16.667 8.417V16.562Q16.667 17.292 16.156 17.812Q15.646 18.333 14.917 18.333H5.083Q4.354 18.333 3.844 17.812Q3.333 17.292 3.333 16.562V8.417Q3.333 7.688 3.844 7.177Q4.354 6.667 5.083 6.667H12.458V5.042Q12.458 4.021 11.74 3.302Q11.021 2.583 10 2.583Q8.979 2.583 8.26 3.302Q7.542 4.021 7.542 5.042ZM5.083 16.583H14.917Q14.917 16.583 14.917 16.583Q14.917 16.583 14.917 16.583V8.417Q14.917 8.417 14.917 8.417Q14.917 8.417 14.917 8.417H5.083Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583ZM10 10.812Q9.292 10.812 8.802 11.302Q8.312 11.792 8.312 12.5Q8.312 13.208 8.802 13.698Q9.292 14.188 10 14.188Q10.708 14.188 11.198 13.698Q11.688 13.208 11.688 12.5Q11.688 11.792 11.198 11.302Q10.708 10.812 10 10.812ZM5.083 8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417V16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583Q5.083 16.583 5.083 16.583V8.417Q5.083 8.417 5.083 8.417Q5.083 8.417 5.083 8.417Z"/></svg>' }), p(X, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1302
+ e || (u.preventDefault(), u.stopPropagation(), r(t));
1303
+ }, icon: sn })] });
1304
+ }, ja = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: n, removeShape: s, toggleShapeVisibility: a, toggleShapeLock: o, selectedShape: r, moveShapes: l, selectShape: c, isLayoutPanelShown: h }) => {
1305
+ const [d, u] = I(void 0), g = !i.features.edition;
1306
+ return h ? p(qe, { alignment: "right", className: "react-paint-editor-layouts-panel", children: p("div", { className: "react-paint-editor-layouts-panel-content", children: O("div", { className: "react-paint-editor-layouts-scrolling-content", children: [O("div", { className: "react-paint-editor-layouts-row", children: [p("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), p(X, { icon: '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.083 11.604H16.583V8.375H13.375V10.896L11.625 9.146V8.375H10.875L9.125 6.625H11.625V3.417H8.396V5.896L6.646 4.146V3.417H5.896L4.146 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417ZM13.375 6.625H16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H13.375ZM16.771 19.229 15.854 18.333H3.417Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V4.125L0.812 3.271L2.042 2.021L18 18ZM13.375 16.583H14.104L13.375 15.833ZM8.396 11.604H9.125L8.396 10.854ZM8.396 16.583H11.625V14.083L10.875 13.354H8.396ZM3.417 6.625H4.167L3.417 5.875ZM3.417 11.604H6.646V9.104L5.917 8.375H3.417ZM6.646 16.583V13.354H3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Z"/></svg>', className: "react-paint-editor-layouts-grid-button", selected: e === "none", disabled: g, onClick: () => t("none") }), ["small", "medium", "large"].map((f) => p(X, { className: "react-paint-editor-layouts-grid-button", selected: e === f, disabled: g, onClick: () => t(f), children: f.charAt(0).toUpperCase() }, f))] }), p("hr", {}), p("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? p("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((f) => p(_a, { shape: f, disabled: g, layoutDragging: d, setLayoutDragging: u, selected: r?.id === f.id, handleSelect: c, handleRemove: s, onMoveShapes: l, toggleShapeVisibility: a, toggleShapeLock: o }, f.id)) })] }) }) }) : null;
1307
+ }, Tt = ({ children: e, onClose: t, position: i = "center", title: n, className: s = "" }) => O("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": cn }, role: "dialog", "aria-modal": "true", "aria-labelledby": n, children: [p("div", { className: "react-paint-editor-modal-mask", onClick: t }), p("div", { className: `react-paint-editor-modal-panel ${s}`, children: e })] }), St = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: n = "fill", disabled: s = !1, values: a, field: o, value: r = "", valueChanged: l }) => {
1308
+ const [c] = I(ce("settings_")), h = e === c;
1309
+ return a.length ? O(xe, { children: [p(X, { selected: h, title: i, disabled: s, onClick: () => {
1310
+ t((d) => d === c ? void 0 : c);
1311
+ }, icon: r === "transparent" ? n === "fill" ? vi : fi : void 0, children: r !== "transparent" && p("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": r } }) }), h && p(qe, { title: i, alignment: "left", children: O("div", { className: "react-paint-editor-colorfield-wrapper", children: [a.map((d) => p(X, { title: d, selected: d === r, color: d, icon: d === "transparent" ? n === "fill" ? vi : fi : void 0, onClick: () => {
1312
+ l(o, d);
1313
+ }, children: d !== "transparent" && p("div", { className: "react-paint-editor-colorfield-color", color: d, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": d } }) }, d)), p(X, { type: "color", title: "Custom color", selected: !a.includes(r), value: r, onChange: (d) => {
1314
+ const u = +d.target.value;
1315
+ l(o, Number.isNaN(u) ? d.target.value : u);
1316
+ }, children: p("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": a.includes(r) ? "var(--react-paint-editor-app-font-color)" : r }, children: p("span", { dangerouslySetInnerHTML: { __html: '<svg><path d="M9.958 18.333Q8.25 18.333 6.74 17.677Q5.229 17.021 4.104 15.885Q2.979 14.75 2.323 13.229Q1.667 11.708 1.667 10Q1.667 8.271 2.333 6.75Q3 5.229 4.156 4.104Q5.312 2.979 6.854 2.323Q8.396 1.667 10.125 1.667Q11.771 1.667 13.26 2.25Q14.75 2.833 15.875 3.854Q17 4.875 17.667 6.26Q18.333 7.646 18.333 9.25Q18.333 11.688 16.792 12.948Q15.25 14.208 13.188 14.208H11.75Q11.625 14.208 11.562 14.281Q11.5 14.354 11.5 14.458Q11.5 14.688 11.812 15.219Q12.125 15.75 12.125 16.458Q12.125 17.458 11.51 17.896Q10.896 18.333 9.958 18.333ZM5.458 10.875Q6 10.875 6.375 10.5Q6.75 10.125 6.75 9.583Q6.75 9.042 6.375 8.667Q6 8.292 5.458 8.292Q4.917 8.292 4.542 8.667Q4.167 9.042 4.167 9.583Q4.167 10.125 4.542 10.5Q4.917 10.875 5.458 10.875ZM7.917 7.583Q8.458 7.583 8.833 7.208Q9.208 6.833 9.208 6.292Q9.208 5.75 8.833 5.375Q8.458 5 7.917 5Q7.375 5 7 5.375Q6.625 5.75 6.625 6.292Q6.625 6.833 7 7.208Q7.375 7.583 7.917 7.583ZM12.021 7.583Q12.562 7.583 12.938 7.208Q13.312 6.833 13.312 6.292Q13.312 5.75 12.938 5.375Q12.562 5 12.021 5Q11.479 5 11.104 5.375Q10.729 5.75 10.729 6.292Q10.729 6.833 11.104 7.208Q11.479 7.583 12.021 7.583ZM14.479 10.875Q15.021 10.875 15.396 10.5Q15.771 10.125 15.771 9.583Q15.771 9.042 15.396 8.667Q15.021 8.292 14.479 8.292Q13.938 8.292 13.562 8.667Q13.188 9.042 13.188 9.583Q13.188 10.125 13.562 10.5Q13.938 10.875 14.479 10.875Z"/></svg>' } }) }) })] }) })] }) : null;
1317
+ }, Ka = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => p(X, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1318
+ i(t);
1319
+ }, icon: sn }), zt = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: n = "Choisissez l'option", disabled: s = !1, field: a, icon: o, values: r, defaultValue: l, valueChanged: c }) => {
1320
+ const [h] = I(ce("settings_")), d = t === h;
1321
+ return r.length ? O(xe, { children: [p(X, { selected: d, title: n, icon: o, disabled: s, onClick: () => {
1322
+ i((u) => u === h ? void 0 : h);
1323
+ } }), d && p(qe, { title: n, alignment: "left", fitContainer: !0, children: p("div", { className: "react-paint-editor-selectfield-wrapper", children: r.map((u) => p(X, { title: `${u}`, onClick: () => ((g) => {
1324
+ c(a, g);
1101
1325
  })(u), selected: l === u, style: { "--react-paint-editor-button-padding": "16px" }, children: p(e, { children: u }) }, u)) }) })] }) : null;
1102
- }, yn = ({ children: e }) => p("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), Ti = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: s, valueChanged: a }) => n.length ? p(jt, { selectedSettings: e, setSelectedSettings: i, CustomOption: yn, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: t, field: "fontFamily", values: n, defaultValue: s, valueChanged: a }) : null, Qn = ({ disabled: e, toggleLayoutPanel: i }) => p(Y, { title: "Toggle layers panel", disabled: e, onClick: i, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), Sn = ({ children: e }) => R("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [p("span", { className: "react-paint-editor-linearrow-left" }), p("span", { className: "react-paint-editor-linearrow-right" })] }), Ai = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: s, valueChanged: a }) => n.length ? p(jt, { selectedSettings: e, setSelectedSettings: i, CustomOption: Sn, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: t, field: "lineArrow", values: n, defaultValue: s, valueChanged: a }) : null, bn = ({ children: e }) => R("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {})] }), Zi = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, values: n, defaultValue: s, valueChanged: a }) => n.length ? p(jt, { selectedSettings: e, setSelectedSettings: i, CustomOption: bn, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: t, field: "lineDash", values: n, defaultValue: s, valueChanged: a }) : null, at = ({ selectedSettings: e, setSelectedSettings: i, title: t = "Choisissez l'intervalle", icon: n, disabled: s = !1, field: a, value: r = 1, min: o = 1, max: l = 20, step: h = 1, unity: d = "", valueChanged: c }) => {
1103
- const u = Math.round(r), [g] = $(re("settings_")), f = J(null);
1104
- G(() => () => {
1326
+ }, Ja = ({ children: e }) => p("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), qi = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: s, valueChanged: a }) => n.length ? p(zt, { selectedSettings: e, setSelectedSettings: t, CustomOption: Ja, title: "Police", icon: '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>', disabled: i, field: "fontFamily", values: n, defaultValue: s, valueChanged: a }) : null, es = ({ disabled: e, toggleLayoutPanel: t }) => p(X, { title: "Toggle layers panel", disabled: e, onClick: t, icon: '<svg><path d="M10 17.646 2.438 11.75 3.875 10.646 10 15.396 16.125 10.646 17.562 11.75ZM10 13.188 2.5 7.354 10 1.521 17.5 7.354Z"/></svg>', className: "react-paint-editor-layout-button" }), ts = ({ children: e }) => O("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [p("span", { className: "react-paint-editor-linearrow-left" }), p("span", { className: "react-paint-editor-linearrow-right" })] }), Gi = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: s, valueChanged: a }) => n.length ? p(zt, { selectedSettings: e, setSelectedSettings: t, CustomOption: ts, title: "Flèches", icon: '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>', disabled: i, field: "lineArrow", values: n, defaultValue: s, valueChanged: a }) : null, is = ({ children: e }) => O("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {}), p("span", {})] }), _i = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: s, valueChanged: a }) => n.length ? p(zt, { selectedSettings: e, setSelectedSettings: t, CustomOption: is, icon: '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>', title: "Type de traits", disabled: i, field: "lineDash", values: n, defaultValue: s, valueChanged: a }) : null, bt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: n, disabled: s = !1, field: a, value: o = 1, min: r = 1, max: l = 20, step: c = 1, unity: h = "", valueChanged: d }) => {
1327
+ const u = Math.round(o), [g] = I(ce("settings_")), f = j(null);
1328
+ q(() => () => {
1105
1329
  f.current && clearTimeout(f.current);
1106
1330
  }, []);
1107
- const x = e === g;
1108
- return o === l ? null : R(pe, { children: [p(Y, { selected: x, title: t, disabled: s, icon: n, onClick: () => {
1109
- i((w) => w === g ? void 0 : g);
1110
- } }), x && p(et, { title: t, alignment: "left", fitContainer: !0, children: p("div", { children: R("label", { className: "react-paint-editor-rangefield", children: [p("input", { type: "range", min: o, max: l, step: h, value: r, onChange: (w) => {
1111
- const Q = +w.target.value;
1112
- c(a, Number.isNaN(Q) ? w.target.value : Q, !1), f.current && clearTimeout(f.current), f.current = setTimeout(() => {
1113
- c(a, Number.isNaN(Q) ? w.target.value : Q, !0);
1331
+ const w = e === g;
1332
+ return r === l ? null : O(xe, { children: [p(X, { selected: w, title: i, disabled: s, icon: n, onClick: () => {
1333
+ t((C) => C === g ? void 0 : g);
1334
+ } }), w && p(qe, { title: i, alignment: "left", fitContainer: !0, children: p("div", { children: O("label", { className: "react-paint-editor-rangefield", children: [p("input", { type: "range", min: r, max: l, step: c, value: o, onChange: (C) => {
1335
+ const x = +C.target.value;
1336
+ d(a, Number.isNaN(x) ? C.target.value : x, !1), f.current && clearTimeout(f.current), f.current = setTimeout(() => {
1337
+ d(a, Number.isNaN(x) ? C.target.value : x, !0);
1114
1338
  }, 1e3);
1115
- } }), R("span", { children: [u, d] })] }) }) })] });
1116
- }, Ei = ({ selectedSettings: e, setSelectedSettings: i, disabled: t = !1, min: n, max: s, step: a, value: r, valueChanged: o }) => n === s ? null : p(at, { selectedSettings: e, setSelectedSettings: i, icon: Wt, title: "Nombre de points", disabled: t, field: "pointsCount", min: n, max: s, step: a, unity: "", value: r, valueChanged: o }), ht = ({ setSelectedSettings: e, disabled: i = !1, field: t, icon: n, values: s, value: a = !1, valueChanged: r }) => {
1117
- const [o] = $(re("settings_"));
1118
- return s.length !== 2 ? null : p(Y, { onClick: () => {
1119
- e((l) => l === o ? void 0 : o), r(t, !a);
1120
- }, selected: a, disabled: i, icon: n });
1121
- }, At = ({ activeTool: e, selectedShape: i, selectedShapeTool: t, disabled: n, selectedSettings: s, setSelectedSettings: a, handleShapeStyleChange: r, handlePolygonLinesCount: o, handleShapeFontFamilyChange: l }) => i ? p(pe, { children: t && R(pe, { children: ["strokeColor" in t.settings && !t.settings.strokeColor.hidden && p(ct, { selectedSettings: s, setSelectedSettings: a, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: i.style?.strokeColor, valueChanged: r, values: t.settings.strokeColor.values }), "fillColor" in t.settings && !t.settings.fillColor.hidden && p(ct, { selectedSettings: s, setSelectedSettings: a, title: "Couleur de fond", disabled: n, field: "fillColor", value: i.style?.fillColor, valueChanged: r, values: t.settings.fillColor.values }), "lineWidth" in t.settings && !t.settings.lineWidth.hidden && p(at, { selectedSettings: s, setSelectedSettings: a, title: "Epaisseur du trait", icon: ei, disabled: n, field: "lineWidth", value: i.style?.lineWidth, valueChanged: r, unity: "px", min: t.settings.lineWidth.min, max: t.settings.lineWidth.max, step: t.settings.lineWidth.step }), "lineDash" in t.settings && !t.settings.lineDash.hidden && p(Zi, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: i.style?.lineDash, valueChanged: r, values: t.settings.lineDash.values }), "lineArrow" in t.settings && !t.settings.lineArrow.hidden && p(Ai, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: i.style?.lineArrow, valueChanged: r, values: t.settings.lineArrow.values }), "pointsCount" in t.settings && !t.settings.pointsCount.hidden && p(Ei, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: o, min: t.settings.pointsCount.min, max: t.settings.pointsCount.max, step: t.settings.pointsCount.step, value: i.style?.pointsCount }), "fontFamily" in t.settings && !t.settings.fontFamily.hidden && p(Ti, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: l, values: t.settings.fontFamily.values, defaultValue: i.style?.fontFamily }), "fontBold" in t.settings && !t.settings.fontBold.hidden && p(ht, { setSelectedSettings: a, disabled: n, field: "fontBold", icon: Jt, valueChanged: l, values: t.settings.fontBold.values, value: i.style?.fontBold }), "fontItalic" in t.settings && !t.settings.fontItalic.hidden && p(ht, { setSelectedSettings: a, disabled: n, field: "fontItalic", icon: Kt, valueChanged: l, values: t.settings.fontItalic.values, value: i.style?.fontItalic }), "opacity" in t.settings && !t.settings.opacity.hidden && p(at, { selectedSettings: s, setSelectedSettings: a, title: "Opacité", icon: qt, min: t.settings.opacity.min, max: t.settings.opacity.max, step: t.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: i.style?.opacity ?? 100, valueChanged: r })] }) }) : "settings" in e ? R(pe, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && p(ct, { selectedSettings: s, setSelectedSettings: a, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: r, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && p(ct, { selectedSettings: s, setSelectedSettings: a, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: r, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && p(at, { selectedSettings: s, setSelectedSettings: a, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: ei, value: e.settings.lineWidth.default, valueChanged: r, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && !e.settings.lineDash.hidden && p(Zi, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: r, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && p(Ai, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: r, values: e.settings.lineArrow.values }), "pointsCount" in e.settings && !e.settings.pointsCount.hidden && p(Ei, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: o, min: e.settings.pointsCount.min, max: e.settings.pointsCount.max, step: e.settings.pointsCount.step, value: e.settings.pointsCount.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && p(Ti, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && p(ht, { setSelectedSettings: a, disabled: n, field: "fontBold", icon: Jt, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && p(ht, { setSelectedSettings: a, disabled: n, field: "fontItalic", icon: Kt, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && p(at, { selectedSettings: s, setSelectedSettings: a, title: "Opacité", icon: qt, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: e.settings.opacity.default, valueChanged: r })] }) : null, Cn = ({ width: e, disabled: i = !1, availableTools: t, updateToolSettings: n, layersManipulation: s, toggleLayoutPanel: a, activeTool: r, selectedShape: o, canvas: l, settings: h, updateShape: d, removeShape: c }) => {
1122
- const [u, g] = $(void 0), [f, x] = $(!1), w = () => {
1123
- x((H) => !H);
1124
- }, Q = o ? t.find((H) => H.id === o.toolId) || t.find((H) => H.type === o.type) : void 0, L = (Q ? Object.keys(Q.settings).length + 1 : "settings" in r ? Object.keys(r.settings).length : 0) + (s ? 1 : 0), b = e < 40 * L, k = (H, T, C = !0) => {
1125
- o ? (d(ot(de(["style", H], T, o), h), C), Q && n(Q.id, H, T)) : n(r.id, H, T);
1126
- }, P = (H, T) => {
1339
+ } }), O("span", { children: [u, h] })] }) }) })] });
1340
+ }, ns = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => p(X, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: dn, className: t ? ` ${t}` : "" }), wt = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: n, values: s, value: a = !1, valueChanged: o }) => {
1341
+ const [r] = I(ce("settings_"));
1342
+ return s.length !== 2 ? null : p(X, { onClick: () => {
1343
+ e((l) => l === r ? void 0 : r), o(i, !a);
1344
+ }, selected: a, disabled: t, icon: n });
1345
+ }, as = ({ children: e }) => p("span", { children: e === 0 ? "Non" : "Oui" }), ss = [0, 1], ji = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: n, valueChanged: s }) => p(zt, { selectedSettings: e, setSelectedSettings: t, CustomOption: as, title: "Fermer les points", icon: ei, disabled: i, field: "closedPoints", values: ss, defaultValue: n, valueChanged: s }), Ut = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: n, selectedSettings: s, setSelectedSettings: a, handleShapeStyleChange: o, handlePolygonLinesCount: r, handleShapeFontFamilyChange: l }) => t ? i && O(xe, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && p(St, { selectedSettings: s, setSelectedSettings: a, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: t.style?.strokeColor, valueChanged: o, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && p(St, { selectedSettings: s, setSelectedSettings: a, title: "Couleur de fond", disabled: n, field: "fillColor", value: t.style?.fillColor, valueChanged: o, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && p(bt, { selectedSettings: s, setSelectedSettings: a, title: "Epaisseur du trait", icon: gi, disabled: n, field: "lineWidth", value: t.style?.lineWidth, valueChanged: o, unity: "px", min: i.settings.lineWidth.min, max: i.settings.lineWidth.max, step: i.settings.lineWidth.step }), "lineDash" in i.settings && !i.settings.lineDash.hidden && p(_i, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: t.style?.lineDash, valueChanged: o, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && p(Gi, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: t.style?.lineArrow, valueChanged: o, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && p(ji, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: o, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && p(qi, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: l, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && p(wt, { setSelectedSettings: a, disabled: n, field: "fontBold", icon: ui, valueChanged: l, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && p(wt, { setSelectedSettings: a, disabled: n, field: "fontItalic", icon: pi, valueChanged: l, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && p(bt, { selectedSettings: s, setSelectedSettings: a, title: "Opacité", icon: hi, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: t.style?.opacity ?? 100, valueChanged: o })] }) : "settings" in e ? O(xe, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && p(St, { selectedSettings: s, setSelectedSettings: a, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: o, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && p(St, { selectedSettings: s, setSelectedSettings: a, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: o, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && p(bt, { selectedSettings: s, setSelectedSettings: a, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: gi, value: e.settings.lineWidth.default, valueChanged: o, unity: "px", min: e.settings.lineWidth.min, max: e.settings.lineWidth.max, step: e.settings.lineWidth.step }), "lineDash" in e.settings && !e.settings.lineDash.hidden && p(_i, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: o, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && p(Gi, { selectedSettings: s, setSelectedSettings: a, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: o, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && p(ji, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: o, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && p(qi, { selectedSettings: s, setSelectedSettings: a, disabled: n, valueChanged: l, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && p(wt, { setSelectedSettings: a, disabled: n, field: "fontBold", icon: ui, valueChanged: l, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && p(wt, { setSelectedSettings: a, disabled: n, field: "fontItalic", icon: pi, valueChanged: l, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && p(bt, { selectedSettings: s, setSelectedSettings: a, title: "Opacité", icon: hi, min: e.settings.opacity.min, max: e.settings.opacity.max, step: e.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: e.settings.opacity.default, valueChanged: o })] }) : null, os = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: n = !1, toggleLayoutPanel: s, activeTool: a, selectedShape: o, canvas: r, settings: l, updateShape: c, removeShape: h, isZoomPanelShown: d, setIsZoomPanelShown: u }) => {
1346
+ const [g, f] = I(void 0), [w, C] = I(!1), x = l.size === "infinite" || l.features.zoom, b = !l.features.edition, M = () => {
1347
+ C((P) => !P);
1348
+ }, v = o ? t.find((P) => P.id === o.toolId) || t.find((P) => P.type === o.type) : void 0, Q = (v ? Object.keys(v.settings).length + 1 : "settings" in a ? Object.keys(a.settings).length : 0) + +n + +x, H = e < 40 * Q, Z = (P, W, N = !0) => {
1349
+ o ? (c(et(me(["style", P], W, o), l), N), v && i(v.id, P, W)) : i(a.id, P, W);
1350
+ }, E = (P, W) => {
1127
1351
  if (o) {
1128
1352
  if (o.type !== "text") return;
1129
- const C = l?.getContext("2d");
1130
- if (!C) return;
1131
- const V = de(["style", H], T, o), I = Gt(C, V.value, V.width, V.style?.fontBold ?? !1, V.style?.fontItalic ?? !1, V.style?.fontFamily), y = ot({ ...V, fontSize: I, height: I * V.value.length }, h);
1132
- d(y, !0), Q && n(Q.id, H, T);
1133
- } else n(r.id, H, T);
1134
- }, E = (H, T) => {
1353
+ const N = r?.getContext("2d");
1354
+ if (!N) return;
1355
+ const z = me(["style", P], W, o), B = oi(N, z.value, z.width, z.style?.fontBold ?? !1, z.style?.fontItalic ?? !1, z.style?.fontFamily), U = et({ ...z, fontSize: B, height: B * z.value.length }, l);
1356
+ c(U, !0), v && i(v.id, P, W);
1357
+ } else i(a.id, P, W);
1358
+ }, D = (P, W) => {
1135
1359
  if (o) {
1136
1360
  if (o.type !== "polygon" && o.type !== "curve") return;
1137
- d(o.type === "polygon" ? ((C, V, I) => {
1138
- const y = C.points.length;
1139
- if (y === V) return C;
1140
- if (y > V) {
1141
- const Z = C.points.slice(0, V);
1142
- return _e({ ...C, points: Z, style: { ...C.style, pointsCount: Z.length } }, I);
1143
- }
1144
- const N = V - y, M = new Array(N).fill(void 0).map((Z, v) => [C.points[0][0] + (C.points[1][0] - C.points[0][0]) * (v + 1) / (N + 1), C.points[0][1] + (C.points[1][1] - C.points[0][1]) * (v + 1) / (N + 1)]), A = [C.points[0], ...M, ...C.points.slice(1, C.points.length)];
1145
- return _e({ ...C, points: A, style: { ...C.style, pointsCount: A.length } }, I);
1146
- })(o, T, h) : ((C, V, I) => {
1147
- const y = C.points.length;
1148
- if (y === V) return C;
1149
- if (y > V) {
1150
- const Z = C.points.slice(0, V);
1151
- return qe({ ...C, points: Z, style: { ...C.style, pointsCount: Z.length } }, I);
1152
- }
1153
- const N = V - y, M = new Array(N).fill(void 0).map((Z, v) => [C.points[0][0] + (C.points[1][0] - C.points[0][0]) * (v + 1) / (N + 1), C.points[0][1] + (C.points[1][1] - C.points[0][1]) * (v + 1) / (N + 1)]), A = [C.points[0], ...M, ...C.points.slice(1, C.points.length)];
1154
- return qe({ ...C, points: A, style: { ...C.style, pointsCount: A.length } }, I);
1155
- })(o, T, h), !0), Q && n(Q.id, H, T);
1156
- } else n(r.id, H, T);
1361
+ c(o.type === "polygon" ? Nn(o, W, l) : Rn(o, W, l), !0), v && i(v.id, P, W);
1362
+ } else i(a.id, P, W);
1157
1363
  };
1158
- return R(pe, { children: [R("div", { className: "react-paint-editor-settings-bar", children: [R("div", { className: "react-paint-editor-settings-shrinkable", children: [b && L > 2 && p(Y, { disabled: i, onClick: w, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), o ? p(pe, { children: Q && R(pe, { children: [!b && p(At, { activeTool: r, selectedShape: o, selectedShapeTool: Q, disabled: i, selectedSettings: u, setSelectedSettings: g, handleShapeStyleChange: k, handlePolygonLinesCount: E, handleShapeFontFamilyChange: P }), r.type === "selection" && p(mn, { disabled: i, selectedShape: o, removeShape: c })] }) }) : !b && p(At, { activeTool: r, selectedShape: o, selectedShapeTool: Q, disabled: i, selectedSettings: u, setSelectedSettings: g, handleShapeStyleChange: k, handlePolygonLinesCount: E, handleShapeFontFamilyChange: P })] }), p("div", { className: "react-paint-editor-settings-separator" }), s && p(Qn, { disabled: i, toggleLayoutPanel: a })] }), f && p(Yt, { className: "react-paint-editor-settings-modal", onClose: w, position: "bottom", children: p(At, { activeTool: r, selectedShape: o, selectedShapeTool: Q, disabled: i, selectedSettings: u, setSelectedSettings: g, handleShapeStyleChange: k, handlePolygonLinesCount: E, handleShapeFontFamilyChange: P }) })] });
1159
- }, Di = ({ disabled: e = !1, withText: i = !1, loadFile: t, type: n, img: s, accept: a }) => {
1160
- const r = J(null);
1161
- return p(Y, { ref: r, type: "file", onClick: (o) => {
1162
- o.stopPropagation(), r.current && (r.current.value = "");
1163
- }, onChange: (o) => {
1164
- const l = o.target.files?.item(0);
1165
- l && t(l);
1166
- }, accept: a, title: n.label ?? n.type, icon: s, disabled: e, children: i ? n.label : void 0 });
1167
- }, ge = ({ type: e, img: i, isActive: t, withText: n = !1, disabled: s = !1, setActive: a }) => p(Y, { disabled: s, selected: t, onClick: () => {
1364
+ return O(xe, { children: [O("div", { className: "react-paint-editor-settings-bar", children: [O("div", { className: "react-paint-editor-settings-shrinkable", children: [x && p(ns, { className: d ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1365
+ u((P) => !P);
1366
+ } }), H && Q > 2 && p(X, { disabled: b, onClick: M, title: "Toggle settings", icon: '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>' }), o ? v && O(xe, { children: [!H && p(Ut, { activeTool: a, selectedShape: o, selectedShapeTool: v, disabled: b, selectedSettings: g, setSelectedSettings: f, handleShapeStyleChange: Z, handlePolygonLinesCount: D, handleShapeFontFamilyChange: E }), a.type === "selection" && p(Ka, { disabled: b, selectedShape: o, removeShape: h })] }) : !H && p(Ut, { activeTool: a, selectedShape: o, selectedShapeTool: v, disabled: b, selectedSettings: g, setSelectedSettings: f, handleShapeStyleChange: Z, handlePolygonLinesCount: D, handleShapeFontFamilyChange: E })] }), p("div", { className: "react-paint-editor-settings-separator" }), n && p(es, { disabled: b, toggleLayoutPanel: s })] }), w && p(Tt, { className: "react-paint-editor-settings-modal", onClose: M, position: "bottom", title: "Settings", children: p(Ut, { activeTool: a, selectedShape: o, selectedShapeTool: v, disabled: b, selectedSettings: g, setSelectedSettings: f, handleShapeStyleChange: Z, handlePolygonLinesCount: D, handleShapeFontFamilyChange: E }) })] });
1367
+ }, Ki = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: n, img: s, accept: a }) => {
1368
+ const o = j(null);
1369
+ return p(X, { ref: o, type: "file", onClick: (r) => {
1370
+ r.stopPropagation(), o.current && (o.current.value = "");
1371
+ }, onChange: (r) => {
1372
+ const l = r.target.files?.item(0);
1373
+ l && i(l);
1374
+ }, accept: a, title: n.label ?? n.type, icon: s, disabled: e, children: t ? n.label : void 0 });
1375
+ }, ve = ({ type: e, img: t, isActive: i, withText: n = !1, disabled: s = !1, setActive: a }) => p(X, { disabled: s, selected: i, onClick: () => {
1168
1376
  a(e);
1169
- }, title: e.label ?? e.type, icon: i, children: n ? e.label : void 0 }), wn = ({ activeTool: e, withActionsInMenu: i, hasActionToUndo: t = !1, hasActionToRedo: n = !1, hasActionToClear: s = !1, undoAction: a, redoAction: r, clearCanvas: o, alignment: l, group: h, vertical: d = !1, disabled: c = !1, withLoadAndSave: u, withExport: g, addPicture: f, loadFile: x, togglePictureUrlModal: w, saveFile: Q, exportCanvasInFile: L, withUploadPicture: b, withUrlPicture: k }) => {
1170
- const [P, E] = $(!1), [, H] = Ri(), T = h?.tools?.some((V) => V === e.type), C = (T ? e.icon : h.img) ?? h.title;
1171
- return G(() => {
1172
- if (!P) return;
1173
- const V = () => {
1174
- E(!1);
1377
+ }, title: e.label ?? e.type, icon: t, children: n ? e.label : void 0 }), rs = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: n = !1, hasActionToClear: s = !1, undoAction: a, redoAction: o, clearCanvas: r, alignment: l, group: c, vertical: h = !1, disabled: d = !1, withLoadAndSave: u, withExport: g, addPicture: f, loadFile: w, togglePictureUrlModal: C, saveFile: x, toggleExportModal: b, withUploadPicture: M, withUrlPicture: v }) => {
1378
+ const [Q, H] = I(!1), [, Z] = nn(), E = c?.tools?.some((P) => P === e.type), D = (E ? e.icon : c.img) ?? c.title;
1379
+ return q(() => {
1380
+ if (!Q) return;
1381
+ const P = () => {
1382
+ H(!1);
1175
1383
  };
1176
- return document.addEventListener("click", V), () => {
1177
- document.removeEventListener("click", V);
1384
+ return document.addEventListener("click", P), () => {
1385
+ document.removeEventListener("click", P);
1178
1386
  };
1179
- }, [P]), i || b || k || u || g ? R("div", { className: "react-paint-editor-toolbox-relative", children: [p(Y, { selected: T, title: h.title, disabled: c, onClick: () => {
1180
- H(() => {
1181
- E(!0);
1387
+ }, [Q]), t || M || v || u || g ? O("div", { className: "react-paint-editor-toolbox-relative", children: [p(X, { selected: E, title: c.title, disabled: d, onClick: () => {
1388
+ Z(() => {
1389
+ H(!0);
1182
1390
  });
1183
- }, icon: C }), P && p(et, { alignment: l, position: "top", children: R("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +d, children: [i && R(pe, { children: [p(ge, { withText: !0, type: Xe, disabled: c || !t, img: Xe.icon, isActive: e.id === Xe.id, setActive: a }), p(ge, { withText: !0, type: Ye, disabled: c || !n, img: Ye.icon, isActive: e.id === Ye.id, setActive: r }), p(ge, { withText: !0, type: je, disabled: c || !s, img: je.icon, isActive: e.id === je.id, setActive: o }), (b || k || u) && p("hr", {})] }), b && p(Di, { withText: !0, type: si, disabled: c, loadFile: async (V) => {
1184
- E(!1), await f(V);
1185
- }, img: si.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml" }), k && p(Y, { disabled: c, selected: !1, onClick: w, title: "Add picture from URL", icon: '<svg><path d="M9.188 16.542V14.938Q8.5 14.938 8.021 14.458Q7.542 13.979 7.542 13.292V12.458L3.583 8.5Q3.5 8.875 3.458 9.25Q3.417 9.625 3.417 10Q3.417 12.5 5.062 14.365Q6.708 16.229 9.188 16.542ZM14.854 14.438Q15.708 13.521 16.146 12.385Q16.583 11.25 16.583 10Q16.583 7.979 15.469 6.313Q14.354 4.646 12.479 3.917V4.229Q12.479 4.917 12 5.396Q11.521 5.875 10.833 5.875H9.188V7.521Q9.188 7.875 8.948 8.115Q8.708 8.354 8.354 8.354H6.708V10H11.646Q12 10 12.24 10.229Q12.479 10.458 12.479 10.812V13.292H13.292Q13.833 13.292 14.26 13.604Q14.688 13.917 14.854 14.438ZM10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333Z"/></svg>', children: "Add picture from URL" }), (b || k) && u && p("hr", {}), u && R(pe, { children: [p(Di, { withText: !0, type: ai, disabled: c, loadFile: (V) => {
1186
- E(!1), x(V);
1187
- }, img: ai.icon, accept: "application/JSON" }), p(ge, { withText: !0, disabled: c, type: Lt, img: Lt.icon, isActive: e.id === Lt.id, setActive: Q })] }), g && p(ge, { withText: !0, disabled: c, type: kt, img: kt.icon, isActive: e.id === kt.id, setActive: L })] }) })] }) : null;
1188
- }, xn = ({ togglePictureUrlModal: e, addPicture: i }) => {
1189
- const t = J(null);
1190
- return G(() => {
1191
- t.current && t.current.focus();
1192
- }, []), p(Yt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, children: R("form", { onSubmit: async (n) => {
1391
+ }, icon: D }), Q && p(qe, { alignment: l, position: "top", children: O("div", { className: "react-paint-editor-toolbox-panel-content", "data-vertical": +h, children: [t && O(xe, { children: [p(ve, { withText: !0, type: je, disabled: d || !i, img: je.icon, isActive: e.id === je.id, setActive: a }), p(ve, { withText: !0, type: Ke, disabled: d || !n, img: Ke.icon, isActive: e.id === Ke.id, setActive: o }), p(ve, { withText: !0, type: Je, disabled: d || !s, img: Je.icon, isActive: e.id === Je.id, setActive: r }), (M || v || u) && p("hr", {})] }), M && p(Ki, { withText: !0, type: Qi, disabled: d, loadFile: async (P) => {
1392
+ H(!1), await f(P);
1393
+ }, img: Qi.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), v && p(X, { disabled: d, selected: !1, onClick: C, title: "Add picture from URL", icon: '<svg><path d="M9.188 16.542V14.938Q8.5 14.938 8.021 14.458Q7.542 13.979 7.542 13.292V12.458L3.583 8.5Q3.5 8.875 3.458 9.25Q3.417 9.625 3.417 10Q3.417 12.5 5.062 14.365Q6.708 16.229 9.188 16.542ZM14.854 14.438Q15.708 13.521 16.146 12.385Q16.583 11.25 16.583 10Q16.583 7.979 15.469 6.313Q14.354 4.646 12.479 3.917V4.229Q12.479 4.917 12 5.396Q11.521 5.875 10.833 5.875H9.188V7.521Q9.188 7.875 8.948 8.115Q8.708 8.354 8.354 8.354H6.708V10H11.646Q12 10 12.24 10.229Q12.479 10.458 12.479 10.812V13.292H13.292Q13.833 13.292 14.26 13.604Q14.688 13.917 14.854 14.438ZM10 18.333Q8.271 18.333 6.75 17.677Q5.229 17.021 4.104 15.896Q2.979 14.771 2.323 13.25Q1.667 11.729 1.667 10Q1.667 8.271 2.323 6.75Q2.979 5.229 4.104 4.104Q5.229 2.979 6.75 2.323Q8.271 1.667 10 1.667Q11.729 1.667 13.25 2.323Q14.771 2.979 15.896 4.104Q17.021 5.229 17.677 6.75Q18.333 8.271 18.333 10Q18.333 11.729 17.677 13.25Q17.021 14.771 15.896 15.896Q14.771 17.021 13.25 17.677Q11.729 18.333 10 18.333Z"/></svg>', children: "Add picture from URL" }), (M || v) && u && p("hr", {}), u && O(xe, { children: [p(Ki, { withText: !0, type: yi, disabled: d, loadFile: (P) => {
1394
+ H(!1), w(P);
1395
+ }, img: yi.icon, accept: "application/JSON" }), p(ve, { withText: !0, disabled: d, type: Rt, img: Rt.icon, isActive: e.id === Rt.id, setActive: x })] }), g && p(ve, { withText: !0, disabled: d, type: Nt, img: Nt.icon, isActive: e.id === Nt.id, setActive: b })] }) })] }) : null;
1396
+ }, ls = ({ togglePictureUrlModal: e, addPicture: t }) => {
1397
+ const i = j(null);
1398
+ return q(() => {
1399
+ i.current && i.current.focus();
1400
+ }, []), p(Tt, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: O("form", { onSubmit: async (n) => {
1193
1401
  n.preventDefault();
1194
- const s = t.current?.value;
1195
- s && (await i(s), e());
1196
- }, children: [R("label", { children: ["URL ", p("input", { type: "text", ref: t })] }), p(Y, { onClick: e, children: "Annuler" }), p(Y, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1197
- }, Mn = ({ activeTool: e, alignment: i, group: t, disabled: n = !1, setActiveToolFromId: s }) => {
1198
- const a = J(null), [r, o] = $(!1), [, l] = Ri(), [h, d] = $(void 0), c = (f) => {
1199
- d(f), s(f.id);
1402
+ const s = i.current?.value;
1403
+ s && (await t(s), e());
1404
+ }, children: [O("label", { children: ["URL ", p("input", { type: "text", ref: i })] }), p(X, { onClick: e, children: "Annuler" }), p(X, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1405
+ }, Ji = "Choose export settings", ds = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1406
+ const i = async (n) => {
1407
+ t(n), e();
1408
+ };
1409
+ return O(Tt, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: Ji, children: [p("h3", { children: Ji }), p("hr", {}), p(X, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), p(X, { onClick: () => i("defaultView"), children: "Exporter le canvas entier" }), p(X, { onClick: () => i("fitToShapes"), children: "Exporter dans les limites du dessin" }), p(X, { selected: !0, onClick: e, children: "Annuler" })] });
1410
+ }, cs = ({ activeTool: e, alignment: t, group: i, disabled: n = !1, setActiveToolFromId: s }) => {
1411
+ const a = j(null), [o, r] = I(!1), [, l] = nn(), [c, h] = I(void 0), d = (f) => {
1412
+ h(f), s(f.id);
1200
1413
  };
1201
- if (G(() => {
1202
- if (!r) return;
1203
- const f = (x) => {
1204
- !o1(x, a.current) && o(!1);
1414
+ if (q(() => {
1415
+ if (!o) return;
1416
+ const f = (w) => {
1417
+ !kn(w, a.current) && r(!1);
1205
1418
  };
1206
1419
  return document.addEventListener("mousedown", f, { passive: !1 }), document.addEventListener("touchstart", f, { passive: !1 }), () => {
1207
1420
  document.removeEventListener("mousedown", f), document.removeEventListener("touchstart", f);
1208
1421
  };
1209
- }, [r]), "type" in t) return p(ge, { disabled: n, type: t, img: t.icon, isActive: e.id === t.id, setActive: c });
1210
- if (!t.toolsType.length) return null;
1211
- if (t.toolsType?.length === 1) return p(ge, { disabled: n, type: t.toolsType[0], img: t.toolsType[0].icon, isActive: e.id === t.toolsType[0].id, setActive: c });
1212
- const u = t?.toolsType.find((f) => f.type === e.type) !== void 0, g = (h ? h.icon : t.toolsType?.[0]?.icon) ?? t.title;
1213
- return R("div", { className: "react-paint-editor-toolbargroup-relative", children: [p(Y, { selected: u, title: t.title, disabled: n, onClick: () => {
1214
- h ? s(h.id) : t.toolsType?.[0] && c(t.toolsType[0]), l(() => {
1215
- o(!0);
1422
+ }, [o]), "type" in i) return p(ve, { disabled: n, type: i, img: i.icon, isActive: e.id === i.id, setActive: d });
1423
+ if (!i.toolsType.length) return null;
1424
+ if (i.toolsType?.length === 1) return p(ve, { disabled: n, type: i.toolsType[0], img: i.toolsType[0].icon, isActive: e.id === i.toolsType[0].id, setActive: d });
1425
+ const u = i?.toolsType.find((f) => f.type === e.type) !== void 0, g = (c ? c.icon : i.toolsType?.[0]?.icon) ?? i.title;
1426
+ return O("div", { className: "react-paint-editor-toolbargroup-relative", children: [p(X, { selected: u, title: i.title, disabled: n, onClick: () => {
1427
+ c ? s(c.id) : i.toolsType?.[0] && d(i.toolsType[0]), l(() => {
1428
+ r(!0);
1216
1429
  });
1217
- }, icon: g }), r && p(et, { alignment: i, position: "top", children: p("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +t.vertical, ref: a, children: t.toolsType.map((f, x) => p(ge, { disabled: n, type: f, img: f.icon, isActive: e.id === f.id, setActive: c }, f.id)) }) })] });
1218
- }, kn = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], Ln = ({ width: e, disabled: i = !1, activeTool: t, hasActionToUndo: n = !1, hasActionToRedo: s = !1, hasActionToClear: a = !1, withLoadAndSave: r, withExport: o, clearCanvas: l, setActiveTool: h, undoAction: d, redoAction: c, addPicture: u, loadFile: g, saveFile: f, exportCanvasInFile: x, availableTools: w, withUrlPicture: Q, withUploadPicture: L }) => {
1219
- const b = ((M, A) => {
1220
- const Z = A.flatMap((v) => {
1221
- if (typeof v != "object") return M.filter((S) => S.type === v);
1222
- const m = M.filter((S) => v.toolsType.includes(S.type));
1223
- return m ? { ...v, toolsType: m } : null;
1430
+ }, icon: g }), o && p(qe, { alignment: t, position: "top", children: p("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +i.vertical, ref: a, children: i.toolsType.map((f) => p(ve, { disabled: n, type: f, img: f.icon, isActive: e.id === f.id, setActive: d }, f.id)) }) })] });
1431
+ }, hs = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], us = ({ settings: e, width: t, activeTool: i, hasActionToUndo: n = !1, hasActionToRedo: s = !1, hasActionToClear: a = !1, withLoadAndSave: o, withExport: r, clearCanvas: l, setActiveTool: c, undoAction: h, redoAction: d, addPicture: u, loadFile: g, saveFile: f, exportCanvasInFile: w, availableTools: C, withUrlPicture: x, withUploadPicture: b }) => {
1432
+ const M = ((y, S) => {
1433
+ const V = S.flatMap((T) => {
1434
+ if (typeof T != "object") return y.filter((F) => F.type === T);
1435
+ const k = y.filter((F) => T.toolsType.includes(F.type));
1436
+ return k ? { ...T, toolsType: k } : null;
1224
1437
  });
1225
- return $t(Z);
1226
- })(w, kn), k = e < 40 * (5 + b.length), P = e < 40 * (2 + b.length), [E, H] = $(!1), [T, C] = $(!1), V = () => {
1227
- H((M) => !M);
1228
- }, I = (M) => {
1229
- h(M), H(!1);
1230
- }, y = (M) => {
1231
- I(w.find((A) => A.id === M) ?? t);
1232
- }, N = w.find((M) => M.type === t.type) !== void 0;
1233
- return R(pe, { children: [R("div", { className: "react-paint-editor-toolbar-toolbox", children: [R("div", { className: "react-paint-editor-toolbar-shrinkable", children: [p(ge, { type: Ae, disabled: i, img: Ae.icon, isActive: t.id === Ae.id, setActive: I }), P ? p(Y, { disabled: i, onClick: V, title: "Toggle tools", icon: '<svg><path d="M5.333 9.292 10.021 1.646 14.708 9.292ZM14.562 18.333Q13 18.333 11.896 17.229Q10.792 16.125 10.792 14.562Q10.792 13 11.896 11.896Q13 10.792 14.562 10.792Q16.125 10.792 17.229 11.896Q18.333 13 18.333 14.562Q18.333 16.125 17.229 17.229Q16.125 18.333 14.562 18.333ZM2.5 17.917V11.188H9.229V17.917ZM14.562 16.583Q15.438 16.583 16.01 16.01Q16.583 15.438 16.583 14.562Q16.583 13.688 16.01 13.115Q15.438 12.542 14.562 12.542Q13.688 12.542 13.115 13.115Q12.542 13.688 12.542 14.562Q12.542 15.438 13.115 16.01Q13.688 16.583 14.562 16.583ZM4.25 16.167H7.479V12.938H4.25ZM8.458 7.542H11.583L10.021 5ZM10.021 7.542ZM7.479 12.938ZM14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Z"/></svg>', selected: N }) : b.map((M, A) => p(Mn, { disabled: i, activeTool: t, group: M, setActiveToolFromId: y }, "id" in M ? M.id : M.title))] }), !k && R(pe, { children: [p(ge, { type: Xe, disabled: i || !n, img: Xe.icon, isActive: t.id === Xe.id, setActive: d }), p(ge, { type: Ye, disabled: i || !s, img: Ye.icon, isActive: t.id === Ye.id, setActive: c }), p(ge, { type: je, disabled: i || !a, img: je.icon, isActive: t.id === je.id, setActive: l })] }), p(wn, { withActionsInMenu: k, disabled: i, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: t, addPicture: u, loadFile: g, saveFile: f, togglePictureUrlModal: () => {
1234
- C(!0);
1235
- }, exportCanvasInFile: x, withUploadPicture: L, withUrlPicture: Q, withLoadAndSave: r, withExport: o, hasActionToUndo: n, hasActionToRedo: s, hasActionToClear: a, undoAction: d, redoAction: c, clearCanvas: l })] }), E && p(Yt, { className: "react-paint-editor-toolbar-modal", onClose: V, children: w.map((M, A) => M.type === "picture" ? null : p(ge, { disabled: i, type: M, img: M.icon, withText: !1, isActive: t.id === M.id, setActive: I }, M.id)) }), T && p(xn, { togglePictureUrlModal: () => {
1236
- C((M) => !M);
1237
- }, addPicture: u })] });
1238
- }, pt = { none: 0, small: 10, medium: 20, large: 40 }, Vn = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, Pn = () => {
1239
- const e = J([]), [i, t] = $([]);
1240
- return G(() => () => {
1438
+ return ri(V);
1439
+ })(C, hs), v = !e.features.edition, Q = t < 40 * (6 + M.length), H = t < 40 * (3 + M.length), [Z, E] = I(!1), [D, P] = I(!1), [W, N] = I(!1), z = () => {
1440
+ E((y) => !y);
1441
+ }, B = () => {
1442
+ N((y) => !y);
1443
+ }, U = (y) => {
1444
+ c(y), E(!1);
1445
+ }, L = (y) => {
1446
+ U(C.find((S) => S.id === y) ?? i);
1447
+ }, m = C.find((y) => y.type === i.type) !== void 0;
1448
+ return O(xe, { children: [O("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [O("div", { className: "react-paint-editor-toolbar-shrinkable", children: [p(ve, { type: Ae, disabled: v, img: Ae.icon, isActive: i.id === Ae.id, setActive: U }), (e.size === "infinite" || e.features.zoom) && p(ve, { type: Ot, disabled: v, img: Ot.icon, isActive: i.id === Ot.id, setActive: U }), H ? p(X, { disabled: v, onClick: z, title: "Toggle tools", icon: '<svg><path d="M5.333 9.292 10.021 1.646 14.708 9.292ZM14.562 18.333Q13 18.333 11.896 17.229Q10.792 16.125 10.792 14.562Q10.792 13 11.896 11.896Q13 10.792 14.562 10.792Q16.125 10.792 17.229 11.896Q18.333 13 18.333 14.562Q18.333 16.125 17.229 17.229Q16.125 18.333 14.562 18.333ZM2.5 17.917V11.188H9.229V17.917ZM14.562 16.583Q15.438 16.583 16.01 16.01Q16.583 15.438 16.583 14.562Q16.583 13.688 16.01 13.115Q15.438 12.542 14.562 12.542Q13.688 12.542 13.115 13.115Q12.542 13.688 12.542 14.562Q12.542 15.438 13.115 16.01Q13.688 16.583 14.562 16.583ZM4.25 16.167H7.479V12.938H4.25ZM8.458 7.542H11.583L10.021 5ZM10.021 7.542ZM7.479 12.938ZM14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Q14.562 14.562 14.562 14.562Z"/></svg>', selected: m }) : M.map((y) => p(cs, { disabled: v, activeTool: i, group: y, setActiveToolFromId: L }, "id" in y ? y.id : y.title))] }), !Q && O(xe, { children: [p(ve, { type: je, disabled: v || !n, img: je.icon, isActive: i.id === je.id, setActive: h }), p(ve, { type: Ke, disabled: v || !s, img: Ke.icon, isActive: i.id === Ke.id, setActive: d }), p(ve, { type: Je, disabled: v || !a, img: Je.icon, isActive: i.id === Je.id, setActive: l })] }), p(rs, { withActionsInMenu: Q, disabled: v, vertical: !0, alignment: "right", group: { title: "Menu", img: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }, activeTool: i, addPicture: u, loadFile: g, saveFile: f, togglePictureUrlModal: () => {
1449
+ P(!0);
1450
+ }, toggleExportModal: B, withUploadPicture: b, withUrlPicture: x, withLoadAndSave: o, withExport: r, hasActionToUndo: n, hasActionToRedo: s, hasActionToClear: a, undoAction: h, redoAction: d, clearCanvas: l })] }), Z && p(Tt, { className: "react-paint-editor-toolbar-modal", onClose: z, title: "Outils", children: C.map((y) => y.type === "picture" ? null : p(ve, { disabled: v, type: y, img: y.icon, withText: !1, isActive: i.id === y.id, setActive: U }, y.id)) }), D && p(ls, { togglePictureUrlModal: () => {
1451
+ P((y) => !y);
1452
+ }, addPicture: u }), W && p(ds, { toggleExportModal: B, exportCanvasInFile: w })] });
1453
+ }, Ct = { none: 0, small: 10, medium: 20, large: 40 }, ps = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, gs = () => {
1454
+ const e = j([]), [t, i] = I([]);
1455
+ return q(() => () => {
1241
1456
  for (const n of e.current) clearTimeout(n);
1242
- }, []), { snackbarList: i, addSnackbar: ({ type: n = cn, duration: s = hn, text: a }) => {
1243
- const r = { id: re("snackbar_"), duration: s, type: n, text: a };
1244
- t((o) => [...o, r]), e.current = [...e.current, setTimeout(() => {
1245
- return o = r.id, void t((l) => l.filter((h) => h.id !== o));
1246
- var o;
1457
+ }, []), { snackbarList: t, addSnackbar: ({ type: n = Ua, duration: s = Xa, text: a }) => {
1458
+ const o = { id: ce("snackbar_"), duration: s, type: n, text: a };
1459
+ i((r) => [...r, o]), e.current = [...e.current, setTimeout(() => {
1460
+ return r = o.id, void i((l) => l.filter((c) => c.id !== r));
1461
+ var r;
1247
1462
  }, s)];
1248
1463
  } };
1249
- }, En = ({ editorProps: e, className: i, style: t, options: n, children: s }) => {
1250
- const { shapesRef: a, addPictureShape: r, moveShapes: o, toggleShapeVisibility: l, toggleShapeLock: h, canGoBackward: d, canGoForward: c, canClear: u, selectedShape: g, removeShape: f, updateShape: x, backwardShape: w, forwardShape: Q, refs: L, width: b, height: k, canvasSize: P, selectTool: E, selectShape: H, activeTool: T, setActiveTool: C, setAvailableTools: V, isEditMode: I, isDisabled: y, availableTools: N, gridGap: M, setGridGap: A, loadFile: Z, exportPicture: v, exportData: m, clearCanvas: S, settings: W, canvas: { canGrow: z, layersManipulation: O, withExport: X, withLoadAndSave: D, withUploadPicture: U, withUrlPicture: le } } = e, { toolbarBackgroundColor: te, dividerColor: ie, fontRadius: fe, fontDisabledColor: Me, fontDisabledBackgroundColor: ne, fontColor: _, fontBackgroundColor: Se, fontSelectedColor: Ze, fontSelectedBackgroundColor: ke, fontHoverColor: me, fontHoverBackgroundColor: be } = { ...Vn, ...n }, [Ee, oe] = $(!1), [Le, Ne] = $(!1), he = M >= pt.large ? "large" : M >= pt.medium ? "medium" : M >= pt.small ? "small" : "none", { snackbarList: ye, addSnackbar: ae } = Pn(), Ve = F((K, se, Be) => {
1251
- V((Re) => Re.map((tt) => tt.id === K ? de(["settings", se, "default"], Be, tt) : tt)), C((Re) => Re.id === K ? de(["settings", se, "default"], Be, Re) : Re);
1252
- }, [C, V]), $e = F(() => {
1253
- E(Ae), w();
1254
- }, [E, w]), Pe = F(() => {
1255
- E(Ae), Q();
1256
- }, [E, Q]), Ue = F(() => {
1257
- oe(!0);
1464
+ }, Qs = ({ editorProps: e, className: t, style: i, options: n, children: s }) => {
1465
+ const { shapesRef: a, addPictureShape: o, moveShapes: r, toggleShapeVisibility: l, toggleShapeLock: c, canGoBackward: h, canGoForward: d, canClear: u, selectedShape: g, removeShape: f, updateShape: w, backwardShape: C, forwardShape: x, refs: b, width: M, height: v, selectTool: Q, selectShape: H, activeTool: Z, setActiveTool: E, setAvailableTools: D, isEditMode: P, availableTools: W, gridGap: N, setGridGap: z, loadFile: B, exportPicture: U, exportData: L, clearCanvas: m, settings: y, setCanvasZoom: S, canvas: { canGrow: V, layersManipulation: T, withExport: k, withLoadAndSave: F, withUploadPicture: A, withUrlPicture: te } } = e, { toolbarBackgroundColor: ne, dividerColor: Y, fontRadius: K, fontDisabledColor: G, fontDisabledBackgroundColor: oe, fontColor: ee, fontBackgroundColor: ie, fontSelectedColor: ye, fontSelectedBackgroundColor: we, fontHoverColor: se, fontHoverBackgroundColor: Qe } = { ...ps, ...n }, Ee = y.size === "infinite" || y.features.zoom, [De, he] = I(!1), [We, pe] = I(!1), [re, Ze] = I(Ee), ke = Ee && re, Ge = N >= Ct.large ? "large" : N >= Ct.medium ? "medium" : N >= Ct.small ? "small" : "none", { snackbarList: Ne, addSnackbar: Ce } = gs(), pt = R((le, de, vt) => {
1466
+ D((Te) => Te.map((Re) => Re.id === le ? me(["settings", de, "default"], vt, Re) : Re)), E((Te) => Te.id === le ? me(["settings", de, "default"], vt, Te) : Te);
1467
+ }, [E, D]), gt = R((le) => {
1468
+ he(!0);
1258
1469
  try {
1259
- v(), oe(!1);
1260
- } catch (K) {
1261
- K instanceof Error && ae({ type: "error", text: "L'export a échoué" }), console.warn(K);
1470
+ U(le);
1471
+ } catch (de) {
1472
+ de instanceof Error && Ce({ type: "error", text: `L'export a échoué : ${de.message}` }), console.warn(de);
1262
1473
  } finally {
1263
- oe(!1);
1474
+ he(!1);
1264
1475
  }
1265
- }, [v, ae]), lt = F(() => {
1266
- oe(!0);
1476
+ }, [U, Ce]), ft = R(() => {
1477
+ he(!0);
1267
1478
  try {
1268
- m(), oe(!1);
1269
- } catch (K) {
1270
- K instanceof Error && ae({ type: "error", text: "L'enregistrement a échoué" }), console.warn(K);
1479
+ L(), he(!1);
1480
+ } catch (le) {
1481
+ le instanceof Error && Ce({ type: "error", text: "L'enregistrement a échoué" }), console.warn(le);
1271
1482
  } finally {
1272
- oe(!1);
1483
+ he(!1);
1273
1484
  }
1274
- }, [m, ae]), Ct = F(async (K) => {
1275
- oe(!0);
1485
+ }, [L, Ce]), At = R(async (le) => {
1486
+ he(!0);
1276
1487
  try {
1277
- await Z(K), ae({ type: "success", text: "Fichier chargé !" });
1278
- } catch (se) {
1279
- se instanceof Error && ae({ type: "error", text: "Le chargement a échoué" }), console.warn(se);
1488
+ await B(le), Ce({ type: "success", text: "Fichier chargé !" });
1489
+ } catch (de) {
1490
+ de instanceof Error && Ce({ type: "error", text: "Le chargement a échoué" }), console.warn(de);
1280
1491
  } finally {
1281
- oe(!1);
1492
+ he(!1);
1282
1493
  }
1283
- }, [Z, ae]), wt = F(async (K) => {
1284
- oe(!0);
1494
+ }, [B, Ce]), Et = R(async (le) => {
1495
+ he(!0);
1285
1496
  try {
1286
- const se = await r(K, b, k);
1287
- H(se);
1288
- } catch (se) {
1289
- se instanceof Error && ae({ type: "error", text: "Le chargement a échoué" }), console.warn(se);
1497
+ const de = await o(le, M, v);
1498
+ H(de);
1499
+ } catch (de) {
1500
+ de instanceof Error && Ce({ type: "error", text: "Le chargement a échoué" }), console.warn(de);
1290
1501
  } finally {
1291
- oe(!1);
1502
+ he(!1);
1292
1503
  }
1293
- }, [r, H, ae, b, k]), xt = `${i ? `${i} ` : ""}${Le ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1294
- return R("div", { ref: L.setEditor, className: xt, style: { "--react-paint-editor-app-maxWidth": z ? "100%" : `${b}px`, "--react-paint-editor-app-toolbar-bg": te, "--react-paint-editor-app-divider-color": ie, "--react-paint-editor-app-font-radius": fe, "--react-paint-editor-app-font-disabled-color": Me, "--react-paint-editor-app-font-disabled-bg": ne, "--react-paint-editor-app-font-color": _, "--react-paint-editor-app-font-bg": Se, "--react-paint-editor-app-font-selected-color": Ze, "--react-paint-editor-app-font-selected-bg": ke, "--react-paint-editor-app-font-hover-color": me, "--react-paint-editor-app-font-hover-bg": be, ...t }, children: [I && p(Ln, { width: P.width, disabled: y, activeTool: T, clearCanvas: S, setActiveTool: E, exportCanvasInFile: Ue, saveFile: lt, loadFile: Ct, addPicture: wt, hasActionToUndo: d, hasActionToRedo: c, hasActionToClear: u, undoAction: $e, redoAction: Pe, availableTools: N, withExport: X, withLoadAndSave: D, withUploadPicture: U, withUrlPicture: le }), s, I && O && p(fn, { gridFormat: he, setGridFormat: (K) => {
1295
- A(pt[K]);
1296
- }, disabled: y, shapes: a.current, moveShapes: o, selectedShape: g, removeShape: f, selectShape: H, toggleShapeVisibility: l, toggleShapeLock: h, isLayoutPanelShown: Le }), I && R(pe, { children: [p(Cn, { width: P.width, disabled: y, activeTool: T, availableTools: N, selectedShape: g, settings: W, removeShape: f, updateShape: x, canvas: L.canvas.current, layersManipulation: O, toggleLayoutPanel: () => {
1297
- Ne((K) => !K);
1298
- }, updateToolSettings: Ve }), p(dn, { isLoading: Ee }), p(un, { snackbarList: ye })] })] });
1504
+ }, [o, H, Ce, M, v]), Dt = `${t ? `${t} ` : ""}${We ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1505
+ return O("div", { ref: b.setEditor, className: Dt, style: { "--react-paint-editor-app-maxWidth": V ? "100%" : `${M}px`, "--react-paint-editor-app-toolbar-bg": ne, "--react-paint-editor-app-divider-color": Y, "--react-paint-editor-app-font-radius": K, "--react-paint-editor-app-font-disabled-color": G, "--react-paint-editor-app-font-disabled-bg": oe, "--react-paint-editor-app-font-color": ee, "--react-paint-editor-app-font-bg": ie, "--react-paint-editor-app-font-selected-color": ye, "--react-paint-editor-app-font-selected-bg": we, "--react-paint-editor-app-font-hover-color": se, "--react-paint-editor-app-font-hover-bg": Qe, ...i }, children: [P && p(us, { settings: y, width: y.canvasSize.width, activeTool: Z, clearCanvas: m, setActiveTool: Q, exportCanvasInFile: gt, saveFile: ft, loadFile: At, addPicture: Et, hasActionToUndo: h, hasActionToRedo: d, hasActionToClear: u, undoAction: C, redoAction: x, availableTools: W, withExport: k, withLoadAndSave: F, withUploadPicture: A, withUrlPicture: te }), s, P && T && p(ja, { gridFormat: Ge, setGridFormat: (le) => {
1506
+ z(Ct[le]);
1507
+ }, shapes: a.current, moveShapes: r, selectedShape: g, removeShape: f, selectShape: H, toggleShapeVisibility: l, toggleShapeLock: c, isLayoutPanelShown: We, settings: y }), ke && O(qe, { alignment: "left", className: "react-paint-editor-layouts-panel", "data-edit": +P, children: [p(X, { className: "react-paint-editor-zoom-button", icon: '<svg viewBox="0 -960 960 960" width="24px"><path d="M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400ZM280-540v-80h200v80H280Z"/></svg>', onClick: () => S("unzoom") }), O(X, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => S("default"), children: [Math.round(100 * y.canvasZoom), "%"] }), p(X, { className: "react-paint-editor-zoom-button", icon: dn, onClick: () => S("zoom") })] }), P && O(xe, { children: [p(os, { setCanvasZoom: S, width: y.canvasSize.width, activeTool: Z, availableTools: W, selectedShape: g, settings: y, removeShape: f, updateShape: w, canvas: b.canvas.current, layersManipulation: T, toggleLayoutPanel: () => {
1508
+ pe((le) => !le);
1509
+ }, isZoomPanelShown: ke, setIsZoomPanelShown: Ze, updateToolSettings: pt }), p(Ba, { isLoading: De }), p(qa, { snackbarList: Ne })] })] });
1299
1510
  };
1300
1511
  export {
1301
- Zn as Canvas,
1302
- En as Editor,
1303
- An as useReactPaint
1512
+ ys as Canvas,
1513
+ Qs as Editor,
1514
+ ms as useReactPaint
1304
1515
  };