lecom-modeler 0.1.26 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,25 +1,25 @@
1
- var $n=Object.defineProperty,Xn=Object.defineProperties;var qn=Object.getOwnPropertyDescriptors;var Ke=Object.getOwnPropertySymbols;var ao=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable;var no=(e,t,o)=>t in e?$n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,y=(e,t)=>{for(var o in t||(t={}))ao.call(t,o)&&no(e,o,t[o]);if(Ke)for(var o of Ke(t))io.call(t,o)&&no(e,o,t[o]);return e},w=(e,t)=>Xn(e,qn(t));var Ee=(e,t)=>{var o={};for(var r in e)ao.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&Ke)for(var r of Ke(e))t.indexOf(r)<0&&io.call(e,r)&&(o[r]=e[r]);return o};import{TooltipProvider as jn,Notification as Jn}from"lecom-ui";import{jsx as Qn,jsxs as ea}from"react/jsx-runtime";function so({children:e}){return ea(jn,{children:[Qn(Jn,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as Cd,MiniMap as Id,ReactFlow as Ad,ReactFlowProvider as Sd,SelectionMode as kd,useEdgesState as Ld,useNodesState as Pd,useOnSelectionChange as Dd,useReactFlow as Rd}from"@xyflow/react";import{i18n as Md}from"lecom-ui";import{forwardRef as Vd,useCallback as jt,useEffect as wn,useImperativeHandle as Od,useRef as Gd,useState as Hd}from"react";import{useDebouncedCallback as Bd}from"use-debounce";var Pt=(n=>(n.ACTIVITY="activity",n.ROUTING="routing",n.GATEWAY="gateway",n.SUB_PROCESS="sub_process",n))(Pt||{}),Dt=(r=>(r.START="start",r.END="end",r.BETWEEN="between",r))(Dt||{}),Rt=(l=>(l.SIMPLE="simple",l.LOOP="loop",l.SCRIPT="script",l.COMPLEX="complex",l.EXCLUSIVE="exclusive",l.PARALLEL="parallel",l.FINAL="final",l.TO_SUB_PROCESS="to_sub_process",l))(Rt||{}),Mt=(r=>(r.SCRIPT="script",r.LOOP="loop",r.SCRIPT_LOOP="script_loop",r))(Mt||{}),Vt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Vt||{});import{RotateCcw as ma,ScrollText as ua,SquarePlus as ga}from"lucide-react";import{jsx as Ze,jsxs as ta}from"react/jsx-runtime";var $e=({size:e=24,className:t})=>ta("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Ze("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Ze("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Ze("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Ze("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as lo}from"react/jsx-runtime";var be=({size:e=24,className:t})=>lo("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:lo("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 oa}from"react/jsx-runtime";var Xe=({size:e=24,className:t})=>oa("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 Ot,jsxs as ra}from"react/jsx-runtime";var he=({size:e=24,className:t})=>ra("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:[Ot("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"}),Ot("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Ot("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Gt,jsxs as na}from"react/jsx-runtime";var qe=({size:e=24,className:t})=>na("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:"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"}),Gt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Gt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ht,jsxs as aa}from"react/jsx-runtime";var co=({size:e=24,className:t})=>Ht("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:aa("g",{children:[Ht("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"}),Ht("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as ia}from"clsx";import{twMerge as sa}from"tailwind-merge";function L(...e){return sa(ia(e))}var Se=(e,t)=>e<t?t:e;import{jsx as po,jsxs as la}from"react/jsx-runtime";var mo=({size:e=24,className:t})=>la("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:L("stroke-2",t),children:[po("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"}),po("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Bt}from"react/jsx-runtime";var uo=({size:e=24,className:t})=>Bt("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Bt("g",{children:Bt("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 go}from"react/jsx-runtime";var je=({size:e=24,className:t})=>go("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:go("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 fo}from"react/jsx-runtime";var ke=({size:e=24,className:t})=>fo("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:L("stroke-2",t),children:fo("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 zt,jsxs as da}from"react/jsx-runtime";var Eo=({size:e=24,className:t})=>da("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:[zt("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"}),zt("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"}),zt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Le,jsxs as ca}from"react/jsx-runtime";var bo=({size:e=24,className:t})=>ca("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 Je,jsxs as pa}from"react/jsx-runtime";var ho=({size:e=24,className:t})=>pa("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:[Je("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"}),Je("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),Je("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Je("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var M=(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))(M||{});var Qe={SCRIPT:{icon:ua},SUBPROCESS:{icon:ga}};var et={LOOP:{icon:ma}},ie=(r=>(r.EXCLUSIVE="EXCLUSIVE",r.PARALLEL="PARALLEL",r.COMPLEX="COMPLEX",r))(ie||{}),tt={EXCLUSIVE:{icon:he},PARALLEL:{icon:qe},COMPLEX:{icon:Xe}};import yo from"@dagrejs/dagre";import{getNodesBounds as Ta}from"@xyflow/react";import{orderBy as xa}from"lodash";var fa={MIN_WIDTH:36,MIN_HEIGHT:36},Ea={MIN_WIDTH:36,MIN_HEIGHT:36},ba={MIN_WIDTH:56,MIN_HEIGHT:56},ot={MIN_WIDTH:176,MIN_HEIGHT:96},rt={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},K={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},nt={MIN_WIDTH:176,MIN_HEIGHT:64},ha={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:fa,END_EVENT:Ea,GATEWAY:ba,TASK:ot,LANE:K,ANNOTATION:nt,UNSUPPORTED:ha};import{orderBy as va}from"lodash";var oe=e=>{var t,o,r,n,i,a,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:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},re=e=>va(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),vo=(e,t)=>{let{x:o,y:r}=oe(e),{x:n,y:i}=oe(t);return{x:o-n,y:r-i}};var ve=({parentId:e,nodes:t,includeTypes:o=[...Object.values(M)],excludeTypes:r=[]})=>t.some(n=>n.parentId===e&&(!o.length||o.includes(n.type))&&!r.includes(n.type)),Na=(e,t)=>{let{x:o,y:r}=oe(e),{x:n,y:i}=oe(t),a=o-n,s=r-i;return Math.sqrt(a*a+s*s)},ya=(e,t)=>{let{x:o,y:r,w:n,h:i}=oe(e),{x:a,y:s,w:l,h:d}=oe(t);return o<a+l&&a<o+n&&r<s+d&&s<r+i},Pe=(e,t)=>{let o=null,r=1/0;for(let n of t)if(n.id!==e.id&&ya(e,n)){let i=Na(e,n);i<r&&(r=i,o=n)}return o},No=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,r)=>{var n,i;return Math.max(o,(i=(n=r.measured)==null?void 0:n.width)!=null?i:0)},0);var To=(e=[],t=[],o="LR")=>{let r=new yo.graphlib.Graph;return r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>r.setNode(i,{width:a,height:s})),t.forEach(i=>r.setEdge(i.source,i.target)),yo.layout(r),{nodes:e.map(i=>{let a=r.node(i.id);return w(y({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},ue=(e,t)=>{var m,u;let o=[...t],r=o.find(v=>v.id===e);if(!r)return o;let n=o.filter(v=>v.parentId===e&&v.type==="LANE");if(n.length===0)return o;let i=xa(n,["position.y"]),a=Math.max((u=(m=r.measured)==null?void 0:m.width)!=null?u:0,rt.MIN_WIDTH),s=No(e,i)||K.MIN_WIDTH,l=Math.max(a,s),d=0,f=0;i.forEach(v=>{var x,b,g,h;o=o.map(k=>k.id===v.id?w(y({},k),{width:l-K.HEADER_WIDTH,measured:w(y({},k.measured),{width:l-K.HEADER_WIDTH}),position:{x:K.HEADER_WIDTH,y:d}}):k),d+=(b=(x=v.measured)==null?void 0:x.height)!=null?b:0,f+=(h=(g=v.measured)==null?void 0:g.height)!=null?h:0}),o=o.map(v=>v.id===e?w(y({},v),{height:f,width:l,measured:w(y({},v.measured),{height:f,width:l})}):v);let E=o.find(v=>v.id===e);return E!=null&&E.parentId&&(o=ue(E.parentId,o)),o},xo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},_a=50,_o=(e,t=_a)=>{let o=Ta(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as wa}from"zustand";var V=wa(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 Ro,useReactFlow as ii}from"@xyflow/react";import{BaseEdge as Ya,EdgeLabelRenderer as Ka,getStraightPath as Za,useNodes as $a,useViewport as Xa}from"@xyflow/react";import{getIncomers as De,getOutgoers as Ut,useReactFlow as Sa}from"@xyflow/react";import{Button as ka,Tooltip as La,TooltipContent as Pa,TooltipTrigger as Da,useTranslation as Ra}from"lecom-ui";import{PencilIcon as Ma}from"lucide-react";import{createContext as Ca,useContext as Ia}from"react";var wo=Ca(null),Co=wo.Provider,Io=()=>{let e=Ia(wo);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as at,jsxs as Va}from"react/jsx-runtime";var Re=({elementId:e,elementType:t="node"})=>{let{t:o}=Ra(),{getNode:r,getEdge:n,getNodes:i,getEdges:a}=Sa(),{onConfigureElement:s}=Io(),l=c=>{var T,I,p,N,A;return c?c.type==="TASK"&&((T=c.data)==null?void 0:T.variant)==="SUBPROCESS"?{id:c.id,type:"sub_process",variant:f(c),label:(I=c.data)==null?void 0:I.label}:c.type==="GATEWAY"?{id:c.id,type:"gateway",variant:((p=c.data)==null?void 0:p.variant)||"EXCLUSIVE",label:(N=c.data)==null?void 0:N.label}:{id:c.id,type:"activity",variant:f(c),label:(A=c.data)==null?void 0:A.label}:null},d=c=>{let T=i(),I=a(),p=De(c,T,I);if(p.length===0)return;let N=p[0];return l(N)||void 0},f=c=>{let T=i(),I=a(),p=De(c,T,I),N=Ut(c,T,I),A=p.some(S=>S.type==="START_EVENT"),_=N.some(S=>S.type==="END_EVENT");return A?"start":_?"end":"between"},E=c=>{var S,C,P,D;let T=i(),I=a(),p=r(c.source),N=r(c.target);if(!p||!N)return"simple";if(Ut(p,T,I).some(O=>O.type==="END_EVENT"))return"final";if(p.type==="GATEWAY")switch((S=p.data)==null?void 0:S.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(p.type==="TASK"){let O=(C=p.data)==null?void 0:C.variant,ae=(P=p.data)==null?void 0:P.attribute;return N.type==="TASK"&&((D=N.data)==null?void 0:D.variant)==="SUBPROCESS"?"to_sub_process":O==="SCRIPT"?"script":ae==="LOOP"?"loop":"simple"}return"simple"},m=c=>{var S;let T=r(c.source);if(!T||T.type!=="GATEWAY"||((S=T.data)==null?void 0:S.variant)!=="COMPLEX")return;let I=i(),p=a(),N=De(T,I,p),A=!1,_=!1;if(N.forEach(C=>{var P,D;C.type==="TASK"&&(((P=C.data)==null?void 0:P.variant)==="SCRIPT"&&(A=!0),((D=C.data)==null?void 0:D.attribute)==="LOOP"&&(_=!0))}),A&&_)return"script_loop";if(A)return"script";if(_)return"loop"},u=c=>{var S;let T=r(c.source);if(!T||T.type!=="GATEWAY"||((S=T.data)==null?void 0:S.variant)!=="EXCLUSIVE")return;let I=i(),p=a(),N=De(T,I,p),A=!1,_=!1;if(N.forEach(C=>{var P,D;C.type==="TASK"&&(((P=C.data)==null?void 0:P.variant)==="SCRIPT"&&(A=!0),((D=C.data)==null?void 0:D.attribute)==="LOOP"&&(_=!0))}),A)return"script";if(_)return"loop"},v=c=>{var _,S;if(c.type!=="GATEWAY")return;let T=i(),I=a(),p=De(c,T,I),N=!1,A=!1;if(p.forEach(C=>{var P,D;C.type==="TASK"&&(((P=C.data)==null?void 0:P.variant)==="SCRIPT"&&(N=!0),((D=C.data)==null?void 0:D.attribute)==="LOOP"&&(A=!0))}),((_=c.data)==null?void 0:_.variant)==="COMPLEX"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}else if(((S=c.data)==null?void 0:S.variant)==="EXCLUSIVE"){if(N)return"script";if(A)return"loop"}},x=c=>Ut(c,i(),a()).map(p=>{var N,A;return{id:p.id,type:p.type,variant:(N=p.data)==null?void 0:N.variant,label:(A=p.data)==null?void 0:A.label}}),b=c=>a().filter(p=>p.source===c.id).map(p=>{var N;return{id:p.id,type:"routing",variant:E(p),label:(N=p.data)==null?void 0:N.label,target:r(p.target)}}),g=()=>{var I,p,N,A,_,S,C,P,D;let c=r(e);if(!c)return;let T=d(c);if(c.type==="TASK"&&((I=c.data)==null?void 0:I.variant)==="SUBPROCESS"){s==null||s({id:c.id,type:"sub_process",variant:f(c),label:(p=c.data)==null?void 0:p.label,origin:T,targets:x(c),edgeTargets:b(c)}),console.log({id:c.id,type:"sub_process",variant:f(c),label:(N=c.data)==null?void 0:N.label,origin:T,targets:x(c),edgeTargets:b(c)});return}if(c.type!=="GATEWAY"){s==null||s({id:c.id,type:"activity",variant:f(c),label:(A=c.data)==null?void 0:A.label,origin:T,targets:x(c),edgeTargets:b(c)}),console.log({id:c.id,type:"activity",variant:f(c),label:(_=c.data)==null?void 0:_.label,origin:T,targets:x(c),edgeTargets:b(c)});return}console.log({id:c.id,type:"gateway",variant:((S=c.data)==null?void 0:S.variant)||"EXCLUSIVE",label:(C=c.data)==null?void 0:C.label,origin:T,subVariant:v(c),targets:x(c)}),s==null||s({id:c.id,type:"gateway",variant:((P=c.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(D=c.data)==null?void 0:D.label,origin:T,subVariant:v(c),targets:x(c)})},h=()=>{let c=n(e);if(c){let T=E(c),I;T==="complex"?I=m(c):T==="exclusive"&&(I=u(c));let p=r(c.source),N=p&&l(p)||void 0;s==null||s({id:c.id,type:"routing",variant:T,subVariant:I,origin:N,target:r(c.target)}),console.log({id:c.id,type:"routing",variant:T,subVariant:I,origin:N,target:r(c.target)})}};return Va(La,{children:[at(Da,{asChild:!0,children:at(ka,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":g();break;case"edge":h();break}},children:at(Ma,{size:16})})}),at(Pa,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Oa}from"@xyflow/react";import{Button as Ga,Tooltip as Ha,TooltipContent as Ba,TooltipTrigger as za,useTranslation as Ua}from"lecom-ui";import{TrashIcon as Fa}from"lucide-react";import{jsx as st,jsxs as Wa}from"react/jsx-runtime";var lt=({elementId:e,elementType:t="node"})=>{let{t:o}=Ua(),{deleteElements:r}=Oa();return Wa(Ha,{children:[st(za,{asChild:!0,children:st(Ga,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{r(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:st(Fa,{size:16})})}),st(Ba,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as dt}from"react/jsx-runtime";var Ne=r=>{var n=r,{edgeId:e,edgeType:t}=n,o=Ee(n,["edgeId","edgeType"]);var s;let i=[{component:dt(lt,{elementId:e,elementType:"edge"})}],a={SEQUENCE_EDGE:[{component:dt(Re,{elementId:e,elementType:"edge"})},...i],MESSAGE_EDGE:[...i],ANNOTATION_EDGE:[...i]};return dt("div",w(y({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(s=a[t])==null?void 0:s.map((l,d)=>dt("div",{children:l.component},d))}))};import{jsx as pt,jsxs as qa}from"react/jsx-runtime";var mt={type:"ANNOTATION_EDGE",zIndex:2e3},Ao=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:i,targetY:a,selected:s,data:l})=>{let d=$a(),{zoom:f}=Xa(),{isMultipleSelection:E}=V(),m=d.find(k=>k.id===t),u=d.find(k=>k.id===o),[v,x,b]=Za({sourceX:r,sourceY:n,targetX:i,targetY:a}),g=s||(m==null?void 0:m.selected)||(u==null?void 0:u.selected),h=1/f;return qa("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":g}),children:[pt(Ya,{id:e,path:v,strokeDasharray:4,className:L("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)})}),pt(Ka,{children:pt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${x}px, ${b}px)`},children:s&&!E&&pt(Ne,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${h})`}})})})]})};import{BaseEdge as Qa,EdgeLabelRenderer as ei,getSmoothStepPath as ti,MarkerType as Lo,useNodes as oi,useReactFlow as ri,useViewport as ni}from"@xyflow/react";import{useState as ai}from"react";import{useEffect as So,useRef as ja,useState as Ja}from"react";import{jsx as ko}from"react/jsx-runtime";var W=({value:e,maxLength:t,onChange:o,isEditing:r,onBlur:n,className:i,style:a})=>{let s=ja(null),[l,d]=Ja(!1);So(()=>{d(r!=null?r:!1)},[r]),So(()=>{if(l&&s.current){s.current.focus();let u=document.createRange();u.selectNodeContents(s.current),u.collapse(!1);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(u))}},[l]);let f=u=>{u.stopPropagation(),d(!0)},E=u=>{let v=u.currentTarget.innerText;t&&v.length>=t&&u.preventDefault()},m=u=>{d(!1),n==null||n(),o==null||o(u.currentTarget.innerText)};return ko("div",{className:L("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",i,{"border border-dashed border-grey-400":l}),style:a,onDoubleClick:f,children:ko("div",{ref:s,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:E,onBlur:m,children:e})})};import{jsx as ut,jsxs as Po}from"react/jsx-runtime";var se={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Lo.ArrowClosed},markerEnd:{type:Lo.Arrow},data:{label:""}},Do=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:i,targetY:a,sourcePosition:s,targetPosition:l,data:d,selected:f})=>{let E=oi(),{zoom:m}=ni(),{updateEdgeData:u}=ri(),{isMultipleSelection:v}=V(),[x,b]=ai(!1),g=E.find(P=>P.id===t),h=E.find(P=>P.id===o),[k,c,T]=ti({sourceX:r,sourceY:n,sourcePosition:s,targetX:i,targetY:a,targetPosition:l}),I=f||(g==null?void 0:g.selected)||(h==null?void 0:h.selected),p=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=x||(d==null?void 0:d.label.trim().length)>0,A=1/m,_=()=>{b(!0)},S=()=>{b(!1)},C=P=>{u(e,{label:P.trim()})};return Po("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:S,onDoubleClick:_,children:[ut(Qa,{id:e,path:k,markerEnd:`url(#${p})`,className:L("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)]":I&&!(d!=null&&d.hasError)})}),ut(ei,{children:Po("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${c}px, ${T}px)`},children:[f&&!v&&ut(Ne,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${A})`}}),N&&ut(W,{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:x,onChange:C})]})})]})};var Mo=({setEdges:e})=>{let{getNode:t}=ii();return{isValidConnection:n=>{let i=t(n.source),a=t(n.target);if((i==null?void 0:i.id)===(a==null?void 0:a.id))return!1;switch(i==null?void 0:i.type){case"START_EVENT":return(a==null?void 0:a.type)==="TASK"||(a==null?void 0:a.type)==="END_EVENT"||(a==null?void 0:a.type)==="GATEWAY"||(a==null?void 0:a.type)==="ANNOTATION";case"END_EVENT":return(a==null?void 0:a.type)==="ANNOTATION";case"TASK":return(a==null?void 0:a.type)==="TASK"||(a==null?void 0:a.type)==="END_EVENT"||(a==null?void 0:a.type)==="GATEWAY"||(a==null?void 0:a.type)==="ANNOTATION";case"GATEWAY":return(a==null?void 0:a.type)==="TASK"||(a==null?void 0:a.type)==="END_EVENT"||(a==null?void 0:a.type)==="GATEWAY"||(a==null?void 0:a.type)==="ANNOTATION";case"LANE":return(a==null?void 0:a.type)==="ANNOTATION";default:return!1}},onConnect:n=>{e(i=>{let a=t(n.target);return(a==null?void 0:a.type)==="ANNOTATION"?Ro(y(y({},n),mt),i):Ro(y(y({},n),se),i)})}}};import{useState as Wo}from"react";import{useTranslation as si}from"lecom-ui";import{useReactFlow as li}from"@xyflow/react";var Me=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ge=(e=[])=>e.filter(t=>t.type==="END_EVENT"),le=(e=[])=>e.filter(t=>t.type==="TASK")||[],Vo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Oo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),gt=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Go=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),X=(e,t=[])=>t.filter(o=>o.source===e),Ve=(e,t=[])=>t.filter(o=>o.target===e),Ho=(e,t)=>{var r,n;let o=(r=t.nodes)==null?void 0:r.find(i=>i.id===e);return((n=o==null?void 0:o.properties)==null?void 0:n.attribute)==="LOOP"},Bo=(e,t)=>{let o=X(e,t.edges||[]);for(let r of o){let n=(t.nodes||[]).find(i=>i.id===r.target);if(n&&n.type==="END_EVENT")return!0}return!1},zo=e=>e?/\w/g.test(e.trim()):!1,R=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)}},Uo=(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 Oe=[{id:"start_event_not_found",validate:e=>{let t=Me(e.nodes);return R({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ge(e.nodes);return R({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Me(e.nodes),o=t.length===1;if(t.length===0)return R({isValid:!0});if(!o)return R({isValid:!1,nodeIds:t.map(i=>i.id)});let r=X(t[0].id,e.edges);if(!(r.length<=1)){let i=[...t.map(a=>a.id),...r.map(a=>a.target)];return R({isValid:!1,nodeIds:[...new Set(i)]})}return R({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=le(e.nodes),o=Q(t,r=>X(r.id,e.edges).length<=2);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=le(e.nodes),o=Q(t,r=>!!r.label&&r.label.trim()!=="");return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=le(e.nodes),r=Q(o,n=>!n.label||n.label.length<=60);return R({isValid:r.isValid,nodeIds:r.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=le(e.nodes),o=new Map;for(let n of t){if(!n.label)continue;let i=n.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(n))}let r=[];for(let[,n]of o.entries())n.length>1&&n.forEach(i=>r.push(i.id));return R({isValid:r.length===0,nodeIds:r})}},{id:"nested_gateway",validate:e=>{let t=gt(e.nodes),o=[],r=[];for(let n of t){let i=X(n.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(n.id,s.id),r.push(a.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"events_nested",validate:e=>{let t=[...Me(e.nodes),...ge(e.nodes)],o=[],r=[];for(let n of t){let i=X(n.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(n.id,s.id),r.push(a.id))}}return R({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 i=Ve(n.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=X(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(d=>r.push(d.id)))}}}return R({isValid:o.length===0,nodeIds:o,edgeIds:r})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Go(e.nodes),o=Q(t,n=>X(n.id,e.edges).length<=2),r=o.invalidIds.flatMap(n=>X(n,e.edges).map(i=>i.id));return R({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:r})}},{id:"activity_name_invalid",validate:e=>{let t=le(e.nodes),o=Q(t,r=>!r.label||zo(r.label));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return R({isValid:!0});let t=ge(e.nodes)[0];if(!t)return R({isValid:!0});let o=Ve(t.id,e.edges);if(!o.length)return R({isValid:!0});let n=le(e.nodes).filter(l=>o.some(d=>d.source===l.id)),i=Q(n,l=>!Ho(l.id,e));return R({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=le(e.nodes),o=ge(e.nodes)[0];if(!o)return R({isValid:!0});let r=t.filter(l=>{let d=Ve(l.id,e.edges),f=X(l.id,e.edges),E=d.some(u=>{var v;return((v=e.nodes.find(x=>x.id===u.source))==null?void 0:v.type)==="START_EVENT"}),m=f.some(u=>{var v;return((v=e.nodes.find(x=>x.id===u.target))==null?void 0:v.type)==="END_EVENT"});return E&&m}),n=Ve(o.id,e.edges),i=n.length>1,a=n.map(l=>l.source),s={isValid:r.length===0&&!i,nodeIds:[...r.map(l=>l.id),...i?a:[]]};return R(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=gt(e.nodes),o=[],r=[];for(let n of t){let i=X(n.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(n.id,s.id),r.push(a.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"gateway_missing_output_streams",validate:e=>{let t=gt(e.nodes),o=Q(t,r=>X(r.id,e.edges).length>=1);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Me(e.nodes),...ge(e.nodes)],o=[],r=[];for(let n of t){let i=X(n.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(n.id,s.id),r.push(a.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:r})}},{id:"script_in_final_activity",validate:e=>{let t=Vo(e.nodes),o=Q(t,r=>!Bo(r.id,e));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Oo(e.nodes),o=Q(t,r=>{var n,i;return((n=r.properties)==null?void 0:n.subprocessRef)!==void 0&&((i=r.properties)==null?void 0:i.subprocessRef)!==""});return R({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Fo=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let r of Oe){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 Yo=()=>{let{t:e}=si(),[t,o]=Wo(null),{setNodes:r,setEdges:n,getNodes:i,getEdges:a}=li(),[s,l]=Wo(!1);return{validationResult:t,validateDiagram:m=>{let u=Uo(m.nodes,m.edges),v=Fo(u),x=v.errors.map(b=>w(y({},b),{message:e(`validation.errors.${b.id}`)}));return s||l(!0),{isValid:v.isValid,errors:x}},handleValidationComplete:m=>{if(o(m),!m)return;let u=[],v=[];m.errors.forEach(p=>{p.nodeIds&&p.nodeIds.length>0&&p.nodeIds.forEach(N=>u.push(N)),p.edgeIds&&p.edgeIds.length>0&&p.edgeIds.forEach(N=>v.push(N))});let x=[...new Set(u)];r(p=>p.map(N=>w(y({},N),{data:w(y({},N.data),{hasError:!1})}))),n(p=>p.map(N=>w(y({},N),{data:w(y({},N.data),{hasError:!1})})));let b=i(),g=a(),h=new Set(x),k=new Set;m.errors.forEach(p=>{var _,S;let N=Oe.find(C=>C.id===p.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((_=p.edgeIds)==null||_.forEach(C=>k.add(C)),(S=p.nodeIds)==null||S.forEach(C=>{g.forEach(P=>{(P.source===C||P.target===C)&&k.add(P.id)})}))});let c=new Set,T=new Set,I=new Set;b.forEach(p=>{p.type==="START_EVENT"?c.add(p.id):p.type==="END_EVENT"&&T.add(p.id)}),g.forEach(p=>{c.has(p.source)&&I.add(p.target),T.has(p.target)&&I.add(p.source)}),I.forEach(p=>{var N,A;if(h.has(p)){let _=(N=m.errors.find(C=>{var P;return(P=C.nodeIds)==null?void 0:P.includes(p)}))==null?void 0:N.id;((A=Oe.find(C=>C.id===_))==null?void 0:A.highlightRelatedEdges)!==!1&&g.forEach(C=>{C.source===p&&T.has(C.target)&&(h.add(C.target),k.add(C.id)),C.target===p&&c.has(C.source)&&(h.add(C.source),k.add(C.id))})}}),h.size>0&&r(p=>p.map(N=>w(y({},N),{data:w(y({},N.data),{hasError:h.has(N.id)})}))),k.size>0&&n(p=>p.map(N=>w(y({},N),{data:w(y({},N.data),{hasError:k.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),r(m=>m.map(u=>w(y({},u),{data:w(y({},u.data),{hasError:!1})}))),n(m=>m.map(u=>w(y({},u),{data:w(y({},u.data),{hasError:!1})})))},isAutoValidationEnabled:s}};import{useReactFlow as di}from"@xyflow/react";import{useEffect as ci}from"react";import{v7 as Ko}from"uuid";var pi=15,Zo="bpmn:selection",$o=({offset:e=pi}={})=>{let{getNodes:t,setNodes:o,getEdges:r,setEdges:n}=di();ci(()=>{let i=s=>{var u;s.preventDefault();let l=t(),d=r(),f=l.filter(v=>v.selected);if(!f.length)return;let E=d.filter(v=>f.some(x=>x.id===v.source)&&f.some(x=>x.id===v.target)),m={nodes:f,edges:E};(u=s.clipboardData)==null||u.setData(Zo,JSON.stringify(m))},a=s=>{var m,u;s.preventDefault();let l=JSON.parse(((m=s.clipboardData)==null?void 0:m.getData(Zo))||"{}");if(!((u=l.nodes)!=null&&u.length))return;let d=new Map,f=l.nodes.map(v=>{let x=Ko();return d.set(v.id,x),w(y({},v),{id:x,selected:!0,position:{x:v.position.x+e,y:v.position.y+e}})}),E=l.edges.map(v=>w(y({},v),{id:Ko(),selected:!0,source:d.get(v.source)||v.source,target:d.get(v.target)||v.target}));o(v=>[...v.map(x=>w(y({},x),{selected:!1})),...f]),n(v=>[...v.map(x=>w(y({},x),{selected:!1})),...E])};return document.addEventListener("copy",i),document.addEventListener("paste",a),()=>{document.removeEventListener("copy",i),document.removeEventListener("paste",a)}},[t,o,r,n,e])};import{useReactFlow as Ti,useStoreApi as xi}from"@xyflow/react";import{v7 as Qo}from"uuid";import{create as mi}from"zustand";var ye=mi(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as ui,EdgeLabelRenderer as gi,getSmoothStepPath as fi,MarkerType as Ei,useNodes as bi,useReactFlow as hi,useViewport as vi}from"@xyflow/react";import{useState as Ni}from"react";import{jsx as ft,jsxs as Xo}from"react/jsx-runtime";var Km={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:Ei.Arrow},data:{label:""}},qo=({id:e,source:t,target:o,sourceX:r,sourceY:n,targetX:i,targetY:a,sourcePosition:s,targetPosition:l,data:d,selected:f})=>{let E=bi(),{zoom:m}=vi(),{updateEdgeData:u}=hi(),{isMultipleSelection:v}=V(),[x,b]=Ni(!1),g=E.find(P=>P.id===t),h=E.find(P=>P.id===o),[k,c,T]=fi({sourceX:r,sourceY:n,sourcePosition:s,targetX:i,targetY:a,targetPosition:l}),I=f||(g==null?void 0:g.selected)||(h==null?void 0:h.selected),p=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=x||(d==null?void 0:d.label.trim().length)>0,A=1/m,_=()=>{b(!0)},S=()=>{b(!1)},C=P=>{u(e,{label:P.trim()})};return Xo("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:S,onDoubleClick:_,children:[ft(ui,{id:e,path:k,markerEnd:`url(#${p})`,strokeDasharray:4,className:L("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)]":I&&!(d!=null&&d.hasError)})}),ft(gi,{children:Xo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${c}px, ${T}px)`},children:[f&&!v&&ft(Ne,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${A})`}}),N&&ft(W,{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:x,onChange:C})]})})]})};import{jsx as jo,jsxs as yi}from"react/jsx-runtime";var Jo=({fromX:e,fromY:t,toX:o,toY:r})=>yi("g",{children:[jo("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${r} ${e} ${r} ${o},${r}`}),jo("circle",{cx:o,cy:r,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var er=({nodes:e,setNodes:t,setEdges:o})=>{let r=xi(),{draggableNode:n,setDraggableNode:i}=ye(),{getInternalNode:a,screenToFlowPosition:s}=Ti(),l=b=>{let g="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(h=>h.map(k=>w(y({},k),{className:k.id===b?g:""})))},d=()=>{let{nodeLookup:b}=r.getState();return Array.from(b.values())},f=b=>{let g=a(b.id),h=d();if(b.type==="LANE"){if(ve({parentId:b.id,nodes:e,includeTypes:["LANE"]})){l();return}let N=h.filter(S=>S.id!==b.id&&S.type==="LANE"&&!S.parentId),A=Pe(g,N);if(!A){l();return}if(ve({parentId:A.id,nodes:e,excludeTypes:["LANE"]})){l();return}l(A.id);return}let c=h.filter(p=>p.id!==b.id&&p.type==="LANE"),T=Pe(g,c);if(!T){l();return}if(ve({parentId:T.id,nodes:e,includeTypes:["LANE"]})){l();return}l(T.id)},E=b=>{b.preventDefault(),b.dataTransfer.dropEffect="move"},m=(b,g)=>{b.preventDefault(),f(g)},u=(b,g,h)=>{var N,A;let k=_=>_.map(S=>w(y({},S),{className:void 0}));if(b.parentId===g.id){let _=ue(g.id,h);t(re(k(_)));return}if(b.type==="LANE"){if(ve({parentId:g.id,nodes:h,excludeTypes:["LANE"]}))return;let C=h.filter(O=>O.parentId===g.id).reduce((O,ae)=>{var pe,me;return O+((me=(pe=ae.measured)==null?void 0:pe.height)!=null?me:0)},0),P={x:K.HEADER_WIDTH,y:C},D=h.map(O=>O.id===b.id?w(y({},O),{parentId:g.id,position:P,className:void 0}):w(y({},O),{className:void 0}));D=ue(g.id,D),t(re(D));return}if(ve({parentId:g.id,nodes:h,includeTypes:["LANE"]})){let _;if(b.parentId){let C=a(b.parentId),{x:P,y:D}=oe(C);_={x:P+((N=b.position.x)!=null?N:0),y:D+((A=b.position.y)!=null?A:0)}}let S=h.map(C=>C.id===b.id?w(y({},C),{position:_!=null?_:C.position,parentId:void 0,className:void 0}):w(y({},C),{className:void 0}));t(re(S));return}let I=vo(b,g),p=h.map(_=>_.id===b.id?w(y({},_),{parentId:g.id,position:I,className:void 0}):w(y({},_),{className:void 0}));t(re(p))};return{onDragOver:E,onDrop:b=>{if(b.preventDefault(),!(n!=null&&n.type))return;let g=s({x:b.clientX,y:b.clientY}),h={width:G[n.type].MIN_WIDTH,height:G[n.type].MIN_HEIGHT},k={id:Qo(),type:n.type,position:g,measured:h,data:{label:"",variant:n.variant,attribute:n.attribute}},c=w(y({},k),{internals:{positionAbsolute:g}}),T=d(),I=n.type==="LANE",p=T.filter(_=>I?_.type==="LANE"&&!_.parentId:_.type==="LANE"),N=Pe(c,p);N?u(c,N,[...T,c]):t(_=>{let S=_.concat(k);return re(S)});let A=b.dataTransfer.getData("sourceId");if(A){let _={id:Qo(),source:A,target:k.id};if(n.type==="ANNOTATION"){o(S=>S.concat(y(y({},_),mt)));return}o(S=>S.concat(y(y({},_),se)))}i(null)},onNodeDrag:m,onNodeDragStop:async(b,g)=>{var N,A;let{nodeLookup:h}=r.getState(),k=a(g.id),c=Array.from(h.values()),T=g.type==="LANE",I=c.filter(_=>_.id!==g.id&&(T?_.type==="LANE"&&!_.parentId:_.type==="LANE")),p=Pe(k,I);if(p){u(k,p,c);return}if(g.parentId){let _=a(g.parentId),{x:S,y:C}=oe(_),P={x:S+((N=g.position.x)!=null?N:0),y:C+((A=g.position.y)!=null?A:0)},D=e.map(O=>O.id===g.id?w(y({},O),{position:P,parentId:void 0}):O);D=ue(g.parentId,D),t(re(D))}}}};import{applyNodeChanges as _i}from"@xyflow/react";import{useCallback as wi,useState as or}from"react";function tr(e,t,o=5){var l,d,f,E,m,u,v,x;let r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},n=t.find(b=>b.id===e.id);if(!n||!e.position)return r;let i={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+((E=(f=n.measured)==null?void 0:f.height)!=null?E:0),width:(u=(m=n.measured)==null?void 0:m.width)!=null?u:0,height:(x=(v=n.measured)==null?void 0:v.height)!=null?x:0},a=o,s=o;return t.filter(b=>b.id!==n.id).reduce((b,g)=>{var S,C,P,D,O,ae,pe,me;let h={left:g.position.x,right:g.position.x+((C=(S=g.measured)==null?void 0:S.width)!=null?C:0),top:g.position.y,bottom:g.position.y+((D=(P=g.measured)==null?void 0:P.height)!=null?D:0),width:(ae=(O=g.measured)==null?void 0:O.width)!=null?ae:0,height:(me=(pe=g.measured)==null?void 0:pe.height)!=null?me:0},k=Math.abs(i.left-h.left);k<s&&(b.snapPosition.x=h.left,b.vertical=h.left,s=k);let c=Math.abs(i.right-h.right);c<s&&(b.snapPosition.x=h.right-i.width,b.vertical=h.right,s=c);let T=Math.abs(i.left-h.right);T<s&&(b.snapPosition.x=h.right,b.vertical=h.right,s=T);let I=Math.abs(i.right-h.left);I<s&&(b.snapPosition.x=h.left-i.width,b.vertical=h.left,s=I);let p=Math.abs(i.top-h.top);p<a&&(b.snapPosition.y=h.top,b.horizontal=h.top,a=p);let N=Math.abs(i.bottom-h.top);N<a&&(b.snapPosition.y=h.top-i.height,b.horizontal=h.top,a=N);let A=Math.abs(i.bottom-h.bottom);A<a&&(b.snapPosition.y=h.bottom-i.height,b.horizontal=h.bottom,a=A);let _=Math.abs(i.top-h.bottom);return _<a&&(b.snapPosition.y=h.bottom,b.horizontal=h.bottom,a=_),b},r)}var rr=()=>{let[e,t]=or(void 0),[o,r]=or(void 0),n=wi((i,a)=>{var s,l;if(t(void 0),r(void 0),i.length===1&&i[0].type==="position"&&i[0].dragging&&i[0].position){let d=tr(i[0],a);i[0].position.x=(s=d.snapPosition.x)!=null?s:i[0].position.x,i[0].position.y=(l=d.snapPosition.y)!=null?l:i[0].position.y,t(d.horizontal),r(d.vertical)}return _i(i,a)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:n}};import{useReactFlow as Ii}from"@xyflow/react";import{v7 as lr}from"uuid";var ar={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},ir={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},nr=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],r=e.match(/(\[.*?\])/)||[],n=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return r.length&&(a="task",s=r[1].replace(/\[|\]/g,""),e=e.replace(r[1],"")),n.length&&(a="gateway-exclusive",s=n[1].replace(/\{|\}/g,""),e=e.replace(n[1],"")),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},Ci=e=>{e=e||"";let t=e.trim().split(`
2
- `),o={},r=[];return t.forEach(n=>{n=n||"";let i=n.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=nr(i[0],o),s=nr(i[1],o);a&&s&&r.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:r}},sr=e=>{let{components:t,connections:o}=Ci(e);return{nodes:t,edges:o}};var dr=()=>{let{setNodes:e,setEdges:t,fitView:o}=Ii();return{createDiagram:n=>{let{nodes:i,edges:a}=sr(n),s=[],l=new Map;for(let[m,u]of Object.entries(i)){let v=lr(),x=ar[u.type],b=ir[u.type];l.set(m,v);let g=G[x].MIN_WIDTH,h=G[x].MIN_HEIGHT;s.push({id:v,type:x,data:{label:u.label||"",variant:b,attribute:""},position:{x:0,y:0},width:g,height:h,measured:{width:g,height:h}})}let d=[];for(let m of a){let u=w(y({},se),{id:lr(),source:l.get(m.sourceId)||m.sourceId,target:l.get(m.targetId)||m.targetId});d.push(u)}let{nodes:f,edges:E}=To(s,d);e(f),t(E),o()}}};import{useEffect as Ai,useCallback as Si}from"react";var ki={origin:"*",debug:!1};function cr(e,t=ki){let{origin:o,debug:r}=t,n=Si((i,a)=>{r&&console.debug("[postMessage] sending:",{type:i,payload:a}),window.parent.postMessage({type:i,payload:a},o||"*")},[o,r]);return Ai(()=>{let i=a=>{let{type:s,data:l}=a.data||{};r&&console.debug("[postMessage] received:",a.data),s&&e[s]&&e[s](l)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,r]),{sendMessage:n}}import{useReactFlow as Li}from"@xyflow/react";var pr=(e,t)=>{let{getNodes:o,getEdges:r}=Li();return{selectElement:a=>{let s=o().map(d=>w(y({},d),{selected:d.id===a})),l=r().map(d=>w(y({},d),{selected:d.id===a}));return e(s),t(l),!0},isReady:()=>!0}};import{useReactFlow as Pi}from"@xyflow/react";import{useCallback as Ge,useState as mr}from"react";import{useDebouncedCallback as Di}from"use-debounce";var Ri={nodes:[],edges:[]},Mi=500,ur=10,gr=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:r}=Pi(),[n,i]=mr([Ri]),[a,s]=mr(0),l=n[a],d=a>0,f=a<n.length-1,E=Ge(h=>{o(n[h].nodes),r(n[h].edges)},[n,o,r]),m=Ge(()=>{if(a>0){let h=a-1;s(h),E(h)}},[a,E]),u=Ge(()=>{if(a<n.length-1){let h=a+1;s(h),E(h)}},[n,a,E]),v=h=>{let c=[...n.slice(0,a+1),h],T=c.length>ur?c.slice(c.length-ur):c;i(T),s(T.length-1)},x=Di(()=>{let h=e(),k=t(),c={nodes:h,edges:k};JSON.stringify(l)!==JSON.stringify(c)&&v(c)},Mi),b=Ge(h=>{if(h==="forceSave"){x();return}h.some(c=>c.type!=="select")&&x()},[x]),g=Ge(()=>{i([]),s(0)},[]);return{undo:m,redo:u,saveHistory:b,canUndo:d,canRedo:f,clearHistory:g}};import{jsx as fr}from"react/jsx-runtime";var Ft=({id:e,className:t})=>fr("marker",{id:e,className:L("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:fr("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Wt,jsxs as Vi}from"react/jsx-runtime";var Er=()=>Wt("svg",{style:{position:"absolute",top:0,left:0},children:Vi("defs",{children:[Wt(Ft,{id:"sequence-edge-marker",className:"text-grey-400"}),Wt(Ft,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as Rr}from"@xyflow/react";import{Button as yt,Tooltip as Tt,TooltipContent as xt,TooltipTrigger as _t,useTranslation as Ls}from"lecom-ui";import{HandIcon as Ps,ListCheckIcon as Ds,MapIcon as Rs,MousePointerIcon as Ms}from"lucide-react";import{useCallback as Vs,useEffect as Mr}from"react";import{useStore as Oi}from"@xyflow/react";var Gi=e=>({unselectAll:e.unselectNodesAndEdges}),He=()=>{let{unselectAll:e}=Oi(Gi);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as ds,TooltipContent as cs,TooltipTrigger as ps,useNotificationToast as ms,useTranslation as us}from"lecom-ui";var Be=(g=>(g.START_EVENT="START_EVENT",g.END_EVENT="END_EVENT",g.TASK="TASK",g.SUBPROCESS="SUBPROCESS",g.GATEWAY="GATEWAY",g.ANNOTATION="ANNOTATION",g.CONNECTION="CONNECTION",g.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",g.ACTIVITY="ACTIVITY",g.PROCESS_INTERFACE="PROCESS_INTERFACE",g.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",g.VARIANT_ACTIVITY="VARIANT_ACTIVITY",g.AUTO_ACTIVITY="AUTO_ACTIVITY",g.DATA_STORE="DATA_STORE",g.DATA_OBJECT="DATA_OBJECT",g.DATA_OUTPUT="DATA_OUTPUT",g.DATA_INPUT="DATA_INPUT",g))(Be||{});import{useReactFlow as es}from"@xyflow/react";import{useNotificationToast as ts,useTranslation as os,Button as rs}from"lecom-ui";var br=async e=>new Promise((t,o)=>{let r=new FileReader;r.onload=n=>{var i;t((i=n.target)==null?void 0:i.result)},r.onerror=n=>{var i;o((i=n.target)==null?void 0:i.error)},r.readAsText(e)});function hr({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let n="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
3
- `),i=encodeURI(n);Et(i,`${o}.csv`)}var Et=(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 Xi}from"uuid";import{xml2json as Hi,json2xml as og}from"xml-js";var Bi={compact:!0,spaces:4},zi=e=>e.replaceAll(`
4
- `,"&#xA;");function vr(e,t=Bi){if(e)return JSON.parse(Hi(e,w(y({},t),{attributeValueFn:zi})))}function Nr(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as Fi}from"uuid";var lg={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},yr={script:"SCRIPT",subprocess:"SUBPROCESS"},Tr={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Te=({cell:e,type:t,variant:o=""})=>{let{_attributes:r,mxGeometry:n}=e,{value:i}=r,a=Number(n._attributes.width),s=Number(n._attributes.height);return{id:r.id,type:t,data:{label:i||"",variant:o,attribute:""},position:{x:Number(n._attributes.x),y:Number(n._attributes.y)},width:a,height:s,measured:{width:a,height:s}}},Wi=e=>{let{subType:t,style:o}=e._attributes,r="imported";return["none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=G.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.START_EVENT.MIN_HEIGHT,{node:Te({cell:e,type:"START_EVENT"}),status:r,originalType:o}},Yi=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,r="imported";return["none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=G.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.END_EVENT.MIN_HEIGHT,{node:Te({cell:e,type:"END_EVENT"}),status:r,originalType:o}},Ki=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,r=yr[t],n="imported";return["script","none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=Se(e.mxGeometry._attributes.width,G.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Se(e.mxGeometry._attributes.height,G.TASK.MIN_HEIGHT),{node:Te({cell:e,type:"TASK",variant:r}),status:n,originalType:o}},Zi=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,r=Tr[o],n=["none","inclusive","event-based"],i="imported";return n.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=G.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=G.GATEWAY.MIN_HEIGHT,{node:Te({cell:e,type:"GATEWAY",variant:r}),status:i,originalType:t}},$i=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Se(e.mxGeometry._attributes.width,G.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Se(e.mxGeometry._attributes.height,G.ANNOTATION.MIN_HEIGHT),{node:Te({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},xr=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=G.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=G.UNSUPPORTED.MIN_HEIGHT,{node:Te({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},_r=(e,t)=>{let{source:o,target:r}=e._attributes;return w(y({},se),{id:Fi(),source:t.get(o)||o,target:t.get(r)||r})},wr={TASK:Ki,GATEWAY:Zi,START_EVENT:Wi,END_EVENT:Yi,ANNOTATION:$i};var qi=e=>{var a;let t=new Map,o=Object.values(Be),r=e.filter(s=>{var l;return o.includes((l=s._attributes)==null?void 0:l.type)}),n=[],i=[];for(let s of r){let l=Xi(),{type:d}=s._attributes,f=wr[d]||xr;t.set((a=s._attributes)==null?void 0:a.id,l),s._attributes.id=l;let{node:E,status:m,originalType:u}=f(s);n.push(E),i.push({originalType:u,type:E.type,variant:E.data.variant,value:Nr(E.data.label),status:m})}return{nodes:n,governanceIdToNodeIdMap:t,summary:i}},ji=(e,t)=>e.filter(n=>{var i;return(i=n._attributes)==null?void 0:i.edge}).map(n=>_r(n,t)),Ji=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:r,summary:n}=qi(t.root.mxCell),i=ji(t.root.mxCell,r);return{nodes:o,edges:i,summary:n}},Qi=async e=>{let t=await br(e),o=vr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:r,mxGraphModel:n}=o.modeler||{},i=(r==null?void 0:r.app)&&(r==null?void 0:r.diagramType)&&(r==null?void 0:r.version),a=n==null?void 0:n.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(n.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:r,mxGraphModel:n}},Cr=async e=>{try{let t=await Qi(e),{nodes:o,edges:r,summary:n}=Ji(t)||{};return{nodes:o,edges:r,summary:n}}catch(t){throw t}};import{jsx as ns}from"react/jsx-runtime";var Ir=()=>{let{t:e}=os(),{toast:t}=ts(),{setNodes:o,setEdges:r,fitView:n}=es(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],d=s.map(f=>[f.originalType,f.value,e(`adapter.governance.report.status.${f.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:ns(rs,{size:"small",variant:"ghost",onClick:()=>hr({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:f}=await Cr(s);if(o(m=>m.concat(l)),r(m=>m.concat(d)),n(),f.some(m=>m.status==="unsupported")){i(f);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 as}from"lecom-ui";import{useRef as is}from"react";import{Fragment as ss,jsx as Ar,jsxs as ls}from"react/jsx-runtime";var Sr=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:r=!1,onClick:n,onFilesSelected:i}=l,a=Ee(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let d=is(null),f=m=>{let u=m.target.files;u!=null&&u.length&&i(u),d.current&&(d.current.value="")};return ls(ss,{children:[Ar(as,w(y({onClick:m=>{var u;(u=d.current)==null||u.click(),n==null||n(m)}},a),{children:e})),Ar("input",{type:"file",ref:d,className:"sr-only",accept:t,multiple:o,disabled:r,onChange:f})]})};import{jsx as bt,jsxs as gs}from"react/jsx-runtime";var kr=({disabled:e=!1})=>{let{t}=us(),{toast:o}=ms(),{createDiagram:r}=Ir(),n=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}r(s)};return gs(ds,{children:[bt(ps,{asChild:!0,children:bt(Sr,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:n,onFilesSelected:i,children:bt(co,{})})}),bt(cs,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{Button as ys,DropdownMenu as Ts,DropdownMenuContent as xs,DropdownMenuItem as Kt,DropdownMenuTrigger as _s,Tooltip as ht,TooltipContent as vt,TooltipTrigger as Nt,useTranslation as ws}from"lecom-ui";import{FileCodeIcon as Cs,FileImageIcon as Is,FolderOutputIcon as As,PrinterIcon as Ss}from"lucide-react";import{useState as ks}from"react";import{useReactFlow as fs}from"@xyflow/react";import{toPng as Lr,toSvg as Es}from"html-to-image";import{toast as bs,useTranslation as hs}from"lecom-ui";import{useState as vs}from"react";var Ns=3,Yt="diagram",Pr=()=>{let{t:e}=hs(),{getNodes:t}=fs(),{deselectAll:o}=He(),[r,n]=vs({png:!1,html:!1,print:!1}),i=()=>{let{x:f,y:E,width:m,height:u}=_o(t());return{width:m,height:u,style:{width:`${m}px`,height:`${u}px`,transform:`translate(${-f}px, ${-E}px)`}}},a=async(f,E)=>{n(w(y({},r),{[E]:!0})),await o();try{let m=xo();if(!m)throw new Error("Flow element not found");let u=i();return await f(m,u)}catch(m){bs({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{n(w(y({},r),{[E]:!1}))}};return{exportAsPng:async(f=Yt)=>{await a(async(E,m)=>{let u=await Lr(E,w(y({},m),{backgroundColor:"#fcfcfc"}));Et(u,`${f}.png`)},"png")},exportAsHtml:async(f=Yt)=>{await a(async(E,m)=>{let u=await Es(E,w(y({},m),{backgroundColor:"#fcfcfc"})),v=`
1
+ var pa=Object.defineProperty,ua=Object.defineProperties;var ma=Object.getOwnPropertyDescriptors;var Je=Object.getOwnPropertySymbols;var yo=Object.prototype.hasOwnProperty,To=Object.prototype.propertyIsEnumerable;var vo=(e,t,o)=>t in e?pa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))yo.call(t,o)&&vo(e,o,t[o]);if(Je)for(var o of Je(t))To.call(t,o)&&vo(e,o,t[o]);return e},I=(e,t)=>ua(e,ma(t));var le=(e,t)=>{var o={};for(var n in e)yo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Je)for(var n of Je(e))t.indexOf(n)<0&&To.call(e,n)&&(o[n]=e[n]);return o};import{TooltipProvider as ga,Notification as fa}from"lecom-ui";import{jsx as Ea,jsxs as ba}from"react/jsx-runtime";function No({children:e}){return ba(ga,{children:[Ea(fa,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as Wd,MiniMap as Yd,ReactFlow as Kd,ReactFlowProvider as $d,SelectionMode as Xd,useEdgesState as Zd,useNodesState as qd,useOnSelectionChange as jd,useReactFlow as Jd}from"@xyflow/react";import{i18n as Ur}from"lecom-ui";import{forwardRef as Qd,useCallback as co,useEffect as mo,useImperativeHandle as ec,useRef as tc,useState as oc}from"react";import{useDebouncedCallback as nc}from"use-debounce";import{v7 as po}from"uuid";var zt=(a=>(a.ACTIVITY="activity",a.ROUTING="routing",a.GATEWAY="gateway",a.SUB_PROCESS="sub_process",a))(zt||{}),Ft=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Ft||{}),Ut=(l=>(l.SIMPLE="simple",l.LOOP="loop",l.SCRIPT="script",l.COMPLEX="complex",l.EXCLUSIVE="exclusive",l.PARALLEL="parallel",l.FINAL="final",l.TO_SUB_PROCESS="to_sub_process",l))(Ut||{}),Wt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Wt||{}),Yt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Yt||{});import{RotateCcw as Sa,ScrollText as ka,SquarePlus as La}from"lucide-react";import{jsx as Qe,jsxs as ha}from"react/jsx-runtime";var et=({size:e=24,className:t})=>ha("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[Qe("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),Qe("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),Qe("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),Qe("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as _o}from"react/jsx-runtime";var Ne=({size:e=24,className:t})=>_o("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:_o("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 De,jsxs as va}from"react/jsx-runtime";var tt=({size:e=24,className:t})=>va("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:[De("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"}),De("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Kt,jsxs as ya}from"react/jsx-runtime";var _e=({size:e=24,className:t})=>ya("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:[Kt("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"}),Kt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Kt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $t,jsxs as Ta}from"react/jsx-runtime";var ot=({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:[$t("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"}),$t("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),$t("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Xt,jsxs as Na}from"react/jsx-runtime";var xo=({size:e=24,className:t})=>Xt("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Na("g",{children:[Xt("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"}),Xt("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as _a}from"clsx";import{twMerge as xa}from"tailwind-merge";function L(...e){return xa(_a(e))}var Re=(e,t)=>e<t?t:e;import{jsx as wo,jsxs as wa}from"react/jsx-runtime";var Co=({size:e=24,className:t})=>wa("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:L("stroke-2",t),children:[wo("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"}),wo("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zt}from"react/jsx-runtime";var Ao=({size:e=24,className:t})=>Zt("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Zt("g",{children:Zt("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 Io}from"react/jsx-runtime";var nt=({size:e=24,className:t})=>Io("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:Io("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 So}from"react/jsx-runtime";var Ve=({size:e=24,className:t})=>So("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:L("stroke-2",t),children:So("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 qt,jsxs as Ca}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>Ca("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:[qt("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"}),qt("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"}),qt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Me,jsxs as Aa}from"react/jsx-runtime";var Lo=({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:[Me("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"}),Me("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"}),Me("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"}),Me("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Me("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as rt,jsxs as Ia}from"react/jsx-runtime";var Po=({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:[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:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),rt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),rt("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var V=(r=>(r.START_EVENT="START_EVENT",r.END_EVENT="END_EVENT",r.TASK="TASK",r.LANE="LANE",r.GATEWAY="GATEWAY",r.ANNOTATION="ANNOTATION",r.UNSUPPORTED="UNSUPPORTED",r))(V||{});var at={SCRIPT:{icon:ka},SUBPROCESS:{icon:La}};var it={LOOP:{icon:Sa}},te=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(te||{}),st={EXCLUSIVE:{icon:_e},PARALLEL:{icon:ot},COMPLEX:{icon:tt}};import Vo from"@dagrejs/dagre";import{getNodesBounds as Ha}from"@xyflow/react";import{orderBy as Ba}from"lodash";var Pa={MIN_WIDTH:36,MIN_HEIGHT:36},Da={MIN_WIDTH:36,MIN_HEIGHT:36},Ra={MIN_WIDTH:56,MIN_HEIGHT:56},lt={MIN_WIDTH:176,MIN_HEIGHT:96},dt={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},$={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},ct={MIN_WIDTH:176,MIN_HEIGHT:64},Va={MIN_WIDTH:128,MIN_HEIGHT:64},H={START_EVENT:Pa,END_EVENT:Da,GATEWAY:Ra,TASK:lt,LANE:$,ANNOTATION:ct,UNSUPPORTED:Va};import{orderBy as Ma}from"lodash";var de=e=>{var t,o,n,a,i,s,r,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(a=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?a:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(r=e.measured)==null?void 0:r.height)!=null?l:0}},ce=e=>Ma(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),Do=(e,t)=>{let{x:o,y:n}=de(e),{x:a,y:i}=de(t);return{x:o-a,y:n-i}};var xe=({parentId:e,nodes:t,includeTypes:o=[...Object.values(V)],excludeTypes:n=[]})=>t.some(a=>a.parentId===e&&(!o.length||o.includes(a.type))&&!n.includes(a.type)),Oa=(e,t)=>{let{x:o,y:n}=de(e),{x:a,y:i}=de(t),s=o-a,r=n-i;return Math.sqrt(s*s+r*r)},Ga=(e,t)=>{let{x:o,y:n,w:a,h:i}=de(e),{x:s,y:r,w:l,h:c}=de(t);return o<s+l&&s<o+a&&n<r+c&&r<n+i},Oe=(e,t)=>{let o=null,n=1/0;for(let a of t)if(a.id!==e.id&&Ga(e,a)){let i=Oa(e,a);i<n&&(n=i,o=a)}return o},Ro=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var a,i;return Math.max(o,(i=(a=n.measured)==null?void 0:a.width)!=null?i:0)},0);var Mo=(e=[],t=[],o="LR")=>{let n=new Vo.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:r})=>n.setNode(i,{width:s,height:r})),t.forEach(i=>n.setEdge(i.source,i.target)),Vo.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return I(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},fe=(e,t)=>{var f,b;let o=[...t],n=o.find(g=>g.id===e);if(!n)return o;let a=o.filter(g=>g.parentId===e&&g.type==="LANE");if(a.length===0)return o;let i=Ba(a,["position.y"]),s=Math.max((b=(f=n.measured)==null?void 0:f.width)!=null?b:0,dt.MIN_WIDTH),r=Ro(e,i)||$.MIN_WIDTH,l=Math.max(s,r),c=0,u=0;i.forEach(g=>{var T,N,m,d;o=o.map(w=>w.id===g.id?I(_({},w),{width:l-$.HEADER_WIDTH,measured:I(_({},w.measured),{width:l-$.HEADER_WIDTH}),position:{x:$.HEADER_WIDTH,y:c}}):w),c+=(N=(T=g.measured)==null?void 0:T.height)!=null?N:0,u+=(d=(m=g.measured)==null?void 0:m.height)!=null?d:0}),o=o.map(g=>g.id===e?I(_({},g),{height:u,width:l,measured:I(_({},g.measured),{height:u,width:l})}):g);let E=o.find(g=>g.id===e);return E!=null&&E.parentId&&(o=fe(E.parentId,o)),o},Oo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},za=50,Go=(e,t=za)=>{let o=Ha(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 Zo,useReactFlow as Ni}from"@xyflow/react";import{BaseEdge as si,EdgeLabelRenderer as li,getStraightPath as di,useNodes as ci,useViewport as pi}from"@xyflow/react";import{getIncomers as Ge,getOutgoers as jt,useReactFlow as Ya}from"@xyflow/react";import{Button as Ka,Tooltip as $a,TooltipContent as Xa,TooltipTrigger as Za,useTranslation as qa}from"lecom-ui";import{PencilIcon as ja}from"lucide-react";import{createContext as Ua,useContext as Wa}from"react";var Ho=Ua(null),Bo=Ho.Provider,zo=()=>{let e=Wa(Ho);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as pt,jsxs as Ja}from"react/jsx-runtime";var He=({elementId:e,elementType:t="node"})=>{let{t:o}=qa(),{getNode:n,getEdge:a,getNodes:i,getEdges:s}=Ya(),{onConfigureElement:r}=zo(),l=p=>{var x,S,h,y,k;return p?p.type==="TASK"&&((x=p.data)==null?void 0:x.variant)==="SUBPROCESS"?{id:p.id,type:"sub_process",variant:u(p),label:(S=p.data)==null?void 0:S.label}:p.type==="GATEWAY"?{id:p.id,type:"gateway",variant:((h=p.data)==null?void 0:h.variant)||"EXCLUSIVE",label:(y=p.data)==null?void 0:y.label}:{id:p.id,type:"activity",variant:u(p),label:(k=p.data)==null?void 0:k.label}:null},c=p=>{let x=i(),S=s(),h=Ge(p,x,S);if(h.length===0)return;let y=h[0];return l(y)||void 0},u=p=>{let x=i(),S=s(),h=Ge(p,x,S),y=jt(p,x,S),k=h.some(C=>C.type==="START_EVENT"),P=y.some(C=>C.type==="END_EVENT");return k?"start":P?"end":"between"},E=p=>{var C,v,A,D;let x=i(),S=s(),h=n(p.source),y=n(p.target);if(!h||!y)return"simple";if(jt(h,x,S).some(R=>R.type==="END_EVENT"))return"final";if(h.type==="GATEWAY")switch((C=h.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(h.type==="TASK"){let R=(v=h.data)==null?void 0:v.variant,G=(A=h.data)==null?void 0:A.attribute;return y.type==="TASK"&&((D=y.data)==null?void 0:D.variant)==="SUBPROCESS"?"to_sub_process":R==="SCRIPT"?"script":G==="LOOP"?"loop":"simple"}return"simple"},f=p=>{var C;let x=n(p.source);if(!x||x.type!=="GATEWAY"||((C=x.data)==null?void 0:C.variant)!=="COMPLEX")return;let S=i(),h=s(),y=Ge(x,S,h),k=!1,P=!1;if(y.forEach(v=>{var A,D;v.type==="TASK"&&(((A=v.data)==null?void 0:A.variant)==="SCRIPT"&&(k=!0),((D=v.data)==null?void 0:D.attribute)==="LOOP"&&(P=!0))}),k&&P)return"script_loop";if(k)return"script";if(P)return"loop"},b=p=>{var C;let x=n(p.source);if(!x||x.type!=="GATEWAY"||((C=x.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let S=i(),h=s(),y=Ge(x,S,h),k=!1,P=!1;if(y.forEach(v=>{var A,D;v.type==="TASK"&&(((A=v.data)==null?void 0:A.variant)==="SCRIPT"&&(k=!0),((D=v.data)==null?void 0:D.attribute)==="LOOP"&&(P=!0))}),k)return"script";if(P)return"loop"},g=p=>{var P,C;if(p.type!=="GATEWAY")return;let x=i(),S=s(),h=Ge(p,x,S),y=!1,k=!1;if(h.forEach(v=>{var A,D;v.type==="TASK"&&(((A=v.data)==null?void 0:A.variant)==="SCRIPT"&&(y=!0),((D=v.data)==null?void 0:D.attribute)==="LOOP"&&(k=!0))}),((P=p.data)==null?void 0:P.variant)==="COMPLEX"){if(y&&k)return"script_loop";if(y)return"script";if(k)return"loop"}else if(((C=p.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(y)return"script";if(k)return"loop"}},T=p=>jt(p,i(),s()).map(h=>{var y,k;return{id:h.id,type:h.type,variant:(y=h.data)==null?void 0:y.variant,label:(k=h.data)==null?void 0:k.label}}),N=p=>s().filter(h=>h.source===p.id).map(h=>{var y;return{id:h.id,type:"routing",variant:E(h),label:(y=h.data)==null?void 0:y.label,target:n(h.target)}}),m=()=>{var S,h,y,k,P,C,v,A,D;let p=n(e);if(!p)return;let x=c(p);if(p.type==="TASK"&&((S=p.data)==null?void 0:S.variant)==="SUBPROCESS"){r==null||r({id:p.id,type:"sub_process",variant:u(p),label:(h=p.data)==null?void 0:h.label,origin:x,targets:T(p),edgeTargets:N(p)}),console.log({id:p.id,type:"sub_process",variant:u(p),label:(y=p.data)==null?void 0:y.label,origin:x,targets:T(p),edgeTargets:N(p)});return}if(p.type!=="GATEWAY"){r==null||r({id:p.id,type:"activity",variant:u(p),label:(k=p.data)==null?void 0:k.label,origin:x,targets:T(p),edgeTargets:N(p)}),console.log({id:p.id,type:"activity",variant:u(p),label:(P=p.data)==null?void 0:P.label,origin:x,targets:T(p),edgeTargets:N(p)});return}console.log({id:p.id,type:"gateway",variant:((C=p.data)==null?void 0:C.variant)||"EXCLUSIVE",label:(v=p.data)==null?void 0:v.label,origin:x,subVariant:g(p),targets:T(p)}),r==null||r({id:p.id,type:"gateway",variant:((A=p.data)==null?void 0:A.variant)||"EXCLUSIVE",label:(D=p.data)==null?void 0:D.label,origin:x,subVariant:g(p),targets:T(p)})},d=()=>{let p=a(e);if(p){let x=E(p),S;x==="complex"?S=f(p):x==="exclusive"&&(S=b(p));let h=n(p.source),y=h&&l(h)||void 0;r==null||r({id:p.id,type:"routing",variant:x,subVariant:S,origin:y,target:n(p.target)}),console.log({id:p.id,type:"routing",variant:x,subVariant:S,origin:y,target:n(p.target)})}};return Ja($a,{children:[pt(Za,{asChild:!0,children:pt(Ka,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":m();break;case"edge":d();break}},children:pt(ja,{size:16})})}),pt(Xa,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as Qa}from"@xyflow/react";import{Button as ei,Tooltip as ti,TooltipContent as oi,TooltipTrigger as ni,useTranslation as ri}from"lecom-ui";import{TrashIcon as ai}from"lucide-react";import{jsx as ut,jsxs as ii}from"react/jsx-runtime";var mt=({elementId:e,elementType:t="node"})=>{let{t:o}=ri(),{deleteElements:n}=Qa();return ii(ti,{children:[ut(ni,{asChild:!0,children:ut(ei,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:ut(ai,{size:16})})}),ut(oi,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as gt}from"react/jsx-runtime";var we=n=>{var a=n,{edgeId:e,edgeType:t}=a,o=le(a,["edgeId","edgeType"]);var r;let i=[{component:gt(mt,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:gt(He,{elementId:e,elementType:"edge"})},...i],MESSAGE_EDGE:[...i],ANNOTATION_EDGE:[...i]};return gt("div",I(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(r=s[t])==null?void 0:r.map((l,c)=>gt("div",{children:l.component},c))}))};import{jsx as Et,jsxs as ui}from"react/jsx-runtime";var bt={type:"ANNOTATION_EDGE",zIndex:2e3},Uo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:i,targetY:s,selected:r,data:l})=>{let c=ci(),{zoom:u}=pi(),{isMultipleSelection:E}=O(),f=c.find(w=>w.id===t),b=c.find(w=>w.id===o),[g,T,N]=di({sourceX:n,sourceY:a,targetX:i,targetY:s}),m=r||(f==null?void 0:f.selected)||(b==null?void 0:b.selected),d=1/u;return ui("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[Et(si,{id:e,path:g,strokeDasharray:4,className:L("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)]":m&&!(l!=null&&l.hasError)})}),Et(li,{children:Et("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${T}px, ${N}px)`},children:r&&!E&&Et(we,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};import{BaseEdge as fi,EdgeLabelRenderer as Ei,getSmoothStepPath as bi,MarkerType as Ko,useNodes as hi,useReactFlow as vi,useViewport as yi}from"@xyflow/react";import{useState as Ti}from"react";import{useEffect as Wo,useRef as mi,useState as gi}from"react";import{jsx as Yo}from"react/jsx-runtime";var W=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:a,className:i,style:s})=>{let r=mi(null),[l,c]=gi(!1);Wo(()=>{c(n!=null?n:!1)},[n]),Wo(()=>{if(l&&r.current){r.current.focus();let g=document.createRange();g.selectNodeContents(r.current),g.collapse(!1);let T=window.getSelection();T&&(T.removeAllRanges(),T.addRange(g))}},[l]);let u=g=>{if(g.stopPropagation(),l&&r.current){let T=document.createRange();T.selectNodeContents(r.current);let N=window.getSelection();N&&(N.removeAllRanges(),N.addRange(T))}else c(!0)},E=g=>{let T=g.currentTarget.innerText.trim(),N=t&&T.length>=t,m=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=g.ctrlKey||g.metaKey,w=d&&g.key==="a",p=d&&g.key==="c",x=d&&g.key==="x",S=d&&g.key==="v";function h(k){return/\w/.test(k)}if(T.length===0&&!h(g.key)&&!m.includes(g.key)&&!d){g.preventDefault();return}N&&(m.includes(g.key)||w||p||x||S||g.preventDefault())},f=g=>{if(!t)return;g.preventDefault();let T=g.clipboardData.getData("text/plain"),N=g.currentTarget.innerText,m=window.getSelection();if(!m||m.rangeCount===0)return;let d=m.getRangeAt(0);if((N.substring(0,d.startOffset)+T+N.substring(d.endOffset)).length>t){let p=t-(N.length-(d.endOffset-d.startOffset)),x=T.substring(0,Math.max(0,p));x&&(d.deleteContents(),d.insertNode(document.createTextNode(x)),d.setStartAfter(d.endContainer),d.collapse(!0),m.removeAllRanges(),m.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(T)),d.setStartAfter(d.endContainer),d.collapse(!0),m.removeAllRanges(),m.addRange(d)},b=g=>{c(!1);let T=g.currentTarget.innerText.trim();t&&T.length>t&&(T=T.substring(0,t)),g.currentTarget.innerText=T,a==null||a(),T!==e&&(o==null||o(T))};return Yo("div",{className:L("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",i,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:u,children:Yo("div",{ref:r,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:E,onPaste:f,onBlur:b,children:e})})};import{jsx as ht,jsxs as $o}from"react/jsx-runtime";var oe={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Ko.ArrowClosed},markerEnd:{type:Ko.Arrow},data:{label:""}},Xo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:i,targetY:s,sourcePosition:r,targetPosition:l,data:c,selected:u})=>{let E=hi(),{zoom:f}=yi(),{updateEdgeData:b}=vi(),{isMultipleSelection:g}=O(),[T,N]=Ti(!1),m=E.find(A=>A.id===t),d=E.find(A=>A.id===o),[w,p,x]=bi({sourceX:n,sourceY:a,sourcePosition:r,targetX:i,targetY:s,targetPosition:l}),S=u||(m==null?void 0:m.selected)||(d==null?void 0:d.selected),h=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",y=T||(c==null?void 0:c.label.trim().length)>0,k=1/f,P=()=>{N(!0)},C=()=>{N(!1)},v=A=>{b(e,{label:A.trim()})};return $o("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":S}),onBlur:C,onDoubleClick:P,children:[ht(fi,{id:e,path:w,markerEnd:`url(#${h})`,className:L("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(c!=null&&c.hasError)})}),ht(Ei,{children:$o("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${x}px)`},children:[u&&!g&&ht(we,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${k})`}}),y&&ht(W,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:T,onChange:v})]})})]})};var qo=({setEdges:e})=>{let{getNode:t,getEdges:o}=Ni();return{isValidConnection:i=>{var l,c;let s=t(i.source),r=t(i.target);if((s==null?void 0:s.id)===(r==null?void 0:r.id)||(s==null?void 0:s.type)==="GATEWAY"&&((l=s==null?void 0:s.data)==null?void 0:l.variant)==="EXCLUSIVE"&&o().filter(f=>f.source===s.id).length>=2||(s==null?void 0:s.type)==="TASK"&&o().filter(f=>f.source===s.id).length>=2||(s==null?void 0:s.type)==="GATEWAY"&&(r==null?void 0:r.type)==="GATEWAY"||(s==null?void 0:s.type)==="START_EVENT"&&(r==null?void 0:r.type)==="END_EVENT"||(s==null?void 0:s.type)==="GATEWAY"&&(r==null?void 0:r.type)==="END_EVENT"||(s==null?void 0:s.type)==="START_EVENT"&&(r==null?void 0:r.type)==="GATEWAY"||(s==null?void 0:s.type)==="START_EVENT"&&(r==null?void 0:r.type)==="TASK"&&o().filter(b=>b.source===r.id).some(b=>{let g=t(b.target);return(g==null?void 0:g.type)==="END_EVENT"})||(s==null?void 0:s.type)==="TASK"&&((c=s==null?void 0:s.data)==null?void 0:c.variant)==="SCRIPT"&&(r==null?void 0:r.type)==="END_EVENT")return!1;if((s==null?void 0:s.type)==="TASK"&&(r==null?void 0:r.type)==="END_EVENT"){let u=o();if(u.filter(g=>g.target===s.id).some(g=>{let T=t(g.source);return(T==null?void 0:T.type)==="START_EVENT"})||u.filter(g=>g.source===s.id).length>0)return!1}if((s==null?void 0:s.type)==="TASK"&&o().filter(b=>b.source===s.id).some(b=>{let g=t(b.target);return(g==null?void 0:g.type)==="END_EVENT"}))return!1;switch(s==null?void 0:s.type){case"START_EVENT":return(r==null?void 0:r.type)==="TASK"||(r==null?void 0:r.type)==="END_EVENT"||(r==null?void 0:r.type)==="GATEWAY"||(r==null?void 0:r.type)==="ANNOTATION";case"END_EVENT":return(r==null?void 0:r.type)==="ANNOTATION";case"TASK":return(r==null?void 0:r.type)==="TASK"||(r==null?void 0:r.type)==="END_EVENT"||(r==null?void 0:r.type)==="GATEWAY"||(r==null?void 0:r.type)==="ANNOTATION";case"GATEWAY":return(r==null?void 0:r.type)==="TASK"||(r==null?void 0:r.type)==="END_EVENT"||(r==null?void 0:r.type)==="GATEWAY"||(r==null?void 0:r.type)==="ANNOTATION";case"LANE":return(r==null?void 0:r.type)==="ANNOTATION";default:return!1}},onConnect:i=>{e(s=>{let r=t(i.target);return(r==null?void 0:r.type)==="ANNOTATION"?Zo(_(_({},i),bt),s):Zo(_(_({},i),oe),s)})}}};import{useState as an}from"react";import{useTranslation as _i}from"lecom-ui";import{useReactFlow as xi}from"@xyflow/react";var Be=(e=[])=>e.filter(t=>t.type==="START_EVENT"),be=(e=[])=>e.filter(t=>t.type==="END_EVENT"),ue=(e=[])=>e.filter(t=>t.type==="TASK")||[],jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),vt=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Qo=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),j=(e,t=[])=>t.filter(o=>o.source===e),ze=(e,t=[])=>t.filter(o=>o.target===e),en=(e,t)=>{var n,a;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((a=o==null?void 0:o.properties)==null?void 0:a.attribute)==="LOOP"},tn=(e,t)=>{let o=j(e,t.edges||[]);for(let n of o){let a=(t.nodes||[]).find(i=>i.id===n.target);if(a&&a.type==="END_EVENT")return!0}return!1},on=e=>e?/\w/g.test(e.trim()):!1,M=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},ne=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},nn=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.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 Fe=[{id:"start_event_not_found",validate:e=>{let t=Be(e.nodes);return M({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=be(e.nodes);return M({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Be(e.nodes),o=t.length===1;if(t.length===0)return M({isValid:!0});if(!o)return M({isValid:!1,nodeIds:t.map(i=>i.id)});let n=j(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return M({isValid:!1,nodeIds:[...new Set(i)]})}return M({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=ue(e.nodes),o=ne(t,n=>j(n.id,e.edges).length<=2);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=ue(e.nodes),o=ne(t,n=>!!n.label&&n.label.trim()!=="");return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=ue(e.nodes),n=ne(o,a=>!a.label||a.label.length<=60);return M({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=ue(e.nodes),o=new Map;for(let a of t){if(!a.label)continue;let i=a.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(a))}let n=[];for(let[,a]of o.entries())a.length>1&&a.forEach(i=>n.push(i.id));return M({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=vt(e.nodes),o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&r.type==="GATEWAY"&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Be(e.nodes),...be(e.nodes)],o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&(r.type==="START_EVENT"||r.type==="END_EVENT")&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=be(e.nodes),o=[],n=[];for(let a of t){let i=ze(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.source);if(r&&r.type==="TASK"){let l=j(r.id,e.edges);l.length>1&&(o.push(r.id),l.forEach(c=>n.push(c.id)))}}}return M({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Qo(e.nodes),o=ne(t,a=>j(a.id,e.edges).length<=2),n=o.invalidIds.flatMap(a=>j(a,e.edges).map(i=>i.id));return M({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=ue(e.nodes),o=ne(t,n=>!n.label||on(n.label));return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,r;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((r=e==null?void 0:e.edges)!=null&&r.length))return M({isValid:!0});let t=be(e.nodes)[0];if(!t)return M({isValid:!0});let o=ze(t.id,e.edges);if(!o.length)return M({isValid:!0});let a=ue(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=ne(a,l=>!en(l.id,e));return M({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=ue(e.nodes),o=be(e.nodes)[0];if(!o)return M({isValid:!0});let n=t.filter(l=>{let c=ze(l.id,e.edges),u=j(l.id,e.edges),E=c.some(b=>{var g;return((g=e.nodes.find(T=>T.id===b.source))==null?void 0:g.type)==="START_EVENT"}),f=u.some(b=>{var g;return((g=e.nodes.find(T=>T.id===b.target))==null?void 0:g.type)==="END_EVENT"});return E&&f}),a=ze(o.id,e.edges),i=a.length>1,s=a.map(l=>l.source),r={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return M(r)}},{id:"gateway_flow_to_event",validate:e=>{let t=vt(e.nodes),o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&r.type==="END_EVENT"&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=vt(e.nodes),o=ne(t,n=>j(n.id,e.edges).length>=1);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Be(e.nodes),...be(e.nodes)],o=[],n=[];for(let a of t){let i=j(a.id,e.edges);for(let s of i){let r=e.nodes.find(l=>l.id===s.target);r&&r.type==="GATEWAY"&&(o.push(a.id,r.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=jo(e.nodes),o=ne(t,n=>!tn(n.id,e));return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Jo(e.nodes),o=ne(t,n=>{var a,i;return((a=n.properties)==null?void 0:a.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return M({isValid:o.isValid,nodeIds:o.invalidIds})}}];var rn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Fe){let a=n.validate(e);a.isValid||t.push({id:n.id,message:n.id,nodeIds:a.nodeIds||[],edgeIds:a.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var sn=()=>{let{t:e}=_i(),[t,o]=an(null),{setNodes:n,setEdges:a,getNodes:i,getEdges:s}=xi(),[r,l]=an(!1);return{validationResult:t,validateDiagram:f=>{let b=nn(f.nodes,f.edges),g=rn(b),T=g.errors.map(N=>I(_({},N),{message:e(`validation.errors.${N.id}`)}));return r||l(!0),{isValid:g.isValid,errors:T}},handleValidationComplete:f=>{if(o(f),!f)return;let b=[],g=[];f.errors.forEach(h=>{h.nodeIds&&h.nodeIds.length>0&&h.nodeIds.forEach(y=>b.push(y)),h.edgeIds&&h.edgeIds.length>0&&h.edgeIds.forEach(y=>g.push(y))});let T=[...new Set(b)];n(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:!1})}))),a(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:!1})})));let N=i(),m=s(),d=new Set(T),w=new Set;f.errors.forEach(h=>{var P,C;let y=Fe.find(v=>v.id===h.id);(y==null?void 0:y.highlightRelatedEdges)!==!1&&((P=h.edgeIds)==null||P.forEach(v=>w.add(v)),(C=h.nodeIds)==null||C.forEach(v=>{m.forEach(A=>{(A.source===v||A.target===v)&&w.add(A.id)})}))});let p=new Set,x=new Set,S=new Set;N.forEach(h=>{h.type==="START_EVENT"?p.add(h.id):h.type==="END_EVENT"&&x.add(h.id)}),m.forEach(h=>{p.has(h.source)&&S.add(h.target),x.has(h.target)&&S.add(h.source)}),S.forEach(h=>{var y,k;if(d.has(h)){let P=(y=f.errors.find(v=>{var A;return(A=v.nodeIds)==null?void 0:A.includes(h)}))==null?void 0:y.id;((k=Fe.find(v=>v.id===P))==null?void 0:k.highlightRelatedEdges)!==!1&&m.forEach(v=>{v.source===h&&x.has(v.target)&&(d.add(v.target),w.add(v.id)),v.target===h&&p.has(v.source)&&(d.add(v.source),w.add(v.id))})}}),d.size>0&&n(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:d.has(y.id)})}))),w.size>0&&a(h=>h.map(y=>I(_({},y),{data:I(_({},y.data),{hasError:w.has(y.id)})})))},clearValidation:()=>{o(null),l(!1),n(f=>f.map(b=>I(_({},b),{data:I(_({},b.data),{hasError:!1})}))),a(f=>f.map(b=>I(_({},b),{data:I(_({},b.data),{hasError:!1})})))},isAutoValidationEnabled:r}};import{useReactFlow as wi}from"@xyflow/react";import{useTranslation as Ci}from"lecom-ui";import{useEffect as Ai}from"react";import{v7 as ln}from"uuid";var yt=(e,t)=>{let n=e.filter(i=>i.type==="TASK").map(i=>{var r;let s=(r=i.data)==null?void 0:r.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(i=>i>0),a=n.length>0?Math.max(...n)+1:1;return`${t} ${a}`},Tt=(e,t)=>{let n=t.filter(r=>r.type==="TASK").map(r=>{var l;return(l=r.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let a=e.replace(/\s+\(\d+\)$/,""),i=n.filter(r=>r===a||r.startsWith(`${a} (`)).map(r=>{if(r===a)return 1;let l=r.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(r=>r>0),s=2;for(;i.includes(s);)s++;return`${a} (${s})`};var Ii=15,dn="bpmn:selection",Si=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||i},cn=e=>{if(!Si(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},pn=({offset:e=Ii}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=wi(),{t:i}=Ci();Ai(()=>{let s=l=>{var T,N;if(!cn(l))return;let c=t(),u=n(),E=c.filter(m=>m.selected);if(!E.length)return;l.preventDefault(),l.stopPropagation();let f=u.filter(m=>E.some(d=>d.id===m.source)&&E.some(d=>d.id===m.target)),g=JSON.stringify({nodes:E,edges:f});(T=l.clipboardData)==null||T.setData(dn,g),(N=l.clipboardData)==null||N.setData("text/plain",`BPMN Selection: ${E.length} nodes`)},r=l=>{var N,m;if(!cn(l))return;let c=(N=l.clipboardData)==null?void 0:N.getData(dn);if(!c)return;l.preventDefault(),l.stopPropagation();let u;try{u=JSON.parse(c)}catch(d){return}if(!((m=u.nodes)!=null&&m.length))return;let E=new Map,f=t(),b=[],g=u.nodes.map(d=>{var x;let w=ln();E.set(d.id,w);let p=I(_({},d),{id:w,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let S=(x=d.data)==null?void 0:x.label,h=Tt(S||i("bpmn.task.label.prefix"),[...f,...b]);p.data=I(_({},d.data),{label:h})}return b.push(p),p}),T=u.edges.map(d=>I(_({},d),{id:ln(),selected:!0,source:E.get(d.source)||d.source,target:E.get(d.target)||d.target}));o(d=>[...d.map(w=>I(_({},w),{selected:!1})),...g]),a(d=>[...d.map(w=>I(_({},w),{selected:!1})),...T])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",r,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",r,!0)}},[t,o,n,a,e,i])};import{useReactFlow as Bi,useStoreApi as zi}from"@xyflow/react";import{useTranslation as Fi}from"lecom-ui";import{v7 as En}from"uuid";import{create as ki}from"zustand";var Ce=ki(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Li,EdgeLabelRenderer as Pi,getSmoothStepPath as Di,MarkerType as Ri,useNodes as Vi,useReactFlow as Mi,useViewport as Oi}from"@xyflow/react";import{useState as Gi}from"react";import{jsx as Nt,jsxs as un}from"react/jsx-runtime";var mm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:Ri.Arrow},data:{label:""}},mn=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:i,targetY:s,sourcePosition:r,targetPosition:l,data:c,selected:u})=>{let E=Vi(),{zoom:f}=Oi(),{updateEdgeData:b}=Mi(),{isMultipleSelection:g}=O(),[T,N]=Gi(!1),m=E.find(A=>A.id===t),d=E.find(A=>A.id===o),[w,p,x]=Di({sourceX:n,sourceY:a,sourcePosition:r,targetX:i,targetY:s,targetPosition:l}),S=u||(m==null?void 0:m.selected)||(d==null?void 0:d.selected),h=S?"sequence-edge-marker-highlighted":"sequence-edge-marker",y=T||(c==null?void 0:c.label.trim().length)>0,k=1/f,P=()=>{N(!0)},C=()=>{N(!1)},v=A=>{b(e,{label:A.trim()})};return un("g",{className:L("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":S}),onBlur:C,onDoubleClick:P,children:[Nt(Li,{id:e,path:w,markerEnd:`url(#${h})`,strokeDasharray:4,className:L("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":S&&!(c!=null&&c.hasError)})}),Nt(Pi,{children:un("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${p}px, ${x}px)`},children:[u&&!g&&Nt(we,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${k})`}}),y&&Nt(W,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:T,onChange:v})]})})]})};import{jsx as gn,jsxs as Hi}from"react/jsx-runtime";var fn=({fromX:e,fromY:t,toX:o,toY:n})=>Hi("g",{children:[gn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),gn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var bn=({nodes:e,setNodes:t,setEdges:o})=>{let n=zi(),{draggableNode:a,setDraggableNode:i}=Ce(),{getInternalNode:s,screenToFlowPosition:r}=Bi(),{t:l}=Fi(),c=m=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(w=>w.map(p=>I(_({},p),{className:p.id===m?d:""})))},u=()=>{let{nodeLookup:m}=n.getState();return Array.from(m.values())},E=m=>{let d=s(m.id),w=u();if(m.type==="LANE"){if(xe({parentId:m.id,nodes:e,includeTypes:["LANE"]})){c();return}let k=w.filter(v=>v.id!==m.id&&v.type==="LANE"&&!v.parentId),P=Oe(d,k);if(!P){c();return}if(xe({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let x=w.filter(y=>y.id!==m.id&&y.type==="LANE"),S=Oe(d,x);if(!S){c();return}if(xe({parentId:S.id,nodes:e,includeTypes:["LANE"]})){c();return}c(S.id)},f=m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},b=(m,d)=>{m.preventDefault(),E(d)},g=(m,d,w)=>{var k,P;let p=C=>C.map(v=>I(_({},v),{className:void 0}));if(m.parentId===d.id){let C=fe(d.id,w);t(ce(p(C)));return}if(m.type==="LANE"){if(xe({parentId:d.id,nodes:w,excludeTypes:["LANE"]}))return;let A=w.filter(G=>G.parentId===d.id).reduce((G,ie)=>{var ee,se;return G+((se=(ee=ie.measured)==null?void 0:ee.height)!=null?se:0)},0),D={x:$.HEADER_WIDTH,y:A},R=w.map(G=>G.id===m.id?I(_({},G),{parentId:d.id,position:D,className:void 0}):I(_({},G),{className:void 0}));R=fe(d.id,R),t(ce(R));return}if(xe({parentId:d.id,nodes:w,includeTypes:["LANE"]})){let C;if(m.parentId){let A=s(m.parentId),{x:D,y:R}=de(A);C={x:D+((k=m.position.x)!=null?k:0),y:R+((P=m.position.y)!=null?P:0)}}let v=w.map(A=>A.id===m.id?I(_({},A),{position:C!=null?C:A.position,parentId:void 0,className:void 0}):I(_({},A),{className:void 0}));t(ce(v));return}let h=Do(m,d),y=w.map(C=>C.id===m.id?I(_({},C),{parentId:d.id,position:h,className:void 0}):I(_({},C),{className:void 0}));t(ce(y))};return{onDragOver:f,onDrop:m=>{if(m.preventDefault(),!(a!=null&&a.type))return;let d=r({x:m.clientX,y:m.clientY}),w={width:H[a.type].MIN_WIDTH,height:H[a.type].MIN_HEIGHT},p={id:En(),type:a.type,position:d,measured:w,data:{label:a.type==="TASK"?yt(e,l("bpmn.task.label.prefix")):"",variant:a.variant,attribute:a.attribute}},x=I(_({},p),{internals:{positionAbsolute:d}}),S=u(),h=a.type==="LANE",y=S.filter(C=>h?C.type==="LANE"&&!C.parentId:C.type==="LANE"),k=Oe(x,y);k?g(x,k,[...S,x]):t(C=>{let v=C.concat(p);return ce(v)});let P=m.dataTransfer.getData("sourceId");if(P){let C={id:En(),source:P,target:p.id};if(a.type==="ANNOTATION"){o(v=>v.concat(_(_({},C),bt)));return}o(v=>v.concat(_(_({},C),oe)))}i(null)},onNodeDrag:b,onNodeDragStop:async(m,d)=>{var k,P;let{nodeLookup:w}=n.getState(),p=s(d.id),x=Array.from(w.values()),S=d.type==="LANE",h=x.filter(C=>C.id!==d.id&&(S?C.type==="LANE"&&!C.parentId:C.type==="LANE")),y=Oe(p,h);if(y){g(p,y,x);return}if(d.parentId){let C=s(d.parentId),{x:v,y:A}=de(C),D={x:v+((k=d.position.x)!=null?k:0),y:A+((P=d.position.y)!=null?P:0)},R=e.map(G=>G.id===d.id?I(_({},G),{position:D,parentId:void 0}):G);R=fe(d.parentId,R),t(ce(R))}}}};import{applyNodeChanges as Ui}from"@xyflow/react";import{useCallback as Wi,useState as vn}from"react";function hn(e,t,o=5){var l,c,u,E,f,b,g,T;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},a=t.find(N=>N.id===e.id);if(!a||!e.position)return n;let i={left:e.position.x,right:e.position.x+((c=(l=a.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((E=(u=a.measured)==null?void 0:u.height)!=null?E:0),width:(b=(f=a.measured)==null?void 0:f.width)!=null?b:0,height:(T=(g=a.measured)==null?void 0:g.height)!=null?T:0},s=o,r=o;return t.filter(N=>N.id!==a.id).reduce((N,m)=>{var C,v,A,D,R,G,ie,ee;let d={left:m.position.x,right:m.position.x+((v=(C=m.measured)==null?void 0:C.width)!=null?v:0),top:m.position.y,bottom:m.position.y+((D=(A=m.measured)==null?void 0:A.height)!=null?D:0),width:(G=(R=m.measured)==null?void 0:R.width)!=null?G:0,height:(ee=(ie=m.measured)==null?void 0:ie.height)!=null?ee:0},w=Math.abs(i.left-d.left);w<r&&(N.snapPosition.x=d.left,N.vertical=d.left,r=w);let p=Math.abs(i.right-d.right);p<r&&(N.snapPosition.x=d.right-i.width,N.vertical=d.right,r=p);let x=Math.abs(i.left-d.right);x<r&&(N.snapPosition.x=d.right,N.vertical=d.right,r=x);let S=Math.abs(i.right-d.left);S<r&&(N.snapPosition.x=d.left-i.width,N.vertical=d.left,r=S);let h=Math.abs(i.top-d.top);h<s&&(N.snapPosition.y=d.top,N.horizontal=d.top,s=h);let y=Math.abs(i.bottom-d.top);y<s&&(N.snapPosition.y=d.top-i.height,N.horizontal=d.top,s=y);let k=Math.abs(i.bottom-d.bottom);k<s&&(N.snapPosition.y=d.bottom-i.height,N.horizontal=d.bottom,s=k);let P=Math.abs(i.top-d.bottom);return P<s&&(N.snapPosition.y=d.bottom,N.horizontal=d.bottom,s=P),N},n)}var yn=()=>{let[e,t]=vn(void 0),[o,n]=vn(void 0),a=Wi((i,s)=>{var r,l;if(t(void 0),n(void 0),i.length===1&&i[0].type==="position"&&i[0].dragging&&i[0].position){let c=hn(i[0],s);i[0].position.x=(r=c.snapPosition.x)!=null?r:i[0].position.x,i[0].position.y=(l=c.snapPosition.y)!=null?l:i[0].position.y,t(c.horizontal),n(c.vertical)}return Ui(i,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:a}};import{useReactFlow as Ki}from"@xyflow/react";import{v7 as wn}from"uuid";var Nn={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},_n={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Tn=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],a=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],s="",r="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",r=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),a.length&&(s="gateway-exclusive",r=a[1].replace(/\{|\}/g,""),e=e.replace(a[1],"")),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:r}),{step:e,type:s,label:r,edgeLabel:l}},Yi=e=>{e=e||"";let t=e.trim().split(`
2
+ `),o={},n=[];return t.forEach(a=>{a=a||"";let i=a.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let s=Tn(i[0],o),r=Tn(i[1],o);s&&r&&n.push({sourceId:s.step,targetId:r.step,label:s.edgeLabel||r.edgeLabel||""})}),{components:o,connections:n}},xn=e=>{let{components:t,connections:o}=Yi(e);return{nodes:t,edges:o}};var Cn=()=>{let{setNodes:e,setEdges:t,fitView:o}=Ki();return{createDiagram:a=>{let{nodes:i,edges:s}=xn(a),r=[],l=new Map;for(let[f,b]of Object.entries(i)){let g=wn(),T=Nn[b.type],N=_n[b.type];l.set(f,g);let m=H[T].MIN_WIDTH,d=H[T].MIN_HEIGHT;r.push({id:g,type:T,data:{label:b.label||"",variant:N,attribute:""},position:{x:0,y:0},width:m,height:d,measured:{width:m,height:d}})}let c=[];for(let f of s){let b=I(_({},oe),{id:wn(),source:l.get(f.sourceId)||f.sourceId,target:l.get(f.targetId)||f.targetId});c.push(b)}let{nodes:u,edges:E}=Mo(r,c);e(u),t(E),o()}}};import{useEffect as $i,useCallback as Xi}from"react";var Zi={origin:"*",debug:!1};function An(e,t=Zi){let{origin:o,debug:n}=t,a=Xi((i,s)=>{n&&console.debug("[postMessage] sending:",{type:i,payload:s}),window.parent.postMessage({type:i,payload:s},o||"*")},[o,n]);return $i(()=>{let i=s=>{let{type:r,data:l}=s.data||{};n&&console.debug("[postMessage] received:",s.data),r&&e[r]&&e[r](l)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:a}}import{useReactFlow as qi}from"@xyflow/react";var In=(e,t)=>{let{getNodes:o,getEdges:n}=qi();return{selectElement:s=>{let r=o().map(c=>I(_({},c),{selected:c.id===s})),l=n().map(c=>I(_({},c),{selected:c.id===s}));return e(r),t(l),!0},isReady:()=>!0}};import{useReactFlow as ji}from"@xyflow/react";import{useCallback as Ue,useState as Sn}from"react";import{useDebouncedCallback as Ji}from"use-debounce";var Qi={nodes:[],edges:[]},es=500,kn=10,Ln=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=ji(),[a,i]=Sn([Qi]),[s,r]=Sn(0),l=a[s],c=s>0,u=s<a.length-1,E=Ue(d=>{o(a[d].nodes),n(a[d].edges)},[a,o,n]),f=Ue(()=>{if(s>0){let d=s-1;r(d),E(d)}},[s,E]),b=Ue(()=>{if(s<a.length-1){let d=s+1;r(d),E(d)}},[a,s,E]),g=d=>{let p=[...a.slice(0,s+1),d],x=p.length>kn?p.slice(p.length-kn):p;i(x),r(x.length-1)},T=Ji(()=>{let d=e(),w=t(),p={nodes:d,edges:w};JSON.stringify(l)!==JSON.stringify(p)&&g(p)},es),N=Ue(d=>{if(d==="forceSave"){T();return}d.some(p=>p.type!=="select")&&T()},[T]),m=Ue(()=>{i([]),r(0)},[]);return{undo:f,redo:b,saveHistory:N,canUndo:c,canRedo:u,clearHistory:m}};import{jsx as Pn}from"react/jsx-runtime";var Jt=({id:e,className:t})=>Pn("marker",{id:e,className:L("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:Pn("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Qt,jsxs as ts}from"react/jsx-runtime";var Dn=()=>Qt("svg",{style:{position:"absolute",top:0,left:0},children:ts("defs",{children:[Qt(Jt,{id:"sequence-edge-marker",className:"text-grey-400"}),Qt(Jt,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as jn}from"@xyflow/react";import{Button as It,Tooltip as St,TooltipContent as kt,TooltipTrigger as Lt,useTranslation as qs}from"lecom-ui";import{HandIcon as js,ListCheckIcon as Js,MapIcon as Qs,MousePointerIcon as el}from"lucide-react";import{useCallback as tl,useEffect as Jn}from"react";import{useStore as os}from"@xyflow/react";var ns=e=>({unselectAll:e.unselectNodesAndEdges}),We=()=>{let{unselectAll:e}=os(ns);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as Is,TooltipContent as Ss,TooltipTrigger as ks,useNotificationToast as Ls,useTranslation as Ps}from"lecom-ui";var Ye=(m=>(m.START_EVENT="START_EVENT",m.END_EVENT="END_EVENT",m.TASK="TASK",m.SUBPROCESS="SUBPROCESS",m.GATEWAY="GATEWAY",m.ANNOTATION="ANNOTATION",m.CONNECTION="CONNECTION",m.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",m.ACTIVITY="ACTIVITY",m.PROCESS_INTERFACE="PROCESS_INTERFACE",m.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",m.VARIANT_ACTIVITY="VARIANT_ACTIVITY",m.AUTO_ACTIVITY="AUTO_ACTIVITY",m.DATA_STORE="DATA_STORE",m.DATA_OBJECT="DATA_OBJECT",m.DATA_OUTPUT="DATA_OUTPUT",m.DATA_INPUT="DATA_INPUT",m))(Ye||{});import{useReactFlow as vs}from"@xyflow/react";import{useNotificationToast as ys,useTranslation as Ts,Button as Ns}from"lecom-ui";var Rn=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=a=>{var i;t((i=a.target)==null?void 0:i.result)},n.onerror=a=>{var i;o((i=a.target)==null?void 0:i.error)},n.readAsText(e)});function Vn({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let a="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
3
+ `),i=encodeURI(a);_t(i,`${o}.csv`)}var _t=(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 gs}from"uuid";import{xml2json as rs,json2xml as wg}from"xml-js";var as={compact:!0,spaces:4},is=e=>e.replaceAll(`
4
+ `,"&#xA;");function Mn(e,t=as){if(e)return JSON.parse(rs(e,I(_({},t),{attributeValueFn:is})))}function On(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as ls}from"uuid";var Lg={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Gn={script:"SCRIPT",subprocess:"SUBPROCESS"},Hn={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Ae=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:a}=e,{value:i}=n,s=Number(a._attributes.width),r=Number(a._attributes.height);return{id:n.id,type:t,data:{label:i||"",variant:o,attribute:""},position:{x:Number(a._attributes.x),y:Number(a._attributes.y)},width:s,height:r,measured:{width:s,height:r}}},ds=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=H.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=H.START_EVENT.MIN_HEIGHT,{node:Ae({cell:e,type:"START_EVENT"}),status:n,originalType:o}},cs=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=H.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=H.END_EVENT.MIN_HEIGHT,{node:Ae({cell:e,type:"END_EVENT"}),status:n,originalType:o}},ps=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Gn[t],a="imported";return["script","none"].includes(t)||(a="adapted"),e.mxGeometry._attributes.width=Re(e.mxGeometry._attributes.width,H.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Re(e.mxGeometry._attributes.height,H.TASK.MIN_HEIGHT),{node:Ae({cell:e,type:"TASK",variant:n}),status:a,originalType:o}},us=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Hn[o],a=["none","inclusive","event-based"],i="imported";return a.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=H.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=H.GATEWAY.MIN_HEIGHT,{node:Ae({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},ms=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Re(e.mxGeometry._attributes.width,H.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Re(e.mxGeometry._attributes.height,H.ANNOTATION.MIN_HEIGHT),{node:Ae({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Bn=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=H.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=H.UNSUPPORTED.MIN_HEIGHT,{node:Ae({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},zn=(e,t)=>{let{source:o,target:n}=e._attributes;return I(_({},oe),{id:ls(),source:t.get(o)||o,target:t.get(n)||n})},Fn={TASK:ps,GATEWAY:us,START_EVENT:ds,END_EVENT:cs,ANNOTATION:ms};var fs=e=>{var s;let t=new Map,o=Object.values(Ye),n=e.filter(r=>{var l;return o.includes((l=r._attributes)==null?void 0:l.type)}),a=[],i=[];for(let r of n){let l=gs(),{type:c}=r._attributes,u=Fn[c]||Bn;t.set((s=r._attributes)==null?void 0:s.id,l),r._attributes.id=l;let{node:E,status:f,originalType:b}=u(r);a.push(E),i.push({originalType:b,type:E.type,variant:E.data.variant,value:On(E.data.label),status:f})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},Es=(e,t)=>e.filter(a=>{var i;return(i=a._attributes)==null?void 0:i.edge}).map(a=>zn(a,t)),bs=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:a}=fs(t.root.mxCell),i=Es(t.root.mxCell,n);return{nodes:o,edges:i,summary:a}},hs=async e=>{let t=await Rn(e),o=Mn(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:a}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=a==null?void 0:a.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(a.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:a}},Un=async e=>{try{let t=await hs(e),{nodes:o,edges:n,summary:a}=bs(t)||{};return{nodes:o,edges:n,summary:a}}catch(t){throw t}};import{jsx as _s}from"react/jsx-runtime";var Wn=()=>{let{t:e}=Ts(),{toast:t}=ys(),{setNodes:o,setEdges:n,fitView:a}=vs(),i=r=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=r.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:_s(Ns,{size:"small",variant:"ghost",onClick:()=>Vn({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{createDiagram:async r=>{try{let{nodes:l,edges:c,summary:u}=await Un(r);if(o(f=>f.concat(l)),n(f=>f.concat(c)),a(),u.some(f=>f.status==="unsupported")){i(u);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as xs}from"lecom-ui";import{useRef as ws}from"react";import{Fragment as Cs,jsx as Yn,jsxs as As}from"react/jsx-runtime";var Kn=r=>{var l=r,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:a,onFilesSelected:i}=l,s=le(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=ws(null),u=f=>{let b=f.target.files;b!=null&&b.length&&i(b),c.current&&(c.current.value="")};return As(Cs,{children:[Yn(xs,I(_({onClick:f=>{var b;(b=c.current)==null||b.click(),a==null||a(f)}},s),{children:e})),Yn("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:u})]})};import{jsx as xt,jsxs as Ds}from"react/jsx-runtime";var $n=({disabled:e=!1})=>{let{t}=Ps(),{toast:o}=Ls(),{createDiagram:n}=Wn(),a=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let r=s[0];if(!r){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(r)};return Ds(Is,{children:[xt(ks,{asChild:!0,children:xt(Kn,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:a,onFilesSelected:i,children:xt(xo,{})})}),xt(Ss,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{Button as Bs,DropdownMenu as zs,DropdownMenuContent as Fs,DropdownMenuItem as to,DropdownMenuTrigger as Us,Tooltip as wt,TooltipContent as Ct,TooltipTrigger as At,useTranslation as Ws}from"lecom-ui";import{FileCodeIcon as Ys,FileImageIcon as Ks,FolderOutputIcon as $s,PrinterIcon as Xs}from"lucide-react";import{useState as Zs}from"react";import{useReactFlow as Rs}from"@xyflow/react";import{toPng as Xn,toSvg as Vs}from"html-to-image";import{toast as Ms,useTranslation as Os}from"lecom-ui";import{useState as Gs}from"react";var Hs=3,eo="diagram",Zn=()=>{let{t:e}=Os(),{getNodes:t}=Rs(),{deselectAll:o}=We(),[n,a]=Gs({png:!1,html:!1,print:!1}),i=()=>{let{x:u,y:E,width:f,height:b}=Go(t());return{width:f,height:b,style:{width:`${f}px`,height:`${b}px`,transform:`translate(${-u}px, ${-E}px)`}}},s=async(u,E)=>{a(I(_({},n),{[E]:!0})),await o();try{let f=Oo();if(!f)throw new Error("Flow element not found");let b=i();return await u(f,b)}catch(f){Ms({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(I(_({},n),{[E]:!1}))}};return{exportAsPng:async(u=eo)=>{await s(async(E,f)=>{let b=await Xn(E,I(_({},f),{backgroundColor:"#fcfcfc"}));_t(b,`${u}.png`)},"png")},exportAsHtml:async(u=eo)=>{await s(async(E,f)=>{let b=await Vs(E,I(_({},f),{backgroundColor:"#fcfcfc"})),g=`
5
5
  <!DOCTYPE html>
6
6
  <html>
7
7
  <head>
8
- <title>${f}</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="${u}" alt="Diagram" />
15
+ <img src="${b}" alt="Diagram" />
16
16
  </body>
17
17
  </html>
18
- `,x=new Blob([v],{type:"text/html"}),b=URL.createObjectURL(x);Et(b,`${f}.html`),setTimeout(()=>URL.revokeObjectURL(b),100)},"html")},printDiagram:async(f=Yt)=>{await a(async(E,m)=>{let u=await Lr(E,w(y({},m),{pixelRatio:Ns})),v=window.open("","_blank");if(!v)throw new Error("Failed to open print window.");let x=v.document;x.open(),x.write(`
18
+ `,T=new Blob([g],{type:"text/html"}),N=URL.createObjectURL(T);_t(N,`${u}.html`),setTimeout(()=>URL.revokeObjectURL(N),100)},"html")},printDiagram:async(u=eo)=>{await s(async(E,f)=>{let b=await Xn(E,I(_({},f),{pixelRatio:Hs})),g=window.open("","_blank");if(!g)throw new Error("Failed to open print window.");let T=g.document;T.open(),T.write(`
19
19
  <!DOCTYPE html>
20
20
  <html>
21
21
  <head>
22
- <title>${f}</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 $n=Object.defineProperty,Xn=Object.defineProperties;var qn=Object.getOwnProp
28
28
  </style>
29
29
  </head>
30
30
  <body>
31
- <img src="${u}" alt="Diagram" onload="window.print(); window.close();" />
31
+ <img src="${b}" alt="Diagram" onload="window.print(); window.close();" />
32
32
  </body>
33
33
  </html>
34
- `),x.close()},"print")},isPrintingPng:r.png,isPrintingHtml:r.html,isPrinting:r.print}};import{jsx as H,jsxs as xe}from"react/jsx-runtime";function Dr(){let{t:e}=ws(),{exportAsPng:t,exportAsHtml:o,printDiagram:r,isPrinting:n,isPrintingPng:i,isPrintingHtml:a}=Pr(),[s,l]=ks(!1);return xe(Ts,{modal:!1,open:s,onOpenChange:l,children:[H(_s,{asChild:!0,children:H("div",{children:xe(ht,{children:[H(Nt,{asChild:!0,children:H(ys,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:H(As,{})})}),!s&&H(vt,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),xe(xs,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[xe(ht,{children:[H(Nt,{asChild:!0,children:H(Kt,{className:"p-1.5",disabled:i,onClick:()=>t(),children:H(Is,{})})}),H(vt,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),xe(ht,{children:[H(Nt,{asChild:!0,children:H(Kt,{className:"p-1.5",disabled:a,onClick:()=>o(),children:H(Cs,{})})}),H(vt,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),xe(ht,{children:[H(Nt,{asChild:!0,children:H(Kt,{className:"p-1.5",disabled:n,onClick:()=>r(),children:H(Ss,{})})}),H(vt,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as Os,jsx as B,jsxs as de}from"react/jsx-runtime";var Vr=({nodes:e,isReadOnly:t,diagram:o,onValidationComplete:r,onValidateDiagram:n})=>{let{t:i}=Ls(),{deselectAll:a}=He(),{isMoveTool:s,isHandTool:l,activeMoveTool:d,activeHandTool:f,isMinimapOpen:E,setIsMinimapOpen:m}=V(),u=Rr(["v","V"]),v=Rr(["h","H"]),x=Vs(()=>{a(),f()},[a,f]),b=()=>{a();let g=n(o);r&&r(g)};return Mr(()=>{u&&!s&&!t&&d()},[u,d,s,t]),Mr(()=>{v&&!l&&!t&&x()},[v,x,l,t]),de("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&de(Os,{children:[de(Tt,{children:[B(_t,{asChild:!0,children:B(yt,{size:"small",variant:"ghost",color:"grey",className:L(s&&"bg-grey-400"),iconButton:!0,onClick:d,children:B(Ms,{})})}),de(xt,{color:"black",children:[i("editor.controls.actions.move_tool"),B("span",{className:"ml-1 text-grey-400",children:"V"})]})]}),de(Tt,{children:[B(_t,{asChild:!0,children:B(yt,{size:"small",variant:"ghost",color:"grey",className:L(l&&"bg-grey-400"),iconButton:!0,onClick:x,children:B(Ps,{})})}),de(xt,{color:"black",children:[i("editor.controls.actions.hand_tool")," ",B("span",{className:"ml-2 text-grey-400",children:"H"})]})]}),de(Tt,{children:[B(_t,{asChild:!0,children:B(yt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:b,children:B(Ds,{})})}),B(xt,{color:"black",children:i("editor.controls.actions.check")})]})]}),B(Dr,{}),!t&&B(kr,{disabled:e.length>0}),de(Tt,{children:[B(_t,{asChild:!0,children:B(yt,{size:"small",variant:"ghost",color:"grey",className:L(E&&"bg-grey-400"),iconButton:!0,onClick:()=>m(!E),children:B(Rs,{})})}),B(xt,{color:"black",children:i(E?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as Or,Tooltip as Gr,TooltipContent as Hr,TooltipTrigger as Br,useTranslation as Gs}from"lecom-ui";import{RedoIcon as Hs,UndoIcon as Bs}from"lucide-react";import{jsx as ce,jsxs as Zt}from"react/jsx-runtime";var zr=({undo:e,redo:t,canUndo:o,canRedo:r})=>{let{t:n}=Gs();return Zt("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Zt(Gr,{children:[ce(Br,{asChild:!0,children:ce(Or,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:ce(Bs,{})})}),ce(Hr,{color:"black",children:n("editor.controls.history.undo")})]}),Zt(Gr,{children:[ce(Br,{asChild:!0,children:ce(Or,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!r,onClick:t,children:ce(Hs,{})})}),ce(Hr,{color:"black",children:n("editor.controls.history.redo")})]})]})};import{useReactFlow as zs}from"@xyflow/react";import{Button as wt,Tooltip as Ct,TooltipContent as It,TooltipTrigger as At,useTranslation as Us}from"lecom-ui";import{ScanIcon as Fs,ZoomIn as Ws,ZoomOut as Ys}from"lucide-react";import{jsx as Y,jsxs as ze}from"react/jsx-runtime";var Ur=()=>{let{t:e}=Us(),{zoomIn:t,zoomOut:o,zoomTo:r,fitView:n}=zs();return ze("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[ze(Ct,{children:[Y(At,{asChild:!0,children:Y(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(),children:Y(Fs,{})})}),Y(It,{color:"black",children:e("editor.controls.zoom.fit")})]}),ze(Ct,{children:[Y(At,{asChild:!0,children:Y(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:Y(Ys,{})})}),Y(It,{color:"black",children:e("editor.controls.zoom.out")})]}),ze(Ct,{children:[Y(At,{asChild:!0,children:Y(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>r(1),children:Y(uo,{})})}),Y(It,{color:"black",children:e("editor.controls.zoom.reset")})]}),ze(Ct,{children:[Y(At,{asChild:!0,children:Y(wt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:Y(Ws,{})})}),Y(It,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Position as Dl,useReactFlow as Rl}from"@xyflow/react";import{Handle as Ks}from"@xyflow/react";import{jsx as Zs}from"react/jsx-runtime";var z=({type:e,position:t,className:o})=>Zs(Ks,{type:e,position:t,className:L("size-2.5 border border-grey-400 bg-white",o)});import{NodeResizer as $s,useReactFlow as Xs}from"@xyflow/react";import{orderBy as qs}from"lodash";import{jsx as js}from"react/jsx-runtime";var _e=o=>{var r=o,{nodeId:e}=r,t=Ee(r,["nodeId"]);let{getNode:n,getNodes:i,setNodes:a}=Xs(),s=({width:l,height:d})=>{if(!e)return;let f=n(e);if((f==null?void 0:f.type)!=="LANE")return;let E=[...i()],m=!f.parentId,u=m?f.id:f.parentId,v=E.filter(g=>g.type==="LANE"&&g.parentId===u);if(!v.length)return;let x=qs(v,["position.y"]),b=0;x.forEach((g,h)=>{var T,I;let k=h===x.length-1,c=(I=(T=g.measured)==null?void 0:T.height)!=null?I:0;E=E.map(p=>{if(p.id===g.id){let N=m?l-K.HEADER_WIDTH:l,A=w(y({},p),{width:N,measured:w(y({},p.measured),{width:N}),position:w(y({},p.position),{y:b})});return k&&m&&(A.height=d-b),A}return p}),b+=c}),E=E.map(g=>{if(g.id===u){let h=m?l:l+K.HEADER_WIDTH;return w(y({},g),{width:h,height:m?d:b,measured:{width:h,height:m?d:b}})}return g}),a(E)};return js($s,y({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 wl,NodeToolbar as Cl}from"@xyflow/react";import{Button as Il,Tooltip as Al,TooltipContent as Sl,TooltipTrigger as kl,useTranslation as Ll}from"lecom-ui";import{useNodesData as Js,useReactFlow as Qs}from"@xyflow/react";import{Button as el,DropdownMenu as tl,DropdownMenuContent as ol,DropdownMenuGroup as rl,DropdownMenuItem as nl,DropdownMenuLabel as al,DropdownMenuTrigger as il,Tooltip as sl,TooltipContent as ll,TooltipTrigger as dl,useTranslation as cl}from"lecom-ui";import{WrenchIcon as pl}from"lucide-react";import{jsx as ne,jsxs as St}from"react/jsx-runtime";var Fr=({nodeId:e})=>{let{t}=cl(),{updateNodeData:o}=Qs(),r=Js(e),n=i=>{(r==null?void 0:r.data.variant)!==i&&o(e,{variant:i})};return St(tl,{children:[St(sl,{children:[ne(dl,{asChild:!0,children:ne(il,{asChild:!0,children:ne(el,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:ne(pl,{})})})}),ne(ll,{color:"black",children:t("bpmn.gateway.menu.title")})]}),St(ol,{align:"start",className:"w-60 bg-white text-grey-600",children:[ne(al,{className:"flex items-center",children:ne("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.gateway.menu.title")})}),ne(rl,{children:Object.entries(tt).map(([i,a])=>St(nl,{className:L({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.variant)===i}),onClick:()=>n(i),children:[ne(a.icon,{className:"stroke-current"}),t(`bpmn.gateway.variant.${i.toLowerCase()}`)]},i))})]})]})};import{useNodesData as ml,useReactFlow as ul}from"@xyflow/react";import{Button as Wr,DropdownMenu as gl,DropdownMenuContent as fl,DropdownMenuGroup as El,DropdownMenuItem as bl,DropdownMenuLabel as hl,DropdownMenuTrigger as vl,Tooltip as Nl,TooltipContent as yl,TooltipTrigger as Tl,useTranslation as xl}from"lecom-ui";import{WrenchIcon as _l}from"lucide-react";import{jsx as q,jsxs as Ue}from"react/jsx-runtime";var Yr=({nodeId:e})=>{let{t}=xl(),{updateNodeData:o}=ul(),r=ml(e),n=a=>{o(e,{variant:(r==null?void 0:r.data.variant)===a?"":a})},i=a=>{o(e,{attribute:(r==null?void 0:r.data.attribute)===a?"":a})};return Ue(gl,{children:[Ue(Nl,{children:[q(Tl,{asChild:!0,children:q(vl,{asChild:!0,children:q(Wr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:q(_l,{})})})}),q(yl,{color:"black",children:t("bpmn.task.menu.title")})]}),Ue(fl,{align:"start",className:"w-60 bg-white text-grey-600",children:[Ue(hl,{className:"flex items-center gap-1",children:[q("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.task.menu.title")}),q("div",{className:"flex items-center gap-1",children:Object.entries(et).map(([a,s])=>q(Wr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,className:L({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.attribute)===a}),onClick:()=>i(a),children:q(s.icon,{className:"stroke-inherit"})},a))})]}),q(El,{children:Object.entries(Qe).map(([a,s])=>Ue(bl,{className:L({"bg-grey-100 text-blue-500":(r==null?void 0:r.data.variant)===a}),onClick:()=>n(a),children:[q(s.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${a.toLowerCase()}`)]},a))})]})]})};import{jsx as j,jsxs as Pl}from"react/jsx-runtime";var Z=({nodeId:e,nodeType:t,isChild:o,isVisible:r})=>{var f;let{t:n}=Ll(),{setDraggableNode:i}=ye(),a=({event:E,type:m,variant:u})=>{i({type:m,variant:u}),E.dataTransfer.effectAllowed="move",E.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:$e,label:n("bpmn.annotation.variant.default")}},l=[{component:j(lt,{elementId:e})}],d={START_EVENT:[s.TASK,s.ANNOTATION,...l],TASK:[{component:j(Re,{elementId:e})},{component:j(Yr,{nodeId:e})},s.TASK,s.GATEWAY,s.END_EVENT,s.ANNOTATION,...l],GATEWAY:[{component:j(Re,{elementId:e})},{component:j(Fr,{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(Cl,{className:"-top-6 flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",position:wl.Right,align:"start",isVisible:r,children:(f=d[t])==null?void 0:f.map((E,m)=>E.component?j("div",{children:E.component},m):Pl(Al,{children:[j(kl,{asChild:!0,children:j(Il,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!0,onDragStart:u=>a({event:u,type:E.type,variant:E.variant}),children:E.icon&&j(E.icon,{size:16})})}),j(Sl,{color:"black",children:E.label})]},m))})};import{Fragment as Ml,jsx as Fe,jsxs as Vl}from"react/jsx-runtime";var Kr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Rl(),{isMultipleSelection:i}=V(),a=s=>{n(e,{label:s})};return Vl(Ml,{children:[Fe("div",{className:L("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:Fe(W,{value:t.label,className:"m-1 text-grey-600",onChange:a})}),Fe(Z,{nodeId:e,nodeType:"ANNOTATION",isVisible:!r&&!i&&o}),Fe(_e,{isVisible:!r&&!i&&o,minWidth:nt.MIN_WIDTH,minHeight:nt.MIN_HEIGHT}),Fe(z,{type:"target",position:Dl.Left})]})};import{Position as Zr,useReactFlow as Ol}from"@xyflow/react";import{useState as Gl}from"react";import{Fragment as Hl,jsx as we,jsxs as $r}from"react/jsx-runtime";var Xr=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Ol(),{isMultipleSelection:i}=V(),[a,s]=Gl(!1),l=E=>{n(e,{label:E})};return $r(Hl,{children:[$r("div",{className:"relative",onBlur:()=>{s(!1)},onDoubleClick:()=>{s(!0)},children:[we(be,{className:L("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})}),we("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:we(W,{value:t.label,isEditing:a,onChange:l})})]}),we(Z,{nodeId:e,nodeType:"END_EVENT",isVisible:!r&&!i&&o}),we(z,{type:"source",position:Zr.Right}),we(z,{type:"target",position:Zr.Left})]})};import{Position as qr,useReactFlow as Bl}from"@xyflow/react";import{useState as zl}from"react";import{Fragment as Ul,jsx as Ce,jsxs as jr}from"react/jsx-runtime";var Jr=({id:e,data:t,selected:o,dragging:r})=>{let n=tt[t.variant].icon,{updateNodeData:i}=Bl(),{isMultipleSelection:a}=V(),[s,l]=zl(!1),d=m=>{i(e,{label:m})};return jr(Ul,{children:[jr("div",{className:"relative",onBlur:()=>{l(!1)},onDoubleClick:()=>{l(!0)},children:[Ce(n,{className:L("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})}),Ce("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Ce(W,{value:t.label,isEditing:s,onChange:d})})]}),Ce(Z,{nodeId:e,nodeType:"GATEWAY",isVisible:!r&&!a&&o}),Ce(z,{type:"target",position:qr.Left}),Ce(z,{type:"source",position:qr.Right})]})};import{Position as Fl,useReactFlow as Wl}from"@xyflow/react";import{useState as Yl}from"react";import{Fragment as Kl,jsx as We,jsxs as Qr}from"react/jsx-runtime";var en=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Wl(),{isMultipleSelection:i}=V(),[a,s]=Yl(!1),l=E=>{n(e,{label:E})};return Qr(Kl,{children:[Qr("div",{className:"relative",onBlur:()=>{s(!1)},onDoubleClick:()=>{s(!0)},children:[We(je,{className:L("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})}),We("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:We(W,{value:t.label,isEditing:a,onChange:l})})]}),We(Z,{nodeId:e,nodeType:"START_EVENT",isVisible:!r&&!i&&o}),We(z,{type:"source",position:Fl.Right})]})};import{Position as tn,useReactFlow as Zl}from"@xyflow/react";import{Fragment as $l,jsx as ee,jsxs as on}from"react/jsx-runtime";var rn=({id:e,data:t,selected:o,dragging:r})=>{let{updateNodeData:n}=Zl(),{isMultipleSelection:i}=V(),a=m=>{n(e,{label:m})},s=t.variant?Qe[t.variant].icon:null,l=t.attribute?et[t.attribute].icon:null,d=t.variant==="SUBPROCESS",f=s&&!d,E=l||d;return on($l,{children:[on("div",{className:L("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(W,{value:t.label,className:L("m-1",{"py-6":f||E}),onChange:a}),s&&ee("div",{className:L("absolute flex items-center p-1",d?"bottom-0":"top-0 left-0"),children:ee(s,{size:16,className:L(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:L("flex items-center w-16 p-1",d?"justify-between":"justify-center"),children:ee(l,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500")})})})]}),ee(Z,{nodeId:e,nodeType:"TASK",isVisible:!r&&!i&&o}),ee(_e,{isVisible:!r&&!i&&o,minWidth:ot.MIN_WIDTH,minHeight:ot.MIN_HEIGHT}),ee(z,{type:"source",position:tn.Right}),ee(z,{type:"target",position:tn.Left})]})};import{Position as nn}from"@xyflow/react";import{Fragment as Xl,jsx as kt,jsxs as ql}from"react/jsx-runtime";var an=({id:e,data:t,selected:o,dragging:r})=>{let{isMultipleSelection:n}=V();return ql(Xl,{children:[kt("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}),kt(Z,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!r&&!n&&o}),kt(z,{type:"source",position:nn.Right}),kt(z,{type:"target",position:nn.Left})]})};import{Position as jl,useReactFlow as Jl}from"@xyflow/react";import{orderBy as Ql}from"lodash";import{useMemo as sn}from"react";import{Fragment as ed,jsx as fe,jsxs as ln}from"react/jsx-runtime";var dn=({id:e,data:t,selected:o,dragging:r,parentId:n})=>{let{updateNodeData:i,getNodes:a}=Jl(),{isMultipleSelection:s}=V(),l=a(),d=!n,f=sn(()=>Ql([...l.filter(v=>v.parentId===e&&v.type==="LANE")],"position.y","asc"),[l,e]),E=d?rt.MIN_WIDTH:K.MIN_WIDTH,m=sn(()=>{if(d&&f.length>1){let v=[...f];return v.pop(),v.reduce((b,g)=>{var h,k;return b+((k=(h=g.measured)==null?void 0:h.height)!=null?k:0)},0)+K.MIN_HEIGHT}return K.MIN_HEIGHT},[d,f]),u=v=>{i(e,{label:v})};return ln(ed,{children:[ln("div",{className:L("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(W,{value:t.label,className:"w-full h-full",onChange:u})})}),fe("div",{className:"flex-1"})]}),fe(Z,{nodeId:e,nodeType:"LANE",isChild:!d,isVisible:!r&&!s&&o}),fe(_e,{nodeId:e,minWidth:E,minHeight:m,isVisible:!r&&!s&&o}),d&&fe(z,{type:"source",position:jl.Right})]})};var cn={START_EVENT:en,END_EVENT:Xr,TASK:rn,GATEWAY:Jr,ANNOTATION:Kr,LANE:dn,UNSUPPORTED:an},pn={SEQUENCE_EDGE:Do,MESSAGE_EDGE:qo,ANNOTATION_EDGE:Ao},mn="#fafafa",un="#bebebe",gn=1,fn=10,En="bottom-left",bn=.5,hn=4,vn={x:0,y:0,zoom:.75};import{useStore as td}from"@xyflow/react";import{useEffect as od,useRef as rd}from"react";import{jsx as ad}from"react/jsx-runtime";var nd=e=>({width:e.width,height:e.height,transform:e.transform}),Nn=({horizontal:e,vertical:t,color:o="#3367d9",dashArray:r=[6,6]})=>{let{width:n,height:i,transform:a}=td(nd),s=rd(null);return od(()=>{let l=s.current,d=l==null?void 0:l.getContext("2d");if(!d||!l)return;let f=window.devicePixelRatio;l.width=n*f,l.height=i*f,d.scale(f,f),d.clearRect(0,0,n,i),d.strokeStyle=o,d.setLineDash(r),typeof t=="number"&&(d.moveTo(t*a[2]+a[0],0),d.lineTo(t*a[2]+a[0],i),d.stroke()),typeof e=="number"&&(d.moveTo(0,e*a[2]+a[1]),d.lineTo(n,e*a[2]+a[1]),d.stroke())},[n,i,a,e,t,o,r]),ad("canvas",{ref:s,className:"react-flow__canvas w-full h-full absolute z-10 pointer-events-none"})};import{Button as yn,Dialog as id,DialogContent as sd,DialogFooter as ld,DialogHeader as dd,DialogTitle as cd,Notification as pd,Typography as $t,useTranslation as md}from"lecom-ui";import{jsx as te,jsxs as Xt}from"react/jsx-runtime";var Tn=({pendingDelete:e,setPendingDelete:t,setNodes:o,setEdges:r})=>{let{t:n}=md(),i=!!e,a=()=>{let{nodes:l,edges:d}=e||{};l!=null&&l.length&&o(f=>f.filter(E=>!l.some(m=>m.id===E.id))),d!=null&&d.length&&r(f=>f.filter(E=>!d.some(m=>m.id===E.id))),t(null)},s=()=>{t(null)};return te(id,{open:i,onOpenChange:s,children:Xt(sd,{className:"w-[488px] max-w-fit gap-2",children:[te(dd,{children:te(cd,{children:te($t,{variant:"heading-small-600",textColor:"text-grey-950",children:n("editor.modals.delete_elements.title")})})}),Xt("div",{className:"flex flex-col gap-2",children:[te("div",{className:"py-2",children:te(pd,{type:"callout",variant:"warning",content:n("editor.modals.delete_elements.callout")})}),te($t,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:n("editor.modals.delete_elements.content")})]}),Xt(ld,{className:"flex items-center flex-row justify-end w-full gap-2",children:[te(yn,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:s,children:te($t,{variant:"body-medium-500",textColor:"text-grey-800",children:n("editor.modals.delete_elements.cancel")})}),te(yn,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:a,children:n("editor.modals.delete_elements.confirm")})]})]})})};import{Button as ud,Tooltip as gd,TooltipContent as fd,TooltipTrigger as Ed,useTranslation as bd}from"lecom-ui";import{jsx as Ye,jsxs as hd}from"react/jsx-runtime";var xn=()=>{let{t:e}=bd(),{setDraggableNode:t}=ye(),o=[{type:"START_EVENT",icon:je,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:ho,label:e("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:bo,label:e("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Eo,label:e("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:he,label:e("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:qe,label:e("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Xe,label:e("bpmn.gateway.variant.complex")},{type:"LANE",icon:mo,label:e("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:$e,label:e("bpmn.annotation.variant.default")}],r=(n,i)=>{t({type:i.type,variant:i.variant,attribute:i.attribute}),n.dataTransfer.effectAllowed="move"};return Ye("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,i)=>hd(gd,{children:[Ye(Ed,{asChild:!0,children:Ye(ud,{className:"[&>svg]:size-6",size:"small",variant:"ghost",color:"grey",draggable:!0,iconButton:!0,onDragStart:a=>r(a,n),children:Ye(n.icon,{})},i)}),Ye(fd,{color:"black",side:"right",children:n.label})]},i))})};import{Button as vd,useTranslation as Nd}from"lecom-ui";import{AlertCircleIcon as yd,CircleCheckIcon as Td,XIcon as xd}from"lucide-react";import{useEffect as _d,useState as wd}from"react";import{jsx as J,jsxs as qt}from"react/jsx-runtime";var _n=({validationResult:e,onClose:t})=>{let{t:o}=Nd(),[r,n]=wd(!1);if(_d(()=>{e&&n(!0)},[e]),!r||!e)return null;let{isValid:i,errors:a}=e;return qt("div",{className:L("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[qt("div",{className:"flex flex-row items-start gap-4",children:[J("div",{className:"flex-shrink-0",children:i?J(Td,{className:"text-green-500 size-5"}):J(yd,{className:"text-red-500 size-5"})}),qt("div",{className:"body-medium-500 text-grey-800",children:[J("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&J("div",{children:o("validation.errors.subtitle")})]}),J(vd,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{n(!1),t()},children:J(xd,{})})]}),J("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?J("p",{children:o("validation.success.message")}):J("div",{className:"list-disc list-inside",children:a.map(s=>J("li",{className:"mb-1",children:s.message},s.id))})})]})};import{jsx as $,jsxs as Jt}from"react/jsx-runtime";var zd=[],Cn=Vd(({mode:e="edit"},t)=>{let o=Gd(!1),[r,n,i]=Pd([]),[a,s,l]=Ld([]),[d,f]=Hd(null),{isMoveTool:E,isHandTool:m,isReadOnly:u,setIsReadOnly:v,setIsMultipleSelection:x,isMinimapOpen:b}=V(),{validationResult:g,handleValidationComplete:h,clearValidation:k,isAutoValidationEnabled:c,validateDiagram:T}=Yo(),{getNode:I,getNodes:p,getEdges:N}=Rd(),A=pr(n,s);Od(t,()=>A);let{onNodeDrag:_,onDrop:S,onDragOver:C,onNodeDragStop:P}=er({nodes:r,setNodes:n,setEdges:s}),{isValidConnection:D,onConnect:O}=Mo({setEdges:s});$o();let{createDiagram:ae}=dr(),{undo:pe,redo:me,saveHistory:Lt,canUndo:Rn,canRedo:Mn}=gr(),{helperLineHorizontal:Vn,helperLineVertical:On,customApplyNodeChanges:Kd}=rr();cr({LIA_CREATE_DIAGRAM:ae,CLEAR_DIAGRAM:()=>{n([]),s([])}}),wn(()=>{v(e==="readonly")},[e,v]);let Gn=()=>{k()},Hn=jt(({nodes:F,edges:U})=>{let Ie=F.length+U.length>1;x(Ie)},[x]);Dd({onChange:Hn});let Bn=F=>{let U=I(F.id);if(U!=null&&U.parentId&&(U==null?void 0:U.type)==="LANE"){let Ie=ue(U.parentId,r.filter(ro=>ro.id!==U.id&&ro.type==="LANE"));n(re(Ie))}},zn=F=>{F.forEach(U=>{switch(U.type){case"remove":Bn(U);break}})},Un=jt(()=>{if(!c){o.current=!1;return}let F=p(),U=N(),Ie=T({nodes:F,edges:U});h(Ie),o.current=!1},[c,p,N,T,h]),to=Bd(Un,300),oo=jt(()=>{c&&!o.current&&(o.current=!0,to())},[c,to]),Fn=F=>{i(F),Lt(F),oo(),zn(F)},Wn=F=>{l(F),Lt(F),oo()},Yn=()=>{Lt("forceSave")},Kn=async({nodes:F,edges:U})=>(f({nodes:F,edges:U}),!1),Zn={nodes:r,edges:a};return Jt("div",{className:"w-full h-full",children:[!u&&$(xn,{}),$(Er,{}),Jt(Ad,{edges:a,nodes:r,nodeTypes:cn,edgeTypes:pn,minZoom:bn,maxZoom:hn,panOnDrag:m||u?!0:zd,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!u&&E,nodesConnectable:!u&&E,nodesDraggable:!u&&E,isValidConnection:D,connectionLineComponent:Jo,onConnect:O,onDrop:S,onDropCapture:Yn,onDragOver:C,onNodesChange:Fn,onEdgesChange:Wn,onNodeDrag:_,onNodeDragStop:P,onBeforeDelete:Kn,selectionMode:kd.Partial,proOptions:{hideAttribution:!0},multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[10,10],defaultViewport:vn,connectOnClick:!1,children:[b&&$(Id,{pannable:!0,zoomable:!0,position:En,className:"shadow-md rounded-md"}),Jt("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!u&&$(zr,{canUndo:Rn,canRedo:Mn,undo:pe,redo:me}),$(Vr,{nodes:r,isReadOnly:u,diagram:Zn,onValidationComplete:h,onValidateDiagram:T}),$(Ur,{})]}),$(Nn,{horizontal:Vn,vertical:On}),$(Cd,{gap:fn,size:gn,color:un,bgColor:mn}),g&&$("div",{className:"absolute top-6 right-6 z-[1000]",children:$(_n,{validationResult:g,onClose:Gn})})]}),$(Tn,{pendingDelete:d,setPendingDelete:f,setNodes:n,setEdges:s})]})});Cn.displayName="Editor";var Ud=({mode:e,locale:t="pt_BR",onConfigureElement:o,selectorRef:r})=>(wn(()=>{t&&Md.changeLanguage(t)},[t]),$(Sd,{children:$(Co,{value:{onConfigureElement:o},children:$(Cn,{mode:e,ref:r})})})),Qt=Ud;var eo=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 Fd,Translations as Wd}from"lecom-ui";var In={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 An={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 Sn={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 kn={pt_BR:Sn,en_US:In,es_ES:An};var Ln,Pn,Yd=(Pn=(Ln=eo("LecomUserLanguage"))!=null?Ln:eo("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Pn:Wd.PT_BR;Fd({lng:Yd,resources:kn});import{jsx as Dn}from"react/jsx-runtime";var ub=e=>Dn(so,{children:Dn(Qt,y({},e))});export{Dt as ActivityVariant,Mt as ComplexVariant,Pt as ElementType,Vt as ExclusiveVariant,ie as GatewayVariant,ub as Modeler,Rt as RoutingVariant,He as useSelectionUtils};
34
+ `),T.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};import{jsx as z,jsxs as Ie}from"react/jsx-runtime";function qn(){let{t:e}=Ws(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:a,isPrintingPng:i,isPrintingHtml:s}=Zn(),[r,l]=Zs(!1);return Ie(zs,{modal:!1,open:r,onOpenChange:l,children:[z(Us,{asChild:!0,children:z("div",{children:Ie(wt,{children:[z(At,{asChild:!0,children:z(Bs,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:z($s,{})})}),!r&&z(Ct,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),Ie(Fs,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[Ie(wt,{children:[z(At,{asChild:!0,children:z(to,{className:"p-1.5",disabled:i,onClick:()=>t(),children:z(Ks,{})})}),z(Ct,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),Ie(wt,{children:[z(At,{asChild:!0,children:z(to,{className:"p-1.5",disabled:s,onClick:()=>o(),children:z(Ys,{})})}),z(Ct,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),Ie(wt,{children:[z(At,{asChild:!0,children:z(to,{className:"p-1.5",disabled:a,onClick:()=>n(),children:z(Xs,{})})}),z(Ct,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}import{Fragment as ol,jsx as F,jsxs as me}from"react/jsx-runtime";var Qn=({nodes:e,isReadOnly:t,diagram:o,onValidationComplete:n,onValidateDiagram:a})=>{let{t:i}=qs(),{deselectAll:s}=We(),{isMoveTool:r,isHandTool:l,activeMoveTool:c,activeHandTool:u,isMinimapOpen:E,setIsMinimapOpen:f}=O(),b=jn(["v","V"]),g=jn(["h","H"]),T=tl(()=>{s(),u()},[s,u]),N=()=>{s();let m=a(o);n&&n(m)};return Jn(()=>{b&&!r&&!t&&c()},[b,c,r,t]),Jn(()=>{g&&!l&&!t&&T()},[g,T,l,t]),me("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[!t&&me(ol,{children:[me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",className:L(r&&"bg-grey-400"),iconButton:!0,onClick:c,children:F(el,{})})}),me(kt,{color:"black",children:[i("editor.controls.actions.move_tool"),F("span",{className:"ml-1 text-grey-400",children:"V"})]})]}),me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",className:L(l&&"bg-grey-400"),iconButton:!0,onClick:T,children:F(js,{})})}),me(kt,{color:"black",children:[i("editor.controls.actions.hand_tool")," ",F("span",{className:"ml-2 text-grey-400",children:"H"})]})]}),me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:N,children:F(Js,{})})}),F(kt,{color:"black",children:i("editor.controls.actions.check")})]})]}),F(qn,{}),!t&&F($n,{disabled:e.length>0}),me(St,{children:[F(Lt,{asChild:!0,children:F(It,{size:"small",variant:"ghost",color:"grey",className:L(E&&"bg-grey-400"),iconButton:!0,onClick:()=>f(!E),children:F(Qs,{})})}),F(kt,{color:"black",children:i(E?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};import{Button as er,Tooltip as tr,TooltipContent as or,TooltipTrigger as nr,useTranslation as nl}from"lecom-ui";import{RedoIcon as rl,UndoIcon as al}from"lucide-react";import{jsx as ge,jsxs as oo}from"react/jsx-runtime";var rr=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:a}=nl();return oo("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[oo(tr,{children:[ge(nr,{asChild:!0,children:ge(er,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:ge(al,{})})}),ge(or,{color:"black",children:a("editor.controls.history.undo")})]}),oo(tr,{children:[ge(nr,{asChild:!0,children:ge(er,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:ge(rl,{})})}),ge(or,{color:"black",children:a("editor.controls.history.redo")})]})]})};import{useReactFlow as il}from"@xyflow/react";import{Button as Pt,Tooltip as Dt,TooltipContent as Rt,TooltipTrigger as Vt,useTranslation as sl}from"lecom-ui";import{ScanIcon as ll,ZoomIn as dl,ZoomOut as cl}from"lucide-react";import{jsx as Y,jsxs as Ke}from"react/jsx-runtime";var ar=()=>{let{t:e}=sl(),{zoomIn:t,zoomOut:o,zoomTo:n,fitView:a}=il();return Ke("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>a(),children:Y(ll,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.fit")})]}),Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>o(),children:Y(cl,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.out")})]}),Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>n(1),children:Y(Ao,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.reset")})]}),Ke(Dt,{children:[Y(Vt,{asChild:!0,children:Y(Pt,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:()=>t(),children:Y(dl,{})})}),Y(Rt,{color:"black",children:e("editor.controls.zoom.in")})]})]})};import{Position as Zl,useReactFlow as ql}from"@xyflow/react";import{Handle as ir,useReactFlow as pl}from"@xyflow/react";import{jsx as sr}from"react/jsx-runtime";var K=a=>{var i=a,{type:e,position:t,className:o}=i,n=le(i,["type","position","className"]);return sr(ir,_({type:e,position:t,className:L("size-2.5 border border-grey-400 bg-white",o)},n))},Mt=r=>{var l=r,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:a,className:i}=l,s=le(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c}=pl(),E=n!=="source"?!1:t==="TASK"?c().filter(g=>g.source===e).length>=2:t==="GATEWAY"&&o==="EXCLUSIVE"?c().filter(g=>g.source===e).length>=2:!1;return sr(ir,_({type:n,position:a,className:L("size-2.5 border border-grey-400 bg-white transition-all duration-200",{"opacity-50 cursor-not-allowed pointer-events-none":E,"hover:border-grey-500":!E},i),style:{pointerEvents:E?"none":"auto"}},s))};import{NodeResizer as ul,useReactFlow as ml}from"@xyflow/react";import{orderBy as gl}from"lodash";import{jsx as fl}from"react/jsx-runtime";var Se=o=>{var n=o,{nodeId:e}=n,t=le(n,["nodeId"]);let{getNode:a,getNodes:i,setNodes:s}=ml(),r=({width:l,height:c})=>{if(!e)return;let u=a(e);if((u==null?void 0:u.type)!=="LANE")return;let E=[...i()],f=!u.parentId,b=f?u.id:u.parentId,g=E.filter(m=>m.type==="LANE"&&m.parentId===b);if(!g.length)return;let T=gl(g,["position.y"]),N=0;T.forEach((m,d)=>{var x,S;let w=d===T.length-1,p=(S=(x=m.measured)==null?void 0:x.height)!=null?S:0;E=E.map(h=>{if(h.id===m.id){let y=f?l-$.HEADER_WIDTH:l,k=I(_({},h),{width:y,measured:I(_({},h.measured),{width:y}),position:I(_({},h.position),{y:N})});return w&&f&&(k.height=c-N),k}return h}),N+=p}),E=E.map(m=>{if(m.id===b){let d=f?l:l+$.HEADER_WIDTH;return I(_({},m),{width:d,height:f?c:N,measured:{width:d,height:f?c:N}})}return m}),s(E)};return fl(ul,_({nodeId:e,handleClassName:"size-1.5 bg-blue-400",lineClassName:"border-blue-400/90 border-dashed",onResizeEnd:(l,c)=>r(c)},t))};import{Position as Bl,NodeToolbar as zl,useReactFlow as Fl}from"@xyflow/react";import{Button as Ul,Tooltip as Wl,TooltipContent as Yl,TooltipTrigger as Kl,useTranslation as $l}from"lecom-ui";import{useNodesData as El,useReactFlow as bl}from"@xyflow/react";import{Button as hl,DropdownMenu as vl,DropdownMenuContent as yl,DropdownMenuGroup as Tl,DropdownMenuItem as Nl,DropdownMenuLabel as _l,DropdownMenuTrigger as xl,Tooltip as wl,TooltipContent as Cl,TooltipTrigger as Al,useTranslation as Il}from"lecom-ui";import{WrenchIcon as Sl}from"lucide-react";import{jsx as pe,jsxs as Ot}from"react/jsx-runtime";var lr=({nodeId:e})=>{let{t}=Il(),{updateNodeData:o}=bl(),n=El(e),a=i=>{(n==null?void 0:n.data.variant)!==i&&o(e,{variant:i})};return Ot(vl,{children:[Ot(wl,{children:[pe(Al,{asChild:!0,children:pe(xl,{asChild:!0,children:pe(hl,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:pe(Sl,{})})})}),pe(Cl,{color:"black",children:t("bpmn.gateway.menu.title")})]}),Ot(yl,{align:"start",className:"w-60 bg-white text-grey-600",children:[pe(_l,{className:"flex items-center",children:pe("div",{className:"flex-1 text-sm font-semibold",children:t("bpmn.gateway.menu.title")})}),pe(Tl,{children:Object.entries(st).map(([i,s])=>Ot(Nl,{className:L({"bg-grey-100 text-blue-500":(n==null?void 0:n.data.variant)===i}),onClick:()=>a(i),children:[pe(s.icon,{className:"stroke-current"}),t(`bpmn.gateway.variant.${i.toLowerCase()}`)]},i))})]})]})};import{useNodesData as kl,useReactFlow as Ll}from"@xyflow/react";import{Button as dr,DropdownMenu as Pl,DropdownMenuContent as Dl,DropdownMenuGroup as Rl,DropdownMenuItem as Vl,DropdownMenuLabel as Ml,DropdownMenuTrigger as Ol,Tooltip as no,TooltipContent as ro,TooltipTrigger as ao,useTranslation as Gl}from"lecom-ui";import{WrenchIcon as Hl}from"lucide-react";import{jsx as X,jsxs as he}from"react/jsx-runtime";var cr=({nodeId:e})=>{let{t}=Gl(),{updateNodeData:o,getEdges:n,getNode:a}=Ll(),i=kl(e),r=n().filter(f=>f.source===e).some(f=>{let b=a(f.target);return(b==null?void 0:b.type)==="END_EVENT"}),l=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},c=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return he(Pl,{children:[he(no,{children:[X(ao,{asChild:!0,children:X(Ol,{asChild:!0,children:X(dr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:X(Hl,{})})})}),X(ro,{color:"black",children:t("bpmn.task.menu.title")})]}),he(Dl,{align:"start",className:"w-60 bg-white text-grey-600",children:[he(Ml,{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(it).map(([u,E])=>{let f=u==="LOOP"&&r,b=f?t("editor.task_menu.loop_not_allowed_when_connected_to_end"):void 0;return he(no,{children:[X(ao,{asChild:!0,children:X(dr,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:L({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>c(u),children:X(E.icon,{className:"stroke-inherit"})})}),b&&X(ro,{color:"black",children:b})]},u)})})]}),X(Rl,{children:Object.entries(at).map(([u,E])=>{let f=u==="SCRIPT"&&r;return he(no,{children:[X(ao,{asChild:!0,children:he(Vl,{className:L({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)===u,"opacity-50 cursor-not-allowed":f}),disabled:f,onClick:f?void 0:()=>l(u),children:[X(E.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${u.toLowerCase()}`)]})}),f&&X(ro,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]},u)})})]})]})};import{jsx as J,jsxs as Xl}from"react/jsx-runtime";var Z=({nodeId:e,nodeType:t,isChild:o,isVisible:n})=>{var C;let{t:a}=$l(),{setDraggableNode:i}=Ce(),{getNode:s,getEdges:r,getNodes:l}=Fl(),c=()=>{var R;if(t!=="GATEWAY")return!1;let v=s(e);return((R=v==null?void 0:v.data)==null?void 0:R.variant)!=="EXCLUSIVE"?!1:r().filter(G=>G.source===e).length>=2},u=()=>l().some(A=>A.type==="START_EVENT"),E=()=>{var A;if(t!=="TASK")return!1;let v=s(e);return((A=v==null?void 0:v.data)==null?void 0:A.variant)==="SCRIPT"},f=()=>t!=="TASK"?!1:r().filter(D=>D.target===e).some(D=>{let R=s(D.source);return(R==null?void 0:R.type)==="START_EVENT"}),b=()=>t!=="TASK"?!1:r().filter(D=>D.source===e).some(D=>{let R=s(D.target);return(R==null?void 0:R.type)==="END_EVENT"}),g=()=>t!=="TASK"?!1:r().filter(D=>D.source===e).length>0,T=()=>t!=="TASK"?!1:r().filter(D=>D.source===e).length>=2,N=c(),m=u(),d=E(),w=f(),p=b(),x=g(),S=T(),h=({event:v,type:A,variant:D})=>{i({type:A,variant:D}),v.dataTransfer.effectAllowed="move",v.dataTransfer.setData("sourceId",e)},y={START_EVENT:{type:"START_EVENT",icon:Ve,label:a("bpmn.start_event.variant.default")},END_EVENT:{type:"END_EVENT",icon:Ne,label:a("bpmn.end_event.variant.default")},TASK:{type:"TASK",icon:Ve,label:a("bpmn.task.variant.default")},GATEWAY:{type:"GATEWAY",variant:"EXCLUSIVE",icon:_e,label:a("bpmn.gateway.variant.exclusive")},ANNOTATION:{type:"ANNOTATION",icon:et,label:a("bpmn.annotation.variant.default")}},k=[{component:J(mt,{elementId:e})}],P={START_EVENT:[y.TASK,y.ANNOTATION,...k],TASK:[{component:J(He,{elementId:e})},{component:J(cr,{nodeId:e})},y.TASK,y.GATEWAY,y.END_EVENT,y.ANNOTATION,...k],GATEWAY:[{component:J(He,{elementId:e})},{component:J(lr,{nodeId:e})},y.TASK,y.GATEWAY,y.ANNOTATION,...k],END_EVENT:[y.ANNOTATION,...k],LANE:[...o?[]:[y.ANNOTATION],...k],ANNOTATION:[...k],UNSUPPORTED:[...k]};return J(zl,{className:"-top-6 flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",position:Bl.Right,align:"start",isVisible:n,children:(C=P[t])==null?void 0:C.map((v,A)=>{if(v.component)return J("div",{children:v.component},A);let D=N&&(v.type==="TASK"||v.type==="GATEWAY"),R=t==="GATEWAY"&&v.type==="GATEWAY",G=m&&v.type==="START_EVENT",ie=d&&v.type==="END_EVENT",ee=w&&v.type==="END_EVENT",se=p&&v.type!=="ANNOTATION",qe=x&&v.type==="END_EVENT",je=S&&v.type!=="ANNOTATION",ye=D||R||G||ie||ee||se||qe||je,Ht=D?a("editor.toolbar.gateway_limit_reached"):R?a("editor.toolbar.gateway_to_gateway_not_allowed"):G?a("editor.toolbar.start_event_already_exists"):ie?a("editor.toolbar.script_to_end_not_allowed"):ee?a("editor.toolbar.initial_activity_to_end_not_allowed"):se?a("editor.toolbar.final_activity_cannot_connect"):qe?a("editor.toolbar.activity_has_outgoing_connections"):je?a("editor.toolbar.task_limit_reached"):v.label;return Xl(Wl,{children:[J(Kl,{asChild:!0,children:J(Ul,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!ye,disabled:ye,className:ye?"opacity-50 cursor-not-allowed":"",onDragStart:ye?void 0:Bt=>h({event:Bt,type:v.type,variant:v.variant}),children:v.icon&&J(v.icon,{size:16})})}),J(Yl,{color:"black",children:Ht})]},A)})})};import{Fragment as jl,jsx as $e,jsxs as Jl}from"react/jsx-runtime";var pr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a}=ql(),{isMultipleSelection:i}=O(),s=r=>{a(e,{label:r})};return Jl(jl,{children:[$e("div",{className:L("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:$e(W,{value:t.label,className:"m-1 text-grey-600",onChange:s})}),$e(Z,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&!i&&o}),$e(Se,{isVisible:!n&&!i&&o,minWidth:ct.MIN_WIDTH,minHeight:ct.MIN_HEIGHT}),$e(K,{type:"target",position:Zl.Left})]})};import{Position as ur,useReactFlow as Ql}from"@xyflow/react";import{useState as ed}from"react";import{Fragment as td,jsx as ke,jsxs as mr}from"react/jsx-runtime";var gr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a}=Ql(),{isMultipleSelection:i}=O(),[s,r]=ed(!1),l=E=>{a(e,{label:E})};return mr(td,{children:[mr("div",{className:"relative",onBlur:()=>{r(!1)},onDoubleClick:()=>{r(!0)},children:[ke(Ne,{className:L("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})}),ke("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:ke(W,{value:t.label,isEditing:s,onChange:l})})]}),ke(Z,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&!i&&o}),ke(K,{type:"source",position:ur.Right}),ke(K,{type:"target",position:ur.Left})]})};import{Position as fr,useReactFlow as od}from"@xyflow/react";import{useState as nd}from"react";import{Fragment as rd,jsx as Le,jsxs as Er}from"react/jsx-runtime";var br=({id:e,data:t,selected:o,dragging:n})=>{let a=st[t.variant].icon,{updateNodeData:i}=od(),{isMultipleSelection:s}=O(),[r,l]=nd(!1),c=f=>{i(e,{label:f})};return Er(rd,{children:[Er("div",{className:"relative",onBlur:()=>{l(!1)},onDoubleClick:()=>{l(!0)},children:[Le(a,{className:L("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})}),Le("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Le(W,{value:t.label,isEditing:r,onChange:c})})]}),Le(Z,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&!s&&o}),Le(K,{type:"target",position:fr.Left}),Le(Mt,{type:"source",position:fr.Right,nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})};import{Position as ad,useReactFlow as id}from"@xyflow/react";import{useState as sd}from"react";import{Fragment as ld,jsx as Xe,jsxs as hr}from"react/jsx-runtime";var vr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a}=id(),{isMultipleSelection:i}=O(),[s,r]=sd(!1),l=E=>{a(e,{label:E})};return hr(ld,{children:[hr("div",{className:"relative",onBlur:()=>{r(!1)},onDoubleClick:()=>{r(!0)},children:[Xe(nt,{className:L("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})}),Xe("div",{className:"absolute top-9 left-1/2 -translate-x-1/2 max-w-80 w-max",children:Xe(W,{value:t.label,isEditing:s,onChange:l})})]}),Xe(Z,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&!i&&o}),Xe(K,{type:"source",position:ad.Right})]})};import{Position as yr,useReactFlow as dd}from"@xyflow/react";import{useTranslation as cd}from"lecom-ui";import{Fragment as pd,jsx as re,jsxs as Tr}from"react/jsx-runtime";var Nr=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:a,getNodes:i}=dd(),{isMultipleSelection:s}=O(),{t:r}=cd(),l=g=>{let T=g.trim(),N=t.label||"";if(T===N)return;let m=i(),d=T;T||(d=yt(m,r("bpmn.task.label.prefix")));let w=Tt(d,m);w!==N&&a(e,{label:w})},c=t.variant?at[t.variant].icon:null,u=t.attribute?it[t.attribute].icon:null,E=t.variant==="SUBPROCESS",f=c&&!E,b=u||E;return Tr(pd,{children:[Tr("div",{className:L("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:[re(W,{value:t.label,maxLength:60,className:L("m-1",{"py-6":f||b}),onChange:l}),c&&re("div",{className:L("absolute flex items-center p-1",E?"bottom-0":"top-0 left-0"),children:re(c,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500")})}),u&&re("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:re("div",{className:L("flex items-center w-16 p-1",E?"justify-between":"justify-center"),children:re(u,{size:16,className:L(t.hasError?"text-red-500":"text-grey-500")})})})]}),re(Z,{nodeId:e,nodeType:"TASK",isVisible:!n&&!s&&o}),re(Se,{isVisible:!n&&!s&&o,minWidth:lt.MIN_WIDTH,minHeight:lt.MIN_HEIGHT}),re(Mt,{type:"source",position:yr.Right,nodeId:e,nodeType:"TASK"}),re(K,{type:"target",position:yr.Left})]})};import{Position as _r}from"@xyflow/react";import{Fragment as ud,jsx as Gt,jsxs as md}from"react/jsx-runtime";var xr=({id:e,data:t,selected:o,dragging:n})=>{let{isMultipleSelection:a}=O();return md(ud,{children:[Gt("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}),Gt(Z,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&!a&&o}),Gt(K,{type:"source",position:_r.Right}),Gt(K,{type:"target",position:_r.Left})]})};import{Position as gd,useReactFlow as fd}from"@xyflow/react";import{orderBy as Ed}from"lodash";import{useMemo as wr}from"react";import{Fragment as bd,jsx as ve,jsxs as Cr}from"react/jsx-runtime";var Ar=({id:e,data:t,selected:o,dragging:n,parentId:a})=>{let{updateNodeData:i,getNodes:s}=fd(),{isMultipleSelection:r}=O(),l=s(),c=!a,u=wr(()=>Ed([...l.filter(g=>g.parentId===e&&g.type==="LANE")],"position.y","asc"),[l,e]),E=c?dt.MIN_WIDTH:$.MIN_WIDTH,f=wr(()=>{if(c&&u.length>1){let g=[...u];return g.pop(),g.reduce((N,m)=>{var d,w;return N+((w=(d=m.measured)==null?void 0:d.height)!=null?w:0)},0)+$.MIN_HEIGHT}return $.MIN_HEIGHT},[c,u]),b=g=>{i(e,{label:g})};return Cr(bd,{children:[Cr("div",{className:L("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:[ve("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400 bg-white",children:ve("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:ve(W,{value:t.label,className:"w-full h-full",onChange:b})})}),ve("div",{className:"flex-1"})]}),ve(Z,{nodeId:e,nodeType:"LANE",isChild:!c,isVisible:!n&&!r&&o}),ve(Se,{nodeId:e,minWidth:E,minHeight:f,isVisible:!n&&!r&&o}),c&&ve(K,{type:"source",position:gd.Right})]})};var Ir={START_EVENT:vr,END_EVENT:gr,TASK:Nr,GATEWAY:br,ANNOTATION:pr,LANE:Ar,UNSUPPORTED:xr},Sr={SEQUENCE_EDGE:Xo,MESSAGE_EDGE:mn,ANNOTATION_EDGE:Uo},kr="#fafafa",Lr="#bebebe",Pr=1,Dr=10,Rr="bottom-left",Vr=.5,Mr=4,Or={x:0,y:0,zoom:.75};import{useStore as hd}from"@xyflow/react";import{useEffect as vd,useRef as yd}from"react";import{jsx as Nd}from"react/jsx-runtime";var Td=e=>({width:e.width,height:e.height,transform:e.transform}),Gr=({horizontal:e,vertical:t,color:o="#3367d9",dashArray:n=[6,6]})=>{let{width:a,height:i,transform:s}=hd(Td),r=yd(null);return vd(()=>{let l=r.current,c=l==null?void 0:l.getContext("2d");if(!c||!l)return;let u=window.devicePixelRatio;l.width=a*u,l.height=i*u,c.scale(u,u),c.clearRect(0,0,a,i),c.strokeStyle=o,c.setLineDash(n),typeof t=="number"&&(c.moveTo(t*s[2]+s[0],0),c.lineTo(t*s[2]+s[0],i),c.stroke()),typeof e=="number"&&(c.moveTo(0,e*s[2]+s[1]),c.lineTo(a,e*s[2]+s[1]),c.stroke())},[a,i,s,e,t,o,n]),Nd("canvas",{ref:r,className:"react-flow__canvas w-full h-full absolute z-10 pointer-events-none"})};import{Button as Hr,Dialog as _d,DialogContent as xd,DialogFooter as wd,DialogHeader as Cd,DialogTitle as Ad,Notification as Id,Typography as io,useTranslation as Sd}from"lecom-ui";import{jsx as ae,jsxs as so}from"react/jsx-runtime";var Br=({pendingDelete:e,setPendingDelete:t,setNodes:o,setEdges:n})=>{let{t:a}=Sd(),i=!!e,s=()=>{let{nodes:l,edges:c}=e||{};l!=null&&l.length&&o(u=>u.filter(E=>!l.some(f=>f.id===E.id))),c!=null&&c.length&&n(u=>u.filter(E=>!c.some(f=>f.id===E.id))),t(null)},r=()=>{t(null)};return ae(_d,{open:i,onOpenChange:r,children:so(xd,{className:"w-[488px] max-w-fit gap-2",children:[ae(Cd,{children:ae(Ad,{children:ae(io,{variant:"heading-small-600",textColor:"text-grey-950",children:a("editor.modals.delete_elements.title")})})}),so("div",{className:"flex flex-col gap-2",children:[ae("div",{className:"py-2",children:ae(Id,{type:"callout",variant:"warning",content:a("editor.modals.delete_elements.callout")})}),ae(io,{variant:"body-large-400",textColor:"text-grey-800",className:"py-2",children:a("editor.modals.delete_elements.content")})]}),so(wd,{className:"flex items-center flex-row justify-end w-full gap-2",children:[ae(Hr,{variant:"outlined",color:"grey",disabled:!1,size:"small",onClick:r,children:ae(io,{variant:"body-medium-500",textColor:"text-grey-800",children:a("editor.modals.delete_elements.cancel")})}),ae(Hr,{size:"small",variant:"filled",color:"destructive",autoFocus:!0,onClick:s,children:a("editor.modals.delete_elements.confirm")})]})]})})};import{useReactFlow as kd}from"@xyflow/react";import{Button as Ld,Tooltip as Pd,TooltipContent as Dd,TooltipTrigger as Rd,useTranslation as Vd}from"lecom-ui";import{jsx as Ze,jsxs as Md}from"react/jsx-runtime";var zr=()=>{let{t:e}=Vd(),{setDraggableNode:t}=Ce(),{getNodes:o}=kd(),a=o().some(l=>l.type==="START_EVENT"),i=[{type:"START_EVENT",icon:nt,label:e("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Ne,label:e("bpmn.end_event.variant.default")},{type:"TASK",icon:Ve,label:e("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Po,label:e("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Lo,label:e("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:ko,label:e("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:_e,label:e("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:ot,label:e("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:tt,label:e("bpmn.gateway.variant.complex")},{type:"LANE",icon:Co,label:e("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:et,label:e("bpmn.annotation.variant.default")}],s=(r,l)=>{t({type:l.type,variant:l.variant,attribute:l.attribute}),r.dataTransfer.effectAllowed="move"};return Ze("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:i.map((r,l)=>{let c=a&&r.type==="START_EVENT",u=c?e("editor.toolbar.start_event_already_exists"):r.label;return Md(Pd,{children:[Ze(Rd,{asChild:!0,children:Ze(Ld,{className:`[&>svg]:size-6 ${c?"opacity-50 cursor-not-allowed":""}`,size:"small",variant:"ghost",color:"grey",draggable:!c,disabled:c,iconButton:!0,onDragStart:c?void 0:E=>s(E,r),children:Ze(r.icon,{})},l)}),Ze(Dd,{color:"black",side:"right",children:u})]},l)})})};import{Button as Od,useTranslation as Gd}from"lecom-ui";import{AlertCircleIcon as Hd,CircleCheckIcon as Bd,XIcon as zd}from"lucide-react";import{useEffect as Fd,useState as Ud}from"react";import{jsx as Q,jsxs as lo}from"react/jsx-runtime";var Fr=({validationResult:e,onClose:t})=>{let{t:o}=Gd(),[n,a]=Ud(!1);if(Fd(()=>{e&&a(!0)},[e]),!n||!e)return null;let{isValid:i,errors:s}=e;return lo("div",{className:L("w-72 max-w-[95vw] rounded-lg border px-4 py-2",{"bg-green-100":i,"bg-red-100":!i}),children:[lo("div",{className:"flex flex-row items-start gap-4",children:[Q("div",{className:"flex-shrink-0",children:i?Q(Bd,{className:"text-green-500 size-5"}):Q(Hd,{className:"text-red-500 size-5"})}),lo("div",{className:"body-medium-500 text-grey-800",children:[Q("div",{children:o(i?"validation.success.title":"validation.errors.title")}),!i&&Q("div",{children:o("validation.errors.subtitle")})]}),Q(Od,{variant:"ghost",size:"small",color:"grey",className:"size-5 hover:bg-transparent",iconButton:!0,onClick:()=>{a(!1),t()},children:Q(zd,{})})]}),Q("div",{className:"max-h-80 overflow-y-auto mt-2 px-9 body-medium-400 text-grey-800",children:i?Q("p",{children:o("validation.success.message")}):Q("div",{className:"list-disc list-inside",children:s.map(r=>Q("li",{className:"mb-1",children:r.message},r.id))})})]})};import{jsx as q,jsxs as uo}from"react/jsx-runtime";var rc=[],Wr=Qd(({mode:e="edit"},t)=>{let o=tc(!1),[n,a,i]=qd([]),[s,r,l]=Zd([]),[c,u]=oc(null),{isMoveTool:E,isHandTool:f,isReadOnly:b,setIsReadOnly:g,setIsMultipleSelection:T,isMinimapOpen:N}=O(),{validationResult:m,handleValidationComplete:d,clearValidation:w,isAutoValidationEnabled:p,validateDiagram:x}=sn(),{getNode:S,getNodes:h,getEdges:y}=Jd(),k=In(a,r);ec(t,()=>k);let{onNodeDrag:P,onDrop:C,onDragOver:v,onNodeDragStop:A}=bn({nodes:n,setNodes:a,setEdges:r}),{isValidConnection:D,onConnect:R}=qo({setEdges:r});pn();let{createDiagram:G}=Cn(),{undo:ie,redo:ee,saveHistory:se,canUndo:qe,canRedo:je}=Ln(),{helperLineHorizontal:ye,helperLineVertical:Ht}=yn();An({LIA_CREATE_DIAGRAM:G,CLEAR_DIAGRAM:()=>{a([]),r([])}}),mo(()=>{g(e==="readonly")},[e,g]),mo(()=>{if(n.length===0&&s.length===0&&e!=="readonly"){let Pe=po(),sa={id:Pe,type:"START_EVENT",position:{x:200,y:300},data:{}},ho=po(),la={id:ho,type:"TASK",position:{x:400,y:270},data:{label:Ur.t("editor.toolbar.initial_task")}},da=po(),ca=I(_({},oe),{id:da,source:Pe,target:ho});a([sa,la]),r([ca])}},[n.length,s.length,e,a,r]);let Bt=()=>{w()},Jr=co(({nodes:U,edges:B})=>{let Te=U.length+B.length>1;T(Te)},[T]);jd({onChange:Jr});let Qr=U=>{let B=S(U.id);if(B!=null&&B.parentId&&(B==null?void 0:B.type)==="LANE"){let Te=fe(B.parentId,n.filter(Pe=>Pe.id!==B.id&&Pe.type==="LANE"));a(ce(Te))}},ea=U=>{U.forEach(B=>{switch(B.type){case"remove":Qr(B);break}})},ta=co(()=>{if(!p){o.current=!1;return}let U=h(),B=y(),Te=x({nodes:U,edges:B});d(Te),o.current=!1},[p,h,y,x,d]),Eo=nc(ta,300),bo=co(()=>{p&&!o.current&&(o.current=!0,Eo())},[p,Eo]),oa=U=>{i(U),se(U),bo(),ea(U)},na=U=>{l(U),se(U),bo()},ra=()=>{se("forceSave")},aa=async({nodes:U,edges:B})=>(u({nodes:U,edges:B}),!1),ia={nodes:n,edges:s};return uo("div",{className:"w-full h-full",children:[!b&&q(zr,{}),q(Dn,{}),uo(Kd,{edges:s,nodes:n,nodeTypes:Ir,edgeTypes:Sr,minZoom:Vr,maxZoom:Mr,panOnDrag:f||b?!0:rc,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:!b&&E,nodesConnectable:!b&&E,nodesDraggable:!b&&E,isValidConnection:D,connectionLineComponent:fn,onConnect:R,onDrop:C,onDropCapture:ra,onDragOver:v,onNodesChange:oa,onEdgesChange:na,onNodeDrag:P,onNodeDragStop:A,onBeforeDelete:aa,selectionMode:Xd.Partial,proOptions:{hideAttribution:!0},multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,snapToGrid:!0,snapGrid:[10,10],defaultViewport:Or,connectOnClick:!0,children:[N&&q(Yd,{pannable:!0,zoomable:!0,position:Rr,className:"shadow-md rounded-md"}),uo("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[!b&&q(rr,{canUndo:qe,canRedo:je,undo:ie,redo:ee}),q(Qn,{nodes:n,isReadOnly:b,diagram:ia,onValidationComplete:d,onValidateDiagram:x}),q(ar,{})]}),q(Gr,{horizontal:ye,vertical:Ht}),q(Wd,{gap:Dr,size:Pr,color:Lr,bgColor:kr}),m&&q("div",{className:"absolute top-6 right-6 z-[1000]",children:q(Fr,{validationResult:m,onClose:Bt})})]}),q(Br,{pendingDelete:c,setPendingDelete:u,setNodes:a,setEdges:r})]})});Wr.displayName="Editor";var ac=({mode:e,locale:t="pt_BR",onConfigureElement:o,selectorRef:n})=>(mo(()=>{t&&Ur.changeLanguage(t)},[t]),q($d,{children:q(Bo,{value:{onConfigureElement:o},children:q(Wr,{mode:e,ref:n})})})),go=ac;var fo=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 ic,Translations as sc}from"lecom-ui";var Yr={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event"},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"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event"}},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"},label:{prefix:"Activity"}},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 Kr={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio"},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"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final"}},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"},label:{prefix:"Actividad"}},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 $r={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio"},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"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final"}},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"},label:{prefix:"Atividade"}},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 Xr={pt_BR:$r,en_US:Yr,es_ES:Kr};var Zr,qr,lc=(qr=(Zr=fo("LecomUserLanguage"))!=null?Zr:fo("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?qr:sc.PT_BR;ic({lng:lc,resources:Xr});import{jsx as jr}from"react/jsx-runtime";var W2=e=>jr(No,{children:jr(go,_({},e))});export{Ft as ActivityVariant,Wt as ComplexVariant,zt as ElementType,Yt as ExclusiveVariant,te as GatewayVariant,W2 as Modeler,Ut as RoutingVariant,We as useSelectionUtils};