lecom-modeler 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,25 +1,25 @@
1
- var Wn=Object.defineProperty,Yn=Object.defineProperties;var Kn=Object.getOwnPropertyDescriptors;var We=Object.getOwnPropertySymbols;var to=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable;var eo=(e,t,o)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))to.call(t,o)&&eo(e,o,t[o]);if(We)for(var o of We(t))oo.call(t,o)&&eo(e,o,t[o]);return e},y=(e,t)=>Yn(e,Kn(t));var be=(e,t)=>{var o={};for(var r in e)to.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&We)for(var r of We(e))t.indexOf(r)<0&&oo.call(e,r)&&(o[r]=e[r]);return o};import{TooltipProvider as Zn,Notification as $n}from"lecom-ui";import{jsx as qn,jsxs as Xn}from"react/jsx-runtime";function ro({children:e}){return Xn(Zn,{children:[qn($n,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{applyEdgeChanges as _d,Background as wd,getIncomers as Cd,getOutgoers as Id,MiniMap as Ad,ReactFlow as kd,ReactFlowProvider as Sd,SelectionMode as Ld,useEdgesState as Dd,useNodesState as Pd,useOnSelectionChange as Rd,useReactFlow as Md}from"@xyflow/react";import{i18n as Vd}from"lecom-ui";import{useCallback as Lt,useEffect as vn,useRef as Od,useState as Gd}from"react";import{useDebouncedCallback as Hd}from"use-debounce";var Pt=(o=>(o.EDIT="edit",o.READONLY="readonly",o))(Pt||{});import{RotateCcw as la,ScrollText as da,SquarePlus as ca}from"lucide-react";import{jsx as Ye,jsxs as jn}from"react/jsx-runtime";var Ke=({size:e=24,className:t})=>jn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Ye("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Ye("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Ye("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Ye("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as no}from"react/jsx-runtime";var Ee=({size:e=24,className:t})=>no("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#f87171",stroke:"#ef4444",strokeWidth:3,className:t,children:no("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ae,jsxs as Jn}from"react/jsx-runtime";var Ze=({size:e=24,className:t})=>Jn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Ae("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Ae("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ae("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Ae("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ae("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Rt,jsxs as Qn}from"react/jsx-runtime";var ve=({size:e=24,className:t})=>Qn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Rt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Rt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Rt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Mt,jsxs as ea}from"react/jsx-runtime";var $e=({size:e=24,className:t})=>ea("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Mt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Mt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Mt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Vt,jsxs as ta}from"react/jsx-runtime";var ao=({size:e=24,className:t})=>Vt("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:ta("g",{children:[Vt("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),Vt("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as oa}from"clsx";import{twMerge as ra}from"tailwind-merge";function _(...e){return ra(oa(e))}var ke=(e,t)=>e<t?t:e;import{jsx as io,jsxs as na}from"react/jsx-runtime";var so=({size:e=24,className:t})=>na("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:_("stroke-2",t),children:[io("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),io("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ot}from"react/jsx-runtime";var lo=({size:e=24,className:t})=>Ot("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Ot("g",{children:Ot("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as co}from"react/jsx-runtime";var qe=({size:e=24,className:t})=>co("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:co("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as po}from"react/jsx-runtime";var Se=({size:e=24,className:t})=>po("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:_("stroke-2",t),children:po("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Gt,jsxs as aa}from"react/jsx-runtime";var mo=({size:e=24,className:t})=>aa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Gt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Le,jsxs as ia}from"react/jsx-runtime";var uo=({size:e=24,className:t})=>ia("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Le("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Le("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Le("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Le("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Le("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Xe,jsxs as sa}from"react/jsx-runtime";var go=({size:e=24,className:t})=>sa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Xe("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Xe("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Xe("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Xe("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var P=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(P||{});var je={SCRIPT:{icon:da},SUBPROCESS:{icon:ca}};var Je={LOOP:{icon:la}};var Qe={EXCLUSIVE:{icon:ve},PARALLEL:{icon:$e},COMPLEX:{icon:Ze}};import bo from"@dagrejs/dagre";import{getNodesBounds as Ea}from"@xyflow/react";import{orderBy as va}from"lodash";var pa={MIN_WIDTH:36,MIN_HEIGHT:36},ma={MIN_WIDTH:36,MIN_HEIGHT:36},ua={MIN_WIDTH:56,MIN_HEIGHT:56},et={MIN_WIDTH:176,MIN_HEIGHT:96},tt={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},Y={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},ot={MIN_WIDTH:176,MIN_HEIGHT:64},ga={MIN_WIDTH:128,MIN_HEIGHT:64},V={START_EVENT:pa,END_EVENT:ma,GATEWAY:ua,TASK:et,LANE:Y,ANNOTATION:ot,UNSUPPORTED:ga};import{orderBy as fa}from"lodash";var ne=e=>{var t,o,r,n,a,i,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(n=(r=e.internals)==null?void 0:r.positionAbsolute.y)!=null?n:0,w:(i=(a=e.measured)==null?void 0:a.width)!=null?i:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},ae=e=>fa(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),fo=(e,t)=>{let{x:o,y:r}=ne(e),{x:n,y:a}=ne(t);return{x:o-n,y:r-a}};var Ne=({parentId:e,nodes:t,includeTypes:o=[...Object.values(P)],excludeTypes:r=[]})=>t.some(n=>n.parentId===e&&(!o.length||o.includes(n.type))&&!r.includes(n.type)),ha=(e,t)=>{let{x:o,y:r}=ne(e),{x:n,y:a}=ne(t),i=o-n,s=r-a;return Math.sqrt(i*i+s*s)},ba=(e,t)=>{let{x:o,y:r,w:n,h:a}=ne(e),{x:i,y:s,w:l,h:d}=ne(t);return o<i+l&&i<o+n&&r<s+d&&s<r+a},De=(e,t)=>{let o=null,r=1/0;for(let n of t)if(n.id!==e.id&&ba(e,n)){let a=ha(e,n);a<r&&(r=a,o=n)}return o},ho=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,r)=>{var n,a;return Math.max(o,(a=(n=r.measured)==null?void 0:n.width)!=null?a:0)},0);var Eo=(e=[],t=[],o="LR")=>{let r=new bo.graphlib.Graph;return r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:o}),e.forEach(({id:a,width:i,height:s})=>r.setNode(a,{width:i,height:s})),t.forEach(a=>r.setEdge(a.source,a.target)),bo.layout(r),{nodes:e.map(a=>{let i=r.node(a.id);return y(E({},a),{position:{x:i.x-a.width/2,y:i.y-a.height/2}})}),edges:t}},ue=(e,t)=>{var c,h;let o=[...t],r=o.find(u=>u.id===e);if(!r)return o;let n=o.filter(u=>u.parentId===e&&u.type==="LANE");if(n.length===0)return o;let a=va(n,["position.y"]),i=Math.max((h=(c=r.measured)==null?void 0:c.width)!=null?h:0,tt.MIN_WIDTH),s=ho(e,a)||Y.MIN_WIDTH,l=Math.max(i,s),d=0,m=0;a.forEach(u=>{var v,g,p,b;o=o.map(w=>w.id===u.id?y(E({},w),{width:l-Y.HEADER_WIDTH,measured:y(E({},w.measured),{width:l-Y.HEADER_WIDTH}),position:{x:Y.HEADER_WIDTH,y:d}}):w),d+=(g=(v=u.measured)==null?void 0:v.height)!=null?g:0,m+=(b=(p=u.measured)==null?void 0:p.height)!=null?b:0}),o=o.map(u=>u.id===e?y(E({},u),{height:m,width:l,measured:y(E({},u.measured),{height:m,width:l})}):u);let f=o.find(u=>u.id===e);return f!=null&&f.parentId&&(o=ue(f.parentId,o)),o},vo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Na=50,No=(e,t=Na)=>{let o=Ea(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as ya}from"zustand";var O=ya(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as ko,useReactFlow as ai}from"@xyflow/react";import{BaseEdge as Wa,EdgeLabelRenderer as Ya,getStraightPath as Ka,useNodes as Za,useViewport as $a}from"@xyflow/react";import{getIncomers as Ca,getOutgoers as Ia,useReactFlow as Aa}from"@xyflow/react";import{Button as ka,Tooltip as Sa,TooltipContent as La,TooltipTrigger as Da,useTranslation as Pa}from"lecom-ui";import{PencilIcon as Ra}from"lucide-react";import{createContext as Ta,useContext as xa}from"react";var yo=Ta(null),To=yo.Provider,rt=()=>{let e=xa(yo);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as nt,jsxs as Ma}from"react/jsx-runtime";var Pe=({elementId:e,elementType:t="node"})=>{let{t:o}=Pa(),{getNode:r,getEdge:n,getNodes:a,getEdges:i}=Aa(),{onConfigureElement:s}=rt(),l=c=>{let h=a(),u=i(),v=Ca(c,h,u),g=Ia(c,h,u),p=v.some(w=>w.type==="START_EVENT"),b=g.some(w=>w.type==="END_EVENT");return p?"start":b?"end":"between"},d=()=>{let c=r(e);c&&(s==null||s({id:c.id,type:"activity",variant:l(c)}))},m=()=>{let c=n(e);c&&(s==null||s({id:c.id,type:"routing"}))};return Ma(Sa,{children:[nt(Da,{asChild:!0,children:nt(ka,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":d();break;case"edge":m();break}},children:nt(Ra,{size:16})})}),nt(La,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Va}from"@xyflow/react";import{Button as Oa,Tooltip as Ga,TooltipContent as Ha,TooltipTrigger as Ba,useTranslation as za}from"lecom-ui";import{TrashIcon as Fa}from"lucide-react";import{jsx as at,jsxs as Ua}from"react/jsx-runtime";var it=({elementId:e,elementType:t="node"})=>{let{t:o}=za(),{deleteElements:r}=Va();return Ua(Ga,{children:[at(Ba,{asChild:!0,children:at(Oa,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{r(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:at(Fa,{size:16})})}),at(Ha,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as st}from"react/jsx-runtime";var ye=r=>{var n=r,{edgeId:e,edgeType:t}=n,o=be(n,["edgeId","edgeType"]);var s;let a=[{component:st(it,{elementId:e,elementType:"edge"})}],i={SEQUENCE_EDGE:[{component:st(Pe,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return st("div",y(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(s=i[t])==null?void 0:s.map((l,d)=>st("div",{children:l.component},d))}))};import{jsx as dt,jsxs as qa}from"react/jsx-runtime";var ct={type:"ANNOTATION_EDGE",zIndex:2e3},xo=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:a,targetY:i,selected:s,data:l})=>{let d=Za(),{zoom:m}=$a(),f=d.find(b=>b.id===t),c=d.find(b=>b.id===o),[h,u,v]=Ka({sourceX:r,sourceY:n,targetX:a,targetY:i}),g=s||(f==null?void 0:f.selected)||(c==null?void 0:c.selected),p=1/m;return qa("g",{className:_("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":g}),children:[dt(Wa,{id:e,path:h,strokeDasharray:4,className:_("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":g&&!(l!=null&&l.hasError)})}),dt(Ya,{children:dt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${v}px)`},children:s&&dt(ye,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${p})`}})})})]})};import{BaseEdge as Ja,EdgeLabelRenderer as Qa,getSmoothStepPath as ei,MarkerType as Co,useNodes as ti,useReactFlow as oi,useViewport as ri}from"@xyflow/react";import{useState as ni}from"react";import{useEffect as _o,useRef as Xa,useState as ja}from"react";import{jsx as wo}from"react/jsx-runtime";var U=({value:e,maxLength:t,onChange:o,isEditing:r,onBlur:n,className:a,style:i})=>{let s=Xa(null),[l,d]=ja(!1);_o(()=>{d(r!=null?r:!1)},[r]),_o(()=>{if(l&&s.current){s.current.focus();let h=document.createRange();h.selectNodeContents(s.current),h.collapse(!1);let u=window.getSelection();u&&(u.removeAllRanges(),u.addRange(h))}},[l]);let m=h=>{h.stopPropagation(),d(!0)},f=h=>{let u=h.currentTarget.innerText;t&&u.length>=t&&h.preventDefault()},c=h=>{d(!1),n==null||n(),o==null||o(h.currentTarget.innerText)};return wo("div",{className:_("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:i,onDoubleClick:m,children:wo("div",{ref:s,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:f,onBlur:c,children:e})})};import{jsx as pt,jsxs as Io}from"react/jsx-runtime";var le={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Co.ArrowClosed},markerEnd:{type:Co.Arrow},data:{label:""}},Ao=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,data:d,selected:m})=>{let f=ti(),{zoom:c}=ri(),{updateEdgeData:h}=oi(),[u,v]=ni(!1),g=f.find(x=>x.id===t),p=f.find(x=>x.id===o),[b,w,I]=ei({sourceX:r,sourceY:n,sourcePosition:s,targetX:a,targetY:i,targetPosition:l}),A=m||(g==null?void 0:g.selected)||(p==null?void 0:p.selected),R=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=u||(d==null?void 0:d.label.trim().length)>0,T=1/c,S=()=>{v(!0)},C=()=>{v(!1)},k=x=>{h(e,{label:x.trim()})};return Io("g",{className:_("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":A}),onBlur:C,onDoubleClick:S,children:[pt(Ja,{id:e,path:b,markerEnd:`url(#${R})`,className:_("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":d==null?void 0:d.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":A&&!(d!=null&&d.hasError)})}),pt(Qa,{children:Io("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${w}px, ${I}px)`},children:[m&&pt(ye,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${T})`}}),N&&pt(U,{value:d==null?void 0:d.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:u,onChange:k})]})})]})};var So=({setEdges:e})=>{let{getNode:t}=ai();return{isValidConnection:n=>{let a=t(n.source),i=t(n.target);if((a==null?void 0:a.id)===(i==null?void 0:i.id))return!1;switch(a==null?void 0:a.type){case"START_EVENT":return(i==null?void 0:i.type)==="TASK"||(i==null?void 0:i.type)==="END_EVENT"||(i==null?void 0:i.type)==="GATEWAY"||(i==null?void 0:i.type)==="ANNOTATION";case"END_EVENT":return(i==null?void 0:i.type)==="ANNOTATION";case"TASK":return(i==null?void 0:i.type)==="TASK"||(i==null?void 0:i.type)==="END_EVENT"||(i==null?void 0:i.type)==="GATEWAY"||(i==null?void 0:i.type)==="ANNOTATION";case"GATEWAY":return(i==null?void 0:i.type)==="TASK"||(i==null?void 0:i.type)==="END_EVENT"||(i==null?void 0:i.type)==="GATEWAY"||(i==null?void 0:i.type)==="ANNOTATION";case"LANE":return(i==null?void 0:i.type)==="ANNOTATION";default:return!1}},onConnect:n=>{e(a=>{let i=t(n.target);return(i==null?void 0:i.type)==="ANNOTATION"?ko(E(E({},n),ct),a):ko(E(E({},n),le),a)})}}};import{useState as Ho}from"react";import{useTranslation as ii}from"lecom-ui";import{useReactFlow as si}from"@xyflow/react";var Re=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ge=(e=[])=>e.filter(t=>t.type==="END_EVENT"),de=(e=[])=>e.filter(t=>t.type==="TASK")||[],Lo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Do=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),ut=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Po=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),q=(e,t=[])=>t.filter(o=>o.source===e),Me=(e,t=[])=>t.filter(o=>o.target===e),Ro=(e,t)=>{var r,n;let o=(r=t.nodes)==null?void 0:r.find(a=>a.id===e);return((n=o==null?void 0:o.properties)==null?void 0:n.attribute)==="LOOP"},Mo=(e,t)=>{let o=q(e,t.edges||[]);for(let r of o){let n=(t.nodes||[]).find(a=>a.id===r.target);if(n&&n.type==="END_EVENT")return!0}return!1},Vo=e=>e?/\w/g.test(e.trim()):!1,D=e=>{let{isValid:t,nodeIds:o,edgeIds:r}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&r&&r.length>0?r:[]}},Q=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(r=>!t(r));return{isValid:o.length===0,invalidIds:o.map(r=>r.id)}},Oo=(e=[],t=[])=>({nodes:e.map(o=>{var r;return{id:o.id,type:o.type||"",label:typeof((r=o.data)==null?void 0:r.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Ve=[{id:"start_event_not_found",validate:e=>{let t=Re(e.nodes);return D({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ge(e.nodes);return D({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Re(e.nodes),o=t.length===1;if(t.length===0)return D({isValid:!0});if(!o)return D({isValid:!1,nodeIds:t.map(a=>a.id)});let r=q(t[0].id,e.edges);if(!(r.length<=1)){let a=[...t.map(i=>i.id),...r.map(i=>i.target)];return D({isValid:!1,nodeIds:[...new Set(a)]})}return D({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=de(e.nodes),o=Q(t,r=>q(r.id,e.edges).length<=2);return D({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=Q(t,r=>!!r.label&&r.label.trim()!=="");return D({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=de(e.nodes),r=Q(o,n=>!n.label||n.label.length<=60);return D({isValid:r.isValid,nodeIds:r.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=new Map;for(let n of t){if(!n.label)continue;let a=n.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(n))}let r=[];for(let[,n]of o.entries())n.length>1&&n.forEach(a=>r.push(a.id));return D({isValid:r.length===0,nodeIds:r})}},{id:"nested_gateway",validate:e=>{let t=ut(e.nodes),o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&s.type==="GATEWAY"&&(o.push(n.id,s.id),r.push(i.id))}}return D({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"events_nested",validate:e=>{let t=[...Re(e.nodes),...ge(e.nodes)],o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(n.id,s.id),r.push(i.id))}}return D({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ge(e.nodes),o=[],r=[];for(let n of t){let a=Me(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.source);if(s&&s.type==="TASK"){let l=q(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(d=>r.push(d.id)))}}}return D({isValid:o.length===0,nodeIds:o,edgeIds:r})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Po(e.nodes),o=Q(t,n=>q(n.id,e.edges).length<=2),r=o.invalidIds.flatMap(n=>q(n,e.edges).map(a=>a.id));return D({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:r})}},{id:"activity_name_invalid",validate:e=>{let t=de(e.nodes),o=Q(t,r=>!r.label||Vo(r.label));return D({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var i,s;if(!((i=e==null?void 0:e.nodes)!=null&&i.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return D({isValid:!0});let t=ge(e.nodes)[0];if(!t)return D({isValid:!0});let o=Me(t.id,e.edges);if(!o.length)return D({isValid:!0});let n=de(e.nodes).filter(l=>o.some(d=>d.source===l.id)),a=Q(n,l=>!Ro(l.id,e));return D({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=de(e.nodes),o=ge(e.nodes)[0];if(!o)return D({isValid:!0});let r=t.filter(l=>{let d=Me(l.id,e.edges),m=q(l.id,e.edges),f=d.some(h=>{var u;return((u=e.nodes.find(v=>v.id===h.source))==null?void 0:u.type)==="START_EVENT"}),c=m.some(h=>{var u;return((u=e.nodes.find(v=>v.id===h.target))==null?void 0:u.type)==="END_EVENT"});return f&&c}),n=Me(o.id,e.edges),a=n.length>1,i=n.map(l=>l.source),s={isValid:r.length===0&&!a,nodeIds:[...r.map(l=>l.id),...a?i:[]]};return D(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=ut(e.nodes),o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&s.type==="END_EVENT"&&(o.push(n.id,s.id),r.push(i.id))}}return D({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ut(e.nodes),o=Q(t,r=>q(r.id,e.edges).length>=1);return D({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Re(e.nodes),...ge(e.nodes)],o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&s.type==="GATEWAY"&&(o.push(n.id,s.id),r.push(i.id))}}return D({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"script_in_final_activity",validate:e=>{let t=Lo(e.nodes),o=Q(t,r=>!Mo(r.id,e));return D({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Do(e.nodes),o=Q(t,r=>{var n,a;return((n=r.properties)==null?void 0:n.subprocessRef)!==void 0&&((a=r.properties)==null?void 0:a.subprocessRef)!==""});return D({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Go=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let r of Ve){let n=r.validate(e);n.isValid||t.push({id:r.id,message:r.id,nodeIds:n.nodeIds||[],edgeIds:n.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var Bo=()=>{let{t:e}=ii(),[t,o]=Ho(null),{setNodes:r,setEdges:n,getNodes:a,getEdges:i}=si(),[s,l]=Ho(!1);return{validationResult:t,validateDiagram:c=>{let h=Oo(c.nodes,c.edges),u=Go(h),v=u.errors.map(g=>y(E({},g),{message:e(`validation.errors.${g.id}`)}));return s||l(!0),{isValid:u.isValid,errors:v}},handleValidationComplete:c=>{if(o(c),!c)return;let h=[],u=[];c.errors.forEach(N=>{N.nodeIds&&N.nodeIds.length>0&&N.nodeIds.forEach(T=>h.push(T)),N.edgeIds&&N.edgeIds.length>0&&N.edgeIds.forEach(T=>u.push(T))});let v=[...new Set(h)];r(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:!1})}))),n(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:!1})})));let g=a(),p=i(),b=new Set(v),w=new Set;c.errors.forEach(N=>{var C,k;let T=Ve.find(x=>x.id===N.id);(T==null?void 0:T.highlightRelatedEdges)!==!1&&((C=N.edgeIds)==null||C.forEach(x=>w.add(x)),(k=N.nodeIds)==null||k.forEach(x=>{p.forEach(z=>{(z.source===x||z.target===x)&&w.add(z.id)})}))});let I=new Set,A=new Set,R=new Set;g.forEach(N=>{N.type==="START_EVENT"?I.add(N.id):N.type==="END_EVENT"&&A.add(N.id)}),p.forEach(N=>{I.has(N.source)&&R.add(N.target),A.has(N.target)&&R.add(N.source)}),R.forEach(N=>{var T,S;if(b.has(N)){let C=(T=c.errors.find(x=>{var z;return(z=x.nodeIds)==null?void 0:z.includes(N)}))==null?void 0:T.id;((S=Ve.find(x=>x.id===C))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(x=>{x.source===N&&A.has(x.target)&&(b.add(x.target),w.add(x.id)),x.target===N&&I.has(x.source)&&(b.add(x.source),w.add(x.id))})}}),b.size>0&&r(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:b.has(T.id)})}))),w.size>0&&n(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:w.has(T.id)})})))},clearValidation:()=>{o(null),l(!1),r(c=>c.map(h=>y(E({},h),{data:y(E({},h.data),{hasError:!1})}))),n(c=>c.map(h=>y(E({},h),{data:y(E({},h.data),{hasError:!1})})))},isAutoValidationEnabled:s}};import{useReactFlow as li}from"@xyflow/react";import{useEffect as di}from"react";import{v7 as zo}from"uuid";var ci=15,Fo="bpmn:selection",Uo=({offset:e=ci}={})=>{let{getNodes:t,setNodes:o,getEdges:r,setEdges:n}=li();di(()=>{let a=s=>{var h;s.preventDefault();let l=t(),d=r(),m=l.filter(u=>u.selected);if(!m.length)return;let f=d.filter(u=>m.some(v=>v.id===u.source)&&m.some(v=>v.id===u.target)),c={nodes:m,edges:f};(h=s.clipboardData)==null||h.setData(Fo,JSON.stringify(c))},i=s=>{var c,h;s.preventDefault();let l=JSON.parse(((c=s.clipboardData)==null?void 0:c.getData(Fo))||"{}");if(!((h=l.nodes)!=null&&h.length))return;let d=new Map,m=l.nodes.map(u=>{let v=zo();return d.set(u.id,v),y(E({},u),{id:v,selected:!0,position:{x:u.position.x+e,y:u.position.y+e}})}),f=l.edges.map(u=>y(E({},u),{id:zo(),selected:!0,source:d.get(u.source)||u.source,target:d.get(u.target)||u.target}));o(u=>[...u.map(v=>y(E({},v),{selected:!1})),...m]),n(u=>[...u.map(v=>y(E({},v),{selected:!1})),...f])};return document.addEventListener("copy",a),document.addEventListener("paste",i),()=>{document.removeEventListener("copy",a),document.removeEventListener("paste",i)}},[t,o,r,n,e])};import{useReactFlow as yi,useStoreApi as Ti}from"@xyflow/react";import{v7 as $o}from"uuid";import{create as pi}from"zustand";var Te=pi(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as mi,EdgeLabelRenderer as ui,getSmoothStepPath as gi,MarkerType as fi,useNodes as hi,useReactFlow as bi,useViewport as Ei}from"@xyflow/react";import{useState as vi}from"react";import{jsx as gt,jsxs as Wo}from"react/jsx-runtime";var zm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:fi.Arrow},data:{label:""}},Yo=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,data:d,selected:m})=>{let f=hi(),{zoom:c}=Ei(),{updateEdgeData:h}=bi(),[u,v]=vi(!1),g=f.find(x=>x.id===t),p=f.find(x=>x.id===o),[b,w,I]=gi({sourceX:r,sourceY:n,sourcePosition:s,targetX:a,targetY:i,targetPosition:l}),A=m||(g==null?void 0:g.selected)||(p==null?void 0:p.selected),R=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=u||(d==null?void 0:d.label.trim().length)>0,T=1/c,S=()=>{v(!0)},C=()=>{v(!1)},k=x=>{h(e,{label:x.trim()})};return Wo("g",{className:_("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":A}),onBlur:C,onDoubleClick:S,children:[gt(mi,{id:e,path:b,markerEnd:`url(#${R})`,strokeDasharray:4,className:_("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":d==null?void 0:d.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":A&&!(d!=null&&d.hasError)})}),gt(ui,{children:Wo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${w}px, ${I}px)`},children:[m&&gt(ye,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${T})`}}),N&&gt(U,{value:d==null?void 0:d.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:u,onChange:k})]})})]})};import{jsx as Ko,jsxs as Ni}from"react/jsx-runtime";var Zo=({fromX:e,fromY:t,toX:o,toY:r})=>Ni("g",{children:[Ko("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${r} ${e} ${r} ${o},${r}`}),Ko("circle",{cx:o,cy:r,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var qo=({nodes:e,setNodes:t,setEdges:o})=>{let r=Ti(),{draggableNode:n,setDraggableNode:a}=Te(),{getInternalNode:i,screenToFlowPosition:s}=yi(),l=g=>{let p="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(b=>b.map(w=>y(E({},w),{className:w.id===g?p:""})))},d=()=>{let{nodeLookup:g}=r.getState();return Array.from(g.values())},m=g=>{let p=i(g.id),b=d();if(g.type==="LANE"){if(Ne({parentId:g.id,nodes:e,includeTypes:["LANE"]})){l();return}let T=b.filter(k=>k.id!==g.id&&k.type==="LANE"&&!k.parentId),S=De(p,T);if(!S){l();return}if(Ne({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){l();return}l(S.id);return}let I=b.filter(N=>N.id!==g.id&&N.type==="LANE"),A=De(p,I);if(!A){l();return}if(Ne({parentId:A.id,nodes:e,includeTypes:["LANE"]})){l();return}l(A.id)},f=g=>{g.preventDefault(),g.dataTransfer.dropEffect="move"},c=(g,p)=>{g.preventDefault(),m(p)},h=(g,p,b)=>{var T,S;let w=C=>C.map(k=>y(E({},k),{className:void 0}));if(g.parentId===p.id){let C=ue(p.id,b);t(ae(w(C)));return}if(g.type==="LANE"){if(Ne({parentId:p.id,nodes:b,excludeTypes:["LANE"]}))return;let x=b.filter(F=>F.parentId===p.id).reduce((F,he)=>{var oe,me;return F+((me=(oe=he.measured)==null?void 0:oe.height)!=null?me:0)},0),z={x:Y.HEADER_WIDTH,y:x},K=b.map(F=>F.id===g.id?y(E({},F),{parentId:p.id,position:z,className:void 0}):y(E({},F),{className:void 0}));K=ue(p.id,K),t(ae(K));return}if(Ne({parentId:p.id,nodes:b,includeTypes:["LANE"]})){let C;if(g.parentId){let x=i(g.parentId),{x:z,y:K}=ne(x);C={x:z+((T=g.position.x)!=null?T:0),y:K+((S=g.position.y)!=null?S:0)}}let k=b.map(x=>x.id===g.id?y(E({},x),{position:C!=null?C:x.position,parentId:void 0,className:void 0}):y(E({},x),{className:void 0}));t(ae(k));return}let R=fo(g,p),N=b.map(C=>C.id===g.id?y(E({},C),{parentId:p.id,position:R,className:void 0}):y(E({},C),{className:void 0}));t(ae(N))};return{onDragOver:f,onDrop:g=>{if(g.preventDefault(),!(n!=null&&n.type))return;let p=s({x:g.clientX,y:g.clientY}),b={width:V[n.type].MIN_WIDTH,height:V[n.type].MIN_HEIGHT},w={id:$o(),type:n.type,position:p,measured:b,data:{label:"",variant:n.variant,attribute:n.attribute}},I=y(E({},w),{internals:{positionAbsolute:p}}),A=d(),R=n.type==="LANE",N=A.filter(C=>R?C.type==="LANE"&&!C.parentId:C.type==="LANE"),T=De(I,N);T?h(I,T,[...A,I]):t(C=>{let k=C.concat(w);return ae(k)});let S=g.dataTransfer.getData("sourceId");if(S){let C={id:$o(),source:S,target:w.id};if(n.type==="ANNOTATION"){o(k=>k.concat(E(E({},C),ct)));return}o(k=>k.concat(E(E({},C),le)))}a(null)},onNodeDrag:c,onNodeDragStop:async(g,p)=>{var T,S;let{nodeLookup:b}=r.getState(),w=i(p.id),I=Array.from(b.values()),A=p.type==="LANE",R=I.filter(C=>C.id!==p.id&&(A?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=De(w,R);if(N){h(w,N,I);return}if(p.parentId){let C=i(p.parentId),{x:k,y:x}=ne(C),z={x:k+((T=p.position.x)!=null?T:0),y:x+((S=p.position.y)!=null?S:0)},K=e.map(F=>F.id===p.id?y(E({},F),{position:z,parentId:void 0}):F);K=ue(p.parentId,K),t(ae(K))}}}};import{applyNodeChanges as xi}from"@xyflow/react";import{useCallback as _i,useState as jo}from"react";function Xo(e,t,o=5){var l,d,m,f,c,h,u,v;let r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},n=t.find(g=>g.id===e.id);if(!n||!e.position)return r;let a={left:e.position.x,right:e.position.x+((d=(l=n.measured)==null?void 0:l.width)!=null?d:0),top:e.position.y,bottom:e.position.y+((f=(m=n.measured)==null?void 0:m.height)!=null?f:0),width:(h=(c=n.measured)==null?void 0:c.width)!=null?h:0,height:(v=(u=n.measured)==null?void 0:u.height)!=null?v:0},i=o,s=o;return t.filter(g=>g.id!==n.id).reduce((g,p)=>{var k,x,z,K,F,he,oe,me;let b={left:p.position.x,right:p.position.x+((x=(k=p.measured)==null?void 0:k.width)!=null?x:0),top:p.position.y,bottom:p.position.y+((K=(z=p.measured)==null?void 0:z.height)!=null?K:0),width:(he=(F=p.measured)==null?void 0:F.width)!=null?he:0,height:(me=(oe=p.measured)==null?void 0:oe.height)!=null?me:0},w=Math.abs(a.left-b.left);w<s&&(g.snapPosition.x=b.left,g.vertical=b.left,s=w);let I=Math.abs(a.right-b.right);I<s&&(g.snapPosition.x=b.right-a.width,g.vertical=b.right,s=I);let A=Math.abs(a.left-b.right);A<s&&(g.snapPosition.x=b.right,g.vertical=b.right,s=A);let R=Math.abs(a.right-b.left);R<s&&(g.snapPosition.x=b.left-a.width,g.vertical=b.left,s=R);let N=Math.abs(a.top-b.top);N<i&&(g.snapPosition.y=b.top,g.horizontal=b.top,i=N);let T=Math.abs(a.bottom-b.top);T<i&&(g.snapPosition.y=b.top-a.height,g.horizontal=b.top,i=T);let S=Math.abs(a.bottom-b.bottom);S<i&&(g.snapPosition.y=b.bottom-a.height,g.horizontal=b.bottom,i=S);let C=Math.abs(a.top-b.bottom);return C<i&&(g.snapPosition.y=b.bottom,g.horizontal=b.bottom,i=C),g},r)}var Jo=()=>{let[e,t]=jo(void 0),[o,r]=jo(void 0),n=_i((a,i)=>{var s,l;if(t(void 0),r(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let d=Xo(a[0],i);a[0].position.x=(s=d.snapPosition.x)!=null?s:a[0].position.x,a[0].position.y=(l=d.snapPosition.y)!=null?l:a[0].position.y,t(d.horizontal),r(d.vertical)}return xi(a,i)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:n}};import{useReactFlow as Ci}from"@xyflow/react";import{v7 as rr}from"uuid";var er={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},tr={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Qo=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],r=e.match(/(\[.*?\])/)||[],n=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],i="",s="",l="";if(o.length){switch(o[1]){case"<start>":i="start-event";break;case"<end>":i="end-event";break}e=e.replace(o[1],"")}return r.length&&(i="task",s=r[1].replace(/\[|\]/g,""),e=e.replace(r[1],"")),n.length&&(i="gateway-exclusive",s=n[1].replace(/\{|\}/g,""),e=e.replace(n[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:i,label:s}),{step:e,type:i,label:s,edgeLabel:l}},wi=e=>{e=e||"";let t=e.trim().split(`
2
- `),o={},r=[];return t.forEach(n=>{n=n||"";let a=n.trim().split("-->");if(a.length!==2){console.warn("Invalid number of steps");return}let i=Qo(a[0],o),s=Qo(a[1],o);i&&s&&r.push({sourceId:i.step,targetId:s.step,label:i.edgeLabel||s.edgeLabel||""})}),{components:o,connections:r}},or=e=>{let{components:t,connections:o}=wi(e);return{nodes:t,edges:o}};var nr=()=>{let{setNodes:e,setEdges:t,fitView:o}=Ci();return{createDiagram:n=>{let{nodes:a,edges:i}=or(n),s=[],l=new Map;for(let[c,h]of Object.entries(a)){let u=rr(),v=er[h.type],g=tr[h.type];l.set(c,u);let p=V[v].MIN_WIDTH,b=V[v].MIN_HEIGHT;s.push({id:u,type:v,data:{label:h.label||"",variant:g,attribute:""},position:{x:0,y:0},width:p,height:b,measured:{width:p,height:b}})}let d=[];for(let c of i){let h=y(E({},le),{id:rr(),source:l.get(c.sourceId)||c.sourceId,target:l.get(c.targetId)||c.targetId});d.push(h)}let{nodes:m,edges:f}=Eo(s,d);e(m),t(f),o()}}};import{useEffect as Ii,useCallback as Ai}from"react";var ki={origin:"*",debug:!1};function ar(e,t=ki){let{origin:o,debug:r}=t,n=Ai((a,i)=>{r&&console.debug("[postMessage] sending:",{type:a,payload:i}),window.parent.postMessage({type:a,payload:i},o||"*")},[o,r]);return Ii(()=>{let a=i=>{let{type:s,data:l}=i.data||{};r&&console.debug("[postMessage] received:",i.data),s&&e[s]&&e[s](l)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[e,r]),{sendMessage:n}}import{useReactFlow as Si}from"@xyflow/react";import{useCallback as Oe,useState as ir}from"react";import{useDebouncedCallback as Li}from"use-debounce";var Di={nodes:[],edges:[]},Pi=500,sr=10,lr=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:r}=Si(),[n,a]=ir([Di]),[i,s]=ir(0),l=n[i],d=i>0,m=i<n.length-1,f=Oe(b=>{o(n[b].nodes),r(n[b].edges)},[n,o,r]),c=Oe(()=>{if(i>0){let b=i-1;s(b),f(b)}},[i,f]),h=Oe(()=>{if(i<n.length-1){let b=i+1;s(b),f(b)}},[n,i,f]),u=b=>{let I=[...n.slice(0,i+1),b],A=I.length>sr?I.slice(I.length-sr):I;a(A),s(A.length-1)},v=Li(()=>{let b=e(),w=t(),I={nodes:b,edges:w};JSON.stringify(l)!==JSON.stringify(I)&&u(I)},Pi),g=Oe(b=>{if(b==="forceSave"){v();return}b.some(I=>I.type!=="select")&&v()},[v]),p=Oe(()=>{a([]),s(0)},[]);return{undo:c,redo:h,saveHistory:g,canUndo:d,canRedo:m,clearHistory:p}};import{jsx as dr}from"react/jsx-runtime";var Bt=({id:e,className:t})=>dr("marker",{id:e,className:_("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:dr("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as zt,jsxs as Ri}from"react/jsx-runtime";var cr=()=>zt("svg",{style:{position:"absolute",top:0,left:0},children:Ri("defs",{children:[zt(Bt,{id:"sequence-edge-marker",className:"text-grey-400"}),zt(Bt,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Ar}from"@xyflow/react";import{Button as yt,Tooltip as Tt,TooltipContent as xt,TooltipTrigger as _t,useTranslation as ks}from"lecom-ui";import{HandIcon as Ss,ListCheckIcon as Ls,MapIcon as Ds,MousePointerIcon as Ps}from"lucide-react";import{useCallback as Rs,useEffect as kr}from"react";import{useStore as Mi}from"@xyflow/react";var Vi=e=>({unselectAll:e.unselectNodesAndEdges}),ft=()=>{let{unselectAll:e}=Mi(Vi);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as ss,TooltipContent as ls,TooltipTrigger as ds,useNotificationToast as cs,useTranslation as ps}from"lecom-ui";var Ge=(p=>(p.START_EVENT="START_EVENT",p.END_EVENT="END_EVENT",p.TASK="TASK",p.SUBPROCESS="SUBPROCESS",p.GATEWAY="GATEWAY",p.ANNOTATION="ANNOTATION",p.CONNECTION="CONNECTION",p.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",p.ACTIVITY="ACTIVITY",p.PROCESS_INTERFACE="PROCESS_INTERFACE",p.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",p.VARIANT_ACTIVITY="VARIANT_ACTIVITY",p.AUTO_ACTIVITY="AUTO_ACTIVITY",p.DATA_STORE="DATA_STORE",p.DATA_OBJECT="DATA_OBJECT",p.DATA_OUTPUT="DATA_OUTPUT",p.DATA_INPUT="DATA_INPUT",p))(Ge||{});import{useReactFlow as Ji}from"@xyflow/react";import{useNotificationToast as Qi,useTranslation as es,Button as ts}from"lecom-ui";var pr=async e=>new Promise((t,o)=>{let r=new FileReader;r.onload=n=>{var a;t((a=n.target)==null?void 0:a.result)},r.onerror=n=>{var a;o((a=n.target)==null?void 0:a.error)},r.readAsText(e)});function mr({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let n="data:text/csv;charset=utf-8,"+[e,...t].map(i=>i.join(",")).join(`
3
- `),a=encodeURI(n);ht(a,`${o}.csv`)}var ht=(e,t)=>{let o=document.createElement("a");o.setAttribute("download",t),o.setAttribute("href",e),document.body.appendChild(o),o.click(),document.body.removeChild(o)};import{v7 as Zi}from"uuid";import{xml2json as Oi,json2xml as $u}from"xml-js";var Gi={compact:!0,spaces:4},Hi=e=>e.replaceAll(`
4
- `,"&#xA;");function ur(e,t=Gi){if(e)return JSON.parse(Oi(e,y(E({},t),{attributeValueFn:Hi})))}function gr(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as zi}from"uuid";var e1={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},fr={script:"SCRIPT",subprocess:"SUBPROCESS"},hr={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var xe=({cell:e,type:t,variant:o=""})=>{let{_attributes:r,mxGeometry:n}=e,{value:a}=r,i=Number(n._attributes.width),s=Number(n._attributes.height);return{id:r.id,type:t,data:{label:a||"",variant:o,attribute:""},position:{x:Number(n._attributes.x),y:Number(n._attributes.y)},width:i,height:s,measured:{width:i,height:s}}},Fi=e=>{let{subType:t,style:o}=e._attributes,r="imported";return["none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=V.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=V.START_EVENT.MIN_HEIGHT,{node:xe({cell:e,type:"START_EVENT"}),status:r,originalType:o}},Ui=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,r="imported";return["none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=V.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=V.END_EVENT.MIN_HEIGHT,{node:xe({cell:e,type:"END_EVENT"}),status:r,originalType:o}},Wi=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,r=fr[t],n="imported";return["script","none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=ke(e.mxGeometry._attributes.width,V.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=ke(e.mxGeometry._attributes.height,V.TASK.MIN_HEIGHT),{node:xe({cell:e,type:"TASK",variant:r}),status:n,originalType:o}},Yi=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,r=hr[o],n=["none","inclusive","event-based"],a="imported";return n.includes(o)&&(a="adapted"),e.mxGeometry._attributes.width=V.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=V.GATEWAY.MIN_HEIGHT,{node:xe({cell:e,type:"GATEWAY",variant:r}),status:a,originalType:t}},Ki=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=ke(e.mxGeometry._attributes.width,V.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=ke(e.mxGeometry._attributes.height,V.ANNOTATION.MIN_HEIGHT),{node:xe({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},br=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=V.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=V.UNSUPPORTED.MIN_HEIGHT,{node:xe({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Er=(e,t)=>{let{source:o,target:r}=e._attributes;return y(E({},le),{id:zi(),source:t.get(o)||o,target:t.get(r)||r})},vr={TASK:Wi,GATEWAY:Yi,START_EVENT:Fi,END_EVENT:Ui,ANNOTATION:Ki};var $i=e=>{var i;let t=new Map,o=Object.values(Ge),r=e.filter(s=>{var l;return o.includes((l=s._attributes)==null?void 0:l.type)}),n=[],a=[];for(let s of r){let l=Zi(),{type:d}=s._attributes,m=vr[d]||br;t.set((i=s._attributes)==null?void 0:i.id,l),s._attributes.id=l;let{node:f,status:c,originalType:h}=m(s);n.push(f),a.push({originalType:h,type:f.type,variant:f.data.variant,value:gr(f.data.label),status:c})}return{nodes:n,governanceIdToNodeIdMap:t,summary:a}},qi=(e,t)=>e.filter(n=>{var a;return(a=n._attributes)==null?void 0:a.edge}).map(n=>Er(n,t)),Xi=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:r,summary:n}=$i(t.root.mxCell),a=qi(t.root.mxCell,r);return{nodes:o,edges:a,summary:n}},ji=async e=>{let t=await pr(e),o=ur(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:r,mxGraphModel:n}=o.modeler||{},a=(r==null?void 0:r.app)&&(r==null?void 0:r.diagramType)&&(r==null?void 0:r.version),i=n==null?void 0:n.root;if(!a||!i)throw new Error("INVALID_FILE");if(!Object.keys(n.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:r,mxGraphModel:n}},Nr=async e=>{try{let t=await ji(e),{nodes:o,edges:r,summary:n}=Xi(t)||{};return{nodes:o,edges:r,summary:n}}catch(t){throw t}};import{jsx as os}from"react/jsx-runtime";var yr=()=>{let{t:e}=es(),{toast:t}=Qi(),{setNodes:o,setEdges:r,fitView:n}=Ji(),a=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],d=s.map(m=>[m.originalType,m.value,e(`adapter.governance.report.status.${m.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:os(ts,{size:"small",variant:"ghost",onClick:()=>mr({columns:l,rows:d,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{createDiagram:async s=>{try{let{nodes:l,edges:d,summary:m}=await Nr(s);if(o(c=>c.concat(l)),r(c=>c.concat(d)),n(),m.some(c=>c.status==="unsupported")){a(m);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let d=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${d}`)})}}}};import{Button as rs}from"lecom-ui";import{useRef as ns}from"react";import{Fragment as as,jsx as Tr,jsxs as is}from"react/jsx-runtime";var xr=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:r=!1,onClick:n,onFilesSelected:a}=l,i=be(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let d=ns(null),m=c=>{let h=c.target.files;h!=null&&h.length&&a(h),d.current&&(d.current.value="")};return is(as,{children:[Tr(rs,y(E({onClick:c=>{var h;(h=d.current)==null||h.click(),n==null||n(c)}},i),{children:e})),Tr("input",{type:"file",ref:d,className:"sr-only",accept:t,multiple:o,disabled:r,onChange:m})]})};import{jsx as bt,jsxs as ms}from"react/jsx-runtime";var _r=({disabled:e=!1})=>{let{t}=ps(),{toast:o}=cs(),{createDiagram:r}=yr(),n=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},a=i=>{let s=i[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}r(s)};return ms(ss,{children:[bt(ds,{asChild:!0,children:bt(xr,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:n,onFilesSelected:a,children:bt(ao,{})})}),bt(ls,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{Button as vs,DropdownMenu as Ns,DropdownMenuContent as ys,DropdownMenuItem as Ut,DropdownMenuTrigger as Ts,Tooltip as Et,TooltipContent as vt,TooltipTrigger as Nt,useTranslation as xs}from"lecom-ui";import{FileCodeIcon as _s,FileImageIcon as ws,FolderOutputIcon as Cs,PrinterIcon as Is}from"lucide-react";import{useState as As}from"react";import{useReactFlow as us}from"@xyflow/react";import{toPng as wr,toSvg as gs}from"html-to-image";import{toast as fs,useTranslation as hs}from"lecom-ui";import{useState as bs}from"react";var Es=3,Ft="diagram",Cr=()=>{let{t:e}=hs(),{getNodes:t}=us(),{deselectAll:o}=ft(),[r,n]=bs({png:!1,html:!1,print:!1}),a=()=>{let{x:m,y:f,width:c,height:h}=No(t());return{width:c,height:h,style:{width:`${c}px`,height:`${h}px`,transform:`translate(${-m}px, ${-f}px)`}}},i=async(m,f)=>{n(y(E({},r),{[f]:!0})),await o();try{let c=vo();if(!c)throw new Error("Flow element not found");let h=a();return await m(c,h)}catch(c){fs({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{n(y(E({},r),{[f]:!1}))}};return{exportAsPng:async(m=Ft)=>{await i(async(f,c)=>{let h=await wr(f,y(E({},c),{backgroundColor:"#fcfcfc"}));ht(h,`${m}.png`)},"png")},exportAsHtml:async(m=Ft)=>{await i(async(f,c)=>{let h=await gs(f,y(E({},c),{backgroundColor:"#fcfcfc"})),u=`
1
+ var Gn=Object.defineProperty,Hn=Object.defineProperties;var Bn=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var Qt=Object.prototype.hasOwnProperty,eo=Object.prototype.propertyIsEnumerable;var Jt=(e,t,o)=>t in e?Gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))Qt.call(t,o)&&Jt(e,o,t[o]);if(Ue)for(var o of Ue(t))eo.call(t,o)&&Jt(e,o,t[o]);return e},y=(e,t)=>Hn(e,Bn(t));var fe=(e,t)=>{var o={};for(var r in e)Qt.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&Ue)for(var r of Ue(e))t.indexOf(r)<0&&eo.call(e,r)&&(o[r]=e[r]);return o};import{TooltipProvider as zn,Notification as Fn}from"lecom-ui";import{jsx as Un,jsxs as Wn}from"react/jsx-runtime";function to({children:e}){return Wn(zn,{children:[Un(Fn,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{applyEdgeChanges as bd,Background as hd,MiniMap as Ed,ReactFlow as vd,ReactFlowProvider as Nd,SelectionMode as yd,useEdgesState as Td,useNodesState as xd,useOnSelectionChange as _d,useReactFlow as wd}from"@xyflow/react";import{i18n as Cd}from"lecom-ui";import{useCallback as Yt,useEffect as En,useRef as Id,useState as Ad}from"react";import{useDebouncedCallback as kd}from"use-debounce";var kt=(o=>(o.ACTIVITY="activity",o.ROUTING="routing",o))(kt||{}),St=(r=>(r.START="start",r.END="end",r.BETWEEN="between",r))(St||{});import{RotateCcw as oa,ScrollText as ra,SquarePlus as na}from"lucide-react";import{jsx as We,jsxs as Yn}from"react/jsx-runtime";var Ye=({size:e=24,className:t})=>Yn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[We("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),We("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),We("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),We("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as oo}from"react/jsx-runtime";var be=({size:e=24,className:t})=>oo("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#f87171",stroke:"#ef4444",strokeWidth:3,className:t,children:oo("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ie,jsxs as Kn}from"react/jsx-runtime";var Ke=({size:e=24,className:t})=>Kn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Ie("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Ie("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Ie("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Ie("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ie("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Lt,jsxs as Zn}from"react/jsx-runtime";var he=({size:e=24,className:t})=>Zn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Lt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Lt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Lt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Dt,jsxs as $n}from"react/jsx-runtime";var Ze=({size:e=24,className:t})=>$n("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Dt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Dt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Dt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Pt,jsxs as qn}from"react/jsx-runtime";var ro=({size:e=24,className:t})=>Pt("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:qn("g",{children:[Pt("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),Pt("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Xn}from"clsx";import{twMerge as jn}from"tailwind-merge";function _(...e){return jn(Xn(e))}var Ae=(e,t)=>e<t?t:e;import{jsx as no,jsxs as Jn}from"react/jsx-runtime";var ao=({size:e=24,className:t})=>Jn("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:_("stroke-2",t),children:[no("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),no("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Mt}from"react/jsx-runtime";var io=({size:e=24,className:t})=>Mt("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Mt("g",{children:Mt("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as so}from"react/jsx-runtime";var $e=({size:e=24,className:t})=>so("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:so("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as lo}from"react/jsx-runtime";var ke=({size:e=24,className:t})=>lo("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:_("stroke-2",t),children:lo("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Rt,jsxs as Qn}from"react/jsx-runtime";var co=({size:e=24,className:t})=>Qn("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Rt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Rt("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Rt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Se,jsxs as ea}from"react/jsx-runtime";var po=({size:e=24,className:t})=>ea("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Se("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Se("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Se("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Se("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Se("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as qe,jsxs as ta}from"react/jsx-runtime";var mo=({size:e=24,className:t})=>ta("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[qe("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),qe("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),qe("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),qe("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var D=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(D||{});var Xe={SCRIPT:{icon:ra},SUBPROCESS:{icon:na}};var je={LOOP:{icon:oa}};var Je={EXCLUSIVE:{icon:he},PARALLEL:{icon:Ze},COMPLEX:{icon:Ke}};import fo from"@dagrejs/dagre";import{getNodesBounds as ma}from"@xyflow/react";import{orderBy as ua}from"lodash";var aa={MIN_WIDTH:36,MIN_HEIGHT:36},ia={MIN_WIDTH:36,MIN_HEIGHT:36},sa={MIN_WIDTH:56,MIN_HEIGHT:56},Qe={MIN_WIDTH:176,MIN_HEIGHT:96},et={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},Y={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},tt={MIN_WIDTH:176,MIN_HEIGHT:64},la={MIN_WIDTH:128,MIN_HEIGHT:64},R={START_EVENT:aa,END_EVENT:ia,GATEWAY:sa,TASK:Qe,LANE:Y,ANNOTATION:tt,UNSUPPORTED:la};import{orderBy as da}from"lodash";var oe=e=>{var t,o,r,n,a,i,s,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(n=(r=e.internals)==null?void 0:r.positionAbsolute.y)!=null?n:0,w:(i=(a=e.measured)==null?void 0:a.width)!=null?i:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},re=e=>da(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),uo=(e,t)=>{let{x:o,y:r}=oe(e),{x:n,y:a}=oe(t);return{x:o-n,y:r-a}};var Ee=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:r=[]})=>t.some(n=>n.parentId===e&&(!o.length||o.includes(n.type))&&!r.includes(n.type)),ca=(e,t)=>{let{x:o,y:r}=oe(e),{x:n,y:a}=oe(t),i=o-n,s=r-a;return Math.sqrt(i*i+s*s)},pa=(e,t)=>{let{x:o,y:r,w:n,h:a}=oe(e),{x:i,y:s,w:l,h:d}=oe(t);return o<i+l&&i<o+n&&r<s+d&&s<r+a},Le=(e,t)=>{let o=null,r=1/0;for(let n of t)if(n.id!==e.id&&pa(e,n)){let a=ca(e,n);a<r&&(r=a,o=n)}return o},go=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,r)=>{var n,a;return Math.max(o,(a=(n=r.measured)==null?void 0:n.width)!=null?a:0)},0);var bo=(e=[],t=[],o="LR")=>{let r=new fo.graphlib.Graph;return r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:o}),e.forEach(({id:a,width:i,height:s})=>r.setNode(a,{width:i,height:s})),t.forEach(a=>r.setEdge(a.source,a.target)),fo.layout(r),{nodes:e.map(a=>{let i=r.node(a.id);return y(E({},a),{position:{x:i.x-a.width/2,y:i.y-a.height/2}})}),edges:t}},pe=(e,t)=>{var c,m;let o=[...t],r=o.find(g=>g.id===e);if(!r)return o;let n=o.filter(g=>g.parentId===e&&g.type==="LANE");if(n.length===0)return o;let a=ua(n,["position.y"]),i=Math.max((m=(c=r.measured)==null?void 0:c.width)!=null?m:0,et.MIN_WIDTH),s=go(e,a)||Y.MIN_WIDTH,l=Math.max(i,s),d=0,u=0;a.forEach(g=>{var v,f,p,h;o=o.map(w=>w.id===g.id?y(E({},w),{width:l-Y.HEADER_WIDTH,measured:y(E({},w.measured),{width:l-Y.HEADER_WIDTH}),position:{x:Y.HEADER_WIDTH,y:d}}):w),d+=(f=(v=g.measured)==null?void 0:v.height)!=null?f:0,u+=(h=(p=g.measured)==null?void 0:p.height)!=null?h:0}),o=o.map(g=>g.id===e?y(E({},g),{height:u,width:l,measured:y(E({},g.measured),{height:u,width:l})}):g);let b=o.find(g=>g.id===e);return b!=null&&b.parentId&&(o=pe(b.parentId,o)),o},ho=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},ga=50,Eo=(e,t=ga)=>{let o=ma(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as fa}from"zustand";var O=fa(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as Ao,useReactFlow as ja}from"@xyflow/react";import{BaseEdge as Va,EdgeLabelRenderer as Oa,getStraightPath as Ga,useNodes as Ha,useViewport as Ba}from"@xyflow/react";import{getIncomers as Ea,getOutgoers as va,useReactFlow as Na}from"@xyflow/react";import{Button as ya,Tooltip as Ta,TooltipContent as xa,TooltipTrigger as _a,useTranslation as wa}from"lecom-ui";import{PencilIcon as Ca}from"lucide-react";import{createContext as ba,useContext as ha}from"react";var vo=ba(null),No=vo.Provider,yo=()=>{let e=ha(vo);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as ot,jsxs as Ia}from"react/jsx-runtime";var De=({elementId:e,elementType:t="node"})=>{let{t:o}=wa(),{getNode:r,getEdge:n,getNodes:a,getEdges:i}=Na(),{onConfigureElement:s}=yo(),l=c=>{let m=a(),g=i(),v=Ea(c,m,g),f=va(c,m,g),p=v.some(w=>w.type==="START_EVENT"),h=f.some(w=>w.type==="END_EVENT");return p?"start":h?"end":"between"},d=()=>{var m;let c=r(e);c&&(s==null||s({id:c.id,type:"activity",variant:l(c),label:(m=c.data)==null?void 0:m.label}))},u=()=>{var m;let c=n(e);c&&(s==null||s({id:c.id,type:"routing",label:(m=c.data)==null?void 0:m.label}))};return Ia(Ta,{children:[ot(_a,{asChild:!0,children:ot(ya,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":d();break;case"edge":u();break}},children:ot(Ca,{size:16})})}),ot(xa,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Aa}from"@xyflow/react";import{Button as ka,Tooltip as Sa,TooltipContent as La,TooltipTrigger as Da,useTranslation as Pa}from"lecom-ui";import{TrashIcon as Ma}from"lucide-react";import{jsx as rt,jsxs as Ra}from"react/jsx-runtime";var nt=({elementId:e,elementType:t="node"})=>{let{t:o}=Pa(),{deleteElements:r}=Aa();return Ra(Sa,{children:[rt(Da,{asChild:!0,children:rt(ka,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{r(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:rt(Ma,{size:16})})}),rt(La,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as at}from"react/jsx-runtime";var ve=r=>{var n=r,{edgeId:e,edgeType:t}=n,o=fe(n,["edgeId","edgeType"]);var s;let a=[{component:at(nt,{elementId:e,elementType:"edge"})}],i={SEQUENCE_EDGE:[{component:at(De,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return at("div",y(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(s=i[t])==null?void 0:s.map((l,d)=>at("div",{children:l.component},d))}))};import{jsx as st,jsxs as za}from"react/jsx-runtime";var lt={type:"ANNOTATION_EDGE",zIndex:2e3},To=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:a,targetY:i,selected:s,data:l})=>{let d=Ha(),{zoom:u}=Ba(),b=d.find(h=>h.id===t),c=d.find(h=>h.id===o),[m,g,v]=Ga({sourceX:r,sourceY:n,targetX:a,targetY:i}),f=s||(b==null?void 0:b.selected)||(c==null?void 0:c.selected),p=1/u;return za("g",{className:_("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":f}),children:[st(Va,{id:e,path:m,strokeDasharray:4,className:_("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":f&&!(l!=null&&l.hasError)})}),st(Oa,{children:st("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${v}px)`},children:s&&st(ve,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${p})`}})})})]})};import{BaseEdge as Wa,EdgeLabelRenderer as Ya,getSmoothStepPath as Ka,MarkerType as wo,useNodes as Za,useReactFlow as $a,useViewport as qa}from"@xyflow/react";import{useState as Xa}from"react";import{useEffect as xo,useRef as Fa,useState as Ua}from"react";import{jsx as _o}from"react/jsx-runtime";var U=({value:e,maxLength:t,onChange:o,isEditing:r,onBlur:n,className:a,style:i})=>{let s=Fa(null),[l,d]=Ua(!1);xo(()=>{d(r!=null?r:!1)},[r]),xo(()=>{if(l&&s.current){s.current.focus();let m=document.createRange();m.selectNodeContents(s.current),m.collapse(!1);let g=window.getSelection();g&&(g.removeAllRanges(),g.addRange(m))}},[l]);let u=m=>{m.stopPropagation(),d(!0)},b=m=>{let g=m.currentTarget.innerText;t&&g.length>=t&&m.preventDefault()},c=m=>{d(!1),n==null||n(),o==null||o(m.currentTarget.innerText)};return _o("div",{className:_("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:i,onDoubleClick:u,children:_o("div",{ref:s,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:b,onBlur:c,children:e})})};import{jsx as dt,jsxs as Co}from"react/jsx-runtime";var ae={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:wo.ArrowClosed},markerEnd:{type:wo.Arrow},data:{label:""}},Io=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,data:d,selected:u})=>{let b=Za(),{zoom:c}=qa(),{updateEdgeData:m}=$a(),[g,v]=Xa(!1),f=b.find(x=>x.id===t),p=b.find(x=>x.id===o),[h,w,I]=Ka({sourceX:r,sourceY:n,sourcePosition:s,targetX:a,targetY:i,targetPosition:l}),A=u||(f==null?void 0:f.selected)||(p==null?void 0:p.selected),P=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=g||(d==null?void 0:d.label.trim().length)>0,T=1/c,S=()=>{v(!0)},C=()=>{v(!1)},k=x=>{m(e,{label:x.trim()})};return Co("g",{className:_("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":A}),onBlur:C,onDoubleClick:S,children:[dt(Wa,{id:e,path:h,markerEnd:`url(#${P})`,className:_("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":d==null?void 0:d.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":A&&!(d!=null&&d.hasError)})}),dt(Ya,{children:Co("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${w}px, ${I}px)`},children:[u&&dt(ve,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${T})`}}),N&&dt(U,{value:d==null?void 0:d.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:g,onChange:k})]})})]})};var ko=({setEdges:e})=>{let{getNode:t}=ja();return{isValidConnection:n=>{let a=t(n.source),i=t(n.target);if((a==null?void 0:a.id)===(i==null?void 0:i.id))return!1;switch(a==null?void 0:a.type){case"START_EVENT":return(i==null?void 0:i.type)==="TASK"||(i==null?void 0:i.type)==="END_EVENT"||(i==null?void 0:i.type)==="GATEWAY"||(i==null?void 0:i.type)==="ANNOTATION";case"END_EVENT":return(i==null?void 0:i.type)==="ANNOTATION";case"TASK":return(i==null?void 0:i.type)==="TASK"||(i==null?void 0:i.type)==="END_EVENT"||(i==null?void 0:i.type)==="GATEWAY"||(i==null?void 0:i.type)==="ANNOTATION";case"GATEWAY":return(i==null?void 0:i.type)==="TASK"||(i==null?void 0:i.type)==="END_EVENT"||(i==null?void 0:i.type)==="GATEWAY"||(i==null?void 0:i.type)==="ANNOTATION";case"LANE":return(i==null?void 0:i.type)==="ANNOTATION";default:return!1}},onConnect:n=>{e(a=>{let i=t(n.target);return(i==null?void 0:i.type)==="ANNOTATION"?Ao(E(E({},n),lt),a):Ao(E(E({},n),ae),a)})}}};import{useState as Go}from"react";import{useTranslation as Ja}from"lecom-ui";import{useReactFlow as Qa}from"@xyflow/react";var Pe=(e=[])=>e.filter(t=>t.type==="START_EVENT"),me=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ie=(e=[])=>e.filter(t=>t.type==="TASK")||[],So=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Lo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),pt=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Do=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),q=(e,t=[])=>t.filter(o=>o.source===e),Me=(e,t=[])=>t.filter(o=>o.target===e),Po=(e,t)=>{var r,n;let o=(r=t.nodes)==null?void 0:r.find(a=>a.id===e);return((n=o==null?void 0:o.properties)==null?void 0:n.attribute)==="LOOP"},Mo=(e,t)=>{let o=q(e,t.edges||[]);for(let r of o){let n=(t.nodes||[]).find(a=>a.id===r.target);if(n&&n.type==="END_EVENT")return!0}return!1},Ro=e=>e?/\w/g.test(e.trim()):!1,L=e=>{let{isValid:t,nodeIds:o,edgeIds:r}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&r&&r.length>0?r:[]}},Q=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(r=>!t(r));return{isValid:o.length===0,invalidIds:o.map(r=>r.id)}},Vo=(e=[],t=[])=>({nodes:e.map(o=>{var r;return{id:o.id,type:o.type||"",label:typeof((r=o.data)==null?void 0:r.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Re=[{id:"start_event_not_found",validate:e=>{let t=Pe(e.nodes);return L({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=me(e.nodes);return L({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Pe(e.nodes),o=t.length===1;if(t.length===0)return L({isValid:!0});if(!o)return L({isValid:!1,nodeIds:t.map(a=>a.id)});let r=q(t[0].id,e.edges);if(!(r.length<=1)){let a=[...t.map(i=>i.id),...r.map(i=>i.target)];return L({isValid:!1,nodeIds:[...new Set(a)]})}return L({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ie(e.nodes),o=Q(t,r=>q(r.id,e.edges).length<=2);return L({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ie(e.nodes),o=Q(t,r=>!!r.label&&r.label.trim()!=="");return L({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=ie(e.nodes),r=Q(o,n=>!n.label||n.label.length<=60);return L({isValid:r.isValid,nodeIds:r.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=ie(e.nodes),o=new Map;for(let n of t){if(!n.label)continue;let a=n.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(n))}let r=[];for(let[,n]of o.entries())n.length>1&&n.forEach(a=>r.push(a.id));return L({isValid:r.length===0,nodeIds:r})}},{id:"nested_gateway",validate:e=>{let t=pt(e.nodes),o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&s.type==="GATEWAY"&&(o.push(n.id,s.id),r.push(i.id))}}return L({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"events_nested",validate:e=>{let t=[...Pe(e.nodes),...me(e.nodes)],o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(n.id,s.id),r.push(i.id))}}return L({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=me(e.nodes),o=[],r=[];for(let n of t){let a=Me(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.source);if(s&&s.type==="TASK"){let l=q(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(d=>r.push(d.id)))}}}return L({isValid:o.length===0,nodeIds:o,edgeIds:r})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Do(e.nodes),o=Q(t,n=>q(n.id,e.edges).length<=2),r=o.invalidIds.flatMap(n=>q(n,e.edges).map(a=>a.id));return L({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:r})}},{id:"activity_name_invalid",validate:e=>{let t=ie(e.nodes),o=Q(t,r=>!r.label||Ro(r.label));return L({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var i,s;if(!((i=e==null?void 0:e.nodes)!=null&&i.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return L({isValid:!0});let t=me(e.nodes)[0];if(!t)return L({isValid:!0});let o=Me(t.id,e.edges);if(!o.length)return L({isValid:!0});let n=ie(e.nodes).filter(l=>o.some(d=>d.source===l.id)),a=Q(n,l=>!Po(l.id,e));return L({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=ie(e.nodes),o=me(e.nodes)[0];if(!o)return L({isValid:!0});let r=t.filter(l=>{let d=Me(l.id,e.edges),u=q(l.id,e.edges),b=d.some(m=>{var g;return((g=e.nodes.find(v=>v.id===m.source))==null?void 0:g.type)==="START_EVENT"}),c=u.some(m=>{var g;return((g=e.nodes.find(v=>v.id===m.target))==null?void 0:g.type)==="END_EVENT"});return b&&c}),n=Me(o.id,e.edges),a=n.length>1,i=n.map(l=>l.source),s={isValid:r.length===0&&!a,nodeIds:[...r.map(l=>l.id),...a?i:[]]};return L(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=pt(e.nodes),o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&s.type==="END_EVENT"&&(o.push(n.id,s.id),r.push(i.id))}}return L({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"gateway_missing_output_streams",validate:e=>{let t=pt(e.nodes),o=Q(t,r=>q(r.id,e.edges).length>=1);return L({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Pe(e.nodes),...me(e.nodes)],o=[],r=[];for(let n of t){let a=q(n.id,e.edges);for(let i of a){let s=e.nodes.find(l=>l.id===i.target);s&&s.type==="GATEWAY"&&(o.push(n.id,s.id),r.push(i.id))}}return L({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"script_in_final_activity",validate:e=>{let t=So(e.nodes),o=Q(t,r=>!Mo(r.id,e));return L({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Lo(e.nodes),o=Q(t,r=>{var n,a;return((n=r.properties)==null?void 0:n.subprocessRef)!==void 0&&((a=r.properties)==null?void 0:a.subprocessRef)!==""});return L({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Oo=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let r of Re){let n=r.validate(e);n.isValid||t.push({id:r.id,message:r.id,nodeIds:n.nodeIds||[],edgeIds:n.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var Ho=()=>{let{t:e}=Ja(),[t,o]=Go(null),{setNodes:r,setEdges:n,getNodes:a,getEdges:i}=Qa(),[s,l]=Go(!1);return{validationResult:t,validateDiagram:c=>{let m=Vo(c.nodes,c.edges),g=Oo(m),v=g.errors.map(f=>y(E({},f),{message:e(`validation.errors.${f.id}`)}));return s||l(!0),{isValid:g.isValid,errors:v}},handleValidationComplete:c=>{if(o(c),!c)return;let m=[],g=[];c.errors.forEach(N=>{N.nodeIds&&N.nodeIds.length>0&&N.nodeIds.forEach(T=>m.push(T)),N.edgeIds&&N.edgeIds.length>0&&N.edgeIds.forEach(T=>g.push(T))});let v=[...new Set(m)];r(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:!1})}))),n(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:!1})})));let f=a(),p=i(),h=new Set(v),w=new Set;c.errors.forEach(N=>{var C,k;let T=Re.find(x=>x.id===N.id);(T==null?void 0:T.highlightRelatedEdges)!==!1&&((C=N.edgeIds)==null||C.forEach(x=>w.add(x)),(k=N.nodeIds)==null||k.forEach(x=>{p.forEach(z=>{(z.source===x||z.target===x)&&w.add(z.id)})}))});let I=new Set,A=new Set,P=new Set;f.forEach(N=>{N.type==="START_EVENT"?I.add(N.id):N.type==="END_EVENT"&&A.add(N.id)}),p.forEach(N=>{I.has(N.source)&&P.add(N.target),A.has(N.target)&&P.add(N.source)}),P.forEach(N=>{var T,S;if(h.has(N)){let C=(T=c.errors.find(x=>{var z;return(z=x.nodeIds)==null?void 0:z.includes(N)}))==null?void 0:T.id;((S=Re.find(x=>x.id===C))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(x=>{x.source===N&&A.has(x.target)&&(h.add(x.target),w.add(x.id)),x.target===N&&I.has(x.source)&&(h.add(x.source),w.add(x.id))})}}),h.size>0&&r(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:h.has(T.id)})}))),w.size>0&&n(N=>N.map(T=>y(E({},T),{data:y(E({},T.data),{hasError:w.has(T.id)})})))},clearValidation:()=>{o(null),l(!1),r(c=>c.map(m=>y(E({},m),{data:y(E({},m.data),{hasError:!1})}))),n(c=>c.map(m=>y(E({},m),{data:y(E({},m.data),{hasError:!1})})))},isAutoValidationEnabled:s}};import{useReactFlow as ei}from"@xyflow/react";import{useEffect as ti}from"react";import{v7 as Bo}from"uuid";var oi=15,zo="bpmn:selection",Fo=({offset:e=oi}={})=>{let{getNodes:t,setNodes:o,getEdges:r,setEdges:n}=ei();ti(()=>{let a=s=>{var m;s.preventDefault();let l=t(),d=r(),u=l.filter(g=>g.selected);if(!u.length)return;let b=d.filter(g=>u.some(v=>v.id===g.source)&&u.some(v=>v.id===g.target)),c={nodes:u,edges:b};(m=s.clipboardData)==null||m.setData(zo,JSON.stringify(c))},i=s=>{var c,m;s.preventDefault();let l=JSON.parse(((c=s.clipboardData)==null?void 0:c.getData(zo))||"{}");if(!((m=l.nodes)!=null&&m.length))return;let d=new Map,u=l.nodes.map(g=>{let v=Bo();return d.set(g.id,v),y(E({},g),{id:v,selected:!0,position:{x:g.position.x+e,y:g.position.y+e}})}),b=l.edges.map(g=>y(E({},g),{id:Bo(),selected:!0,source:d.get(g.source)||g.source,target:d.get(g.target)||g.target}));o(g=>[...g.map(v=>y(E({},v),{selected:!1})),...u]),n(g=>[...g.map(v=>y(E({},v),{selected:!1})),...b])};return document.addEventListener("copy",a),document.addEventListener("paste",i),()=>{document.removeEventListener("copy",a),document.removeEventListener("paste",i)}},[t,o,r,n,e])};import{useReactFlow as ui,useStoreApi as gi}from"@xyflow/react";import{v7 as Zo}from"uuid";import{create as ri}from"zustand";var Ne=ri(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as ni,EdgeLabelRenderer as ai,getSmoothStepPath as ii,MarkerType as si,useNodes as li,useReactFlow as di,useViewport as ci}from"@xyflow/react";import{useState as pi}from"react";import{jsx as mt,jsxs as Uo}from"react/jsx-runtime";var Lm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:si.Arrow},data:{label:""}},Wo=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:a,targetY:i,sourcePosition:s,targetPosition:l,data:d,selected:u})=>{let b=li(),{zoom:c}=ci(),{updateEdgeData:m}=di(),[g,v]=pi(!1),f=b.find(x=>x.id===t),p=b.find(x=>x.id===o),[h,w,I]=ii({sourceX:r,sourceY:n,sourcePosition:s,targetX:a,targetY:i,targetPosition:l}),A=u||(f==null?void 0:f.selected)||(p==null?void 0:p.selected),P=A?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=g||(d==null?void 0:d.label.trim().length)>0,T=1/c,S=()=>{v(!0)},C=()=>{v(!1)},k=x=>{m(e,{label:x.trim()})};return Uo("g",{className:_("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":A}),onBlur:C,onDoubleClick:S,children:[mt(ni,{id:e,path:h,markerEnd:`url(#${P})`,strokeDasharray:4,className:_("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":d==null?void 0:d.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":A&&!(d!=null&&d.hasError)})}),mt(ai,{children:Uo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${w}px, ${I}px)`},children:[u&&mt(ve,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${T})`}}),N&&mt(U,{value:d==null?void 0:d.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:g,onChange:k})]})})]})};import{jsx as Yo,jsxs as mi}from"react/jsx-runtime";var Ko=({fromX:e,fromY:t,toX:o,toY:r})=>mi("g",{children:[Yo("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${r} ${e} ${r} ${o},${r}`}),Yo("circle",{cx:o,cy:r,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var $o=({nodes:e,setNodes:t,setEdges:o})=>{let r=gi(),{draggableNode:n,setDraggableNode:a}=Ne(),{getInternalNode:i,screenToFlowPosition:s}=ui(),l=f=>{let p="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(h=>h.map(w=>y(E({},w),{className:w.id===f?p:""})))},d=()=>{let{nodeLookup:f}=r.getState();return Array.from(f.values())},u=f=>{let p=i(f.id),h=d();if(f.type==="LANE"){if(Ee({parentId:f.id,nodes:e,includeTypes:["LANE"]})){l();return}let T=h.filter(k=>k.id!==f.id&&k.type==="LANE"&&!k.parentId),S=Le(p,T);if(!S){l();return}if(Ee({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){l();return}l(S.id);return}let I=h.filter(N=>N.id!==f.id&&N.type==="LANE"),A=Le(p,I);if(!A){l();return}if(Ee({parentId:A.id,nodes:e,includeTypes:["LANE"]})){l();return}l(A.id)},b=f=>{f.preventDefault(),f.dataTransfer.dropEffect="move"},c=(f,p)=>{f.preventDefault(),u(p)},m=(f,p,h)=>{var T,S;let w=C=>C.map(k=>y(E({},k),{className:void 0}));if(f.parentId===p.id){let C=pe(p.id,h);t(re(w(C)));return}if(f.type==="LANE"){if(Ee({parentId:p.id,nodes:h,excludeTypes:["LANE"]}))return;let x=h.filter(V=>V.parentId===p.id).reduce((V,ge)=>{var de,ce;return V+((ce=(de=ge.measured)==null?void 0:de.height)!=null?ce:0)},0),z={x:Y.HEADER_WIDTH,y:x},K=h.map(V=>V.id===f.id?y(E({},V),{parentId:p.id,position:z,className:void 0}):y(E({},V),{className:void 0}));K=pe(p.id,K),t(re(K));return}if(Ee({parentId:p.id,nodes:h,includeTypes:["LANE"]})){let C;if(f.parentId){let x=i(f.parentId),{x:z,y:K}=oe(x);C={x:z+((T=f.position.x)!=null?T:0),y:K+((S=f.position.y)!=null?S:0)}}let k=h.map(x=>x.id===f.id?y(E({},x),{position:C!=null?C:x.position,parentId:void 0,className:void 0}):y(E({},x),{className:void 0}));t(re(k));return}let P=uo(f,p),N=h.map(C=>C.id===f.id?y(E({},C),{parentId:p.id,position:P,className:void 0}):y(E({},C),{className:void 0}));t(re(N))};return{onDragOver:b,onDrop:f=>{if(f.preventDefault(),!(n!=null&&n.type))return;let p=s({x:f.clientX,y:f.clientY}),h={width:R[n.type].MIN_WIDTH,height:R[n.type].MIN_HEIGHT},w={id:Zo(),type:n.type,position:p,measured:h,data:{label:"",variant:n.variant,attribute:n.attribute}},I=y(E({},w),{internals:{positionAbsolute:p}}),A=d(),P=n.type==="LANE",N=A.filter(C=>P?C.type==="LANE"&&!C.parentId:C.type==="LANE"),T=Le(I,N);T?m(I,T,[...A,I]):t(C=>{let k=C.concat(w);return re(k)});let S=f.dataTransfer.getData("sourceId");if(S){let C={id:Zo(),source:S,target:w.id};if(n.type==="ANNOTATION"){o(k=>k.concat(E(E({},C),lt)));return}o(k=>k.concat(E(E({},C),ae)))}a(null)},onNodeDrag:c,onNodeDragStop:async(f,p)=>{var T,S;let{nodeLookup:h}=r.getState(),w=i(p.id),I=Array.from(h.values()),A=p.type==="LANE",P=I.filter(C=>C.id!==p.id&&(A?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=Le(w,P);if(N){m(w,N,I);return}if(p.parentId){let C=i(p.parentId),{x:k,y:x}=oe(C),z={x:k+((T=p.position.x)!=null?T:0),y:x+((S=p.position.y)!=null?S:0)},K=e.map(V=>V.id===p.id?y(E({},V),{position:z,parentId:void 0}):V);K=pe(p.parentId,K),t(re(K))}}}};import{applyNodeChanges as fi}from"@xyflow/react";import{useCallback as bi,useState as Xo}from"react";function qo(e,t,o=5){var l,d,u,b,c,m,g,v;let r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},n=t.find(f=>f.id===e.id);if(!n||!e.position)return r;let a={left:e.position.x,right:e.position.x+((d=(l=n.measured)==null?void 0:l.width)!=null?d:0),top:e.position.y,bottom:e.position.y+((b=(u=n.measured)==null?void 0:u.height)!=null?b:0),width:(m=(c=n.measured)==null?void 0:c.width)!=null?m:0,height:(v=(g=n.measured)==null?void 0:g.height)!=null?v:0},i=o,s=o;return t.filter(f=>f.id!==n.id).reduce((f,p)=>{var k,x,z,K,V,ge,de,ce;let h={left:p.position.x,right:p.position.x+((x=(k=p.measured)==null?void 0:k.width)!=null?x:0),top:p.position.y,bottom:p.position.y+((K=(z=p.measured)==null?void 0:z.height)!=null?K:0),width:(ge=(V=p.measured)==null?void 0:V.width)!=null?ge:0,height:(ce=(de=p.measured)==null?void 0:de.height)!=null?ce:0},w=Math.abs(a.left-h.left);w<s&&(f.snapPosition.x=h.left,f.vertical=h.left,s=w);let I=Math.abs(a.right-h.right);I<s&&(f.snapPosition.x=h.right-a.width,f.vertical=h.right,s=I);let A=Math.abs(a.left-h.right);A<s&&(f.snapPosition.x=h.right,f.vertical=h.right,s=A);let P=Math.abs(a.right-h.left);P<s&&(f.snapPosition.x=h.left-a.width,f.vertical=h.left,s=P);let N=Math.abs(a.top-h.top);N<i&&(f.snapPosition.y=h.top,f.horizontal=h.top,i=N);let T=Math.abs(a.bottom-h.top);T<i&&(f.snapPosition.y=h.top-a.height,f.horizontal=h.top,i=T);let S=Math.abs(a.bottom-h.bottom);S<i&&(f.snapPosition.y=h.bottom-a.height,f.horizontal=h.bottom,i=S);let C=Math.abs(a.top-h.bottom);return C<i&&(f.snapPosition.y=h.bottom,f.horizontal=h.bottom,i=C),f},r)}var jo=()=>{let[e,t]=Xo(void 0),[o,r]=Xo(void 0),n=bi((a,i)=>{var s,l;if(t(void 0),r(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let d=qo(a[0],i);a[0].position.x=(s=d.snapPosition.x)!=null?s:a[0].position.x,a[0].position.y=(l=d.snapPosition.y)!=null?l:a[0].position.y,t(d.horizontal),r(d.vertical)}return fi(a,i)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:n}};import{useReactFlow as Ei}from"@xyflow/react";import{v7 as or}from"uuid";var Qo={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},er={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Jo=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],r=e.match(/(\[.*?\])/)||[],n=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],i="",s="",l="";if(o.length){switch(o[1]){case"<start>":i="start-event";break;case"<end>":i="end-event";break}e=e.replace(o[1],"")}return r.length&&(i="task",s=r[1].replace(/\[|\]/g,""),e=e.replace(r[1],"")),n.length&&(i="gateway-exclusive",s=n[1].replace(/\{|\}/g,""),e=e.replace(n[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:i,label:s}),{step:e,type:i,label:s,edgeLabel:l}},hi=e=>{e=e||"";let t=e.trim().split(`
2
+ `),o={},r=[];return t.forEach(n=>{n=n||"";let a=n.trim().split("-->");if(a.length!==2){console.warn("Invalid number of steps");return}let i=Jo(a[0],o),s=Jo(a[1],o);i&&s&&r.push({sourceId:i.step,targetId:s.step,label:i.edgeLabel||s.edgeLabel||""})}),{components:o,connections:r}},tr=e=>{let{components:t,connections:o}=hi(e);return{nodes:t,edges:o}};var rr=()=>{let{setNodes:e,setEdges:t,fitView:o}=Ei();return{createDiagram:n=>{let{nodes:a,edges:i}=tr(n),s=[],l=new Map;for(let[c,m]of Object.entries(a)){let g=or(),v=Qo[m.type],f=er[m.type];l.set(c,g);let p=R[v].MIN_WIDTH,h=R[v].MIN_HEIGHT;s.push({id:g,type:v,data:{label:m.label||"",variant:f,attribute:""},position:{x:0,y:0},width:p,height:h,measured:{width:p,height:h}})}let d=[];for(let c of i){let m=y(E({},ae),{id:or(),source:l.get(c.sourceId)||c.sourceId,target:l.get(c.targetId)||c.targetId});d.push(m)}let{nodes:u,edges:b}=bo(s,d);e(u),t(b),o()}}};import{useEffect as vi,useCallback as Ni}from"react";var yi={origin:"*",debug:!1};function nr(e,t=yi){let{origin:o,debug:r}=t,n=Ni((a,i)=>{r&&console.debug("[postMessage] sending:",{type:a,payload:i}),window.parent.postMessage({type:a,payload:i},o||"*")},[o,r]);return vi(()=>{let a=i=>{let{type:s,data:l}=i.data||{};r&&console.debug("[postMessage] received:",i.data),s&&e[s]&&e[s](l)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[e,r]),{sendMessage:n}}import{useReactFlow as Ti}from"@xyflow/react";import{useCallback as Ve,useState as ar}from"react";import{useDebouncedCallback as xi}from"use-debounce";var _i={nodes:[],edges:[]},wi=500,ir=10,sr=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:r}=Ti(),[n,a]=ar([_i]),[i,s]=ar(0),l=n[i],d=i>0,u=i<n.length-1,b=Ve(h=>{o(n[h].nodes),r(n[h].edges)},[n,o,r]),c=Ve(()=>{if(i>0){let h=i-1;s(h),b(h)}},[i,b]),m=Ve(()=>{if(i<n.length-1){let h=i+1;s(h),b(h)}},[n,i,b]),g=h=>{let I=[...n.slice(0,i+1),h],A=I.length>ir?I.slice(I.length-ir):I;a(A),s(A.length-1)},v=xi(()=>{let h=e(),w=t(),I={nodes:h,edges:w};JSON.stringify(l)!==JSON.stringify(I)&&g(I)},wi),f=Ve(h=>{if(h==="forceSave"){v();return}h.some(I=>I.type!=="select")&&v()},[v]),p=Ve(()=>{a([]),s(0)},[]);return{undo:c,redo:m,saveHistory:f,canUndo:d,canRedo:u,clearHistory:p}};import{jsx as lr}from"react/jsx-runtime";var Ot=({id:e,className:t})=>lr("marker",{id:e,className:_("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:lr("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Gt,jsxs as Ci}from"react/jsx-runtime";var dr=()=>Gt("svg",{style:{position:"absolute",top:0,left:0},children:Ci("defs",{children:[Gt(Ot,{id:"sequence-edge-marker",className:"text-grey-400"}),Gt(Ot,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Ir}from"@xyflow/react";import{Button as vt,Tooltip as Nt,TooltipContent as yt,TooltipTrigger as Tt,useTranslation as ys}from"lecom-ui";import{HandIcon as Ts,ListCheckIcon as xs,MapIcon as _s,MousePointerIcon as ws}from"lucide-react";import{useCallback as Cs,useEffect as Ar}from"react";import{useStore as Ii}from"@xyflow/react";var Ai=e=>({unselectAll:e.unselectNodesAndEdges}),ut=()=>{let{unselectAll:e}=Ii(Ai);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as Qi,TooltipContent as es,TooltipTrigger as ts,useNotificationToast as os,useTranslation as rs}from"lecom-ui";var Oe=(p=>(p.START_EVENT="START_EVENT",p.END_EVENT="END_EVENT",p.TASK="TASK",p.SUBPROCESS="SUBPROCESS",p.GATEWAY="GATEWAY",p.ANNOTATION="ANNOTATION",p.CONNECTION="CONNECTION",p.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",p.ACTIVITY="ACTIVITY",p.PROCESS_INTERFACE="PROCESS_INTERFACE",p.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",p.VARIANT_ACTIVITY="VARIANT_ACTIVITY",p.AUTO_ACTIVITY="AUTO_ACTIVITY",p.DATA_STORE="DATA_STORE",p.DATA_OBJECT="DATA_OBJECT",p.DATA_OUTPUT="DATA_OUTPUT",p.DATA_INPUT="DATA_INPUT",p))(Oe||{});import{useReactFlow as Wi}from"@xyflow/react";import{useNotificationToast as Yi,useTranslation as Ki,Button as Zi}from"lecom-ui";var cr=async e=>new Promise((t,o)=>{let r=new FileReader;r.onload=n=>{var a;t((a=n.target)==null?void 0:a.result)},r.onerror=n=>{var a;o((a=n.target)==null?void 0:a.error)},r.readAsText(e)});function pr({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let n="data:text/csv;charset=utf-8,"+[e,...t].map(i=>i.join(",")).join(`
3
+ `),a=encodeURI(n);gt(a,`${o}.csv`)}var gt=(e,t)=>{let o=document.createElement("a");o.setAttribute("download",t),o.setAttribute("href",e),document.body.appendChild(o),o.click(),document.body.removeChild(o)};import{v7 as Hi}from"uuid";import{xml2json as ki,json2xml as Gu}from"xml-js";var Si={compact:!0,spaces:4},Li=e=>e.replaceAll(`
4
+ `,"&#xA;");function mr(e,t=Si){if(e)return JSON.parse(ki(e,y(E({},t),{attributeValueFn:Li})))}function ur(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as Pi}from"uuid";var Wu={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},gr={script:"SCRIPT",subprocess:"SUBPROCESS"},fr={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var ye=({cell:e,type:t,variant:o=""})=>{let{_attributes:r,mxGeometry:n}=e,{value:a}=r,i=Number(n._attributes.width),s=Number(n._attributes.height);return{id:r.id,type:t,data:{label:a||"",variant:o,attribute:""},position:{x:Number(n._attributes.x),y:Number(n._attributes.y)},width:i,height:s,measured:{width:i,height:s}}},Mi=e=>{let{subType:t,style:o}=e._attributes,r="imported";return["none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=R.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=R.START_EVENT.MIN_HEIGHT,{node:ye({cell:e,type:"START_EVENT"}),status:r,originalType:o}},Ri=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,r="imported";return["none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=R.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=R.END_EVENT.MIN_HEIGHT,{node:ye({cell:e,type:"END_EVENT"}),status:r,originalType:o}},Vi=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,r=gr[t],n="imported";return["script","none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=Ae(e.mxGeometry._attributes.width,R.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Ae(e.mxGeometry._attributes.height,R.TASK.MIN_HEIGHT),{node:ye({cell:e,type:"TASK",variant:r}),status:n,originalType:o}},Oi=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,r=fr[o],n=["none","inclusive","event-based"],a="imported";return n.includes(o)&&(a="adapted"),e.mxGeometry._attributes.width=R.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=R.GATEWAY.MIN_HEIGHT,{node:ye({cell:e,type:"GATEWAY",variant:r}),status:a,originalType:t}},Gi=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Ae(e.mxGeometry._attributes.width,R.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Ae(e.mxGeometry._attributes.height,R.ANNOTATION.MIN_HEIGHT),{node:ye({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},br=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=R.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=R.UNSUPPORTED.MIN_HEIGHT,{node:ye({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},hr=(e,t)=>{let{source:o,target:r}=e._attributes;return y(E({},ae),{id:Pi(),source:t.get(o)||o,target:t.get(r)||r})},Er={TASK:Vi,GATEWAY:Oi,START_EVENT:Mi,END_EVENT:Ri,ANNOTATION:Gi};var Bi=e=>{var i;let t=new Map,o=Object.values(Oe),r=e.filter(s=>{var l;return o.includes((l=s._attributes)==null?void 0:l.type)}),n=[],a=[];for(let s of r){let l=Hi(),{type:d}=s._attributes,u=Er[d]||br;t.set((i=s._attributes)==null?void 0:i.id,l),s._attributes.id=l;let{node:b,status:c,originalType:m}=u(s);n.push(b),a.push({originalType:m,type:b.type,variant:b.data.variant,value:ur(b.data.label),status:c})}return{nodes:n,governanceIdToNodeIdMap:t,summary:a}},zi=(e,t)=>e.filter(n=>{var a;return(a=n._attributes)==null?void 0:a.edge}).map(n=>hr(n,t)),Fi=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:r,summary:n}=Bi(t.root.mxCell),a=zi(t.root.mxCell,r);return{nodes:o,edges:a,summary:n}},Ui=async e=>{let t=await cr(e),o=mr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:r,mxGraphModel:n}=o.modeler||{},a=(r==null?void 0:r.app)&&(r==null?void 0:r.diagramType)&&(r==null?void 0:r.version),i=n==null?void 0:n.root;if(!a||!i)throw new Error("INVALID_FILE");if(!Object.keys(n.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:r,mxGraphModel:n}},vr=async e=>{try{let t=await Ui(e),{nodes:o,edges:r,summary:n}=Fi(t)||{};return{nodes:o,edges:r,summary:n}}catch(t){throw t}};import{jsx as $i}from"react/jsx-runtime";var Nr=()=>{let{t:e}=Ki(),{toast:t}=Yi(),{setNodes:o,setEdges:r,fitView:n}=Wi(),a=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],d=s.map(u=>[u.originalType,u.value,e(`adapter.governance.report.status.${u.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:$i(Zi,{size:"small",variant:"ghost",onClick:()=>pr({columns:l,rows:d,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{createDiagram:async s=>{try{let{nodes:l,edges:d,summary:u}=await vr(s);if(o(c=>c.concat(l)),r(c=>c.concat(d)),n(),u.some(c=>c.status==="unsupported")){a(u);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let d=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${d}`)})}}}};import{Button as qi}from"lecom-ui";import{useRef as Xi}from"react";import{Fragment as ji,jsx as yr,jsxs as Ji}from"react/jsx-runtime";var Tr=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:r=!1,onClick:n,onFilesSelected:a}=l,i=fe(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let d=Xi(null),u=c=>{let m=c.target.files;m!=null&&m.length&&a(m),d.current&&(d.current.value="")};return Ji(ji,{children:[yr(qi,y(E({onClick:c=>{var m;(m=d.current)==null||m.click(),n==null||n(c)}},i),{children:e})),yr("input",{type:"file",ref:d,className:"sr-only",accept:t,multiple:o,disabled:r,onChange:u})]})};import{jsx as ft,jsxs as ns}from"react/jsx-runtime";var xr=({disabled:e=!1})=>{let{t}=rs(),{toast:o}=os(),{createDiagram:r}=Nr(),n=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},a=i=>{let s=i[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}r(s)};return ns(Qi,{children:[ft(ts,{asChild:!0,children:ft(Tr,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:n,onFilesSelected:a,children:ft(ro,{})})}),ft(es,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{Button as ps,DropdownMenu as ms,DropdownMenuContent as us,DropdownMenuItem as Bt,DropdownMenuTrigger as gs,Tooltip as bt,TooltipContent as ht,TooltipTrigger as Et,useTranslation as fs}from"lecom-ui";import{FileCodeIcon as bs,FileImageIcon as hs,FolderOutputIcon as Es,PrinterIcon as vs}from"lucide-react";import{useState as Ns}from"react";import{useReactFlow as as}from"@xyflow/react";import{toPng as _r,toSvg as is}from"html-to-image";import{toast as ss,useTranslation as ls}from"lecom-ui";import{useState as ds}from"react";var cs=3,Ht="diagram",wr=()=>{let{t:e}=ls(),{getNodes:t}=as(),{deselectAll:o}=ut(),[r,n]=ds({png:!1,html:!1,print:!1}),a=()=>{let{x:u,y:b,width:c,height:m}=Eo(t());return{width:c,height:m,style:{width:`${c}px`,height:`${m}px`,transform:`translate(${-u}px, ${-b}px)`}}},i=async(u,b)=>{n(y(E({},r),{[b]:!0})),await o();try{let c=ho();if(!c)throw new Error("Flow element not found");let m=a();return await u(c,m)}catch(c){ss({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{n(y(E({},r),{[b]:!1}))}};return{exportAsPng:async(u=Ht)=>{await i(async(b,c)=>{let m=await _r(b,y(E({},c),{backgroundColor:"#fcfcfc"}));gt(m,`${u}.png`)},"png")},exportAsHtml:async(u=Ht)=>{await i(async(b,c)=>{let m=await is(b,y(E({},c),{backgroundColor:"#fcfcfc"})),g=`
5
5
  <!DOCTYPE html>
6
6
  <html>
7
7
  <head>
8
- <title>${m}</title>
8
+ <title>${u}</title>
9
9
  <style>
10
10
  body { margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #eee; }
11
11
  img { max-width: 95%; max-height: 95vh; background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
12
12
  </style>
13
13
  </head>
14
14
  <body>
15
- <img src="${h}" alt="Diagram" />
15
+ <img src="${m}" alt="Diagram" />
16
16
  </body>
17
17
  </html>
18
- `,v=new Blob([u],{type:"text/html"}),g=URL.createObjectURL(v);ht(g,`${m}.html`),setTimeout(()=>URL.revokeObjectURL(g),100)},"html")},printDiagram:async(m=Ft)=>{await i(async(f,c)=>{let h=await wr(f,y(E({},c),{pixelRatio:Es})),u=window.open("","_blank");if(!u)throw new Error("Failed to open print window.");let v=u.document;v.open(),v.write(`
18
+ `,v=new Blob([g],{type:"text/html"}),f=URL.createObjectURL(v);gt(f,`${u}.html`),setTimeout(()=>URL.revokeObjectURL(f),100)},"html")},printDiagram:async(u=Ht)=>{await i(async(b,c)=>{let m=await _r(b,y(E({},c),{pixelRatio:cs})),g=window.open("","_blank");if(!g)throw new Error("Failed to open print window.");let v=g.document;v.open(),v.write(`
19
19
  <!DOCTYPE html>
20
20
  <html>
21
21
  <head>
22
- <title>${m}</title>
22
+ <title>${u}</title>
23
23
  <style>
24
24
  @page { size: auto; margin: 0mm; }
25
25
  @media print { body { margin: 0; } img { width: 100%; height: auto; vertical-align: middle; } }
@@ -28,7 +28,7 @@ var Wn=Object.defineProperty,Yn=Object.defineProperties;var Kn=Object.getOwnProp
28
28
  </style>
29
29
  </head>
30
30
  <body>
31
- <img src="${h}" alt="Diagram" onload="window.print(); window.close();" />
31
+ <img src="${m}" alt="Diagram" onload="window.print(); window.close();" />
32
32
  </body>
33
33
  </html>
34
- `),v.close()},"print")},isPrintingPng:r.png,isPrintingHtml:r.html,isPrinting:r.print}};import{jsx as G,jsxs as _e}from"react/jsx-runtime";function Ir(){let{t:e}=xs(),{exportAsPng:t,exportAsHtml:o,printDiagram:r,isPrinting:n,isPrintingPng:a,isPrintingHtml:i}=Cr(),[s,l]=As(!1);return _e(Ns,{modal:!1,open:s,onOpenChange:l,children:[G(Ts,{asChild:!0,children:G("div",{children:_e(Et,{children:[G(Nt,{asChild:!0,children:G(vs,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:G(Cs,{})})}),!s&&G(vt,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),_e(ys,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[_e(Et,{children:[G(Nt,{asChild:!0,children:G(Ut,{className:"p-1.5",disabled:a,onClick:()=>t(),children:G(ws,{})})}),G(vt,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),_e(Et,{children:[G(Nt,{asChild:!0,children:G(Ut,{className:"p-1.5",disabled:i,onClick:()=>o(),children:G(_s,{})})}),G(vt,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),_e(Et,{children:[G(Nt,{asChild:!0,children:G(Ut,{className:"p-1.5",disabled:n,onClick:()=>r(),children:G(Is,{})})}),G(vt,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Ms,jsx as H,jsxs as ce}from"react/jsx-runtime";var Sr=({nodes:e,isReadOnly:t,diagram:o,onValidationComplete:r,onValidateDiagram:n})=>{let{t:a}=ks(),{deselectAll:i}=ft(),{isMoveTool:s,isHandTool:l,activeMoveTool:d,activeHandTool:m,isMinimapOpen:f,setIsMinimapOpen:c}=O(),h=Ar(["v","V"]),u=Ar(["h","H"]),v=Rs(()=>{i(),m()},[i,m]),g=()=>{i();let p=n(o);r&&r(p)};return kr(()=>{h&&!s&&!t&&d()},[h,d,s,t]),kr(()=>{u&&!l&&!t&&v()},[u,v,l,t]),ce("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&ce(Ms,{children:[ce(Tt,{children:[H(_t,{asChild:!0,children:H(yt,{size:"small",variant:"ghost",color:"grey",className:_(s&&"bg-grey-400"),iconButton:!0,onClick:d,children:H(Ps,{})})}),ce(xt,{color:"black",children:[a("editor.controls.actions.move_tool"),H("span",{className:"ml-1 text-grey-400",children:"V"})]})]}),ce(Tt,{children:[H(_t,{asChild:!0,children:H(yt,{size:"small",variant:"ghost",color:"grey",className:_(l&&"bg-grey-400"),iconButton:!0,onClick:v,children:H(Ss,{})})}),ce(xt,{color:"black",children:[a("editor.controls.actions.hand_tool")," ",H("span",{className:"ml-2 text-grey-400",children:"H"})]})]}),ce(Tt,{children:[H(_t,{asChild:!0,children:H(yt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:g,children:H(Ls,{})})}),H(xt,{color:"black",children:a("editor.controls.actions.check")})]})]}),H(Ir,{}),!t&&H(_r,{disabled:e.length>0}),ce(Tt,{children:[H(_t,{asChild:!0,children:H(yt,{size:"small",variant:"ghost",color:"grey",className:_(f&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!f),children:H(Ds,{})})}),H(xt,{color:"black",children:a(f?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Lr,Tooltip as Dr,TooltipContent as Pr,TooltipTrigger as Rr,useTranslation as Vs}from"lecom-ui";import{RedoIcon as Os,UndoIcon as Gs}from"lucide-react";import{jsx as pe,jsxs as Wt}from"react/jsx-runtime";var Mr=({undo:e,redo:t,canUndo:o,canRedo:r})=>{let{t:n}=Vs();return Wt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Wt(Dr,{children:[pe(Rr,{asChild:!0,children:pe(Lr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:pe(Gs,{})})}),pe(Pr,{color:"black",children:n("editor.controls.history.undo")})]}),Wt(Dr,{children:[pe(Rr,{asChild:!0,children:pe(Lr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!r,onClick:t,children:pe(Os,{})})}),pe(Pr,{color:"black",children:n("editor.controls.history.redo")})]})]})};import{useReactFlow as Hs}from"@xyflow/react";import{Button as wt,Tooltip as Ct,TooltipContent as It,TooltipTrigger as At,useTranslation as Bs}from"lecom-ui";import{ScanIcon as zs,ZoomIn as Fs,ZoomOut as Us}from"lucide-react";import{jsx as W,jsxs as He}from"react/jsx-runtime";var Vr=()=>{let{t:e}=Bs(),{zoomIn:t,zoomOut:o,zoomTo:r,fitView:n}=Hs();return He("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[He(Ct,{children:[W(At,{asChild:!0,children:W(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(),children:W(zs,{})})}),W(It,{color:"black",children:e("editor.controls.zoom.fit")})]}),He(Ct,{children:[W(At,{asChild:!0,children:W(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:W(Us,{})})}),W(It,{color:"black",children:e("editor.controls.zoom.out")})]}),He(Ct,{children:[W(At,{asChild:!0,children:W(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(1),children:W(lo,{})})}),W(It,{color:"black",children:e("editor.controls.zoom.reset")})]}),He(Ct,{children:[W(At,{asChild:!0,children:W(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:W(Fs,{})})}),W(It,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Position as Ll,useReactFlow as Dl}from"@xyflow/react";import{Handle as Ws}from"@xyflow/react";import{jsx as Ys}from"react/jsx-runtime";var B=({type:e,position:t,className:o})=>Ys(Ws,{type:e,position:t,className:_("size-2.5 border border-grey-400 bg-white",o)});import{NodeResizer as Ks,useReactFlow as Zs}from"@xyflow/react";import{orderBy as $s}from"lodash";import{jsx as qs}from"react/jsx-runtime";var we=o=>{var r=o,{nodeId:e}=r,t=be(r,["nodeId"]);let{getNode:n,getNodes:a,setNodes:i}=Zs(),s=({width:l,height:d})=>{if(!e)return;let m=n(e);if((m==null?void 0:m.type)!=="LANE")return;let f=[...a()],c=!m.parentId,h=c?m.id:m.parentId,u=f.filter(p=>p.type==="LANE"&&p.parentId===h);if(!u.length)return;let v=$s(u,["position.y"]),g=0;v.forEach((p,b)=>{var A,R;let w=b===v.length-1,I=(R=(A=p.measured)==null?void 0:A.height)!=null?R:0;f=f.map(N=>{if(N.id===p.id){let T=c?l-Y.HEADER_WIDTH:l,S=y(E({},N),{width:T,measured:y(E({},N.measured),{width:T}),position:y(E({},N.position),{y:g})});return w&&c&&(S.height=d-g),S}return N}),g+=I}),f=f.map(p=>{if(p.id===h){let b=c?l:l+Y.HEADER_WIDTH;return y(E({},p),{width:b,height:c?d:g,measured:{width:b,height:c?d:g}})}return p}),i(f)};return qs(Ks,E({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",onResizeEnd:(l,d)=>s(d)},t))};import{Position as xl,NodeToolbar as _l}from"@xyflow/react";import{Button as wl,Tooltip as Cl,TooltipContent as Il,TooltipTrigger as Al,useTranslation as kl}from"lecom-ui";import{useNodesData as Xs,useReactFlow as js}from"@xyflow/react";import{Button as Js,DropdownMenu as Qs,DropdownMenuContent as el,DropdownMenuGroup as tl,DropdownMenuItem as ol,DropdownMenuLabel as rl,DropdownMenuTrigger as nl,Tooltip as al,TooltipContent as il,TooltipTrigger as sl,useTranslation as ll}from"lecom-ui";import{WrenchIcon as dl}from"lucide-react";import{jsx as ie,jsxs as kt}from"react/jsx-runtime";var Or=({nodeId:e})=>{let{t}=ll(),{updateNodeData:o}=js(),r=Xs(e),n=a=>{(r==null?void 0:r.data.variant)!==a&&o(e,{variant:a})};return kt(Qs,{children:[kt(al,{children:[ie(sl,{asChild:!0,children:ie(nl,{asChild:!0,children:ie(Js,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:ie(dl,{})})})}),ie(il,{color:"black",children:t("bpmn.gateway.menu.title")})]}),kt(el,{align:"start",className:"w-60 bg-white text-grey-600",children:[ie(rl,{className:"flex items-center",children:ie("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.gateway.menu.title")})}),ie(tl,{children:Object.entries(Qe).map(([a,i])=>kt(ol,{className:_({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.variant)===a}),onClick:()=>n(a),children:[ie(i.icon,{className:"stroke-current"}),t(`bpmn.gateway.variant.${a.toLowerCase()}`)]},a))})]})]})};import{useNodesData as cl,useReactFlow as pl}from"@xyflow/react";import{Button as Gr,DropdownMenu as ml,DropdownMenuContent as ul,DropdownMenuGroup as gl,DropdownMenuItem as fl,DropdownMenuLabel as hl,DropdownMenuTrigger as bl,Tooltip as El,TooltipContent as vl,TooltipTrigger as Nl,useTranslation as yl}from"lecom-ui";import{WrenchIcon as Tl}from"lucide-react";import{jsx as X,jsxs as Be}from"react/jsx-runtime";var Hr=({nodeId:e})=>{let{t}=yl(),{updateNodeData:o}=pl(),r=cl(e),n=i=>{o(e,{variant:(r==null?void 0:r.data.variant)===i?"":i})},a=i=>{o(e,{attribute:(r==null?void 0:r.data.attribute)===i?"":i})};return Be(ml,{children:[Be(El,{children:[X(Nl,{asChild:!0,children:X(bl,{asChild:!0,children:X(Gr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:X(Tl,{})})})}),X(vl,{color:"black",children:t("bpmn.task.menu.title")})]}),Be(ul,{align:"start",className:"w-60 bg-white text-grey-600",children:[Be(hl,{className:"flex items-center gap-1",children:[X("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),X("div",{className:"flex items-center gap-1",children:Object.entries(Je).map(([i,s])=>X(Gr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,className:_({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.attribute)===i}),onClick:()=>a(i),children:X(s.icon,{className:"stroke-inherit"})},i))})]}),X(gl,{children:Object.entries(je).map(([i,s])=>Be(fl,{className:_({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.variant)===i}),onClick:()=>n(i),children:[X(s.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${i.toLowerCase()}`)]},i))})]})]})};import{jsx as j,jsxs as Sl}from"react/jsx-runtime";var Z=({nodeId:e,nodeType:t,isChild:o,isVisible:r})=>{var m;let{t:n}=kl(),{setDraggableNode:a}=Te(),i=({event:f,type:c,variant:h})=>{a({type:c,variant:h}),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("sourceId",e)},s={START_EVENT:{type:"START_EVENT",icon:Se,label:n("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:Ee,label:n("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:Se,label:n("bpmn.task.variant.default")},GATEWAY:{type:"GATEWAY",variant:"EXCLUSIVE",icon:ve,label:n("bpmn.gateway.variant.exclusive")},ANNOTATION:{type:"ANNOTATION",icon:Ke,label:n("bpmn.annotation.variant.default")}},l=[{component:j(it,{elementId:e})}],d={START_EVENT:[s.TASK,s.ANNOTATION,...l],TASK:[{component:j(Pe,{elementId:e})},{component:j(Hr,{nodeId:e})},s.TASK,s.GATEWAY,s.END_EVENT,s.ANNOTATION,...l],GATEWAY:[{component:j(Pe,{elementId:e})},{component:j(Or,{nodeId:e})},s.TASK,s.GATEWAY,s.ANNOTATION,...l],END_EVENT:[s.ANNOTATION,...l],LANE:[...o?[]:[s.ANNOTATION],...l],ANNOTATION:[...l],UNSUPPORTED:[...l]};return j(_l,{className:"-top-6 flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",position:xl.Right,align:"start",isVisible:r,children:(m=d[t])==null?void 0:m.map((f,c)=>f.component?j("div",{children:f.component},c):Sl(Cl,{children:[j(Al,{asChild:!0,children:j(wl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!0,onDragStart:h=>i({event:h,type:f.type,variant:f.variant}),children:f.icon&&j(f.icon,{size:16})})}),j(Il,{color:"black",children:f.label})]},c))})};import{Fragment as Pl,jsx as ze,jsxs as Rl}from"react/jsx-runtime";var Br=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Dl(),{isMultipleSelection:a}=O(),i=s=>{n(e,{label:s})};return Rl(Pl,{children:[ze("div",{className:_("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm overflow-hidden border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"text-blue-500 hover:text-blue-600 shadow-md":o,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:ze(U,{value:t.label,className:"m-1 text-grey-600",onChange:i})}),ze(Z,{nodeId:e,nodeType:"ANNOTATION",isVisible:!r&&!a&&o}),ze(we,{isVisible:!r&&!a&&o,minWidth:ot.MIN_WIDTH,minHeight:ot.MIN_HEIGHT}),ze(B,{type:"target",position:Ll.Left})]})};import{Position as zr,useReactFlow as Ml}from"@xyflow/react";import{useState as Vl}from"react";import{Fragment as Ol,jsx as Ce,jsxs as Fr}from"react/jsx-runtime";var Ur=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Ml(),{isMultipleSelection:a}=O(),[i,s]=Vl(!1),l=f=>{n(e,{label:f})};return Fr(Ol,{children:[Fr("div",{className:"relative",onBlur:()=>{s(!1)},onDoubleClick:()=>{s(!0)},children:[Ce(Ee,{className:_("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Ce("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ce(U,{value:t.label,isEditing:i,onChange:l})})]}),Ce(Z,{nodeId:e,nodeType:"END_EVENT",isVisible:!r&&!a&&o}),Ce(B,{type:"source",position:zr.Right}),Ce(B,{type:"target",position:zr.Left})]})};import{Position as Wr,useReactFlow as Gl}from"@xyflow/react";import{useState as Hl}from"react";import{Fragment as Bl,jsx as Ie,jsxs as Yr}from"react/jsx-runtime";var Kr=({id:e,data:t,selected:o,dragging:r})=>{let n=Qe[t.variant].icon,{updateNodeData:a}=Gl(),{isMultipleSelection:i}=O(),[s,l]=Hl(!1),d=c=>{a(e,{label:c})};return Yr(Bl,{children:[Yr("div",{className:"relative",onBlur:()=>{l(!1)},onDoubleClick:()=>{l(!0)},children:[Ie(n,{className:_("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),Ie("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ie(U,{value:t.label,isEditing:s,onChange:d})})]}),Ie(Z,{nodeId:e,nodeType:"GATEWAY",isVisible:!r&&!i&&o}),Ie(B,{type:"target",position:Wr.Left}),Ie(B,{type:"source",position:Wr.Right})]})};import{Position as zl,useReactFlow as Fl}from"@xyflow/react";import{useState as Ul}from"react";import{Fragment as Wl,jsx as Fe,jsxs as Zr}from"react/jsx-runtime";var $r=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Fl(),{isMultipleSelection:a}=O(),[i,s]=Ul(!1),l=f=>{n(e,{label:f})};return Zr(Wl,{children:[Zr("div",{className:"relative",onBlur:()=>{s(!1)},onDoubleClick:()=>{s(!0)},children:[Fe(qe,{className:_("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),Fe("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Fe(U,{value:t.label,isEditing:i,onChange:l})})]}),Fe(Z,{nodeId:e,nodeType:"START_EVENT",isVisible:!r&&!a&&o}),Fe(B,{type:"source",position:zl.Right})]})};import{Position as qr,useReactFlow as Yl}from"@xyflow/react";import{Fragment as Kl,jsx as ee,jsxs as Xr}from"react/jsx-runtime";var jr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Yl(),{isMultipleSelection:a}=O(),i=c=>{n(e,{label:c})},s=t.variant?je[t.variant].icon:null,l=t.attribute?Je[t.attribute].icon:null,d=t.variant==="SUBPROCESS",m=s&&!d,f=l||d;return Xr(Kl,{children:[Xr("div",{className:_("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md overflow-hidden hover:shadow-md transition-colors duration-75",{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[ee(U,{value:t.label,className:_("m-1",{"py-6":m||f}),onChange:i}),s&&ee("div",{className:_("absolute flex items-center p-1",d?"bottom-0":"top-0 left-0"),children:ee(s,{size:16,className:_(t.hasError?"text-red-500":"text-grey-500")})}),l&&ee("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ee("div",{className:_("flex items-center w-16 p-1",d?"justify-between":"justify-center"),children:ee(l,{size:16,className:_(t.hasError?"text-red-500":"text-grey-500")})})})]}),ee(Z,{nodeId:e,nodeType:"TASK",isVisible:!r&&!a&&o}),ee(we,{isVisible:!r&&!a&&o,minWidth:et.MIN_WIDTH,minHeight:et.MIN_HEIGHT}),ee(B,{type:"source",position:qr.Right}),ee(B,{type:"target",position:qr.Left})]})};import{Position as Jr}from"@xyflow/react";import{Fragment as Zl,jsx as St,jsxs as $l}from"react/jsx-runtime";var Qr=({id:e,data:t,selected:o,dragging:r})=>{let{isMultipleSelection:n}=O();return $l(Zl,{children:[St("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),St(Z,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!r&&!n&&o}),St(B,{type:"source",position:Jr.Right}),St(B,{type:"target",position:Jr.Left})]})};import{Position as ql,useReactFlow as Xl}from"@xyflow/react";import{orderBy as jl}from"lodash";import{useMemo as en}from"react";import{Fragment as Jl,jsx as fe,jsxs as tn}from"react/jsx-runtime";var on=({id:e,data:t,selected:o,dragging:r,parentId:n})=>{let{updateNodeData:a,getNodes:i}=Xl(),{isMultipleSelection:s}=O(),l=i(),d=!n,m=en(()=>jl([...l.filter(u=>u.parentId===e&&u.type==="LANE")],"position.y","asc"),[l,e]),f=d?tt.MIN_WIDTH:Y.MIN_WIDTH,c=en(()=>{if(d&&m.length>1){let u=[...m];return u.pop(),u.reduce((g,p)=>{var b,w;return g+((w=(b=p.measured)==null?void 0:b.height)!=null?w:0)},0)+Y.MIN_HEIGHT}return Y.MIN_HEIGHT},[d,m]),h=u=>{a(e,{label:u})};return tn(Jl,{children:[tn("div",{className:_("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[fe("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",children:fe("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:fe(U,{value:t.label,className:"w-full h-full",onChange:h})})}),fe("div",{className:"flex-1"})]}),fe(Z,{nodeId:e,nodeType:"LANE",isChild:!d,isVisible:!r&&!s&&o}),fe(we,{nodeId:e,minWidth:f,minHeight:c,isVisible:!r&&!s&&o}),d&&fe(B,{type:"source",position:ql.Right})]})};var rn={START_EVENT:$r,END_EVENT:Ur,TASK:jr,GATEWAY:Kr,ANNOTATION:Br,LANE:on,UNSUPPORTED:Qr},nn={SEQUENCE_EDGE:Ao,MESSAGE_EDGE:Yo,ANNOTATION_EDGE:xo},an="#fafafa",sn="#bebebe",ln=1,dn=10,cn="bottom-left",pn=.5,mn=4,un={x:0,y:0,zoom:.75};import{useStore as Ql}from"@xyflow/react";import{useEffect as ed,useRef as td}from"react";import{jsx as rd}from"react/jsx-runtime";var od=e=>({width:e.width,height:e.height,transform:e.transform}),gn=({horizontal:e,vertical:t,color:o="#3367d9",dashArray:r=[6,6]})=>{let{width:n,height:a,transform:i}=Ql(od),s=td(null);return ed(()=>{let l=s.current,d=l==null?void 0:l.getContext("2d");if(!d||!l)return;let m=window.devicePixelRatio;l.width=n*m,l.height=a*m,d.scale(m,m),d.clearRect(0,0,n,a),d.strokeStyle=o,d.setLineDash(r),typeof t=="number"&&(d.moveTo(t*i[2]+i[0],0),d.lineTo(t*i[2]+i[0],a),d.stroke()),typeof e=="number"&&(d.moveTo(0,e*i[2]+i[1]),d.lineTo(n,e*i[2]+i[1]),d.stroke())},[n,a,i,e,t,o,r]),rd("canvas",{ref:s,className:"react-flow__canvas w-full h-full absolute z-10 pointer-events-none"})};import{Button as fn,Dialog as nd,DialogContent as ad,DialogFooter as id,DialogHeader as sd,DialogTitle as ld,Notification as dd,Typography as Yt,useTranslation as cd}from"lecom-ui";import{jsx as te,jsxs as Kt}from"react/jsx-runtime";var hn=({pendingDelete:e,setPendingDelete:t,setNodes:o,setEdges:r})=>{let{t:n}=cd(),a=!!e,i=()=>{let{nodes:l,edges:d}=e||{};l!=null&&l.length&&o(m=>m.filter(f=>!l.some(c=>c.id===f.id))),d!=null&&d.length&&r(m=>m.filter(f=>!d.some(c=>c.id===f.id))),t(null)},s=()=>{t(null)};return te(nd,{open:a,onOpenChange:s,children:Kt(ad,{className:"w-[488px] max-w-fit gap-2",children:[te(sd,{children:te(ld,{children:te(Yt,{variant:"heading-small-600",textColor:"text-grey-950",children:n("editor.modals.delete_elements.title")})})}),Kt("div",{className:"flex flex-col gap-2",children:[te("div",{className:"py-2",children:te(dd,{type:"callout",variant:"warning",content:n("editor.modals.delete_elements.callout")})}),te(Yt,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:n("editor.modals.delete_elements.content")})]}),Kt(id,{className:"flex items-center flex-row justify-end w-full gap-2",children:[te(fn,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:s,children:te(Yt,{variant:"body-medium-500",textColor:"text-grey-800",children:n("editor.modals.delete_elements.cancel")})}),te(fn,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:i,children:n("editor.modals.delete_elements.confirm")})]})]})})};import{Button as pd,Tooltip as md,TooltipContent as ud,TooltipTrigger as gd,useTranslation as fd}from"lecom-ui";import{jsx as Ue,jsxs as hd}from"react/jsx-runtime";var bn=()=>{let{t:e}=fd(),{setDraggableNode:t}=Te(),o=[{type:"START_EVENT",icon:qe,label:e("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Ee,label:e("bpmn.end_event.variant.default")},{type:"TASK",icon:Se,label:e("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:go,label:e("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:uo,label:e("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:mo,label:e("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:ve,label:e("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:$e,label:e("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Ze,label:e("bpmn.gateway.variant.complex")},{type:"LANE",icon:so,label:e("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Ke,label:e("bpmn.annotation.variant.default")}],r=(n,a)=>{t({type:a.type,variant:a.variant,attribute:a.attribute}),n.dataTransfer.effectAllowed="move"};return Ue("aside",{className:"sidebar absolute z-[1] top-4 left-4 grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:o.map((n,a)=>hd(md,{children:[Ue(gd,{asChild:!0,children:Ue(pd,{className:"[&>svg]:size-6",size:"small",variant:"ghost",color:"grey",draggable:!0,iconButton:!0,onDragStart:i=>r(i,n),children:Ue(n.icon,{})},a)}),Ue(ud,{color:"black",side:"right",children:n.label})]},a))})};import{Button as bd,useTranslation as Ed}from"lecom-ui";import{AlertCircleIcon as vd,CircleCheckIcon as Nd,XIcon as yd}from"lucide-react";import{useEffect as Td,useState as xd}from"react";import{jsx as J,jsxs as Zt}from"react/jsx-runtime";var En=({validationResult:e,onClose:t})=>{let{t:o}=Ed(),[r,n]=xd(!1);if(Td(()=>{e&&n(!0)},[e]),!r||!e)return null;let{isValid:a,errors:i}=e;return Zt("div",{className:_("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":a,"bg-red-100":!a}),children:[Zt("div",{className:"flex flex-row items-start gap-4",children:[J("div",{className:"flex-shrink-0",children:a?J(Nd,{className:"text-green-500 size-5"}):J(vd,{className:"text-red-500 size-5"})}),Zt("div",{className:"body-medium-500 text-grey-800",children:[J("div",{children:o(a?"validation.success.title":"validation.errors.title")}),!a&&J("div",{children:o("validation.errors.subtitle")})]}),J(bd,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{n(!1),t()},children:J(yd,{})})]}),J("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:a?J("p",{children:o("validation.success.message")}):J("div",{className:"list-disc list-inside",children:i.map(s=>J("li",{className:"mb-1",children:s.message},s.id))})})]})};import{jsx as $,jsxs as $t}from"react/jsx-runtime";var Bd=[],zd=({mode:e="edit"})=>{let t=Od(!1),[o,r]=Pd([]),[n,a]=Dd([]),[i,s]=Gd(null),{isMoveTool:l,isHandTool:d,isReadOnly:m,setIsReadOnly:f,setIsMultipleSelection:c,isMinimapOpen:h}=O(),{validationResult:u,handleValidationComplete:v,clearValidation:g,isAutoValidationEnabled:p,validateDiagram:b}=Bo(),{getNode:w,getEdges:I,getNodes:A}=Md(),{onNodeSelected:R,onEdgeSelected:N}=rt(),{onNodeDrag:T,onDrop:S,onDragOver:C,onNodeDragStop:k}=qo({nodes:o,setNodes:r,setEdges:a}),{isValidConnection:x,onConnect:z}=So({setEdges:a});Uo();let{createDiagram:K}=nr(),{undo:F,redo:he,saveHistory:oe,canUndo:me,canRedo:In}=lr(),{helperLineHorizontal:An,helperLineVertical:kn,customApplyNodeChanges:Sn}=Jo();ar({LIA_CREATE_DIAGRAM:K,CLEAR_DIAGRAM:()=>{r([]),a([])}}),vn(()=>{f(e==="readonly")},[e,f]);let Ln=()=>{g()},jt=Lt(M=>{let L=A(),se=I(),re=Cd(M,L,se),zn=Id(M,L,se),Fn=re.some(Dt=>Dt.type==="START_EVENT"),Un=zn.some(Dt=>Dt.type==="END_EVENT");return Fn?"start":Un?"end":"between"},[A,I]),Dn=Lt(({nodes:M,edges:L})=>{let se=M.length+L.length>1;if(c(se),M.length===1&&L.length===0){let re=M[0];R==null||R({id:re.id,type:"activity",variant:jt(re)})}else if(L.length===1&&M.length===0){let re=L[0];N==null||N({id:re.id,type:"routing"})}},[c,R,N,jt]);Rd({onChange:Dn});let Pn=M=>{let L=w(M.id);if(L!=null&&L.parentId&&(L==null?void 0:L.type)==="LANE"){let se=ue(L.parentId,o.filter(re=>re.id!==L.id&&re.type==="LANE"));r(ae(se))}},Rn=M=>{M.forEach(L=>{switch(L.type){case"remove":Pn(L);break}})},Mn=Lt(()=>{if(!p){t.current=!1;return}let M=A(),L=I(),se=b({nodes:M,edges:L});v(se),t.current=!1},[p,A,I,b,v]),Jt=Hd(Mn,300),Qt=Lt(()=>{p&&!t.current&&(t.current=!0,Jt())},[p,Jt]),Vn=M=>{r(L=>Sn(M,L)),oe(M),Qt(),Rn(M)},On=M=>{a(L=>_d(M,L)),oe(M),Qt()},Gn=()=>{oe("forceSave")},Hn=async({nodes:M,edges:L})=>(s({nodes:M,edges:L}),!1),Bn={nodes:o,edges:n};return $t("div",{className:"w-full h-full",children:[!m&&$(bn,{}),$(cr,{}),$t(kd,{edges:n,nodes:o,nodeTypes:rn,edgeTypes:nn,minZoom:pn,maxZoom:mn,panOnDrag:d||m?!0:Bd,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!m&&l,nodesConnectable:!m&&l,nodesDraggable:!m&&l,isValidConnection:x,connectionLineComponent:Zo,onConnect:z,onDrop:S,onDropCapture:Gn,onDragOver:C,onNodesChange:Vn,onEdgesChange:On,onNodeDrag:T,onNodeDragStop:k,onBeforeDelete:Hn,selectionMode:Ld.Partial,proOptions:{hideAttribution:!0},multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[10,10],defaultViewport:un,connectOnClick:!1,children:[h&&$(Ad,{pannable:!0,zoomable:!0,position:cn,className:"shadow-md rounded-md"}),$t("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!m&&$(Mr,{canUndo:me,canRedo:In,undo:F,redo:he}),$(Sr,{nodes:o,isReadOnly:m,diagram:Bn,onValidationComplete:v,onValidateDiagram:b}),$(Vr,{})]}),$(gn,{horizontal:An,vertical:kn}),$(wd,{gap:dn,size:ln,color:sn,bgColor:an}),u&&$("div",{className:"absolute top-6 right-6 z-[1000]",children:$(En,{validationResult:u,onClose:Ln})})]}),$(hn,{pendingDelete:i,setPendingDelete:s,setNodes:r,setEdges:a})]})},Fd=({mode:e="edit",locale:t="pt_BR",onConfigureElement:o,onNodeSelected:r,onEdgeSelected:n})=>(vn(()=>{t&&Vd.changeLanguage(t)},[t]),$(Sd,{children:$(To,{value:{onConfigureElement:o,onNodeSelected:r,onEdgeSelected:n},children:$(zd,{mode:e})})})),qt=Fd;var Xt=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Ud,Translations as Wd}from"lecom-ui";var Nn={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing"},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"}},lane:{variant:{default:"Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var yn={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento"},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"}},lane:{variant:{default:"Lane"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Tn={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento"},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de tarefa"},variant:{default:"Tarefa",script:"Tarefa de script",subprocess:"Subprocesso"},attribute:{loop:"Tarefa com loop"}},lane:{variant:{default:"Lane"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var xn={pt_BR:Tn,en_US:Nn,es_ES:yn};var _n,wn,Yd=(wn=(_n=Xt("LecomUserLanguage"))!=null?_n:Xt("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?wn:Wd.PT_BR;Ud({lng:Yd,resources:xn});import{jsx as Cn}from"react/jsx-runtime";var eb=e=>Cn(ro,{children:Cn(qt,E({},e))});export{Pt as EditorMode,eb as Modeler};
34
+ `),v.close()},"print")},isPrintingPng:r.png,isPrintingHtml:r.html,isPrinting:r.print}};import{jsx as G,jsxs as Te}from"react/jsx-runtime";function Cr(){let{t:e}=fs(),{exportAsPng:t,exportAsHtml:o,printDiagram:r,isPrinting:n,isPrintingPng:a,isPrintingHtml:i}=wr(),[s,l]=Ns(!1);return Te(ms,{modal:!1,open:s,onOpenChange:l,children:[G(gs,{asChild:!0,children:G("div",{children:Te(bt,{children:[G(Et,{asChild:!0,children:G(ps,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:G(Es,{})})}),!s&&G(ht,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Te(us,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Te(bt,{children:[G(Et,{asChild:!0,children:G(Bt,{className:"p-1.5",disabled:a,onClick:()=>t(),children:G(hs,{})})}),G(ht,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Te(bt,{children:[G(Et,{asChild:!0,children:G(Bt,{className:"p-1.5",disabled:i,onClick:()=>o(),children:G(bs,{})})}),G(ht,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Te(bt,{children:[G(Et,{asChild:!0,children:G(Bt,{className:"p-1.5",disabled:n,onClick:()=>r(),children:G(vs,{})})}),G(ht,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Is,jsx as H,jsxs as se}from"react/jsx-runtime";var kr=({nodes:e,isReadOnly:t,diagram:o,onValidationComplete:r,onValidateDiagram:n})=>{let{t:a}=ys(),{deselectAll:i}=ut(),{isMoveTool:s,isHandTool:l,activeMoveTool:d,activeHandTool:u,isMinimapOpen:b,setIsMinimapOpen:c}=O(),m=Ir(["v","V"]),g=Ir(["h","H"]),v=Cs(()=>{i(),u()},[i,u]),f=()=>{i();let p=n(o);r&&r(p)};return Ar(()=>{m&&!s&&!t&&d()},[m,d,s,t]),Ar(()=>{g&&!l&&!t&&v()},[g,v,l,t]),se("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&se(Is,{children:[se(Nt,{children:[H(Tt,{asChild:!0,children:H(vt,{size:"small",variant:"ghost",color:"grey",className:_(s&&"bg-grey-400"),iconButton:!0,onClick:d,children:H(ws,{})})}),se(yt,{color:"black",children:[a("editor.controls.actions.move_tool"),H("span",{className:"ml-1 text-grey-400",children:"V"})]})]}),se(Nt,{children:[H(Tt,{asChild:!0,children:H(vt,{size:"small",variant:"ghost",color:"grey",className:_(l&&"bg-grey-400"),iconButton:!0,onClick:v,children:H(Ts,{})})}),se(yt,{color:"black",children:[a("editor.controls.actions.hand_tool")," ",H("span",{className:"ml-2 text-grey-400",children:"H"})]})]}),se(Nt,{children:[H(Tt,{asChild:!0,children:H(vt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:f,children:H(xs,{})})}),H(yt,{color:"black",children:a("editor.controls.actions.check")})]})]}),H(Cr,{}),!t&&H(xr,{disabled:e.length>0}),se(Nt,{children:[H(Tt,{asChild:!0,children:H(vt,{size:"small",variant:"ghost",color:"grey",className:_(b&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!b),children:H(_s,{})})}),H(yt,{color:"black",children:a(b?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Sr,Tooltip as Lr,TooltipContent as Dr,TooltipTrigger as Pr,useTranslation as As}from"lecom-ui";import{RedoIcon as ks,UndoIcon as Ss}from"lucide-react";import{jsx as le,jsxs as zt}from"react/jsx-runtime";var Mr=({undo:e,redo:t,canUndo:o,canRedo:r})=>{let{t:n}=As();return zt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[zt(Lr,{children:[le(Pr,{asChild:!0,children:le(Sr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:le(Ss,{})})}),le(Dr,{color:"black",children:n("editor.controls.history.undo")})]}),zt(Lr,{children:[le(Pr,{asChild:!0,children:le(Sr,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!r,onClick:t,children:le(ks,{})})}),le(Dr,{color:"black",children:n("editor.controls.history.redo")})]})]})};import{useReactFlow as Ls}from"@xyflow/react";import{Button as xt,Tooltip as _t,TooltipContent as wt,TooltipTrigger as Ct,useTranslation as Ds}from"lecom-ui";import{ScanIcon as Ps,ZoomIn as Ms,ZoomOut as Rs}from"lucide-react";import{jsx as W,jsxs as Ge}from"react/jsx-runtime";var Rr=()=>{let{t:e}=Ds(),{zoomIn:t,zoomOut:o,zoomTo:r,fitView:n}=Ls();return Ge("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ge(_t,{children:[W(Ct,{asChild:!0,children:W(xt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(),children:W(Ps,{})})}),W(wt,{color:"black",children:e("editor.controls.zoom.fit")})]}),Ge(_t,{children:[W(Ct,{asChild:!0,children:W(xt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:W(Rs,{})})}),W(wt,{color:"black",children:e("editor.controls.zoom.out")})]}),Ge(_t,{children:[W(Ct,{asChild:!0,children:W(xt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(1),children:W(io,{})})}),W(wt,{color:"black",children:e("editor.controls.zoom.reset")})]}),Ge(_t,{children:[W(Ct,{asChild:!0,children:W(xt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:W(Ms,{})})}),W(wt,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Position as xl,useReactFlow as _l}from"@xyflow/react";import{Handle as Vs}from"@xyflow/react";import{jsx as Os}from"react/jsx-runtime";var B=({type:e,position:t,className:o})=>Os(Vs,{type:e,position:t,className:_("size-2.5 border border-grey-400 bg-white",o)});import{NodeResizer as Gs,useReactFlow as Hs}from"@xyflow/react";import{orderBy as Bs}from"lodash";import{jsx as zs}from"react/jsx-runtime";var xe=o=>{var r=o,{nodeId:e}=r,t=fe(r,["nodeId"]);let{getNode:n,getNodes:a,setNodes:i}=Hs(),s=({width:l,height:d})=>{if(!e)return;let u=n(e);if((u==null?void 0:u.type)!=="LANE")return;let b=[...a()],c=!u.parentId,m=c?u.id:u.parentId,g=b.filter(p=>p.type==="LANE"&&p.parentId===m);if(!g.length)return;let v=Bs(g,["position.y"]),f=0;v.forEach((p,h)=>{var A,P;let w=h===v.length-1,I=(P=(A=p.measured)==null?void 0:A.height)!=null?P:0;b=b.map(N=>{if(N.id===p.id){let T=c?l-Y.HEADER_WIDTH:l,S=y(E({},N),{width:T,measured:y(E({},N.measured),{width:T}),position:y(E({},N.position),{y:f})});return w&&c&&(S.height=d-f),S}return N}),f+=I}),b=b.map(p=>{if(p.id===m){let h=c?l:l+Y.HEADER_WIDTH;return y(E({},p),{width:h,height:c?d:f,measured:{width:h,height:c?d:f}})}return p}),i(b)};return zs(Gs,E({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",onResizeEnd:(l,d)=>s(d)},t))};import{Position as fl,NodeToolbar as bl}from"@xyflow/react";import{Button as hl,Tooltip as El,TooltipContent as vl,TooltipTrigger as Nl,useTranslation as yl}from"lecom-ui";import{useNodesData as Fs,useReactFlow as Us}from"@xyflow/react";import{Button as Ws,DropdownMenu as Ys,DropdownMenuContent as Ks,DropdownMenuGroup as Zs,DropdownMenuItem as $s,DropdownMenuLabel as qs,DropdownMenuTrigger as Xs,Tooltip as js,TooltipContent as Js,TooltipTrigger as Qs,useTranslation as el}from"lecom-ui";import{WrenchIcon as tl}from"lucide-react";import{jsx as ne,jsxs as It}from"react/jsx-runtime";var Vr=({nodeId:e})=>{let{t}=el(),{updateNodeData:o}=Us(),r=Fs(e),n=a=>{(r==null?void 0:r.data.variant)!==a&&o(e,{variant:a})};return It(Ys,{children:[It(js,{children:[ne(Qs,{asChild:!0,children:ne(Xs,{asChild:!0,children:ne(Ws,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:ne(tl,{})})})}),ne(Js,{color:"black",children:t("bpmn.gateway.menu.title")})]}),It(Ks,{align:"start",className:"w-60 bg-white text-grey-600",children:[ne(qs,{className:"flex items-center",children:ne("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.gateway.menu.title")})}),ne(Zs,{children:Object.entries(Je).map(([a,i])=>It($s,{className:_({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.variant)===a}),onClick:()=>n(a),children:[ne(i.icon,{className:"stroke-current"}),t(`bpmn.gateway.variant.${a.toLowerCase()}`)]},a))})]})]})};import{useNodesData as ol,useReactFlow as rl}from"@xyflow/react";import{Button as Or,DropdownMenu as nl,DropdownMenuContent as al,DropdownMenuGroup as il,DropdownMenuItem as sl,DropdownMenuLabel as ll,DropdownMenuTrigger as dl,Tooltip as cl,TooltipContent as pl,TooltipTrigger as ml,useTranslation as ul}from"lecom-ui";import{WrenchIcon as gl}from"lucide-react";import{jsx as X,jsxs as He}from"react/jsx-runtime";var Gr=({nodeId:e})=>{let{t}=ul(),{updateNodeData:o}=rl(),r=ol(e),n=i=>{o(e,{variant:(r==null?void 0:r.data.variant)===i?"":i})},a=i=>{o(e,{attribute:(r==null?void 0:r.data.attribute)===i?"":i})};return He(nl,{children:[He(cl,{children:[X(ml,{asChild:!0,children:X(dl,{asChild:!0,children:X(Or,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:X(gl,{})})})}),X(pl,{color:"black",children:t("bpmn.task.menu.title")})]}),He(al,{align:"start",className:"w-60 bg-white text-grey-600",children:[He(ll,{className:"flex items-center gap-1",children:[X("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),X("div",{className:"flex items-center gap-1",children:Object.entries(je).map(([i,s])=>X(Or,{variant:"ghost",color:"grey",size:"small",iconButton:!0,className:_({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.attribute)===i}),onClick:()=>a(i),children:X(s.icon,{className:"stroke-inherit"})},i))})]}),X(il,{children:Object.entries(Xe).map(([i,s])=>He(sl,{className:_({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.variant)===i}),onClick:()=>n(i),children:[X(s.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${i.toLowerCase()}`)]},i))})]})]})};import{jsx as j,jsxs as Tl}from"react/jsx-runtime";var Z=({nodeId:e,nodeType:t,isChild:o,isVisible:r})=>{var u;let{t:n}=yl(),{setDraggableNode:a}=Ne(),i=({event:b,type:c,variant:m})=>{a({type:c,variant:m}),b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("sourceId",e)},s={START_EVENT:{type:"START_EVENT",icon:ke,label:n("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:be,label:n("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:ke,label:n("bpmn.task.variant.default")},GATEWAY:{type:"GATEWAY",variant:"EXCLUSIVE",icon:he,label:n("bpmn.gateway.variant.exclusive")},ANNOTATION:{type:"ANNOTATION",icon:Ye,label:n("bpmn.annotation.variant.default")}},l=[{component:j(nt,{elementId:e})}],d={START_EVENT:[s.TASK,s.ANNOTATION,...l],TASK:[{component:j(De,{elementId:e})},{component:j(Gr,{nodeId:e})},s.TASK,s.GATEWAY,s.END_EVENT,s.ANNOTATION,...l],GATEWAY:[{component:j(De,{elementId:e})},{component:j(Vr,{nodeId:e})},s.TASK,s.GATEWAY,s.ANNOTATION,...l],END_EVENT:[s.ANNOTATION,...l],LANE:[...o?[]:[s.ANNOTATION],...l],ANNOTATION:[...l],UNSUPPORTED:[...l]};return j(bl,{className:"-top-6 flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",position:fl.Right,align:"start",isVisible:r,children:(u=d[t])==null?void 0:u.map((b,c)=>b.component?j("div",{children:b.component},c):Tl(El,{children:[j(Nl,{asChild:!0,children:j(hl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!0,onDragStart:m=>i({event:m,type:b.type,variant:b.variant}),children:b.icon&&j(b.icon,{size:16})})}),j(vl,{color:"black",children:b.label})]},c))})};import{Fragment as wl,jsx as Be,jsxs as Cl}from"react/jsx-runtime";var Hr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=_l(),{isMultipleSelection:a}=O(),i=s=>{n(e,{label:s})};return Cl(wl,{children:[Be("div",{className:_("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm overflow-hidden border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"text-blue-500 hover:text-blue-600 shadow-md":o,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:Be(U,{value:t.label,className:"m-1 text-grey-600",onChange:i})}),Be(Z,{nodeId:e,nodeType:"ANNOTATION",isVisible:!r&&!a&&o}),Be(xe,{isVisible:!r&&!a&&o,minWidth:tt.MIN_WIDTH,minHeight:tt.MIN_HEIGHT}),Be(B,{type:"target",position:xl.Left})]})};import{Position as Br,useReactFlow as Il}from"@xyflow/react";import{useState as Al}from"react";import{Fragment as kl,jsx as _e,jsxs as zr}from"react/jsx-runtime";var Fr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Il(),{isMultipleSelection:a}=O(),[i,s]=Al(!1),l=b=>{n(e,{label:b})};return zr(kl,{children:[zr("div",{className:"relative",onBlur:()=>{s(!1)},onDoubleClick:()=>{s(!0)},children:[_e(be,{className:_("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),_e("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:_e(U,{value:t.label,isEditing:i,onChange:l})})]}),_e(Z,{nodeId:e,nodeType:"END_EVENT",isVisible:!r&&!a&&o}),_e(B,{type:"source",position:Br.Right}),_e(B,{type:"target",position:Br.Left})]})};import{Position as Ur,useReactFlow as Sl}from"@xyflow/react";import{useState as Ll}from"react";import{Fragment as Dl,jsx as we,jsxs as Wr}from"react/jsx-runtime";var Yr=({id:e,data:t,selected:o,dragging:r})=>{let n=Je[t.variant].icon,{updateNodeData:a}=Sl(),{isMultipleSelection:i}=O(),[s,l]=Ll(!1),d=c=>{a(e,{label:c})};return Wr(Dl,{children:[Wr("div",{className:"relative",onBlur:()=>{l(!1)},onDoubleClick:()=>{l(!0)},children:[we(n,{className:_("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),we("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:we(U,{value:t.label,isEditing:s,onChange:d})})]}),we(Z,{nodeId:e,nodeType:"GATEWAY",isVisible:!r&&!i&&o}),we(B,{type:"target",position:Ur.Left}),we(B,{type:"source",position:Ur.Right})]})};import{Position as Pl,useReactFlow as Ml}from"@xyflow/react";import{useState as Rl}from"react";import{Fragment as Vl,jsx as ze,jsxs as Kr}from"react/jsx-runtime";var Zr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Ml(),{isMultipleSelection:a}=O(),[i,s]=Rl(!1),l=b=>{n(e,{label:b})};return Kr(Vl,{children:[Kr("div",{className:"relative",onBlur:()=>{s(!1)},onDoubleClick:()=>{s(!0)},children:[ze($e,{className:_("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),ze("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:ze(U,{value:t.label,isEditing:i,onChange:l})})]}),ze(Z,{nodeId:e,nodeType:"START_EVENT",isVisible:!r&&!a&&o}),ze(B,{type:"source",position:Pl.Right})]})};import{Position as $r,useReactFlow as Ol}from"@xyflow/react";import{Fragment as Gl,jsx as ee,jsxs as qr}from"react/jsx-runtime";var Xr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Ol(),{isMultipleSelection:a}=O(),i=c=>{n(e,{label:c})},s=t.variant?Xe[t.variant].icon:null,l=t.attribute?je[t.attribute].icon:null,d=t.variant==="SUBPROCESS",u=s&&!d,b=l||d;return qr(Gl,{children:[qr("div",{className:_("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md overflow-hidden hover:shadow-md transition-colors duration-75",{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[ee(U,{value:t.label,className:_("m-1",{"py-6":u||b}),onChange:i}),s&&ee("div",{className:_("absolute flex items-center p-1",d?"bottom-0":"top-0 left-0"),children:ee(s,{size:16,className:_(t.hasError?"text-red-500":"text-grey-500")})}),l&&ee("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:ee("div",{className:_("flex items-center w-16 p-1",d?"justify-between":"justify-center"),children:ee(l,{size:16,className:_(t.hasError?"text-red-500":"text-grey-500")})})})]}),ee(Z,{nodeId:e,nodeType:"TASK",isVisible:!r&&!a&&o}),ee(xe,{isVisible:!r&&!a&&o,minWidth:Qe.MIN_WIDTH,minHeight:Qe.MIN_HEIGHT}),ee(B,{type:"source",position:$r.Right}),ee(B,{type:"target",position:$r.Left})]})};import{Position as jr}from"@xyflow/react";import{Fragment as Hl,jsx as At,jsxs as Bl}from"react/jsx-runtime";var Jr=({id:e,data:t,selected:o,dragging:r})=>{let{isMultipleSelection:n}=O();return Bl(Hl,{children:[At("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),At(Z,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!r&&!n&&o}),At(B,{type:"source",position:jr.Right}),At(B,{type:"target",position:jr.Left})]})};import{Position as zl,useReactFlow as Fl}from"@xyflow/react";import{orderBy as Ul}from"lodash";import{useMemo as Qr}from"react";import{Fragment as Wl,jsx as ue,jsxs as en}from"react/jsx-runtime";var tn=({id:e,data:t,selected:o,dragging:r,parentId:n})=>{let{updateNodeData:a,getNodes:i}=Fl(),{isMultipleSelection:s}=O(),l=i(),d=!n,u=Qr(()=>Ul([...l.filter(g=>g.parentId===e&&g.type==="LANE")],"position.y","asc"),[l,e]),b=d?et.MIN_WIDTH:Y.MIN_WIDTH,c=Qr(()=>{if(d&&u.length>1){let g=[...u];return g.pop(),g.reduce((f,p)=>{var h,w;return f+((w=(h=p.measured)==null?void 0:h.height)!=null?w:0)},0)+Y.MIN_HEIGHT}return Y.MIN_HEIGHT},[d,u]),m=g=>{a(e,{label:g})};return en(Wl,{children:[en("div",{className:_("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[ue("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",children:ue("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:ue(U,{value:t.label,className:"w-full h-full",onChange:m})})}),ue("div",{className:"flex-1"})]}),ue(Z,{nodeId:e,nodeType:"LANE",isChild:!d,isVisible:!r&&!s&&o}),ue(xe,{nodeId:e,minWidth:b,minHeight:c,isVisible:!r&&!s&&o}),d&&ue(B,{type:"source",position:zl.Right})]})};var on={START_EVENT:Zr,END_EVENT:Fr,TASK:Xr,GATEWAY:Yr,ANNOTATION:Hr,LANE:tn,UNSUPPORTED:Jr},rn={SEQUENCE_EDGE:Io,MESSAGE_EDGE:Wo,ANNOTATION_EDGE:To},nn="#fafafa",an="#bebebe",sn=1,ln=10,dn="bottom-left",cn=.5,pn=4,mn={x:0,y:0,zoom:.75};import{useStore as Yl}from"@xyflow/react";import{useEffect as Kl,useRef as Zl}from"react";import{jsx as ql}from"react/jsx-runtime";var $l=e=>({width:e.width,height:e.height,transform:e.transform}),un=({horizontal:e,vertical:t,color:o="#3367d9",dashArray:r=[6,6]})=>{let{width:n,height:a,transform:i}=Yl($l),s=Zl(null);return Kl(()=>{let l=s.current,d=l==null?void 0:l.getContext("2d");if(!d||!l)return;let u=window.devicePixelRatio;l.width=n*u,l.height=a*u,d.scale(u,u),d.clearRect(0,0,n,a),d.strokeStyle=o,d.setLineDash(r),typeof t=="number"&&(d.moveTo(t*i[2]+i[0],0),d.lineTo(t*i[2]+i[0],a),d.stroke()),typeof e=="number"&&(d.moveTo(0,e*i[2]+i[1]),d.lineTo(n,e*i[2]+i[1]),d.stroke())},[n,a,i,e,t,o,r]),ql("canvas",{ref:s,className:"react-flow__canvas w-full h-full absolute z-10 pointer-events-none"})};import{Button as gn,Dialog as Xl,DialogContent as jl,DialogFooter as Jl,DialogHeader as Ql,DialogTitle as ed,Notification as td,Typography as Ft,useTranslation as od}from"lecom-ui";import{jsx as te,jsxs as Ut}from"react/jsx-runtime";var fn=({pendingDelete:e,setPendingDelete:t,setNodes:o,setEdges:r})=>{let{t:n}=od(),a=!!e,i=()=>{let{nodes:l,edges:d}=e||{};l!=null&&l.length&&o(u=>u.filter(b=>!l.some(c=>c.id===b.id))),d!=null&&d.length&&r(u=>u.filter(b=>!d.some(c=>c.id===b.id))),t(null)},s=()=>{t(null)};return te(Xl,{open:a,onOpenChange:s,children:Ut(jl,{className:"w-[488px] max-w-fit gap-2",children:[te(Ql,{children:te(ed,{children:te(Ft,{variant:"heading-small-600",textColor:"text-grey-950",children:n("editor.modals.delete_elements.title")})})}),Ut("div",{className:"flex flex-col gap-2",children:[te("div",{className:"py-2",children:te(td,{type:"callout",variant:"warning",content:n("editor.modals.delete_elements.callout")})}),te(Ft,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:n("editor.modals.delete_elements.content")})]}),Ut(Jl,{className:"flex items-center flex-row justify-end w-full gap-2",children:[te(gn,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:s,children:te(Ft,{variant:"body-medium-500",textColor:"text-grey-800",children:n("editor.modals.delete_elements.cancel")})}),te(gn,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:i,children:n("editor.modals.delete_elements.confirm")})]})]})})};import{Button as rd,Tooltip as nd,TooltipContent as ad,TooltipTrigger as id,useTranslation as sd}from"lecom-ui";import{jsx as Fe,jsxs as ld}from"react/jsx-runtime";var bn=()=>{let{t:e}=sd(),{setDraggableNode:t}=Ne(),o=[{type:"START_EVENT",icon:$e,label:e("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:be,label:e("bpmn.end_event.variant.default")},{type:"TASK",icon:ke,label:e("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:mo,label:e("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:po,label:e("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:co,label:e("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:he,label:e("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Ze,label:e("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Ke,label:e("bpmn.gateway.variant.complex")},{type:"LANE",icon:ao,label:e("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Ye,label:e("bpmn.annotation.variant.default")}],r=(n,a)=>{t({type:a.type,variant:a.variant,attribute:a.attribute}),n.dataTransfer.effectAllowed="move"};return Fe("aside",{className:"sidebar absolute z-[1] top-4 left-4 grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:o.map((n,a)=>ld(nd,{children:[Fe(id,{asChild:!0,children:Fe(rd,{className:"[&>svg]:size-6",size:"small",variant:"ghost",color:"grey",draggable:!0,iconButton:!0,onDragStart:i=>r(i,n),children:Fe(n.icon,{})},a)}),Fe(ad,{color:"black",side:"right",children:n.label})]},a))})};import{Button as dd,useTranslation as cd}from"lecom-ui";import{AlertCircleIcon as pd,CircleCheckIcon as md,XIcon as ud}from"lucide-react";import{useEffect as gd,useState as fd}from"react";import{jsx as J,jsxs as Wt}from"react/jsx-runtime";var hn=({validationResult:e,onClose:t})=>{let{t:o}=cd(),[r,n]=fd(!1);if(gd(()=>{e&&n(!0)},[e]),!r||!e)return null;let{isValid:a,errors:i}=e;return Wt("div",{className:_("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":a,"bg-red-100":!a}),children:[Wt("div",{className:"flex flex-row items-start gap-4",children:[J("div",{className:"flex-shrink-0",children:a?J(md,{className:"text-green-500 size-5"}):J(pd,{className:"text-red-500 size-5"})}),Wt("div",{className:"body-medium-500 text-grey-800",children:[J("div",{children:o(a?"validation.success.title":"validation.errors.title")}),!a&&J("div",{children:o("validation.errors.subtitle")})]}),J(dd,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{n(!1),t()},children:J(ud,{})})]}),J("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:a?J("p",{children:o("validation.success.message")}):J("div",{className:"list-disc list-inside",children:i.map(s=>J("li",{className:"mb-1",children:s.message},s.id))})})]})};import{jsx as $,jsxs as Kt}from"react/jsx-runtime";var Sd=[],Ld=({mode:e="edit"})=>{let t=Id(!1),[o,r]=xd([]),[n,a]=Td([]),[i,s]=Ad(null),{isMoveTool:l,isHandTool:d,isReadOnly:u,setIsReadOnly:b,setIsMultipleSelection:c,isMinimapOpen:m}=O(),{validationResult:g,handleValidationComplete:v,clearValidation:f,isAutoValidationEnabled:p,validateDiagram:h}=Ho(),{getNode:w,getNodes:I,getEdges:A}=wd(),{onNodeDrag:P,onDrop:N,onDragOver:T,onNodeDragStop:S}=$o({nodes:o,setNodes:r,setEdges:a}),{isValidConnection:C,onConnect:k}=ko({setEdges:a});Fo();let{createDiagram:x}=rr(),{undo:z,redo:K,saveHistory:V,canUndo:ge,canRedo:de}=sr(),{helperLineHorizontal:ce,helperLineVertical:Cn,customApplyNodeChanges:In}=jo();nr({LIA_CREATE_DIAGRAM:x,CLEAR_DIAGRAM:()=>{r([]),a([])}}),En(()=>{b(e==="readonly")},[e,b]);let An=()=>{f()},kn=Yt(({nodes:F,edges:M})=>{let Ce=F.length+M.length>1;c(Ce)},[c]);_d({onChange:kn});let Sn=F=>{let M=w(F.id);if(M!=null&&M.parentId&&(M==null?void 0:M.type)==="LANE"){let Ce=pe(M.parentId,o.filter(jt=>jt.id!==M.id&&jt.type==="LANE"));r(re(Ce))}},Ln=F=>{F.forEach(M=>{switch(M.type){case"remove":Sn(M);break}})},Dn=Yt(()=>{if(!p){t.current=!1;return}let F=I(),M=A(),Ce=h({nodes:F,edges:M});v(Ce),t.current=!1},[p,I,A,h,v]),qt=kd(Dn,300),Xt=Yt(()=>{p&&!t.current&&(t.current=!0,qt())},[p,qt]),Pn=F=>{r(M=>In(F,M)),V(F),Xt(),Ln(F)},Mn=F=>{a(M=>bd(F,M)),V(F),Xt()},Rn=()=>{V("forceSave")},Vn=async({nodes:F,edges:M})=>(s({nodes:F,edges:M}),!1),On={nodes:o,edges:n};return Kt("div",{className:"w-full h-full",children:[!u&&$(bn,{}),$(dr,{}),Kt(vd,{edges:n,nodes:o,nodeTypes:on,edgeTypes:rn,minZoom:cn,maxZoom:pn,panOnDrag:d||u?!0:Sd,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!u&&l,nodesConnectable:!u&&l,nodesDraggable:!u&&l,isValidConnection:C,connectionLineComponent:Ko,onConnect:k,onDrop:N,onDropCapture:Rn,onDragOver:T,onNodesChange:Pn,onEdgesChange:Mn,onNodeDrag:P,onNodeDragStop:S,onBeforeDelete:Vn,selectionMode:yd.Partial,proOptions:{hideAttribution:!0},multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[10,10],defaultViewport:mn,connectOnClick:!1,children:[m&&$(Ed,{pannable:!0,zoomable:!0,position:dn,className:"shadow-md rounded-md"}),Kt("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!u&&$(Mr,{canUndo:ge,canRedo:de,undo:z,redo:K}),$(kr,{nodes:o,isReadOnly:u,diagram:On,onValidationComplete:v,onValidateDiagram:h}),$(Rr,{})]}),$(un,{horizontal:ce,vertical:Cn}),$(hd,{gap:ln,size:sn,color:an,bgColor:nn}),g&&$("div",{className:"absolute top-6 right-6 z-[1000]",children:$(hn,{validationResult:g,onClose:An})})]}),$(fn,{pendingDelete:i,setPendingDelete:s,setNodes:r,setEdges:a})]})},Dd=({mode:e,locale:t="pt_BR",onConfigureElement:o})=>(En(()=>{t&&Cd.changeLanguage(t)},[t]),$(Nd,{children:$(No,{value:{onConfigureElement:o},children:$(Ld,{mode:e})})})),Zt=Dd;var $t=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};import{initializeI18n as Pd,Translations as Md}from"lecom-ui";var vn={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing"},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"}},lane:{variant:{default:"Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Nn={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento"},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"}},lane:{variant:{default:"Lane"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var yn={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento"},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Verificar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de tarefa"},variant:{default:"Tarefa",script:"Tarefa de script",subprocess:"Subprocesso"},attribute:{loop:"Tarefa com loop"}},lane:{variant:{default:"Lane"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Tn={pt_BR:yn,en_US:vn,es_ES:Nn};var xn,_n,Rd=(_n=(xn=$t("LecomUserLanguage"))!=null?xn:$t("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?_n:Md.PT_BR;Pd({lng:Rd,resources:Tn});import{jsx as wn}from"react/jsx-runtime";var Wb=e=>wn(to,{children:wn(Zt,E({},e))});export{kt as ElementType,St as ElementVariant,Wb as Modeler};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-modeler",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",