@yorab/react-paint 0.17.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,69 +1,72 @@
1
- import ki, { useState as K, useEffect as le, useRef as re, useCallback as X, useMemo as Fn, useImperativeHandle as Yn, useTransition as Xn } from "react";
2
- import { jsx as v, jsxs as G, Fragment as Ne } from "react/jsx-runtime";
3
- const $n = '<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>', Li = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', Vi = '<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>', Zi = '<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>', Un = '<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>', qi = '<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>', zi = '<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>', qn = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', Gn = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', Gi = '<svg viewBox="0 -960 960 960"><path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"/></svg>', _n = '<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>', _i = '<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>', ji = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', Ki = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', Ji = '<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>', en = '<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>', jn = '<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>', De = ["transparent", "black", "white", "red", "green", "blue", "yellow"], lt = [0, 1, 2], tn = [[1, 0], [1, 2], [4, 6]], It = "serif", jo = 2, Kn = 3, Ko = 4, Qe = "react-paint-", Jn = { strokeColor: { values: De, default: "black" }, fillColor: { values: De, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } }, Ai = { type: "picture", id: `${Qe}picture`, icon: zi, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, eo = { type: "brush", id: `${Qe}brush`, icon: $n, label: "Brosse", settings: { strokeColor: { values: De, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: lt, default: 0 } } }, to = { type: "line", id: `${Qe}line`, icon: Gn, label: "Ligne", settings: { strokeColor: { values: De, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, io = { type: "polygon", id: `${Qe}polygon`, icon: Zi, label: "Polygone", settings: { strokeColor: { values: De, default: "black" }, fillColor: { values: De, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 }, closedPoints: { default: 0 } } }, no = { type: "curve", id: `${Qe}curve`, icon: _n, label: "Courbe", settings: { strokeColor: { values: De, default: "black" }, fillColor: { values: De, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 }, closedPoints: { default: 0 } } }, oo = { type: "rect", id: `${Qe}rect`, icon: Li, label: "Rectangle", settings: Jn }, ao = { type: "square", id: `${Qe}square`, icon: Li, label: "Carré", settings: { strokeColor: { values: De, default: "black" }, fillColor: { values: De, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } } }, so = { type: "circle", id: `${Qe}circle`, icon: Vi, label: "Cercle", settings: { strokeColor: { values: De, default: "black" }, fillColor: { values: De, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } } }, ro = { type: "ellipse", id: `${Qe}ellipse`, icon: Vi, label: "Ellipse", settings: { strokeColor: { values: De, default: "black" }, fillColor: { values: De, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } } }, lo = { type: "text", id: `${Qe}text`, icon: qn, label: "Texte", settings: { strokeColor: { values: De, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: It }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Je = { id: `${Qe}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" }, kt = { id: `${Qe}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" }, Lt = { id: `${Qe}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" }, Vt = { id: `${Qe}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" }, ci = { id: `${Qe}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" }, nn = { id: `${Qe}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" }, hi = { id: `${Qe}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" }, pi = { id: `${Qe}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" }, on = { id: `${Qe}upload-picture`, type: "uploadpicture", icon: zi, label: "Upload picture" }, co = 2, ho = "blue", gt = 14, po = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], uo = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"], Jo = ["rect", "square", "circle", "ellipse", "picture", "text", "triangle", "brush", "group"], ea = ["square", "circle", "picture", "text"], go = "react-paint-canvas-drawcanvas", fo = "react-paint-canvas-selectioncanvas", an = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, withContextMenu: !0, availableTools: [eo, to, io, no, oo, ao, so, ro, Ai, lo], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !0, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never", debug: !1 }, ta = { canvasBackgroundColor: "white", canvasSelectionColor: ho, canvasSelectionWidth: co }, sn = 300, yi = (e, t) => {
1
+ import Pi, { useState as J, useEffect as de, useRef as ce, useCallback as G, useMemo as Yn, useImperativeHandle as Xn, useTransition as $n } from "react";
2
+ import { jsx as v, jsxs as K, Fragment as Oe } from "react/jsx-runtime";
3
+ const Un = '<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>', Li = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>', Vi = '<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>', Zi = '<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>', qn = '<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>', qi = '<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>', Hi = '<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>', Gn = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.292V16.667Z"/></svg>', _n = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>', Gi = '<svg viewBox="0 -960 960 960"><path d="M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z"/></svg>', jn = '<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>', _i = '<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>', ji = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>', Ki = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>', Ji = '<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>', en = '<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>', Kn = '<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>', Ee = ["transparent", "black", "white", "red", "green", "blue", "yellow"], lt = [0, 1, 2], tn = [[1, 0], [1, 2], [4, 6]], It = "serif", ao = 2, Jn = 3, oo = 4, Me = "react-paint-", ea = { strokeColor: { values: Ee, default: "black" }, fillColor: { values: Ee, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } }, zi = { type: "picture", id: `${Me}picture`, icon: Hi, label: "Image", settings: { opacity: { min: 0, max: 100, step: 1, default: 100 } } }, ta = { type: "brush", id: `${Me}brush`, icon: Un, label: "Brosse", settings: { strokeColor: { values: Ee, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 6, max: 20, step: 2, default: 10 }, lineDash: { values: lt, default: 0 } } }, ia = { type: "line", id: `${Me}line`, icon: _n, label: "Ligne", settings: { strokeColor: { values: Ee, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 }, lineArrow: { values: [0, 1, 2, 3], default: 0 } } }, na = { type: "polygon", id: `${Me}polygon`, icon: Zi, label: "Polygone", settings: { strokeColor: { values: Ee, default: "black" }, fillColor: { values: Ee, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 }, closedPoints: { default: 0 } } }, aa = { type: "curve", id: `${Me}curve`, icon: jn, label: "Courbe", settings: { strokeColor: { values: Ee, default: "black" }, fillColor: { values: Ee, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 }, closedPoints: { default: 0 } } }, oa = { type: "rect", id: `${Me}rect`, icon: Li, label: "Rectangle", settings: ea }, sa = { type: "square", id: `${Me}square`, icon: Li, label: "Carré", settings: { strokeColor: { values: Ee, default: "black" }, fillColor: { values: Ee, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } } }, ra = { type: "circle", id: `${Me}circle`, icon: Vi, label: "Cercle", settings: { strokeColor: { values: Ee, default: "black" }, fillColor: { values: Ee, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } } }, la = { type: "ellipse", id: `${Me}ellipse`, icon: Vi, label: "Ellipse", settings: { strokeColor: { values: Ee, default: "black" }, fillColor: { values: Ee, default: "transparent" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, lineWidth: { min: 1, max: 20, step: 1, default: 1 }, lineDash: { values: lt, default: 0 } } }, ca = { type: "text", id: `${Me}text`, icon: Gn, label: "Texte", settings: { strokeColor: { values: Ee, default: "black" }, opacity: { min: 0, max: 100, step: 1, default: 100 }, fontFamily: { values: ["arial", "serif", "monospace"], default: It }, fontBold: { values: [!1, !0], default: !1 }, fontItalic: { values: [!1, !0], default: !1 } } }, Je = { id: `${Me}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" }, Pt = { id: `${Me}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" }, Lt = { id: `${Me}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" }, Vt = { id: `${Me}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" }, di = { id: `${Me}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" }, nn = { id: `${Me}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" }, hi = { id: `${Me}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" }, ui = { id: `${Me}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" }, an = { id: `${Me}upload-picture`, type: "uploadpicture", icon: Hi, label: "Upload picture" }, da = 2, ha = "blue", gt = 14, ua = [[0, 0], [0.5, 0], [1, 0], [1, 0.5], [1, 1], [0.5, 1], [0, 1], [0, 0.5]], pa = ["brush", "rect", "square", "line", "polygon", "circle", "curve", "ellipse", "picture", "text", "triangle", "group"], so = ["rect", "square", "circle", "ellipse", "picture", "text", "triangle", "brush", "group"], ro = ["square", "circle", "picture", "text"], ga = "react-paint-canvas-drawcanvas", fa = "react-paint-canvas-selectioncanvas", on = { layersManipulation: !0, grid: 0, canGrow: !1, canShrink: !0, withExport: !0, withLoadAndSave: !0, withUploadPicture: !0, withUrlPicture: !1, withContextMenu: !0, availableTools: [ta, ia, na, aa, oa, sa, ra, la, zi, ca], clearCallback: "empty", brushAlgo: "simple", isBrushShapeDoneOnMouseUp: !0, withFrameSelection: !0, withSkeleton: !0, canvasSelectionPadding: 0, size: "fixed", canZoom: "never", debug: !1 }, lo = { canvasBackgroundColor: "white", canvasSelectionColor: ha, canvasSelectionWidth: da }, sn = 300, Si = (e, t) => {
4
4
  const i = { ...t };
5
5
  for (const n of e) Array.isArray(n) ? n[1].includes(i[n[0]]) && delete i[n[0]] : delete i[n];
6
6
  return i;
7
7
  }, Xe = (e, t, i) => {
8
- const n = Array.isArray(i) ? [...i] : { ...i }, o = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
9
- return o.reduce((a, r, l) => (a[r] = bi(a[r]) ? { ...a[r] } : Array.isArray(a[r]) ? [...a[r]] : a[r] === void 0 || a[r] === null ? {} : a[r], l === o.length - 1 && (a[r] = t), a[r]), n), n;
8
+ const n = Array.isArray(i) ? [...i] : { ...i }, a = Array.isArray(e) ? e : typeof e == "string" ? e.split(".") : [e];
9
+ return a.reduce((o, r, l) => (o[r] = bi(o[r]) ? { ...o[r] } : Array.isArray(o[r]) ? [...o[r]] : o[r] === void 0 || o[r] === null ? {} : o[r], l === a.length - 1 && (o[r] = t), o[r]), n), n;
10
10
  }, bi = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Ke = (e, t, i) => {
11
11
  if (!bi(t) || !bi(i)) return i;
12
12
  const n = { ...t };
13
- for (const o in i) i.hasOwnProperty(o) && (n.hasOwnProperty(o) ? n[o] = e(n[o], i[o], o) ?? Ke(e, n[o], i[o]) : n[o] = i[o]);
13
+ for (const a in i) i.hasOwnProperty(a) && (n.hasOwnProperty(a) ? n[a] = e(n[a], i[a], a) ?? Ke(e, n[a], i[a]) : n[a] = i[a]);
14
14
  return n;
15
- }, vo = (e, t) => {
15
+ }, va = (e, t) => {
16
16
  if (e === t) return !0;
17
17
  if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
18
18
  const i = Object.keys(e), n = Object.keys(t);
19
19
  if (i.length !== n.length) return !1;
20
- for (const o of i) if (!n.includes(o) || !vo(e[o], t[o])) return !1;
20
+ for (const a of i) if (!n.includes(a) || !va(e[a], t[a])) return !1;
21
21
  return !0;
22
- }, ui = {}, Ce = (e = "") => (ui[e] || (ui[e] = 0), `${e}${++ui[e]}`), et = (e, t, i) => Math.max(t, Math.min(e, i)), mo = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), So = (e) => {
22
+ }, pi = {}, Le = (e = "") => (pi[e] || (pi[e] = 0), `${e}${++pi[e]}`), et = (e, t, i) => Math.max(t, Math.min(e, i)), ma = () => typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), ya = (e) => {
23
23
  e.reset(), e.lineCap = "round", e.lineJoin = "round";
24
- }, Te = (e, t = {}) => {
25
- const { lineCap: i = "round", fillColor: n = "transparent", opacity: o = 100, strokeColor: a = ho, lineWidth: r = co, lineDash: l = 0, shadowColor: s = "transparent", shadowBlur: d = 0 } = t;
26
- e.lineCap = i, e.globalAlpha = o / 100, e.fillStyle = n, e.strokeStyle = a, e.lineWidth = r, e.setLineDash(l === 0 ? [] : [tn[l][0] * r, tn[l][1] * r]), e.shadowColor = s, e.shadowBlur = d;
27
- }, Pt = (e, t, i, n) => {
24
+ }, De = (e, t = {}) => {
25
+ const { lineCap: i = "round", fillColor: n = "transparent", opacity: a = 100, strokeColor: o = ha, lineWidth: r = da, lineDash: l = 0, shadowColor: s = "transparent", shadowBlur: c = 0 } = t;
26
+ e.lineCap = i, e.globalAlpha = a / 100, e.fillStyle = n, e.strokeStyle = o, e.lineWidth = r, e.setLineDash(l === 0 ? [] : [tn[l][0] * r, tn[l][1] * r]), e.shadowColor = s, e.shadowBlur = c;
27
+ }, kt = (e, t, i, n) => {
28
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
- }, Qi = (e) => 180 * e / Math.PI, yo = (e, t) => {
29
+ }, Qi = (e) => 180 * e / Math.PI, Sa = (e, t) => {
30
30
  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);
31
31
  return Math.sqrt(i * i + n * n) <= t.radius;
32
- }, me = ({ origin: e = [0, 0], point: t, rotation: i = 0 }) => {
32
+ }, Qe = ({ origin: e = [0, 0], point: t, rotation: i = 0 }) => {
33
33
  if (i === 0) return t;
34
- const n = [t[0] - e[0], t[1] - e[1]], o = n[1] * Math.cos(i) - n[0] * Math.sin(i);
35
- return [n[1] * Math.sin(i) + n[0] * Math.cos(i) + e[0], o + e[1]];
34
+ const n = [t[0] - e[0], t[1] - e[1]], a = n[1] * Math.cos(i) - n[0] * Math.sin(i);
35
+ return [n[1] * Math.sin(i) + n[0] * Math.cos(i) + e[0], a + e[1]];
36
36
  }, rn = (e) => (e + 2 * Math.PI) % (2 * Math.PI), ln = ({ targetVector: [e, t], radian: i = !0, originVector: n }) => {
37
- const o = rn(Math.atan2(t[1] - e[1], t[0] - e[0]));
37
+ const a = rn(Math.atan2(t[1] - e[1], t[0] - e[0]));
38
38
  if (n) {
39
- const [a, r] = n, l = Math.atan2(r[1] - a[1], r[0] - a[0]), s = rn(o - l);
39
+ const [o, r] = n, l = Math.atan2(r[1] - o[1], r[0] - o[0]), s = rn(a - l);
40
40
  return i ? s : Qi(s);
41
41
  }
42
- return i ? o : Qi(o);
43
- }, bo = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), vt = (e, t, i) => {
44
- const n = me({ origin: t.computed.center, point: e.computed.center, rotation: t.rotation ?? 0 }), o = (n[0] - (e.computed.borders.width / 2 - i.settings.selectionPadding) - (i.originalBorders.x + i.settings.selectionPadding)) * i.widthMultiplier, a = (n[1] - (e.computed.borders.height / 2 - i.settings.selectionPadding) - (i.originalBorders.y + i.settings.selectionPadding)) * i.heightMultiplier;
45
- return { x: i.newBorderX + i.settings.selectionPadding + (i.isXinverted ? i.newBorderWidth - 2 * i.settings.selectionPadding - (e.computed.borders.width - 2 * i.settings.selectionPadding || 1) * i.widthMultiplier - o : o), y: i.newBorderY + i.settings.selectionPadding + (i.isYinverted ? i.newBorderHeight - 2 * i.settings.selectionPadding - (e.computed.borders.height - 2 * i.settings.selectionPadding || 1) * i.heightMultiplier - a : a) };
46
- }, mt = (e, t, i, n, o) => me({ origin: e.groupCenter, point: [t + n / 2, i + o / 2], rotation: -e.rotation }), Hi = (e, { selectionPadding: t }) => {
47
- const i = e.points.flat(), n = Math.min(...i.map((s) => s[0])), o = Math.min(...i.map((s) => s[1])), a = i.map((s) => Ge(s, n, o, e.scaleX, e.scaleY)), r = Math.max(...a.map((s) => s[0])) + t, l = Math.max(...a.map((s) => s[1])) + t;
48
- return { x: n - t, width: r - n + t, y: o - t, height: l - o + t };
42
+ return i ? a : Qi(a);
43
+ }, ba = (e, t) => Math.sqrt((e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2), mt = (e, t, i) => {
44
+ const n = Qe({ origin: t.computed.center, point: e.computed.center, rotation: t.rotation ?? 0 }), a = (n[0] - (e.computed.borders.width / 2 - i.settings.selectionPadding) - (i.originalBorders.x + i.settings.selectionPadding)) * i.widthMultiplier, o = (n[1] - (e.computed.borders.height / 2 - i.settings.selectionPadding) - (i.originalBorders.y + i.settings.selectionPadding)) * i.heightMultiplier;
45
+ return { x: i.newBorderX + i.settings.selectionPadding + (i.isXinverted ? i.newBorderWidth - 2 * i.settings.selectionPadding - (e.computed.borders.width - 2 * i.settings.selectionPadding || 1) * i.widthMultiplier - a : a), y: i.newBorderY + i.settings.selectionPadding + (i.isYinverted ? i.newBorderHeight - 2 * i.settings.selectionPadding - (e.computed.borders.height - 2 * i.settings.selectionPadding || 1) * i.heightMultiplier - o : o) };
46
+ }, yt = (e, t, i, n, a) => Qe({ origin: e.groupCenter, point: [t + n / 2, i + a / 2], rotation: -e.rotation }), Ai = (e, { selectionPadding: t }) => {
47
+ const i = e.points.flat(), n = Math.min(...i.map((s) => s[0])), a = Math.min(...i.map((s) => s[1])), o = i.map((s) => Ge(s, n, a, e.scaleX, e.scaleY)), r = Math.max(...o.map((s) => s[0])) + t, l = Math.max(...o.map((s) => s[1])) + t;
48
+ return { x: n - t, width: r - n + t, y: a - t, height: l - a + t };
49
49
  }, Zt = (e, t) => {
50
- const i = oa(e, t), n = ((o, a) => it(o, Hi, a))(e, t);
51
- return { ...e, path: i, selection: zt(i, n, t), computed: n };
52
- }, ia = Zt, We = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, Ge = (e, t, i, n = 1, o = 1) => [t + (e[0] - t) * n, i + (e[1] - i) * o], Ze = (e, t, i = 0) => {
53
- if (!t.gridGap) return We(e);
54
- const n = e + i, o = n >= 0 ? t.gridGap : -t.gridGap;
55
- return n + o / 2 - (n + o / 2) % o - i;
56
- }, na = (e, t, i, n, o, a, r) => {
57
- if (n.mode === "translate") return de(Do(i, n.originalShape, n.cursorStartPosition, o, a), o);
50
+ const i = uo(e, t), n = it(e, Ai, t);
51
+ return { ...e, path: i, selection: Ht(i, n, t), computed: n };
52
+ }, co = Zt, Qa = (e, t, i) => {
53
+ const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: r, heightMultiplier: l } = i, s = Ai({ ...e, scaleX: 1, scaleY: 1 }, o), c = s.width - 2 * o.selectionPadding, h = s.height - 2 * o.selectionPadding, d = e.scaleX ?? 1 ? (e.scaleX ?? 1) * r : r / c, u = e.scaleY ?? 1 ? (e.scaleY ?? 1) * l : l / h, p = c * d, f = h * u, m = mt(e, t, i), b = yt(i, m.x, m.y, p, f), x = Be(b[0] - p / 2 - e.computed.borders.x - o.selectionPadding) + (n ? 2 * e.computed.borders.x + s.width : 0), k = Be(b[1] - f / 2 - e.computed.borders.y - o.selectionPadding) + (a ? 2 * e.computed.borders.y + s.height : 0), M = (n || a) && !(n && a) && (e.rotation ?? 0) !== 0 && i.rotation !== e.rotation;
54
+ return Zt({ ...e, points: e.points.map((S) => S.map(([g, P]) => [n ? -g + x : g + x, a ? -P + k : P + k])), scaleX: d, scaleY: u, rotation: M ? -(e.rotation ?? 0) : e.rotation ?? 0 }, i.settings);
55
+ }, Be = (e, t = 2) => Math.round(e * 10 ** t) / 10 ** t, Ge = (e, t, i, n = 1, a = 1) => [t + (e[0] - t) * n, i + (e[1] - i) * a], ze = (e, t, i = 0) => {
56
+ if (!t.gridGap) return Be(e);
57
+ const n = e + i, a = n >= 0 ? t.gridGap : -t.gridGap;
58
+ return n + a / 2 - (n + a / 2) % a - i;
59
+ }, ho = (e, t, i, n, a, o, r) => {
60
+ if (n.mode === "translate") return pe(Oa(i, n.originalShape, n.cursorStartPosition, a, o), a);
58
61
  if (n.mode === "rotate") {
59
- const l = n.originalShape.computed.center[0] - n.cursorStartPosition[0], s = n.originalShape.computed.center[1] - n.cursorStartPosition[1], d = n.originalShape.computed.center[0] - i[0], h = n.originalShape.computed.center[1] - i[1], c = ((p, m, u) => m.gridGap || u ? p + Math.PI / 18 / 2 - (p + Math.PI / 18 / 2) % (Math.PI / 18) : We(p, 3))(Math.atan2(h, d) - Math.atan2(s, l), o, a), f = U(n.originalShape).map((p) => _e(Ho(p, c, n.originalShape.computed.center), o));
60
- return de(f, o);
62
+ const l = n.originalShape.computed.center[0] - n.cursorStartPosition[0], s = n.originalShape.computed.center[1] - n.cursorStartPosition[1], c = n.originalShape.computed.center[0] - i[0], h = n.originalShape.computed.center[1] - i[1], d = ((p, f, m) => f.gridGap || m ? p + Math.PI / 18 / 2 - (p + Math.PI / 18 / 2) % (Math.PI / 18) : Be(p, 3))(Math.atan2(h, c) - Math.atan2(s, l), a, o), u = _(n.originalShape).map((p) => _e(Na(p, d, n.originalShape.computed.center), a));
63
+ return pe(u, a);
61
64
  }
62
- return n.mode === "resize" ? de(Za(e, i, n.originalShape, n, o, a, r), o) : n.mode === "brush" ? de(U(t).map((l) => ((s, d, h) => {
63
- const c = { ...s, points: Xe(s.points.length - 1, [...s.points[s.points.length - 1], [Math.round(d[0]), Math.round(d[1])]], s.points) };
64
- return Zt(c, h);
65
- })(l, i, o)), o) : t;
66
- }, Rt = (e) => {
65
+ return n.mode === "resize" ? pe(Do(e, i, n.originalShape, n, a, o, r), a) : n.mode === "brush" ? pe(_(t).map((l) => ((s, c, h) => {
66
+ const d = { ...s, points: Xe(s.points.length - 1, [...s.points[s.points.length - 1], [Math.round(c[0]), Math.round(c[1])]], s.points) };
67
+ return Zt(d, h);
68
+ })(l, i, a)), a) : t;
69
+ }, Wt = (e) => {
67
70
  const t = new Path2D();
68
71
  return t.rect(e.x, e.y, e.width, e.height), t;
69
72
  }, Gt = (e) => {
@@ -72,65 +75,65 @@ const $n = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
72
75
  }, _t = (e) => {
73
76
  const t = new Path2D();
74
77
  return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t;
75
- }, oa = (e, { brushAlgo: t }) => {
78
+ }, uo = (e, { brushAlgo: t }) => {
76
79
  const i = new Path2D();
77
80
  if (e.points.length < 1) return i;
78
- const n = e.points.flat(), o = n.map((s) => s[0]), a = n.map((s) => s[1]), r = Math.min(...o), l = Math.min(...a);
81
+ const n = e.points.flat(), a = n.map((s) => s[0]), o = n.map((s) => s[1]), r = Math.min(...a), l = Math.min(...o);
79
82
  for (const s of e.points) if (s.length) if (s.length === 1) i.rect(...Ge(s[0], r, l, e.scaleX, e.scaleY), 1, 1);
80
83
  else if (i.moveTo(...Ge(s[0], r, l, e.scaleX, e.scaleY)), t === "quadratic") {
81
- for (let d = 0; d < s.slice(1).length - 2; d++) {
82
- const h = Ge(s[d], r, l, e.scaleX, e.scaleY), c = Ge(s[d + 1], r, l, e.scaleX, e.scaleY), f = (h[0] + c[0]) / 2, p = (h[1] + c[1]) / 2;
83
- i.quadraticCurveTo(...h, f, p);
84
+ for (let c = 0; c < s.slice(1).length - 2; c++) {
85
+ const h = Ge(s[c], r, l, e.scaleX, e.scaleY), d = Ge(s[c + 1], r, l, e.scaleX, e.scaleY), u = (h[0] + d[0]) / 2, p = (h[1] + d[1]) / 2;
86
+ i.quadraticCurveTo(...h, u, p);
84
87
  }
85
88
  i.quadraticCurveTo(...Ge(s[s.length - 2], r, l, e.scaleX, e.scaleY), ...Ge(s[s.length - 1], r, l, e.scaleX, e.scaleY));
86
- } else for (const d of s.slice(1)) i.lineTo(...Ge(d, r, l, e.scaleX, e.scaleY));
89
+ } else for (const c of s.slice(1)) i.lineTo(...Ge(c, r, l, e.scaleX, e.scaleY));
87
90
  return i;
88
- }, aa = (e, t, i, n) => {
89
- const o = (g) => (1 - g) ** 3 * e[0] + 3 * (1 - g) ** 2 * g * t[0] + 3 * (1 - g) * g ** 2 * i[0] + g ** 3 * n[0], a = (g) => (1 - g) ** 3 * e[1] + 3 * (1 - g) ** 2 * g * t[1] + 3 * (1 - g) * g ** 2 * i[1] + g ** 3 * n[1], r = (g, P, z) => {
90
- const D = g - 2 * P + z, A = -2 * g + 2 * P, H = g;
91
- if (Math.abs(D) < 1e-10) {
92
- if (Math.abs(A) < 1e-10) return [];
93
- const oe = -H / A;
94
- return oe > 0 && oe < 1 ? [oe] : [];
91
+ }, po = (e, t, i, n) => {
92
+ const a = (g) => (1 - g) ** 3 * e[0] + 3 * (1 - g) ** 2 * g * t[0] + 3 * (1 - g) * g ** 2 * i[0] + g ** 3 * n[0], o = (g) => (1 - g) ** 3 * e[1] + 3 * (1 - g) ** 2 * g * t[1] + 3 * (1 - g) * g ** 2 * i[1] + g ** 3 * n[1], r = (g, P, z) => {
93
+ const N = g - 2 * P + z, D = -2 * g + 2 * P, E = g;
94
+ if (Math.abs(N) < 1e-10) {
95
+ if (Math.abs(D) < 1e-10) return [];
96
+ const Z = -E / D;
97
+ return Z > 0 && Z < 1 ? [Z] : [];
95
98
  }
96
- const Z = A * A - 4 * D * H;
97
- if (Z < 0) return [];
98
- const E = Math.sqrt(Z), F = (-A - E) / (2 * D), W = (-A + E) / (2 * D), I = [];
99
- return F > 0 && F < 1 && I.push(F), W > 0 && W < 1 && W !== F && I.push(W), I;
100
- }, l = e[0], s = t[0], d = i[0], h = n[0], c = e[1], f = t[1], p = i[1], m = n[1], u = r(s - l, d - s, h - d), S = r(f - c, p - f, m - p);
101
- let w = Math.min(e[0], n[0]), x = Math.max(e[0], n[0]), b = Math.min(e[1], n[1]), y = Math.max(e[1], n[1]);
102
- for (const g of u) {
103
- const P = o(g);
104
- w = Math.min(w, P), x = Math.max(x, P);
105
- }
106
- for (const g of S) {
99
+ const A = D * D - 4 * N * E;
100
+ if (A < 0) return [];
101
+ const T = Math.sqrt(A), B = (-D - T) / (2 * N), F = (-D + T) / (2 * N), X = [];
102
+ return B > 0 && B < 1 && X.push(B), F > 0 && F < 1 && F !== B && X.push(F), X;
103
+ }, l = e[0], s = t[0], c = i[0], h = n[0], d = e[1], u = t[1], p = i[1], f = n[1], m = r(s - l, c - s, h - c), b = r(u - d, p - u, f - p);
104
+ let x = Math.min(e[0], n[0]), k = Math.max(e[0], n[0]), M = Math.min(e[1], n[1]), S = Math.max(e[1], n[1]);
105
+ for (const g of m) {
107
106
  const P = a(g);
108
- b = Math.min(b, P), y = Math.max(y, P);
107
+ x = Math.min(x, P), k = Math.max(k, P);
109
108
  }
110
- return { minX: w, maxX: x, minY: b, maxY: y };
111
- }, Ti = (e, t) => e.style?.closedPoints === 1 && t.length > 2 ? [t[t.length - 2], ...t, t[0], t[1]] : [t[0], ...t, t[t.length - 1]], Di = (e, t, i, n) => ({ cp1: [t[0] + (i[0] - e[0]) / 6, t[1] + (i[1] - e[1]) / 6], cp2: [i[0] - (n[0] - t[0]) / 6, i[1] - (n[1] - t[1]) / 6] }), Qo = (e) => {
109
+ for (const g of b) {
110
+ const P = o(g);
111
+ M = Math.min(M, P), S = Math.max(S, P);
112
+ }
113
+ return { minX: x, maxX: k, minY: M, maxY: S };
114
+ }, Ti = (e, t) => e.style?.closedPoints === 1 && t.length > 2 ? [t[t.length - 2], ...t, t[0], t[1]] : [t[0], ...t, t[t.length - 1]], Di = (e, t, i, n) => ({ cp1: [t[0] + (i[0] - e[0]) / 6, t[1] + (i[1] - e[1]) / 6], cp2: [i[0] - (n[0] - t[0]) / 6, i[1] - (n[1] - t[1]) / 6] }), wa = (e) => {
112
115
  const t = new Path2D(), i = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
113
116
  if (i.length < 2) return t;
114
117
  t.moveTo(...i[0]);
115
118
  for (const n of i.slice(1)) t.lineTo(...n);
116
119
  return i.length > 2 && e.style?.closedPoints === 1 && t.lineTo(...i[0]), t;
117
- }, sa = (e) => {
120
+ }, go = (e) => {
118
121
  const t = new Path2D();
119
122
  return t.moveTo(...e.points[0]), t.lineTo(...e.points[1]), t.lineTo(...e.points[2]), t.lineTo(...e.points[0]), t;
120
- }, ra = (e, t) => ({ x: t.x - (e.style?.lineWidth ?? 0) / 2, y: t.y - (e.style?.lineWidth ?? 0) / 2, width: t.width + (e.style?.lineWidth ?? 0), height: t.height + (e.style?.lineWidth ?? 0) }), it = (e, t, i, n = ra) => {
121
- const o = t(e, i), a = n(e, o, i), r = [o.x + o.width / 2, o.y + o.height / 2], l = ((s, d, h = 0) => {
123
+ }, fo = (e, t) => ({ x: t.x - (e.style?.lineWidth ?? 0) / 2, y: t.y - (e.style?.lineWidth ?? 0) / 2, width: t.width + (e.style?.lineWidth ?? 0), height: t.height + (e.style?.lineWidth ?? 0) }), it = (e, t, i, n = fo) => {
124
+ const a = t(e, i), o = n(e, a, i), r = [a.x + a.width / 2, a.y + a.height / 2], l = ((s, c, h = 0) => {
122
125
  if (h === 0) return s;
123
- const c = [[s.x, s.y], [s.x + s.width, s.y], [s.x + s.width, s.y + s.height], [s.x, s.y + s.height]].map((m) => me({ point: m, origin: d, rotation: h })), f = Math.min(...c.map((m) => m[0])), p = Math.min(...c.map((m) => m[1]));
124
- return { x: f, y: p, width: Math.max(...c.map((m) => m[0])) - f, height: Math.max(...c.map((m) => m[1])) - p };
125
- })(a, r, e.rotation);
126
- return { borders: o, outerBorders: a, center: r, boundingBox: l };
127
- }, zt = (e, t, i) => {
126
+ const d = [[s.x, s.y], [s.x + s.width, s.y], [s.x + s.width, s.y + s.height], [s.x, s.y + s.height]].map((f) => Qe({ point: f, origin: c, rotation: h })), u = Math.min(...d.map((f) => f[0])), p = Math.min(...d.map((f) => f[1]));
127
+ return { x: u, y: p, width: Math.max(...d.map((f) => f[0])) - u, height: Math.max(...d.map((f) => f[1])) - p };
128
+ })(o, r, e.rotation);
129
+ return { borders: a, outerBorders: o, center: r, boundingBox: l };
130
+ }, Ht = (e, t, i) => {
128
131
  const { borders: n } = t;
129
- return { type: "rect", border: Rt(n), shapePath: e, line: _t({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: [Gt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...po.map((o) => Gt({ x: n.x + n.width * o[0], y: n.y + n.height * o[1], radius: 7 / i.canvasSize.scaleRatio }))] };
130
- }, dn = ({ borderStart: e, borderSize: t, vector: i, settings: n, invertedAxe: o, anchor: a }) => {
131
- switch (a) {
132
+ return { type: "rect", border: Wt(n), shapePath: e, line: _t({ points: [[n.x + n.width / 2, n.y], [n.x + n.width / 2, n.y - 23 / i.canvasSize.scaleRatio]] }), anchors: [Gt({ x: n.x + n.width / 2, y: n.y - 23 / i.canvasSize.scaleRatio, radius: 7 / i.canvasSize.scaleRatio }), ...ua.map((a) => Gt({ x: n.x + n.width * a[0], y: n.y + n.height * a[1], radius: 7 / i.canvasSize.scaleRatio }))] };
133
+ }, cn = ({ borderStart: e, borderSize: t, vector: i, settings: n, invertedAxe: a, anchor: o }) => {
134
+ switch (o) {
132
135
  case 0: {
133
- if (o) {
136
+ if (a) {
134
137
  const l = Math.max(0, i - t) + 2 * n.selectionPadding;
135
138
  return [e + t - 2 * n.selectionPadding, l];
136
139
  }
@@ -140,7 +143,7 @@ const $n = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
140
143
  case 0.5:
141
144
  return [e, t];
142
145
  case 1:
143
- if (o) {
146
+ if (a) {
144
147
  const r = Math.min(e, e + t + i);
145
148
  return [r, e - r + 2 * n.selectionPadding];
146
149
  }
@@ -148,314 +151,348 @@ const $n = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.70
148
151
  default:
149
152
  return [0, 0];
150
153
  }
151
- }, la = ({ borderX: e, borderWidth: t, borderY: i, borderHeight: n, center: o, originalShape: a }) => {
152
- const r = [e + t / 2 - o[0], i + n / 2 - o[1]], [l, s] = me({ point: r, rotation: -(a.rotation ?? 0) });
153
- return { borderX: We(e + l - r[0]), borderWidth: We(t), borderY: We(i + s - r[1]), borderHeight: We(n) };
154
- }, da = (e, t, i, n) => {
155
- const o = t.x + t.width / 2, a = t.y + t.height / 2, r = i ? 2 * e.borderWidth + t.width : Math.abs(t.width + 2 * (e.borderWidth - t.width)), l = n ? 2 * e.borderHeight + t.height : Math.abs(t.height + 2 * (e.borderHeight - t.height));
156
- return { ...e, borderHeight: l, borderWidth: r, borderX: o - r / 2, borderY: a - l / 2 };
157
- }, St = (e, t, i, n, o = !1, a = !1) => {
158
- const { center: r, borders: l } = t.computed, s = me({ origin: r, point: e, rotation: t.rotation }), d = i.anchor[0] === 0 && s[0] >= l.x + l.width - n.selectionPadding || i.anchor[0] === 1 && s[0] <= l.x + n.selectionPadding, h = i.anchor[1] === 0 && s[1] >= l.y + l.height - n.selectionPadding || i.anchor[1] === 1 && s[1] <= l.y + n.selectionPadding, c = [Ze(s[0], n, i.anchor[0] === 0 && !d || i.anchor[0] === 1 && d ? n.selectionPadding : -n.selectionPadding), Ze(s[1], n, i.anchor[1] === 0 && !h || i.anchor[1] === 1 && h ? n.selectionPadding : -n.selectionPadding)], f = n.gridGap ? [i.anchor[0] === 0 ? l.x : i.anchor[0] === 0.5 ? l.x + l.width / 2 : l.x + l.width, i.anchor[1] === 0 ? l.y : i.anchor[1] === 0.5 ? l.y + l.height / 2 : l.y + l.height] : me({ origin: r, point: i.cursorStartPosition, rotation: t.rotation }), p = [c[0] - f[0], c[1] - f[1]], [m, u] = dn({ borderStart: l.x, borderSize: l.width, vector: p[0], settings: n, invertedAxe: d, anchor: i.anchor[0] }), [S, w] = dn({ borderStart: l.y, borderSize: l.height, vector: p[1], settings: n, invertedAxe: h, anchor: i.anchor[1] }), x = o ? ((b, y, g, P, z, D, A, H, Z, E, F) => {
159
- const { selectionPadding: W } = F, I = "ratio" in Z && Z.ratio ? Z.ratio : (b.width - 2 * W || 1) / (b.height - 2 * W || 1), oe = (P - 2 * W) / (D - 2 * W);
160
- let te, R, $, j;
161
- return E.anchor[0] !== 0.5 && E.anchor[1] !== 0.5 ? oe < I ? (R = z, j = D, $ = (D - 2 * W) * I + 2 * W, te = E.anchor[0] === 0 ? A ? b.x + b.width - 2 * W : b.x + (b.width - $) : A ? b.x - $ + 2 * W : b.x) : (te = g, $ = P, j = (P - 2 * W) / I + 2 * W, R = E.anchor[1] === 0 ? H ? b.y + b.height - 2 * W : b.y + (b.height - j) : H ? b.y - j + 2 * W : b.y) : E.anchor[0] !== 0.5 ? (te = g, $ = P, j = (P - 2 * W) / I + 2 * W, R = b.y + (b.height - j) / 2) : (R = z, j = D, $ = (D - 2 * W) * I + 2 * W, te = b.x + (b.width - $) / 2), { borderX: te, borderWidth: $, borderY: R, borderHeight: j, center: y, originalShape: Z };
162
- })(l, r, m, u, S, w, d, h, t, i, n) : { borderX: m, borderWidth: u, borderY: S, borderHeight: w, center: r, originalShape: t };
163
- return { ...la(a ? da(x, l, d, h) : x), isXinverted: d, isYinverted: h };
154
+ }, dn = ({ borderX: e, borderWidth: t, borderY: i, borderHeight: n, center: a, originalShape: o }) => {
155
+ const r = [e + t / 2 - a[0], i + n / 2 - a[1]], [l, s] = Qe({ point: r, rotation: -(o.rotation ?? 0) });
156
+ return { borderX: Be(e + l - r[0]), borderWidth: Be(t), borderY: Be(i + s - r[1]), borderHeight: Be(n) };
157
+ }, vo = (e, t, i, n) => {
158
+ const a = t.x + t.width / 2, o = t.y + t.height / 2, r = i ? 2 * e.borderWidth + t.width : Math.abs(t.width + 2 * (e.borderWidth - t.width)), l = n ? 2 * e.borderHeight + t.height : Math.abs(t.height + 2 * (e.borderHeight - t.height));
159
+ return { ...e, borderHeight: l, borderWidth: r, borderX: a - r / 2, borderY: o - l / 2 };
160
+ }, vt = (e, t, i, n, a = !1, o = !1) => {
161
+ const { center: r, borders: l } = t.computed, s = Qe({ origin: r, point: e, rotation: t.rotation }), c = o && a ? [l.x + l.width / 2, l.x + l.width / 2] : [l.x + l.width - n.selectionPadding, l.x + n.selectionPadding], h = o && a ? [l.y + l.height / 2, l.y + l.height / 2] : [l.y + l.height - n.selectionPadding, l.y + n.selectionPadding], d = i.anchor[0] === 0 && s[0] >= c[0] || i.anchor[0] === 1 && s[0] <= c[1], u = i.anchor[1] === 0 && s[1] >= h[0] || i.anchor[1] === 1 && s[1] <= h[1], p = [ze(s[0], n, i.anchor[0] === 0 && !d || i.anchor[0] === 1 && d ? n.selectionPadding : -n.selectionPadding), ze(s[1], n, i.anchor[1] === 0 && !u || i.anchor[1] === 1 && u ? n.selectionPadding : -n.selectionPadding)];
162
+ if (a && o) {
163
+ const g = (({ roundCursorPosition: P, borders: z, center: N, selectionMode: D, originalShape: E, settings: A }) => {
164
+ const { selectionPadding: T } = A, B = Math.max(1, z.width - 2 * T), F = Math.max(1, z.height - 2 * T), X = "ratio" in E && E.ratio ? E.ratio : B / F, Z = z.x + z.width / 2, ne = z.y + z.height / 2;
165
+ let I = 1;
166
+ if (D.anchor[0] !== 0.5 && D.anchor[1] !== 0.5) {
167
+ const C = [(D.anchor[0] - 0.5) * B, (D.anchor[1] - 0.5) * F], $ = [P[0] - Z, P[1] - ne], Q = Math.hypot(C[0], C[1]) || 1;
168
+ I = Math.hypot($[0], $[1]) / Q;
169
+ } else if (D.anchor[0] === 0.5) {
170
+ const C = (D.anchor[1] - 0.5) * F, $ = P[1] - ne, Q = Math.abs(C) || 1;
171
+ I = Math.abs($) / Q;
172
+ } else {
173
+ const C = (D.anchor[0] - 0.5) * B, $ = P[0] - Z, Q = Math.abs(C) || 1;
174
+ I = Math.abs($) / Q;
175
+ }
176
+ const j = 2 * T / (B + 2 * T), ee = B * Math.max(I, j), se = ee + 2 * T, he = ee / X + 2 * T;
177
+ return { borderX: Z - se / 2, borderY: ne - he / 2, borderWidth: se, borderHeight: he, center: N, originalShape: E };
178
+ })({ roundCursorPosition: p, borders: l, center: r, selectionMode: i, originalShape: t, settings: n });
179
+ return { ...dn(g), isXinverted: d, isYinverted: u };
180
+ }
181
+ const f = n.gridGap ? [i.anchor[0] === 0 ? l.x : i.anchor[0] === 0.5 ? l.x + l.width / 2 : l.x + l.width, i.anchor[1] === 0 ? l.y : i.anchor[1] === 0.5 ? l.y + l.height / 2 : l.y + l.height] : Qe({ origin: r, point: i.cursorStartPosition, rotation: t.rotation }), m = [p[0] - f[0], p[1] - f[1]], [b, x] = cn({ borderStart: l.x, borderSize: l.width, vector: m[0], settings: n, invertedAxe: d, anchor: i.anchor[0] }), [k, M] = cn({ borderStart: l.y, borderSize: l.height, vector: m[1], settings: n, invertedAxe: u, anchor: i.anchor[1] }), S = a ? ((g, P, z, N, D, E, A, T, B, F, X) => {
182
+ const { selectionPadding: Z } = X, ne = "ratio" in B && B.ratio ? B.ratio : (g.width - 2 * Z || 1) / (g.height - 2 * Z || 1), I = (N - 2 * Z) / (E - 2 * Z);
183
+ let j, ee, se, he;
184
+ return F.anchor[0] !== 0.5 && F.anchor[1] !== 0.5 ? I < ne ? (ee = D, he = E, se = (E - 2 * Z) * ne + 2 * Z, j = F.anchor[0] === 0 ? A ? g.x + g.width - 2 * Z : g.x + (g.width - se) : A ? g.x - se + 2 * Z : g.x) : (j = z, se = N, he = (N - 2 * Z) / ne + 2 * Z, ee = F.anchor[1] === 0 ? T ? g.y + g.height - 2 * Z : g.y + (g.height - he) : T ? g.y - he + 2 * Z : g.y) : F.anchor[0] !== 0.5 ? (j = z, se = N, he = (N - 2 * Z) / ne + 2 * Z, ee = g.y + (g.height - he) / 2) : (ee = D, he = E, se = (E - 2 * Z) * ne + 2 * Z, j = g.x + (g.width - se) / 2), { borderX: j, borderWidth: se, borderY: ee, borderHeight: he, center: P, originalShape: B };
185
+ })(l, r, b, x, k, M, d, u, t, i, n) : { borderX: b, borderWidth: x, borderY: k, borderHeight: M, center: r, originalShape: t };
186
+ return { ...dn(o ? vo(S, l, d, u) : S), isXinverted: d, isYinverted: u };
164
187
  }, Kt = (e, t) => {
165
- const i = Rt(e), n = ((o, a) => it(o, Ei, a))(e, t);
166
- return { ...e, path: i, computed: n, selection: zt(i, n, t) };
167
- }, ca = Kt, wo = (e, t, i, n = 0, o = 0) => {
168
- const a = { toolId: e.id, type: e.type, id: Ce(`${e.type}_`), x: t[0], y: t[1], width: n, height: o, style: { opacity: e.settings.opacity.default, fillColor: e.settings.fillColor.default, strokeColor: e.settings.strokeColor.default, lineWidth: e.settings.lineWidth.default, lineDash: e.settings.lineDash.default } };
169
- return Kt(a, i);
170
- }, ha = (e, t) => {
188
+ const i = Wt(e), n = it(e, Ei, t);
189
+ return { ...e, path: i, computed: n, selection: Ht(i, n, t) };
190
+ }, mo = Kt, xa = (e, t, i, n = 0, a = 0) => {
191
+ const o = { toolId: e.id, type: e.type, id: Le(`${e.type}_`), x: t[0], y: t[1], width: n, height: a, style: { opacity: e.settings.opacity.default, fillColor: e.settings.fillColor.default, strokeColor: e.settings.strokeColor.default, lineWidth: e.settings.lineWidth.default, lineDash: e.settings.lineDash.default } };
192
+ return Kt(o, i);
193
+ }, yo = (e, t) => {
171
194
  e.globalAlpha !== 0 && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
172
- }, Ei = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), cn = (e, t, i, [n, o] = [!1, !1]) => {
173
- const a = e[0] === 0.5 ? i.x + i.width / 2 : e[0] === 0 ? i.x + (n ? 0 : i.width) : i.x + (n ? i.width : 0), r = e[1] === 0.5 ? i.y + i.height / 2 : e[1] === 0 ? i.y + (o ? 0 : i.height) : i.y + (o ? i.height : 0);
174
- return wi([a, r], i.rotation ?? 0, t);
175
- }, Bt = (e, t, i, n, o, a, r, l = "replace") => {
195
+ }, Ei = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), hn = (e, t, i, [n, a] = [!1, !1]) => {
196
+ const 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), r = e[1] === 0.5 ? i.y + i.height / 2 : e[1] === 0 ? i.y + (a ? 0 : i.height) : i.y + (a ? i.height : 0);
197
+ return wi([o, r], i.rotation ?? 0, t);
198
+ }, Ma = (e, t, i) => {
199
+ const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: r, heightMultiplier: l } = i, s = (n || a) && !(n && a) && (e.rotation ?? 0) !== 0 && i.rotation !== e.rotation, c = mt(e, t, i), h = (e.width || 1) * r, d = (e.height || 1) * l, u = yt(i, c.x, c.y, h, d);
200
+ return Kt({ ...e, width: h, height: d, x: u[0] - h / 2, y: u[1] - d / 2, rotation: s ? -(e.rotation ?? 0) : e.rotation ?? 0 }, o);
201
+ }, Ot = (e, t, i, n, a, o, r, l = "replace") => {
176
202
  let s = !1;
177
- if (o) {
178
- s = Et(e, o, i, n, !0, a ? 20 : void 0);
179
- const h = ((c, f, p) => {
180
- if (c.mode === "translate") return { mode: "translate", cursorStartPosition: p, originalShape: f, hasBeenDuplicated: !1, dateStart: Date.now(), selectedShapesLengthAtMouseDown: U(f).length };
181
- if (c.mode === "rotate") {
182
- const { center: m } = f.computed;
183
- return { mode: "rotate", cursorStartPosition: p, originalShape: f, center: [m[0], m[1]], selectedShapesLengthAtMouseDown: U(f).length };
203
+ if (a) {
204
+ s = Et(e, a, i, n, !0, o ? 20 : void 0);
205
+ const h = ((d, u, p) => {
206
+ if (d.mode === "translate") return { mode: "translate", cursorStartPosition: p, originalShape: u, hasBeenDuplicated: !1, dateStart: Date.now(), selectedShapesLengthAtMouseDown: _(u).length };
207
+ if (d.mode === "rotate") {
208
+ const { center: f } = u.computed;
209
+ return { mode: "rotate", cursorStartPosition: p, originalShape: u, center: [f[0], f[1]], selectedShapesLengthAtMouseDown: _(u).length };
184
210
  }
185
- return c.mode === "resize" ? { mode: "resize", cursorStartPosition: p, originalShape: f, anchor: c.anchor, selectedShapesLengthAtMouseDown: U(f).length } : void 0;
186
- })(s || { mode: "default" }, o, i);
187
- if (h?.mode === "resize" || h?.mode === "rotate") return { shape: o, mode: h };
211
+ return d.mode === "resize" ? { mode: "resize", cursorStartPosition: p, originalShape: u, anchor: d.anchor, selectedShapesLengthAtMouseDown: _(u).length } : void 0;
212
+ })(s || { mode: "default" }, a, i);
213
+ if (h?.mode === "resize" || h?.mode === "rotate") return { shape: a, mode: h };
188
214
  }
189
- const d = t.find((h) => U(o).find((c) => h.id === c?.id) ? s && Et(e, h, i, n, !0, a ? 20 : void 0) : !!Po(e, h, i, n)) ?? (s ? o : void 0);
190
- if (o && o?.id === d?.id) return { shape: o, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: o, selectedShapesLengthAtMouseDown: U(o).length } };
191
- if (d) {
215
+ const c = t.find((h) => _(a).find((d) => h.id === d?.id) ? s && Et(e, h, i, n, !0, o ? 20 : void 0) : !!La(e, h, i, n)) ?? (s ? a : void 0);
216
+ if (a && a?.id === c?.id) return { shape: a, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: a, selectedShapesLengthAtMouseDown: _(a).length } };
217
+ if (c) {
192
218
  if (l === "add") {
193
- const c = de(xo(o, [d]), n);
194
- return { shape: c, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: c, selectedShapesLengthAtMouseDown: U(o).length } };
219
+ const d = pe(Ca(a, [c]), n);
220
+ return { shape: d, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: d, selectedShapesLengthAtMouseDown: _(a).length } };
195
221
  }
196
222
  if (l === "remove") {
197
- const c = de(pa(o, d), n);
198
- return { shape: c, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: c, selectedShapesLengthAtMouseDown: U(o).length } };
223
+ const d = pe(So(a, c), n);
224
+ return { shape: d, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: d, selectedShapesLengthAtMouseDown: _(a).length } };
199
225
  }
200
- const h = U(o).find((c) => c.id === d?.id) ? o : de([d], n);
201
- return { shape: h, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: h, selectedShapesLengthAtMouseDown: U(o).length } };
226
+ const h = _(a).find((d) => d.id === c?.id) ? a : pe([c], n);
227
+ return { shape: h, mode: { mode: "translate", cursorStartPosition: i, hasBeenDuplicated: !1, dateStart: Date.now(), originalShape: h, selectedShapesLengthAtMouseDown: _(a).length } };
202
228
  }
203
- return { shape: l !== "replace" ? o : void 0, mode: { mode: r ? "selectionFrame" : "default" } };
204
- }, de = (e, t) => {
229
+ return { shape: l !== "replace" ? a : void 0, mode: { mode: r ? "selectionFrame" : "default" } };
230
+ }, pe = (e, t) => {
205
231
  if (!e.length) return;
206
232
  if (e.length === 1) return e[0];
207
233
  const i = e.some((r) => r.rotation !== e[0].rotation) ? 0 : e[0]?.rotation ?? 0, n = ((r, l, s) => {
208
- const d = r.map((y) => [[y.computed.borders.x + s.selectionPadding, y.computed.borders.y + s.selectionPadding], [y.computed.borders.x - s.selectionPadding + y.computed.borders.width, y.computed.borders.y + s.selectionPadding], [y.computed.borders.x - s.selectionPadding + y.computed.borders.width, y.computed.borders.y - s.selectionPadding + y.computed.borders.height], [y.computed.borders.x + s.selectionPadding, y.computed.borders.y - s.selectionPadding + y.computed.borders.height]].map((g) => {
209
- const P = me({ point: [g[0], g[1]], origin: y.computed.center, rotation: -(y.rotation ?? 0) });
210
- return me({ point: [P[0], P[1]], origin: [0, 0], rotation: l });
211
- })), h = Math.min(...d.flatMap((y) => [y[0][0], y[1][0], y[2][0], y[3][0]])), c = Math.min(...d.flatMap((y) => [y[0][1], y[1][1], y[2][1], y[3][1]])), f = Math.max(...d.flatMap((y) => [y[0][0], y[1][0], y[2][0], y[3][0]])), p = Math.max(...d.flatMap((y) => [y[0][1], y[1][1], y[2][1], y[3][1]])), m = [(h + f) / 2, (c + p) / 2], u = me({ point: m, origin: [0, 0], rotation: -l }), S = [m[0] - u[0], m[1] - u[1]], w = We(h - S[0]), x = We(f - S[0]), b = We(c - S[1]);
212
- return { width: x - w, height: We(p - S[1]) - b, x: w, y: b };
213
- })(e, i, t), o = wo({ id: "group_selection", type: "rect", settings: Jn }, [n.x, n.y], t, n.width, n.height), a = e.slice(1).reduce((r, l) => {
214
- const s = l.style ?? {}, d = {};
215
- for (const h in s) r[h] !== void 0 && s[h] !== void 0 && r[h] === s[h] && (d[h] = r[h]);
216
- return d;
234
+ const c = r.map((S) => [[S.computed.borders.x + s.selectionPadding, S.computed.borders.y + s.selectionPadding], [S.computed.borders.x - s.selectionPadding + S.computed.borders.width, S.computed.borders.y + s.selectionPadding], [S.computed.borders.x - s.selectionPadding + S.computed.borders.width, S.computed.borders.y - s.selectionPadding + S.computed.borders.height], [S.computed.borders.x + s.selectionPadding, S.computed.borders.y - s.selectionPadding + S.computed.borders.height]].map((g) => {
235
+ const P = Qe({ point: [g[0], g[1]], origin: S.computed.center, rotation: -(S.rotation ?? 0) });
236
+ return Qe({ point: [P[0], P[1]], origin: [0, 0], rotation: l });
237
+ })), h = Math.min(...c.flatMap((S) => [S[0][0], S[1][0], S[2][0], S[3][0]])), d = Math.min(...c.flatMap((S) => [S[0][1], S[1][1], S[2][1], S[3][1]])), u = Math.max(...c.flatMap((S) => [S[0][0], S[1][0], S[2][0], S[3][0]])), p = Math.max(...c.flatMap((S) => [S[0][1], S[1][1], S[2][1], S[3][1]])), f = [(h + u) / 2, (d + p) / 2], m = Qe({ point: f, origin: [0, 0], rotation: -l }), b = [f[0] - m[0], f[1] - m[1]], x = Be(h - b[0]), k = Be(u - b[0]), M = Be(d - b[1]);
238
+ return { width: k - x, height: Be(p - b[1]) - M, x, y: M };
239
+ })(e, i, t), a = xa({ id: "group_selection", type: "rect", settings: ea }, [n.x, n.y], t, n.width, n.height), o = e.slice(1).reduce((r, l) => {
240
+ const s = l.style ?? {}, c = {};
241
+ for (const h in s) r[h] !== void 0 && s[h] !== void 0 && r[h] === s[h] && (c[h] = r[h]);
242
+ return c;
217
243
  }, e[0].style ?? {});
218
- return { id: e.map((r) => r.id).join("-"), type: "group", shapes: e, rotation: i, visible: !0, locked: !1, selection: o.selection, x: o.x, y: o.y, width: o.width, height: o.height, style: a, computed: o.computed, path: o.path };
219
- }, U = (e) => e ? e.type === "group" ? e.shapes : [e] : [], xo = (e, t) => {
220
- const i = U(e);
244
+ return { id: e.map((r) => r.id).join("-"), type: "group", shapes: e, rotation: i, visible: !0, locked: !1, selection: a.selection, x: a.x, y: a.y, width: a.width, height: a.height, style: o, computed: a.computed, path: a.path };
245
+ }, _ = (e) => e ? e.type === "group" ? e.shapes : [e] : [], Ca = (e, t) => {
246
+ const i = _(e);
221
247
  return [.../* @__PURE__ */ new Set([...i, ...t])];
222
- }, pa = (e, t) => U(e).filter((i) => i.id !== t.id), Mo = (e) => {
248
+ }, So = (e, t) => _(e).filter((i) => i.id !== t.id), ka = (e) => {
223
249
  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 : {};
224
250
  return { clientX: t, clientY: i };
225
- }, Co = (e, t, i) => {
226
- const { clientX: n, clientY: o } = Mo(e), a = t.getBoundingClientRect();
227
- return [(n - a.left) / i.scaleRatio, (o - a.top) / i.scaleRatio];
251
+ }, Pa = (e, t, i) => {
252
+ const { clientX: n, clientY: a } = ka(e), o = t.getBoundingClientRect();
253
+ return [(n - o.left) / i.scaleRatio, (a - o.top) / i.scaleRatio];
228
254
  }, ft = (e, t, i) => {
229
- const { clientX: n, clientY: o } = Mo(e), a = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
230
- return [(n - a.left) * (i.canvasSize.width / a.width) / i.canvasSize.scaleRatio - i.canvasOffset[0], (o - a.top) * (i.canvasSize.height / a.height) / i.canvasSize.scaleRatio - i.canvasOffset[1]];
231
- }, ot = (e) => "touches" in e, tt = (e, t, [i, n]) => me({ origin: [i, n], point: e, rotation: t }), wi = (e, t, [i, n]) => me({ origin: [i, n], point: e, rotation: -t }), Ft = (e, t, i) => i ? yo(e, { x: t[0], y: t[1], radius: i }) : ((n, o) => o[0] >= n.x && o[0] <= n.x + n.width && o[1] >= n.y && o[1] <= n.y + n.height)(e, t), Et = (e, t, i, n, o = !1, a = 0) => {
232
- const r = U(t).length > 1 ? t : U(t)[0];
233
- if (!r || r.locked) return !1;
234
- const { borders: l, center: s } = r.computed, d = tt(i, r.rotation ?? 0, s);
235
- if (o) {
236
- const h = ((c, f, p, m = 0) => {
237
- const { canvasSize: { scaleRatio: u } } = p, { borders: S } = c.computed;
238
- if (c.type === "line" || c.type === "polygon" || c.type === "curve") {
239
- for (let w = 0; w < c.points.length; w++) if (Ft({ x: c.points[w][0] - 7 / u, y: c.points[w][1] - 7 / u, width: gt / u, height: gt / u }, f, m)) return { mode: "resize", anchor: w };
255
+ const { clientX: n, clientY: a } = ka(e), o = t?.getBoundingClientRect() ?? { left: 0, top: 0, width: i.canvasSize.width, height: i.canvasSize.height };
256
+ return [(n - o.left) * (i.canvasSize.width / o.width) / i.canvasSize.scaleRatio - i.canvasOffset[0], (a - o.top) * (i.canvasSize.height / o.height) / i.canvasSize.scaleRatio - i.canvasOffset[1]];
257
+ }, at = (e) => "touches" in e, tt = (e, t, [i, n]) => Qe({ origin: [i, n], point: e, rotation: t }), wi = (e, t, [i, n]) => Qe({ origin: [i, n], point: e, rotation: -t }), Ft = (e, t, i) => i ? Sa(e, { x: t[0], y: t[1], radius: i }) : ((n, a) => a[0] >= n.x && a[0] <= n.x + n.width && a[1] >= n.y && a[1] <= n.y + n.height)(e, t), Et = (e, t, i, n, a = !1, o = 0) => {
258
+ const r = _(t).length > 1 ? t : _(t)[0];
259
+ if (!r) return !1;
260
+ const { borders: l, center: s } = r.computed, c = tt(i, r.rotation ?? 0, s);
261
+ if (a) {
262
+ const h = ((d, u, p, f = 0) => {
263
+ const { canvasSize: { scaleRatio: m } } = p, { borders: b } = d.computed;
264
+ if (d.type === "line" || d.type === "polygon" || d.type === "curve") {
265
+ for (let x = 0; x < d.points.length; x++) if (Ft({ x: d.points[x][0] - 7 / m, y: d.points[x][1] - 7 / m, width: gt / m, height: gt / m }, u, f)) return { mode: "resize", anchor: x };
240
266
  } else {
241
- if (Ft({ x: S.x + S.width / 2 - 7 / u, y: S.y - gt / u - 16 / u, width: gt / u, height: gt / u }, f, m)) return { mode: "rotate" };
242
- for (const w of po) if (Ft({ x: S.x + S.width * w[0] - 7 / u, y: S.y + S.height * w[1] - 7 / u, width: gt / u, height: gt / u }, f, m)) return { mode: "resize", anchor: w };
267
+ if (Ft({ x: b.x + b.width / 2 - 7 / m, y: b.y - gt / m - 16 / m, width: gt / m, height: gt / m }, u, f)) return { mode: "rotate" };
268
+ for (const x of ua) if (Ft({ x: b.x + b.width * x[0] - 7 / m, y: b.y + b.height * x[1] - 7 / m, width: gt / m, height: gt / m }, u, f)) return { mode: "resize", anchor: x };
243
269
  }
244
270
  return !1;
245
- })(r, d, n, a);
271
+ })(r, c, n, o);
246
272
  if (h) return h;
247
273
  }
248
- return r.selection?.type === "line" ? (e.lineWidth = (r.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!(Ii(r, !0) ? e.isPointInPath(r.path, d[0], d[1]) : e.isPointInStroke(r.path, d[0], d[1])) && { mode: "translate" }) : !!Ft(l, d, 15 + a) && { mode: "translate" };
249
- }, hn = (e, t, i, n, o = 50) => {
274
+ return r.selection?.type === "line" ? (e.lineWidth = (r.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!(Ii(r, !0) ? e.isPointInPath(r.path, c[0], c[1]) : e.isPointInStroke(r.path, c[0], c[1])) && { mode: "translate" }) : !!Ft(l, c, 15 + o) && { mode: "translate" };
275
+ }, un = (e, t, i, n, a = 50) => {
250
276
  if (t.locked || t.points.length < 2) return !1;
251
- const { center: a } = t.computed, r = tt(i, t.rotation ?? 0, a);
252
- e.lineWidth = (t.style?.lineWidth ?? 0) + o / n.canvasZoom;
277
+ const { center: o } = t.computed, r = tt(i, t.rotation ?? 0, o);
278
+ e.lineWidth = (t.style?.lineWidth ?? 0) + a / n.canvasZoom;
253
279
  const l = t.style?.closedPoints ? [...t.points, t.points[0]] : t.points;
254
280
  for (let s = 0; s < l.length - 1; s++) {
255
- const d = _t({ points: [l[s], l[s + 1]] });
256
- if (e.isPointInStroke(d, r[0], r[1])) return { lineIndex: s };
281
+ const c = _t({ points: [l[s], l[s + 1]] });
282
+ if (e.isPointInStroke(c, r[0], r[1])) return { lineIndex: s };
257
283
  }
258
284
  return !1;
259
- }, Ii = (e, t = !1) => !(!t || !["curve", "polygon"].includes(e.type)) || e.style?.fillColor && e.style?.fillColor !== "transparent" || ["picture", "text"].includes(e.type), Po = (e, t, i, n) => {
260
- if (t.locked) return !1;
261
- const { center: o } = t.computed, a = tt(i, t.rotation ?? 0, o);
262
- return e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!(Ii(t) ? e.isPointInPath(t.path, a[0], a[1]) : e.isPointInStroke(t.path, a[0], a[1])) && { mode: "translate" };
285
+ }, Ii = (e, t = !1) => !(!t || !["curve", "polygon"].includes(e.type)) || e.style?.fillColor && e.style?.fillColor !== "transparent" || ["picture", "text"].includes(e.type), La = (e, t, i, n) => {
286
+ const { center: a } = t.computed, o = tt(i, t.rotation ?? 0, a);
287
+ return e.lineWidth = (t.style?.lineWidth ?? 0) + 15 / n.canvasZoom, !!(Ii(t) ? e.isPointInPath(t.path, o[0], o[1]) : e.isPointInStroke(t.path, o[0], o[1])) && { mode: "translate" };
263
288
  };
264
289
  function xi(e, t) {
265
- const i = Math.max(e.x, t.x), n = Math.max(e.y, t.y), o = 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));
266
- if (i < o && n < a) return { x: i, y: n, width: o - i, height: a - n };
290
+ const i = Math.max(e.x, t.x), n = Math.max(e.y, t.y), a = Math.min(e.x + (e.width || 1), t.x + (t.width || 1)), o = Math.min(e.y + (e.height || 1), t.y + (t.height || 1));
291
+ if (i < a && n < o) return { x: i, y: n, width: a - i, height: o - n };
267
292
  }
268
- const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, checkFill: r }) => {
269
- for (let l = 0; l < n; l += n / 2) for (let s = 0; s < n; s += n / 2) for (let d = l + i.x; d < i.x + i.width; d += n) for (let h = s + i.y; h < i.y + i.height; h += n) {
270
- const c = tt([d, h], a, o);
271
- if (r ? e.isPointInPath(t, c[0], c[1]) : e.isPointInStroke(t, c[0], c[1])) return !0;
293
+ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: a, rotation: o = 0, checkFill: r }) => {
294
+ for (let l = 0; l < n; l += n / 2) for (let s = 0; s < n; s += n / 2) for (let c = l + i.x; c < i.x + i.width; c += n) for (let h = s + i.y; h < i.y + i.height; h += n) {
295
+ const d = tt([c, h], o, a);
296
+ if (r ? e.isPointInPath(t, d[0], d[1]) : e.isPointInStroke(t, d[0], d[1])) return !0;
272
297
  }
273
298
  return !1;
274
- }, Ri = (e, t, i, n) => ({ type: "line", border: Rt(i.borders), shapePath: e, anchors: [...t.points.map((o) => Gt({ x: o[0], y: o[1], radius: 7 / n.canvasSize.scaleRatio }))] }), Ie = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], Mi = ({ size: e, zoom: t, newOffset: [i, n], canvasSize: o }) => e === "infinite" ? { zoom: t, offset: [i, n] } : t < 1 ? { zoom: t, offset: [-(o.realWidth - o.realWidth / t) / 2, -(o.realHeight - o.realHeight / t) / 2] } : { zoom: t, offset: [et(i, o.realWidth / t - o.realWidth, 0), et(n, o.realHeight / t - o.realHeight, 0)] }, Ci = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: n, zoom: o, centerPoint: a }) => {
275
- const r = e === "fixed" && o < 1 ? [t.realWidth / 2, t.realHeight / 2] : a, l = i[0] - (r[0] / n - r[0] / o), s = i[1] - (r[1] / n - r[1] / o);
276
- return { offset: e === "infinite" ? [l, s] : o < 1 ? [-(t.realWidth - t.realWidth / o) / 2, -(t.realHeight - t.realHeight / o) / 2] : [et(l, t.realWidth / o - t.realWidth, 0), et(s, t.realHeight / o - t.realHeight, 0)], zoom: o };
277
- }, ko = (e) => {
278
- const { canvasSize: { width: t, height: i, scaleRatioWithNoZoom: n }, canvasZoom: o, canvasOffset: a } = e;
279
- return { x: a[0] * o * n, y: a[1] * o * n, width: t * o, height: i * o };
280
- }, Lo = (e, t) => {
299
+ }, Wi = (e, t, i, n) => ({ type: "line", border: Wt(i.borders), shapePath: e, anchors: [...t.points.map((a) => Gt({ x: a[0], y: a[1], radius: 7 / n.canvasSize.scaleRatio }))] }), Re = [0.05, 0.1, 0.25, 0.5, 1, 2, 4, 8], Mi = ({ size: e, zoom: t, newOffset: [i, n], canvasSize: a }) => e === "infinite" ? { zoom: t, offset: [i, n] } : t < 1 ? { zoom: t, offset: [-(a.realWidth - a.realWidth / t) / 2, -(a.realHeight - a.realHeight / t) / 2] } : { zoom: t, offset: [et(i, a.realWidth / t - a.realWidth, 0), et(n, a.realHeight / t - a.realHeight, 0)] }, Ci = ({ size: e, canvasSize: t, currentOffset: i, currentZoom: n, zoom: a, centerPoint: o }) => {
300
+ const r = e === "fixed" && a < 1 ? [t.realWidth / 2, t.realHeight / 2] : o, l = i[0] - (r[0] / n - r[0] / a), s = i[1] - (r[1] / n - r[1] / a);
301
+ return { offset: e === "infinite" ? [l, s] : a < 1 ? [-(t.realWidth - t.realWidth / a) / 2, -(t.realHeight - t.realHeight / a) / 2] : [et(l, t.realWidth / a - t.realWidth, 0), et(s, t.realHeight / a - t.realHeight, 0)], zoom: a };
302
+ }, Va = (e) => {
303
+ const { canvasSize: { width: t, height: i, scaleRatioWithNoZoom: n }, canvasZoom: a, canvasOffset: o } = e;
304
+ return { x: o[0] * a * n, y: o[1] * a * n, width: t * a, height: i * a };
305
+ }, Za = (e, t) => {
281
306
  const { canvasZoom: i, size: n } = t;
282
307
  if (n !== "fixed" || i >= 1) return;
283
- const o = ko(t);
284
- e.beginPath(), e.rect(o.x, o.y, o.width, o.height), e.closePath(), e.clip();
285
- }, Dt = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, ua = (e, t) => ({ x: e.x - e.radius - t.selectionPadding, width: 2 * (e.radius + t.selectionPadding), y: e.y - e.radius - t.selectionPadding, height: 2 * (e.radius + t.selectionPadding) }), Jt = (e, t) => {
286
- const i = Gt(e), n = ((o, a) => it(o, ua, a))(e, t);
287
- return { ...e, path: i, selection: zt(i, n, t), computed: n };
288
- }, ga = Jt, At = (e, t) => {
289
- const i = Qo(e), n = ((o, a) => it(o, ei, a))(e, t);
290
- return { ...e, path: i, selection: Ri(i, e, n, t), computed: n };
291
- }, Vo = At, ei = (e, t) => {
292
- const i = Math.min(...e.points.map((a) => a[0])) - t.selectionPadding, n = Math.max(...e.points.map((a) => a[0])) + t.selectionPadding, o = Math.min(...e.points.map((a) => a[1])) - t.selectionPadding;
293
- return { x: i, width: n - i, y: o, height: Math.max(...e.points.map((a) => a[1])) + t.selectionPadding - o };
294
- }, fa = (e, t, i, n) => {
308
+ const a = Va(t);
309
+ e.beginPath(), e.rect(a.x, a.y, a.width, a.height), e.closePath(), e.clip();
310
+ }, Dt = (e, t) => t.size !== "fixed" || e[0] > 0 && e[0] < t.canvasSize.realWidth && e[1] > 0 && e[1] < t.canvasSize.realHeight, bo = (e, t) => ({ x: e.x - e.radius - t.selectionPadding, width: 2 * (e.radius + t.selectionPadding), y: e.y - e.radius - t.selectionPadding, height: 2 * (e.radius + t.selectionPadding) }), Jt = (e, t) => {
311
+ const i = Gt(e), n = it(e, bo, t);
312
+ return { ...e, path: i, selection: Ht(i, n, t), computed: n };
313
+ }, Qo = Jt, Ha = (e, t, i) => {
314
+ const n = mt(e, t, i), a = (e.radius || 0.5) * i.widthMultiplier, o = yt(i, n.x, n.y, 2 * a, 2 * a);
315
+ return Jt({ ...e, radius: a, x: o[0], y: o[1] }, i.settings);
316
+ }, zt = (e, t) => {
317
+ const i = wa(e), n = it(e, ei, t);
318
+ return { ...e, path: i, selection: Wi(i, e, n, t), computed: n };
319
+ }, za = zt, ei = (e, t) => {
320
+ const i = Math.min(...e.points.map((o) => o[0])) - t.selectionPadding, n = Math.max(...e.points.map((o) => o[0])) + t.selectionPadding, a = Math.min(...e.points.map((o) => o[1])) - t.selectionPadding;
321
+ return { x: i, width: n - i, y: a, height: Math.max(...e.points.map((o) => o[1])) + t.selectionPadding - a };
322
+ }, wo = (e, t, i, n) => {
295
323
  if (t < 0 || t > e.points.length - 1) return e;
296
- const o = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
297
- return At({ ...e, points: o }, n);
298
- }, un = (e, t, i, n = !1) => {
299
- const o = [Ze(t[0], i), Ze(t[1], i)], a = tt(o, e.rotation ?? 0, e.computed.center), r = { ...e, points: n ? e.points : [...e.points, a], tempPoint: n ? a : void 0 };
300
- return At(r, i);
301
- }, va = (e, t, i) => {
324
+ const a = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
325
+ return zt({ ...e, points: a }, n);
326
+ }, gn = (e, t, i, n = !1) => {
327
+ const a = [ze(t[0], i), ze(t[1], i)], o = tt(a, e.rotation ?? 0, e.computed.center), r = { ...e, points: n ? e.points : [...e.points, o], tempPoint: n ? o : void 0 };
328
+ return zt(r, i);
329
+ }, xo = (e, t, i) => {
302
330
  const n = e.tempPoint ? [...e.points, e.tempPoint] : e.points;
303
331
  if (n.length < 2) {
304
- const d = n[0] ?? [0, 0], h = i.selectionPadding;
305
- return { x: d[0] - h, y: d[1] - h, width: 2 * h, height: 2 * h };
332
+ const c = n[0] ?? [0, 0], h = i.selectionPadding;
333
+ return { x: c[0] - h, y: c[1] - h, width: 2 * h, height: 2 * h };
306
334
  }
307
335
  if (n.length < 3) return ei({ ...e, points: n }, i);
308
- const o = Ti(e, n);
309
- let a = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, l = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
310
- for (let d = 1; d < o.length - 2; d++) {
311
- const h = o[d - 1], c = o[d], f = o[d + 1], p = o[d + 2], { cp1: m, cp2: u } = Di(h, c, f, p), S = aa(c, m, u, f);
312
- a = Math.min(a, S.minX), r = Math.max(r, S.maxX), l = Math.min(l, S.minY), s = Math.max(s, S.maxY);
336
+ const a = Ti(e, n);
337
+ let o = Number.POSITIVE_INFINITY, r = Number.NEGATIVE_INFINITY, l = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
338
+ for (let c = 1; c < a.length - 2; c++) {
339
+ const h = a[c - 1], d = a[c], u = a[c + 1], p = a[c + 2], { cp1: f, cp2: m } = Di(h, d, u, p), b = po(d, f, m, u);
340
+ o = Math.min(o, b.minX), r = Math.max(r, b.maxX), l = Math.min(l, b.minY), s = Math.max(s, b.maxY);
313
341
  }
314
- return Ei({ x: a, y: l, width: r - a, height: s - l }, i);
315
- }, Ht = (e, t) => {
316
- const i = ((o) => {
317
- const a = new Path2D(), r = o.tempPoint ? [...o.points, o.tempPoint] : o.points;
318
- if (r.length < 2) return a;
319
- if (r.length < 3) return Qo(o);
320
- const l = o.style?.closedPoints === 1 && r.length > 2;
321
- a.moveTo(...r[0]);
322
- const s = Ti(o, r);
323
- for (let d = 1; d < s.length - 2; d++) {
324
- const h = s[d - 1], c = s[d], f = s[d + 1], p = s[d + 2], { cp1: m, cp2: u } = Di(h, c, f, p);
325
- a.bezierCurveTo(m[0], m[1], u[0], u[1], f[0], f[1]);
342
+ return Ei({ x: o, y: l, width: r - o, height: s - l }, i);
343
+ }, At = (e, t) => {
344
+ const i = ((a) => {
345
+ const o = new Path2D(), r = a.tempPoint ? [...a.points, a.tempPoint] : a.points;
346
+ if (r.length < 2) return o;
347
+ if (r.length < 3) return wa(a);
348
+ const l = a.style?.closedPoints === 1 && r.length > 2;
349
+ o.moveTo(...r[0]);
350
+ const s = Ti(a, r);
351
+ for (let c = 1; c < s.length - 2; c++) {
352
+ const h = s[c - 1], d = s[c], u = s[c + 1], p = s[c + 2], { cp1: f, cp2: m } = Di(h, d, u, p);
353
+ o.bezierCurveTo(f[0], f[1], m[0], m[1], u[0], u[1]);
326
354
  }
327
- return l && a.closePath(), a;
328
- })(e), n = ((o, a) => it(o, ei, a, va))(e, t);
329
- return { ...e, path: i, selection: Ri(i, e, n, t), computed: n };
330
- }, Zo = Ht, ma = (e, t, i, n) => {
355
+ return l && o.closePath(), o;
356
+ })(e), n = it(e, ei, t, xo);
357
+ return { ...e, path: i, selection: Wi(i, e, n, t), computed: n };
358
+ }, Aa = At, Mo = (e, t, i, n) => {
331
359
  if (t < 0 || t > e.points.length - 1) return e;
332
- const o = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
333
- return Ht({ ...e, points: o }, n);
334
- }, gn = (e, t, i, n = !1) => {
335
- const o = [Ze(t[0], i), Ze(t[1], i)], a = e.computed.center, r = tt(o, e.rotation ?? 0, a), l = { ...e, points: n ? e.points : [...e.points, r], tempPoint: n ? r : void 0 };
336
- return Ht(l, i);
337
- }, Sa = (e, t) => ({ x: e.x - e.radiusX - t.selectionPadding, width: 2 * (e.radiusX + t.selectionPadding), y: e.y - e.radiusY - t.selectionPadding, height: 2 * (e.radiusY + t.selectionPadding) }), ti = (e, t) => {
338
- const i = ((o) => {
339
- const a = new Path2D();
340
- return a.ellipse(o.x, o.y, o.radiusX, o.radiusY, 0, 0, 2 * Math.PI), a;
341
- })(e), n = ((o, a) => it(o, Sa, a))(e, t);
342
- return { ...e, path: i, selection: zt(i, n, t), computed: n };
343
- }, ya = ti, ba = (e, t) => it(e, ei, t), fn = (e, t) => ((i, n) => ({ ...i, path: sa(i), computed: ba(i, n) }))({ ...e, id: Ce("triangle_"), type: "triangle" }, t), Qa = (e, t) => {
360
+ const a = [...e.points.slice(0, t + 1), i, ...e.points.slice(t + 1)];
361
+ return At({ ...e, points: a }, n);
362
+ }, fn = (e, t, i, n = !1) => {
363
+ const a = [ze(t[0], i), ze(t[1], i)], o = e.computed.center, r = tt(a, e.rotation ?? 0, o), l = { ...e, points: n ? e.points : [...e.points, r], tempPoint: n ? r : void 0 };
364
+ return At(l, i);
365
+ }, Co = (e, t) => ({ x: e.x - e.radiusX - t.selectionPadding, width: 2 * (e.radiusX + t.selectionPadding), y: e.y - e.radiusY - t.selectionPadding, height: 2 * (e.radiusY + t.selectionPadding) }), ti = (e, t) => {
366
+ const i = ((a) => {
367
+ const o = new Path2D();
368
+ return o.ellipse(a.x, a.y, a.radiusX, a.radiusY, 0, 0, 2 * Math.PI), o;
369
+ })(e), n = it(e, Co, t);
370
+ return { ...e, path: i, selection: Ht(i, n, t), computed: n };
371
+ }, ko = ti, Ta = (e, t, i) => {
372
+ const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: r, heightMultiplier: l } = i, s = (n || a) && !(n && a) && (e.rotation ?? 0) !== 0 && i.rotation !== e.rotation, c = mt(e, t, i), h = (e.radiusX || 0.5) * r, d = (e.radiusY || 0.5) * l, u = yt(i, c.x, c.y, 2 * h, 2 * d);
373
+ return ti({ ...e, radiusX: h, radiusY: d, x: u[0], y: u[1], rotation: s ? -(e.rotation ?? 0) : e.rotation ?? 0 }, o);
374
+ }, vn = (e, t) => ((i, n) => ({ ...i, path: go(i), computed: it(i, ei, n) }))({ ...e, id: Le("triangle_"), type: "triangle" }, t), Po = (e, t) => {
344
375
  e.globalAlpha !== 0 && (t.style?.fillColor !== "transparent" && e.fill(t.path), t.style?.strokeColor !== "transparent" && e.stroke(t.path));
345
- }, wa = (e, t) => ({ x: Math.min(e.points[0][0], e.points[1][0]) - t.selectionPadding, width: Math.abs(e.points[0][0] - e.points[1][0]) + 2 * t.selectionPadding, y: Math.min(e.points[0][1], e.points[1][1]) - t.selectionPadding, height: Math.abs(e.points[0][1] - e.points[1][1]) + 2 * t.selectionPadding }), ii = (e, t) => {
376
+ }, Lo = (e, t) => ({ x: Math.min(e.points[0][0], e.points[1][0]) - t.selectionPadding, width: Math.abs(e.points[0][0] - e.points[1][0]) + 2 * t.selectionPadding, y: Math.min(e.points[0][1], e.points[1][1]) - t.selectionPadding, height: Math.abs(e.points[0][1] - e.points[1][1]) + 2 * t.selectionPadding }), ii = (e, t) => {
346
377
  const i = [];
347
378
  let n;
348
379
  if (e.style?.lineArrow === 1 || e.style?.lineArrow === 2 || e.style?.lineArrow === 3) {
349
- const a = Math.PI / 2 - ln({ targetVector: [e.points[0], e.points[1]] });
350
- e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(fn(vn(e.points[0], a, e.style), t)), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(fn(vn(e.points[1], a + Math.PI, e.style), t));
351
- const r = (({ line: l, size: s, direction: d }) => {
352
- const h = Math.PI / 2 - ln({ targetVector: [l.points[0], l.points[1]] }), c = [l.points[0][0] + (l.points[1][0] - l.points[0][0]) / 2, l.points[0][1] + (l.points[1][1] - l.points[0][1]) / 2];
353
- let f, p;
354
- if (["start", "both"].includes(d)) {
355
- const m = me({ point: l.points[0], origin: c, rotation: -h });
356
- f = me({ point: [m[0], m[1] + s], origin: c, rotation: h });
357
- } else f = [...l.points[0]];
358
- if (["end", "both"].includes(d)) {
359
- const m = me({ point: l.points[1], origin: c, rotation: -h });
360
- p = me({ point: [m[0], m[1] - s], origin: c, rotation: h });
380
+ const o = Math.PI / 2 - ln({ targetVector: [e.points[0], e.points[1]] });
381
+ e.style?.lineArrow !== 1 && e.style?.lineArrow !== 3 || i.push(vn(mn(e.points[0], o, e.style), t)), e.style?.lineArrow !== 2 && e.style?.lineArrow !== 3 || i.push(vn(mn(e.points[1], o + Math.PI, e.style), t));
382
+ const r = (({ line: l, size: s, direction: c }) => {
383
+ const h = Math.PI / 2 - ln({ targetVector: [l.points[0], l.points[1]] }), d = [l.points[0][0] + (l.points[1][0] - l.points[0][0]) / 2, l.points[0][1] + (l.points[1][1] - l.points[0][1]) / 2];
384
+ let u, p;
385
+ if (["start", "both"].includes(c)) {
386
+ const f = Qe({ point: l.points[0], origin: d, rotation: -h });
387
+ u = Qe({ point: [f[0], f[1] + s], origin: d, rotation: h });
388
+ } else u = [...l.points[0]];
389
+ if (["end", "both"].includes(c)) {
390
+ const f = Qe({ point: l.points[1], origin: d, rotation: -h });
391
+ p = Qe({ point: [f[0], f[1] - s], origin: d, rotation: h });
361
392
  } else p = [...l.points[1]];
362
- return { points: [f, p] };
393
+ return { points: [u, p] };
363
394
  })({ line: e, size: 10 + 2 * (e.style?.lineWidth ?? 0), direction: e.style?.lineArrow === 1 ? "start" : e.style?.lineArrow === 2 ? "end" : "both" });
364
395
  n = _t(r);
365
396
  } else n = _t(e);
366
- const o = ((a, r) => it(a, wa, r))(e, t);
367
- return { ...e, path: n, selection: Ri(n, e, o, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" }, computed: o };
368
- }, xa = ii, vn = (e, t, i) => {
369
- const n = [me({ point: [0, 0], rotation: t }), me({ point: [-(5 + (i.lineWidth ?? 0)), 10 + 2 * (i.lineWidth ?? 0)], rotation: t }), me({ point: [5 + (i.lineWidth ?? 0), 10 + 2 * (i.lineWidth ?? 0)], rotation: t })];
397
+ const a = it(e, Lo, t);
398
+ return { ...e, path: n, selection: Wi(n, e, a, t), arrows: i, style: { ...e.style, lineCap: e.style?.lineArrow ? "butt" : "round" }, computed: a };
399
+ }, Vo = ii, mn = (e, t, i) => {
400
+ const n = [Qe({ point: [0, 0], rotation: t }), Qe({ point: [-(5 + (i.lineWidth ?? 0)), 10 + 2 * (i.lineWidth ?? 0)], rotation: t }), Qe({ point: [5 + (i.lineWidth ?? 0), 10 + 2 * (i.lineWidth ?? 0)], rotation: t })];
370
401
  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" } };
371
- }, Ma = (e, t, i) => {
372
- const { isXinverted: n, isYinverted: o, settings: a, widthMultiplier: r, heightMultiplier: l } = i, s = e.computed.borders.width - 2 * a.selectionPadding, d = e.computed.borders.height - 2 * a.selectionPadding, h = s * r, c = d * l, f = vt(e, t, i), p = mt(i, f.x, f.y, h, c), m = e.computed.center[0] - s / 2, u = e.computed.center[1] - d / 2, S = p[0] - h / 2, w = p[1] - c / 2;
373
- return ((x, b) => x.type === "line" ? ii(x, b) : x.type === "polygon" ? Vo(x, b) : Zo(x, b))({ ...e, points: e.points.map(([x, b]) => [S + (n ? h - (x - m) * r : (x - m) * r), w + (o ? c - (b - u) * l : (b - u) * l)]) }, i.settings);
402
+ }, Da = (e, t, i) => {
403
+ const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: r, heightMultiplier: l } = i, s = e.computed.borders.width - 2 * o.selectionPadding, c = e.computed.borders.height - 2 * o.selectionPadding, h = s * r, d = c * l, u = mt(e, t, i), p = yt(i, u.x, u.y, h, d), f = e.computed.center[0] - s / 2, m = e.computed.center[1] - c / 2, b = p[0] - h / 2, x = p[1] - d / 2;
404
+ return ((k, M) => k.type === "line" ? ii(k, M) : k.type === "polygon" ? za(k, M) : Aa(k, M))({ ...e, points: e.points.map(([k, M]) => [b + (n ? h - (k - f) * r : (k - f) * r), x + (a ? d - (M - m) * l : (M - m) * l)]) }, i.settings);
374
405
  }, ni = (e, t) => {
375
- const i = ((o, a) => it(o, Ei, a))(e, t), n = Rt(e);
376
- return { ...e, path: n, selection: zt(void 0, i, t), computed: i };
377
- }, Ca = ni, gi = (e, t, i, n, o) => {
378
- const [a, r] = ((l, s, d, h, c = !1) => {
379
- if (!(l && s && h && d)) return [sn, sn];
380
- const f = l / s;
381
- if (f > d / h) {
382
- const m = c ? d : Math.min(l, d);
383
- return [m, m / f];
406
+ const i = it(e, Ei, t), n = Wt(e);
407
+ return { ...e, path: n, selection: Ht(void 0, i, t), computed: i };
408
+ }, Zo = ni, gi = (e, t, i, n, a) => {
409
+ const [o, r] = ((l, s, c, h, d = !1) => {
410
+ if (!(l && s && h && c)) return [sn, sn];
411
+ const u = l / s;
412
+ if (u > c / h) {
413
+ const f = d ? c : Math.min(l, c);
414
+ return [f, f / u];
384
415
  }
385
- const p = c ? h : Math.min(s, h);
386
- return [p * f, p];
416
+ const p = d ? h : Math.min(s, h);
417
+ return [p * u, p];
387
418
  })(e.width, e.height, i, n, !0);
388
- return ni({ toolId: Ai.id, type: "picture", id: Ce("picture_"), x: -o.canvasOffset[0] + o.canvasSize.realWidth / o.canvasZoom / 2 - a / 2, y: -o.canvasOffset[1] + o.canvasSize.realHeight / o.canvasZoom / 2 - r / 2, width: a, height: r, ratio: a / r, src: t, img: e }, o);
389
- }, Pa = (e, t, i, n) => new Promise((o, a) => {
419
+ return ni({ toolId: zi.id, type: "picture", id: Le("picture_"), x: -a.canvasOffset[0] + a.canvasSize.realWidth / a.canvasZoom / 2 - o / 2, y: -a.canvasOffset[1] + a.canvasSize.realHeight / a.canvasZoom / 2 - r / 2, width: o, height: r, ratio: o / r, src: t, img: e }, a);
420
+ }, Ho = (e, t, i, n) => new Promise((a, o) => {
390
421
  const r = new Image();
391
422
  r.onerror = () => {
392
- a(new Error("Some images could not be loaded"));
423
+ o(new Error("Some images could not be loaded"));
393
424
  }, setTimeout(() => {
394
- a(new Error("Timeout while loading images"));
395
- }, 4e3), e instanceof File ? ((l, s, d, h, c, f) => {
396
- Io(d) ? d.text().then((p) => {
397
- const m = Eo(p);
425
+ o(new Error("Timeout while loading images"));
426
+ }, 4e3), e instanceof File ? ((l, s, c, h, d, u) => {
427
+ Ya(c) ? c.text().then((p) => {
428
+ const f = Fa(p);
398
429
  l.onload = async () => {
399
430
  URL.revokeObjectURL(l.src);
400
- const u = gi(l, p, h, c, f);
401
- s(u);
402
- }, l.src = m;
431
+ const m = gi(l, p, h, d, u);
432
+ s(m);
433
+ }, l.src = f;
403
434
  }) : (l.onload = async () => {
404
435
  URL.revokeObjectURL(l.src);
405
- const p = gi(l, l.src, h, c, f);
436
+ const p = gi(l, l.src, h, d, u);
406
437
  s(p);
407
- }, l.src = URL.createObjectURL(d));
408
- })(r, o, e, t, i, n) : ((l, s, d, h, c, f) => {
438
+ }, l.src = URL.createObjectURL(c));
439
+ })(r, a, e, t, i, n) : ((l, s, c, h, d, u) => {
409
440
  l.onload = () => {
410
441
  URL.revokeObjectURL(l.src);
411
- const p = gi(l, d, h, c, f);
442
+ const p = gi(l, c, h, d, u);
412
443
  s(p);
413
- }, Ro(d).then((p) => {
444
+ }, Xa(c).then((p) => {
414
445
  l.src = p;
415
446
  }).catch(() => {
416
447
  l.src = "";
417
448
  });
418
- })(r, o, e, t, i, n);
419
- }), fi = ["Texte"], zo = (e, t) => it(e, La, t), oi = (e, t) => {
420
- const i = zo(e, t), n = Rt(e);
421
- return { ...e, path: n, selection: zt(void 0, i, t), computed: i };
422
- }, ka = oi, ai = (e, t, i, n, o, a = It) => {
423
- e.font = `${o ? "italic" : ""} ${n ? "bold" : ""} 1px ${a}`;
449
+ })(r, a, e, t, i, n);
450
+ }), Ea = (e, t, i) => {
451
+ const { isXinverted: n, isYinverted: a, settings: o, widthMultiplier: r, heightMultiplier: l } = i, s = mt(e, t, i), c = (e.width === 0 || e.height === 0 ? e.ratio ?? 1 : e.width) * r, h = (e.width === 0 || e.height === 0 ? e.ratio ?? 1 : e.height) * l, d = yt(i, s.x, s.y, c, h), u = (n || a) && !(n && a) && (e.rotation ?? 0) !== 0 && i.rotation !== e.rotation;
452
+ return ni({ ...e, width: c, height: h, x: d[0] - c / 2, y: d[1] - h / 2, flipX: n ? !e.flipX : !!e.flipX, flipY: a ? !e.flipY : !!e.flipY, rotation: u ? -(e.rotation ?? 0) : e.rotation ?? 0 }, o);
453
+ }, fi = ["Texte"], Ia = (e, t) => it(e, Ao, t), ai = (e, t) => {
454
+ const i = Ia(e, t), n = Wt(e);
455
+ return { ...e, path: n, selection: Ht(void 0, i, t), computed: i };
456
+ }, zo = ai, oi = (e, t, i, n, a, o = It) => {
457
+ e.font = `${a ? "italic" : ""} ${n ? "bold" : ""} 1px ${o}`;
424
458
  const r = t.map((l) => i / e.measureText(l).width);
425
459
  return Math.min(...r) || 36;
426
- }, La = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), Va = (e, t, i, n) => {
427
- const o = { ...t, value: i }, a = ((m, u, S, w, x, b = It) => {
428
- m.font = `${x ? "italic" : ""} ${w ? "bold" : ""} ${S}px ${b}`;
429
- const y = u.map((g) => m.measureText(g).width);
430
- return Math.max(...y) || 20;
431
- })(e, o.value, o.fontSize, o.style?.fontBold ?? !1, o.style?.fontItalic ?? !1, o.style?.fontFamily), r = o.fontSize * o.value.length, l = a / r, s = { ...o, width: a, height: r, ratio: l }, { center: d } = zo(s, n), [h, c] = cn([1, 1], t.computed.center, t), [f, p] = cn([1, 1], d, s, [!1, !1]);
432
- return { ...s, x: s.x - (f - h), y: s.y - (p - c) };
433
- }, mn = (e, t, i, n) => {
434
- const o = [Ze(i[0], n), Ze(i[1], n)];
460
+ }, Ao = (e, t) => ({ x: e.x - t.selectionPadding, width: e.width + 2 * t.selectionPadding, y: e.y - t.selectionPadding, height: e.height + 2 * t.selectionPadding }), Wa = (e, t, i, n) => {
461
+ const { isXinverted: a, isYinverted: o, settings: r, widthMultiplier: l, heightMultiplier: s } = n, c = (a || o) && !(a && o) && (t.rotation ?? 0) !== 0 && n.rotation !== t.rotation, h = mt(t, i, n), d = (t.width === 0 || t.height === 0 ? t.ratio ?? 1 : t.width) * l, u = (t.width === 0 || t.height === 0 ? t.ratio ?? 1 : t.height) * s, p = yt(n, h.x, h.y, d, u), f = ai({ ...t, width: d, height: u, x: p[0] - d / 2, y: p[1] - u / 2, flipX: a ? !t.flipX : !!t.flipX, flipY: o ? !t.flipY : !!t.flipY, rotation: c ? -(t.rotation ?? 0) : t.rotation ?? 0 }, r);
462
+ return { ...f, fontSize: oi(e, f.value, f.width, f.style?.fontBold ?? !1, f.style?.fontItalic ?? !1, f.style?.fontFamily) };
463
+ }, To = (e, t, i, n) => {
464
+ const a = { ...t, value: i }, o = ((f, m, b, x, k, M = It) => {
465
+ f.font = `${k ? "italic" : ""} ${x ? "bold" : ""} ${b}px ${M}`;
466
+ const S = m.map((g) => f.measureText(g).width);
467
+ return Math.max(...S) || 20;
468
+ })(e, a.value, a.fontSize, a.style?.fontBold ?? !1, a.style?.fontItalic ?? !1, a.style?.fontFamily), r = a.fontSize * a.value.length, l = o / r, s = { ...a, width: o, height: r, ratio: l }, { center: c } = Ia(s, n), [h, d] = hn([1, 1], t.computed.center, t), [u, p] = hn([1, 1], c, s, [!1, !1]);
469
+ return { ...s, x: s.x - (u - h), y: s.y - (p - d) };
470
+ }, yn = (e, t, i, n) => {
471
+ const a = [ze(i[0], n), ze(i[1], n)];
435
472
  switch (t.type) {
436
473
  case "brush":
437
- return ((a, r, l) => Zt({ toolId: a.id, type: a.type, id: Ce(`${a.type}_`), points: [[r]], 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 } }, l))(t, o, n);
474
+ return ((o, r, l) => Zt({ toolId: o.id, type: o.type, id: Le(`${o.type}_`), points: [[r]], scaleX: 1, scaleY: 1, style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, a, n);
438
475
  case "line":
439
- return ((a, r, l) => {
440
- const s = { toolId: a.id, type: a.type, id: Ce(`${a.type}_`), points: [r, r], 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 } };
476
+ return ((o, r, l) => {
477
+ const s = { toolId: o.id, type: o.type, id: Le(`${o.type}_`), points: [r, r], style: { opacity: o.settings.opacity.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, lineArrow: o.settings.lineArrow.default } };
441
478
  return ii(s, l);
442
- })(t, o, n);
479
+ })(t, a, n);
443
480
  case "polygon":
444
- return ((a, r, l) => At({ toolId: a.id, type: a.type, id: Ce(`${a.type}_`), points: [r], 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 } }, l))(t, o, n);
481
+ return ((o, r, l) => zt({ toolId: o.id, type: o.type, id: Le(`${o.type}_`), points: [r], style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, l))(t, a, n);
445
482
  case "curve":
446
- return ((a, r, l) => Ht({ toolId: a.id, type: a.type, id: Ce(`${a.type}_`), points: [r], 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 } }, l))(t, o, n);
483
+ return ((o, r, l) => At({ toolId: o.id, type: o.type, id: Le(`${o.type}_`), points: [r], style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default, closedPoints: o.settings.closedPoints.default } }, l))(t, a, n);
447
484
  case "rect":
448
485
  case "square":
449
- return wo(t, o, n);
486
+ return xa(t, a, n);
450
487
  case "text":
451
- return ((a, r, l, s) => {
452
- const d = ai(a, fi, 150, r.settings?.fontBold.default ?? !1, r.settings?.fontItalic.default ?? !1, r.settings.fontFamily.default), h = d * (fi.length || 1);
453
- return oi({ toolId: r.id, type: r.type, id: Ce(`${r.type}_`), x: l[0] - 150, y: l[1] - h, value: fi, fontSize: d, width: 150, height: h, ratio: 150 / h, 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 } }, s);
454
- })(e, t, o, n);
488
+ return ((o, r, l, s) => {
489
+ const c = oi(o, fi, 150, r.settings?.fontBold.default ?? !1, r.settings?.fontItalic.default ?? !1, r.settings.fontFamily.default), h = c * (fi.length || 1);
490
+ return ai({ toolId: r.id, type: r.type, id: Le(`${r.type}_`), x: l[0] - 150, y: l[1] - h, value: fi, fontSize: c, width: 150, height: h, ratio: 150 / h, 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 } }, s);
491
+ })(e, t, a, n);
455
492
  case "ellipse":
456
- return ((a, r, l) => ti({ toolId: a.id, type: a.type, id: Ce(`${a.type}_`), x: r[0], y: r[1], radiusX: 0, radiusY: 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 } }, l))(t, o, n);
493
+ return ((o, r, l) => ti({ toolId: o.id, type: o.type, id: Le(`${o.type}_`), x: r[0], y: r[1], radiusX: 0, radiusY: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, a, n);
457
494
  case "circle":
458
- return ((a, r, l) => Jt({ toolId: a.id, type: a.type, id: Ce(`${a.type}_`), x: r[0], y: r[1], radius: 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 } }, l))(t, o, n);
495
+ return ((o, r, l) => Jt({ toolId: o.id, type: o.type, id: Le(`${o.type}_`), x: r[0], y: r[1], radius: 0, style: { opacity: o.settings.opacity.default, fillColor: o.settings.fillColor.default, strokeColor: o.settings.strokeColor.default, lineWidth: o.settings.lineWidth.default, lineDash: o.settings.lineDash.default } }, l))(t, a, n);
459
496
  }
460
497
  }, Sn = (e, t) => {
461
498
  switch (t.type) {
@@ -468,7 +505,7 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
468
505
  ((i, n) => {
469
506
  if (i.globalAlpha !== 0 && n.style?.strokeColor && n.style.strokeColor !== "transparent") {
470
507
  i.scale(n.flipX ? -1 : 1, n.flipY ? -1 : 1), i.font = `${n.style?.fontItalic ? "italic" : ""} ${n.style?.fontBold ? "bold" : ""} ${n.fontSize}px ${n.style?.fontFamily ?? It}`, i.textBaseline = "top", i.fillStyle = n.style.strokeColor;
471
- for (let o = 0; o < n.value.length; o++) i.fillText(n.value[o], n.flipX ? -n.x - n.width : n.x, (n.flipY ? -n.y - n.height : n.y) + o * n.fontSize, n.width);
508
+ for (let a = 0; a < n.value.length; a++) i.fillText(n.value[a], n.flipX ? -n.x - n.width : n.x, (n.flipY ? -n.y - n.height : n.y) + a * n.fontSize, n.width);
472
509
  }
473
510
  })(e, t);
474
511
  break;
@@ -476,7 +513,7 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
476
513
  ((i, n) => {
477
514
  if (i.globalAlpha !== 0) {
478
515
  n.style?.fillColor !== "transparent" && i.fill(n.path), n.style?.strokeColor !== "transparent" && i.stroke(n.path);
479
- for (const o of n.arrows ?? []) Te(i, o.style), Qa(i, o);
516
+ for (const a of n.arrows ?? []) De(i, a.style), Po(i, a);
480
517
  }
481
518
  })(e, t);
482
519
  break;
@@ -502,143 +539,129 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
502
539
  break;
503
540
  case "rect":
504
541
  case "square":
505
- ha(e, t);
542
+ yo(e, t);
506
543
  break;
507
544
  case "picture":
508
545
  ((i, n) => {
509
546
  i.globalAlpha !== 0 && (i.beginPath(), i.scale(n.flipX ? -1 : 1, n.flipY ? -1 : 1), i.drawImage(n.img, n.flipX ? -n.x - n.width : n.x, n.flipY ? -n.y - n.height : n.y, n.width, n.height));
510
547
  })(e, t);
511
548
  }
512
- }, Ao = (e, t, i) => {
549
+ }, Ra = (e, t, i) => {
513
550
  if (t.visible === !1) return;
514
- if (((o, a) => {
551
+ if (((a, o) => {
515
552
  const r = ((l) => {
516
- const { canvasSize: { width: s, height: d, scaleRatioWithNoZoom: h }, canvasZoom: c, canvasOffset: f } = l;
517
- return { x: -f[0], y: -f[1], width: s / c / h, height: d / c / h };
518
- })(a);
519
- return !!xi(o.computed.boundingBox, r);
553
+ const { canvasSize: { width: s, height: c, scaleRatioWithNoZoom: h }, canvasZoom: d, canvasOffset: u } = l;
554
+ return { x: -u[0], y: -u[1], width: s / d / h, height: c / d / h };
555
+ })(o);
556
+ return !!xi(a.computed.boundingBox, r);
520
557
  })(t, i)) {
521
- if (Pt(e, i, t.rotation, t.computed.center), Te(e, t.style), e.globalAlpha !== 1) return ((o, a) => {
522
- const { outerBorders: r } = a.computed, l = { width: 2 * r.width, height: 2 * r.height };
558
+ if (kt(e, i, t.rotation, t.computed.center), De(e, t.style), e.globalAlpha !== 1) return ((a, o) => {
559
+ const { outerBorders: r } = o.computed, l = { width: 2 * r.width, height: 2 * r.height };
523
560
  if (l.width === 0 || l.height === 0) return;
524
- const s = document.createElement("canvas"), d = s.getContext("2d");
525
- if (!d) throw new Error("No context found for canvas");
526
- s.width = l.width, s.height = l.height, d.translate(l.width / 4 - r.x, l.height / 4 - r.y), Te(d, { ...a.style, opacity: 100 }), Sn(d, a), o.drawImage(s, r.x - l.width / 4, r.y - l.height / 4);
561
+ const s = document.createElement("canvas"), c = s.getContext("2d");
562
+ if (!c) throw new Error("No context found for canvas");
563
+ s.width = l.width, s.height = l.height, c.translate(l.width / 4 - r.x, l.height / 4 - r.y), De(c, { ...o.style, opacity: 100 }), Sn(c, o), a.drawImage(s, r.x - l.width / 4, r.y - l.height / 4);
527
564
  })(e, t), void e.restore();
528
565
  Sn(e, t), e.restore();
529
566
  }
530
- }, Ho = (e, t, i) => {
531
- const n = me({ origin: i, point: e.computed.center, rotation: -t });
567
+ }, Na = (e, t, i) => {
568
+ if (e.locked) return e;
569
+ const n = Qe({ origin: i, point: e.computed.center, rotation: -t });
532
570
  if ("points" in e) {
533
571
  if (e.type === "brush") {
534
- const a = e.points.map((r) => r.map((l) => [l[0] + n[0] - e.computed.center[0], l[1] + n[1] - e.computed.center[1]]));
535
- return { ...e, points: a, rotation: (e.rotation ?? 0) + t };
572
+ const o = e.points.map((r) => r.map((l) => [l[0] + n[0] - e.computed.center[0], l[1] + n[1] - e.computed.center[1]]));
573
+ return { ...e, points: o, rotation: (e.rotation ?? 0) + t };
536
574
  }
537
- const o = e.points.map((a) => me({ origin: i, point: a, rotation: -t }));
538
- return { ...e, points: o };
575
+ const a = e.points.map((o) => Qe({ origin: i, point: o, rotation: -t }));
576
+ return { ...e, points: a };
539
577
  }
540
578
  return { ...e, x: e.x + n[0] - e.computed.center[0], y: e.y + n[1] - e.computed.center[1], rotation: (e.rotation ?? 0) + t };
541
- }, yn = (e, t, i, n, o, a, r) => {
579
+ }, bn = (e, t, i, n, a, o, r) => {
580
+ if (i.locked) return i;
542
581
  switch (i.type) {
543
582
  case "line":
544
- return ((l, s, d, h) => {
545
- const c = [Ze(l[0], h), Ze(l[1], h)], f = tt(c, s.rotation ?? 0, s.computed.center), p = Xe(["points", d.anchor], f, s);
583
+ return ((l, s, c, h) => {
584
+ const d = [ze(l[0], h), ze(l[1], h)], u = tt(d, s.rotation ?? 0, s.computed.center), p = Xe(["points", c.anchor], u, s);
546
585
  return ii(p, h);
547
- })(t, i, n, o);
586
+ })(t, i, n, a);
548
587
  case "polygon":
549
- return ((l, s, d, h) => {
550
- const c = [Ze(l[0], h), Ze(l[1], h)], f = tt(c, s.rotation ?? 0, s.computed.center), p = Xe(["points", d.anchor], f, s);
551
- return At(p, h);
552
- })(t, i, n, o);
588
+ return ((l, s, c, h) => {
589
+ const d = [ze(l[0], h), ze(l[1], h)], u = tt(d, s.rotation ?? 0, s.computed.center), p = Xe(["points", c.anchor], u, s);
590
+ return zt(p, h);
591
+ })(t, i, n, a);
553
592
  case "curve":
554
- return ((l, s, d, h) => {
555
- const c = [Ze(l[0], h), Ze(l[1], h)], f = s.computed.center, p = tt(c, s.rotation ?? 0, f), m = Xe(["points", d.anchor], p, s);
556
- return Ht(m, h);
557
- })(t, i, n, o);
593
+ return ((l, s, c, h) => {
594
+ const d = [ze(l[0], h), ze(l[1], h)], u = s.computed.center, p = tt(d, s.rotation ?? 0, u), f = Xe(["points", c.anchor], p, s);
595
+ return At(f, h);
596
+ })(t, i, n, a);
558
597
  case "brush":
559
- return ((l, s, d, h, c, f) => {
560
- const p = Hi({ ...s, scaleX: 1, scaleY: 1 }, h), m = s.computed.borders, { borderX: u, borderHeight: S, borderY: w, borderWidth: x, isXinverted: b, isYinverted: y } = St(l, s, d, h, c, f), g = Math.max(0, p.width - 2 * h.selectionPadding), P = Math.max(0, p.height - 2 * h.selectionPadding), z = Math.max(0, x - 2 * h.selectionPadding), D = Math.max(0, S - 2 * h.selectionPadding), A = g ? z / g : 1, H = P ? D / P : 1;
598
+ return ((l, s, c, h, d, u) => {
599
+ const p = Ai({ ...s, scaleX: 1, scaleY: 1 }, h), f = s.computed.borders, { borderX: m, borderHeight: b, borderY: x, borderWidth: k, isXinverted: M, isYinverted: S } = vt(l, s, c, h, d, u), g = Math.max(0, p.width - 2 * h.selectionPadding), P = Math.max(0, p.height - 2 * h.selectionPadding), z = Math.max(0, k - 2 * h.selectionPadding), N = Math.max(0, b - 2 * h.selectionPadding), D = g ? z / g : 1, E = P ? N / P : 1;
561
600
  if (!g || !P) return s;
562
- const Z = We(u - m.x) + (b ? 2 * m.x + p.width : 0), E = We(w - m.y) + (y ? 2 * m.y + p.height : 0);
563
- return Zt({ ...s, points: s.points.map((F) => F.map(([W, I]) => [b ? -W + Z : W + Z, y ? -I + E : I + E])), scaleX: A, scaleY: H }, h);
564
- })(t, i, n, o, a, r);
601
+ const A = Be(m - f.x) + (M ? 2 * f.x + p.width : 0), T = Be(x - f.y) + (S ? 2 * f.y + p.height : 0);
602
+ return Zt({ ...s, points: s.points.map((B) => B.map(([F, X]) => [M ? -F + A : F + A, S ? -X + T : X + T])), scaleX: D, scaleY: E }, h);
603
+ })(t, i, n, a, o, r);
565
604
  case "circle":
566
- return ((l, s, d, h, c) => {
567
- const { borderX: f, borderHeight: p, borderY: m, borderWidth: u } = St(l, s, d, h, !0, c);
568
- return Jt({ ...s, radius: Math.max(0, u / 2 - h.selectionPadding), x: f + u / 2, y: m + p / 2 }, h);
569
- })(t, i, n, o, r);
605
+ return ((l, s, c, h, d) => {
606
+ const { borderX: u, borderHeight: p, borderY: f, borderWidth: m } = vt(l, s, c, h, !0, d);
607
+ return Jt({ ...s, radius: Math.max(0, m / 2 - h.selectionPadding), x: u + m / 2, y: f + p / 2 }, h);
608
+ })(t, i, n, a, r);
570
609
  case "ellipse":
571
- return ((l, s, d, h, c = !1, f = !1) => {
572
- const { borderX: p, borderHeight: m, borderY: u, borderWidth: S } = St(l, s, d, h, c, f);
573
- return ti({ ...s, radiusX: Math.max(0, S / 2 - h.selectionPadding), radiusY: Math.max(0, m / 2 - h.selectionPadding), x: p + S / 2, y: u + m / 2 }, h);
574
- })(t, i, n, o, a, r);
610
+ return ((l, s, c, h, d = !1, u = !1) => {
611
+ const { borderX: p, borderHeight: f, borderY: m, borderWidth: b } = vt(l, s, c, h, d, u);
612
+ return ti({ ...s, radiusX: Math.max(0, b / 2 - h.selectionPadding), radiusY: Math.max(0, f / 2 - h.selectionPadding), x: p + b / 2, y: m + f / 2 }, h);
613
+ })(t, i, n, a, o, r);
575
614
  case "rect":
576
615
  case "square":
577
- return ((l, s, d, h, c = !1, f = !1) => {
578
- const { borderX: p, borderHeight: m, borderY: u, borderWidth: S } = St(l, s, d, h, c, f);
579
- return Kt({ ...s, width: Math.max(0, S - 2 * h.selectionPadding), height: Math.max(0, m - 2 * h.selectionPadding), x: p + h.selectionPadding, y: u + h.selectionPadding }, h);
580
- })(t, i, n, o, i.type === "square" || a, r);
616
+ return ((l, s, c, h, d = !1, u = !1) => {
617
+ const { borderX: p, borderHeight: f, borderY: m, borderWidth: b } = vt(l, s, c, h, d, u);
618
+ return Kt({ ...s, width: Math.max(0, b - 2 * h.selectionPadding), height: Math.max(0, f - 2 * h.selectionPadding), x: p + h.selectionPadding, y: m + h.selectionPadding }, h);
619
+ })(t, i, n, a, i.type === "square" || o, r);
581
620
  case "text":
582
- return ((l, s, d, h, c, f) => {
583
- const { borderX: p, borderHeight: m, borderY: u, borderWidth: S, isXinverted: w, isYinverted: x } = St(s, d, h, c, !0, f), b = Math.max(0, S - 2 * c.selectionPadding), y = Math.max(0, m - 2 * c.selectionPadding), g = oi({ ...d, width: b, height: y, x: p + c.selectionPadding, y: u + c.selectionPadding, flipX: w ? !d.flipX : !!d.flipX, flipY: x ? !d.flipY : !!d.flipY }, c);
584
- return { ...g, fontSize: ai(l, g.value, g.width, g.style?.fontBold ?? !1, g.style?.fontItalic ?? !1, g.style?.fontFamily) };
585
- })(e, t, i, n, o, r);
621
+ return ((l, s, c, h, d, u) => {
622
+ const { borderX: p, borderHeight: f, borderY: m, borderWidth: b, isXinverted: x, isYinverted: k } = vt(s, c, h, d, !0, u), M = Math.max(0, b - 2 * d.selectionPadding), S = Math.max(0, f - 2 * d.selectionPadding), g = ai({ ...c, width: M, height: S, x: p + d.selectionPadding, y: m + d.selectionPadding, flipX: x ? !c.flipX : !!c.flipX, flipY: k ? !c.flipY : !!c.flipY }, d);
623
+ return { ...g, fontSize: oi(l, g.value, g.width, g.style?.fontBold ?? !1, g.style?.fontItalic ?? !1, g.style?.fontFamily) };
624
+ })(e, t, i, n, a, r);
586
625
  case "picture":
587
- return ((l, s, d, h, c) => {
588
- const { borderX: f, borderHeight: p, borderY: m, borderWidth: u, isXinverted: S, isYinverted: w } = St(l, s, d, h, !0, c), x = Math.max(0, u - 2 * h.selectionPadding), b = Math.max(0, p - 2 * h.selectionPadding);
589
- return ni({ ...s, width: x, height: b, x: f + h.selectionPadding, y: m + h.selectionPadding, flipX: S ? !s.flipX : !!s.flipX, flipY: w ? !s.flipY : !!s.flipY }, h);
590
- })(t, i, n, o, r);
626
+ return ((l, s, c, h, d) => {
627
+ const { borderX: u, borderHeight: p, borderY: f, borderWidth: m, isXinverted: b, isYinverted: x } = vt(l, s, c, h, !0, d), k = Math.max(0, m - 2 * h.selectionPadding), M = Math.max(0, p - 2 * h.selectionPadding);
628
+ return ni({ ...s, width: k, height: M, x: u + h.selectionPadding, y: f + h.selectionPadding, flipX: b ? !s.flipX : !!s.flipX, flipY: x ? !s.flipY : !!s.flipY }, h);
629
+ })(t, i, n, a, r);
591
630
  default:
592
631
  return i;
593
632
  }
594
- }, Za = (e, t, i, n, o, a, r) => {
595
- if (i.type !== "group") return U(i).map((m) => yn(e, t, m, n, o, a, r));
596
- const l = i, s = U(l), d = s.filter((m) => Jo.includes(m.type)), h = !d.some((m) => (m.rotation ?? 0) !== (d[0]?.rotation ?? 0)), c = (d[0]?.rotation ?? 0) !== 0 && d.length !== s.length, f = s.some((m) => ea.includes(m.type)), p = ((m, u, S, w, x, b) => {
597
- const { borders: y } = u.computed, { borderX: g, borderHeight: P, borderY: z, borderWidth: D, isXinverted: A, isYinverted: H } = St(m, u, S, w, x, b);
598
- return { newBorderX: g, newBorderY: z, newBorderWidth: D, newBorderHeight: P, widthMultiplier: (D - 2 * w.selectionPadding) / (y.width - 2 * w.selectionPadding || 1), heightMultiplier: (P - 2 * w.selectionPadding) / (y.height - 2 * w.selectionPadding || 1), isXinverted: A, isYinverted: H, groupCenter: [g + D / 2, z + P / 2], rotation: u.rotation ?? 0, settings: w, originalBorders: y };
599
- })(t, l, n, o, a || !h || f || c, r);
600
- return s.map((m) => {
601
- switch (m.type) {
633
+ }, Do = (e, t, i, n, a, o, r) => {
634
+ if (i.type !== "group") return _(i).map((f) => bn(e, t, f, n, a, o, r));
635
+ const l = i, s = _(l), c = s.filter((f) => so.includes(f.type)), h = !c.some((f) => (f.rotation ?? 0) !== (c[0]?.rotation ?? 0)), d = (c[0]?.rotation ?? 0) !== 0 && c.length !== s.length, u = s.some((f) => ro.includes(f.type)), p = ((f, m, b, x, k, M) => {
636
+ const { borders: S } = m.computed, { borderX: g, borderHeight: P, borderY: z, borderWidth: N, isXinverted: D, isYinverted: E } = vt(f, m, b, x, k, M);
637
+ return { newBorderX: g, newBorderY: z, newBorderWidth: N, newBorderHeight: P, widthMultiplier: (N - 2 * x.selectionPadding) / (S.width - 2 * x.selectionPadding || 1), heightMultiplier: (P - 2 * x.selectionPadding) / (S.height - 2 * x.selectionPadding || 1), isXinverted: D, isYinverted: E, groupCenter: [g + N / 2, z + P / 2], rotation: m.rotation ?? 0, settings: x, originalBorders: S };
638
+ })(t, l, n, a, o || !h || u || d, r);
639
+ return s.map((f) => {
640
+ if (f.locked) return f;
641
+ switch (f.type) {
602
642
  case "rect":
603
643
  case "square":
604
- return ((u, S, w) => {
605
- const { isXinverted: x, isYinverted: b, settings: y, widthMultiplier: g, heightMultiplier: P } = w, z = (x || b) && !(x && b) && (u.rotation ?? 0) !== 0 && S.rotation !== u.rotation, D = vt(u, S, w), A = (u.width || 1) * g, H = (u.height || 1) * P, Z = mt(w, D.x, D.y, A, H);
606
- return Kt({ ...u, width: A, height: H, x: Z[0] - A / 2, y: Z[1] - H / 2, rotation: z ? -(u.rotation ?? 0) : u.rotation ?? 0 }, y);
607
- })(m, l, p);
644
+ return Ma(f, l, p);
608
645
  case "picture":
609
- return ((u, S, w) => {
610
- const { isXinverted: x, isYinverted: b, settings: y, widthMultiplier: g, heightMultiplier: P } = w, z = vt(u, S, w), D = (u.width === 0 || u.height === 0 ? u.ratio ?? 1 : u.width) * g, A = (u.width === 0 || u.height === 0 ? u.ratio ?? 1 : u.height) * P, H = mt(w, z.x, z.y, D, A), Z = (x || b) && !(x && b) && (u.rotation ?? 0) !== 0 && S.rotation !== u.rotation;
611
- return ni({ ...u, width: D, height: A, x: H[0] - D / 2, y: H[1] - A / 2, flipX: x ? !u.flipX : !!u.flipX, flipY: b ? !u.flipY : !!u.flipY, rotation: Z ? -(u.rotation ?? 0) : u.rotation ?? 0 }, y);
612
- })(m, l, p);
646
+ return Ea(f, l, p);
613
647
  case "text":
614
- return ((u, S, w, x) => {
615
- const { isXinverted: b, isYinverted: y, settings: g, widthMultiplier: P, heightMultiplier: z } = x, D = (b || y) && !(b && y) && (S.rotation ?? 0) !== 0 && w.rotation !== S.rotation, A = vt(S, w, x), H = (S.width === 0 || S.height === 0 ? S.ratio ?? 1 : S.width) * P, Z = (S.width === 0 || S.height === 0 ? S.ratio ?? 1 : S.height) * z, E = mt(x, A.x, A.y, H, Z), F = oi({ ...S, width: H, height: Z, x: E[0] - H / 2, y: E[1] - Z / 2, flipX: b ? !S.flipX : !!S.flipX, flipY: y ? !S.flipY : !!S.flipY, rotation: D ? -(S.rotation ?? 0) : S.rotation ?? 0 }, g);
616
- return { ...F, fontSize: ai(u, F.value, F.width, F.style?.fontBold ?? !1, F.style?.fontItalic ?? !1, F.style?.fontFamily) };
617
- })(e, m, l, p);
648
+ return Wa(e, f, l, p);
618
649
  case "ellipse":
619
- return ((u, S, w) => {
620
- const { isXinverted: x, isYinverted: b, settings: y, widthMultiplier: g, heightMultiplier: P } = w, z = (x || b) && !(x && b) && (u.rotation ?? 0) !== 0 && S.rotation !== u.rotation, D = vt(u, S, w), A = (u.radiusX || 0.5) * g, H = (u.radiusY || 0.5) * P, Z = mt(w, D.x, D.y, 2 * A, 2 * H);
621
- return ti({ ...u, radiusX: A, radiusY: H, x: Z[0], y: Z[1], rotation: z ? -(u.rotation ?? 0) : u.rotation ?? 0 }, y);
622
- })(m, l, p);
650
+ return Ta(f, l, p);
623
651
  case "circle":
624
- return ((u, S, w) => {
625
- const x = vt(u, S, w), b = (u.radius || 0.5) * w.widthMultiplier, y = mt(w, x.x, x.y, 2 * b, 2 * b);
626
- return Jt({ ...u, radius: b, x: y[0], y: y[1] }, w.settings);
627
- })(m, l, p);
652
+ return Ha(f, l, p);
628
653
  case "brush":
629
- return ((u, S, w) => {
630
- const { isXinverted: x, isYinverted: b, settings: y, widthMultiplier: g, heightMultiplier: P } = w, z = Hi({ ...u, scaleX: 1, scaleY: 1 }, y), D = z.width - 2 * y.selectionPadding, A = z.height - 2 * y.selectionPadding, H = u.scaleX ?? 1 ? (u.scaleX ?? 1) * g : g / D, Z = u.scaleY ?? 1 ? (u.scaleY ?? 1) * P : P / A, E = D * H, F = A * Z, W = vt(u, S, w), I = mt(w, W.x, W.y, E, F), oe = We(I[0] - E / 2 - u.computed.borders.x - y.selectionPadding) + (x ? 2 * u.computed.borders.x + z.width : 0), te = We(I[1] - F / 2 - u.computed.borders.y - y.selectionPadding) + (b ? 2 * u.computed.borders.y + z.height : 0), R = (x || b) && !(x && b) && (u.rotation ?? 0) !== 0 && S.rotation !== u.rotation;
631
- return Zt({ ...u, points: u.points.map(($) => $.map(([j, ce]) => [x ? -j + oe : j + oe, b ? -ce + te : ce + te])), scaleX: H, scaleY: Z, rotation: R ? -(u.rotation ?? 0) : u.rotation ?? 0 }, w.settings);
632
- })(m, l, p);
654
+ return Qa(f, l, p);
633
655
  case "line":
634
656
  case "polygon":
635
657
  case "curve":
636
- return Ma(m, l, p);
658
+ return Da(f, l, p);
637
659
  default:
638
- return yn(e, t, m, n, o, a, r);
660
+ return bn(e, t, f, n, a, o, r);
639
661
  }
640
662
  });
641
- }, To = (e, t, i, n) => {
663
+ }, Ba = (e, t, i, n) => {
664
+ if (e.locked) return e;
642
665
  switch (e.type) {
643
666
  case "rect":
644
667
  case "square":
@@ -650,42 +673,42 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
650
673
  case "line":
651
674
  case "polygon":
652
675
  case "curve":
653
- return _e({ ...e, points: e.points.map(([o, a]) => [o + t, a + i]) }, n);
676
+ return _e({ ...e, points: e.points.map(([a, o]) => [a + t, o + i]) }, n);
654
677
  case "brush":
655
- return _e({ ...e, points: e.points.map((o) => o.map(([a, r]) => [a + t, r + i])) }, n);
678
+ return _e({ ...e, points: e.points.map((a) => a.map(([o, r]) => [o + t, r + i])) }, n);
656
679
  default:
657
680
  return e;
658
681
  }
659
- }, Do = (e, t, i, n, o) => {
660
- const a = t.computed.borders, r = ((d, h) => h ? [Math.abs(d[0]) > Math.abs(d[1]) ? d[0] : 0, Math.abs(d[1]) > Math.abs(d[0]) ? d[1] : 0] : d)([e[0] - i[0], e[1] - i[1]], o), l = r[0] === 0 ? 0 : Ze(a.x + n.selectionPadding + r[0], n) - (a.x + n.selectionPadding), s = r[1] === 0 ? 0 : Ze(a.y + n.selectionPadding + r[1], n) - (a.y + n.selectionPadding);
661
- return U(t).map((d) => To(d, l, s, n));
682
+ }, Oa = (e, t, i, n, a) => {
683
+ const o = t.computed.borders, r = ((c, h) => h ? [Math.abs(c[0]) > Math.abs(c[1]) ? c[0] : 0, Math.abs(c[1]) > Math.abs(c[0]) ? c[1] : 0] : c)([e[0] - i[0], e[1] - i[1]], a), l = r[0] === 0 ? 0 : ze(o.x + n.selectionPadding + r[0], n) - (o.x + n.selectionPadding), s = r[1] === 0 ? 0 : ze(o.y + n.selectionPadding + r[1], n) - (o.y + n.selectionPadding);
684
+ return _(t).map((c) => Ba(c, l, s, n));
662
685
  }, _e = (e, t) => {
663
686
  switch (e.type) {
664
687
  case "rect":
665
688
  case "square":
666
- return ca(e, t);
689
+ return mo(e, t);
667
690
  case "ellipse":
668
- return ya(e, t);
691
+ return ko(e, t);
669
692
  case "circle":
670
- return ga(e, t);
693
+ return Qo(e, t);
671
694
  case "picture":
672
- return Ca(e, t);
695
+ return Zo(e, t);
673
696
  case "text":
674
- return ka(e, t);
697
+ return zo(e, t);
675
698
  case "line":
676
- return xa(e, t);
677
- case "polygon":
678
699
  return Vo(e, t);
700
+ case "polygon":
701
+ return za(e, t);
679
702
  case "curve":
680
- return Zo(e, t);
703
+ return Aa(e, t);
681
704
  case "brush":
682
- return ia(e, t);
705
+ return co(e, t);
683
706
  default:
684
707
  return e;
685
708
  }
686
- }, bn = ({ ctx: e, shape: t, settings: i, selectionWidth: n, selectionColor: o, hoverMode: a, selectionMode: r, withAnchors: l = !0 }) => {
687
- switch (i.debug && ((s, d, h, c) => {
688
- d.selection && c.debug && (s.save(), s.scale(c.canvasSize.scaleRatio, c.canvasSize.scaleRatio), s.translate(c.canvasOffset[0], c.canvasOffset[1]), Te(s, { fillColor: "transparent", strokeColor: "green", lineWidth: h / c.canvasSize.scaleRatio }), s.strokeRect(d.computed.boundingBox.x, d.computed.boundingBox.y, d.computed.boundingBox.width, d.computed.boundingBox.height), s.restore());
709
+ }, Qn = ({ ctx: e, shape: t, settings: i, selectionWidth: n, selectionColor: a, hoverMode: o, selectionMode: r, withAnchors: l = !0 }) => {
710
+ switch (i.debug && ((s, c, h, d) => {
711
+ c.selection && d.debug && (s.save(), s.scale(d.canvasSize.scaleRatio, d.canvasSize.scaleRatio), s.translate(d.canvasOffset[0], d.canvasOffset[1]), De(s, { fillColor: "transparent", strokeColor: "green", lineWidth: h / d.canvasSize.scaleRatio }), s.strokeRect(c.computed.boundingBox.x, c.computed.boundingBox.y, c.computed.boundingBox.width, c.computed.boundingBox.height), s.restore());
689
712
  })(e, t, n, i), t.type) {
690
713
  case "rect":
691
714
  case "square":
@@ -694,57 +717,57 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
694
717
  case "picture":
695
718
  case "text":
696
719
  case "brush":
697
- ((s, d, h, c, f, p) => {
698
- if (d.selection && (Pt(s, f, d.rotation, d.computed.center), f.debug && (Te(s, { fillColor: "transparent", strokeColor: "red", lineWidth: c / f.canvasSize.scaleRatio }), s.strokeRect(d.computed.outerBorders.x, d.computed.outerBorders.y, d.computed.outerBorders.width, d.computed.outerBorders.height)), Te(s, { fillColor: "transparent", strokeColor: h, lineWidth: c / f.canvasSize.scaleRatio }), d.selection.shapePath ? s.stroke(d.selection.shapePath) : s.stroke(d.selection.border), p && !d.locked)) {
699
- d.selection.shapePath && s.stroke(d.selection.border), d.selection.line && s.stroke(d.selection.line), Te(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / f.canvasSize.scaleRatio, shadowColor: h, shadowBlur: 0 });
700
- for (const m of d.selection.anchors) s.fill(m), s.stroke(m);
720
+ ((s, c, h, d, u, p) => {
721
+ if (c.selection && (kt(s, u, c.rotation, c.computed.center), u.debug && (De(s, { fillColor: "transparent", strokeColor: "red", lineWidth: d / u.canvasSize.scaleRatio }), s.strokeRect(c.computed.outerBorders.x, c.computed.outerBorders.y, c.computed.outerBorders.width, c.computed.outerBorders.height)), De(s, { fillColor: "transparent", strokeColor: h, lineWidth: d / u.canvasSize.scaleRatio }), c.selection.shapePath ? s.stroke(c.selection.shapePath) : s.stroke(c.selection.border), p && !c.locked)) {
722
+ c.selection.shapePath && s.stroke(c.selection.border), c.selection.line && s.stroke(c.selection.line), De(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / u.canvasSize.scaleRatio, shadowColor: h, shadowBlur: 0 });
723
+ for (const f of c.selection.anchors) s.fill(f), s.stroke(f);
701
724
  }
702
- })(e, t, o, n, i, l);
725
+ })(e, t, a, n, i, l);
703
726
  break;
704
727
  case "group":
705
- ((s, d, h, c, f, p, m) => {
706
- if (d.selection && (d.shapes.forEach((u) => {
707
- Te(s, { fillColor: "transparent", strokeColor: h, lineWidth: c / p.canvasSize.scaleRatio }), Pt(s, p, u.rotation, u.computed.center), u.selection?.shapePath && s.stroke(u.selection.shapePath), s.restore();
708
- }), f.mode !== "rotate" && (Pt(s, p, d.rotation, d.computed.center), p.debug && (Te(s, { fillColor: "transparent", strokeColor: "red", lineWidth: c / p.canvasSize.scaleRatio }), s.strokeRect(d.computed.outerBorders.x, d.computed.outerBorders.y, d.computed.outerBorders.width, d.computed.outerBorders.height)), Te(s, { fillColor: "transparent", strokeColor: h, lineWidth: c / p.canvasSize.scaleRatio }), m && !d.locked))) {
709
- s.stroke(d.selection.border), d.selection.line && s.stroke(d.selection.line), Te(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / p.canvasSize.scaleRatio });
710
- for (const u of d.selection.anchors) s.fill(u), s.stroke(u);
728
+ ((s, c, h, d, u, p, f) => {
729
+ if (c.selection && (c.shapes.forEach((m) => {
730
+ De(s, { fillColor: "transparent", strokeColor: h, lineWidth: d / p.canvasSize.scaleRatio }), kt(s, p, m.rotation, m.computed.center), m.selection?.shapePath && s.stroke(m.selection.shapePath), s.restore();
731
+ }), u.mode !== "rotate" && (kt(s, p, c.rotation, c.computed.center), p.debug && (De(s, { fillColor: "transparent", strokeColor: "red", lineWidth: d / p.canvasSize.scaleRatio }), s.strokeRect(c.computed.outerBorders.x, c.computed.outerBorders.y, c.computed.outerBorders.width, c.computed.outerBorders.height)), De(s, { fillColor: "transparent", strokeColor: h, lineWidth: d / p.canvasSize.scaleRatio }), f && !c.locked))) {
732
+ s.stroke(c.selection.border), c.selection.line && s.stroke(c.selection.line), De(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / p.canvasSize.scaleRatio });
733
+ for (const m of c.selection.anchors) s.fill(m), s.stroke(m);
711
734
  }
712
- })(e, t, o, n, r, i, l);
735
+ })(e, t, a, n, r, i, l);
713
736
  break;
714
737
  case "polygon":
715
738
  case "line":
716
739
  case "curve":
717
- (({ ctx: s, shape: d, withAnchors: h, selectionWidth: c, selectionColor: f, hoverMode: p, settings: m }) => {
718
- if (d.selection && (Pt(s, m, d.rotation, d.computed.center), m.debug && (Te(s, { fillColor: "transparent", strokeColor: "red", lineWidth: c / m.canvasSize.scaleRatio }), s.strokeRect(d.computed.outerBorders.x, d.computed.outerBorders.y, d.computed.outerBorders.width, d.computed.outerBorders.height)), Te(s, { fillColor: "transparent", strokeColor: f, lineWidth: c / m.canvasSize.scaleRatio }), d.selection.shapePath && s.stroke(d.selection.shapePath), h && !d.locked)) {
719
- Te(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / m.canvasSize.scaleRatio, shadowColor: f, shadowBlur: 0 });
720
- for (let u = 0; u < d.selection.anchors.length; u++) {
721
- const S = d.selection.anchors[u];
722
- p.mode === "resize" && p.anchor === u ? (s.shadowBlur = 10, s.fill(S), s.shadowBlur = 0) : s.fill(S), s.stroke(S);
740
+ (({ ctx: s, shape: c, withAnchors: h, selectionWidth: d, selectionColor: u, hoverMode: p, settings: f }) => {
741
+ if (c.selection && (kt(s, f, c.rotation, c.computed.center), f.debug && (De(s, { fillColor: "transparent", strokeColor: "red", lineWidth: d / f.canvasSize.scaleRatio }), s.strokeRect(c.computed.outerBorders.x, c.computed.outerBorders.y, c.computed.outerBorders.width, c.computed.outerBorders.height)), De(s, { fillColor: "transparent", strokeColor: u, lineWidth: d / f.canvasSize.scaleRatio }), c.selection.shapePath && s.stroke(c.selection.shapePath), h && !c.locked)) {
742
+ De(s, { fillColor: "rgb(255,255,255)", strokeColor: "rgb(150,150,150)", lineWidth: 2 / f.canvasSize.scaleRatio, shadowColor: u, shadowBlur: 0 });
743
+ for (let m = 0; m < c.selection.anchors.length; m++) {
744
+ const b = c.selection.anchors[m];
745
+ p.mode === "resize" && p.anchor === m ? (s.shadowBlur = 10, s.fill(b), s.shadowBlur = 0) : s.fill(b), s.stroke(b);
723
746
  }
724
747
  }
725
- })({ ctx: e, shape: t, withAnchors: l, selectionWidth: n, selectionColor: o, hoverMode: a, settings: i });
748
+ })({ ctx: e, shape: t, withAnchors: l, selectionWidth: n, selectionColor: a, hoverMode: o, settings: i });
726
749
  }
727
750
  e.restore();
728
- }, za = ({ ctx: e, selectionFrame: t, settings: i }) => {
729
- Pt(e, i), ((n, o, a) => {
730
- Te(n, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / a.canvasSize.scaleRatio }), n.fillRect(o[0][0], o[0][1], o[1][0] - o[0][0], o[1][1] - o[0][1]), n.strokeRect(o[0][0], o[0][1], o[1][0] - o[0][0], o[1][1] - o[0][1]);
751
+ }, Eo = ({ ctx: e, selectionFrame: t, settings: i }) => {
752
+ kt(e, i), ((n, a, o) => {
753
+ De(n, { fillColor: "rgba(170,170,170, 0.1)", strokeColor: "rgb(170,170,170)", lineWidth: 1 / o.canvasSize.scaleRatio }), n.fillRect(a[0][0], a[0][1], a[1][0] - a[0][0], a[1][1] - a[0][1]), n.strokeRect(a[0][0], a[0][1], a[1][0] - a[0][0], a[1][1] - a[0][1]);
731
754
  })(e, t.frame, i), e.restore();
732
- }, Wi = (e, t) => U(e).map((i) => ({ ...To(i, 20, 20, t), id: Ce(`${i.type}_`) })), Ni = (e) => e.filter((t) => t != null), vi = (e, t, i) => t < 0 || i < 0 || t > e.length - 1 || i > e.length - 1 ? e : t < i ? [...e.slice(0, t), ...e.slice(t + 1, i + 1), e[t], ...e.slice(i + 1, e.length)] : [...e.slice(0, i), e[t], ...e.slice(i, t), ...e.slice(t + 1, e.length)], Eo = (e) => {
755
+ }, Ri = (e, t) => _(e).map((i) => ({ ...Ba(i, 20, 20, t), id: Le(`${i.type}_`) })), Ni = (e) => e.filter((t) => t != null), vi = (e, t, i) => t < 0 || i < 0 || t > e.length - 1 || i > e.length - 1 ? e : t < i ? [...e.slice(0, t), ...e.slice(t + 1, i + 1), e[t], ...e.slice(i + 1, e.length)] : [...e.slice(0, i), e[t], ...e.slice(i, t), ...e.slice(t + 1, e.length)], Fa = (e) => {
733
756
  const t = new DOMParser().parseFromString(e, "text/xml").getElementsByTagName("svg")[0];
734
757
  if (!t) return "";
735
758
  const i = t.getAttribute("width"), n = t.getAttribute("height");
736
- let o;
737
- if (i || n) o = e;
759
+ let a;
760
+ if (i || n) a = e;
738
761
  else {
739
762
  const r = t.getAttribute("viewBox") ?? "0 0 300 300", [, , l, s] = r.split(" ");
740
- t.setAttribute("width", l ?? "300"), t.setAttribute("height", s ?? "300"), o = new XMLSerializer().serializeToString(t);
763
+ t.setAttribute("width", l ?? "300"), t.setAttribute("height", s ?? "300"), a = new XMLSerializer().serializeToString(t);
741
764
  }
742
- const a = new Blob([o], { type: "image/svg+xml" });
743
- return URL.createObjectURL(a);
744
- }, Io = (e) => (e instanceof File ? e.name : e).includes(".svg"), Ro = (e) => Io(e) ? fetch(e).then((t) => t.text()).then((t) => Eo(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), Qn = (e, t) => {
765
+ const o = new Blob([a], { type: "image/svg+xml" });
766
+ return URL.createObjectURL(o);
767
+ }, Ya = (e) => (e instanceof File ? e.name : e).includes(".svg"), Xa = (e) => Ya(e) ? fetch(e).then((t) => t.text()).then((t) => Fa(t)) : fetch(e).then((t) => t.blob()).then((t) => URL.createObjectURL(t)), wn = (e, t) => {
745
768
  const i = document.createElement("a");
746
769
  i.href = e, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i);
747
- }, Aa = (e) => e.src.includes("<svg") ? e.src : ((t) => {
770
+ }, Io = (e) => e.src.includes("<svg") ? e.src : ((t) => {
748
771
  const i = document.createElement("canvas");
749
772
  i.width = t.width, i.height = t.height;
750
773
  const n = i.getContext("2d");
@@ -752,728 +775,756 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
752
775
  })(e.img), mi = ({ shapes: e, settings: t }) => {
753
776
  const i = document.createElement("canvas"), n = i.getContext("2d");
754
777
  if (!n) throw new Error("No context found for canvas");
755
- const { realHeight: o, realWidth: a } = t.canvasSize;
756
- i.width = a, i.height = o, n.clearRect(0, 0, a, o), So(n);
757
- for (let r = e.length - 1; r >= 0; r--) Ao(n, e[r], t);
778
+ const { realHeight: a, realWidth: o } = t.canvasSize;
779
+ i.width = o, i.height = a, n.clearRect(0, 0, o, a), ya(n);
780
+ for (let r = e.length - 1; r >= 0; r--) Ra(n, e[r], t);
758
781
  return i.toDataURL("image/png");
759
- }, wn = ({ shapes: e, settings: t, view: i }) => {
782
+ }, xn = ({ shapes: e, settings: t, view: i }) => {
760
783
  if (i === "fitToShapes" && !e.length) throw new Error("No image found to export");
761
784
  if (i === "fitToShapes") {
762
- const o = Math.min(...e.map((d) => d.computed.boundingBox.x)), a = Math.max(...e.map((d) => d.computed.boundingBox.x + d.computed.boundingBox.width)), r = Math.min(...e.map((d) => d.computed.boundingBox.y)), l = Math.max(...e.map((d) => d.computed.boundingBox.y + d.computed.boundingBox.height)), s = { ...t, canvasOffset: [-o, -r], canvasZoom: 1, canvasSize: { realWidth: a - o, realHeight: l - r, width: a - o, height: l - r, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
785
+ const a = Math.min(...e.map((c) => c.computed.boundingBox.x)), o = Math.max(...e.map((c) => c.computed.boundingBox.x + c.computed.boundingBox.width)), r = Math.min(...e.map((c) => c.computed.boundingBox.y)), l = Math.max(...e.map((c) => c.computed.boundingBox.y + c.computed.boundingBox.height)), s = { ...t, canvasOffset: [-a, -r], canvasZoom: 1, canvasSize: { realWidth: o - a, realHeight: l - r, width: o - a, height: l - r, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
763
786
  return mi({ shapes: e, settings: s });
764
787
  }
765
788
  if (i === "defaultView") {
766
- const o = { ...t, canvasOffset: [0, 0], canvasZoom: 1, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
767
- return mi({ shapes: e, settings: o });
789
+ const a = { ...t, canvasOffset: [0, 0], canvasZoom: 1, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: 1, scaleRatioWithNoZoom: 1 } };
790
+ return mi({ shapes: e, settings: a });
768
791
  }
769
792
  const n = { ...t, canvasSize: { ...t.canvasSize, width: t.canvasSize.realWidth, height: t.canvasSize.realHeight, scaleRatio: t.canvasZoom, scaleRatioWithNoZoom: 1 } };
770
793
  return mi({ shapes: e, settings: n });
771
- }, Ha = (e, t, i) => {
772
- return o = Oi(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(o))}`;
773
- var o;
774
- }, Ta = (e) => {
794
+ }, Wo = (e, t, i) => {
795
+ return a = Bi(e, t, i), `data:text/plain;charset=utf-8,${encodeURIComponent(JSON.stringify(a))}`;
796
+ var a;
797
+ }, Ro = (e) => {
775
798
  const t = ["img", "id", "selection", "path", "arrows", "tempPoint", "computed", ["flipX", [void 0, !1]], ["flipY", [void 0, !1]]];
776
- return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? yi(t, i) : yi(t, { ...i, src: Aa(i) }));
777
- }, Oi = (e, t, i) => ({ shapes: Ta(e), config: { width: t, height: i } }), xn = (e, t) => _e({ ...e, id: Ce(`${e.type}_`) }, t), Da = (e, t, i, n) => {
778
- const o = re([]), a = re(void 0), r = re({ dataChanged: [] }), [l, s] = K(void 0), [d, h] = K(void 0), [c, f] = K(void 0), [p, m] = K(void 0), [u, S] = K({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), w = X((M) => {
779
- a.current = typeof M == "function" ? M(a.current) : M, h(a.current);
780
- }, []), x = u.cursor > 0, b = u.cursor < u.states.length - 1, y = o.current.length > 0, g = X(() => {
781
- S((M) => vo(M.states[M.cursor]?.shapes, o.current) ? M : { states: [...M.states.slice(0, M.cursor + 1), { shapes: o.current, selectedShape: a.current, source: "user" }], cursor: M.cursor + 1 });
782
- }, []), P = X((M) => {
783
- o.current = [...M, ...o.current];
784
- }, []), z = X((M, C = !1, Q = !1) => {
785
- const V = [];
786
- o.current = o.current.flatMap((N) => {
787
- const k = M.find((J) => J.id === N.id);
788
- if (k) {
789
- const J = C ? Wi(de([k], e), e)[0] : { ...k, id: Ce(`${N.type}_`) };
790
- return V.push(J), [J, N];
799
+ return e.map((i) => i.type !== "picture" || i.src.startsWith("http") ? Si(t, i) : Si(t, { ...i, src: Io(i) }));
800
+ }, Bi = (e, t, i) => ({ shapes: Ro(e), config: { width: t, height: i } }), Mn = (e, t) => _e({ ...e, id: Le(`${e.type}_`) }, t), No = (e, t, i, n) => {
801
+ const a = ce([]), o = ce(void 0), r = ce({ dataChanged: [] }), [l, s] = J(void 0), [c, h] = J(void 0), [d, u] = J(void 0), [p, f] = J(void 0), [m, b] = J({ states: [{ shapes: [], selectedShape: void 0, source: "remote" }], cursor: 0 }), x = G((Q) => {
802
+ o.current = typeof Q == "function" ? Q(o.current) : Q, h(o.current);
803
+ }, []), k = m.cursor > 0, M = m.cursor < m.states.length - 1, S = a.current.length > 0, g = G(() => {
804
+ b((Q) => va(Q.states[Q.cursor]?.shapes, a.current) ? Q : { states: [...Q.states.slice(0, Q.cursor + 1), { shapes: a.current, selectedShape: o.current, source: "user" }], cursor: Q.cursor + 1 });
805
+ }, []), P = G((Q) => {
806
+ a.current = [...Q, ...a.current];
807
+ }, []), z = G((Q, w = !1, y = !1) => {
808
+ const L = [];
809
+ a.current = a.current.flatMap((W) => {
810
+ const V = Q.find((U) => U.id === W.id);
811
+ if (V) {
812
+ const U = w ? Ri(pe([V], e), e)[0] : { ...V, id: Le(`${W.type}_`) };
813
+ return L.push(U), [U, W];
791
814
  }
792
- return N;
793
- }), Q && w(de(V, e));
794
- }, [e, w]), D = X((M, C, Q, V) => {
795
- if (M.target && "className" in M.target && ![go, fo].includes(M.target.className) || !V) return void f(void 0);
796
- const N = o.current.find((k) => U(d)?.map((J) => J.id).includes(k.id) ? !!Et(C, k, Q, e) : !!Po(C, k, Q, e));
797
- f(N);
798
- }, [e, d]), A = X(async (M, C = 300, Q = 300) => {
799
- const V = await Pa(M, C, Q, e);
800
- return P([V]), g(), V;
801
- }, [P, g, e]), H = X((M, C = !1) => {
802
- o.current = o.current.map((Q) => M.find((V) => V.id === Q.id) ?? Q), w((Q) => Q && de(U(Q).map((V) => M.find((N) => N.id === V.id) ?? V), e)), C && g();
803
- }, [g, w, e]), Z = X((M) => {
804
- const C = M.map((Q) => yi(["chosen"], Q));
805
- o.current = C, g();
806
- }, [g]), E = X((M) => {
807
- const C = new Set(M.map((Q) => Q.id));
808
- w((Q) => {
809
- const V = U(Q).map((N) => N.id);
810
- return V && C.size && V.find((N) => C.has(N)) ? void 0 : Q;
811
- }), o.current = o.current.filter((Q) => !C?.has(Q.id)), g();
812
- }, [g, w]), F = X((M) => {
813
- S((C) => {
814
- const Q = M(C);
815
- return o.current = C.states[Q]?.shapes ?? [], w(C.states[Q]?.selectedShape), Xe("cursor", Q, C);
815
+ return W;
816
+ }), y && x(pe(L, e));
817
+ }, [e, x]), N = G((Q, w, y, L) => {
818
+ if (Q.target && "className" in Q.target && ![ga, fa].includes(Q.target.className) || !L) return void u(void 0);
819
+ const W = a.current.find((V) => !V.locked && (_(c)?.map((U) => U.id).includes(V.id) ? !!Et(w, V, y, e) : !!La(w, V, y, e)));
820
+ u(W);
821
+ }, [e, c]), D = G(async (Q, w = 300, y = 300) => {
822
+ const L = await Ho(Q, w, y, e);
823
+ return P([L]), g(), L;
824
+ }, [P, g, e]), E = G((Q, w = !1) => {
825
+ a.current = a.current.map((y) => Q.find((L) => L.id === y.id) ?? y), x((y) => y && pe(_(y).map((L) => Q.find((W) => W.id === L.id) ?? L), e)), w && g();
826
+ }, [g, x, e]), A = G((Q) => {
827
+ const w = Q.map((y) => Si(["chosen"], y));
828
+ a.current = w, g();
829
+ }, [g]), T = G((Q) => {
830
+ const w = new Set(Q.map((y) => y.id));
831
+ x((y) => {
832
+ const L = _(y).map((W) => W.id);
833
+ return L && w.size && L.find((W) => w.has(W)) ? void 0 : y;
834
+ }), a.current = a.current.filter((y) => !w?.has(y.id)), g();
835
+ }, [g, x]), B = G((Q) => {
836
+ b((w) => {
837
+ const y = Q(w);
838
+ return a.current = w.states[y]?.shapes ?? [], x(w.states[y]?.selectedShape), Xe("cursor", y, w);
816
839
  });
817
- }, [w]), W = X(() => {
818
- F((M) => Math.max(0, M.cursor - 1));
819
- }, [F]), I = X(() => {
820
- F((M) => Math.min(M.states.length - 1, M.cursor + 1));
821
- }, [F]), oe = X((M, C) => {
822
- w(void 0), o.current = M, S((Q) => C.clearHistory ? { states: [{ shapes: M, selectedShape: void 0, source: C.source }], cursor: 0 } : { states: [...Q.states.slice(0, Q.cursor + 1), { shapes: M, selectedShape: void 0, source: C.source }], cursor: Q.cursor + 1 });
823
- }, [w]), te = X((M, C) => {
824
- const Q = o.current, V = Q.findIndex((k) => k.id === M), N = Q.findIndex((k) => k.id === C);
825
- Z(vi(Q, V, N));
826
- }, [Z]), R = X((M, C) => {
827
- const Q = [...o.current], V = new Set(M.map((k) => k.id)), N = Q.map((k, J) => V.has(k.id) ? J : -1).filter((k) => k >= 0);
828
- if (N.length !== 0) switch (C) {
840
+ }, [x]), F = G(() => {
841
+ B((Q) => Math.max(0, Q.cursor - 1));
842
+ }, [B]), X = G(() => {
843
+ B((Q) => Math.min(Q.states.length - 1, Q.cursor + 1));
844
+ }, [B]), Z = G((Q, w) => {
845
+ x(void 0), a.current = Q, b((y) => w.clearHistory ? { states: [{ shapes: Q, selectedShape: void 0, source: w.source }], cursor: 0 } : { states: [...y.states.slice(0, y.cursor + 1), { shapes: Q, selectedShape: void 0, source: w.source }], cursor: y.cursor + 1 });
846
+ }, [x]), ne = G((Q, w) => {
847
+ const y = a.current, L = y.findIndex((V) => V.id === Q), W = y.findIndex((V) => V.id === w);
848
+ A(vi(y, L, W));
849
+ }, [A]), I = G((Q, w) => {
850
+ const y = [...a.current], L = new Set(Q.map((V) => V.id)), W = y.map((V, U) => L.has(V.id) ? U : -1).filter((V) => V >= 0);
851
+ if (W.length !== 0) switch (w) {
829
852
  case "first":
830
853
  case "last": {
831
- const k = N.map((O) => Q[O]).filter(Boolean), J = Q.filter((O, T) => !N.includes(T));
832
- Z(C === "first" ? [...k, ...J] : [...J, ...k]);
854
+ const V = W.map((R) => y[R]).filter(Boolean), U = y.filter((R, H) => !W.includes(H));
855
+ A(w === "first" ? [...V, ...U] : [...U, ...V]);
833
856
  break;
834
857
  }
835
858
  case "backward": {
836
- let k = [...Q];
837
- const J = N.sort((O, T) => T - O).map((O) => Q[O].id);
838
- for (const O of J) {
839
- const T = k.findIndex((ne) => ne.id === O);
840
- if (T < k.length - 1) {
841
- const ne = T + 1;
842
- V.has(k[ne].id) || (k = vi(k, T, ne));
859
+ let V = [...y];
860
+ const U = W.sort((R, H) => H - R).map((R) => y[R].id);
861
+ for (const R of U) {
862
+ const H = V.findIndex((ae) => ae.id === R);
863
+ if (H < V.length - 1) {
864
+ const ae = H + 1;
865
+ L.has(V[ae].id) || (V = vi(V, H, ae));
843
866
  }
844
867
  }
845
- Z(k);
868
+ A(V);
846
869
  break;
847
870
  }
848
871
  case "forward": {
849
- let k = [...Q];
850
- const J = N.sort((O, T) => O - T).map((O) => Q[O].id);
851
- for (const O of J) {
852
- const T = k.findIndex((ne) => ne.id === O);
853
- if (T > 0) {
854
- const ne = T - 1;
855
- V.has(k[ne].id) || (k = vi(k, T, ne));
872
+ let V = [...y];
873
+ const U = W.sort((R, H) => R - H).map((R) => y[R].id);
874
+ for (const R of U) {
875
+ const H = V.findIndex((ae) => ae.id === R);
876
+ if (H > 0) {
877
+ const ae = H - 1;
878
+ L.has(V[ae].id) || (V = vi(V, H, ae));
856
879
  }
857
880
  }
858
- Z(k);
881
+ A(V);
859
882
  break;
860
883
  }
861
884
  }
862
- }, [Z]), $ = X((M, C, Q) => {
863
- const V = new Set(M.map((k) => k.id)), N = o.current.map((k) => V.has(k.id) ? _e(Ho(k, Q === "rotateClockwise" ? Math.PI / 2 : -Math.PI / 2, C), e) : k);
864
- w(de(N.filter((k) => V.has(k.id)), e)), Z(N);
865
- }, [e, Z, w]), j = X((M) => {
866
- const C = new Set(M.map((V) => V.id)), Q = o.current.map((V) => C.has(V.id) ? Xe("visible", V.visible === !1, V) : V);
867
- w((V) => de(Q.filter((N) => U(V)?.map((k) => k.id).includes(N.id)), e)), Z(Q);
868
- }, [Z, e, w]), ce = X((M) => {
869
- const C = new Set(M.map((V) => V.id)), Q = o.current.map((V) => C.has(V.id) ? Xe("locked", !V.locked, V) : V);
870
- w((V) => de(Q.filter((N) => U(V)?.map((k) => k.id).includes(N.id)), e)), Z(Q);
871
- }, [Z, e, w]), Pe = X((M, C) => {
872
- r.current.hasOwnProperty(M) && (r.current[M] = [...r.current[M], C]);
873
- }, []), L = X((M, C) => {
874
- if (r.current.hasOwnProperty(M)) if (C) {
875
- const Q = r.current[M].indexOf(C);
876
- r.current[M] = [...r.current[M].slice(0, Q), ...r.current[M].slice(Q + 1)];
877
- } else r.current[M] = [];
885
+ }, [A]), j = G((Q, w, y, L) => {
886
+ const W = new Set(w.map((U) => U.id)), V = L === "rotateClockwise" || L === "rotateCounterclockwise" ? a.current.map((U) => W.has(U.id) ? _e(Na(U, L === "rotateClockwise" ? Math.PI / 2 : -Math.PI / 2, y), e) : U) : ((U, R, H, ae, me, O) => {
887
+ if (H.length === 0) return R;
888
+ const ge = pe(H, O), ue = ge.computed.borders, Se = { newBorderX: ue.x, newBorderY: ue.y, newBorderWidth: ue.width, newBorderHeight: ue.height, widthMultiplier: 1, heightMultiplier: 1, isXinverted: me === "flipHorizontally", isYinverted: me === "flipVertically", groupCenter: ae, rotation: 0, settings: O, originalBorders: ue }, Ie = new Set(H.map((te) => te.id));
889
+ return R.map((te) => {
890
+ if (te.locked || !Ie.has(te.id)) return te;
891
+ switch (te.type) {
892
+ case "rect":
893
+ case "square":
894
+ return Ma(te, ge, Se);
895
+ case "picture":
896
+ return Ea(te, ge, Se);
897
+ case "text":
898
+ return Wa(U, te, ge, Se);
899
+ case "ellipse":
900
+ return Ta(te, ge, Se);
901
+ case "circle":
902
+ return Ha(te, ge, Se);
903
+ case "brush":
904
+ return Qa(te, ge, Se);
905
+ case "line":
906
+ case "polygon":
907
+ case "curve":
908
+ return Da(te, ge, Se);
909
+ default:
910
+ return te;
911
+ }
912
+ });
913
+ })(Q, a.current, w, y, L, e);
914
+ x(pe(V.filter((U) => W.has(U.id)), e)), A(V);
915
+ }, [e, A, x]), ee = G((Q) => {
916
+ const w = new Set(Q.map((L) => L.id)), y = a.current.map((L) => w.has(L.id) ? Xe("visible", L.visible === !1, L) : L);
917
+ x((L) => pe(y.filter((W) => _(L)?.map((V) => V.id).includes(W.id)), e)), A(y);
918
+ }, [A, e, x]), se = G((Q) => {
919
+ const w = new Set(Q.map((L) => L.id)), y = a.current.map((L) => w.has(L.id) ? Xe("locked", !L.locked, L) : L);
920
+ x((L) => pe(y.filter((W) => _(L)?.map((V) => V.id).includes(W.id)), e)), A(y);
921
+ }, [A, e, x]), he = G((Q, w) => {
922
+ r.current.hasOwnProperty(Q) && (r.current[Q] = [...r.current[Q], w]);
923
+ }, []), C = G((Q, w) => {
924
+ if (r.current.hasOwnProperty(Q)) if (w) {
925
+ const y = r.current[Q].indexOf(w);
926
+ r.current[Q] = [...r.current[Q].slice(0, y), ...r.current[Q].slice(y + 1)];
927
+ } else r.current[Q] = [];
878
928
  }, []);
879
- le(() => {
880
- const M = u.states[u.cursor], C = Oi(M.shapes, t, i);
881
- for (const Q of r.current.dataChanged) Q(C, M.source);
882
- }, [t, i, u]), le(() => {
883
- o.current = o.current.map((M) => _e(M, e)), w((M) => M === void 0 ? void 0 : de(U(M).map((C) => _e(C, e)), e));
884
- }, [e, w]);
885
- const _ = X((M, C) => {
886
- s((Q) => {
887
- const V = [Q?.frame[0] ?? [C[0], C[1]], [C[0], C[1]]], N = o.current.filter((J) => ((O, T, ne) => {
888
- const { borders: ye, center: Y, boundingBox: ze } = T.computed, ge = Math.min(ne[0][0], ne[1][0]), Oe = Math.max(ne[0][0], ne[1][0]), Ye = Math.min(ne[0][1], ne[1][1]), he = { x: ge, y: Ye, width: Oe - ge, height: Math.max(ne[0][1], ne[1][1]) - Ye }, Se = xi(ze, he);
889
- if (!Se) return !1;
890
- if (ye.width <= 1 || ye.height <= 1) return !0;
891
- if (O.lineWidth = (T.style?.lineWidth ?? 0) + 10, T.type === "brush") {
892
- const fe = T.points.flat(), ee = Math.min(...fe.map((pe) => pe[0])), se = Math.min(...fe.map((pe) => pe[1]));
893
- for (const pe of T.points) {
894
- if (pe.length < 1) break;
895
- if (pe.length < 2) {
896
- const ke = Ge(pe[0], ee, se, T.scaleX, T.scaleY);
897
- if (yo(Se, { x: ke[0], y: ke[1], radius: (T.style?.lineWidth ?? 1) / 2 })) return !0;
929
+ de(() => {
930
+ const Q = m.states[m.cursor], w = Bi(Q.shapes, t, i);
931
+ for (const y of r.current.dataChanged) y(w, Q.source);
932
+ }, [t, i, m]), de(() => {
933
+ a.current = a.current.map((Q) => _e(Q, e)), x((Q) => Q === void 0 ? void 0 : pe(_(Q).map((w) => _e(w, e)), e));
934
+ }, [e, x]);
935
+ const $ = G((Q, w) => {
936
+ s((y) => {
937
+ const L = [y?.frame[0] ?? [w[0], w[1]], [w[0], w[1]]], W = a.current.filter((U) => !U.locked && ((R, H, ae) => {
938
+ const { borders: me, center: O, boundingBox: ge } = H.computed, ue = Math.min(ae[0][0], ae[1][0]), Se = Math.max(ae[0][0], ae[1][0]), Ie = Math.min(ae[0][1], ae[1][1]), te = { x: ue, y: Ie, width: Se - ue, height: Math.max(ae[0][1], ae[1][1]) - Ie }, we = xi(ge, te);
939
+ if (!we) return !1;
940
+ if (me.width <= 1 || me.height <= 1) return !0;
941
+ if (R.lineWidth = (H.style?.lineWidth ?? 0) + 10, H.type === "brush") {
942
+ const ye = H.points.flat(), ie = Math.min(...ye.map((fe) => fe[0])), le = Math.min(...ye.map((fe) => fe[1]));
943
+ for (const fe of H.points) {
944
+ if (fe.length < 1) break;
945
+ if (fe.length < 2) {
946
+ const Ve = Ge(fe[0], ie, le, H.scaleX, H.scaleY);
947
+ if (Sa(we, { x: Ve[0], y: Ve[1], radius: (H.style?.lineWidth ?? 1) / 2 })) return !0;
898
948
  }
899
- for (let ke = 0; ke < pe.length - 1; ke++) {
900
- const Be = wi(Ge(pe[ke], ee, se, T.scaleX, T.scaleY), T.rotation ?? 0, Y), Ee = wi(Ge(pe[ke + 1], ee, se, T.scaleX, T.scaleY), T.rotation ?? 0, Y), we = xi({ x: Math.min(Be[0], Ee[0]), y: Math.min(Be[1], Ee[1]), width: Math.abs(Be[0] - Ee[0]), height: Math.abs(Be[1] - Ee[1]) }, he);
901
- if (we) {
902
- const Fe = new Path2D();
903
- if (Fe.moveTo(...Be), Fe.lineTo(...Ee), pn({ ctx: O, path: Fe, rect: we, offset: 10, center: Y, checkFill: !1 })) return !0;
949
+ for (let Ve = 0; Ve < fe.length - 1; Ve++) {
950
+ const Fe = wi(Ge(fe[Ve], ie, le, H.scaleX, H.scaleY), H.rotation ?? 0, O), We = wi(Ge(fe[Ve + 1], ie, le, H.scaleX, H.scaleY), H.rotation ?? 0, O), Ce = xi({ x: Math.min(Fe[0], We[0]), y: Math.min(Fe[1], We[1]), width: Math.abs(Fe[0] - We[0]), height: Math.abs(Fe[1] - We[1]) }, te);
951
+ if (Ce) {
952
+ const Ye = new Path2D();
953
+ if (Ye.moveTo(...Fe), Ye.lineTo(...We), pn({ ctx: R, path: Ye, rect: Ce, offset: 10, center: O, checkFill: !1 })) return !0;
904
954
  }
905
955
  }
906
956
  }
907
957
  return !1;
908
958
  }
909
- const ae = Ii(T);
910
- return pn({ ctx: O, path: T.path, rect: Se, offset: 10, center: Y, rotation: T.rotation ?? 0, checkFill: ae });
911
- })(M, J, V)), k = de(N, e);
912
- return w(n ? de(xo(Q?.oldSelection, N), e) : k), { oldSelection: Q?.oldSelection, frame: V };
959
+ const re = Ii(H);
960
+ return pn({ ctx: R, path: H.path, rect: we, offset: 10, center: O, rotation: H.rotation ?? 0, checkFill: re });
961
+ })(Q, U, L)), V = pe(W, e);
962
+ return x(n ? pe(Ca(y?.oldSelection, W), e) : V), { oldSelection: y?.oldSelection, frame: L };
913
963
  });
914
- }, [e, n, w]);
915
- return { registerEvent: Pe, unregisterEvent: L, shapesRef: o, selectedShape: d, hoveredShape: c, selectionFrame: l, setSelectionFrame: s, copiedShape: p, setCopiedShape: m, refreshSelectedShapes: _, addShapes: P, duplicateShapes: z, addPictureShape: A, moveShapes: R, swapShapes: te, saveShapes: g, setSelectedShape: w, refreshHoveredShape: D, toggleShapeVisibility: j, toggleShapeLock: ce, removeShape: E, updateShape: H, transformShape: $, backwardShape: W, forwardShape: I, clearShapes: oe, canGoBackward: x, canGoForward: b, canClear: y };
916
- }, Mn = (e) => {
964
+ }, [e, n, x]);
965
+ return { registerEvent: he, unregisterEvent: C, shapesRef: a, selectedShape: c, hoveredShape: d, selectionFrame: l, setSelectionFrame: s, copiedShape: p, setCopiedShape: f, refreshSelectedShapes: $, addShapes: P, duplicateShapes: z, addPictureShape: D, moveShapes: I, swapShapes: ne, saveShapes: g, setSelectedShape: x, refreshHoveredShape: N, toggleShapeVisibility: ee, toggleShapeLock: se, removeShape: T, updateShape: E, transformShape: j, backwardShape: F, forwardShape: X, clearShapes: Z, canGoBackward: k, canGoForward: M, canClear: S };
966
+ }, Cn = (e) => {
917
967
  const t = [e[0].clientX, e[0].clientY], i = [e[1].clientX, e[1].clientY];
918
- var n, o;
919
- return { diff: bo(t, i), center: (o = i, [((n = t)[0] + o[0]) / 2, (n[1] + o[1]) / 2]) };
920
- }, Ea = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: n, setCanvasTransformation: o }) => {
921
- const a = re([]), [r, l] = K(a.current.length > 0), s = re(null), d = re(t);
922
- d.current = t;
923
- const h = X(({ startDiff: c, startZoom: f, startCenter: p, startOffset: m, currentDiff: u, currentCenter: S, isMoving: w, isZooming: x }) => {
924
- if (!e || !u || !c) return;
925
- const b = (({ canvasBoundingRect: y, canvasSize: g, size: P, startDiff: z, startZoom: D, startCenter: A, startOffset: H, currentDiff: Z, currentCenter: E, isMoving: F, isZooming: W }) => {
926
- const I = W ? et(Z / z * D, Ie[0], Ie[Ie.length - 1]) : D, oe = F ? [H[0] + (E[0] - A[0]) * (g.width / y.width) / g.scaleRatio / D, H[1] + (E[1] - A[1]) * (g.height / y.height) / g.scaleRatio / D] : [H[0], H[1]], te = [(E[0] - y.left) / g.scaleRatio, (E[1] - y.top) / g.scaleRatio];
927
- return Ci({ size: P, canvasSize: g, currentOffset: oe, currentZoom: D, zoom: I, centerPoint: te });
928
- })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: n, startDiff: c, startZoom: f, startCenter: p, startOffset: m, currentDiff: u, currentCenter: S, isMoving: w, isZooming: x });
929
- o(b);
930
- }, [e, i, n, o]);
931
- le(() => {
968
+ var n, a;
969
+ return { diff: ba(t, i), center: (a = i, [((n = t)[0] + a[0]) / 2, (n[1] + a[1]) / 2]) };
970
+ }, Bo = ({ canvasElt: e, canvasTransformation: t, canvasSize: i, size: n, setCanvasTransformation: a }) => {
971
+ const o = ce([]), [r, l] = J(o.current.length > 0), s = ce(null), c = ce(t);
972
+ c.current = t;
973
+ const h = G(({ startDiff: d, startZoom: u, startCenter: p, startOffset: f, currentDiff: m, currentCenter: b, isMoving: x, isZooming: k }) => {
974
+ if (!e || !m || !d) return;
975
+ const M = (({ canvasBoundingRect: S, canvasSize: g, size: P, startDiff: z, startZoom: N, startCenter: D, startOffset: E, currentDiff: A, currentCenter: T, isMoving: B, isZooming: F }) => {
976
+ const X = F ? et(A / z * N, Re[0], Re[Re.length - 1]) : N, Z = B ? [E[0] + (T[0] - D[0]) * (g.width / S.width) / g.scaleRatio / N, E[1] + (T[1] - D[1]) * (g.height / S.height) / g.scaleRatio / N] : [E[0], E[1]], ne = [(T[0] - S.left) / g.scaleRatio, (T[1] - S.top) / g.scaleRatio];
977
+ return Ci({ size: P, canvasSize: g, currentOffset: Z, currentZoom: N, zoom: X, centerPoint: ne });
978
+ })({ canvasBoundingRect: e.getBoundingClientRect(), canvasSize: i, size: n, startDiff: d, startZoom: u, startCenter: p, startOffset: f, currentDiff: m, currentCenter: b, isMoving: x, isZooming: k });
979
+ a(M);
980
+ }, [e, i, n, a]);
981
+ de(() => {
932
982
  if (!e) return;
933
- const c = (f) => {
934
- if (a.current = [...a.current, f], l(a.current.length > 0), a.current.length === 2) {
935
- f.stopPropagation();
936
- const { diff: p, center: m } = Mn(a.current);
937
- s.current = { startDiff: p, startCenter: m, startZoom: d.current.zoom, startOffset: d.current.offset, isMoving: !1, isZooming: !1 };
983
+ const d = (u) => {
984
+ if (o.current = [...o.current, u], l(o.current.length > 0), o.current.length === 2) {
985
+ u.stopPropagation();
986
+ const { diff: p, center: f } = Cn(o.current);
987
+ s.current = { startDiff: p, startCenter: f, startZoom: c.current.zoom, startOffset: c.current.offset, isMoving: !1, isZooming: !1 };
938
988
  }
939
989
  };
940
- return e.addEventListener("pointerdown", c), () => {
941
- e.removeEventListener("pointerdown", c);
990
+ return e.addEventListener("pointerdown", d), () => {
991
+ e.removeEventListener("pointerdown", d);
942
992
  };
943
- }, [e]), le(() => {
993
+ }, [e]), de(() => {
944
994
  if (!r) return;
945
- const c = (p) => {
946
- const m = a.current.findIndex((u) => u.pointerId === p.pointerId);
947
- if (m > -1 && (a.current[m] = p), a.current.length === 2 && s.current) {
948
- const { diff: u, center: S } = Mn(a.current), w = s.current.isZooming || ((b, y) => Math.abs(b - y.startDiff) > 30)(u, s.current), x = s.current.isMoving || w || ((b, y) => Math.abs(bo(b, y.startCenter)) > 10)(S, s.current);
949
- s.current = { ...s.current, isMoving: x, isZooming: w }, h({ ...s.current, currentDiff: u, currentCenter: S });
995
+ const d = (p) => {
996
+ const f = o.current.findIndex((m) => m.pointerId === p.pointerId);
997
+ if (f > -1 && (o.current[f] = p), o.current.length === 2 && s.current) {
998
+ const { diff: m, center: b } = Cn(o.current), x = s.current.isZooming || ((M, S) => Math.abs(M - S.startDiff) > 30)(m, s.current), k = s.current.isMoving || x || ((M, S) => Math.abs(ba(M, S.startCenter)) > 10)(b, s.current);
999
+ s.current = { ...s.current, isMoving: k, isZooming: x }, h({ ...s.current, currentDiff: m, currentCenter: b });
950
1000
  }
951
- }, f = (p) => {
952
- a.current = a.current.filter((m) => m.pointerId !== p.pointerId), l(a.current.length > 0);
1001
+ }, u = (p) => {
1002
+ o.current = o.current.filter((f) => f.pointerId !== p.pointerId), l(o.current.length > 0);
953
1003
  };
954
- return document.addEventListener("pointermove", c), document.addEventListener("pointerup", f), document.addEventListener("pointerout", f), document.addEventListener("pointercancel", f), document.addEventListener("pointerleave", f), () => {
955
- document.removeEventListener("pointermove", c), document.removeEventListener("pointerup", f), document.removeEventListener("pointerout", f), document.removeEventListener("pointercancel", f), document.removeEventListener("pointerleave", f);
1004
+ return document.addEventListener("pointermove", d), document.addEventListener("pointerup", u), document.addEventListener("pointerout", u), document.addEventListener("pointercancel", u), document.addEventListener("pointerleave", u), () => {
1005
+ document.removeEventListener("pointermove", d), document.removeEventListener("pointerup", u), document.removeEventListener("pointerout", u), document.removeEventListener("pointercancel", u), document.removeEventListener("pointerleave", u);
956
1006
  };
957
1007
  }, [r, h]);
958
- }, Cn = { offset: [0, 0], zoom: 1 }, Ia = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: n }) => {
959
- const [o, a] = K(Cn), r = re(0), l = X((h) => {
960
- a(({ zoom: c }) => Mi({ zoom: c, size: t, canvasSize: e, newOffset: h }));
961
- }, [e, t]), s = X((h) => {
962
- a(({ offset: c, zoom: f }) => (({ size: p, canvasSize: m, currentOffset: u, currentZoom: S, action: w }) => {
963
- const x = w === "default" ? Ie[4] : w === "zoom" ? Ie[et(Ie.length - 1 - Ie.slice(0).reverse().findIndex((y) => y <= S) + 1, 0, Ie.length - 1)] : Ie[et(Ie.findIndex((y) => y >= S) - 1, 0, Ie.length - 1)], b = [m.realWidth / 2, m.realHeight / 2];
964
- return Ci({ size: p, canvasSize: m, currentOffset: u, currentZoom: S, zoom: x, centerPoint: b });
965
- })({ size: t, canvasSize: e, currentOffset: c, currentZoom: f, action: h }));
1008
+ }, kn = { offset: [0, 0], zoom: 1 }, Oo = ({ canvasSize: e, size: t, zoomEnabled: i, canvasElt: n }) => {
1009
+ const [a, o] = J(kn), r = ce(0), l = G((h) => {
1010
+ o(({ zoom: d }) => Mi({ zoom: d, size: t, canvasSize: e, newOffset: h }));
1011
+ }, [e, t]), s = G((h) => {
1012
+ o(({ offset: d, zoom: u }) => (({ size: p, canvasSize: f, currentOffset: m, currentZoom: b, action: x }) => {
1013
+ const k = x === "default" ? Re[4] : x === "zoom" ? Re[et(Re.length - 1 - Re.slice(0).reverse().findIndex((S) => S <= b) + 1, 0, Re.length - 1)] : Re[et(Re.findIndex((S) => S >= b) - 1, 0, Re.length - 1)], M = [f.realWidth / 2, f.realHeight / 2];
1014
+ return Ci({ size: p, canvasSize: f, currentOffset: m, currentZoom: b, zoom: k, centerPoint: M });
1015
+ })({ size: t, canvasSize: e, currentOffset: d, currentZoom: u, action: h }));
966
1016
  }, [e, t]);
967
- Ea({ canvasElt: n, canvasTransformation: o, canvasSize: e, size: t, setCanvasTransformation: a });
968
- const d = X(() => {
969
- a(Cn);
1017
+ Bo({ canvasElt: n, canvasTransformation: a, canvasSize: e, size: t, setCanvasTransformation: o });
1018
+ const c = G(() => {
1019
+ o(kn);
970
1020
  }, []);
971
- return le(() => {
1021
+ return de(() => {
972
1022
  if (!i || !n) return;
973
- const h = (c) => {
974
- const f = c.ctrlKey, { deltaX: p, deltaY: m } = ((x, b) => {
975
- const y = Math.abs(x.deltaY) < 50 && b < 50, g = x.ctrlKey, P = mo() && y && g;
976
- switch (x.deltaMode) {
1023
+ const h = (d) => {
1024
+ const u = d.ctrlKey, { deltaX: p, deltaY: f } = ((k, M) => {
1025
+ const S = Math.abs(k.deltaY) < 50 && M < 50, g = k.ctrlKey, P = ma() && S && g;
1026
+ switch (k.deltaMode) {
977
1027
  case WheelEvent.DOM_DELTA_LINE:
978
- return { deltaX: 16 * x.deltaX, deltaY: 16 * x.deltaY };
1028
+ return { deltaX: 16 * k.deltaX, deltaY: 16 * k.deltaY };
979
1029
  case WheelEvent.DOM_DELTA_PAGE:
980
- return { deltaX: x.deltaX * window.innerHeight, deltaY: x.deltaY * window.innerHeight };
1030
+ return { deltaX: k.deltaX * window.innerHeight, deltaY: k.deltaY * window.innerHeight };
981
1031
  default:
982
- return P ? { deltaX: 5 * x.deltaX, deltaY: 5 * x.deltaY } : { deltaX: x.deltaX, deltaY: x.deltaY };
1032
+ return P ? { deltaX: 5 * k.deltaX, deltaY: 5 * k.deltaY } : { deltaX: k.deltaX, deltaY: k.deltaY };
983
1033
  }
984
- })(c, c.timeStamp - r.current);
985
- if (r.current = c.timeStamp, f) {
986
- c.preventDefault();
987
- const x = Co(c, n, e);
988
- return void a(({ offset: b, zoom: y }) => (({ size: g, canvasSize: P, currentOffset: z, currentZoom: D, delta: A, centerPoint: H }) => {
989
- const Z = et(D * (1 - A / 1e3), Ie[0], Ie[Ie.length - 1]);
990
- return Ci({ size: g, canvasSize: P, currentOffset: z, currentZoom: D, zoom: Z, centerPoint: H });
991
- })({ size: t, canvasSize: e, currentOffset: b, currentZoom: y, delta: m, centerPoint: x }));
1034
+ })(d, d.timeStamp - r.current);
1035
+ if (r.current = d.timeStamp, u) {
1036
+ d.preventDefault();
1037
+ const k = Pa(d, n, e);
1038
+ return void o(({ offset: M, zoom: S }) => (({ size: g, canvasSize: P, currentOffset: z, currentZoom: N, delta: D, centerPoint: E }) => {
1039
+ const A = et(N * (1 - D / 1e3), Re[0], Re[Re.length - 1]);
1040
+ return Ci({ size: g, canvasSize: P, currentOffset: z, currentZoom: N, zoom: A, centerPoint: E });
1041
+ })({ size: t, canvasSize: e, currentOffset: M, currentZoom: S, delta: f, centerPoint: k }));
992
1042
  }
993
- const u = c.shiftKey, [S, w] = u ? [m, p] : [p, m];
994
- a(({ offset: x, zoom: b }) => {
995
- const y = [x[0] - S / b, x[1] - w / b], g = Mi({ zoom: b, size: t, canvasSize: e, newOffset: y });
996
- return g.offset[0] === x[0] && g.offset[1] === x[1] || c.preventDefault(), g;
1043
+ const m = d.shiftKey, [b, x] = m ? [f, p] : [p, f];
1044
+ o(({ offset: k, zoom: M }) => {
1045
+ const S = [k[0] - b / M, k[1] - x / M], g = Mi({ zoom: M, size: t, canvasSize: e, newOffset: S });
1046
+ return g.offset[0] === k[0] && g.offset[1] === k[1] || d.preventDefault(), g;
997
1047
  });
998
1048
  };
999
1049
  return n.addEventListener("wheel", h, { passive: !1 }), () => {
1000
1050
  n.removeEventListener("wheel", h);
1001
1051
  };
1002
- }, [n, t, e, i]), { setCanvasTransformation: a, setCanvasOffset: l, setCanvasZoom: s, resetZoom: d, canvasTransformation: o };
1052
+ }, [n, t, e, i]), { setCanvasTransformation: o, setCanvasOffset: l, setCanvasZoom: s, resetZoom: c, canvasTransformation: a };
1003
1053
  }, Pn = (e, t = !1) => {
1004
- const i = (o, a) => {
1005
- if (Array.isArray(o)) return a;
1006
- }, n = e.map((o) => {
1007
- if (typeof o != "object") return null;
1008
- switch (o.type) {
1054
+ const i = (a, o) => {
1055
+ if (Array.isArray(a)) return o;
1056
+ }, n = e.map((a) => {
1057
+ if (typeof a != "object") return null;
1058
+ switch (a.type) {
1009
1059
  case "brush":
1010
- return Ke(i, eo, o);
1060
+ return Ke(i, ta, a);
1011
1061
  case "circle":
1012
- return Ke(i, so, o);
1062
+ return Ke(i, ra, a);
1013
1063
  case "curve":
1014
- return Ke(i, no, o);
1064
+ return Ke(i, aa, a);
1015
1065
  case "ellipse":
1016
- return Ke(i, ro, o);
1066
+ return Ke(i, la, a);
1017
1067
  case "line":
1018
- return Ke(i, to, o);
1068
+ return Ke(i, ia, a);
1019
1069
  case "polygon":
1020
- return Ke(i, io, o);
1070
+ return Ke(i, na, a);
1021
1071
  case "rect":
1022
- return Ke(i, oo, o);
1072
+ return Ke(i, oa, a);
1023
1073
  case "square":
1024
- return Ke(i, ao, o);
1074
+ return Ke(i, sa, a);
1025
1075
  case "text":
1026
- return Ke(i, lo, o);
1076
+ return Ke(i, ca, a);
1027
1077
  }
1028
1078
  return null;
1029
1079
  });
1030
- return Ni(t ? [...n, Ai] : n);
1031
- }, Vs = ({ width: e = 1e3, height: t = 600, shapes: i, mode: n = "editor", disabled: o = !1, options: a = an } = {}) => {
1032
- const { layersManipulation: r, brushAlgo: l, isBrushShapeDoneOnMouseUp: s, debug: d, grid: h, canGrow: c, canShrink: f, withExport: p, withLoadAndSave: m, withUploadPicture: u, withUrlPicture: S, withSkeleton: w, withFrameSelection: x, withContextMenu: b, clearCallback: y, availableTools: g, canvasSelectionPadding: P, size: z, canZoom: D } = { ...an, ...a }, A = n !== "viewer", H = b && A && !o, Z = re(null), E = re(null), F = re(!1), W = X((ie) => {
1033
- Z.current = ie;
1034
- }, []), [I, oe] = K(void 0), [te, R] = K(Je), [$, j] = K({ mode: "default" }), [ce, Pe] = K(h), [L, _] = K({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), M = D === "always" && !o, { canvasTransformation: C, setCanvasTransformation: Q, setCanvasOffset: V, setCanvasZoom: N, resetZoom: k } = Ia({ canvasSize: L, size: z, canvasElt: E.current, zoomEnabled: M }), { offset: J, zoom: O } = C, T = Fn(() => ({ brushAlgo: l, isBrushShapeDoneOnMouseUp: s, debug: d, canvasSize: { realWidth: L.realWidth, realHeight: L.realHeight, width: L.width, height: L.height, scaleRatioWithNoZoom: L.scaleRatio, scaleRatio: L.scaleRatio * O }, size: z, canvasOffset: J, canvasZoom: O, gridGap: ce, selectionPadding: P, features: { edition: A && !o, zoom: M } }), [P, ce, l, s, d, O, J, L, z, o, M, A]), [ne, ye] = K(Pn(g, u || S)), { isInsideComponent: Y, isInsideCanvas: ze } = (({ settings: ie, componentRef: ue, canvasRef: He }) => {
1035
- const [xe, Ve] = K(!1), [Ue, qe] = K(!1), Me = !ie.features.edition && !ie.features.zoom;
1036
- return le(() => {
1037
- if (!Me) {
1038
- const Le = () => Ve(!0), Nt = () => Ve(!1), rt = () => qe(!0), Ot = () => qe(!1);
1039
- return ue.current?.addEventListener("focusin", Le), ue.current?.addEventListener("focusout", Nt), He.current?.addEventListener("focusin", rt), He.current?.addEventListener("focusout", Ot), () => {
1040
- ue.current?.removeEventListener("focusin", Le), ue.current?.removeEventListener("focusout", Nt), He.current?.removeEventListener("focusin", rt), He.current?.removeEventListener("focusout", Ot);
1080
+ return Ni(t ? [...n, zi] : n);
1081
+ }, Ts = ({ width: e = 1e3, height: t = 600, shapes: i, mode: n = "editor", disabled: a = !1, options: o = on } = {}) => {
1082
+ const { layersManipulation: r, brushAlgo: l, isBrushShapeDoneOnMouseUp: s, debug: c, grid: h, canGrow: d, canShrink: u, withExport: p, withLoadAndSave: f, withUploadPicture: m, withUrlPicture: b, withSkeleton: x, withFrameSelection: k, withContextMenu: M, clearCallback: S, availableTools: g, canvasSelectionPadding: P, size: z, canZoom: N } = { ...on, ...o }, D = n !== "viewer", E = M && D && !a, A = ce(null), T = ce(null), B = ce(!1), F = G((oe) => {
1083
+ A.current = oe;
1084
+ }, []), [X, Z] = J(void 0), [ne, I] = J(Je), [j, ee] = J({ mode: "default" }), [se, he] = J(h), [C, $] = J({ realWidth: e, realHeight: t, width: e, height: t, scaleRatio: 1 }), Q = N === "always" && !a, { canvasTransformation: w, setCanvasTransformation: y, setCanvasOffset: L, setCanvasZoom: W, resetZoom: V } = Oo({ canvasSize: C, size: z, canvasElt: T.current, zoomEnabled: Q }), { offset: U, zoom: R } = w, H = Yn(() => ({ brushAlgo: l, isBrushShapeDoneOnMouseUp: s, debug: c, canvasSize: { realWidth: C.realWidth, realHeight: C.realHeight, width: C.width, height: C.height, scaleRatioWithNoZoom: C.scaleRatio, scaleRatio: C.scaleRatio * R }, size: z, canvasOffset: U, canvasZoom: R, gridGap: se, selectionPadding: P, features: { edition: D && !a, zoom: Q } }), [P, se, l, s, c, R, U, C, z, a, Q, D]), [ae, me] = J(Pn(g, m || b)), { isInsideComponent: O, isInsideCanvas: ge } = (({ settings: oe, componentRef: ve, canvasRef: Te }) => {
1085
+ const [ke, He] = J(!1), [Ue, qe] = J(!1), Pe = !oe.features.edition && !oe.features.zoom;
1086
+ return de(() => {
1087
+ if (!Pe) {
1088
+ const Ze = () => He(!0), Nt = () => He(!1), rt = () => qe(!0), Bt = () => qe(!1);
1089
+ return ve.current?.addEventListener("focusin", Ze), ve.current?.addEventListener("focusout", Nt), Te.current?.addEventListener("focusin", rt), Te.current?.addEventListener("focusout", Bt), () => {
1090
+ ve.current?.removeEventListener("focusin", Ze), ve.current?.removeEventListener("focusout", Nt), Te.current?.removeEventListener("focusin", rt), Te.current?.removeEventListener("focusout", Bt);
1041
1091
  };
1042
1092
  }
1043
- Ve(!1), qe(!1);
1044
- }, [Me, ue, He]), { isInsideComponent: xe, isInsideCanvas: Ue };
1045
- })({ settings: T, componentRef: Z, canvasRef: E }), [ge, Oe] = K(!1), [Ye, he] = K(!1), [Se, ae] = K(!1), { registerEvent: fe, unregisterEvent: ee, shapesRef: se, selectedShape: pe, selectionFrame: ke, hoveredShape: Be, copiedShape: Ee, setCopiedShape: we, addShapes: Fe, addPictureShape: bt, moveShapes: Qt, swapShapes: dt, setSelectedShape: $e, setSelectionFrame: wt, refreshSelectedShapes: xt, refreshHoveredShape: Ae, duplicateShapes: at, removeShape: st, updateShape: je, backwardShape: ct, forwardShape: ht, clearShapes: pt, saveShapes: ve, toggleShapeVisibility: be, toggleShapeLock: B, transformShape: nt, canGoBackward: Tt, canGoForward: Oo, canClear: Bo } = Da(T, e, t, ge), li = X((ie) => {
1046
- $e(void 0), R(ie);
1047
- }, [$e]), [Mt, Bi] = K([0, 0]), Fi = $.mode === "preview";
1048
- le(() => {
1049
- if (Fi) return () => j((ie) => ie.mode === "preview" ? { mode: "default" } : ie);
1050
- }, [pe?.id, Fi]);
1051
- const Yi = $.mode === "selectionFrame";
1052
- le(() => {
1053
- if (Yi) return () => Bi([0, 0]);
1054
- }, [Yi]), le(() => {
1093
+ He(!1), qe(!1);
1094
+ }, [Pe, ve, Te]), { isInsideComponent: ke, isInsideCanvas: Ue };
1095
+ })({ settings: H, componentRef: A, canvasRef: T }), [ue, Se] = J(!1), [Ie, te] = J(!1), [we, re] = J(!1), { registerEvent: ye, unregisterEvent: ie, shapesRef: le, selectedShape: fe, selectionFrame: Ve, hoveredShape: Fe, copiedShape: We, setCopiedShape: Ce, addShapes: Ye, addPictureShape: bt, moveShapes: Qt, swapShapes: ct, setSelectedShape: $e, setSelectionFrame: wt, refreshSelectedShapes: xt, refreshHoveredShape: Ae, duplicateShapes: ot, removeShape: st, updateShape: je, backwardShape: dt, forwardShape: ht, clearShapes: ut, saveShapes: be, toggleShapeVisibility: xe, toggleShapeLock: Y, transformShape: nt, canGoBackward: Tt, canGoForward: qa, canClear: Ga } = No(H, e, t, ue), li = G((oe) => {
1096
+ $e(void 0), I(oe);
1097
+ }, [$e]), [Mt, Oi] = J([0, 0]), Fi = j.mode === "preview";
1098
+ de(() => {
1099
+ if (Fi) return () => ee((oe) => oe.mode === "preview" ? { mode: "default" } : oe);
1100
+ }, [fe?.id, Fi]);
1101
+ const Yi = j.mode === "selectionFrame";
1102
+ de(() => {
1103
+ if (Yi) return () => Oi([0, 0]);
1104
+ }, [Yi]), de(() => {
1055
1105
  if (Mt[0] !== 0 || Mt[1] !== 0) {
1056
- const ie = setInterval(() => {
1057
- Q(({ offset: ue, zoom: He }) => {
1058
- const xe = [ue[0] - Mt[0], ue[1] - Mt[1]];
1059
- return Mi({ zoom: He, size: z, canvasSize: L, newOffset: xe });
1106
+ const oe = setInterval(() => {
1107
+ y(({ offset: ve, zoom: Te }) => {
1108
+ const ke = [ve[0] - Mt[0], ve[1] - Mt[1]];
1109
+ return Mi({ zoom: Te, size: z, canvasSize: C, newOffset: ke });
1060
1110
  });
1061
1111
  }, 20);
1062
- return () => clearInterval(ie);
1112
+ return () => clearInterval(oe);
1063
1113
  }
1064
- }, [Mt[0], Mt[1], Q, z, L]);
1065
- const Wt = X((ie, ue) => {
1066
- pt(ie, ue), li(Je), Q({ offset: [0, 0], zoom: 1 });
1067
- }, [li, pt, Q]), Ct = X((ie) => {
1068
- $e((ue) => (ue?.id !== ie.map((He) => He.id).join("-") && R(Je), de(ie, T)));
1069
- }, [$e, T]), Xi = X((ie) => {
1070
- Fe(ie), Ct(ie);
1071
- }, [Fe, Ct]), $i = X(() => {
1072
- Ct(se.current);
1073
- }, [Ct, se]), Fo = X(() => {
1074
- const ie = Ha(se.current, e, t);
1075
- if (!ie) throw new Error("L'encodage a échoué");
1076
- Qn(ie, "drawing.json");
1077
- }, [se, e, t]), Yo = X((ie) => {
1078
- const ue = wn({ shapes: se.current, settings: T, view: ie });
1079
- Qn(ue, "drawing.png");
1080
- }, [se, T]), Xo = X((ie) => wn({ shapes: se.current, settings: T, view: ie }), [se, T]), $o = X(() => Oi(se.current, e, t), [se, e, t]), ut = X(async (ie, ue) => {
1081
- const He = await (async (xe, Ve) => {
1082
- if (!xe) return [];
1083
- const Ue = [], qe = Ni(xe.map((Me) => {
1084
- if (!Me || !uo.includes(Me.type)) return null;
1085
- if (Me.type === "picture") {
1086
- const Le = new Image(), Nt = new Promise((rt, Ot) => {
1087
- Le.onload = () => {
1088
- URL.revokeObjectURL(Le.src), rt();
1089
- }, Le.onerror = () => {
1090
- Ot(new Error("Some images could not be loaded"));
1114
+ }, [Mt[0], Mt[1], y, z, C]);
1115
+ const Rt = G((oe, ve) => {
1116
+ ut(oe, ve), li(Je), y({ offset: [0, 0], zoom: 1 });
1117
+ }, [li, ut, y]), Ct = G((oe) => {
1118
+ $e((ve) => (ve?.id !== oe.map((Te) => Te.id).join("-") && I(Je), pe(oe, H)));
1119
+ }, [$e, H]), Xi = G((oe) => {
1120
+ Ye(oe), Ct(oe);
1121
+ }, [Ye, Ct]), $i = G(() => {
1122
+ Ct(le.current);
1123
+ }, [Ct, le]), _a = G(() => {
1124
+ const oe = Wo(le.current, e, t);
1125
+ if (!oe) throw new Error("L'encodage a échoué");
1126
+ wn(oe, "drawing.json");
1127
+ }, [le, e, t]), ja = G((oe) => {
1128
+ const ve = xn({ shapes: le.current, settings: H, view: oe });
1129
+ wn(ve, "drawing.png");
1130
+ }, [le, H]), Ka = G((oe) => xn({ shapes: le.current, settings: H, view: oe }), [le, H]), Ja = G(() => Bi(le.current, e, t), [le, e, t]), pt = G(async (oe, ve) => {
1131
+ const Te = await (async (ke, He) => {
1132
+ if (!ke) return [];
1133
+ const Ue = [], qe = Ni(ke.map((Pe) => {
1134
+ if (!Pe || !pa.includes(Pe.type)) return null;
1135
+ if (Pe.type === "picture") {
1136
+ const Ze = new Image(), Nt = new Promise((rt, Bt) => {
1137
+ Ze.onload = () => {
1138
+ URL.revokeObjectURL(Ze.src), rt();
1139
+ }, Ze.onerror = () => {
1140
+ Bt(new Error("Some images could not be loaded"));
1091
1141
  };
1092
1142
  });
1093
- if (Ue.push(Nt), Me.src.startsWith("http")) Ro(Me.src).then((rt) => {
1094
- Le.src = rt;
1143
+ if (Ue.push(Nt), Pe.src.startsWith("http")) Xa(Pe.src).then((rt) => {
1144
+ Ze.src = rt;
1095
1145
  }).catch(() => {
1096
- Le.src = "";
1146
+ Ze.src = "";
1097
1147
  });
1098
- else if (Me.src.includes("<svg")) {
1099
- const rt = new Blob([Me.src], { type: "image/svg+xml" });
1100
- Le.src = URL.createObjectURL(rt);
1101
- } else Le.src = Me.src;
1102
- return xn({ ...Me, img: Le }, Ve);
1148
+ else if (Pe.src.includes("<svg")) {
1149
+ const rt = new Blob([Pe.src], { type: "image/svg+xml" });
1150
+ Ze.src = URL.createObjectURL(rt);
1151
+ } else Ze.src = Pe.src;
1152
+ return Mn({ ...Pe, img: Ze }, He);
1103
1153
  }
1104
- return xn(Me, Ve);
1154
+ return Mn(Pe, He);
1105
1155
  }));
1106
1156
  return await Promise.all(Ue), qe;
1107
- })(ie, T);
1108
- Wt(He, ue);
1109
- }, [Wt, T]), di = re(ut);
1110
- di.current = ut;
1111
- const Uo = X((ie = [], ue = !0) => {
1112
- di.current?.(ie, { clearHistory: ue, source: "remote" });
1157
+ })(oe, H);
1158
+ Rt(Te, ve);
1159
+ }, [Rt, H]), ci = ce(pt);
1160
+ ci.current = pt;
1161
+ const eo = G((oe = [], ve = !0) => {
1162
+ ci.current?.(oe, { clearHistory: ve, source: "remote" });
1113
1163
  }, []);
1114
- le(() => {
1115
- F.current || (F.current = !0, i && di.current?.(i, { clearHistory: !0, source: "remote" }));
1164
+ de(() => {
1165
+ B.current || (B.current = !0, i && ci.current?.(i, { clearHistory: !0, source: "remote" }));
1116
1166
  }, [i]);
1117
- const qo = X(async (ie) => {
1118
- const ue = await (async (He) => new Promise((xe, Ve) => {
1167
+ const to = G(async (oe) => {
1168
+ const ve = await (async (Te) => new Promise((ke, He) => {
1119
1169
  const Ue = new FileReader();
1120
1170
  Ue.onload = (qe) => {
1121
- const Me = qe.target?.result;
1122
- if (!Me) return Ve("Impossible de récupérer les données du fichier");
1123
- const Le = JSON.parse(Me);
1124
- xe(Le);
1125
- }, Ue.readAsText(He);
1126
- }))(ie);
1127
- await ut(ue.shapes ?? [], { clearHistory: !0, source: "remote" });
1128
- }, [ut]), Go = X(() => {
1129
- typeof y != "string" ? ut(y(), { clearHistory: !1, source: "user" }) : y === "defaultShapes" && i !== void 0 ? ut(i, { clearHistory: !1, source: "user" }) : Wt([], { clearHistory: !1, source: "user" });
1130
- }, [Wt, ut, i, y]), _o = X((ie, ue) => {
1131
- const He = ie.type === "curve" ? ((xe, Ve, Ue) => {
1132
- if (Ve < 0 || Ve > xe.points.length - 1) return xe;
1133
- const qe = { ...xe, points: xe.points.filter((Me, Le) => Le !== Ve) };
1134
- return Ht(qe, Ue);
1135
- })(ie, ue, T) : ((xe, Ve, Ue) => {
1136
- if (Ve < 0 || Ve > xe.points.length - 1) return xe;
1137
- const qe = { ...xe, points: xe.points.filter((Me, Le) => Le !== Ve) };
1171
+ const Pe = qe.target?.result;
1172
+ if (!Pe) return He("Impossible de récupérer les données du fichier");
1173
+ const Ze = JSON.parse(Pe);
1174
+ ke(Ze);
1175
+ }, Ue.readAsText(Te);
1176
+ }))(oe);
1177
+ await pt(ve.shapes ?? [], { clearHistory: !0, source: "remote" });
1178
+ }, [pt]), io = G(() => {
1179
+ typeof S != "string" ? pt(S(), { clearHistory: !1, source: "user" }) : S === "defaultShapes" && i !== void 0 ? pt(i, { clearHistory: !1, source: "user" }) : Rt([], { clearHistory: !1, source: "user" });
1180
+ }, [Rt, pt, i, S]), no = G((oe, ve) => {
1181
+ const Te = oe.type === "curve" ? ((ke, He, Ue) => {
1182
+ if (He < 0 || He > ke.points.length - 1) return ke;
1183
+ const qe = { ...ke, points: ke.points.filter((Pe, Ze) => Ze !== He) };
1138
1184
  return At(qe, Ue);
1139
- })(ie, ue, T);
1140
- je([He], !0);
1141
- }, [T, je]);
1142
- le(() => {
1143
- ye(Pn(g, u || S));
1144
- }, [g, u, S]);
1145
- const Ui = { canvas: E, editor: Z, setEditor: W };
1146
- return { annotationsProps: { style: { userSelect: "none", touchAction: "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": T.canvasZoom, "--react-paint-canvas-offset-x": T.canvasOffset[0], "--react-paint-canvas-offset-y": T.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: se, addPictureShape: bt, moveShapes: Qt, swapShapes: dt, toggleShapeVisibility: be, toggleShapeLock: B, duplicateShapes: at, canGoBackward: Tt, canGoForward: Oo, canClear: Bo, selectedShape: pe, copiedShape: Ee, setCopiedShape: we, pasteShapes: Xi, saveShapes: ve, removeShape: st, updateShape: je, backwardShape: ct, forwardShape: ht, removeShapePoint: _o, transformShape: nt, refs: Ui, width: e, height: t, selectTool: li, selectShapes: Ct, selectAllShapes: $i, activeTool: te, setActiveTool: R, setAvailableTools: ye, isEditMode: A, availableTools: ne, gridGap: ce, setGridGap: Pe, loadFile: qo, exportPicture: Yo, exportData: Fo, clearCanvas: Go, selectionMode: $, setSelectionMode: j, settings: T, setCanvasZoom: N, resetZoom: k, canvas: { canGrow: c, canShrink: f, layersManipulation: r, withExport: p, withLoadAndSave: m, withUploadPicture: u, withUrlPicture: S, withContextMenu: H } }, canvasProps: { shapesRef: se, selectedShape: pe, selectionFrame: ke, hoveredShape: Be, copiedShape: Ee, pasteShapes: Xi, setCopiedShape: we, addShape: Fe, setSelectedShape: $e, setSelectionFrame: wt, refreshSelectedShapes: xt, refreshHoveredShape: Ae, removeShape: st, updateShape: je, duplicateShapes: at, backwardShape: ct, forwardShape: ht, saveShapes: ve, refs: Ui, width: e, height: t, settings: T, setCanvasSize: _, setCanvasOffset: V, setCanvasZoom: N, resetZoom: k, selectShapes: Ct, selectAllShapes: $i, activeTool: te, setActiveTool: R, isInsideComponent: Y, isInsideCanvas: ze, isEditMode: A, canvas: { withSkeleton: w, withFrameSelection: x, withContextMenu: H, canGrow: c, canShrink: f }, canvasOffsetStartData: I, setCanvasOffsetStartData: oe, selectionMode: $, setSelectionMode: j, setCanvasMoveAcceleration: Bi, isShiftPressed: ge, isAltPressed: Ye, isSpacePressed: Se, setShiftPressed: Oe, setAltPressed: he, setIsSpacePressed: ae }, registerEvent: fe, unregisterEvent: ee, resetCanvas: Uo, resetZoom: k, getCurrentImage: Xo, getCurrentData: $o, setCanvasOffset: V, setCanvasZoom: N };
1147
- }, Ra = ({ addShapes: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: n, shapes: o, selectionMode: a, activeTool: r, isInsideComponent: l, isInsideCanvas: s, setCanvasOffset: d, selectedShape: h, canvasOffsetStartData: c, refreshSelectedShapes: f, setSelectedShape: p, setSelectionFrame: m, setCanvasOffsetStartData: u, updateSingleShape: S, duplicateShapes: w, saveShapes: x, setSelectionMode: b, setCanvasMoveAcceleration: y, settings: g, isShiftPressed: P, isAltPressed: z, withFrameSelection: D, withContextMenu: A, isSpacePressed: H }) => {
1148
- const Z = re(null), [E, F] = K({ mode: "default" }), { registerDoubleClickEvent: W, unRegisterDoubleClickEvent: I } = (() => {
1149
- const L = re(void 0), _ = re(void 0), M = (C) => {
1150
- const Q = Date.now();
1151
- L.current && Q < L.current + 300 && _.current?.(C), L.current = Date.now();
1185
+ })(oe, ve, H) : ((ke, He, Ue) => {
1186
+ if (He < 0 || He > ke.points.length - 1) return ke;
1187
+ const qe = { ...ke, points: ke.points.filter((Pe, Ze) => Ze !== He) };
1188
+ return zt(qe, Ue);
1189
+ })(oe, ve, H);
1190
+ je([Te], !0);
1191
+ }, [H, je]);
1192
+ de(() => {
1193
+ me(Pn(g, m || b));
1194
+ }, [g, m, b]);
1195
+ const Ui = { canvas: T, editor: A, setEditor: F };
1196
+ return { annotationsProps: { style: { userSelect: "none", touchAction: "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": H.canvasZoom, "--react-paint-canvas-offset-x": H.canvasOffset[0], "--react-paint-canvas-offset-y": H.canvasOffset[1], "--react-paint-app-canvaswidth": e, "--react-paint-app-canvasheight": t } }, editorProps: { shapesRef: le, addPictureShape: bt, moveShapes: Qt, swapShapes: ct, toggleShapeVisibility: xe, toggleShapeLock: Y, duplicateShapes: ot, canGoBackward: Tt, canGoForward: qa, canClear: Ga, selectedShape: fe, copiedShape: We, setCopiedShape: Ce, pasteShapes: Xi, saveShapes: be, removeShape: st, updateShape: je, backwardShape: dt, forwardShape: ht, removeShapePoint: no, transformShape: nt, refs: Ui, width: e, height: t, selectTool: li, selectShapes: Ct, selectAllShapes: $i, activeTool: ne, setActiveTool: I, setAvailableTools: me, isEditMode: D, availableTools: ae, gridGap: se, setGridGap: he, loadFile: to, exportPicture: ja, exportData: _a, clearCanvas: io, selectionMode: j, setSelectionMode: ee, settings: H, setCanvasZoom: W, resetZoom: V, canvas: { canGrow: d, canShrink: u, layersManipulation: r, withExport: p, withLoadAndSave: f, withUploadPicture: m, withUrlPicture: b, withContextMenu: E } }, canvasProps: { shapesRef: le, selectedShape: fe, selectionFrame: Ve, hoveredShape: Fe, copiedShape: We, pasteShapes: Xi, setCopiedShape: Ce, addShape: Ye, setSelectedShape: $e, setSelectionFrame: wt, refreshSelectedShapes: xt, refreshHoveredShape: Ae, removeShape: st, updateShape: je, duplicateShapes: ot, backwardShape: dt, forwardShape: ht, saveShapes: be, refs: Ui, width: e, height: t, settings: H, setCanvasSize: $, setCanvasOffset: L, setCanvasZoom: W, resetZoom: V, selectShapes: Ct, selectAllShapes: $i, activeTool: ne, setActiveTool: I, isInsideComponent: O, isInsideCanvas: ge, isEditMode: D, canvas: { withSkeleton: x, withFrameSelection: k, withContextMenu: E, canGrow: d, canShrink: u }, canvasOffsetStartData: X, setCanvasOffsetStartData: Z, selectionMode: j, setSelectionMode: ee, setCanvasMoveAcceleration: Oi, isShiftPressed: ue, isAltPressed: Ie, isSpacePressed: we, setShiftPressed: Se, setAltPressed: te, setIsSpacePressed: re }, registerEvent: ye, unregisterEvent: ie, resetCanvas: eo, resetZoom: V, getCurrentImage: Ka, getCurrentData: Ja, setCanvasOffset: L, setCanvasZoom: W };
1197
+ }, Fo = ({ addShapes: e, drawCanvasRef: t, setActiveTool: i, refreshHoveredShape: n, shapes: a, selectionMode: o, activeTool: r, isInsideComponent: l, isInsideCanvas: s, setCanvasOffset: c, selectedShape: h, canvasOffsetStartData: d, refreshSelectedShapes: u, setSelectedShape: p, setSelectionFrame: f, setCanvasOffsetStartData: m, updateSingleShape: b, duplicateShapes: x, saveShapes: k, setSelectionMode: M, setCanvasMoveAcceleration: S, settings: g, isShiftPressed: P, isAltPressed: z, withFrameSelection: N, withContextMenu: D, isSpacePressed: E }) => {
1198
+ const A = ce(null), [T, B] = J({ mode: "default" }), { registerDoubleClickEvent: F, unRegisterDoubleClickEvent: X } = (() => {
1199
+ const C = ce(void 0), $ = ce(void 0), Q = (w) => {
1200
+ const y = Date.now();
1201
+ C.current && y < C.current + 300 && $.current?.(w), C.current = Date.now();
1152
1202
  };
1153
- return { registerDoubleClickEvent: (C, Q) => {
1154
- _.current = Q, C.addEventListener("click", M), C.addEventListener("touchend", M);
1155
- }, unRegisterDoubleClickEvent: (C) => {
1156
- C.removeEventListener("click", M), C.removeEventListener("touchend", M);
1203
+ return { registerDoubleClickEvent: (w, y) => {
1204
+ $.current = y, w.addEventListener("click", Q), w.addEventListener("touchend", Q);
1205
+ }, unRegisterDoubleClickEvent: (w) => {
1206
+ w.removeEventListener("click", Q), w.removeEventListener("touchend", Q);
1157
1207
  } };
1158
- })(), oe = (L, _) => {
1159
- const M = _?.getContext("2d");
1160
- if (M) {
1161
- if (r === Je && A) {
1162
- const C = ft(L, t.current, g), { shape: Q, mode: V } = Bt(M, o, C, g, h, ot(L), !1);
1163
- p(Q), b({ mode: "contextMenu", cursorStartPosition: C, originalShape: Q, anchor: "anchor" in V ? V.anchor : void 0 });
1164
- } else p(void 0), b({ mode: "default" });
1165
- i(Je), m(void 0);
1208
+ })(), Z = (C, $) => {
1209
+ const Q = $?.getContext("2d");
1210
+ if (Q) {
1211
+ if (r === Je && D) {
1212
+ const w = ft(C, t.current, g), { shape: y, mode: L } = Ot(Q, a, w, g, h, at(C), !1);
1213
+ p(y), M({ mode: "contextMenu", cursorStartPosition: w, originalShape: y, anchor: "anchor" in L ? L.anchor : void 0 });
1214
+ } else p(void 0), M({ mode: "default" });
1215
+ i(Je), f(void 0);
1166
1216
  }
1167
- }, te = re(null);
1168
- te.current = (L) => ((_, M, C, Q, V, N, k, J, O, T, ne, ye, Y, ze, ge, Oe, Ye, he) => {
1169
- if (he && clearTimeout(he), ot(_) && _.touches.length > 1) return;
1170
- const Se = M.current?.getContext("2d");
1171
- if (!Se) return;
1172
- const ae = ft(_, M.current, Y);
1173
- if (Q.mode === "selectionFrame") {
1174
- ye(Se, ae, Y);
1175
- const ee = Co(_, M.current, Y.canvasSize);
1176
- return void Ye([Math.ceil(et(ee[0] * Y.canvasZoom < 50 ? ee[0] * Y.canvasZoom - 50 : ee[0] * Y.canvasZoom > Y.canvasSize.width / Y.canvasSize.scaleRatioWithNoZoom - 50 ? ee[0] * Y.canvasZoom - (Y.canvasSize.width / Y.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / Y.canvasZoom), Math.ceil(et(ee[1] * Y.canvasZoom < 50 ? ee[1] * Y.canvasZoom - 50 : ee[1] * Y.canvasZoom > Y.canvasSize.height / Y.canvasSize.scaleRatioWithNoZoom - 50 ? ee[1] * Y.canvasZoom - (Y.canvasSize.height / Y.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / Y.canvasZoom)]);
1217
+ }, ne = ce(null);
1218
+ ne.current = (C) => (($, Q, w, y, L, W, V, U, R, H, ae, me, O, ge, ue, Se, Ie, te) => {
1219
+ if (te && clearTimeout(te), at($) && $.touches.length > 1) return;
1220
+ const we = Q.current?.getContext("2d");
1221
+ if (!we) return;
1222
+ const re = ft($, Q.current, O);
1223
+ if (y.mode === "selectionFrame") {
1224
+ me(we, re, O);
1225
+ const ie = Pa($, Q.current, O.canvasSize);
1226
+ return void Ie([Math.ceil(et(ie[0] * O.canvasZoom < 50 ? ie[0] * O.canvasZoom - 50 : ie[0] * O.canvasZoom > O.canvasSize.width / O.canvasSize.scaleRatioWithNoZoom - 50 ? ie[0] * O.canvasZoom - (O.canvasSize.width / O.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / O.canvasZoom), Math.ceil(et(ie[1] * O.canvasZoom < 50 ? ie[1] * O.canvasZoom - 50 : ie[1] * O.canvasZoom > O.canvasSize.height / O.canvasSize.scaleRatioWithNoZoom - 50 ? ie[1] * O.canvasZoom - (O.canvasSize.height / O.canvasSize.scaleRatioWithNoZoom - 50) : 0, -100, 100) / 5 / O.canvasZoom)]);
1177
1227
  }
1178
- if (N !== void 0) return void ne([ae[0] + Y.canvasOffset[0] - N.start[0], ae[1] + Y.canvasOffset[1] - N.start[1]]);
1179
- if (Q.mode === "preview") {
1180
- const ee = U(C)[0];
1181
- if (ee?.type === "curve") {
1182
- const se = gn(ee, ae, Y, !0);
1183
- return void Oe(de([se], Y));
1228
+ if (W !== void 0) return void ae([re[0] + O.canvasOffset[0] - W.start[0], re[1] + O.canvasOffset[1] - W.start[1]]);
1229
+ if (y.mode === "preview") {
1230
+ const ie = _(w)[0];
1231
+ if (ie?.type === "curve") {
1232
+ const le = fn(ie, re, O, !0);
1233
+ return void Se(pe([le], O));
1184
1234
  }
1185
- if (ee?.type === "polygon") {
1186
- const se = un(ee, ae, Y, !0);
1187
- return void Oe(de([se], Y));
1235
+ if (ie?.type === "polygon") {
1236
+ const le = gn(ie, re, O, !0);
1237
+ return void Se(pe([le], O));
1188
1238
  }
1189
1239
  }
1190
- const fe = Dt(ae, Y);
1191
- if (ot(_) || J(_, Se, ae, fe), C === void 0 || C.locked) k({ mode: "default", outOfView: !fe });
1240
+ const ye = Dt(re, O);
1241
+ if (at($) || U($, we, re, ye), w === void 0 || w.locked) V({ mode: "default", outOfView: !ye });
1192
1242
  else {
1193
- if (Q.mode === "default" || Q.mode === "textedition" || Q.mode === "contextMenu") {
1194
- if (!fe) return void k({ mode: "default" });
1195
- k(Et(Se, C, ae, Y, !0) || { mode: "default" });
1243
+ if (y.mode === "default" || y.mode === "textedition" || y.mode === "contextMenu") {
1244
+ if (!ye) return void V({ mode: "default" });
1245
+ V(Et(we, w, re, O, !0) || { mode: "default" });
1196
1246
  } else {
1197
- const ee = M.current?.getContext("2d");
1198
- if (!ee) return;
1199
- const se = na(ee, C, ae, Q, Y, ze, ge);
1200
- O(U(se));
1247
+ const ie = Q.current?.getContext("2d");
1248
+ if (!ie) return;
1249
+ const le = ho(ie, w, re, y, O, ge, ue);
1250
+ R(_(le));
1201
1251
  }
1202
- Q.mode === "translate" && ge && !Q.hasBeenDuplicated && (V({ ...Q, hasBeenDuplicated: !0 }), T(U(Q.originalShape)));
1252
+ y.mode === "translate" && ue && !y.hasBeenDuplicated && (L({ ...y, hasBeenDuplicated: !0 }), H(_(y.originalShape)));
1203
1253
  }
1204
- })(L, t, h, a, b, c, F, n, S, w, d, f, g, P, z, p, y, Z.current), le(() => {
1254
+ })(C, t, h, o, M, d, B, n, b, x, c, u, g, P, z, p, S, A.current), de(() => {
1205
1255
  if (l) {
1206
- const L = (_) => te.current?.(_);
1207
- return document.addEventListener("mousemove", L), document.addEventListener("touchmove", L), () => {
1208
- document.removeEventListener("mousemove", L), document.removeEventListener("touchmove", L);
1256
+ const C = ($) => ne.current?.($);
1257
+ return document.addEventListener("mousemove", C), document.addEventListener("touchmove", C), () => {
1258
+ document.removeEventListener("mousemove", C), document.removeEventListener("touchmove", C);
1209
1259
  };
1210
1260
  }
1211
1261
  }, [l]);
1212
- const { isBrushShapeDoneOnMouseUp: R } = g, $ = re(null);
1213
- $.current = (L) => {
1214
- if (Z.current && clearTimeout(Z.current), ot(L) && L.touches.length > 1) return;
1215
- const _ = t.current?.getContext("2d");
1216
- if (!_) return;
1217
- if ("button" in L && L.button === 2) return void oe(L, t.current);
1218
- if (c) return void u(void 0);
1219
- if (a.mode === "contextMenu" || a.mode === "textedition" || a.mode === "preview") return;
1220
- const M = ft(L, t.current, g);
1221
- if (a.mode === "translate" && Date.now() - a.dateStart <= 500 && M[0] === a.cursorStartPosition[0] && M[1] === a.cursorStartPosition[1]) {
1222
- if (L.ctrlKey || L.shiftKey || L.metaKey) {
1223
- const { shape: C } = Bt(_, o, M, g, h, ot(L), D, "remove");
1224
- U(C).length !== a.selectedShapesLengthAtMouseDown && p(C);
1262
+ const { isBrushShapeDoneOnMouseUp: I } = g, j = ce(null);
1263
+ j.current = (C) => {
1264
+ if (A.current && clearTimeout(A.current), at(C) && C.touches.length > 1) return;
1265
+ const $ = t.current?.getContext("2d");
1266
+ if (!$) return;
1267
+ if ("button" in C && C.button === 2) return void Z(C, t.current);
1268
+ if (d) return void m(void 0);
1269
+ if (o.mode === "contextMenu" || o.mode === "textedition" || o.mode === "preview") return;
1270
+ const Q = ft(C, t.current, g);
1271
+ if (o.mode === "translate" && Date.now() - o.dateStart <= 500 && Q[0] === o.cursorStartPosition[0] && Q[1] === o.cursorStartPosition[1]) {
1272
+ if (C.ctrlKey || C.shiftKey || C.metaKey) {
1273
+ const { shape: w } = Ot($, a, Q, g, h, at(C), N, "remove");
1274
+ _(w).length !== o.selectedShapesLengthAtMouseDown && p(w);
1225
1275
  }
1226
- return b({ mode: "default" }), m(void 0), void x();
1276
+ return M({ mode: "default" }), f(void 0), void k();
1227
1277
  }
1228
- a.mode !== "default" && (a.mode === "brush" && R && p(void 0), b({ mode: "default" }), m(void 0), x());
1229
- }, le(() => {
1278
+ o.mode !== "default" && (o.mode === "brush" && I && p(void 0), M({ mode: "default" }), f(void 0), k());
1279
+ }, de(() => {
1230
1280
  if (s) {
1231
- const L = (_) => $.current?.(_);
1232
- return document.addEventListener("mouseup", L), document.addEventListener("touchend", L), () => {
1233
- document.removeEventListener("mouseup", L), document.removeEventListener("touchend", L);
1281
+ const C = ($) => j.current?.($);
1282
+ return document.addEventListener("mouseup", C), document.addEventListener("touchend", C), () => {
1283
+ document.removeEventListener("mouseup", C), document.removeEventListener("touchend", C);
1234
1284
  };
1235
1285
  }
1236
1286
  }, [s]);
1237
- const j = !g.features.edition && g.features.zoom, ce = !g.features.edition && !g.features.zoom, Pe = re(null);
1238
- return Pe.current = (L, _, M) => {
1239
- if (L.preventDefault(), ot(L) && L.touches.length > 1) return;
1240
- const C = _?.getContext("2d");
1241
- if (!C) return;
1242
- _.focus();
1243
- const Q = ft(L, t.current, g), V = "button" in L && L.button === 1, N = "button" in L && L.button === 2;
1244
- if (V || M || r.type === "move" && !N) u({ start: Q, originalOffset: g.canvasOffset });
1245
- else if (!j) {
1246
- if (!Dt(Q, g)) return p(void 0), void b({ mode: "default" });
1247
- if (N) {
1287
+ const ee = !g.features.edition && g.features.zoom, se = !g.features.edition && !g.features.zoom, he = ce(null);
1288
+ return he.current = (C, $, Q) => {
1289
+ if (C.preventDefault(), at(C) && C.touches.length > 1) return;
1290
+ const w = $?.getContext("2d");
1291
+ if (!w) return;
1292
+ $.focus();
1293
+ const y = ft(C, t.current, g), L = "button" in C && C.button === 1, W = "button" in C && C.button === 2;
1294
+ if (L || Q || r.type === "move" && !W) m({ start: y, originalOffset: g.canvasOffset });
1295
+ else if (!ee) {
1296
+ if (!Dt(y, g)) return p(void 0), void M({ mode: "default" });
1297
+ if (W) {
1248
1298
  if (r.type === "selection") {
1249
- const { shape: k } = Bt(C, o, Q, g, h, ot(L), !1);
1250
- p(k), b({ mode: "default" });
1299
+ const { shape: V } = Ot(w, a, y, g, h, at(C), !1);
1300
+ p(V), M({ mode: "default" });
1251
1301
  }
1252
- } else if (ot(L) && (Z.current && clearTimeout(Z.current), Z.current = setTimeout(() => {
1253
- oe(L, t.current);
1302
+ } else if (at(C) && (A.current && clearTimeout(A.current), A.current = setTimeout(() => {
1303
+ Z(C, t.current);
1254
1304
  }, 500)), r.type === "selection") {
1255
- const k = L.ctrlKey || L.shiftKey || L.metaKey ? "add" : "replace", { shape: J, mode: O } = Bt(C, o, Q, g, h, ot(L), D, k);
1256
- p(J), b(O), O.mode === "selectionFrame" && m({ oldSelection: J, frame: [[Q[0], Q[1]], [Q[0], Q[1]]] });
1257
- } else if (uo.some((k) => k === r.type)) {
1258
- const k = U(h)[0], J = t.current?.getContext("2d");
1259
- if (!J) return;
1305
+ const V = C.ctrlKey || C.shiftKey || C.metaKey ? "add" : "replace", { shape: U, mode: R } = Ot(w, a, y, g, h, at(C), N, V);
1306
+ p(U), M(R), R.mode === "selectionFrame" && f({ oldSelection: U, frame: [[y[0], y[1]], [y[0], y[1]]] });
1307
+ } else if (pa.some((V) => V === r.type)) {
1308
+ const V = _(h)[0], U = t.current?.getContext("2d");
1309
+ if (!U) return;
1260
1310
  if (r.type === "brush") {
1261
- if (k?.type === "brush") {
1262
- const O = ((T, ne, ye) => {
1263
- const Y = { ...T, points: Xe(T.points.length, [[Math.round(ne[0]), Math.round(ne[1])]], T.points) };
1264
- return Zt(Y, ye);
1265
- })(k, Q, g);
1266
- S([O]);
1311
+ if (V?.type === "brush") {
1312
+ const R = ((H, ae, me) => {
1313
+ const O = { ...H, points: Xe(H.points.length, [[Math.round(ae[0]), Math.round(ae[1])]], H.points) };
1314
+ return Zt(O, me);
1315
+ })(V, y, g);
1316
+ b([R]);
1267
1317
  } else {
1268
- const O = mn(J, r, Q, g);
1269
- if (!O) return;
1270
- e([O]), p(de([O], g));
1318
+ const R = yn(U, r, y, g);
1319
+ if (!R) return;
1320
+ e([R]), p(pe([R], g));
1271
1321
  }
1272
- b({ mode: "brush" });
1273
- } else if (a.mode !== "preview" || k?.type !== "polygon" && k?.type !== "curve") {
1322
+ M({ mode: "brush" });
1323
+ } else if (o.mode !== "preview" || V?.type !== "polygon" && V?.type !== "curve") {
1274
1324
  if (r.type !== "picture") {
1275
- const O = mn(J, r, Q, g);
1276
- if (!O) return;
1277
- e([O]);
1278
- const T = de([O], g);
1279
- p(T), O.type === "polygon" || O.type === "curve" ? b({ mode: "preview" }) : (i(Je), b({ mode: "resize", cursorStartPosition: [Q[0] + g.selectionPadding, Q[1] + g.selectionPadding], originalShape: T, anchor: O.type === "line" ? 0 : [1, 1], selectedShapesLengthAtMouseDown: U(T).length }));
1325
+ const R = yn(U, r, y, g);
1326
+ if (!R) return;
1327
+ e([R]);
1328
+ const H = pe([R], g);
1329
+ p(H), R.type === "polygon" || R.type === "curve" ? M({ mode: "preview" }) : (i(Je), M({ mode: "resize", cursorStartPosition: [y[0] + g.selectionPadding, y[1] + g.selectionPadding], originalShape: H, anchor: R.type === "line" ? 0 : [1, 1], selectedShapesLengthAtMouseDown: _(H).length }));
1280
1330
  }
1281
1331
  } else {
1282
- const O = k.type === "polygon" ? un(k, Q, g) : gn(k, Q, g);
1283
- p(de([O], g)), S([O], !0);
1332
+ const R = V.type === "polygon" ? gn(V, y, g) : fn(V, y, g);
1333
+ p(pe([R], g)), b([R], !0);
1284
1334
  }
1285
1335
  }
1286
1336
  }
1287
- }, le(() => {
1288
- if (ce) return;
1289
- const L = t.current;
1290
- if (!L) return;
1291
- const _ = (M) => Pe.current?.(M, L, H);
1292
- return L.addEventListener("mousedown", _, { passive: !1 }), L.addEventListener("touchstart", _, { passive: !1 }), () => {
1293
- L.removeEventListener("mousedown", _), L.removeEventListener("touchstart", _);
1337
+ }, de(() => {
1338
+ if (se) return;
1339
+ const C = t.current;
1340
+ if (!C) return;
1341
+ const $ = (Q) => he.current?.(Q, C, E);
1342
+ return C.addEventListener("mousedown", $, { passive: !1 }), C.addEventListener("touchstart", $, { passive: !1 }), () => {
1343
+ C.removeEventListener("mousedown", $), C.removeEventListener("touchstart", $);
1294
1344
  };
1295
- }, [ce, t, H]), le(() => {
1296
- const L = t.current, _ = t.current?.getContext("2d");
1297
- if (!(!L || !_))
1298
- return s ? (W(L, (M) => {
1345
+ }, [se, t, E]), de(() => {
1346
+ const C = t.current, $ = t.current?.getContext("2d");
1347
+ if (!(!C || !$))
1348
+ return s ? (F(C, (Q) => {
1299
1349
  if (r.type === "selection") {
1300
- if (U(h).length !== 1) return;
1301
- const C = U(h)[0];
1302
- if (C?.type === "text") {
1303
- const Q = ft(M, t.current, g);
1304
- return Dt(Q, g) ? void (Et(_, h, Q, g) && b({ mode: "textedition", defaultValue: C.value })) : void 0;
1350
+ if (_(h).length !== 1) return;
1351
+ const w = _(h)[0];
1352
+ if (w?.locked) return;
1353
+ if (w?.type === "text") {
1354
+ const y = ft(Q, t.current, g);
1355
+ return Dt(y, g) ? void (Et($, h, y, g) && M({ mode: "textedition", defaultValue: w.value })) : void 0;
1305
1356
  }
1306
- if (C?.type === "polygon") {
1307
- const Q = ft(M, t.current, g);
1308
- if (!Dt(Q, g)) return;
1309
- const V = hn(_, C, Q, g);
1310
- return void (V && S([fa(C, V.lineIndex, Q, g)]));
1357
+ if (w?.type === "polygon") {
1358
+ const y = ft(Q, t.current, g);
1359
+ if (!Dt(y, g)) return;
1360
+ const L = un($, w, y, g);
1361
+ return void (L && b([wo(w, L.lineIndex, y, g)]));
1311
1362
  }
1312
- if (C?.type === "curve") {
1313
- const Q = ft(M, t.current, g);
1314
- if (!Dt(Q, g)) return;
1315
- const V = ((N, k, J, O, T = 50) => {
1316
- if (k.locked || k.points.length < 2) return !1;
1317
- if (k.points.length < 3) return hn(N, k, J, O, T);
1318
- const { center: ne } = k.computed, ye = tt(J, k.rotation ?? 0, ne);
1319
- N.lineWidth = (k.style?.lineWidth ?? 0) + T / O.canvasZoom;
1320
- const Y = Ti(k, k.points), ze = new Path2D();
1321
- ze.moveTo(...Y[0]);
1322
- for (let ge = 1; ge < Y.length - 2; ge++) {
1323
- const Oe = Y[ge - 1], Ye = Y[ge], he = Y[ge + 1], Se = Y[ge + 2], { cp1: ae, cp2: fe } = Di(Oe, Ye, he, Se);
1324
- if (ze.bezierCurveTo(ae[0], ae[1], fe[0], fe[1], he[0], he[1]), N.isPointInStroke(ze, ye[0], ye[1])) return { lineIndex: ge - 1 };
1363
+ if (w?.type === "curve") {
1364
+ const y = ft(Q, t.current, g);
1365
+ if (!Dt(y, g)) return;
1366
+ const L = ((W, V, U, R, H = 50) => {
1367
+ if (V.locked || V.points.length < 2) return !1;
1368
+ if (V.points.length < 3) return un(W, V, U, R, H);
1369
+ const { center: ae } = V.computed, me = tt(U, V.rotation ?? 0, ae);
1370
+ W.lineWidth = (V.style?.lineWidth ?? 0) + H / R.canvasZoom;
1371
+ const O = Ti(V, V.points), ge = new Path2D();
1372
+ ge.moveTo(...O[0]);
1373
+ for (let ue = 1; ue < O.length - 2; ue++) {
1374
+ const Se = O[ue - 1], Ie = O[ue], te = O[ue + 1], we = O[ue + 2], { cp1: re, cp2: ye } = Di(Se, Ie, te, we);
1375
+ if (ge.bezierCurveTo(re[0], re[1], ye[0], ye[1], te[0], te[1]), W.isPointInStroke(ge, me[0], me[1])) return { lineIndex: ue - 1 };
1325
1376
  }
1326
1377
  return !1;
1327
- })(_, C, Q, g);
1328
- return void (V && S([ma(C, V.lineIndex, Q, g)]));
1378
+ })($, w, y, g);
1379
+ return void (L && b([Mo(w, L.lineIndex, y, g)]));
1329
1380
  }
1330
1381
  }
1331
1382
  }), () => {
1332
- I(L);
1383
+ X(C);
1333
1384
  }) : void 0;
1334
- }, [S, W, I, s, t, r, h, b, g]), { hoverMode: E };
1335
- }, Wo = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => Wo(t)).join("") : e.nodeValue ?? "", Wa = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: n, saveShapes: o, settings: a }) => {
1336
- const r = re(null), l = re(o);
1337
- le(() => {
1385
+ }, [b, F, X, s, t, r, h, M, g]), { hoverMode: T };
1386
+ }, $a = (e) => e.childNodes.length ? Array.from(e.childNodes).map((t) => $a(t)).join("") : e.nodeValue ?? "", Yo = ({ disabled: e = !1, shape: t, defaultValue: i, updateValue: n, saveShapes: a, settings: o }) => {
1387
+ const r = ce(null), l = ce(a);
1388
+ de(() => {
1338
1389
  if (!r.current) return;
1339
- const c = r.current, f = (p) => {
1390
+ const d = r.current, u = (p) => {
1340
1391
  p.preventDefault();
1341
- const m = p.clipboardData?.getData("text/plain");
1342
- document.execCommand("insertText", !1, m);
1392
+ const f = p.clipboardData?.getData("text/plain");
1393
+ document.execCommand("insertText", !1, f);
1343
1394
  };
1344
- c.addEventListener("paste", f), c.innerText = "";
1395
+ d.addEventListener("paste", u), d.innerText = "";
1345
1396
  for (const p of i) {
1346
- const m = document.createElement("div");
1347
- p === "" ? m.innerHTML = "<br/>" : m.innerText = p, c.appendChild(m);
1397
+ const f = document.createElement("div");
1398
+ p === "" ? f.innerHTML = "<br/>" : f.innerText = p, d.appendChild(f);
1348
1399
  }
1349
- return c.focus(), () => {
1350
- c.removeEventListener("paste", f);
1400
+ return d.focus(), () => {
1401
+ d.removeEventListener("paste", u);
1351
1402
  };
1352
- }, [i]), le(() => {
1353
- const c = l.current;
1403
+ }, [i]), de(() => {
1404
+ const d = l.current;
1354
1405
  return () => {
1355
- c();
1406
+ d();
1356
1407
  };
1357
1408
  }, []);
1358
- const s = Fn(() => {
1359
- const { borders: c, center: f } = t.computed;
1360
- return me({ point: [c.x, c.y], rotation: -(t.rotation ?? 0), origin: f });
1361
- }, [t]), d = [`translate3D(${(s[0] + a.canvasOffset[0]) * a.canvasSize.scaleRatio}px, ${(s[1] + a.canvasOffset[1]) * a.canvasSize.scaleRatio}px, 0)`, `rotate(${Qi(t.rotation ?? 0)}deg)`, t.flipX || t.flipY ? `scale(${t.flipX ? -1 : 1}, ${t.flipY ? -1 : 1})` : void 0, t.flipX || t.flipY ? `translate3D(${t.flipX ? -100 : 0}%,${t.flipY ? -100 : 0}%,0)` : void 0].filter(Boolean).join(" "), h = !e;
1362
- return v("div", { className: "react-paint-editor-toolbox-edittextbox", ref: r, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: h, role: "textbox", tabIndex: h ? 0 : void 0, onInput: (c) => {
1363
- const f = Array.from(c.target.childNodes).map((p) => Wo(p));
1364
- n(f);
1365
- }, style: { "--react-paint-editor-toolbox-edittextbox-transform": d, "--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 ?? It } });
1366
- }, Na = (e, t, i, n, o) => {
1367
- So(e), ((a, r) => {
1368
- const { canvasZoom: l, size: s, canvasSize: { width: d, height: h } } = r;
1409
+ const s = Yn(() => {
1410
+ const { borders: d, center: u } = t.computed;
1411
+ return Qe({ point: [d.x, d.y], rotation: -(t.rotation ?? 0), origin: u });
1412
+ }, [t]), c = [`translate3D(${(s[0] + o.canvasOffset[0]) * o.canvasSize.scaleRatio}px, ${(s[1] + o.canvasOffset[1]) * o.canvasSize.scaleRatio}px, 0)`, `rotate(${Qi(t.rotation ?? 0)}deg)`, t.flipX || t.flipY ? `scale(${t.flipX ? -1 : 1}, ${t.flipY ? -1 : 1})` : void 0, t.flipX || t.flipY ? `translate3D(${t.flipX ? -100 : 0}%,${t.flipY ? -100 : 0}%,0)` : void 0].filter(Boolean).join(" "), h = !e;
1413
+ return v("div", { className: "react-paint-editor-toolbox-edittextbox", ref: r, "data-fontbold": t.style?.fontBold ?? !1, "data-fontitalic": t.style?.fontItalic ?? !1, contentEditable: h, role: "textbox", tabIndex: h ? 0 : void 0, onInput: (d) => {
1414
+ const u = Array.from(d.target.childNodes).map((p) => $a(p));
1415
+ n(u);
1416
+ }, style: { "--react-paint-editor-toolbox-edittextbox-transform": c, "--react-paint-editor-toolbox-edittextbox-fontsize": t.fontSize * o.canvasSize.scaleRatio + "px", "--react-paint-editor-toolbox-edittextbox-padding": o.selectionPadding * o.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 ?? It } });
1417
+ }, Xo = (e, t, i, n, a) => {
1418
+ ya(e), ((o, r) => {
1419
+ const { canvasZoom: l, size: s, canvasSize: { width: c, height: h } } = r;
1369
1420
  if (s !== "fixed" || l >= 1) return;
1370
- a.fillStyle = "#f5f5f5", a.fillRect(0, 0, d, h);
1371
- const c = ko(r);
1372
- a.clearRect(c.x, c.y, c.width, c.height), Lo(a, r);
1373
- })(e, i), ((a, r) => {
1374
- const { canvasSize: { width: l, height: s }, gridGap: d, canvasOffset: h, canvasSize: { scaleRatio: c } } = r;
1375
- if (!d) return;
1376
- a.strokeStyle = "rgb(220,220,220)", a.lineWidth = 1, a.save(), a.scale(c, c), a.beginPath();
1377
- const f = h[0] % d, p = h[1] % d, m = Math.ceil(l / c / d) + 2, u = Math.ceil(s / c / d) + 2;
1378
- for (let S = -5; S < m; S++) a.moveTo(f + (S + 1) * d, p - d), a.lineTo(f + (S + 1) * d, p + s / c + d);
1379
- for (let S = -5; S < u; S++) a.moveTo(f - d, p + (S + 1) * d), a.lineTo(f + l / c + d, p + (S + 1) * d);
1380
- a.stroke(), a.restore();
1421
+ o.fillStyle = "#f5f5f5", o.fillRect(0, 0, c, h);
1422
+ const d = Va(r);
1423
+ o.clearRect(d.x, d.y, d.width, d.height), Za(o, r);
1424
+ })(e, i), ((o, r) => {
1425
+ const { canvasSize: { width: l, height: s }, gridGap: c, canvasOffset: h, canvasSize: { scaleRatio: d } } = r;
1426
+ if (!c) return;
1427
+ o.strokeStyle = "rgb(220,220,220)", o.lineWidth = 1, o.save(), o.scale(d, d), o.beginPath();
1428
+ const u = h[0] % c, p = h[1] % c, f = Math.ceil(l / d / c) + 2, m = Math.ceil(s / d / c) + 2;
1429
+ for (let b = -5; b < f; b++) o.moveTo(u + (b + 1) * c, p - c), o.lineTo(u + (b + 1) * c, p + s / d + c);
1430
+ for (let b = -5; b < m; b++) o.moveTo(u - c, p + (b + 1) * c), o.lineTo(u + l / d + c, p + (b + 1) * c);
1431
+ o.stroke(), o.restore();
1381
1432
  })(e, i);
1382
- for (let a = n.length - 1; a >= 0; a--) t.mode === "textedition" && n[a] === o || Ao(e, U(o).find((r) => r.id === n[a].id) ?? n[a], i);
1383
- }, Oa = ki.forwardRef(({ canGrow: e, shapes: t, duplicateShapes: i, addShapes: n, updateSingleShape: o, selectedShape: a, setSelectedShape: r, setSelectionFrame: l, hoveredShape: s, selectionFrame: d, refreshHoveredShape: h, refreshSelectedShapes: c, saveShapes: f, activeTool: p, setActiveTool: m, canvasOffsetStartData: u, setCanvasOffsetStartData: S, setCanvasOffset: w, setCanvasMoveAcceleration: x, isInsideComponent: b, isInsideCanvas: y, selectionMode: g, setSelectionMode: P, selectionWidth: z, selectionColor: D, settings: A, isEditMode: H, isShiftPressed: Z, isAltPressed: E, isSpacePressed: F, withFrameSelection: W, withSkeleton: I, withContextMenu: oe }, te) => {
1384
- const R = re(null), $ = re(null), j = A.canvasSize, ce = H, Pe = H ? 0 : -1;
1385
- Yn(te, () => R.current);
1386
- const { hoverMode: L } = Ra({ addShapes: n, drawCanvasRef: R, setActiveTool: m, shapes: t, selectionMode: g, activeTool: p, isInsideComponent: b, isInsideCanvas: y, setCanvasOffset: w, selectedShape: a, canvasOffsetStartData: u, setCanvasOffsetStartData: S, setSelectedShape: r, setSelectionFrame: l, refreshHoveredShape: h, refreshSelectedShapes: c, updateSingleShape: o, duplicateShapes: i, saveShapes: f, setSelectionMode: P, setCanvasMoveAcceleration: x, isShiftPressed: Z, isAltPressed: E, withFrameSelection: W, settings: A, isSpacePressed: F, withContextMenu: oe }), _ = X((C) => {
1387
- const Q = U(a)[0];
1388
- if (Q?.type !== "text") return;
1389
- const V = R.current?.getContext("2d");
1390
- if (!V) return;
1391
- const N = _e(Va(V, Q, C, A), A);
1392
- o([N]);
1393
- }, [o, a, A]), M = (C) => {
1394
- if (H) return C.preventDefault(), C.stopPropagation(), !1;
1433
+ for (let o = n.length - 1; o >= 0; o--) t.mode === "textedition" && n[o] === a || Ra(e, _(a).find((r) => r.id === n[o].id) ?? n[o], i);
1434
+ }, $o = Pi.forwardRef(({ canGrow: e, shapes: t, duplicateShapes: i, addShapes: n, updateSingleShape: a, selectedShape: o, setSelectedShape: r, setSelectionFrame: l, hoveredShape: s, selectionFrame: c, refreshHoveredShape: h, refreshSelectedShapes: d, saveShapes: u, activeTool: p, setActiveTool: f, canvasOffsetStartData: m, setCanvasOffsetStartData: b, setCanvasOffset: x, setCanvasMoveAcceleration: k, isInsideComponent: M, isInsideCanvas: S, selectionMode: g, setSelectionMode: P, selectionWidth: z, selectionColor: N, settings: D, isEditMode: E, isShiftPressed: A, isAltPressed: T, isSpacePressed: B, withFrameSelection: F, withSkeleton: X, withContextMenu: Z }, ne) => {
1435
+ const I = ce(null), j = ce(null), ee = D.canvasSize, se = E, he = E ? 0 : -1;
1436
+ Xn(ne, () => I.current);
1437
+ const { hoverMode: C } = Fo({ addShapes: n, drawCanvasRef: I, setActiveTool: f, shapes: t, selectionMode: g, activeTool: p, isInsideComponent: M, isInsideCanvas: S, setCanvasOffset: x, selectedShape: o, canvasOffsetStartData: m, setCanvasOffsetStartData: b, setSelectedShape: r, setSelectionFrame: l, refreshHoveredShape: h, refreshSelectedShapes: d, updateSingleShape: a, duplicateShapes: i, saveShapes: u, setSelectionMode: P, setCanvasMoveAcceleration: k, isShiftPressed: A, isAltPressed: T, withFrameSelection: F, settings: D, isSpacePressed: B, withContextMenu: Z }), $ = G((w) => {
1438
+ const y = _(o)[0];
1439
+ if (y?.type !== "text") return;
1440
+ const L = I.current?.getContext("2d");
1441
+ if (!L) return;
1442
+ const W = _e(To(L, y, w, D), D);
1443
+ a([W]);
1444
+ }, [a, o, D]), Q = (w) => {
1445
+ if (E) return w.preventDefault(), w.stopPropagation(), !1;
1395
1446
  };
1396
- return le(() => {
1397
- const C = R.current?.getContext("2d");
1398
- C && window.requestAnimationFrame(() => Na(C, g, A, t, a));
1399
- }, [t, g, a, A]), le(() => {
1400
- const C = $.current?.getContext("2d");
1401
- C && window.requestAnimationFrame(() => ((Q, V, N, k, J, O, T, ne, ye, Y, ze) => {
1402
- Q.reset(), Lo(Q, N), ze && ne && !U(T).find((ge) => ge.id === ne.id) && k.type === "selection" && (V.mode === "default" || V.mode === "contextMenu" || V.mode === "textedition") && bn({ ctx: Q, shape: ne, settings: N, selectionWidth: J, selectionColor: O, hoverMode: ye, selectionMode: V, withAnchors: !1 }), T && k.type !== "brush" && bn({ ctx: Q, shape: T, settings: N, selectionWidth: J, selectionColor: O, hoverMode: ye, selectionMode: V, withAnchors: V.mode !== "textedition" }), Y && za({ ctx: Q, selectionFrame: Y, settings: N });
1403
- })(C, g, A, p, z, D, a, s, L, d, I));
1404
- }, [s, L, d, g, a, p, A, z, D, I]), v("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": u ? "grabbing" : L.outOfView ? "default" : L.mode === "resize" ? "pointer" : p.type !== "selection" && p.type !== "move" ? "crosshair" : L.mode === "translate" ? "move" : L.mode === "rotate" || p.type === "move" || F ? "grab" : "default" }, children: G("div", { className: "react-paint-canvas-container", "data-grow": e, children: [v("canvas", { className: go, ref: R, "data-grow": e, width: j.width, height: j.height, onContextMenu: M, tabIndex: Pe }), ce && v("canvas", { className: fo, ref: $, width: j.width, height: j.height, "data-grow": e, onContextMenu: M }), H && g.mode === "textedition" && U(a)[0]?.type === "text" && v(Wa, { disabled: !A.features.edition, shape: U(a)[0], defaultValue: g.defaultValue, updateValue: _, saveShapes: f, settings: A })] }) });
1405
- }), kn = "ArrowUp", Ln = "ArrowDown", Vn = "ArrowLeft", Zn = "ArrowRight", Ba = "Delete", Fa = "Backspace", Ya = "Escape", zn = "Shift", An = "Alt", Hn = "Option", jt = " ", Xa = "A", $a = "a", Ua = "z", qa = "Z", Ga = "y", _a = "Y", ja = "+", Ka = "-", Ja = "0", Tn = "cut", Dn = "copy", En = "paste", Zs = ({ options: e, className: t, style: i, canvasProps: n }) => {
1406
- const { shapesRef: o, selectedShape: a, selectionFrame: r, hoveredShape: l, addShape: s, setSelectedShape: d, selectAllShapes: h, setSelectionFrame: c, refreshSelectedShapes: f, refreshHoveredShape: p, duplicateShapes: m, removeShape: u, updateShape: S, backwardShape: w, forwardShape: x, saveShapes: b, refs: y, width: g, height: P, settings: z, setCanvasSize: D, setCanvasOffset: A, pasteShapes: H, activeTool: Z, setActiveTool: E, isInsideComponent: F, isInsideCanvas: W, isEditMode: I, canvas: { withSkeleton: oe, withFrameSelection: te, withContextMenu: R, canGrow: $, canShrink: j }, canvasOffsetStartData: ce, setCanvasOffsetStartData: Pe, selectionMode: L, setSelectionMode: _, setCanvasMoveAcceleration: M, isShiftPressed: C, isAltPressed: Q, isSpacePressed: V, copiedShape: N, setCopiedShape: k, setShiftPressed: J, setAltPressed: O, setCanvasZoom: T, resetZoom: ne, setIsSpacePressed: ye } = n, { canvasBackgroundColor: Y, canvasSelectionColor: ze, canvasSelectionWidth: ge } = { ...ta, ...e }, Oe = re(null), Ye = X((he) => {
1407
- D({ realWidth: g, realHeight: P, width: he, height: P * he / g, scaleRatio: he / g });
1408
- }, [g, P, D]);
1409
- return (({ isInsideComponent: he, isInsideCanvas: Se, selectedShape: ae, isEditingText: fe, settings: ee, copiedShape: se, setCopiedShape: pe, setSelectedShape: ke, setActiveTool: Be, setCanvasZoom: Ee, resetZoom: we, setSelectionMode: Fe, setSelectionFrame: bt, selectAllShapes: Qt, removeShape: dt, pasteShapes: $e, updateShapes: wt, backwardShape: xt, forwardShape: Ae, setShiftPressed: at, setAltPressed: st, setIsSpacePressed: je }) => {
1410
- le(() => {
1411
- const ct = (B) => {
1412
- ae && (fe || (B.preventDefault(), pe({ ...ae })));
1413
- }, ht = (B) => {
1414
- ae && (fe || (B.preventDefault(), pe({ ...ae }), dt(U(ae))));
1415
- }, pt = (B) => {
1416
- se && (fe || (B.preventDefault(), $e(Wi(se, ee))));
1417
- }, ve = (B) => {
1418
- switch (B.key) {
1447
+ return de(() => {
1448
+ const w = I.current?.getContext("2d");
1449
+ w && window.requestAnimationFrame(() => Xo(w, g, D, t, o));
1450
+ }, [t, g, o, D]), de(() => {
1451
+ const w = j.current?.getContext("2d");
1452
+ w && window.requestAnimationFrame(() => ((y, L, W, V, U, R, H, ae, me, O, ge) => {
1453
+ y.reset(), Za(y, W), ge && ae && !_(H).find((ue) => ue.id === ae.id) && V.type === "selection" && (L.mode === "default" || L.mode === "contextMenu" || L.mode === "textedition") && Qn({ ctx: y, shape: ae, settings: W, selectionWidth: U, selectionColor: R, hoverMode: me, selectionMode: L, withAnchors: !1 }), H && V.type !== "brush" && Qn({ ctx: y, shape: H, settings: W, selectionWidth: U, selectionColor: R, hoverMode: me, selectionMode: L, withAnchors: L.mode !== "textedition" }), O && Eo({ ctx: y, selectionFrame: O, settings: W });
1454
+ })(w, g, D, p, z, N, o, s, C, c, X));
1455
+ }, [s, C, c, g, o, p, D, z, N, X]), v("div", { className: "react-paint-canvas-box", style: { "--react-paint-canvas-cursor": m ? "grabbing" : C.outOfView ? "default" : C.mode === "resize" ? "pointer" : p.type !== "selection" && p.type !== "move" ? "crosshair" : C.mode === "translate" ? "move" : C.mode === "rotate" || p.type === "move" || B ? "grab" : "default" }, children: K("div", { className: "react-paint-canvas-container", "data-grow": e, children: [v("canvas", { className: ga, ref: I, "data-grow": e, width: ee.width, height: ee.height, onContextMenu: Q, tabIndex: he }), se && v("canvas", { className: fa, ref: j, width: ee.width, height: ee.height, "data-grow": e, onContextMenu: Q }), E && g.mode === "textedition" && _(o)[0]?.type === "text" && v(Yo, { disabled: !D.features.edition, shape: _(o)[0], defaultValue: g.defaultValue, updateValue: $, saveShapes: u, settings: D })] }) });
1456
+ }), Ln = "ArrowUp", Vn = "ArrowDown", Zn = "ArrowLeft", Hn = "ArrowRight", Uo = "Delete", qo = "Backspace", Go = "Escape", zn = "Shift", An = "Alt", Tn = "Option", jt = " ", _o = "A", jo = "a", Ko = "z", Jo = "Z", es = "y", ts = "Y", is = "+", ns = "-", as = "0", Dn = "cut", En = "copy", In = "paste", Ds = ({ options: e, className: t, style: i, canvasProps: n }) => {
1457
+ const { shapesRef: a, selectedShape: o, selectionFrame: r, hoveredShape: l, addShape: s, setSelectedShape: c, selectAllShapes: h, setSelectionFrame: d, refreshSelectedShapes: u, refreshHoveredShape: p, duplicateShapes: f, removeShape: m, updateShape: b, backwardShape: x, forwardShape: k, saveShapes: M, refs: S, width: g, height: P, settings: z, setCanvasSize: N, setCanvasOffset: D, pasteShapes: E, activeTool: A, setActiveTool: T, isInsideComponent: B, isInsideCanvas: F, isEditMode: X, canvas: { withSkeleton: Z, withFrameSelection: ne, withContextMenu: I, canGrow: j, canShrink: ee }, canvasOffsetStartData: se, setCanvasOffsetStartData: he, selectionMode: C, setSelectionMode: $, setCanvasMoveAcceleration: Q, isShiftPressed: w, isAltPressed: y, isSpacePressed: L, copiedShape: W, setCopiedShape: V, setShiftPressed: U, setAltPressed: R, setCanvasZoom: H, resetZoom: ae, setIsSpacePressed: me } = n, { canvasBackgroundColor: O, canvasSelectionColor: ge, canvasSelectionWidth: ue } = { ...lo, ...e }, Se = ce(null), Ie = G((te) => {
1458
+ N({ realWidth: g, realHeight: P, width: te, height: P * te / g, scaleRatio: te / g });
1459
+ }, [g, P, N]);
1460
+ return (({ isInsideComponent: te, isInsideCanvas: we, selectedShape: re, isEditingText: ye, settings: ie, copiedShape: le, setCopiedShape: fe, setSelectedShape: Ve, setActiveTool: Fe, setCanvasZoom: We, resetZoom: Ce, setSelectionMode: Ye, setSelectionFrame: bt, selectAllShapes: Qt, removeShape: ct, pasteShapes: $e, updateShapes: wt, backwardShape: xt, forwardShape: Ae, setShiftPressed: ot, setAltPressed: st, setIsSpacePressed: je }) => {
1461
+ de(() => {
1462
+ const dt = (Y) => {
1463
+ re && (ye || (Y.preventDefault(), fe({ ...re })));
1464
+ }, ht = (Y) => {
1465
+ re && (ye || (Y.preventDefault(), fe({ ...re }), ct(_(re))));
1466
+ }, ut = (Y) => {
1467
+ le && (ye || (Y.preventDefault(), $e(Ri(le, ie))));
1468
+ }, be = (Y) => {
1469
+ switch (Y.key) {
1419
1470
  case zn:
1420
- at(!1);
1471
+ ot(!1);
1421
1472
  break;
1422
1473
  case An:
1423
- case Hn:
1474
+ case Tn:
1424
1475
  st(!1);
1425
1476
  break;
1426
1477
  case jt:
1427
1478
  je(!1);
1428
1479
  }
1429
- }, be = (B) => {
1430
- if (B.metaKey || B.ctrlKey) {
1431
- if (B.key === qa || B.key === Ua) return B.preventDefault(), B.stopPropagation(), void (B.shiftKey ? Ae() : xt());
1432
- if (!mo() && (B.key === _a || B.key === Ga)) return B.preventDefault(), B.stopPropagation(), void Ae();
1433
- if (B.key === Xa || B.key === $a) return B.preventDefault(), B.stopPropagation(), void Qt();
1434
- if (B.key === ja) return B.preventDefault(), B.stopPropagation(), void Ee("zoom");
1435
- if (B.key === Ka) return B.preventDefault(), B.stopPropagation(), void Ee("unzoom");
1436
- if (B.key === Ja) return B.preventDefault(), B.stopPropagation(), void we();
1480
+ }, xe = (Y) => {
1481
+ if (Y.metaKey || Y.ctrlKey) {
1482
+ if (Y.key === Jo || Y.key === Ko) return Y.preventDefault(), Y.stopPropagation(), void (Y.shiftKey ? Ae() : xt());
1483
+ if (!ma() && (Y.key === ts || Y.key === es)) return Y.preventDefault(), Y.stopPropagation(), void Ae();
1484
+ if (Y.key === _o || Y.key === jo) return Y.preventDefault(), Y.stopPropagation(), void Qt();
1485
+ if (Y.key === is) return Y.preventDefault(), Y.stopPropagation(), void We("zoom");
1486
+ if (Y.key === ns) return Y.preventDefault(), Y.stopPropagation(), void We("unzoom");
1487
+ if (Y.key === as) return Y.preventDefault(), Y.stopPropagation(), void Ce();
1437
1488
  }
1438
- if (B.key === zn) return B.preventDefault(), B.stopPropagation(), void at(!0);
1439
- if (B.key === jt && Se) return B.preventDefault(), B.stopPropagation(), void je(!0);
1440
- if (B.key === An || B.key === Hn) return B.preventDefault(), B.stopPropagation(), void st(!0);
1441
- if (!ae) return;
1442
- if (B.key === Ya) return ke(void 0), Be(Je), Fe({ mode: "default" }), void bt(void 0);
1443
- if (fe) return;
1444
- const nt = { [Vn]: [ee.gridGap ? -ee.gridGap : -1, 0], [Zn]: [ee.gridGap ? ee.gridGap : 1, 0], [Ln]: [0, ee.gridGap ? ee.gridGap : 1], [kn]: [0, ee.gridGap ? -ee.gridGap : -1] };
1445
- switch (B.key) {
1446
- case Vn:
1489
+ if (Y.key === zn) return Y.preventDefault(), Y.stopPropagation(), void ot(!0);
1490
+ if (Y.key === jt && we) return Y.preventDefault(), Y.stopPropagation(), void je(!0);
1491
+ if (Y.key === An || Y.key === Tn) return Y.preventDefault(), Y.stopPropagation(), void st(!0);
1492
+ if (!re) return;
1493
+ if (Y.key === Go) return Ve(void 0), Fe(Je), Ye({ mode: "default" }), void bt(void 0);
1494
+ if (ye) return;
1495
+ const nt = { [Zn]: [ie.gridGap ? -ie.gridGap : -1, 0], [Hn]: [ie.gridGap ? ie.gridGap : 1, 0], [Vn]: [0, ie.gridGap ? ie.gridGap : 1], [Ln]: [0, ie.gridGap ? -ie.gridGap : -1] };
1496
+ switch (Y.key) {
1447
1497
  case Zn:
1498
+ case Hn:
1499
+ case Vn:
1448
1500
  case Ln:
1449
- case kn:
1450
- B.preventDefault(), B.stopPropagation(), wt(Do(nt[B.key], ae, [0, 0], ee, !0));
1501
+ Y.preventDefault(), Y.stopPropagation(), wt(Oa(nt[Y.key], re, [0, 0], ie, !0));
1451
1502
  break;
1452
- case Ba:
1453
- case Fa:
1454
- B.preventDefault(), B.stopPropagation(), dt(U(ae));
1503
+ case Uo:
1504
+ case qo:
1505
+ Y.preventDefault(), Y.stopPropagation(), ct(_(re));
1455
1506
  }
1456
1507
  };
1457
- if (he) return document.addEventListener("keydown", be), document.addEventListener("keyup", ve), document.addEventListener(Dn, ct), document.addEventListener(En, pt), document.addEventListener(Tn, ht), () => {
1458
- document.removeEventListener("keydown", be), document.removeEventListener("keyup", ve), document.removeEventListener(Dn, ct), document.removeEventListener(En, pt), document.removeEventListener(Tn, ht);
1508
+ if (te) return document.addEventListener("keydown", xe), document.addEventListener("keyup", be), document.addEventListener(En, dt), document.addEventListener(In, ut), document.addEventListener(Dn, ht), () => {
1509
+ document.removeEventListener("keydown", xe), document.removeEventListener("keyup", be), document.removeEventListener(En, dt), document.removeEventListener(In, ut), document.removeEventListener(Dn, ht);
1459
1510
  };
1460
- }, [he, Se, se, fe, ae, ee, wt, dt, ke, $e, xt, Ae, at, st, Be, Fe, bt, pe, Ee, we, je, Qt]);
1461
- })({ isInsideComponent: F, isInsideCanvas: W, isEditingText: L.mode === "textedition", settings: z, selectedShape: a, copiedShape: N, setCopiedShape: k, selectAllShapes: h, setSelectedShape: d, removeShape: u, pasteShapes: H, updateShapes: S, backwardShape: w, forwardShape: x, setShiftPressed: J, setAltPressed: O, setActiveTool: E, setSelectionMode: _, setSelectionFrame: c, setCanvasZoom: T, resetZoom: ne, setIsSpacePressed: ye }), (({ onResized: he, element: Se }) => {
1462
- le(() => {
1463
- const ae = Se.current;
1464
- if (!ae) return;
1465
- const fe = new ResizeObserver((ee) => {
1466
- const se = ee?.[0]?.borderBoxSize?.[0], { width: pe, height: ke } = se ? { width: se.inlineSize, height: se.blockSize } : ee?.[0]?.contentRect ?? {};
1467
- pe !== void 0 && ke !== void 0 && he(pe, ke);
1511
+ }, [te, we, le, ye, re, ie, wt, ct, Ve, $e, xt, Ae, ot, st, Fe, Ye, bt, fe, We, Ce, je, Qt]);
1512
+ })({ isInsideComponent: B, isInsideCanvas: F, isEditingText: C.mode === "textedition", settings: z, selectedShape: o, copiedShape: W, setCopiedShape: V, selectAllShapes: h, setSelectedShape: c, removeShape: m, pasteShapes: E, updateShapes: b, backwardShape: x, forwardShape: k, setShiftPressed: U, setAltPressed: R, setActiveTool: T, setSelectionMode: $, setSelectionFrame: d, setCanvasZoom: H, resetZoom: ae, setIsSpacePressed: me }), (({ onResized: te, element: we }) => {
1513
+ de(() => {
1514
+ const re = we.current;
1515
+ if (!re) return;
1516
+ const ye = new ResizeObserver((ie) => {
1517
+ const le = ie?.[0]?.borderBoxSize?.[0], { width: fe, height: Ve } = le ? { width: le.inlineSize, height: le.blockSize } : ie?.[0]?.contentRect ?? {};
1518
+ fe !== void 0 && Ve !== void 0 && te(fe, Ve);
1468
1519
  });
1469
- return fe.observe(ae), () => {
1470
- fe.unobserve(ae);
1520
+ return ye.observe(re), () => {
1521
+ ye.unobserve(re);
1471
1522
  };
1472
- }, [Se, he]);
1473
- })({ element: Oe, onResized: Ye }), v("div", { ref: Oe, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": $, "data-shrink": j, style: { "--react-paint-app-row-width": z.canvasSize.width, "--react-paint-app-canvaswidth": g, "--react-paint-app-canvasheight": P, "--react-paint-app-row-aspectratio": `calc(${z.canvasSize.width} / ${z.canvasSize.height})`, "--react-paint-app-canvas-bg": Y, ...i }, children: v(Oa, { duplicateShapes: m, isSpacePressed: V, withContextMenu: R, ref: y.canvas, canGrow: $, isInsideComponent: F, isInsideCanvas: W, activeTool: Z, setActiveTool: E, canvasOffsetStartData: ce, setCanvasOffsetStartData: Pe, shapes: o.current, addShapes: s, updateSingleShape: S, selectedShape: a, selectionFrame: r, setSelectedShape: d, setSelectionFrame: c, hoveredShape: l, refreshHoveredShape: p, refreshSelectedShapes: f, settings: z, setCanvasOffset: A, saveShapes: b, selectionMode: L, setSelectionMode: _, setCanvasMoveAcceleration: M, selectionColor: ze, selectionWidth: ge, isEditMode: I, isShiftPressed: C, isAltPressed: Q, withFrameSelection: te, withSkeleton: oe }) });
1474
- }, es = ({ isLoading: e = !1 }) => {
1475
- const [t, i] = K("hidden");
1476
- return le(() => {
1523
+ }, [we, te]);
1524
+ })({ element: Se, onResized: Ie }), v("div", { ref: Se, className: "react-paint-app-row" + (t ? ` ${t}` : ""), "data-grow": j, "data-shrink": ee, style: { "--react-paint-app-row-width": z.canvasSize.width, "--react-paint-app-canvaswidth": g, "--react-paint-app-canvasheight": P, "--react-paint-app-row-aspectratio": `calc(${z.canvasSize.width} / ${z.canvasSize.height})`, "--react-paint-app-canvas-bg": O, ...i }, children: v($o, { duplicateShapes: f, isSpacePressed: L, withContextMenu: I, ref: S.canvas, canGrow: j, isInsideComponent: B, isInsideCanvas: F, activeTool: A, setActiveTool: T, canvasOffsetStartData: se, setCanvasOffsetStartData: he, shapes: a.current, addShapes: s, updateSingleShape: b, selectedShape: o, selectionFrame: r, setSelectedShape: c, setSelectionFrame: d, hoveredShape: l, refreshHoveredShape: p, refreshSelectedShapes: u, settings: z, setCanvasOffset: D, saveShapes: M, selectionMode: C, setSelectionMode: $, setCanvasMoveAcceleration: Q, selectionColor: ge, selectionWidth: ue, isEditMode: X, isShiftPressed: w, isAltPressed: y, withFrameSelection: ne, withSkeleton: Z }) });
1525
+ }, os = ({ isLoading: e = !1 }) => {
1526
+ const [t, i] = J("hidden");
1527
+ return de(() => {
1477
1528
  if (!e) {
1478
1529
  i("fadeOut");
1479
1530
  const n = setTimeout(() => i("hidden"), 300);
@@ -1482,40 +1533,40 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
1482
1533
  };
1483
1534
  }
1484
1535
  i("visible");
1485
- }, [e]), t === "hidden" ? null : v("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": jo, "--react-paint-editor-loading-transition-duration": "300ms" }, children: G("div", { className: "react-paint-editor-loader", children: [v("div", {}), v("div", {}), v("div", {}), v("div", {})] }) });
1486
- }, ts = "infos", is = 4e3, ns = ({ type: e, text: t, duration: i }) => {
1487
- const [n, o] = K(!1);
1488
- return le(() => {
1489
- const a = setTimeout(() => {
1490
- o(!0);
1536
+ }, [e]), t === "hidden" ? null : v("div", { className: "react-paint-editor-loading", "data-loading": t, style: { "--react-paint-editor-loading-zindex": ao, "--react-paint-editor-loading-transition-duration": "300ms" }, children: K("div", { className: "react-paint-editor-loader", children: [v("div", {}), v("div", {}), v("div", {}), v("div", {})] }) });
1537
+ }, ss = "infos", rs = 4e3, ls = ({ type: e, text: t, duration: i }) => {
1538
+ const [n, a] = J(!1);
1539
+ return de(() => {
1540
+ const o = setTimeout(() => {
1541
+ a(!0);
1491
1542
  }, 100), r = setTimeout(() => {
1492
- o(!1);
1543
+ a(!1);
1493
1544
  }, i - 500 - 100);
1494
1545
  return () => {
1495
- clearTimeout(a), clearTimeout(r);
1546
+ clearTimeout(o), clearTimeout(r);
1496
1547
  };
1497
1548
  }, [i]), v("div", { className: "react-paint-editor-snackbar", "data-is-shown": +n, "data-type": e, style: { "--react-paint-editor-panel-transition-duration": "500ms" }, children: t });
1498
- }, os = ({ snackbarList: e }) => v("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": Ko }, children: e.map((t) => v(ns, { ...t }, t.id)) }), as = ki.forwardRef((e, t) => {
1499
- const { hidden: i = !1, disabled: n = !1, selected: o = !1, icon: a, children: r, className: l = "", title: s, onClick: d, ...h } = e, c = n ? -1 : 0, f = re(null);
1500
- return Yn(t, () => f.current), G("label", { className: `react-paint-editor-button ${l}`, title: s, onClick: d, "data-disabled": +n, "data-selected": +o, "data-hidden": +i, tabIndex: c, onKeyDown: (p) => {
1549
+ }, cs = ({ snackbarList: e }) => v("div", { className: "react-paint-editor-snackbar-container", style: { "--react-paint-editor-snackbar-zindex": oo }, children: e.map((t) => v(ls, { ...t }, t.id)) }), ds = Pi.forwardRef((e, t) => {
1550
+ const { hidden: i = !1, disabled: n = !1, selected: a = !1, icon: o, children: r, className: l = "", title: s, onClick: c, ...h } = e, d = n ? -1 : 0, u = ce(null);
1551
+ return Xn(t, () => u.current), K("label", { className: `react-paint-editor-button ${l}`, title: s, onClick: c, "data-disabled": +n, "data-selected": +a, "data-hidden": +i, tabIndex: d, onKeyDown: (p) => {
1501
1552
  p.key === jt && (p.preventDefault(), p.stopPropagation());
1502
1553
  }, onKeyUp: (p) => {
1503
- p.preventDefault(), p.stopPropagation(), p.key === jt && f.current?.click();
1504
- }, children: [v("input", { ref: f, disabled: n, ...h }), G("span", { className: "react-paint-editor-button-content", children: [r && v("span", { className: "react-paint-editor-button-children", children: r }), a && v("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: a } })] })] });
1505
- }), q = ki.forwardRef((e, t) => {
1506
- if (e.type === "file" || e.type === "color") return v(as, { ...e, ref: t });
1507
- const { hidden: i = !1, disabled: n = !1, selected: o = !1, icon: a, children: r, type: l = "button", className: s = "", ...d } = e;
1508
- return v("button", { className: `react-paint-editor-button ${s}`, ref: t, disabled: n, "data-disabled": +n, "data-selected": +o, "data-hidden": +i, type: l, ...d, children: G("span", { className: "react-paint-editor-button-content", children: [r && v("span", { className: "react-paint-editor-button-children", children: r }), a && v("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: a } })] }) });
1509
- }), yt = ({ children: e, title: t = "", className: i = "", position: n, fitContainer: o = !1, alignment: a, style: r, ...l }) => G("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": o, "data-position": n ?? "unset", "data-alignment": a ?? "unset", style: { ...r, "--react-paint-editor-panel-zindex": Kn }, ...l, children: [t && v("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), ss = (e) => {
1554
+ p.preventDefault(), p.stopPropagation(), p.key === jt && u.current?.click();
1555
+ }, children: [v("input", { ref: u, disabled: n, ...h }), K("span", { className: "react-paint-editor-button-content", children: [r && v("span", { className: "react-paint-editor-button-children", children: r }), o && v("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] })] });
1556
+ }), q = Pi.forwardRef((e, t) => {
1557
+ if (e.type === "file" || e.type === "color") return v(ds, { ...e, ref: t });
1558
+ const { hidden: i = !1, disabled: n = !1, selected: a = !1, icon: o, children: r, type: l = "button", className: s = "", ...c } = e;
1559
+ return v("button", { className: `react-paint-editor-button ${s}`, ref: t, disabled: n, "data-disabled": +n, "data-selected": +a, "data-hidden": +i, type: l, ...c, children: K("span", { className: "react-paint-editor-button-content", children: [r && v("span", { className: "react-paint-editor-button-children", children: r }), o && v("span", { className: "react-paint-editor-button-icon", dangerouslySetInnerHTML: { __html: o } })] }) });
1560
+ }), St = ({ children: e, title: t = "", className: i = "", position: n, fitContainer: a = !1, alignment: o, style: r, ...l }) => K("div", { className: `react-paint-editor-panel ${i}`, "data-fitcontainer": a, "data-position": n ?? "unset", "data-alignment": o ?? "unset", style: { ...r, "--react-paint-editor-panel-zindex": Jn }, ...l, children: [t && v("h3", { className: "react-paint-editor-panel-title", children: t }), e] }), hs = (e) => {
1510
1561
  switch (e) {
1511
1562
  case "brush":
1512
- return $n;
1563
+ return Un;
1513
1564
  case "line":
1514
- return Gn;
1565
+ return _n;
1515
1566
  case "polygon":
1516
1567
  return Zi;
1517
1568
  case "curve":
1518
- return _n;
1569
+ return jn;
1519
1570
  case "rect":
1520
1571
  case "square":
1521
1572
  return Li;
@@ -1523,149 +1574,149 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
1523
1574
  case "ellipse":
1524
1575
  return Vi;
1525
1576
  case "text":
1526
- return qn;
1577
+ return Gn;
1527
1578
  case "picture":
1528
- return zi;
1579
+ return Hi;
1529
1580
  case "group":
1530
1581
  return '<svg><path d="M3.333 17.5V16.667H7.5V17.5ZM3.333 14.167V13.333H9.167V14.167ZM3.333 10.833V10H10.833V10.833ZM3.333 7.5V6.667H12.5V7.5ZM3.333 4.167V3.333H13.333V4.167ZM3.333 0.833V0H16.667V0.833Z"/></svg>';
1531
1582
  case "triangle":
1532
1583
  return "";
1533
1584
  }
1534
- }, rs = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: n, toggleShapeVisibility: o, toggleShapeLock: a, setLayoutDragging: r, handleRemove: l, handleSelect: s, onSwapShapes: d }) => {
1535
- const h = re(null), { isOver: c } = (({ disabled: f = !1, ref: p, shape: m, layoutDragging: u, setLayoutDragging: S, handleSelect: w, onSwapShapes: x }) => {
1536
- const [b, y] = K(!1);
1537
- return le(() => {
1538
- u || y(!1);
1539
- }, [u]), le(() => {
1585
+ }, us = ({ disabled: e = !1, shape: t, selected: i, layoutDragging: n, toggleShapeVisibility: a, toggleShapeLock: o, setLayoutDragging: r, handleRemove: l, handleSelect: s, onSwapShapes: c }) => {
1586
+ const h = ce(null), { isOver: d } = (({ disabled: u = !1, ref: p, shape: f, layoutDragging: m, setLayoutDragging: b, handleSelect: x, onSwapShapes: k }) => {
1587
+ const [M, S] = J(!1);
1588
+ return de(() => {
1589
+ m || S(!1);
1590
+ }, [m]), de(() => {
1540
1591
  const g = p.current;
1541
1592
  if (!g) return;
1542
1593
  const P = () => {
1543
- S(void 0);
1544
- }, z = (E) => (E.preventDefault && E.preventDefault(), !1), D = (E) => {
1545
- w([m]), E.dataTransfer && (E.dataTransfer.effectAllowed = "move", E.dataTransfer.setData("draggableShapeId", m.id), S(m.id));
1546
- }, A = () => {
1547
- u !== m.id && y(!0);
1548
- }, H = () => {
1549
- y(!1);
1550
- }, Z = (E) => (E.stopPropagation(), E.dataTransfer && x(E.dataTransfer.getData("draggableShapeId"), m.id), !1);
1551
- return f || (g.addEventListener("dragstart", D), g.addEventListener("dragend", P), g.addEventListener("dragover", z), g.addEventListener("dragenter", A), g.addEventListener("dragleave", H), g.addEventListener("drop", Z)), () => {
1552
- f || (g.removeEventListener("dragstart", D), g.removeEventListener("dragend", P), g.removeEventListener("dragover", z), g.removeEventListener("dragenter", A), g.removeEventListener("dragleave", H), g.removeEventListener("drop", Z));
1594
+ b(void 0);
1595
+ }, z = (T) => (T.preventDefault && T.preventDefault(), !1), N = (T) => {
1596
+ x([f]), T.dataTransfer && (T.dataTransfer.effectAllowed = "move", T.dataTransfer.setData("draggableShapeId", f.id), b(f.id));
1597
+ }, D = () => {
1598
+ m !== f.id && S(!0);
1599
+ }, E = () => {
1600
+ S(!1);
1601
+ }, A = (T) => (T.stopPropagation(), T.dataTransfer && k(T.dataTransfer.getData("draggableShapeId"), f.id), !1);
1602
+ return u || (g.addEventListener("dragstart", N), g.addEventListener("dragend", P), g.addEventListener("dragover", z), g.addEventListener("dragenter", D), g.addEventListener("dragleave", E), g.addEventListener("drop", A)), () => {
1603
+ u || (g.removeEventListener("dragstart", N), g.removeEventListener("dragend", P), g.removeEventListener("dragover", z), g.removeEventListener("dragenter", D), g.removeEventListener("dragleave", E), g.removeEventListener("drop", A));
1553
1604
  };
1554
- }, [f, p, m, S, w, x, u]), { isOver: b };
1555
- })({ disabled: e, ref: h, shape: t, layoutDragging: n, setLayoutDragging: r, handleSelect: s, onSwapShapes: d });
1556
- return G("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === t.id), "data-is-over": +c, onClick: (f) => {
1557
- e || (f.preventDefault(), s([t]));
1558
- }, "data-selected": +i, ref: h, tabIndex: -1, children: [v("span", { dangerouslySetInnerHTML: { __html: ss(t.type) } }), v("span", { children: t.id }), v("div", { className: "react-paint-editor-layouts-separator" }), v(q, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (f) => {
1559
- e || (f.preventDefault(), f.stopPropagation(), o([t]));
1560
- }, 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>' }), v(q, { className: "react-paint-editor-layouts-locked-button", title: t.locked ? "Locked" : "Unlocked", "data-locked": !!t.locked, disabled: e, selected: i, onClick: (f) => {
1561
- e || (f.preventDefault(), f.stopPropagation(), a([t]));
1562
- }, 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>' }), v(q, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (f) => {
1563
- e || (f.preventDefault(), f.stopPropagation(), l([t]));
1564
- }, icon: Un })] });
1565
- }, ls = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: n, removeShape: o, toggleShapeVisibility: a, toggleShapeLock: r, selectedShapes: l, swapShapes: s, selectShapes: d, isLayoutPanelShown: h }) => {
1566
- const [c, f] = K(void 0), p = !i.features.edition;
1567
- return h ? v(yt, { alignment: "right", className: "react-paint-editor-layouts-panel", position: "bottom", children: v("div", { className: "react-paint-editor-layouts-panel-content", children: G("div", { className: "react-paint-editor-layouts-scrolling-content", children: [G("div", { className: "react-paint-editor-layouts-row", children: [v("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), v(q, { 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: p, onClick: () => t("none") }), ["small", "medium", "large"].map((m) => v(q, { className: "react-paint-editor-layouts-grid-button", selected: e === m, disabled: p, onClick: () => t(m), children: m.charAt(0).toUpperCase() }, m))] }), v("hr", {}), v("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? v("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((m) => v(rs, { shape: m, disabled: p, layoutDragging: c, setLayoutDragging: f, selected: U(l).some((u) => u.id === m.id) ?? !1, handleSelect: d, handleRemove: o, onSwapShapes: s, toggleShapeVisibility: a, toggleShapeLock: r }, m.id)) })] }) }) }) : null;
1568
- }, si = ({ children: e, onClose: t, position: i = "center", title: n, className: o = "" }) => G("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": Kn }, role: "dialog", "aria-modal": "true", "aria-labelledby": n, children: [v("div", { className: "react-paint-editor-modal-mask", onClick: t }), v("div", { className: `react-paint-editor-modal-panel ${o}`, children: e })] }), Yt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: n = "fill", disabled: o = !1, values: a, field: r, value: l = "", valueChanged: s }) => {
1569
- const [d] = K(Ce("settings_")), h = e === d;
1570
- return a.length ? G(Ne, { children: [v(q, { selected: h, title: i, disabled: o, onClick: () => {
1571
- t((c) => c === d ? void 0 : d);
1572
- }, icon: l === "transparent" ? n === "fill" ? en : Ji : void 0, children: l !== "transparent" && v("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": l } }) }), h && v(yt, { title: i, alignment: "left", position: "bottom", children: G("div", { className: "react-paint-editor-colorfield-wrapper", children: [a.map((c) => v(q, { title: c, selected: c === l, color: c, icon: c === "transparent" ? n === "fill" ? en : Ji : void 0, onClick: () => {
1573
- s(r, c);
1574
- }, children: c !== "transparent" && v("div", { className: "react-paint-editor-colorfield-color", color: c, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": c } }) }, c)), v(q, { type: "color", title: "Custom color", selected: l !== "" && !a.includes(l), value: l, onChange: (c) => {
1575
- const f = +c.target.value;
1576
- s(r, Number.isNaN(f) ? c.target.value : f);
1577
- }, children: v("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": a.includes(l) ? "var(--react-paint-editor-app-font-color)" : l }, children: v("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;
1578
- }, ds = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => v(q, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1579
- i(U(t));
1580
- }, icon: Un }), ri = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: n = "Choisissez l'option", disabled: o = !1, field: a, icon: r, values: l, defaultValue: s, valueChanged: d }) => {
1581
- const [h] = K(Ce("settings_")), c = t === h;
1582
- return l.length ? G(Ne, { children: [v(q, { selected: c, title: n, icon: r, disabled: o, onClick: () => {
1583
- i((f) => f === h ? void 0 : h);
1584
- } }), c && v(yt, { title: n, alignment: "left", fitContainer: !0, position: "bottom", children: v("div", { className: "react-paint-editor-selectfield-wrapper", children: l.map((f) => v(q, { title: `${f}`, onClick: () => ((p) => {
1585
- d(a, p);
1586
- })(f), selected: s === f, style: { "--react-paint-editor-button-padding": "16px" }, children: v(e, { children: f }) }, f)) }) })] }) : null;
1587
- }, cs = ({ children: e }) => v("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), In = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: o, valueChanged: a }) => n.length ? v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: cs, 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: o, valueChanged: a }) : null, hs = ({ disabled: e, toggleLayoutPanel: t }) => v(q, { 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" }), ps = ({ children: e }) => G("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [v("span", { className: "react-paint-editor-linearrow-left" }), v("span", { className: "react-paint-editor-linearrow-right" })] }), Rn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: o, valueChanged: a }) => n.length ? v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: ps, 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: o, valueChanged: a }) : null, us = ({ children: e }) => G("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {})] }), Wn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: o, valueChanged: a }) => n.length ? v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: us, 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: o, valueChanged: a }) : null, Xt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: n, disabled: o = !1, field: a, value: r, min: l = 1, max: s = 20, step: d = 1, unity: h = "", valueChanged: c, saveShapes: f }) => {
1588
- const p = r === void 0, m = p ? "N/A" : `${Math.round(r)}${h}`, [u] = K(Ce("settings_")), S = ((x, b = 500) => {
1589
- const y = re(null), g = X((...P) => {
1590
- y.current && clearTimeout(y.current), y.current = setTimeout(() => x(...P), b);
1591
- }, [x, b]);
1592
- return le(() => () => {
1593
- y.current && clearTimeout(y.current);
1605
+ }, [u, p, f, b, x, k, m]), { isOver: M };
1606
+ })({ disabled: e, ref: h, shape: t, layoutDragging: n, setLayoutDragging: r, handleSelect: s, onSwapShapes: c });
1607
+ return K("div", { className: "react-paint-editor-layout", "data-disabled": +e, draggable: !e, "data-is-dragging": +(n === t.id), "data-is-over": +d, onClick: (u) => {
1608
+ e || (u.preventDefault(), s([t]));
1609
+ }, "data-selected": +i, ref: h, tabIndex: -1, children: [v("span", { dangerouslySetInnerHTML: { __html: hs(t.type) } }), v("span", { children: t.id }), v("div", { className: "react-paint-editor-layouts-separator" }), v(q, { className: "react-paint-editor-layouts-visible-button", title: t.visible ? "Hide" : "Show", "data-visible": t.visible !== !1, disabled: e, selected: i, onClick: (u) => {
1610
+ e || (u.preventDefault(), u.stopPropagation(), a([t]));
1611
+ }, 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>' }), v(q, { className: "react-paint-editor-layouts-locked-button", title: t.locked ? "Locked" : "Unlocked", "data-locked": !!t.locked, disabled: e, selected: i, onClick: (u) => {
1612
+ e || (u.preventDefault(), u.stopPropagation(), o([t]));
1613
+ }, 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>' }), v(q, { className: "react-paint-editor-layouts-remove-button", title: "Remove", disabled: e, onClick: (u) => {
1614
+ e || (u.preventDefault(), u.stopPropagation(), l([t]));
1615
+ }, icon: qn })] });
1616
+ }, ps = ({ gridFormat: e, setGridFormat: t, settings: i, shapes: n, removeShape: a, toggleShapeVisibility: o, toggleShapeLock: r, selectedShapes: l, swapShapes: s, selectShapes: c, isLayoutPanelShown: h }) => {
1617
+ const [d, u] = J(void 0), p = !i.features.edition;
1618
+ return h ? v(St, { alignment: "right", className: "react-paint-editor-layouts-panel", position: "bottom", children: v("div", { className: "react-paint-editor-layouts-panel-content", children: K("div", { className: "react-paint-editor-layouts-scrolling-content", children: [K("div", { className: "react-paint-editor-layouts-row", children: [v("span", { className: "react-paint-editor-layouts-subtitle", children: "Grid" }), v(q, { 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: p, onClick: () => t("none") }), ["small", "medium", "large"].map((f) => v(q, { className: "react-paint-editor-layouts-grid-button", selected: e === f, disabled: p, onClick: () => t(f), children: f.charAt(0).toUpperCase() }, f))] }), v("hr", {}), v("div", { className: "react-paint-editor-layouts", children: n.length === 0 ? v("div", { className: "react-paint-editor-layouts-placeholder", children: "No layer yet" }) : n.map((f) => v(us, { shape: f, disabled: p, layoutDragging: d, setLayoutDragging: u, selected: _(l).some((m) => m.id === f.id) ?? !1, handleSelect: c, handleRemove: a, onSwapShapes: s, toggleShapeVisibility: o, toggleShapeLock: r }, f.id)) })] }) }) }) : null;
1619
+ }, si = ({ children: e, onClose: t, position: i = "center", title: n, className: a = "" }) => K("div", { className: "react-paint-editor-modal", "data-position": i, style: { "--react-paint-editor-modal-zindex": Jn }, role: "dialog", "aria-modal": "true", "aria-labelledby": n, children: [v("div", { className: "react-paint-editor-modal-mask", onClick: t }), v("div", { className: `react-paint-editor-modal-panel ${a}`, children: e })] }), Yt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez une couleur", mode: n = "fill", disabled: a = !1, values: o, field: r, value: l = "", valueChanged: s }) => {
1620
+ const [c] = J(Le("settings_")), h = e === c;
1621
+ return o.length ? K(Oe, { children: [v(q, { selected: h, title: i, disabled: a, onClick: () => {
1622
+ t((d) => d === c ? void 0 : c);
1623
+ }, icon: l === "transparent" ? n === "fill" ? en : Ji : void 0, children: l !== "transparent" && v("div", { className: "react-paint-editor-colorfield-color", "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": l } }) }), h && v(St, { title: i, alignment: "left", position: "bottom", children: K("div", { className: "react-paint-editor-colorfield-wrapper", children: [o.map((d) => v(q, { title: d, selected: d === l, color: d, icon: d === "transparent" ? n === "fill" ? en : Ji : void 0, onClick: () => {
1624
+ s(r, d);
1625
+ }, children: d !== "transparent" && v("div", { className: "react-paint-editor-colorfield-color", color: d, "data-mode": n, style: { "--react-paint-editor-colorfield-color-value": d } }) }, d)), v(q, { type: "color", title: "Custom color", selected: l !== "" && !o.includes(l), value: l, onChange: (d) => {
1626
+ const u = +d.target.value;
1627
+ s(r, Number.isNaN(u) ? d.target.value : u);
1628
+ }, children: v("div", { className: "react-paint-editor-colorfield-customcolor", style: { "--react-paint-editor-colorfield-color-value": o.includes(l) ? "var(--react-paint-editor-app-font-color)" : l }, children: v("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;
1629
+ }, gs = ({ disabled: e = !1, selectedShape: t, removeShape: i }) => v(q, { title: "Delete", disabled: e, "data-disabled": +e, onClick: () => {
1630
+ i(_(t));
1631
+ }, icon: qn }), ri = ({ CustomOption: e, selectedSettings: t, setSelectedSettings: i, title: n = "Choisissez l'option", disabled: a = !1, field: o, icon: r, values: l, defaultValue: s, valueChanged: c }) => {
1632
+ const [h] = J(Le("settings_")), d = t === h;
1633
+ return l.length ? K(Oe, { children: [v(q, { selected: d, title: n, icon: r, disabled: a, onClick: () => {
1634
+ i((u) => u === h ? void 0 : h);
1635
+ } }), d && v(St, { title: n, alignment: "left", fitContainer: !0, position: "bottom", children: v("div", { className: "react-paint-editor-selectfield-wrapper", children: l.map((u) => v(q, { title: `${u}`, onClick: () => ((p) => {
1636
+ c(o, p);
1637
+ })(u), selected: s === u, style: { "--react-paint-editor-button-padding": "16px" }, children: v(e, { children: u }) }, u)) }) })] }) : null;
1638
+ }, fs = ({ children: e }) => v("span", { className: "react-paint-editor-fontfamily-option", style: { "--react-paint-editor-fontfamily-family": e }, children: e }), Wn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: fs, 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: a, valueChanged: o }) : null, vs = ({ disabled: e, toggleLayoutPanel: t }) => v(q, { 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" }), ms = ({ children: e }) => K("span", { className: "react-paint-editor-linearrow-option", "data-type": e, children: [v("span", { className: "react-paint-editor-linearrow-left" }), v("span", { className: "react-paint-editor-linearrow-right" })] }), Rn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: ms, 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: a, valueChanged: o }) : null, ys = ({ children: e }) => K("span", { className: "react-paint-editor-linetype-option", "data-type": e, children: [v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {}), v("span", {})] }), Nn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, values: n, defaultValue: a, valueChanged: o }) => n.length ? v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: ys, 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: a, valueChanged: o }) : null, Xt = ({ selectedSettings: e, setSelectedSettings: t, title: i = "Choisissez l'intervalle", icon: n, disabled: a = !1, field: o, value: r, min: l = 1, max: s = 20, step: c = 1, unity: h = "", valueChanged: d, saveShapes: u }) => {
1639
+ const p = r === void 0, f = p ? "N/A" : `${Math.round(r)}${h}`, [m] = J(Le("settings_")), b = ((k, M = 500) => {
1640
+ const S = ce(null), g = G((...P) => {
1641
+ S.current && clearTimeout(S.current), S.current = setTimeout(() => k(...P), M);
1642
+ }, [k, M]);
1643
+ return de(() => () => {
1644
+ S.current && clearTimeout(S.current);
1594
1645
  }, []), g;
1595
- })(f), w = e === u;
1596
- return l === s ? null : G(Ne, { children: [v(q, { selected: w, title: i, disabled: o, icon: n, onClick: () => {
1597
- t((x) => x === u ? void 0 : u);
1598
- } }), w && v(yt, { title: i, alignment: "left", fitContainer: !0, position: "bottom", children: v("div", { children: G("label", { className: "react-paint-editor-rangefield", children: [v("input", { type: "range", min: l, max: s, step: d, value: r ?? (s + l) / 2, "data-indeterminate": +p, onChange: (x) => {
1599
- const b = +x.target.value, y = Number.isNaN(b) ? x.target.value : b;
1600
- c(a, y, !1), S();
1601
- } }), v("span", { children: m })] }) }) })] });
1602
- }, gs = ({ children: e }) => v("span", { children: e === 0 ? "Non" : "Oui" }), fs = [0, 1], Nn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: n, valueChanged: o }) => v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: gs, title: "Fermer les points", icon: Zi, disabled: i, field: "closedPoints", values: fs, defaultValue: n, valueChanged: o }), vs = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => v(q, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: jn, className: t ? ` ${t}` : "" }), $t = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: n, values: o, value: a = !1, valueChanged: r }) => {
1603
- const [l] = K(Ce("settings_"));
1604
- return o.length !== 2 ? null : v(q, { onClick: () => {
1605
- e((s) => s === l ? void 0 : l), r(i, !a);
1606
- }, selected: a, disabled: t, icon: n });
1607
- }, Si = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: n, selectedSettings: o, setSelectedSettings: a, saveShapes: r, handleShapeStyleChange: l, handleShapeFontFamilyChange: s }) => t ? i && G(Ne, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && v(Yt, { selectedSettings: o, setSelectedSettings: a, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: t.style?.strokeColor, valueChanged: l, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && v(Yt, { selectedSettings: o, setSelectedSettings: a, title: "Couleur de fond", disabled: n, field: "fillColor", value: t.style?.fillColor, valueChanged: l, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && v(Xt, { saveShapes: r, selectedSettings: o, setSelectedSettings: a, title: "Epaisseur du trait", icon: Ki, disabled: n, field: "lineWidth", value: t.style?.lineWidth, valueChanged: l, 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 && v(Wn, { selectedSettings: o, setSelectedSettings: a, disabled: n, defaultValue: t.style?.lineDash, valueChanged: l, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && v(Rn, { selectedSettings: o, setSelectedSettings: a, disabled: n, defaultValue: t.style?.lineArrow, valueChanged: l, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && v(Nn, { selectedSettings: o, setSelectedSettings: a, disabled: n, valueChanged: l, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && v(In, { selectedSettings: o, setSelectedSettings: a, disabled: n, valueChanged: s, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && v($t, { setSelectedSettings: a, disabled: n, field: "fontBold", icon: _i, valueChanged: s, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && v($t, { setSelectedSettings: a, disabled: n, field: "fontItalic", icon: ji, valueChanged: s, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && v(Xt, { saveShapes: r, selectedSettings: o, setSelectedSettings: a, title: "Opacité", icon: qi, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: t.style?.opacity, valueChanged: l })] }) : "settings" in e ? G(Ne, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && v(Yt, { selectedSettings: o, setSelectedSettings: a, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: l, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && v(Yt, { selectedSettings: o, setSelectedSettings: a, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: l, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && v(Xt, { saveShapes: r, selectedSettings: o, setSelectedSettings: a, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: Ki, value: e.settings.lineWidth.default, valueChanged: l, 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 && v(Wn, { selectedSettings: o, setSelectedSettings: a, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: l, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && v(Rn, { selectedSettings: o, setSelectedSettings: a, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: l, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && v(Nn, { selectedSettings: o, setSelectedSettings: a, disabled: n, valueChanged: l, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && v(In, { selectedSettings: o, setSelectedSettings: a, disabled: n, valueChanged: s, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && v($t, { setSelectedSettings: a, disabled: n, field: "fontBold", icon: _i, valueChanged: s, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && v($t, { setSelectedSettings: a, disabled: n, field: "fontItalic", icon: ji, valueChanged: s, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && v(Xt, { saveShapes: r, selectedSettings: o, setSelectedSettings: a, title: "Opacité", icon: qi, 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: l })] }) : null, ms = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: n = !1, toggleLayoutPanel: o, activeTool: a, saveShapes: r, selectedShape: l, canvas: s, settings: d, updateShape: h, removeShape: c, isZoomPanelShown: f, setIsZoomPanelShown: p }) => {
1608
- const [m, u] = K(void 0), [S, w] = K(!1), x = d.size === "infinite" || d.features.zoom, b = !d.features.edition, y = () => {
1609
- w((H) => !H);
1610
- }, g = ((H, Z) => {
1611
- const E = U(H).map((W) => Z.find((I) => I.id === W?.toolId) || Z.find((I) => I.type === W?.type)).filter((W) => W !== void 0);
1612
- if (!E.length) return;
1613
- if (E.length === 1) return E[0];
1614
- const F = E.slice(1).reduce((W, I) => {
1615
- const oe = {};
1616
- for (const te in I.settings) {
1617
- if (W[te] === void 0 || I.settings[te]?.hidden || W[te]?.hidden) continue;
1618
- const R = W[te], $ = I.settings[te], j = {};
1619
- "min" in $ && "min" in R && $.min === R.min && "max" in $ && "max" in R && $.max === R.max && "step" in $ && "step" in R && $.step === R.step && (j.min = $.min, j.max = $.max, j.step = $.step), "values" in $ && "values" in R && $.values?.join(",") === R.values?.join(",") && (j.values = $.values), (Object.keys(j).length > 0 || te === "closedPoints") && (oe[te] = j);
1646
+ })(u), x = e === m;
1647
+ return l === s ? null : K(Oe, { children: [v(q, { selected: x, title: i, disabled: a, icon: n, onClick: () => {
1648
+ t((k) => k === m ? void 0 : m);
1649
+ } }), x && v(St, { title: i, alignment: "left", fitContainer: !0, position: "bottom", children: v("div", { children: K("label", { className: "react-paint-editor-rangefield", children: [v("input", { type: "range", min: l, max: s, step: c, value: r ?? (s + l) / 2, "data-indeterminate": +p, onChange: (k) => {
1650
+ const M = +k.target.value, S = Number.isNaN(M) ? k.target.value : M;
1651
+ d(o, S, !1), b();
1652
+ } }), v("span", { children: f })] }) }) })] });
1653
+ }, Ss = ({ children: e }) => v("span", { children: e === 0 ? "Non" : "Oui" }), bs = [0, 1], Bn = ({ selectedSettings: e, setSelectedSettings: t, disabled: i = !1, defaultValue: n, valueChanged: a }) => v(ri, { selectedSettings: e, setSelectedSettings: t, CustomOption: Ss, title: "Fermer les points", icon: Zi, disabled: i, field: "closedPoints", values: bs, defaultValue: n, valueChanged: a }), Qs = ({ disabled: e = !1, className: t, toggleZoomPanel: i }) => v(q, { title: "Toggle zoom panel", disabled: e, onClick: i, icon: Kn, className: t ? ` ${t}` : "" }), $t = ({ setSelectedSettings: e, disabled: t = !1, field: i, icon: n, values: a, value: o = !1, valueChanged: r }) => {
1654
+ const [l] = J(Le("settings_"));
1655
+ return a.length !== 2 ? null : v(q, { onClick: () => {
1656
+ e((s) => s === l ? void 0 : l), r(i, !o);
1657
+ }, selected: o, disabled: t, icon: n });
1658
+ }, yi = ({ activeTool: e, selectedShape: t, selectedShapeTool: i, disabled: n, selectedSettings: a, setSelectedSettings: o, saveShapes: r, handleShapeStyleChange: l, handleShapeFontFamilyChange: s }) => t ? i && K(Oe, { children: ["strokeColor" in i.settings && !i.settings.strokeColor.hidden && v(Yt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: t.style?.strokeColor, valueChanged: l, values: i.settings.strokeColor.values }), "fillColor" in i.settings && !i.settings.fillColor.hidden && v(Yt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur de fond", disabled: n, field: "fillColor", value: t.style?.fillColor, valueChanged: l, values: i.settings.fillColor.values }), "lineWidth" in i.settings && !i.settings.lineWidth.hidden && v(Xt, { saveShapes: r, selectedSettings: a, setSelectedSettings: o, title: "Epaisseur du trait", icon: Ki, disabled: n, field: "lineWidth", value: t.style?.lineWidth, valueChanged: l, 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 && v(Nn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: t.style?.lineDash, valueChanged: l, values: i.settings.lineDash.values }), "lineArrow" in i.settings && !i.settings.lineArrow.hidden && v(Rn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: t.style?.lineArrow, valueChanged: l, values: i.settings.lineArrow.values }), "closedPoints" in i.settings && !i.settings.closedPoints.hidden && v(Bn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: l, defaultValue: t.style?.closedPoints }), "fontFamily" in i.settings && !i.settings.fontFamily.hidden && v(Wn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: s, values: i.settings.fontFamily.values, defaultValue: t.style?.fontFamily }), "fontBold" in i.settings && !i.settings.fontBold.hidden && v($t, { setSelectedSettings: o, disabled: n, field: "fontBold", icon: _i, valueChanged: s, values: i.settings.fontBold.values, value: t.style?.fontBold }), "fontItalic" in i.settings && !i.settings.fontItalic.hidden && v($t, { setSelectedSettings: o, disabled: n, field: "fontItalic", icon: ji, valueChanged: s, values: i.settings.fontItalic.values, value: t.style?.fontItalic }), "opacity" in i.settings && !i.settings.opacity.hidden && v(Xt, { saveShapes: r, selectedSettings: a, setSelectedSettings: o, title: "Opacité", icon: qi, min: i.settings.opacity.min, max: i.settings.opacity.max, step: i.settings.opacity.step, unity: "%", disabled: n, field: "opacity", value: t.style?.opacity, valueChanged: l })] }) : "settings" in e ? K(Oe, { children: ["strokeColor" in e.settings && !e.settings.strokeColor.hidden && v(Yt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur du trait", mode: "stroke", disabled: n, field: "strokeColor", value: e.settings.strokeColor.default, valueChanged: l, values: e.settings.strokeColor.values }), "fillColor" in e.settings && !e.settings.fillColor.hidden && v(Yt, { selectedSettings: a, setSelectedSettings: o, title: "Couleur de fond", disabled: n, field: "fillColor", value: e.settings.fillColor.default, valueChanged: l, values: e.settings.fillColor.values }), "lineWidth" in e.settings && !e.settings.lineWidth.hidden && v(Xt, { saveShapes: r, selectedSettings: a, setSelectedSettings: o, title: "Epaisseur du trait", disabled: n, field: "lineWidth", icon: Ki, value: e.settings.lineWidth.default, valueChanged: l, 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 && v(Nn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: e.settings.lineDash.default, valueChanged: l, values: e.settings.lineDash.values }), "lineArrow" in e.settings && !e.settings.lineArrow.hidden && v(Rn, { selectedSettings: a, setSelectedSettings: o, disabled: n, defaultValue: e.settings.lineArrow.default, valueChanged: l, values: e.settings.lineArrow.values }), "closedPoints" in e.settings && !e.settings.closedPoints.hidden && v(Bn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: l, defaultValue: e.settings?.closedPoints.default }), "fontFamily" in e.settings && !e.settings.fontFamily.hidden && v(Wn, { selectedSettings: a, setSelectedSettings: o, disabled: n, valueChanged: s, values: e.settings.fontFamily.values, defaultValue: e.settings.fontFamily.default }), "fontBold" in e.settings && !e.settings.fontBold.hidden && v($t, { setSelectedSettings: o, disabled: n, field: "fontBold", icon: _i, valueChanged: s, values: e.settings.fontBold.values, value: e.settings.fontBold.default }), "fontItalic" in e.settings && !e.settings.fontItalic.hidden && v($t, { setSelectedSettings: o, disabled: n, field: "fontItalic", icon: ji, valueChanged: s, values: e.settings.fontItalic.values, value: e.settings.fontItalic.default }), "opacity" in e.settings && !e.settings.opacity.hidden && v(Xt, { saveShapes: r, selectedSettings: a, setSelectedSettings: o, title: "Opacité", icon: qi, 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: l })] }) : null, ws = ({ width: e, availableTools: t, updateToolSettings: i, layersManipulation: n = !1, toggleLayoutPanel: a, activeTool: o, saveShapes: r, selectedShape: l, canvas: s, settings: c, updateShape: h, removeShape: d, isZoomPanelShown: u, setIsZoomPanelShown: p }) => {
1659
+ const [f, m] = J(void 0), [b, x] = J(!1), k = c.size === "infinite" || c.features.zoom, M = !c.features.edition, S = () => {
1660
+ x((E) => !E);
1661
+ }, g = ((E, A) => {
1662
+ const T = _(E).map((F) => A.find((X) => X.id === F?.toolId) || A.find((X) => X.type === F?.type)).filter((F) => F !== void 0);
1663
+ if (!T.length) return;
1664
+ if (T.length === 1) return T[0];
1665
+ const B = T.slice(1).reduce((F, X) => {
1666
+ const Z = {};
1667
+ for (const ne in X.settings) {
1668
+ if (F[ne] === void 0 || X.settings[ne]?.hidden || F[ne]?.hidden) continue;
1669
+ const I = F[ne], j = X.settings[ne], ee = {};
1670
+ "min" in j && "min" in I && j.min === I.min && "max" in j && "max" in I && j.max === I.max && "step" in j && "step" in I && j.step === I.step && (ee.min = j.min, ee.max = j.max, ee.step = j.step), "values" in j && "values" in I && j.values?.join(",") === I.values?.join(",") && (ee.values = j.values), (Object.keys(ee).length > 0 || ne === "closedPoints") && (Z[ne] = ee);
1620
1671
  }
1621
- return oe;
1622
- }, E[0].settings);
1623
- return { id: E.map((W) => W.id).join("-"), icon: "", label: "group", type: "group", settings: F };
1624
- })(l, t), P = (g ? Object.keys(g.settings).length + 1 : "settings" in a ? Object.keys(a.settings).length : 0) + +n + +x, z = e < 40 * P, D = (H, Z, E = !0) => {
1625
- if (U(l).length) {
1626
- const F = U(l).map((W) => _e(Xe(["style", H], Z, W), d));
1627
- h(F, E), g && i(g.id, H, Z);
1628
- } else i(a.id, H, Z);
1629
- }, A = (H, Z) => {
1630
- if (U(l).length) {
1631
- const E = U(l).map((F) => {
1632
- if (F.type !== "text") return F;
1633
- const W = s?.getContext("2d");
1634
- if (!W) return F;
1635
- const I = Xe(["style", H], Z, F), oe = ai(W, I.value, I.width, I.style?.fontBold ?? !1, I.style?.fontItalic ?? !1, I.style?.fontFamily);
1636
- return _e({ ...I, fontSize: oe, height: oe * I.value.length }, d);
1672
+ return Z;
1673
+ }, T[0].settings);
1674
+ return { id: T.map((F) => F.id).join("-"), icon: "", label: "group", type: "group", settings: B };
1675
+ })(l, t), P = (g ? Object.keys(g.settings).length + 1 : "settings" in o ? Object.keys(o.settings).length : 0) + +n + +k, z = e < 40 * P, N = (E, A, T = !0) => {
1676
+ if (_(l).length) {
1677
+ const B = _(l).map((F) => _e(Xe(["style", E], A, F), c));
1678
+ h(B, T), g && i(g.id, E, A);
1679
+ } else i(o.id, E, A);
1680
+ }, D = (E, A) => {
1681
+ if (_(l).length) {
1682
+ const T = _(l).map((B) => {
1683
+ if (B.type !== "text") return B;
1684
+ const F = s?.getContext("2d");
1685
+ if (!F) return B;
1686
+ const X = Xe(["style", E], A, B), Z = oi(F, X.value, X.width, X.style?.fontBold ?? !1, X.style?.fontItalic ?? !1, X.style?.fontFamily);
1687
+ return _e({ ...X, fontSize: Z, height: Z * X.value.length }, c);
1637
1688
  });
1638
- h(E, !0), g && i(g.id, H, Z);
1639
- } else i(a.id, H, Z);
1689
+ h(T, !0), g && i(g.id, E, A);
1690
+ } else i(o.id, E, A);
1640
1691
  };
1641
- return G(Ne, { children: [G("div", { className: "react-paint-editor-settings-bar", children: [G("div", { className: "react-paint-editor-settings-shrinkable", children: [x && v(vs, { className: f ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1642
- p((H) => !H);
1643
- } }), z && P > 2 && v(q, { disabled: b, onClick: y, 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>' }), l ? g && G(Ne, { children: [!z && v(Si, { saveShapes: r, activeTool: a, selectedShape: l, selectedShapeTool: g, disabled: b, selectedSettings: m, setSelectedSettings: u, handleShapeStyleChange: D, handleShapeFontFamilyChange: A }), a.type === "selection" && v(ds, { disabled: b, selectedShape: l, removeShape: c })] }) : !z && v(Si, { saveShapes: r, activeTool: a, selectedShape: l, selectedShapeTool: g, disabled: b, selectedSettings: m, setSelectedSettings: u, handleShapeStyleChange: D, handleShapeFontFamilyChange: A })] }), v("div", { className: "react-paint-editor-settings-separator" }), n && v(hs, { disabled: b, toggleLayoutPanel: o })] }), S && v(si, { className: "react-paint-editor-settings-modal", onClose: y, position: "bottom", title: "Settings", children: v(Si, { saveShapes: r, activeTool: a, selectedShape: l, selectedShapeTool: g, disabled: b, selectedSettings: m, setSelectedSettings: u, handleShapeStyleChange: D, handleShapeFontFamilyChange: A }) })] });
1644
- }, qt = ({ alignment: e, children: t, className: i, style: n, position: o }) => v(yt, { alignment: e, position: o, className: i, style: n, children: v("div", { className: "react-paint-editor-menu", role: "menu", children: t }) }), On = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: n, img: o, accept: a }) => {
1645
- const r = re(null);
1692
+ return K(Oe, { children: [K("div", { className: "react-paint-editor-settings-bar", children: [K("div", { className: "react-paint-editor-settings-shrinkable", children: [k && v(Qs, { className: u ? "react-paint-editor-bar-zoom-button-opened" : void 0, toggleZoomPanel: () => {
1693
+ p((E) => !E);
1694
+ } }), z && P > 2 && v(q, { disabled: M, onClick: S, 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>' }), l ? g && K(Oe, { children: [!z && v(yi, { saveShapes: r, activeTool: o, selectedShape: l, selectedShapeTool: g, disabled: M, selectedSettings: f, setSelectedSettings: m, handleShapeStyleChange: N, handleShapeFontFamilyChange: D }), o.type === "selection" && v(gs, { disabled: M, selectedShape: l, removeShape: d })] }) : !z && v(yi, { saveShapes: r, activeTool: o, selectedShape: l, selectedShapeTool: g, disabled: M, selectedSettings: f, setSelectedSettings: m, handleShapeStyleChange: N, handleShapeFontFamilyChange: D })] }), v("div", { className: "react-paint-editor-settings-separator" }), n && v(vs, { disabled: M, toggleLayoutPanel: a })] }), b && v(si, { className: "react-paint-editor-settings-modal", onClose: S, position: "bottom", title: "Settings", children: v(yi, { saveShapes: r, activeTool: o, selectedShape: l, selectedShapeTool: g, disabled: M, selectedSettings: f, setSelectedSettings: m, handleShapeStyleChange: N, handleShapeFontFamilyChange: D }) })] });
1695
+ }, qt = ({ alignment: e, children: t, className: i, style: n, position: a }) => v(St, { alignment: e, position: a, className: i, style: n, children: v("div", { className: "react-paint-editor-menu", role: "menu", children: t }) }), On = ({ disabled: e = !1, withText: t = !1, loadFile: i, type: n, img: a, accept: o }) => {
1696
+ const r = ce(null);
1646
1697
  return v(q, { ref: r, type: "file", onClick: () => {
1647
1698
  r.current && (r.current.value = "");
1648
1699
  }, onChange: (l) => {
1649
1700
  const s = l.target.files?.item(0);
1650
1701
  s && i(s);
1651
- }, accept: a, title: n.label ?? n.type, icon: o, disabled: e, children: t ? n.label : void 0 });
1652
- }, Re = ({ type: e, img: t, isActive: i, withText: n = !1, disabled: o = !1, setActive: a }) => v(q, { disabled: o, selected: i, onClick: () => {
1653
- a(e);
1654
- }, title: e.label ?? e.type, icon: t, children: n ? e.label : void 0 }), No = (e, t) => !!(e.target instanceof Node && t) && t.contains(e.target), Pi = ({ trigger: e = "click", buttonElt: t }) => {
1655
- const [i, n] = K(!1), [, o] = Xn(), a = X(() => {
1656
- o(() => {
1702
+ }, accept: o, title: n.label ?? n.type, icon: a, disabled: e, children: t ? n.label : void 0 });
1703
+ }, Ne = ({ type: e, img: t, isActive: i, withText: n = !1, disabled: a = !1, setActive: o }) => v(q, { disabled: a, selected: i, onClick: () => {
1704
+ o(e);
1705
+ }, title: e.label ?? e.type, icon: t, children: n ? e.label : void 0 }), Ua = (e, t) => !!(e.target instanceof Node && t) && t.contains(e.target), ki = ({ trigger: e = "click", buttonElt: t }) => {
1706
+ const [i, n] = J(!1), [, a] = $n(), o = G(() => {
1707
+ a(() => {
1657
1708
  n(!1);
1658
1709
  });
1659
1710
  }, []);
1660
- return le(() => {
1711
+ return de(() => {
1661
1712
  if (!t) return;
1662
1713
  if (i) {
1663
- const l = (d) => {
1664
- No(d, t) || o(() => {
1714
+ const l = (c) => {
1715
+ Ua(c, t) || a(() => {
1665
1716
  n(!1);
1666
1717
  });
1667
1718
  }, s = () => {
1668
- o(() => {
1719
+ a(() => {
1669
1720
  n(!1);
1670
1721
  });
1671
1722
  };
@@ -1676,7 +1727,7 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
1676
1727
  });
1677
1728
  }
1678
1729
  const r = () => {
1679
- o(() => {
1730
+ a(() => {
1680
1731
  n(!0);
1681
1732
  });
1682
1733
  };
@@ -1685,94 +1736,92 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
1685
1736
  }) : (t.addEventListener("click", r), () => {
1686
1737
  t.removeEventListener("click", r);
1687
1738
  });
1688
- }, [t, i, e]), { isOpen: i, trigger: e, closeMenu: a };
1689
- }, Ss = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: n = !1, hasActionToClear: o = !1, undoAction: a, redoAction: r, clearCanvas: l, disabled: s = !1, withLoadAndSave: d, withExport: h, addPicture: c, loadFile: f, togglePictureUrlModal: p, saveFile: m, toggleExportModal: u, withUploadPicture: S, withUrlPicture: w }) => {
1690
- const x = re(null), { isOpen: b, closeMenu: y } = Pi({ buttonElt: x.current }), g = (P) => async (...z) => {
1691
- await P(...z), y();
1739
+ }, [t, i, e]), { isOpen: i, trigger: e, closeMenu: o };
1740
+ }, xs = ({ activeTool: e, withActionsInMenu: t, hasActionToUndo: i = !1, hasActionToRedo: n = !1, hasActionToClear: a = !1, undoAction: o, redoAction: r, clearCanvas: l, disabled: s = !1, withLoadAndSave: c, withExport: h, addPicture: d, loadFile: u, togglePictureUrlModal: p, saveFile: f, toggleExportModal: m, withUploadPicture: b, withUrlPicture: x }) => {
1741
+ const k = ce(null), { isOpen: M, closeMenu: S } = ki({ buttonElt: k.current }), g = (P) => async (...z) => {
1742
+ await P(...z), S();
1692
1743
  };
1693
- return t || S || w || d || h ? v("div", { className: "react-paint-editor-toolbox-relative", children: G("div", { ref: x, children: [v(q, { title: "Menu", disabled: s, icon: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }), b && G(qt, { alignment: "right", position: "top", children: [t && G(Ne, { children: [v(Re, { withText: !0, type: kt, disabled: s || !i, img: kt.icon, isActive: e.id === kt.id, setActive: g(a) }), v(Re, { withText: !0, type: Lt, disabled: s || !n, img: Lt.icon, isActive: e.id === Lt.id, setActive: g(r) }), v(Re, { withText: !0, type: Vt, disabled: s || !o, img: Vt.icon, isActive: e.id === Vt.id, setActive: g(l) }), (S || w || d) && v("hr", {})] }), S && v(On, { withText: !0, type: on, disabled: s, loadFile: g(c), img: on.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), w && v(q, { disabled: s, selected: !1, onClick: g(p), 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" }), (S || w) && d && v("hr", {}), d && G(Ne, { children: [v(On, { withText: !0, type: nn, disabled: s, loadFile: g(f), img: nn.icon, accept: "application/JSON" }), v(Re, { withText: !0, disabled: s, type: hi, img: hi.icon, isActive: e.id === hi.id, setActive: g(m) })] }), h && v(Re, { withText: !0, disabled: s, type: ci, img: ci.icon, isActive: e.id === ci.id, setActive: g(u) })] })] }) }) : null;
1694
- }, ys = ({ togglePictureUrlModal: e, addPicture: t }) => {
1695
- const i = re(null);
1696
- return le(() => {
1744
+ return t || b || x || c || h ? v("div", { className: "react-paint-editor-toolbox-relative", children: K("div", { ref: k, children: [v(q, { title: "Menu", disabled: s, icon: '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>' }), M && K(qt, { alignment: "right", position: "top", children: [t && K(Oe, { children: [v(Ne, { withText: !0, type: Pt, disabled: s || !i, img: Pt.icon, isActive: e.id === Pt.id, setActive: g(o) }), v(Ne, { withText: !0, type: Lt, disabled: s || !n, img: Lt.icon, isActive: e.id === Lt.id, setActive: g(r) }), v(Ne, { withText: !0, type: Vt, disabled: s || !a, img: Vt.icon, isActive: e.id === Vt.id, setActive: g(l) }), (b || x || c) && v("hr", {})] }), b && v(On, { withText: !0, type: an, disabled: s, loadFile: g(d), img: an.icon, accept: "image/png, image/gif, image/jpeg, image/svg+xml, image/webp" }), x && v(q, { disabled: s, selected: !1, onClick: g(p), 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 || x) && c && v("hr", {}), c && K(Oe, { children: [v(On, { withText: !0, type: nn, disabled: s, loadFile: g(u), img: nn.icon, accept: "application/JSON" }), v(Ne, { withText: !0, disabled: s, type: hi, img: hi.icon, isActive: e.id === hi.id, setActive: g(f) })] }), h && v(Ne, { withText: !0, disabled: s, type: di, img: di.icon, isActive: e.id === di.id, setActive: g(m) })] })] }) }) : null;
1745
+ }, Ms = ({ togglePictureUrlModal: e, addPicture: t }) => {
1746
+ const i = ce(null);
1747
+ return de(() => {
1697
1748
  i.current && i.current.focus();
1698
- }, []), v(si, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: G("form", { onSubmit: async (n) => {
1749
+ }, []), v(si, { className: "react-paint-editor-toolbox-pictureinput-modal", onClose: e, title: "Add picture from URL", children: K("form", { onSubmit: async (n) => {
1699
1750
  n.preventDefault();
1700
- const o = i.current?.value;
1701
- o && (await t(o), e());
1702
- }, children: [G("label", { children: ["URL ", v("input", { type: "text", ref: i })] }), v(q, { onClick: e, children: "Annuler" }), v(q, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1703
- }, Bn = "Choose export settings", bs = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1751
+ const a = i.current?.value;
1752
+ a && (await t(a), e());
1753
+ }, children: [K("label", { children: ["URL ", v("input", { type: "text", ref: i })] }), v(q, { onClick: e, children: "Annuler" }), v(q, { type: "submit", selected: !0, children: "Ajouter" })] }) });
1754
+ }, Fn = "Choose export settings", Cs = ({ toggleExportModal: e, exportCanvasInFile: t }) => {
1704
1755
  const i = async (n) => {
1705
1756
  t(n), e();
1706
1757
  };
1707
- return G(si, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: Bn, children: [v("h3", { children: Bn }), v("hr", {}), v(q, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), v(q, { onClick: () => i("defaultView"), children: "Exporter le canevas par défaut" }), v(q, { onClick: () => i("fitToShapes"), children: "Exporter le dessin entier" }), v(q, { selected: !0, onClick: e, children: "Annuler" })] });
1708
- }, Qs = ({ activeTool: e, group: t, disabled: i = !1, setActiveToolFromId: n }) => {
1709
- const o = re(null), [a, r] = K(!1), [, l] = Xn(), [s, d] = K(void 0), h = (p) => {
1710
- d(p), n(p.id);
1758
+ return K(si, { className: "react-paint-editor-toolbox-export-modal", onClose: e, title: Fn, children: [v("h3", { children: Fn }), v("hr", {}), v(q, { onClick: () => i("currentZoom"), children: "Exporter la vue actuelle" }), v(q, { onClick: () => i("defaultView"), children: "Exporter le canevas par défaut" }), v(q, { onClick: () => i("fitToShapes"), children: "Exporter le dessin entier" }), v(q, { selected: !0, onClick: e, children: "Annuler" })] });
1759
+ }, ks = ({ activeTool: e, group: t, disabled: i = !1, setActiveToolFromId: n }) => {
1760
+ const a = ce(null), [o, r] = J(!1), [, l] = $n(), [s, c] = J(void 0), h = (p) => {
1761
+ c(p), n(p.id);
1711
1762
  };
1712
- if (le(() => {
1713
- if (!a) return;
1714
- const p = (m) => {
1715
- !No(m, o.current) && r(!1);
1763
+ if (de(() => {
1764
+ if (!o) return;
1765
+ const p = (f) => {
1766
+ !Ua(f, a.current) && r(!1);
1716
1767
  };
1717
1768
  return document.addEventListener("mousedown", p, { passive: !1 }), document.addEventListener("touchstart", p, { passive: !1 }), () => {
1718
1769
  document.removeEventListener("mousedown", p), document.removeEventListener("touchstart", p);
1719
1770
  };
1720
- }, [a]), "type" in t) return v(Re, { disabled: i, type: t, img: t.icon, isActive: e.id === t.id, setActive: h });
1771
+ }, [o]), "type" in t) return v(Ne, { disabled: i, type: t, img: t.icon, isActive: e.id === t.id, setActive: h });
1721
1772
  if (!t.toolsType.length) return null;
1722
- if (t.toolsType?.length === 1) return v(Re, { disabled: i, type: t.toolsType[0], img: t.toolsType[0].icon, isActive: e.id === t.toolsType[0].id, setActive: h });
1723
- const c = t?.toolsType.find((p) => p.type === e.type) !== void 0, f = (s ? s.icon : t.toolsType?.[0]?.icon) ?? t.title;
1724
- return G("div", { className: "react-paint-editor-toolbargroup-relative", children: [v(q, { selected: c, title: t.title, disabled: i, onClick: () => {
1773
+ if (t.toolsType?.length === 1) return v(Ne, { disabled: i, type: t.toolsType[0], img: t.toolsType[0].icon, isActive: e.id === t.toolsType[0].id, setActive: h });
1774
+ const d = t?.toolsType.find((p) => p.type === e.type) !== void 0, u = (s ? s.icon : t.toolsType?.[0]?.icon) ?? t.title;
1775
+ return K("div", { className: "react-paint-editor-toolbargroup-relative", children: [v(q, { selected: d, title: t.title, disabled: i, onClick: () => {
1725
1776
  s ? n(s.id) : t.toolsType?.[0] && h(t.toolsType[0]), l(() => {
1726
1777
  r(!0);
1727
1778
  });
1728
- }, icon: f }), a && v(yt, { alignment: "center", position: "top", children: v("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +t.vertical, ref: o, children: t.toolsType.map((p) => v(Re, { disabled: i, type: p, img: p.icon, isActive: e.id === p.id, setActive: h }, p.id)) }) })] });
1729
- }, ws = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], xs = ({ settings: e, width: t, activeTool: i, hasActionToUndo: n = !1, hasActionToRedo: o = !1, hasActionToClear: a = !1, withLoadAndSave: r, withExport: l, clearCanvas: s, setActiveTool: d, undoAction: h, redoAction: c, addPicture: f, loadFile: p, saveFile: m, exportCanvasInFile: u, availableTools: S, withUrlPicture: w, withUploadPicture: x }) => {
1730
- const b = ((R, $) => {
1731
- const j = $.flatMap((ce) => {
1732
- if (typeof ce != "object") return R.filter((L) => L.type === ce);
1733
- const Pe = R.filter((L) => ce.toolsType.includes(L.type));
1734
- return Pe ? { ...ce, toolsType: Pe } : null;
1779
+ }, icon: u }), o && v(St, { alignment: "center", position: "top", children: v("div", { className: "react-paint-editor-toolbargroup-panel-content", "data-vertical": +t.vertical, ref: a, children: t.toolsType.map((p) => v(Ne, { disabled: i, type: p, img: p.icon, isActive: e.id === p.id, setActive: h }, p.id)) }) })] });
1780
+ }, Ps = [{ title: "brush", toolsType: ["brush"], vertical: !1 }, { title: "lines", toolsType: ["line", "curve", "polygon"], vertical: !1 }, { title: "shapes", toolsType: ["rect", "square", "circle", "ellipse"], vertical: !1 }, "text"], Ls = ({ settings: e, width: t, activeTool: i, hasActionToUndo: n = !1, hasActionToRedo: a = !1, hasActionToClear: o = !1, withLoadAndSave: r, withExport: l, clearCanvas: s, setActiveTool: c, undoAction: h, redoAction: d, addPicture: u, loadFile: p, saveFile: f, exportCanvasInFile: m, availableTools: b, withUrlPicture: x, withUploadPicture: k }) => {
1781
+ const M = ((I, j) => {
1782
+ const ee = j.flatMap((se) => {
1783
+ if (typeof se != "object") return I.filter((C) => C.type === se);
1784
+ const he = I.filter((C) => se.toolsType.includes(C.type));
1785
+ return he ? { ...se, toolsType: he } : null;
1735
1786
  });
1736
- return Ni(j);
1737
- })(S, ws), y = !e.features.edition, g = t < 40 * (6 + b.length), P = t < 40 * (3 + b.length), [z, D] = K(!1), [A, H] = K(!1), [Z, E] = K(!1), F = () => {
1738
- D((R) => !R);
1739
- }, W = () => {
1740
- E((R) => !R);
1741
- }, I = (R) => {
1742
- d(R), D(!1);
1743
- }, oe = (R) => {
1744
- I(S.find(($) => $.id === R) ?? i);
1745
- }, te = S.find((R) => R.type === i.type) !== void 0;
1746
- return G(Ne, { children: [G("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [G("div", { className: "react-paint-editor-toolbar-shrinkable", children: [v(Re, { type: Je, disabled: y, img: Je.icon, isActive: i.id === Je.id, setActive: I }), (e.size === "infinite" || e.features.zoom) && v(Re, { type: pi, disabled: y, img: pi.icon, isActive: i.id === pi.id, setActive: I }), P ? v(q, { disabled: y, onClick: F, 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: te }) : b.map((R) => v(Qs, { disabled: y, activeTool: i, group: R, setActiveToolFromId: oe }, "id" in R ? R.id : R.title))] }), !g && G(Ne, { children: [v(Re, { type: kt, disabled: y || !n, img: kt.icon, isActive: i.id === kt.id, setActive: h }), v(Re, { type: Lt, disabled: y || !o, img: Lt.icon, isActive: i.id === Lt.id, setActive: c }), v(Re, { type: Vt, disabled: y || !a, img: Vt.icon, isActive: i.id === Vt.id, setActive: s })] }), v(Ss, { withActionsInMenu: g, disabled: y, activeTool: i, addPicture: f, loadFile: p, saveFile: m, togglePictureUrlModal: () => {
1747
- H(!0);
1748
- }, toggleExportModal: W, withUploadPicture: x, withUrlPicture: w, withLoadAndSave: r, withExport: l, hasActionToUndo: n, hasActionToRedo: o, hasActionToClear: a, undoAction: h, redoAction: c, clearCanvas: s })] }), z && v(si, { className: "react-paint-editor-toolbar-modal", onClose: F, title: "Outils", children: S.map((R) => R.type === "picture" ? null : v(Re, { disabled: y, type: R, img: R.icon, withText: !1, isActive: i.id === R.id, setActive: I }, R.id)) }), A && v(ys, { togglePictureUrlModal: () => {
1749
- H((R) => !R);
1750
- }, addPicture: f }), Z && v(bs, { toggleExportModal: W, exportCanvasInFile: u })] });
1751
- }, Ut = { none: 0, small: 10, medium: 20, large: 40 }, Ms = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, Cs = () => {
1752
- const e = re([]), [t, i] = K([]);
1753
- return le(() => () => {
1787
+ return Ni(ee);
1788
+ })(b, Ps), S = !e.features.edition, g = t < 40 * (6 + M.length), P = t < 40 * (3 + M.length), [z, N] = J(!1), [D, E] = J(!1), [A, T] = J(!1), B = () => {
1789
+ N((I) => !I);
1790
+ }, F = () => {
1791
+ T((I) => !I);
1792
+ }, X = (I) => {
1793
+ c(I), N(!1);
1794
+ }, Z = (I) => {
1795
+ X(b.find((j) => j.id === I) ?? i);
1796
+ }, ne = b.find((I) => I.type === i.type) !== void 0;
1797
+ return K(Oe, { children: [K("div", { className: "react-paint-editor-toolbar-toolbox", style: { "--react-paint-editor-toolbar-minwidth": "160px" }, children: [K("div", { className: "react-paint-editor-toolbar-shrinkable", children: [v(Ne, { type: Je, disabled: S, img: Je.icon, isActive: i.id === Je.id, setActive: X }), (e.size === "infinite" || e.features.zoom) && v(Ne, { type: ui, disabled: S, img: ui.icon, isActive: i.id === ui.id, setActive: X }), P ? v(q, { disabled: S, onClick: B, 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: ne }) : M.map((I) => v(ks, { disabled: S, activeTool: i, group: I, setActiveToolFromId: Z }, "id" in I ? I.id : I.title))] }), !g && K(Oe, { children: [v(Ne, { type: Pt, disabled: S || !n, img: Pt.icon, isActive: i.id === Pt.id, setActive: h }), v(Ne, { type: Lt, disabled: S || !a, img: Lt.icon, isActive: i.id === Lt.id, setActive: d }), v(Ne, { type: Vt, disabled: S || !o, img: Vt.icon, isActive: i.id === Vt.id, setActive: s })] }), v(xs, { withActionsInMenu: g, disabled: S, activeTool: i, addPicture: u, loadFile: p, saveFile: f, togglePictureUrlModal: () => {
1798
+ E(!0);
1799
+ }, toggleExportModal: F, withUploadPicture: k, withUrlPicture: x, withLoadAndSave: r, withExport: l, hasActionToUndo: n, hasActionToRedo: a, hasActionToClear: o, undoAction: h, redoAction: d, clearCanvas: s })] }), z && v(si, { className: "react-paint-editor-toolbar-modal", onClose: B, title: "Outils", children: b.map((I) => I.type === "picture" ? null : v(Ne, { disabled: S, type: I, img: I.icon, withText: !1, isActive: i.id === I.id, setActive: X }, I.id)) }), D && v(Ms, { togglePictureUrlModal: () => {
1800
+ E((I) => !I);
1801
+ }, addPicture: u }), A && v(Cs, { toggleExportModal: F, exportCanvasInFile: m })] });
1802
+ }, Ut = { none: 0, small: 10, medium: 20, large: 40 }, Vs = { toolbarBackgroundColor: "white", dividerColor: "#36418129", fontRadius: 8, fontDisabledColor: "#3641812b", fontDisabledBackgroundColor: "transparent", fontColor: "#364181", fontBackgroundColor: "transparent", fontSelectedColor: "white", fontSelectedBackgroundColor: "#364181", fontHoverColor: "#364181", fontHoverBackgroundColor: "#afd8d8" }, Zs = () => {
1803
+ const e = ce([]), [t, i] = J([]);
1804
+ return de(() => () => {
1754
1805
  for (const n of e.current) clearTimeout(n);
1755
- }, []), { snackbarList: t, addSnackbar: ({ type: n = ts, duration: o = is, text: a }) => {
1756
- const r = { id: Ce("snackbar_"), duration: o, type: n, text: a };
1806
+ }, []), { snackbarList: t, addSnackbar: ({ type: n = ss, duration: a = rs, text: o }) => {
1807
+ const r = { id: Le("snackbar_"), duration: a, type: n, text: o };
1757
1808
  i((l) => [...l, r]), e.current = [...e.current, setTimeout(() => {
1758
- return l = r.id, void i((s) => s.filter((d) => d.id !== l));
1809
+ return l = r.id, void i((s) => s.filter((c) => c.id !== l));
1759
1810
  var l;
1760
- }, o)];
1811
+ }, a)];
1761
1812
  } };
1762
- }, Ps = ({ moveShapes: e, selectAllShapes: t, selectionMode: i, transformShape: n, settings: o, canvasRef: a, closeContextMenu: r, toggleShapeVisibility: l, toggleShapeLock: s, removeShape: d, duplicateShapes: h, copiedShape: c, setCopiedShape: f, pasteShapes: p, removeShapePoint: m }) => {
1763
- const u = re(null), S = re(null), { isOpen: w } = Pi({ trigger: "hover", buttonElt: u.current }), { isOpen: x } = Pi({ trigger: "hover", buttonElt: S.current }), { originalShape: b, cursorStartPosition: y, anchor: g } = i, P = U(b), z = P.length > 0, D = P.length === 1 && (P[0]?.type === "polygon" || P[0]?.type === "curve") && g !== void 0 && P[0]?.points?.length > 2, A = !P.some((I) => I.visible === !1);
1764
- P.some((I) => I.locked);
1765
- const H = 16 + 36 * (2 + (z ? 8 : 0) + (D ? 1 : 0)) + 16 * (z ? 3 : 1), [Z] = K(() => [(y[0] + o.canvasOffset[0]) * o.canvasSize.scaleRatio, 36 + (y[1] + o.canvasOffset[1]) * o.canvasSize.scaleRatio]), [E, F] = K();
1766
- le(() => {
1767
- const I = a?.current?.getBoundingClientRect();
1768
- if (!I) return;
1769
- const oe = I.left + Z[0], te = I.top + Z[1], R = Math.max(0, Math.min(oe, window.innerWidth - 176)) - I.left, $ = Math.max(0, Math.min(te, window.innerHeight - H)) - I.top, j = R > window.innerWidth - 176 - Math.min(R, 200) ? "left" : "right";
1770
- F({ x: R, y: $, subMenuPosition: j });
1771
- }, [a, Z, H]);
1772
- const W = E ? { "--react-paint-editor-toolbox-contextmenu-transform": `translate3D(${E.x}px, ${E.y}px, 0)` } : { display: "none" };
1773
- return G(qt, { className: "react-paint-editor-toolbox-contextmenu", style: W, children: [z && G(Ne, { children: [D && v(q, { onClick: () => {
1774
- D && m(P[0], g), r();
1775
- }, children: "Delete point" }), G("div", { className: "react-paint-editor-toolbox-contextmenu-group", ref: u, children: [v(q, { icon: Gi, children: "Organize" }), w && G(qt, { position: E?.subMenuPosition, children: [v(q, { onClick: () => {
1813
+ }, Hs = ({ moveShapes: e, selectAllShapes: t, selectionMode: i, transformShape: n, settings: a, canvasRef: o, closeContextMenu: r, toggleShapeVisibility: l, toggleShapeLock: s, removeShape: c, duplicateShapes: h, copiedShape: d, setCopiedShape: u, pasteShapes: p, removeShapePoint: f }) => {
1814
+ const m = ce(null), b = ce(null), { isOpen: x } = ki({ trigger: "hover", buttonElt: m.current }), { isOpen: k } = ki({ trigger: "hover", buttonElt: b.current }), { originalShape: M, cursorStartPosition: S, anchor: g } = i, P = _(M), z = P.length > 0, N = P.length === 1 && (P[0]?.type === "polygon" || P[0]?.type === "curve") && g !== void 0 && P[0]?.points?.length > 2, D = !P.some((Z) => Z.visible === !1), E = P.some((Z) => Z.locked), A = 16 + 36 * (2 + (z ? 8 : 0) + (N ? 1 : 0)) + 16 * (z ? 3 : 1), [T] = J(() => [(S[0] + a.canvasOffset[0]) * a.canvasSize.scaleRatio, 36 + (S[1] + a.canvasOffset[1]) * a.canvasSize.scaleRatio]), [B, F] = J();
1815
+ de(() => {
1816
+ const Z = o?.current?.getBoundingClientRect();
1817
+ if (!Z) return;
1818
+ const ne = Z.left + T[0], I = Z.top + T[1], j = Math.max(0, Math.min(ne, window.innerWidth - 176)) - Z.left, ee = Math.max(0, Math.min(I, window.innerHeight - A)) - Z.top, se = j > window.innerWidth - 176 - Math.min(j, 200) ? "left" : "right";
1819
+ F({ x: j, y: ee, subMenuPosition: se });
1820
+ }, [o, T, A]);
1821
+ const X = B ? { "--react-paint-editor-toolbox-contextmenu-transform": `translate3D(${B.x}px, ${B.y}px, 0)` } : { display: "none" };
1822
+ return K(qt, { className: "react-paint-editor-toolbox-contextmenu", style: X, children: [z && K(Oe, { children: [N && v(q, { onClick: () => {
1823
+ N && f(P[0], g), r();
1824
+ }, children: "Delete point" }), K("div", { className: "react-paint-editor-toolbox-contextmenu-group", ref: m, children: [v(q, { icon: Gi, children: "Organize" }), x && K(qt, { position: B?.subMenuPosition, children: [v(q, { onClick: () => {
1776
1825
  z && e(P, "forward"), r();
1777
1826
  }, children: "Move forward" }), v(q, { onClick: () => {
1778
1827
  z && e(P, "first"), r();
@@ -1780,76 +1829,86 @@ const pn = ({ ctx: e, path: t, rect: i, offset: n, center: o, rotation: a = 0, c
1780
1829
  z && e(P, "backward"), r();
1781
1830
  }, children: "Move backward" }), v(q, { onClick: () => {
1782
1831
  z && e(P, "last"), r();
1783
- }, children: "Put on last" })] })] }), G("div", { className: "react-paint-editor-toolbox-contextmenu-group", ref: S, children: [v(q, { icon: Gi, children: "Transform" }), x && G(qt, { position: E?.subMenuPosition, children: [v(q, { onClick: () => {
1784
- z && n(P, b.computed.center, "rotateClockwise"), r();
1832
+ }, children: "Put on last" })] })] }), K("div", { className: "react-paint-editor-toolbox-contextmenu-group", ref: b, children: [v(q, { icon: Gi, children: "Transform" }), k && K(qt, { position: B?.subMenuPosition, children: [v(q, { onClick: () => {
1833
+ const Z = o?.current?.getContext("2d");
1834
+ Z && z && n(Z, P, M.computed.center, "flipHorizontally"), r();
1835
+ }, children: "Flip horizontally" }), v(q, { onClick: () => {
1836
+ const Z = o?.current?.getContext("2d");
1837
+ Z && z && n(Z, P, M.computed.center, "flipVertically"), r();
1838
+ }, children: "Flip vertically" }), v(q, { onClick: () => {
1839
+ const Z = o?.current?.getContext("2d");
1840
+ Z && z && n(Z, P, M.computed.center, "rotateClockwise"), r();
1785
1841
  }, children: "Rotate clockwise" }), v(q, { onClick: () => {
1786
- z && n(P, b.computed.center, "rotateCounterclockwise"), r();
1842
+ const Z = o?.current?.getContext("2d");
1843
+ Z && z && n(Z, P, M.computed.center, "rotateCounterclockwise"), r();
1787
1844
  }, children: "Rotate counterclockwise" })] })] }), v("hr", {}), v(q, { onClick: () => {
1788
- z && (f(de(P, o)), d(P)), r();
1845
+ z && (u(pe(P, a)), c(P)), r();
1789
1846
  }, children: "Cut" }), v(q, { onClick: () => {
1790
- z && f(de(P, o)), r();
1847
+ z && u(pe(P, a)), r();
1791
1848
  }, children: "Copy" })] }), v(q, { onClick: () => {
1792
- c && p(Wi(c, o)), r();
1793
- }, disabled: !c, children: "Paste" }), v("hr", {}), z && G(Ne, { children: [v(q, { onClick: () => {
1849
+ d && p(Ri(d, a)), r();
1850
+ }, disabled: !d, children: "Paste" }), v("hr", {}), z && K(Oe, { children: [v(q, { onClick: () => {
1794
1851
  z && h(P, !0, !0), r();
1795
1852
  }, children: "Duplicate" }), v(q, { onClick: () => {
1796
- z && l(P.filter((I) => A ? I.visible !== !1 : I.visible === !1)), r();
1797
- }, children: A ? "Hide" : "Show" }), v(q, { onClick: () => {
1798
- z && d(P), r();
1853
+ z && l(P.filter((Z) => D ? Z.visible !== !1 : Z.visible === !1)), r();
1854
+ }, children: D ? "Hide" : "Show" }), v(q, { onClick: () => {
1855
+ z && s(P.filter((Z) => E ? Z.locked : !Z.locked)), r();
1856
+ }, children: E ? "Unlock" : "Lock" }), v(q, { onClick: () => {
1857
+ z && c(P), r();
1799
1858
  }, children: "Delete" }), v("hr", {})] }), v(q, { onClick: () => {
1800
1859
  t(), r();
1801
1860
  }, children: "Select all" })] });
1802
- }, zs = ({ editorProps: e, className: t, style: i, options: n, children: o }) => {
1803
- const { selectionMode: a, setSelectionMode: r, shapesRef: l, addPictureShape: s, moveShapes: d, swapShapes: h, toggleShapeVisibility: c, toggleShapeLock: f, canGoBackward: p, canGoForward: m, canClear: u, selectedShape: S, copiedShape: w, setCopiedShape: x, pasteShapes: b, removeShape: y, duplicateShapes: g, updateShape: P, backwardShape: z, forwardShape: D, removeShapePoint: A, transformShape: H, refs: Z, width: E, height: F, selectTool: W, selectShapes: I, selectAllShapes: oe, activeTool: te, setActiveTool: R, setAvailableTools: $, isEditMode: j, availableTools: ce, gridGap: Pe, setGridGap: L, loadFile: _, exportPicture: M, exportData: C, clearCanvas: Q, settings: V, setCanvasZoom: N, saveShapes: k, canvas: { canGrow: J, layersManipulation: O, withExport: T, withLoadAndSave: ne, withUploadPicture: ye, withUrlPicture: Y, withContextMenu: ze } } = e, { toolbarBackgroundColor: ge, dividerColor: Oe, fontRadius: Ye, fontDisabledColor: he, fontDisabledBackgroundColor: Se, fontColor: ae, fontBackgroundColor: fe, fontSelectedColor: ee, fontSelectedBackgroundColor: se, fontHoverColor: pe, fontHoverBackgroundColor: ke } = { ...Ms, ...n }, Be = V.size === "infinite" || V.features.zoom, [Ee, we] = K(!1), [Fe, bt] = K(!1), [Qt, dt] = K(Be), $e = Be && Qt, wt = Pe >= Ut.large ? "large" : Pe >= Ut.medium ? "medium" : Pe >= Ut.small ? "small" : "none", { snackbarList: xt, addSnackbar: Ae } = Cs(), at = X((ve, be, B) => {
1804
- $((nt) => nt.map((Tt) => Tt.id === ve ? Xe(["settings", be, "default"], B, Tt) : Tt)), R((nt) => nt.id === ve ? Xe(["settings", be, "default"], B, nt) : nt);
1805
- }, [R, $]), st = X((ve) => {
1806
- we(!0);
1861
+ }, Es = ({ editorProps: e, className: t, style: i, options: n, children: a }) => {
1862
+ const { selectionMode: o, setSelectionMode: r, shapesRef: l, addPictureShape: s, moveShapes: c, swapShapes: h, toggleShapeVisibility: d, toggleShapeLock: u, canGoBackward: p, canGoForward: f, canClear: m, selectedShape: b, copiedShape: x, setCopiedShape: k, pasteShapes: M, removeShape: S, duplicateShapes: g, updateShape: P, backwardShape: z, forwardShape: N, removeShapePoint: D, transformShape: E, refs: A, width: T, height: B, selectTool: F, selectShapes: X, selectAllShapes: Z, activeTool: ne, setActiveTool: I, setAvailableTools: j, isEditMode: ee, availableTools: se, gridGap: he, setGridGap: C, loadFile: $, exportPicture: Q, exportData: w, clearCanvas: y, settings: L, setCanvasZoom: W, saveShapes: V, canvas: { canGrow: U, layersManipulation: R, withExport: H, withLoadAndSave: ae, withUploadPicture: me, withUrlPicture: O, withContextMenu: ge } } = e, { toolbarBackgroundColor: ue, dividerColor: Se, fontRadius: Ie, fontDisabledColor: te, fontDisabledBackgroundColor: we, fontColor: re, fontBackgroundColor: ye, fontSelectedColor: ie, fontSelectedBackgroundColor: le, fontHoverColor: fe, fontHoverBackgroundColor: Ve } = { ...Vs, ...n }, Fe = L.size === "infinite" || L.features.zoom, [We, Ce] = J(!1), [Ye, bt] = J(!1), [Qt, ct] = J(Fe), $e = Fe && Qt, wt = he >= Ut.large ? "large" : he >= Ut.medium ? "medium" : he >= Ut.small ? "small" : "none", { snackbarList: xt, addSnackbar: Ae } = Zs(), ot = G((be, xe, Y) => {
1863
+ j((nt) => nt.map((Tt) => Tt.id === be ? Xe(["settings", xe, "default"], Y, Tt) : Tt)), I((nt) => nt.id === be ? Xe(["settings", xe, "default"], Y, nt) : nt);
1864
+ }, [I, j]), st = G((be) => {
1865
+ Ce(!0);
1807
1866
  try {
1808
- M(ve);
1809
- } catch (be) {
1810
- be instanceof Error && Ae({ type: "error", text: `L'export a échoué : ${be.message}` }), console.warn(be);
1867
+ Q(be);
1868
+ } catch (xe) {
1869
+ xe instanceof Error && Ae({ type: "error", text: `L'export a échoué : ${xe.message}` }), console.warn(xe);
1811
1870
  } finally {
1812
- we(!1);
1871
+ Ce(!1);
1813
1872
  }
1814
- }, [M, Ae]), je = X(() => {
1815
- we(!0);
1873
+ }, [Q, Ae]), je = G(() => {
1874
+ Ce(!0);
1816
1875
  try {
1817
- C(), we(!1);
1818
- } catch (ve) {
1819
- ve instanceof Error && Ae({ type: "error", text: "L'enregistrement a échoué" }), console.warn(ve);
1876
+ w(), Ce(!1);
1877
+ } catch (be) {
1878
+ be instanceof Error && Ae({ type: "error", text: "L'enregistrement a échoué" }), console.warn(be);
1820
1879
  } finally {
1821
- we(!1);
1880
+ Ce(!1);
1822
1881
  }
1823
- }, [C, Ae]), ct = X(async (ve) => {
1824
- we(!0);
1882
+ }, [w, Ae]), dt = G(async (be) => {
1883
+ Ce(!0);
1825
1884
  try {
1826
- await _(ve), Ae({ type: "success", text: "Fichier chargé !" });
1827
- } catch (be) {
1828
- be instanceof Error && Ae({ type: "error", text: "Le chargement a échoué" }), console.warn(be);
1885
+ await $(be), Ae({ type: "success", text: "Fichier chargé !" });
1886
+ } catch (xe) {
1887
+ xe instanceof Error && Ae({ type: "error", text: "Le chargement a échoué" }), console.warn(xe);
1829
1888
  } finally {
1830
- we(!1);
1889
+ Ce(!1);
1831
1890
  }
1832
- }, [_, Ae]), ht = X(async (ve) => {
1833
- we(!0);
1891
+ }, [$, Ae]), ht = G(async (be) => {
1892
+ Ce(!0);
1834
1893
  try {
1835
- const be = await s(ve, E, F);
1836
- I([be]);
1837
- } catch (be) {
1838
- be instanceof Error && Ae({ type: "error", text: "Le chargement a échoué" }), console.warn(be);
1894
+ const xe = await s(be, T, B);
1895
+ X([xe]);
1896
+ } catch (xe) {
1897
+ xe instanceof Error && Ae({ type: "error", text: "Le chargement a échoué" }), console.warn(xe);
1839
1898
  } finally {
1840
- we(!1);
1899
+ Ce(!1);
1841
1900
  }
1842
- }, [s, I, Ae, E, F]), pt = `${t ? `${t} ` : ""}${Fe ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1843
- return G("div", { ref: Z.setEditor, className: pt, style: { "--react-paint-editor-app-maxWidth": J ? "100%" : `${E}px`, "--react-paint-editor-app-toolbar-bg": ge, "--react-paint-editor-app-divider-color": Oe, "--react-paint-editor-app-font-radius": `${Ye}px`, "--react-paint-editor-app-font-disabled-color": he, "--react-paint-editor-app-font-disabled-bg": Se, "--react-paint-editor-app-font-color": ae, "--react-paint-editor-app-font-bg": fe, "--react-paint-editor-app-font-selected-color": ee, "--react-paint-editor-app-font-selected-bg": se, "--react-paint-editor-app-font-hover-color": pe, "--react-paint-editor-app-font-hover-bg": ke, ...i }, children: [j && v(xs, { settings: V, width: V.canvasSize.width, activeTool: te, clearCanvas: Q, setActiveTool: W, exportCanvasInFile: st, saveFile: je, loadFile: ct, addPicture: ht, hasActionToUndo: p, hasActionToRedo: m, hasActionToClear: u, undoAction: z, redoAction: D, availableTools: ce, withExport: T, withLoadAndSave: ne, withUploadPicture: ye, withUrlPicture: Y }), o, j && O && v(ls, { gridFormat: wt, setGridFormat: (ve) => {
1844
- L(Ut[ve]);
1845
- }, shapes: l.current, swapShapes: h, selectedShapes: S, removeShape: y, selectShapes: I, toggleShapeVisibility: c, toggleShapeLock: f, isLayoutPanelShown: Fe, settings: V }), $e && G(yt, { alignment: "left", position: "bottom", className: "react-paint-editor-layouts-panel", "data-edit": +j, children: [v(q, { 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: () => N("unzoom") }), G(q, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => N("default"), children: [Math.round(100 * V.canvasZoom), "%"] }), v(q, { className: "react-paint-editor-zoom-button", icon: jn, onClick: () => N("zoom") })] }), j && G(Ne, { children: [v(ms, { saveShapes: k, setCanvasZoom: N, width: V.canvasSize.width, activeTool: te, availableTools: ce, selectedShape: S, settings: V, removeShape: y, updateShape: P, canvas: Z.canvas.current, layersManipulation: O, toggleLayoutPanel: () => {
1846
- bt((ve) => !ve);
1847
- }, isZoomPanelShown: $e, setIsZoomPanelShown: dt, updateToolSettings: at }), v(es, { isLoading: Ee }), v(os, { snackbarList: xt })] }), a.mode === "contextMenu" && ze && v(Ps, { selectionMode: a, settings: V, canvasRef: Z.canvas, closeContextMenu: () => {
1848
- r({ mode: "default" }), Z.canvas.current?.focus();
1849
- }, selectAllShapes: oe, removeShape: y, moveShapes: d, duplicateShapes: g, toggleShapeLock: f, toggleShapeVisibility: c, setCopiedShape: x, copiedShape: w, pasteShapes: b, removeShapePoint: A, transformShape: H })] });
1901
+ }, [s, X, Ae, T, B]), ut = `${t ? `${t} ` : ""}${Ye ? "react-paint-editor-layout-opened " : ""}react-paint-editor-app`;
1902
+ return K("div", { ref: A.setEditor, className: ut, style: { "--react-paint-editor-app-maxWidth": U ? "100%" : `${T}px`, "--react-paint-editor-app-toolbar-bg": ue, "--react-paint-editor-app-divider-color": Se, "--react-paint-editor-app-font-radius": `${Ie}px`, "--react-paint-editor-app-font-disabled-color": te, "--react-paint-editor-app-font-disabled-bg": we, "--react-paint-editor-app-font-color": re, "--react-paint-editor-app-font-bg": ye, "--react-paint-editor-app-font-selected-color": ie, "--react-paint-editor-app-font-selected-bg": le, "--react-paint-editor-app-font-hover-color": fe, "--react-paint-editor-app-font-hover-bg": Ve, ...i }, children: [ee && v(Ls, { settings: L, width: L.canvasSize.width, activeTool: ne, clearCanvas: y, setActiveTool: F, exportCanvasInFile: st, saveFile: je, loadFile: dt, addPicture: ht, hasActionToUndo: p, hasActionToRedo: f, hasActionToClear: m, undoAction: z, redoAction: N, availableTools: se, withExport: H, withLoadAndSave: ae, withUploadPicture: me, withUrlPicture: O }), a, ee && R && v(ps, { gridFormat: wt, setGridFormat: (be) => {
1903
+ C(Ut[be]);
1904
+ }, shapes: l.current, swapShapes: h, selectedShapes: b, removeShape: S, selectShapes: X, toggleShapeVisibility: d, toggleShapeLock: u, isLayoutPanelShown: Ye, settings: L }), $e && K(St, { alignment: "left", position: "bottom", className: "react-paint-editor-layouts-panel", "data-edit": +ee, children: [v(q, { 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: () => W("unzoom") }), K(q, { className: "react-paint-editor-zoom-button react-paint-editor-zoom-button-value", onClick: () => W("default"), children: [Math.round(100 * L.canvasZoom), "%"] }), v(q, { className: "react-paint-editor-zoom-button", icon: Kn, onClick: () => W("zoom") })] }), ee && K(Oe, { children: [v(ws, { saveShapes: V, setCanvasZoom: W, width: L.canvasSize.width, activeTool: ne, availableTools: se, selectedShape: b, settings: L, removeShape: S, updateShape: P, canvas: A.canvas.current, layersManipulation: R, toggleLayoutPanel: () => {
1905
+ bt((be) => !be);
1906
+ }, isZoomPanelShown: $e, setIsZoomPanelShown: ct, updateToolSettings: ot }), v(os, { isLoading: We }), v(cs, { snackbarList: xt })] }), o.mode === "contextMenu" && ge && v(Hs, { selectionMode: o, settings: L, canvasRef: A.canvas, closeContextMenu: () => {
1907
+ r({ mode: "default" }), A.canvas.current?.focus();
1908
+ }, selectAllShapes: Z, removeShape: S, moveShapes: c, duplicateShapes: g, toggleShapeLock: u, toggleShapeVisibility: d, setCopiedShape: k, copiedShape: x, pasteShapes: M, removeShapePoint: D, transformShape: E })] });
1850
1909
  };
1851
1910
  export {
1852
- Zs as Canvas,
1853
- zs as Editor,
1854
- Vs as useReactPaint
1911
+ Ds as Canvas,
1912
+ Es as Editor,
1913
+ Ts as useReactPaint
1855
1914
  };