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