lecom-modeler 0.2.7 → 0.2.8
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 +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var vi=Object.create;var Nt=Object.defineProperty,Ti=Object.defineProperties,_i=Object.getOwnPropertyDescriptor,wi=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertyNames,Kt=Object.getOwnPropertySymbols,Ci=Object.getPrototypeOf,Bo=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable;var bn=(e,t,o)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))Bo.call(t,o)&&bn(e,o,t[o]);if(Kt)for(var o of Kt(t))yn.call(t,o)&&bn(e,o,t[o]);return e},C=(e,t)=>Ti(e,wi(t));var ke=(e,t)=>{var o={};for(var n in e)Bo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Kt)for(var n of Kt(e))t.indexOf(n)<0&&yn.call(e,n)&&(o[n]=e[n]);return o};var Ai=(e,t)=>{for(var o in t)Nt(e,o,{get:t[o],enumerable:!0})},hn=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of xi(t))!Bo.call(e,a)&&a!==o&&Nt(e,a,{get:()=>t[a],enumerable:!(n=_i(t,a))||n.enumerable});return e};var Ii=(e,t,o)=>(o=e!=null?vi(Ci(e)):{},hn(t||!e||!e.__esModule?Nt(o,"default",{value:e,enumerable:!0}):o,e)),Si=e=>hn(Nt({},"__esModule",{value:!0}),e);var fs={};Ai(fs,{ActivityVariant:()=>Zt,ComplexVariant:()=>Xt,ElementType:()=>vt,ExclusiveVariant:()=>jt,GatewayVariant:()=>ye,Modeler:()=>gs,RoutingVariant:()=>qt,useSelectionUtils:()=>mt});module.exports=Si(fs);var Yt=require("lecom-ui"),$t=require("react/jsx-runtime");function Nn({children:e}){return(0,$t.jsxs)(Yt.TooltipProvider,{children:[(0,$t.jsx)(Yt.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}var q=require("@xyflow/react"),dn=require("lecom-ui"),ee=require("react"),ja=require("use-debounce"),Go=require("uuid");var vt=(a=>(a.ACTIVITY="activity",a.ROUTING="routing",a.GATEWAY="gateway",a.SUB_PROCESS="sub_process",a))(vt||{}),Zt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Zt||{}),qt=(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))(qt||{}),Xt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Xt||{}),jt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(jt||{});var st=require("lucide-react");var Be=require("react/jsx-runtime"),Jt=({size:e=24,className:t})=>(0,Be.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,Be.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Be.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Be.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Be.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var zo=require("react/jsx-runtime"),tt=({size:e=24,className:t})=>(0,zo.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,zo.jsx)("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"})});var De=require("react/jsx-runtime"),Qt=({size:e=24,className:t})=>(0,De.jsxs)("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:[(0,De.jsx)("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"}),(0,De.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,De.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,De.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,De.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var ot=require("react/jsx-runtime"),nt=({size:e=24,className:t})=>(0,ot.jsxs)("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:[(0,ot.jsx)("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"}),(0,ot.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ot.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var rt=require("react/jsx-runtime"),eo=({size:e=24,className:t})=>(0,rt.jsxs)("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:[(0,rt.jsx)("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"}),(0,rt.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,rt.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var at=require("react/jsx-runtime"),vn=({size:e=24,className:t})=>(0,at.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,at.jsxs)("g",{children:[(0,at.jsx)("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"}),(0,at.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Tn=require("clsx"),_n=require("tailwind-merge");function k(...e){return(0,_n.twMerge)((0,Tn.clsx)(e))}var Tt=(e,t)=>e<t?t:e;var _t=require("react/jsx-runtime"),wn=({size:e=24,className:t})=>(0,_t.jsxs)("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:[(0,_t.jsx)("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"}),(0,_t.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var to=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,to.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,to.jsx)("g",{children:(0,to.jsx)("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"})})});var Uo=require("react/jsx-runtime"),oo=({size:e=24,className:t})=>(0,Uo.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,Uo.jsx)("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"})});var Fo=require("react/jsx-runtime"),wt=({size:e=24,className:t})=>(0,Fo.jsx)("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:(0,Fo.jsx)("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"})});var it=require("react/jsx-runtime"),Cn=({size:e=24,className:t})=>(0,it.jsxs)("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:[(0,it.jsx)("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"}),(0,it.jsx)("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"}),(0,it.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Re=require("react/jsx-runtime"),An=({size:e=24,className:t})=>(0,Re.jsxs)("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:[(0,Re.jsx)("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"}),(0,Re.jsx)("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"}),(0,Re.jsx)("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"}),(0,Re.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Re.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ze=require("react/jsx-runtime"),In=({size:e=24,className:t})=>(0,ze.jsxs)("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:[(0,ze.jsx)("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"}),(0,ze.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,ze.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ze.jsx)("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 no={SCRIPT:{icon:st.ScrollText},SUBPROCESS:{icon:st.SquarePlus}};var ro={LOOP:{icon:st.RotateCcw}},ye=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ye||{}),Wo={EXCLUSIVE:{icon:nt},PARALLEL:{icon:eo},COMPLEX:{icon:Qt}};var Sn=require("zustand"),z=(0,Sn.create)(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})}}));var At=require("@xyflow/react");var _e=require("@xyflow/react");var ge=require("@xyflow/react"),ve=require("lecom-ui"),Pn=require("lucide-react");var ao=require("react"),kn=(0,ao.createContext)(null),Ln=kn.Provider,io=()=>{let e=(0,ao.useContext)(kn);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};var Ue=require("react/jsx-runtime"),xt=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,ve.useTranslation)(),{getNode:n,getEdge:a,getNodes:r,getEdges:s}=(0,ge.useReactFlow)(),{onConfigureElement:i}=io(),l=d=>{var u,_,p,N,A;return d?d.type==="TASK"&&((u=d.data)==null?void 0:u.variant)==="SUBPROCESS"?{id:d.id,type:"sub_process",variant:y(d),label:(_=d.data)==null?void 0:_.label}:d.type==="GATEWAY"?{id:d.id,type:"gateway",variant:((p=d.data)==null?void 0:p.variant)||"EXCLUSIVE",label:(N=d.data)==null?void 0:N.label}:{id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label}:null},c=d=>{let u=r(),_=s(),p=(0,ge.getIncomers)(d,u,_);if(p.length===0)return;let N=p[0];return l(N)||void 0},y=d=>{let u=r(),_=s(),p=(0,ge.getIncomers)(d,u,_),N=(0,ge.getOutgoers)(d,u,_),A=p.some(L=>L.type==="START_EVENT"),P=N.some(L=>L.type==="END_EVENT");return A?"start":P?"end":"between"},b=d=>{var L,I,S,R;let u=r(),_=s(),p=n(d.source),N=n(d.target);if(!p||!N)return"simple";if((0,ge.getOutgoers)(p,u,_).some(B=>B.type==="END_EVENT"))return"final";if(p.type==="GATEWAY")switch((L=p.data)==null?void 0:L.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(p.type==="TASK"){let B=(I=p.data)==null?void 0:I.variant,se=(S=p.data)==null?void 0:S.attribute;return N.type==="TASK"&&((R=N.data)==null?void 0:R.variant)==="SUBPROCESS"?"to_sub_process":B==="SCRIPT"?"script":se==="LOOP"?"loop":"simple"}return"simple"},g=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="COMPLEX")return;let _=r(),p=s(),N=(0,ge.getIncomers)(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A&&P)return"script_loop";if(A)return"script";if(P)return"loop"},E=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="EXCLUSIVE")return;let _=r(),p=s(),N=(0,ge.getIncomers)(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A)return"script";if(P)return"loop"},m=d=>{var P,L;if(d.type!=="GATEWAY")return;let u=r(),_=s(),p=(0,ge.getIncomers)(d,u,_),N=!1,A=!1;if(p.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(N=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(A=!0))}),((P=d.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}else if(((L=d.data)==null?void 0:L.variant)==="EXCLUSIVE"){if(N)return"script";if(A)return"loop"}},h=d=>(0,ge.getOutgoers)(d,r(),s()).map(p=>{var N,A;return{id:p.id,type:p.type,variant:(N=p.data)==null?void 0:N.variant,label:(A=p.data)==null?void 0:A.label}}),v=d=>s().filter(p=>p.source===d.id).map(p=>{var N;return{id:p.id,type:"routing",variant:b(p),label:(N=p.data)==null?void 0:N.label,target:n(p.target)}}),T=()=>{var _,p,N,A,P,L;let d=n(e);if(!d)return;let u=c(d);if(d.type==="TASK"&&((_=d.data)==null?void 0:_.variant)==="SUBPROCESS"){i==null||i({id:d.id,type:"sub_process",variant:y(d),label:(p=d.data)==null?void 0:p.label,origin:u,targets:h(d),edgeTargets:v(d)}),console.log({id:d.id,type:"sub_process",variant:y(d),label:(N=d.data)==null?void 0:N.label,origin:u,targets:h(d),edgeTargets:v(d)});return}if(d.type!=="GATEWAY"){i==null||i({id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label,origin:u,targets:h(d),edgeTargets:v(d)});return}i==null||i({id:d.id,type:"gateway",variant:((P=d.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(L=d.data)==null?void 0:L.label,origin:u,subVariant:m(d),targets:h(d)})},f=()=>{let d=a(e);if(d){let u=b(d),_;u==="complex"?_=g(d):u==="exclusive"&&(_=E(d));let p=n(d.source),N=p&&l(p)||void 0;i==null||i({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)}),console.log({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)})}};return(0,Ue.jsxs)(ve.Tooltip,{children:[(0,Ue.jsx)(ve.TooltipTrigger,{asChild:!0,children:(0,Ue.jsx)(ve.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":T();break;case"edge":f();break}},children:(0,Ue.jsx)(Pn.Settings,{size:16})})}),(0,Ue.jsx)(ve.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var Dn=require("@xyflow/react"),Te=require("lecom-ui"),Rn=require("lucide-react"),We=require("react/jsx-runtime"),so=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Te.useTranslation)(),{deleteElements:n}=(0,Dn.useReactFlow)();return(0,We.jsxs)(Te.Tooltip,{children:[(0,We.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(Te.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:(0,We.jsx)(Rn.TrashIcon,{size:16})})}),(0,We.jsx)(Te.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var Ct=require("react/jsx-runtime"),lt=n=>{var a=n,{edgeId:e,edgeType:t}=a,o=ke(a,["edgeId","edgeType"]);var i;let r=[{component:(0,Ct.jsx)(so,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:(0,Ct.jsx)(xt,{elementId:e,elementType:"edge"})},...r],MESSAGE_EDGE:[...r],ANNOTATION_EDGE:[...r]};return(0,Ct.jsx)("div",C(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)=>(0,Ct.jsx)("div",{children:l.component},c))}))};var Ke=require("react/jsx-runtime"),co={type:"ANNOTATION_EDGE",zIndex:2e3},Vn=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,selected:i,data:l})=>{let c=(0,_e.useNodes)(),{zoom:y}=(0,_e.useViewport)(),{isMultipleSelection:b}=z(),g=c.find(x=>x.id===t),E=c.find(x=>x.id===o),[m,h,v]=(0,_e.getStraightPath)({sourceX:n,sourceY:a,targetX:r,targetY:s}),T=i||(g==null?void 0:g.selected)||(E==null?void 0:E.selected),f=1/y;return(0,Ke.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":T}),children:[(0,Ke.jsx)(_e.BaseEdge,{id:e,path:m,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)]":T&&!(l!=null&&l.hasError)})}),(0,Ke.jsx)(_e.EdgeLabelRenderer,{children:(0,Ke.jsx)("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&&!b&&(0,Ke.jsx)(lt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${f})`}})})})]})};var te=require("@xyflow/react"),Mn=require("react");var Ye=require("react");var Yo=require("react/jsx-runtime"),X=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:a,className:r,style:s})=>{let i=(0,Ye.useRef)(null),[l,c]=(0,Ye.useState)(!1);(0,Ye.useEffect)(()=>{c(n!=null?n:!1)},[n]),(0,Ye.useEffect)(()=>{if(l&&i.current){i.current.focus();let m=document.createRange();m.selectNodeContents(i.current),m.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(m))}},[l]);let y=m=>{if(m.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))},b=m=>{let h=m.currentTarget.innerText.trim(),v=t&&h.length>=t,T=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],f=m.ctrlKey||m.metaKey,x=f&&m.key==="a",d=f&&m.key==="c",u=f&&m.key==="x",_=f&&m.key==="v";function p(A){return/\w/.test(A)}if(h.length===0&&!p(m.key)&&!T.includes(m.key)&&!f){m.preventDefault();return}v&&(T.includes(m.key)||x||d||u||_||m.preventDefault())},g=m=>{if(!t)return;m.preventDefault();let h=m.clipboardData.getData("text/plain"),v=m.currentTarget.innerText,T=window.getSelection();if(!T||T.rangeCount===0)return;let f=T.getRangeAt(0);if((v.substring(0,f.startOffset)+h+v.substring(f.endOffset)).length>t){let d=t-(v.length-(f.endOffset-f.startOffset)),u=h.substring(0,Math.max(0,d));u&&(f.deleteContents(),f.insertNode(document.createTextNode(u)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f))}else f.deleteContents(),f.insertNode(document.createTextNode(h)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f)},E=m=>{c(!1);let h=m.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),m.currentTarget.innerText=h,a==null||a(),h!==e&&(o==null||o(h))};return(0,Yo.jsx)("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",r,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:y,children:(0,Yo.jsx)("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:b,onPaste:g,onBlur:E,children:e})})};var Ve=require("react/jsx-runtime"),we={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:te.MarkerType.ArrowClosed},markerEnd:{type:te.MarkerType.Arrow},data:{label:""}},On=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=(0,te.useNodes)(),{zoom:g}=(0,te.useViewport)(),{updateEdgeData:E}=(0,te.useReactFlow)(),{isMultipleSelection:m}=z(),[h,v]=(0,Mn.useState)(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=(0,te.getSmoothStepPath)({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return(0,Ve.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[(0,Ve.jsx)(te.BaseEdge,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),(0,Ve.jsx)(te.EdgeLabelRenderer,{children:(0,Ve.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&&(0,Ve.jsx)(lt,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${A})`}}),N&&(0,Ve.jsx)(X,{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:I})]})})]})};var po=e=>e.some(t=>t.type==="START_EVENT"),uo=(e,t,o)=>{var r;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((r=n.data)==null?void 0:r.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},mo=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},go=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},fo=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.target===e).some(r=>{let s=t.find(i=>i.id===r.source);return(s==null?void 0:s.type)==="START_EVENT"})},Eo=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.source===e).some(r=>{let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)==="END_EVENT"})},bo=(e,t)=>t.filter(n=>n.source===e).length>0,yo=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>{if(r.source!==e)return!1;let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)!=="ANNOTATION"}).length>=2};var ki=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!uo(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!yo(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:!(mo(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(go(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(fo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(Eo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(bo(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"})],Gn=e=>{for(let t of ki){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Li=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:uo(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:po(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:mo(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:go(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Eo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bo(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:yo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Hn=e=>{let t=Li.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),a=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&a});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Bn=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=(0,At.useReactFlow)();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 Gn(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?(0,At.addEdge)(w(w({},s),co),i):(0,At.addEdge)(w(w({},s),we),i)})}}};var $o=require("react"),qn=require("lecom-ui"),Xn=require("@xyflow/react");var It=(e=[])=>e.filter(t=>t.type==="START_EVENT"),$e=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Me=(e=[])=>e.filter(t=>t.type==="TASK")||[],zn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Un=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),ho=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Fn=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),le=(e,t=[])=>t.filter(o=>o.source===e),St=(e,t=[])=>t.filter(o=>o.target===e),Wn=(e,t)=>{var n,a;let o=(n=t.nodes)==null?void 0:n.find(r=>r.id===e);return((a=o==null?void 0:o.properties)==null?void 0:a.attribute)==="LOOP"},Kn=(e,t)=>{let o=le(e,t.edges||[]);for(let n of o){let a=(t.nodes||[]).find(r=>r.id===n.target);if(a&&a.type==="END_EVENT")return!0}return!1},Yn=e=>e?/\w/g.test(e.trim()):!1,O=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:[]}},xe=(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)}},$n=(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 kt=[{id:"start_event_not_found",validate:e=>{let t=It(e.nodes);return O({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=$e(e.nodes);return O({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=It(e.nodes),o=t.length===1;if(t.length===0)return O({isValid:!0});if(!o)return O({isValid:!1,nodeIds:t.map(r=>r.id)});let n=le(t[0].id,e.edges);if(!(n.length<=1)){let r=[...t.map(s=>s.id),...n.map(s=>s.target)];return O({isValid:!1,nodeIds:[...new Set(r)]})}return O({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Me(e.nodes),o=xe(t,n=>le(n.id,e.edges).length<=2);return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Me(e.nodes),o=xe(t,n=>!!n.label&&n.label.trim()!=="");return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Me(e.nodes),n=xe(o,a=>!a.label||a.label.length<=60);return O({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Me(e.nodes),o=new Map;for(let a of t){if(!a.label)continue;let r=a.label.trim();r&&(o.has(r)||o.set(r,[]),o.get(r).push(a))}let n=[];for(let[,a]of o.entries())a.length>1&&a.forEach(r=>n.push(r.id));return O({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...It(e.nodes),...$e(e.nodes)],o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=$e(e.nodes),o=[],n=[];for(let a of t){let r=St(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=le(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return O({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Fn(e.nodes),o=xe(t,a=>le(a.id,e.edges).length<=2),n=o.invalidIds.flatMap(a=>le(a,e.edges).map(r=>r.id));return O({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Me(e.nodes),o=xe(t,n=>!n.label||Yn(n.label));return O({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 O({isValid:!0});let t=$e(e.nodes)[0];if(!t)return O({isValid:!0});let o=St(t.id,e.edges);if(!o.length)return O({isValid:!0});let a=Me(e.nodes).filter(l=>o.some(c=>c.source===l.id)),r=xe(a,l=>!Wn(l.id,e));return O({isValid:r.isValid,nodeIds:r.isValid?[]:[t.id,...r.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Me(e.nodes),o=$e(e.nodes)[0];if(!o)return O({isValid:!0});let n=t.filter(l=>{let c=St(l.id,e.edges),y=le(l.id,e.edges),b=c.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.source))==null?void 0:m.type)==="START_EVENT"}),g=y.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.target))==null?void 0:m.type)==="END_EVENT"});return b&&g}),a=St(o.id,e.edges),r=a.length>1,s=a.map(l=>l.source),i={isValid:n.length===0&&!r,nodeIds:[...n.map(l=>l.id),...r?s:[]]};return O(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ho(e.nodes),o=xe(t,n=>le(n.id,e.edges).length>=1);return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...It(e.nodes),...$e(e.nodes)],o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=zn(e.nodes),o=xe(t,n=>!Kn(n.id,e));return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Un(e.nodes),o=xe(t,n=>{var a,r;return((a=n.properties)==null?void 0:a.subprocessRef)!==void 0&&((r=n.properties)==null?void 0:r.subprocessRef)!==""});return O({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Zn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of kt){let a=n.validate(e);a.isValid||t.push({id:n.id,message:n.id,nodeIds:a.nodeIds||[],edgeIds:a.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var jn=()=>{let{t:e}=(0,qn.useTranslation)(),[t,o]=(0,$o.useState)(null),{setNodes:n,setEdges:a,getNodes:r,getEdges:s}=(0,Xn.useReactFlow)(),[i,l]=(0,$o.useState)(!1);return{validationResult:t,validateDiagram:g=>{let E=$n(g.nodes,g.edges),m=Zn(E),h=m.errors.map(v=>C(w({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:m.isValid,errors:h}},handleValidationComplete:g=>{if(o(g),!g)return;let E=[],m=[];g.errors.forEach(p=>{p.nodeIds&&p.nodeIds.length>0&&p.nodeIds.forEach(N=>E.push(N)),p.edgeIds&&p.edgeIds.length>0&&p.edgeIds.forEach(N=>m.push(N))});let h=[...new Set(E)];n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})}))),a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})})));let v=r(),T=s(),f=new Set(h),x=new Set;g.errors.forEach(p=>{var P,L;let N=kt.find(I=>I.id===p.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=p.edgeIds)==null||P.forEach(I=>x.add(I)),(L=p.nodeIds)==null||L.forEach(I=>{T.forEach(S=>{(S.source===I||S.target===I)&&x.add(S.id)})}))});let d=new Set,u=new Set,_=new Set;v.forEach(p=>{p.type==="START_EVENT"?d.add(p.id):p.type==="END_EVENT"&&u.add(p.id)}),T.forEach(p=>{d.has(p.source)&&_.add(p.target),u.has(p.target)&&_.add(p.source)}),_.forEach(p=>{var N,A;if(f.has(p)){let P=(N=g.errors.find(I=>{var S;return(S=I.nodeIds)==null?void 0:S.includes(p)}))==null?void 0:N.id;((A=kt.find(I=>I.id===P))==null?void 0:A.highlightRelatedEdges)!==!1&&T.forEach(I=>{I.source===p&&u.has(I.target)&&(f.add(I.target),x.add(I.id)),I.target===p&&d.has(I.source)&&(f.add(I.source),x.add(I.id))})}}),f.size>0&&n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:f.has(N.id)})}))),x.size>0&&a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})}))),a(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})})))},isAutoValidationEnabled:i}};var er=require("@xyflow/react"),tr=require("lecom-ui"),or=require("react"),Zo=require("uuid");var No=(e,t)=>{let n=e.filter(r=>r.type==="TASK").map(r=>{var i;let s=(i=r.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(r=>r>0),a=n.length>0?Math.max(...n)+1:1;return`${t} ${a}`},dt=(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 a=e.replace(/\s+\(\d+\)$/,""),r=n.filter(i=>i===a||i.startsWith(`${a} (`)).map(i=>{if(i===a)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;r.includes(s);)s++;return`${a} (${s})`};var Pi=15,Jn="bpmn:selection",Di=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},Qn=e=>{if(!Di(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},nr=({offset:e=Pi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=(0,er.useReactFlow)(),{t:r}=(0,tr.useTranslation)();(0,or.useEffect)(()=>{let s=l=>{var h,v;if(!Qn(l))return;let c=t(),y=n(),b=c.filter(T=>T.selected);if(!b.length)return;l.preventDefault(),l.stopPropagation();let g=y.filter(T=>b.some(f=>f.id===T.source)&&b.some(f=>f.id===T.target)),m=JSON.stringify({nodes:b,edges:g});(h=l.clipboardData)==null||h.setData(Jn,m),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${b.length} nodes`)},i=l=>{var x,d;if(!Qn(l))return;let c=(x=l.clipboardData)==null?void 0:x.getData(Jn);if(!c)return;l.preventDefault(),l.stopPropagation();let y;try{y=JSON.parse(c)}catch(u){return}if(!((d=y.nodes)!=null&&d.length))return;let b=new Map,g=t(),E=[],m=g.some(u=>u.type==="START_EVENT"),h=y.nodes.filter(u=>u.type==="START_EVENT"),v=y.nodes;if(m&&h.length>0&&(v=y.nodes.filter(u=>u.type!=="START_EVENT"),v.length===0))return;let T=v.map(u=>{var N;let _=(0,Zo.v7)();b.set(u.id,_);let p=C(w({},u),{id:_,selected:!0,position:{x:u.position.x+e,y:u.position.y+e}});if(u.type==="TASK"){let A=(N=u.data)==null?void 0:N.label,P=dt(A||r("bpmn.task.label.prefix"),[...g,...E]);p.data=C(w({},u.data),{label:P})}return E.push(p),p}),f=y.edges.map(u=>C(w({},u),{id:(0,Zo.v7)(),selected:!0,source:b.get(u.source)||u.source,target:b.get(u.target)||u.target}));o(u=>[...u.map(_=>C(w({},_),{selected:!1})),...T]),a(u=>[...u.map(_=>C(w({},_),{selected:!1})),...f])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,a,e,r])};var wo=require("@xyflow/react"),Er=require("lecom-ui"),Xo=require("uuid");var Ri={MIN_WIDTH:36,MIN_HEIGHT:36},Vi={MIN_WIDTH:36,MIN_HEIGHT:36},Mi={MIN_WIDTH:56,MIN_HEIGHT:56},vo={MIN_WIDTH:176,MIN_HEIGHT:96},To={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},oe={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},_o={MIN_WIDTH:176,MIN_HEIGHT:64},Oi={MIN_WIDTH:128,MIN_HEIGHT:64},Y={START_EVENT:Ri,END_EVENT:Vi,GATEWAY:Mi,TASK:vo,LANE:oe,ANNOTATION:_o,UNSUPPORTED:Oi};var qo=Ii(require("@dagrejs/dagre"),1),sr=require("@xyflow/react"),lr=require("lodash");var rr=require("lodash");var Le=e=>{var t,o,n,a,r,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(a=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?a:0,w:(s=(r=e.measured)==null?void 0:r.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},Ze=e=>(0,rr.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ar=(e,t)=>{let{x:o,y:n}=Le(e),{x:a,y:r}=Le(t);return{x:o-a,y:n-r}};var ct=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(a=>a.parentId===e&&(!o.length||o.includes(a.type))&&!n.includes(a.type)),Gi=(e,t)=>{let{x:o,y:n}=Le(e),{x:a,y:r}=Le(t),s=o-a,i=n-r;return Math.sqrt(s*s+i*i)},Hi=(e,t)=>{let{x:o,y:n,w:a,h:r}=Le(e),{x:s,y:i,w:l,h:c}=Le(t);return o<s+l&&s<o+a&&n<i+c&&i<n+r},Lt=(e,t)=>{let o=null,n=1/0;for(let a of t)if(a.id!==e.id&&Hi(e,a)){let r=Gi(e,a);r<n&&(n=r,o=a)}return o},ir=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var a,r;return Math.max(o,(r=(a=n.measured)==null?void 0:a.width)!=null?r:0)},0);var dr=(e=[],t=[],o="LR")=>{let n=new qo.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:r,width:s,height:i})=>n.setNode(r,{width:s,height:i})),t.forEach(r=>n.setEdge(r.source,r.target)),qo.default.layout(n),{nodes:e.map(r=>{let s=n.node(r.id);return C(w({},r),{position:{x:s.x-r.width/2,y:s.y-r.height/2}})}),edges:t}},qe=(e,t)=>{var g,E;let o=[...t],n=o.find(m=>m.id===e);if(!n)return o;let a=o.filter(m=>m.parentId===e&&m.type==="LANE");if(a.length===0)return o;let r=(0,lr.orderBy)(a,["position.y"]),s=Math.max((E=(g=n.measured)==null?void 0:g.width)!=null?E:0,To.MIN_WIDTH),i=ir(e,r)||oe.MIN_WIDTH,l=Math.max(s,i),c=0,y=0;r.forEach(m=>{var h,v,T,f;o=o.map(x=>x.id===m.id?C(w({},x),{width:l-oe.HEADER_WIDTH,measured:C(w({},x.measured),{width:l-oe.HEADER_WIDTH}),position:{x:oe.HEADER_WIDTH,y:c}}):x),c+=(v=(h=m.measured)==null?void 0:h.height)!=null?v:0,y+=(f=(T=m.measured)==null?void 0:T.height)!=null?f:0}),o=o.map(m=>m.id===e?C(w({},m),{height:y,width:l,measured:C(w({},m.measured),{height:y,width:l})}):m);let b=o.find(m=>m.id===e);return b!=null&&b.parentId&&(o=qe(b.parentId,o)),o},cr=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Bi=50,pr=(e,t=Bi)=>{let o=(0,sr.getNodesBounds)(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var ur=require("zustand"),pt=(0,ur.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var re=require("@xyflow/react"),mr=require("react");var Oe=require("react/jsx-runtime"),Od={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:re.MarkerType.Arrow},data:{label:""}},gr=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=(0,re.useNodes)(),{zoom:g}=(0,re.useViewport)(),{updateEdgeData:E}=(0,re.useReactFlow)(),{isMultipleSelection:m}=z(),[h,v]=(0,mr.useState)(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=(0,re.getSmoothStepPath)({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return(0,Oe.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[(0,Oe.jsx)(re.BaseEdge,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),(0,Oe.jsx)(re.EdgeLabelRenderer,{children:(0,Oe.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&&(0,Oe.jsx)(lt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${A})`}}),N&&(0,Oe.jsx)(X,{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:I})]})})]})};var Pt=require("react/jsx-runtime"),fr=({fromX:e,fromY:t,toX:o,toY:n})=>(0,Pt.jsxs)("g",{children:[(0,Pt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),(0,Pt.jsx)("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var br=({nodes:e,setNodes:t,setEdges:o})=>{let n=(0,wo.useStoreApi)(),{draggableNode:a,setDraggableNode:r}=pt(),{getInternalNode:s,screenToFlowPosition:i}=(0,wo.useReactFlow)(),{t:l}=(0,Er.useTranslation)(),c=d=>{let u="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(_=>_.map(p=>C(w({},p),{className:p.id===d?u:""})))},y=()=>{let{nodeLookup:d}=n.getState();return Array.from(d.values())},b=d=>{let u=s(d.id),_=y();if(d.type==="LANE"){if(ct({parentId:d.id,nodes:e,includeTypes:["LANE"]})){c();return}let I=_.filter(B=>B.id!==d.id&&B.type==="LANE"&&!B.parentId),S=Lt(u,I);if(!S){c();return}if(ct({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(S.id);return}let N=_.filter(L=>L.id!==d.id&&L.type==="LANE"),A=Lt(u,N);if(!A){c();return}if(ct({parentId:A.id,nodes:e,includeTypes:["LANE"]})){c();return}c(A.id)},g=d=>d.map(u=>C(w({},u),{className:void 0})),E=d=>d.some(_=>_.dragging)?d.map(_=>_.dragging?C(w({},_),{dragging:!1}):_):d,m=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move"},h=(d,u)=>{d.preventDefault(),b(u)},v=(d,u,_)=>{var L,I;let p=[..._];if(d.parentId===u.id)return p=qe(u.id,p),g(p);if(d.type==="LANE"){if(ct({parentId:u.id,nodes:p,excludeTypes:["LANE"]}))return p;let B=p.filter(ue=>ue.parentId===u.id).reduce((ue,Qe)=>{var zt,Ut;return ue+((Ut=(zt=Qe.measured)==null?void 0:zt.height)!=null?Ut:0)},0),se={x:oe.HEADER_WIDTH,y:B};return p=p.map(ue=>ue.id===d.id?C(w({},ue),{parentId:u.id,position:se,className:void 0}):C(w({},ue),{className:void 0})),p=qe(u.id,p),p}if(ct({parentId:u.id,nodes:p,includeTypes:["LANE"]})){let S;if(d.parentId){let R=s(d.parentId),{x:B,y:se}=Le(R);S={x:B+((L=d.position.x)!=null?L:0),y:se+((I=d.position.y)!=null?I:0)}}return p=p.map(R=>R.id===d.id?C(w({},R),{position:S!=null?S:R.position,parentId:void 0,className:void 0}):C(w({},R),{className:void 0})),p}let P=ar(d,u);return p=p.map(S=>S.id===d.id?C(w({},S),{parentId:u.id,position:P,className:void 0}):C(w({},S),{className:void 0})),p},T=d=>{if(d.preventDefault(),!(a!=null&&a.type))return;let u=i({x:d.clientX,y:d.clientY}),_={width:Y[a.type].MIN_WIDTH,height:Y[a.type].MIN_HEIGHT},p={id:(0,Xo.v7)(),type:a.type,position:u,measured:_,data:{label:a.type==="TASK"?No(e,l("bpmn.task.label.prefix")):"",variant:a.variant,attribute:a.attribute}},N=C(w({},p),{internals:{positionAbsolute:u}}),A=y(),P=a.type==="LANE",L=A.filter(B=>P?B.type==="LANE"&&!B.parentId:B.type==="LANE"),I=Lt(N,L),S=[...e,p];I&&(S=v(N,I,S)),t(Ze(S));let R=d.dataTransfer.getData("sourceId");if(R){let B={id:(0,Xo.v7)(),source:R,target:p.id};if(a.type==="ANNOTATION"){o(se=>se.concat(w(w({},B),co)));return}o(se=>se.concat(w(w({},B),we)))}r(null)},f=async(d,u,_)=>{let p=[...e];_.forEach(N=>{let A=y(),P=s(N.id),L=N.type==="LANE",I=A.filter(R=>R.id!==N.id&&(L?R.type==="LANE"&&!R.parentId:R.type==="LANE")),S=Lt(P,I);if(S){p=v(P,S,p);return}N.parentId&&(p=x(N,p))}),p=E(p),t(Ze(p))},x=(d,u)=>{var P,L;let _=s(d.parentId),{x:p,y:N}=Le(_),A={x:p+((P=d.position.x)!=null?P:0),y:N+((L=d.position.y)!=null?L:0)};return u=u.map(I=>I.id===d.id?C(w({},I),{position:A,parentId:void 0}):I),u=qe(d.parentId,u),u};return{onDragOver:m,onDrop:T,onNodeDrag:h,onNodeDragStop:f}};var yr=require("@xyflow/react"),hr=require("lecom-ui"),Nr=require("react"),jo=require("uuid");var zi=30,Ui=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},Fi=e=>!Ui(e.target),vr=({offset:e=zi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=(0,yr.useReactFlow)(),{t:r}=(0,hr.useTranslation)();(0,Nr.useEffect)(()=>{let s=i=>{if(i.ctrlKey&&i.key.toLowerCase()==="d"&&Fi(i)){i.preventDefault(),i.stopPropagation();let l=t(),c=n(),y=l.filter(x=>x.selected);if(!y.length)return;let b=new Map,g=[],E=l.some(x=>x.type==="START_EVENT"),m=y.filter(x=>x.type==="START_EVENT"),h=y;if(E&&m.length>0&&(h=y.filter(x=>x.type!=="START_EVENT"),h.length===0))return;let v=c.filter(x=>h.some(d=>d.id===x.source)&&h.some(d=>d.id===x.target)),T=h.map(x=>{var _;let d=(0,jo.v7)();b.set(x.id,d);let u=C(w({},x),{id:d,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let p=(_=x.data)==null?void 0:_.label,N=dt(p||r("bpmn.task.label.prefix"),[...l,...g]);u.data=C(w({},x.data),{label:N})}return g.push(u),u}),f=v.map(x=>C(w({},x),{id:(0,jo.v7)(),selected:!0,source:b.get(x.source)||x.source,target:b.get(x.target)||x.target}));o(x=>[...x.map(d=>C(w({},d),{selected:!1})),...T]),a(x=>[...x.map(d=>C(w({},d),{selected:!1})),...f])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[t,o,n,a,e,r])};var _r=require("@xyflow/react"),Dt=require("react");function Tr(e,t,o=5){var l,c,y,b,g,E,m,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},a=t.find(v=>v.id===e.id);if(!a||!e.position)return n;let r={left:e.position.x,right:e.position.x+((c=(l=a.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((b=(y=a.measured)==null?void 0:y.height)!=null?b:0),width:(E=(g=a.measured)==null?void 0:g.width)!=null?E:0,height:(h=(m=a.measured)==null?void 0:m.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==a.id).reduce((v,T)=>{var L,I,S,R,B,se,ue,Qe;let f={left:T.position.x,right:T.position.x+((I=(L=T.measured)==null?void 0:L.width)!=null?I:0),top:T.position.y,bottom:T.position.y+((R=(S=T.measured)==null?void 0:S.height)!=null?R:0),width:(se=(B=T.measured)==null?void 0:B.width)!=null?se:0,height:(Qe=(ue=T.measured)==null?void 0:ue.height)!=null?Qe:0},x=Math.abs(r.left-f.left);x<i&&(v.snapPosition.x=f.left,v.vertical=f.left,i=x);let d=Math.abs(r.right-f.right);d<i&&(v.snapPosition.x=f.right-r.width,v.vertical=f.right,i=d);let u=Math.abs(r.left-f.right);u<i&&(v.snapPosition.x=f.right,v.vertical=f.right,i=u);let _=Math.abs(r.right-f.left);_<i&&(v.snapPosition.x=f.left-r.width,v.vertical=f.left,i=_);let p=Math.abs(r.top-f.top);p<s&&(v.snapPosition.y=f.top,v.horizontal=f.top,s=p);let N=Math.abs(r.bottom-f.top);N<s&&(v.snapPosition.y=f.top-r.height,v.horizontal=f.top,s=N);let A=Math.abs(r.bottom-f.bottom);A<s&&(v.snapPosition.y=f.bottom-r.height,v.horizontal=f.bottom,s=A);let P=Math.abs(r.top-f.bottom);return P<s&&(v.snapPosition.y=f.bottom,v.horizontal=f.bottom,s=P),v},n)}var wr=()=>{let[e,t]=(0,Dt.useState)(void 0),[o,n]=(0,Dt.useState)(void 0),a=(0,Dt.useCallback)((r,s)=>{var i,l;if(t(void 0),n(void 0),r.length===1&&r[0].type==="position"&&r[0].dragging&&r[0].position){let c=Tr(r[0],s);r[0].position.x=(i=c.snapPosition.x)!=null?i:r[0].position.x,r[0].position.y=(l=c.snapPosition.y)!=null?l:r[0].position.y,t(c.horizontal),n(c.vertical)}return(0,_r.applyNodeChanges)(r,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:a}};var Sr=require("@xyflow/react"),Jo=require("uuid");var Cr={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ar={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},xr=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],a=e.match(/(\{.*?\})/)||[],r=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],"")),a.length&&(s="gateway-exclusive",i=a[1].replace(/\{|\}/g,""),e=e.replace(a[1],"")),r.length&&(l=r[1].replace(/(\||--)/g,""),e=e.replace(r[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},Wi=e=>{e=e||"";let t=e.trim().split(`
|
|
1
|
+
"use strict";var vi=Object.create;var Nt=Object.defineProperty,Ti=Object.defineProperties,_i=Object.getOwnPropertyDescriptor,wi=Object.getOwnPropertyDescriptors,xi=Object.getOwnPropertyNames,Kt=Object.getOwnPropertySymbols,Ci=Object.getPrototypeOf,Bo=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable;var bn=(e,t,o)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))Bo.call(t,o)&&bn(e,o,t[o]);if(Kt)for(var o of Kt(t))yn.call(t,o)&&bn(e,o,t[o]);return e},C=(e,t)=>Ti(e,wi(t));var ke=(e,t)=>{var o={};for(var n in e)Bo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Kt)for(var n of Kt(e))t.indexOf(n)<0&&yn.call(e,n)&&(o[n]=e[n]);return o};var Ai=(e,t)=>{for(var o in t)Nt(e,o,{get:t[o],enumerable:!0})},hn=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of xi(t))!Bo.call(e,a)&&a!==o&&Nt(e,a,{get:()=>t[a],enumerable:!(n=_i(t,a))||n.enumerable});return e};var Ii=(e,t,o)=>(o=e!=null?vi(Ci(e)):{},hn(t||!e||!e.__esModule?Nt(o,"default",{value:e,enumerable:!0}):o,e)),Si=e=>hn(Nt({},"__esModule",{value:!0}),e);var fs={};Ai(fs,{ActivityVariant:()=>Zt,ComplexVariant:()=>Xt,ElementType:()=>vt,ExclusiveVariant:()=>jt,GatewayVariant:()=>ye,Modeler:()=>gs,RoutingVariant:()=>qt,useSelectionUtils:()=>mt});module.exports=Si(fs);var Yt=require("lecom-ui"),$t=require("react/jsx-runtime");function Nn({children:e}){return(0,$t.jsxs)(Yt.TooltipProvider,{children:[(0,$t.jsx)(Yt.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}var q=require("@xyflow/react"),dn=require("lecom-ui"),ee=require("react"),ja=require("use-debounce"),Go=require("uuid");var vt=(a=>(a.ACTIVITY="activity",a.ROUTING="routing",a.GATEWAY="gateway",a.SUB_PROCESS="sub_process",a))(vt||{}),Zt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Zt||{}),qt=(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))(qt||{}),Xt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Xt||{}),jt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(jt||{});var st=require("lucide-react");var Be=require("react/jsx-runtime"),Jt=({size:e=24,className:t})=>(0,Be.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,Be.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Be.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Be.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Be.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var zo=require("react/jsx-runtime"),tt=({size:e=24,className:t})=>(0,zo.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,zo.jsx)("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"})});var De=require("react/jsx-runtime"),Qt=({size:e=24,className:t})=>(0,De.jsxs)("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:[(0,De.jsx)("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"}),(0,De.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,De.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,De.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,De.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var ot=require("react/jsx-runtime"),nt=({size:e=24,className:t})=>(0,ot.jsxs)("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:[(0,ot.jsx)("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"}),(0,ot.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ot.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var rt=require("react/jsx-runtime"),eo=({size:e=24,className:t})=>(0,rt.jsxs)("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:[(0,rt.jsx)("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"}),(0,rt.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,rt.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var at=require("react/jsx-runtime"),vn=({size:e=24,className:t})=>(0,at.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,at.jsxs)("g",{children:[(0,at.jsx)("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"}),(0,at.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Tn=require("clsx"),_n=require("tailwind-merge");function k(...e){return(0,_n.twMerge)((0,Tn.clsx)(e))}var Tt=(e,t)=>e<t?t:e;var _t=require("react/jsx-runtime"),wn=({size:e=24,className:t})=>(0,_t.jsxs)("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:[(0,_t.jsx)("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"}),(0,_t.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var to=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,to.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,to.jsx)("g",{children:(0,to.jsx)("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"})})});var Uo=require("react/jsx-runtime"),oo=({size:e=24,className:t})=>(0,Uo.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,Uo.jsx)("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"})});var Fo=require("react/jsx-runtime"),wt=({size:e=24,className:t})=>(0,Fo.jsx)("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:(0,Fo.jsx)("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"})});var it=require("react/jsx-runtime"),Cn=({size:e=24,className:t})=>(0,it.jsxs)("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:[(0,it.jsx)("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"}),(0,it.jsx)("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"}),(0,it.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Re=require("react/jsx-runtime"),An=({size:e=24,className:t})=>(0,Re.jsxs)("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:[(0,Re.jsx)("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"}),(0,Re.jsx)("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"}),(0,Re.jsx)("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"}),(0,Re.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Re.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ze=require("react/jsx-runtime"),In=({size:e=24,className:t})=>(0,ze.jsxs)("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:[(0,ze.jsx)("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"}),(0,ze.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,ze.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ze.jsx)("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 no={SCRIPT:{icon:st.ScrollText},SUBPROCESS:{icon:st.SquarePlus}};var ro={LOOP:{icon:st.RotateCcw}},ye=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ye||{}),Wo={EXCLUSIVE:{icon:nt},PARALLEL:{icon:eo},COMPLEX:{icon:Qt}};var Sn=require("zustand"),z=(0,Sn.create)(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})}}));var At=require("@xyflow/react");var _e=require("@xyflow/react");var ge=require("@xyflow/react"),ve=require("lecom-ui"),Pn=require("lucide-react");var ao=require("react"),kn=(0,ao.createContext)(null),Ln=kn.Provider,io=()=>{let e=(0,ao.useContext)(kn);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};var Ue=require("react/jsx-runtime"),xt=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,ve.useTranslation)(),{getNode:n,getEdge:a,getNodes:r,getEdges:s}=(0,ge.useReactFlow)(),{onConfigureElement:i}=io(),l=d=>{var u,_,p,N,A;return d?d.type==="TASK"&&((u=d.data)==null?void 0:u.variant)==="SUBPROCESS"?{id:d.id,type:"sub_process",variant:y(d),label:(_=d.data)==null?void 0:_.label}:d.type==="GATEWAY"?{id:d.id,type:"gateway",variant:((p=d.data)==null?void 0:p.variant)||"EXCLUSIVE",label:(N=d.data)==null?void 0:N.label}:{id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label}:null},c=d=>{let u=r(),_=s(),p=(0,ge.getIncomers)(d,u,_);if(p.length===0)return;let N=p[0];return l(N)||void 0},y=d=>{let u=r(),_=s(),p=(0,ge.getIncomers)(d,u,_),N=(0,ge.getOutgoers)(d,u,_),A=p.some(L=>L.type==="START_EVENT"),P=N.some(L=>L.type==="END_EVENT");return A?"start":P?"end":"between"},b=d=>{var L,I,S,R;let u=r(),_=s(),p=n(d.source),N=n(d.target);if(!p||!N)return"simple";if((0,ge.getOutgoers)(p,u,_).some(B=>B.type==="END_EVENT"))return"final";if(p.type==="GATEWAY")switch((L=p.data)==null?void 0:L.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(p.type==="TASK"){let B=(I=p.data)==null?void 0:I.variant,se=(S=p.data)==null?void 0:S.attribute;return N.type==="TASK"&&((R=N.data)==null?void 0:R.variant)==="SUBPROCESS"?"to_sub_process":B==="SCRIPT"?"script":se==="LOOP"?"loop":"simple"}return"simple"},g=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="COMPLEX")return;let _=r(),p=s(),N=(0,ge.getIncomers)(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A&&P)return"script_loop";if(A)return"script";if(P)return"loop"},E=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="EXCLUSIVE")return;let _=r(),p=s(),N=(0,ge.getIncomers)(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A&&P)return"script_loop";if(A)return"script";if(P)return"loop"},m=d=>{var P,L;if(d.type!=="GATEWAY")return;let u=r(),_=s(),p=(0,ge.getIncomers)(d,u,_),N=!1,A=!1;if(p.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(N=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(A=!0))}),((P=d.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}else if(((L=d.data)==null?void 0:L.variant)==="EXCLUSIVE"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}},h=d=>(0,ge.getOutgoers)(d,r(),s()).map(p=>{var N,A;return{id:p.id,type:p.type,variant:(N=p.data)==null?void 0:N.variant,label:(A=p.data)==null?void 0:A.label}}),v=d=>s().filter(p=>p.source===d.id).map(p=>{var N;return{id:p.id,type:"routing",variant:b(p),label:(N=p.data)==null?void 0:N.label,target:n(p.target)}}),T=()=>{var _,p,N,A,P,L;let d=n(e);if(!d)return;let u=c(d);if(d.type==="TASK"&&((_=d.data)==null?void 0:_.variant)==="SUBPROCESS"){i==null||i({id:d.id,type:"sub_process",variant:y(d),label:(p=d.data)==null?void 0:p.label,origin:u,targets:h(d),edgeTargets:v(d)}),console.log({id:d.id,type:"sub_process",variant:y(d),label:(N=d.data)==null?void 0:N.label,origin:u,targets:h(d),edgeTargets:v(d)});return}if(d.type!=="GATEWAY"){i==null||i({id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label,origin:u,targets:h(d),edgeTargets:v(d)});return}i==null||i({id:d.id,type:"gateway",variant:((P=d.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(L=d.data)==null?void 0:L.label,origin:u,subVariant:m(d),targets:h(d)})},f=()=>{let d=a(e);if(d){let u=b(d),_;u==="complex"?_=g(d):u==="exclusive"&&(_=E(d));let p=n(d.source),N=p&&l(p)||void 0;i==null||i({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)}),console.log({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)})}};return(0,Ue.jsxs)(ve.Tooltip,{children:[(0,Ue.jsx)(ve.TooltipTrigger,{asChild:!0,children:(0,Ue.jsx)(ve.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":T();break;case"edge":f();break}},children:(0,Ue.jsx)(Pn.Settings,{size:16})})}),(0,Ue.jsx)(ve.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var Dn=require("@xyflow/react"),Te=require("lecom-ui"),Rn=require("lucide-react"),We=require("react/jsx-runtime"),so=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Te.useTranslation)(),{deleteElements:n}=(0,Dn.useReactFlow)();return(0,We.jsxs)(Te.Tooltip,{children:[(0,We.jsx)(Te.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(Te.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:(0,We.jsx)(Rn.TrashIcon,{size:16})})}),(0,We.jsx)(Te.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var Ct=require("react/jsx-runtime"),lt=n=>{var a=n,{edgeId:e,edgeType:t}=a,o=ke(a,["edgeId","edgeType"]);var i;let r=[{component:(0,Ct.jsx)(so,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:(0,Ct.jsx)(xt,{elementId:e,elementType:"edge"})},...r],MESSAGE_EDGE:[...r],ANNOTATION_EDGE:[...r]};return(0,Ct.jsx)("div",C(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)=>(0,Ct.jsx)("div",{children:l.component},c))}))};var Ke=require("react/jsx-runtime"),co={type:"ANNOTATION_EDGE",zIndex:2e3},Vn=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,selected:i,data:l})=>{let c=(0,_e.useNodes)(),{zoom:y}=(0,_e.useViewport)(),{isMultipleSelection:b}=z(),g=c.find(x=>x.id===t),E=c.find(x=>x.id===o),[m,h,v]=(0,_e.getStraightPath)({sourceX:n,sourceY:a,targetX:r,targetY:s}),T=i||(g==null?void 0:g.selected)||(E==null?void 0:E.selected),f=1/y;return(0,Ke.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":T}),children:[(0,Ke.jsx)(_e.BaseEdge,{id:e,path:m,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)]":T&&!(l!=null&&l.hasError)})}),(0,Ke.jsx)(_e.EdgeLabelRenderer,{children:(0,Ke.jsx)("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&&!b&&(0,Ke.jsx)(lt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${f})`}})})})]})};var te=require("@xyflow/react"),Mn=require("react");var Ye=require("react");var Yo=require("react/jsx-runtime"),X=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:a,className:r,style:s})=>{let i=(0,Ye.useRef)(null),[l,c]=(0,Ye.useState)(!1);(0,Ye.useEffect)(()=>{c(n!=null?n:!1)},[n]),(0,Ye.useEffect)(()=>{if(l&&i.current){i.current.focus();let m=document.createRange();m.selectNodeContents(i.current),m.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(m))}},[l]);let y=m=>{if(m.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))},b=m=>{let h=m.currentTarget.innerText.trim(),v=t&&h.length>=t,T=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],f=m.ctrlKey||m.metaKey,x=f&&m.key==="a",d=f&&m.key==="c",u=f&&m.key==="x",_=f&&m.key==="v";function p(A){return/\w/.test(A)}if(h.length===0&&!p(m.key)&&!T.includes(m.key)&&!f){m.preventDefault();return}v&&(T.includes(m.key)||x||d||u||_||m.preventDefault())},g=m=>{if(!t)return;m.preventDefault();let h=m.clipboardData.getData("text/plain"),v=m.currentTarget.innerText,T=window.getSelection();if(!T||T.rangeCount===0)return;let f=T.getRangeAt(0);if((v.substring(0,f.startOffset)+h+v.substring(f.endOffset)).length>t){let d=t-(v.length-(f.endOffset-f.startOffset)),u=h.substring(0,Math.max(0,d));u&&(f.deleteContents(),f.insertNode(document.createTextNode(u)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f))}else f.deleteContents(),f.insertNode(document.createTextNode(h)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f)},E=m=>{c(!1);let h=m.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),m.currentTarget.innerText=h,a==null||a(),h!==e&&(o==null||o(h))};return(0,Yo.jsx)("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",r,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:y,children:(0,Yo.jsx)("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:b,onPaste:g,onBlur:E,children:e})})};var Ve=require("react/jsx-runtime"),we={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:te.MarkerType.ArrowClosed},markerEnd:{type:te.MarkerType.Arrow},data:{label:""}},On=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=(0,te.useNodes)(),{zoom:g}=(0,te.useViewport)(),{updateEdgeData:E}=(0,te.useReactFlow)(),{isMultipleSelection:m}=z(),[h,v]=(0,Mn.useState)(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=(0,te.getSmoothStepPath)({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return(0,Ve.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[(0,Ve.jsx)(te.BaseEdge,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),(0,Ve.jsx)(te.EdgeLabelRenderer,{children:(0,Ve.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&&(0,Ve.jsx)(lt,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${A})`}}),N&&(0,Ve.jsx)(X,{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:I})]})})]})};var po=e=>e.some(t=>t.type==="START_EVENT"),uo=(e,t,o)=>{var r;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((r=n.data)==null?void 0:r.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},mo=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},go=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},fo=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.target===e).some(r=>{let s=t.find(i=>i.id===r.source);return(s==null?void 0:s.type)==="START_EVENT"})},Eo=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.source===e).some(r=>{let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)==="END_EVENT"})},bo=(e,t)=>t.filter(n=>n.source===e).length>0,yo=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>{if(r.source!==e)return!1;let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)!=="ANNOTATION"}).length>=2};var ki=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!uo(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!yo(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:!(mo(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(go(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(fo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(Eo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(bo(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"})],Gn=e=>{for(let t of ki){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Li=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:uo(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:po(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:mo(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:go(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Eo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bo(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:yo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Hn=e=>{let t=Li.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),a=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&a});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Bn=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=(0,At.useReactFlow)();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 Gn(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?(0,At.addEdge)(w(w({},s),co),i):(0,At.addEdge)(w(w({},s),we),i)})}}};var $o=require("react"),qn=require("lecom-ui"),Xn=require("@xyflow/react");var It=(e=[])=>e.filter(t=>t.type==="START_EVENT"),$e=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Me=(e=[])=>e.filter(t=>t.type==="TASK")||[],zn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Un=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),ho=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Fn=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),le=(e,t=[])=>t.filter(o=>o.source===e),St=(e,t=[])=>t.filter(o=>o.target===e),Wn=(e,t)=>{var n,a;let o=(n=t.nodes)==null?void 0:n.find(r=>r.id===e);return((a=o==null?void 0:o.properties)==null?void 0:a.attribute)==="LOOP"},Kn=(e,t)=>{let o=le(e,t.edges||[]);for(let n of o){let a=(t.nodes||[]).find(r=>r.id===n.target);if(a&&a.type==="END_EVENT")return!0}return!1},Yn=e=>e?/\w/g.test(e.trim()):!1,O=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:[]}},xe=(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)}},$n=(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 kt=[{id:"start_event_not_found",validate:e=>{let t=It(e.nodes);return O({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=$e(e.nodes);return O({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=It(e.nodes),o=t.length===1;if(t.length===0)return O({isValid:!0});if(!o)return O({isValid:!1,nodeIds:t.map(r=>r.id)});let n=le(t[0].id,e.edges);if(!(n.length<=1)){let r=[...t.map(s=>s.id),...n.map(s=>s.target)];return O({isValid:!1,nodeIds:[...new Set(r)]})}return O({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Me(e.nodes),o=xe(t,n=>le(n.id,e.edges).length<=2);return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Me(e.nodes),o=xe(t,n=>!!n.label&&n.label.trim()!=="");return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Me(e.nodes),n=xe(o,a=>!a.label||a.label.length<=60);return O({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Me(e.nodes),o=new Map;for(let a of t){if(!a.label)continue;let r=a.label.trim();r&&(o.has(r)||o.set(r,[]),o.get(r).push(a))}let n=[];for(let[,a]of o.entries())a.length>1&&a.forEach(r=>n.push(r.id));return O({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...It(e.nodes),...$e(e.nodes)],o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=$e(e.nodes),o=[],n=[];for(let a of t){let r=St(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=le(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return O({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Fn(e.nodes),o=xe(t,a=>le(a.id,e.edges).length<=2),n=o.invalidIds.flatMap(a=>le(a,e.edges).map(r=>r.id));return O({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Me(e.nodes),o=xe(t,n=>!n.label||Yn(n.label));return O({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 O({isValid:!0});let t=$e(e.nodes)[0];if(!t)return O({isValid:!0});let o=St(t.id,e.edges);if(!o.length)return O({isValid:!0});let a=Me(e.nodes).filter(l=>o.some(c=>c.source===l.id)),r=xe(a,l=>!Wn(l.id,e));return O({isValid:r.isValid,nodeIds:r.isValid?[]:[t.id,...r.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Me(e.nodes),o=$e(e.nodes)[0];if(!o)return O({isValid:!0});let n=t.filter(l=>{let c=St(l.id,e.edges),y=le(l.id,e.edges),b=c.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.source))==null?void 0:m.type)==="START_EVENT"}),g=y.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.target))==null?void 0:m.type)==="END_EVENT"});return b&&g}),a=St(o.id,e.edges),r=a.length>1,s=a.map(l=>l.source),i={isValid:n.length===0&&!r,nodeIds:[...n.map(l=>l.id),...r?s:[]]};return O(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=ho(e.nodes),o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=ho(e.nodes),o=xe(t,n=>le(n.id,e.edges).length>=1);return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...It(e.nodes),...$e(e.nodes)],o=[],n=[];for(let a of t){let r=le(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return O({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=zn(e.nodes),o=xe(t,n=>!Kn(n.id,e));return O({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Un(e.nodes),o=xe(t,n=>{var a,r;return((a=n.properties)==null?void 0:a.subprocessRef)!==void 0&&((r=n.properties)==null?void 0:r.subprocessRef)!==""});return O({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Zn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of kt){let a=n.validate(e);a.isValid||t.push({id:n.id,message:n.id,nodeIds:a.nodeIds||[],edgeIds:a.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var jn=()=>{let{t:e}=(0,qn.useTranslation)(),[t,o]=(0,$o.useState)(null),{setNodes:n,setEdges:a,getNodes:r,getEdges:s}=(0,Xn.useReactFlow)(),[i,l]=(0,$o.useState)(!1);return{validationResult:t,validateDiagram:g=>{let E=$n(g.nodes,g.edges),m=Zn(E),h=m.errors.map(v=>C(w({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:m.isValid,errors:h}},handleValidationComplete:g=>{if(o(g),!g)return;let E=[],m=[];g.errors.forEach(p=>{p.nodeIds&&p.nodeIds.length>0&&p.nodeIds.forEach(N=>E.push(N)),p.edgeIds&&p.edgeIds.length>0&&p.edgeIds.forEach(N=>m.push(N))});let h=[...new Set(E)];n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})}))),a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})})));let v=r(),T=s(),f=new Set(h),x=new Set;g.errors.forEach(p=>{var P,L;let N=kt.find(I=>I.id===p.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=p.edgeIds)==null||P.forEach(I=>x.add(I)),(L=p.nodeIds)==null||L.forEach(I=>{T.forEach(S=>{(S.source===I||S.target===I)&&x.add(S.id)})}))});let d=new Set,u=new Set,_=new Set;v.forEach(p=>{p.type==="START_EVENT"?d.add(p.id):p.type==="END_EVENT"&&u.add(p.id)}),T.forEach(p=>{d.has(p.source)&&_.add(p.target),u.has(p.target)&&_.add(p.source)}),_.forEach(p=>{var N,A;if(f.has(p)){let P=(N=g.errors.find(I=>{var S;return(S=I.nodeIds)==null?void 0:S.includes(p)}))==null?void 0:N.id;((A=kt.find(I=>I.id===P))==null?void 0:A.highlightRelatedEdges)!==!1&&T.forEach(I=>{I.source===p&&u.has(I.target)&&(f.add(I.target),x.add(I.id)),I.target===p&&d.has(I.source)&&(f.add(I.source),x.add(I.id))})}}),f.size>0&&n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:f.has(N.id)})}))),x.size>0&&a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})}))),a(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})})))},isAutoValidationEnabled:i}};var er=require("@xyflow/react"),tr=require("lecom-ui"),or=require("react"),Zo=require("uuid");var No=(e,t)=>{let n=e.filter(r=>r.type==="TASK").map(r=>{var i;let s=(i=r.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(r=>r>0),a=n.length>0?Math.max(...n)+1:1;return`${t} ${a}`},dt=(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 a=e.replace(/\s+\(\d+\)$/,""),r=n.filter(i=>i===a||i.startsWith(`${a} (`)).map(i=>{if(i===a)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;r.includes(s);)s++;return`${a} (${s})`};var Pi=15,Jn="bpmn:selection",Di=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},Qn=e=>{if(!Di(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},nr=({offset:e=Pi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=(0,er.useReactFlow)(),{t:r}=(0,tr.useTranslation)();(0,or.useEffect)(()=>{let s=l=>{var h,v;if(!Qn(l))return;let c=t(),y=n(),b=c.filter(T=>T.selected);if(!b.length)return;l.preventDefault(),l.stopPropagation();let g=y.filter(T=>b.some(f=>f.id===T.source)&&b.some(f=>f.id===T.target)),m=JSON.stringify({nodes:b,edges:g});(h=l.clipboardData)==null||h.setData(Jn,m),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${b.length} nodes`)},i=l=>{var x,d;if(!Qn(l))return;let c=(x=l.clipboardData)==null?void 0:x.getData(Jn);if(!c)return;l.preventDefault(),l.stopPropagation();let y;try{y=JSON.parse(c)}catch(u){return}if(!((d=y.nodes)!=null&&d.length))return;let b=new Map,g=t(),E=[],m=g.some(u=>u.type==="START_EVENT"),h=y.nodes.filter(u=>u.type==="START_EVENT"),v=y.nodes;if(m&&h.length>0&&(v=y.nodes.filter(u=>u.type!=="START_EVENT"),v.length===0))return;let T=v.map(u=>{var N;let _=(0,Zo.v7)();b.set(u.id,_);let p=C(w({},u),{id:_,selected:!0,position:{x:u.position.x+e,y:u.position.y+e}});if(u.type==="TASK"){let A=(N=u.data)==null?void 0:N.label,P=dt(A||r("bpmn.task.label.prefix"),[...g,...E]);p.data=C(w({},u.data),{label:P})}return E.push(p),p}),f=y.edges.map(u=>C(w({},u),{id:(0,Zo.v7)(),selected:!0,source:b.get(u.source)||u.source,target:b.get(u.target)||u.target}));o(u=>[...u.map(_=>C(w({},_),{selected:!1})),...T]),a(u=>[...u.map(_=>C(w({},_),{selected:!1})),...f])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,a,e,r])};var wo=require("@xyflow/react"),Er=require("lecom-ui"),Xo=require("uuid");var Ri={MIN_WIDTH:36,MIN_HEIGHT:36},Vi={MIN_WIDTH:36,MIN_HEIGHT:36},Mi={MIN_WIDTH:56,MIN_HEIGHT:56},vo={MIN_WIDTH:176,MIN_HEIGHT:96},To={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},oe={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},_o={MIN_WIDTH:176,MIN_HEIGHT:64},Oi={MIN_WIDTH:128,MIN_HEIGHT:64},Y={START_EVENT:Ri,END_EVENT:Vi,GATEWAY:Mi,TASK:vo,LANE:oe,ANNOTATION:_o,UNSUPPORTED:Oi};var qo=Ii(require("@dagrejs/dagre"),1),sr=require("@xyflow/react"),lr=require("lodash");var rr=require("lodash");var Le=e=>{var t,o,n,a,r,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(a=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?a:0,w:(s=(r=e.measured)==null?void 0:r.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},Ze=e=>(0,rr.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ar=(e,t)=>{let{x:o,y:n}=Le(e),{x:a,y:r}=Le(t);return{x:o-a,y:n-r}};var ct=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(a=>a.parentId===e&&(!o.length||o.includes(a.type))&&!n.includes(a.type)),Gi=(e,t)=>{let{x:o,y:n}=Le(e),{x:a,y:r}=Le(t),s=o-a,i=n-r;return Math.sqrt(s*s+i*i)},Hi=(e,t)=>{let{x:o,y:n,w:a,h:r}=Le(e),{x:s,y:i,w:l,h:c}=Le(t);return o<s+l&&s<o+a&&n<i+c&&i<n+r},Lt=(e,t)=>{let o=null,n=1/0;for(let a of t)if(a.id!==e.id&&Hi(e,a)){let r=Gi(e,a);r<n&&(n=r,o=a)}return o},ir=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var a,r;return Math.max(o,(r=(a=n.measured)==null?void 0:a.width)!=null?r:0)},0);var dr=(e=[],t=[],o="LR")=>{let n=new qo.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:r,width:s,height:i})=>n.setNode(r,{width:s,height:i})),t.forEach(r=>n.setEdge(r.source,r.target)),qo.default.layout(n),{nodes:e.map(r=>{let s=n.node(r.id);return C(w({},r),{position:{x:s.x-r.width/2,y:s.y-r.height/2}})}),edges:t}},qe=(e,t)=>{var g,E;let o=[...t],n=o.find(m=>m.id===e);if(!n)return o;let a=o.filter(m=>m.parentId===e&&m.type==="LANE");if(a.length===0)return o;let r=(0,lr.orderBy)(a,["position.y"]),s=Math.max((E=(g=n.measured)==null?void 0:g.width)!=null?E:0,To.MIN_WIDTH),i=ir(e,r)||oe.MIN_WIDTH,l=Math.max(s,i),c=0,y=0;r.forEach(m=>{var h,v,T,f;o=o.map(x=>x.id===m.id?C(w({},x),{width:l-oe.HEADER_WIDTH,measured:C(w({},x.measured),{width:l-oe.HEADER_WIDTH}),position:{x:oe.HEADER_WIDTH,y:c}}):x),c+=(v=(h=m.measured)==null?void 0:h.height)!=null?v:0,y+=(f=(T=m.measured)==null?void 0:T.height)!=null?f:0}),o=o.map(m=>m.id===e?C(w({},m),{height:y,width:l,measured:C(w({},m.measured),{height:y,width:l})}):m);let b=o.find(m=>m.id===e);return b!=null&&b.parentId&&(o=qe(b.parentId,o)),o},cr=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Bi=50,pr=(e,t=Bi)=>{let o=(0,sr.getNodesBounds)(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var ur=require("zustand"),pt=(0,ur.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var re=require("@xyflow/react"),mr=require("react");var Oe=require("react/jsx-runtime"),Od={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:re.MarkerType.Arrow},data:{label:""}},gr=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=(0,re.useNodes)(),{zoom:g}=(0,re.useViewport)(),{updateEdgeData:E}=(0,re.useReactFlow)(),{isMultipleSelection:m}=z(),[h,v]=(0,mr.useState)(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=(0,re.getSmoothStepPath)({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return(0,Oe.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[(0,Oe.jsx)(re.BaseEdge,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),(0,Oe.jsx)(re.EdgeLabelRenderer,{children:(0,Oe.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&&(0,Oe.jsx)(lt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${A})`}}),N&&(0,Oe.jsx)(X,{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:I})]})})]})};var Pt=require("react/jsx-runtime"),fr=({fromX:e,fromY:t,toX:o,toY:n})=>(0,Pt.jsxs)("g",{children:[(0,Pt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),(0,Pt.jsx)("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var br=({nodes:e,setNodes:t,setEdges:o})=>{let n=(0,wo.useStoreApi)(),{draggableNode:a,setDraggableNode:r}=pt(),{getInternalNode:s,screenToFlowPosition:i}=(0,wo.useReactFlow)(),{t:l}=(0,Er.useTranslation)(),c=d=>{let u="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(_=>_.map(p=>C(w({},p),{className:p.id===d?u:""})))},y=()=>{let{nodeLookup:d}=n.getState();return Array.from(d.values())},b=d=>{let u=s(d.id),_=y();if(d.type==="LANE"){if(ct({parentId:d.id,nodes:e,includeTypes:["LANE"]})){c();return}let I=_.filter(B=>B.id!==d.id&&B.type==="LANE"&&!B.parentId),S=Lt(u,I);if(!S){c();return}if(ct({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(S.id);return}let N=_.filter(L=>L.id!==d.id&&L.type==="LANE"),A=Lt(u,N);if(!A){c();return}if(ct({parentId:A.id,nodes:e,includeTypes:["LANE"]})){c();return}c(A.id)},g=d=>d.map(u=>C(w({},u),{className:void 0})),E=d=>d.some(_=>_.dragging)?d.map(_=>_.dragging?C(w({},_),{dragging:!1}):_):d,m=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move"},h=(d,u)=>{d.preventDefault(),b(u)},v=(d,u,_)=>{var L,I;let p=[..._];if(d.parentId===u.id)return p=qe(u.id,p),g(p);if(d.type==="LANE"){if(ct({parentId:u.id,nodes:p,excludeTypes:["LANE"]}))return p;let B=p.filter(ue=>ue.parentId===u.id).reduce((ue,Qe)=>{var zt,Ut;return ue+((Ut=(zt=Qe.measured)==null?void 0:zt.height)!=null?Ut:0)},0),se={x:oe.HEADER_WIDTH,y:B};return p=p.map(ue=>ue.id===d.id?C(w({},ue),{parentId:u.id,position:se,className:void 0}):C(w({},ue),{className:void 0})),p=qe(u.id,p),p}if(ct({parentId:u.id,nodes:p,includeTypes:["LANE"]})){let S;if(d.parentId){let R=s(d.parentId),{x:B,y:se}=Le(R);S={x:B+((L=d.position.x)!=null?L:0),y:se+((I=d.position.y)!=null?I:0)}}return p=p.map(R=>R.id===d.id?C(w({},R),{position:S!=null?S:R.position,parentId:void 0,className:void 0}):C(w({},R),{className:void 0})),p}let P=ar(d,u);return p=p.map(S=>S.id===d.id?C(w({},S),{parentId:u.id,position:P,className:void 0}):C(w({},S),{className:void 0})),p},T=d=>{if(d.preventDefault(),!(a!=null&&a.type))return;let u=i({x:d.clientX,y:d.clientY}),_={width:Y[a.type].MIN_WIDTH,height:Y[a.type].MIN_HEIGHT},p={id:(0,Xo.v7)(),type:a.type,position:u,measured:_,data:{label:a.type==="TASK"?No(e,l("bpmn.task.label.prefix")):"",variant:a.variant,attribute:a.attribute}},N=C(w({},p),{internals:{positionAbsolute:u}}),A=y(),P=a.type==="LANE",L=A.filter(B=>P?B.type==="LANE"&&!B.parentId:B.type==="LANE"),I=Lt(N,L),S=[...e,p];I&&(S=v(N,I,S)),t(Ze(S));let R=d.dataTransfer.getData("sourceId");if(R){let B={id:(0,Xo.v7)(),source:R,target:p.id};if(a.type==="ANNOTATION"){o(se=>se.concat(w(w({},B),co)));return}o(se=>se.concat(w(w({},B),we)))}r(null)},f=async(d,u,_)=>{let p=[...e];_.forEach(N=>{let A=y(),P=s(N.id),L=N.type==="LANE",I=A.filter(R=>R.id!==N.id&&(L?R.type==="LANE"&&!R.parentId:R.type==="LANE")),S=Lt(P,I);if(S){p=v(P,S,p);return}N.parentId&&(p=x(N,p))}),p=E(p),t(Ze(p))},x=(d,u)=>{var P,L;let _=s(d.parentId),{x:p,y:N}=Le(_),A={x:p+((P=d.position.x)!=null?P:0),y:N+((L=d.position.y)!=null?L:0)};return u=u.map(I=>I.id===d.id?C(w({},I),{position:A,parentId:void 0}):I),u=qe(d.parentId,u),u};return{onDragOver:m,onDrop:T,onNodeDrag:h,onNodeDragStop:f}};var yr=require("@xyflow/react"),hr=require("lecom-ui"),Nr=require("react"),jo=require("uuid");var zi=30,Ui=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},Fi=e=>!Ui(e.target),vr=({offset:e=zi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=(0,yr.useReactFlow)(),{t:r}=(0,hr.useTranslation)();(0,Nr.useEffect)(()=>{let s=i=>{if(i.ctrlKey&&i.key.toLowerCase()==="d"&&Fi(i)){i.preventDefault(),i.stopPropagation();let l=t(),c=n(),y=l.filter(x=>x.selected);if(!y.length)return;let b=new Map,g=[],E=l.some(x=>x.type==="START_EVENT"),m=y.filter(x=>x.type==="START_EVENT"),h=y;if(E&&m.length>0&&(h=y.filter(x=>x.type!=="START_EVENT"),h.length===0))return;let v=c.filter(x=>h.some(d=>d.id===x.source)&&h.some(d=>d.id===x.target)),T=h.map(x=>{var _;let d=(0,jo.v7)();b.set(x.id,d);let u=C(w({},x),{id:d,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let p=(_=x.data)==null?void 0:_.label,N=dt(p||r("bpmn.task.label.prefix"),[...l,...g]);u.data=C(w({},x.data),{label:N})}return g.push(u),u}),f=v.map(x=>C(w({},x),{id:(0,jo.v7)(),selected:!0,source:b.get(x.source)||x.source,target:b.get(x.target)||x.target}));o(x=>[...x.map(d=>C(w({},d),{selected:!1})),...T]),a(x=>[...x.map(d=>C(w({},d),{selected:!1})),...f])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[t,o,n,a,e,r])};var _r=require("@xyflow/react"),Dt=require("react");function Tr(e,t,o=5){var l,c,y,b,g,E,m,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},a=t.find(v=>v.id===e.id);if(!a||!e.position)return n;let r={left:e.position.x,right:e.position.x+((c=(l=a.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((b=(y=a.measured)==null?void 0:y.height)!=null?b:0),width:(E=(g=a.measured)==null?void 0:g.width)!=null?E:0,height:(h=(m=a.measured)==null?void 0:m.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==a.id).reduce((v,T)=>{var L,I,S,R,B,se,ue,Qe;let f={left:T.position.x,right:T.position.x+((I=(L=T.measured)==null?void 0:L.width)!=null?I:0),top:T.position.y,bottom:T.position.y+((R=(S=T.measured)==null?void 0:S.height)!=null?R:0),width:(se=(B=T.measured)==null?void 0:B.width)!=null?se:0,height:(Qe=(ue=T.measured)==null?void 0:ue.height)!=null?Qe:0},x=Math.abs(r.left-f.left);x<i&&(v.snapPosition.x=f.left,v.vertical=f.left,i=x);let d=Math.abs(r.right-f.right);d<i&&(v.snapPosition.x=f.right-r.width,v.vertical=f.right,i=d);let u=Math.abs(r.left-f.right);u<i&&(v.snapPosition.x=f.right,v.vertical=f.right,i=u);let _=Math.abs(r.right-f.left);_<i&&(v.snapPosition.x=f.left-r.width,v.vertical=f.left,i=_);let p=Math.abs(r.top-f.top);p<s&&(v.snapPosition.y=f.top,v.horizontal=f.top,s=p);let N=Math.abs(r.bottom-f.top);N<s&&(v.snapPosition.y=f.top-r.height,v.horizontal=f.top,s=N);let A=Math.abs(r.bottom-f.bottom);A<s&&(v.snapPosition.y=f.bottom-r.height,v.horizontal=f.bottom,s=A);let P=Math.abs(r.top-f.bottom);return P<s&&(v.snapPosition.y=f.bottom,v.horizontal=f.bottom,s=P),v},n)}var wr=()=>{let[e,t]=(0,Dt.useState)(void 0),[o,n]=(0,Dt.useState)(void 0),a=(0,Dt.useCallback)((r,s)=>{var i,l;if(t(void 0),n(void 0),r.length===1&&r[0].type==="position"&&r[0].dragging&&r[0].position){let c=Tr(r[0],s);r[0].position.x=(i=c.snapPosition.x)!=null?i:r[0].position.x,r[0].position.y=(l=c.snapPosition.y)!=null?l:r[0].position.y,t(c.horizontal),n(c.vertical)}return(0,_r.applyNodeChanges)(r,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:a}};var Sr=require("@xyflow/react"),Jo=require("uuid");var Cr={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ar={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},xr=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],a=e.match(/(\{.*?\})/)||[],r=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],"")),a.length&&(s="gateway-exclusive",i=a[1].replace(/\{|\}/g,""),e=e.replace(a[1],"")),r.length&&(l=r[1].replace(/(\||--)/g,""),e=e.replace(r[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},Wi=e=>{e=e||"";let t=e.trim().split(`
|
|
2
2
|
`),o={},n=[];return t.forEach(a=>{a=a||"";let r=a.trim().split("-->");if(r.length!==2){console.warn("Invalid number of steps");return}let s=xr(r[0],o),i=xr(r[1],o);s&&i&&n.push({sourceId:s.step,targetId:i.step,label:s.edgeLabel||i.edgeLabel||""})}),{components:o,connections:n}},Ir=e=>{let{components:t,connections:o}=Wi(e);return{nodes:t,edges:o}};var kr=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,Sr.useReactFlow)();return{createDiagram:a=>{let{nodes:r,edges:s}=Ir(a),i=[],l=new Map;for(let[g,E]of Object.entries(r)){let m=(0,Jo.v7)(),h=Cr[E.type],v=Ar[E.type];l.set(g,m);let T=Y[h].MIN_WIDTH,f=Y[h].MIN_HEIGHT;i.push({id:m,type:h,data:{label:E.label||"",variant:v,attribute:""},position:{x:0,y:0},width:T,height:f,measured:{width:T,height:f}})}let c=[];for(let g of s){let E=C(w({},we),{id:(0,Jo.v7)(),source:l.get(g.sourceId)||g.sourceId,target:l.get(g.targetId)||g.targetId});c.push(E)}let{nodes:y,edges:b}=dr(i,c);e(y),t(b),o()}}};var xo=require("react"),Ki={origin:"*",debug:!1};function Lr(e,t=Ki){let{origin:o,debug:n}=t,a=(0,xo.useCallback)((r,s)=>{n&&console.debug("[postMessage] sending:",{type:r,payload:s}),window.parent.postMessage({type:r,payload:s},o||"*")},[o,n]);return(0,xo.useEffect)(()=>{let r=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",r),()=>window.removeEventListener("message",r)},[e,n]),{sendMessage:a}}var Pr=require("@xyflow/react");var Dr=(e,t)=>{let{getNodes:o,getEdges:n}=(0,Pr.useReactFlow)();return{selectElement:s=>{let i=o().map(c=>C(w({},c),{selected:c.id===s})),l=n().map(c=>C(w({},c),{selected:c.id===s}));return e(i),t(l),!0},isReady:()=>!0}};var Mr=require("@xyflow/react"),fe=require("react"),Or=require("use-debounce");var Rr=[{nodes:[],edges:[]}],Yi=500,Vr=100,Gr=(e=Rr)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:a}=(0,Mr.useReactFlow)(),[r,s]=(0,fe.useState)(e),[i,l]=(0,fe.useState)(0),c=r[i],y=i>0,b=i<r.length-1,g=(0,fe.useCallback)(d=>{n(r[d].nodes),a(r[d].edges)},[r,n,a]),E=(0,fe.useCallback)(()=>{if(i>0){let d=i-1;l(d),g(d)}},[i,g]),m=(0,fe.useCallback)(()=>{if(i<r.length-1){let d=i+1;l(d),g(d)}},[r,i,g]),h=d=>{let _=[...r.slice(0,i+1),d],p=_.length>Vr?_.slice(_.length-Vr):_;s(p),l(p.length-1)},v=(0,Or.useDebouncedCallback)(()=>{let d=t(),u=o(),_=d.map(A=>C(w({},A),{selected:!1,className:""})),p={nodes:Ze(_),edges:u};JSON.stringify(c)!==JSON.stringify(p)&&h(p)},Yi),T=(0,fe.useCallback)(d=>{if(d==="forceSave"){v();return}d.some(p=>p.type==="select")||d.some(p=>p.type==="position"&&p.dragging)||v()},[v]),f=(0,fe.useCallback)(d=>{s(d||Rr),l(0)},[]),x=(0,fe.useCallback)(()=>{s([]),l(0)},[]);return(0,fe.useEffect)(()=>{let d=u=>{(u.ctrlKey||u.metaKey)&&(u.shiftKey&&u.key.toLowerCase()==="z"?(u.preventDefault(),m()):u.key.toLowerCase()==="z"&&(u.preventDefault(),E()))};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[E,m]),{history:r,undo:E,redo:m,canUndo:y,canRedo:b,saveHistory:T,resetHistory:f,clearHistory:x}};var Qo=require("react/jsx-runtime"),en=({id:e,className:t})=>(0,Qo.jsx)("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:(0,Qo.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var ut=require("react/jsx-runtime"),Hr=()=>(0,ut.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,ut.jsxs)("defs",{children:[(0,ut.jsx)(en,{id:"sequence-edge-marker",className:"text-grey-400"}),(0,ut.jsx)(en,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var rn=require("@xyflow/react"),Z=require("lecom-ui"),ft=require("lucide-react"),Mt=require("react");var Br=require("@xyflow/react"),$i=e=>({unselectAll:e.unselectNodesAndEdges}),mt=()=>{let{unselectAll:e}=(0,Br.useStore)($i);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};var Ce=require("lecom-ui");var Rt=(f=>(f.START_EVENT="START_EVENT",f.END_EVENT="END_EVENT",f.TASK="TASK",f.SUBPROCESS="SUBPROCESS",f.GATEWAY="GATEWAY",f.LANE="LANE",f.ANNOTATION="ANNOTATION",f.CONNECTION="CONNECTION",f.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",f.ACTIVITY="ACTIVITY",f.PROCESS_INTERFACE="PROCESS_INTERFACE",f.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",f.VARIANT_ACTIVITY="VARIANT_ACTIVITY",f.AUTO_ACTIVITY="AUTO_ACTIVITY",f.DATA_STORE="DATA_STORE",f.DATA_OBJECT="DATA_OBJECT",f.DATA_OUTPUT="DATA_OUTPUT",f.DATA_INPUT="DATA_INPUT",f))(Rt||{});var Qr=require("@xyflow/react"),gt=require("lecom-ui");var zr=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=a=>{var r;t((r=a.target)==null?void 0:r.result)},n.onerror=a=>{var r;o((r=a.target)==null?void 0:r.error)},n.readAsText(e)});function Ur({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let a="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
|
|
3
3
|
`),r=encodeURI(a);Co(r,`${o}.csv`)}var Co=(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)};var jr=require("uuid");var tn=require("xml-js");var Zi={compact:!0,spaces:4},qi=e=>e.replaceAll(`
|
|
4
4
|
`,"
");function Fr(e,t=Zi){if(e)return JSON.parse((0,tn.xml2json)(e,C(w({},t),{attributeValueFn:qi})))}function Wr(e){return e==null?void 0:e.replaceAll("
"," ")}var $r=require("uuid");var Uc={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Kr={script:"SCRIPT",subprocess:"SUBPROCESS"},Yr={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Xe=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:a}=e,{value:r,parent:s}=n,i=Number(a._attributes.width),l=Number(a._attributes.height),c=s==="1"?void 0:s;return{id:n.id,parentId:c,type:t,data:{label:r||"",variant:o,attribute:""},position:{x:Number(a._attributes.x)||0,y:Number(a._attributes.y)||0},width:i,height:l,measured:{width:i,height:l}}},ji=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=Y.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=Y.START_EVENT.MIN_HEIGHT,{node:Xe({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ji=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=Y.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=Y.END_EVENT.MIN_HEIGHT,{node:Xe({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Qi=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Kr[t],a="imported";return["script","none"].includes(t)||(a="adapted"),e.mxGeometry._attributes.width=Tt(e.mxGeometry._attributes.width,Y.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Tt(e.mxGeometry._attributes.height,Y.TASK.MIN_HEIGHT),{node:Xe({cell:e,type:"TASK",variant:n}),status:a,originalType:o}},es=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Yr[o],a=["none","inclusive","event-based"],r="imported";return a.includes(o)&&(r="adapted"),e.mxGeometry._attributes.width=Y.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=Y.GATEWAY.MIN_HEIGHT,{node:Xe({cell:e,type:"GATEWAY",variant:n}),status:r,originalType:t}},ts=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Xe({cell:e,type:"LANE"}),status:"imported",originalType:t}},os=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Tt(e.mxGeometry._attributes.width,Y.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Tt(e.mxGeometry._attributes.height,Y.ANNOTATION.MIN_HEIGHT),{node:Xe({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Zr=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Y.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=Y.UNSUPPORTED.MIN_HEIGHT,{node:Xe({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},qr=(e,t)=>{let{source:o,target:n,value:a}=e._attributes;return C(w({},we),{id:(0,$r.v7)(),source:t.get(o)||o,target:t.get(n)||n,data:{label:a||""}})},Xr={TASK:Qi,GATEWAY:es,START_EVENT:ji,END_EVENT:Ji,LANE:ts,ANNOTATION:os};var ns=(e,t)=>{let o=e.filter(n=>n.parentId);for(let n of o){let a=t.get(n.parentId);a&&(n.parentId=a)}return e},rs=e=>{var s;let t=new Map,o=Object.values(Rt),n=e.filter(i=>{var l;return o.includes((l=i._attributes)==null?void 0:l.type)}),a=[],r=[];for(let i of n){let l=(0,jr.v7)(),{type:c}=i._attributes,y=Xr[c]||Zr;t.set((s=i._attributes)==null?void 0:s.id,l),i._attributes.id=l;let{node:b,status:g,originalType:E}=y(i);r.push(b),a.push({originalType:E,type:b.type,variant:b.data.variant,value:Wr(b.data.label),status:g})}return r=ns(r,t),{nodes:r,governanceIdToNodeIdMap:t,summary:a}},as=(e,t)=>e.filter(a=>{var r;return(r=a._attributes)==null?void 0:r.edge}).map(a=>qr(a,t)),is=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:a}=rs(t.root.mxCell),r=as(t.root.mxCell,n);return{nodes:o,edges:r,summary:a}},ss=async e=>{let t=await zr(e),o=Fr(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:a}=o.modeler||{},r=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=a==null?void 0:a.root;if(!r||!s)throw new Error("INVALID_FILE");if(!Object.keys(a.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:a}},Jr=async e=>{try{let t=await ss(e),{nodes:o,edges:n,summary:a}=is(t)||{};return{nodes:o,edges:n,summary:a}}catch(t){throw t}};var ta=require("react/jsx-runtime"),ea=()=>{let{t:e}=(0,gt.useTranslation)(),{toast:t}=(0,gt.useNotificationToast)(),{setNodes:o,setEdges:n,fitView:a}=(0,Qr.useReactFlow)(),r=i=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=i.map(y=>[y.originalType,y.value,e(`adapter.governance.report.status.${y.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,ta.jsx)(gt.Button,{size:"small",variant:"ghost",onClick:()=>Ur({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:y}=await Jr(i);if(o(g=>g.concat(l)),n(g=>g.concat(c)),a(),y.some(g=>g.status==="unsupported")){r(y);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}`)})}}}};var oa=require("lecom-ui"),na=require("react");var je=require("react/jsx-runtime"),ra=i=>{var l=i,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:a,onFilesSelected:r}=l,s=ke(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,na.useRef)(null),y=g=>{let E=g.target.files;E!=null&&E.length&&r(E),c.current&&(c.current.value="")};return(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(oa.Button,C(w({onClick:g=>{var E;(E=c.current)==null||E.click(),a==null||a(g)}},s),{children:e})),(0,je.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:y})]})};var Je=require("react/jsx-runtime"),aa=({disabled:e=!1})=>{let{t}=(0,Ce.useTranslation)(),{toast:o}=(0,Ce.useNotificationToast)(),{createDiagram:n}=ea(),a=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},r=s=>{let i=s[0];if(!i){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(i)};return(0,Je.jsxs)(Ce.Tooltip,{children:[(0,Je.jsx)(Ce.TooltipTrigger,{asChild:!0,children:(0,Je.jsx)(ra,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:a,onFilesSelected:r,children:(0,Je.jsx)(vn,{})})}),(0,Je.jsx)(Ce.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var ia=require("react/jsx-runtime"),on=({shortcut:e})=>(0,ia.jsx)("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});var V=require("lecom-ui"),Ge=require("lucide-react"),ca=require("react");var sa=require("@xyflow/react"),Vt=require("html-to-image"),Ao=require("lecom-ui"),la=require("react");var ls=3,nn="diagram",da=()=>{let{t:e}=(0,Ao.useTranslation)(),{getNodes:t}=(0,sa.useReactFlow)(),{deselectAll:o}=mt(),[n,a]=(0,la.useState)({png:!1,html:!1,print:!1}),r=()=>{let{x:y,y:b,width:g,height:E}=pr(t());return{width:g,height:E,style:{width:`${g}px`,height:`${E}px`,transform:`translate(${-y}px, ${-b}px)`}}},s=async(y,b)=>{a(C(w({},n),{[b]:!0})),await o();try{let g=cr();if(!g)throw new Error("Flow element not found");let E=r();return await y(g,E)}catch(g){(0,Ao.toast)({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(C(w({},n),{[b]:!1}))}};return{exportAsPng:async(y=nn)=>{await s(async(b,g)=>{let E=await(0,Vt.toPng)(b,C(w({},g),{backgroundColor:"#fcfcfc"}));Co(E,`${y}.png`)},"png")},exportAsHtml:async(y=nn)=>{await s(async(b,g)=>{let E=await(0,Vt.toSvg)(b,C(w({},g),{backgroundColor:"#fcfcfc"})),m=`
|
package/lib/index.d.cts
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ta=Object.defineProperty,_a=Object.defineProperties;var wa=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var Co=Object.prototype.hasOwnProperty,Ao=Object.prototype.propertyIsEnumerable;var xo=(e,t,o)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))Co.call(t,o)&&xo(e,o,t[o]);if(Xe)for(var o of Xe(t))Ao.call(t,o)&&xo(e,o,t[o]);return e},C=(e,t)=>_a(e,wa(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 xa,Notification as Ca}from"lecom-ui";import{jsx as Aa,jsxs as Ia}from"react/jsx-runtime";function Io({children:e}){return Ia(xa,{children:[Aa(Ca,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as jd,MiniMap as Jd,ReactFlow as Qd,ReactFlowProvider as ec,SelectionMode as tc,useEdgesState as oc,useNodesState as nc,useOnSelectionChange as rc,useReactFlow as ac}from"@xyflow/react";import{i18n as jr}from"lecom-ui";import{forwardRef as ic,useCallback as fo,useEffect as yo,useImperativeHandle as sc,useRef as lc,useState as dc}from"react";import{useDebouncedCallback as cc}from"use-debounce";import{v7 as Eo}from"uuid";var je=(a=>(a.ACTIVITY="activity",a.ROUTING="routing",a.GATEWAY="gateway",a.SUB_PROCESS="sub_process",a))(je||{}),Bt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Bt||{}),zt=(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))(zt||{}),Ut=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ut||{}),Ft=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Ft||{});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 Qe=({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 he=({size:e=24,className:t})=>So("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",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 ke,jsxs as ka}from"react/jsx-runtime";var et=({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:[ke("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"}),ke("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),ke("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),ke("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ke("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wt,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:[Wt("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"}),Wt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Wt("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 tt=({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 Yt,jsxs as Da}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>Yt("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:[Yt("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"}),Yt("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 Le=(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 $t}from"react/jsx-runtime";var Do=({size:e=24,className:t})=>$t("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:$t("g",{children:$t("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 ot=({size:e=24,className:t})=>Ro("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",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 Pe=({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 Zt,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:[Zt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Zt("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Zt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as De,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:[De("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"}),De("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"}),De("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"}),De("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as nt,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:[nt("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"}),nt("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),nt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),nt("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 rt={SCRIPT:{icon:za},SUBPROCESS:{icon:Ua}};var at={LOOP:{icon:Ba}},Q=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Q||{}),qt={EXCLUSIVE:{icon:Ne},PARALLEL:{icon:tt},COMPLEX:{icon:et}};import{create as Fa}from"zustand";var O=Fa(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as qo,useReactFlow as xi}from"@xyflow/react";import{BaseEdge as li,EdgeLabelRenderer as di,getStraightPath as ci,useNodes as pi,useViewport as ui}from"@xyflow/react";import{getIncomers as Re,getOutgoers as Xt,useReactFlow as Ya}from"@xyflow/react";import{Button as $a,Tooltip as Za,TooltipContent as qa,TooltipTrigger as Xa,useTranslation as ja}from"lecom-ui";import{Settings as Ja}from"lucide-react";import{createContext as Wa,useContext as Ka}from"react";var Ho=Wa(null),Bo=Ho.Provider,it=()=>{let e=Ka(Ho);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as st,jsxs as Qa}from"react/jsx-runtime";var Ve=({elementId:e,elementType:t="node"})=>{let{t:o}=ja(),{getNode:n,getEdge:a,getNodes:r,getEdges:s}=Ya(),{onConfigureElement:i}=it(),l=d=>{var u,_,p,N,A;return d?d.type==="TASK"&&((u=d.data)==null?void 0:u.variant)==="SUBPROCESS"?{id:d.id,type:"sub_process",variant:y(d),label:(_=d.data)==null?void 0:_.label}:d.type==="GATEWAY"?{id:d.id,type:"gateway",variant:((p=d.data)==null?void 0:p.variant)||"EXCLUSIVE",label:(N=d.data)==null?void 0:N.label}:{id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label}:null},c=d=>{let u=r(),_=s(),p=Re(d,u,_);if(p.length===0)return;let N=p[0];return l(N)||void 0},y=d=>{let u=r(),_=s(),p=Re(d,u,_),N=Xt(d,u,_),A=p.some(L=>L.type==="START_EVENT"),P=N.some(L=>L.type==="END_EVENT");return A?"start":P?"end":"between"},b=d=>{var L,I,S,R;let u=r(),_=s(),p=n(d.source),N=n(d.target);if(!p||!N)return"simple";if(Xt(p,u,_).some(M=>M.type==="END_EVENT"))return"final";if(p.type==="GATEWAY")switch((L=p.data)==null?void 0:L.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(p.type==="TASK"){let M=(I=p.data)==null?void 0:I.variant,Z=(S=p.data)==null?void 0:S.attribute;return N.type==="TASK"&&((R=N.data)==null?void 0:R.variant)==="SUBPROCESS"?"to_sub_process":M==="SCRIPT"?"script":Z==="LOOP"?"loop":"simple"}return"simple"},g=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="COMPLEX")return;let _=r(),p=s(),N=Re(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A&&P)return"script_loop";if(A)return"script";if(P)return"loop"},E=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="EXCLUSIVE")return;let _=r(),p=s(),N=Re(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A)return"script";if(P)return"loop"},m=d=>{var P,L;if(d.type!=="GATEWAY")return;let u=r(),_=s(),p=Re(d,u,_),N=!1,A=!1;if(p.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(N=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(A=!0))}),((P=d.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}else if(((L=d.data)==null?void 0:L.variant)==="EXCLUSIVE"){if(N)return"script";if(A)return"loop"}},h=d=>Xt(d,r(),s()).map(p=>{var N,A;return{id:p.id,type:p.type,variant:(N=p.data)==null?void 0:N.variant,label:(A=p.data)==null?void 0:A.label}}),v=d=>s().filter(p=>p.source===d.id).map(p=>{var N;return{id:p.id,type:"routing",variant:b(p),label:(N=p.data)==null?void 0:N.label,target:n(p.target)}}),T=()=>{var _,p,N,A,P,L;let d=n(e);if(!d)return;let u=c(d);if(d.type==="TASK"&&((_=d.data)==null?void 0:_.variant)==="SUBPROCESS"){i==null||i({id:d.id,type:"sub_process",variant:y(d),label:(p=d.data)==null?void 0:p.label,origin:u,targets:h(d),edgeTargets:v(d)}),console.log({id:d.id,type:"sub_process",variant:y(d),label:(N=d.data)==null?void 0:N.label,origin:u,targets:h(d),edgeTargets:v(d)});return}if(d.type!=="GATEWAY"){i==null||i({id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label,origin:u,targets:h(d),edgeTargets:v(d)});return}i==null||i({id:d.id,type:"gateway",variant:((P=d.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(L=d.data)==null?void 0:L.label,origin:u,subVariant:m(d),targets:h(d)})},f=()=>{let d=a(e);if(d){let u=b(d),_;u==="complex"?_=g(d):u==="exclusive"&&(_=E(d));let p=n(d.source),N=p&&l(p)||void 0;i==null||i({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)}),console.log({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)})}};return Qa(Za,{children:[st(Xa,{asChild:!0,children:st($a,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":T();break;case"edge":f();break}},children:st(Ja,{size:16})})}),st(qa,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as ei}from"@xyflow/react";import{Button as ti,Tooltip as oi,TooltipContent as ni,TooltipTrigger as ri,useTranslation as ai}from"lecom-ui";import{TrashIcon as ii}from"lucide-react";import{jsx as lt,jsxs as si}from"react/jsx-runtime";var dt=({elementId:e,elementType:t="node"})=>{let{t:o}=ai(),{deleteElements:n}=ei();return si(oi,{children:[lt(ri,{asChild:!0,children:lt(ti,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:lt(ii,{size:16})})}),lt(ni,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as ct}from"react/jsx-runtime";var ve=n=>{var a=n,{edgeId:e,edgeType:t}=a,o=ae(a,["edgeId","edgeType"]);var i;let r=[{component:ct(dt,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:ct(Ve,{elementId:e,elementType:"edge"})},...r],MESSAGE_EDGE:[...r],ANNOTATION_EDGE:[...r]};return ct("div",C(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)=>ct("div",{children:l.component},c))}))};import{jsx as ut,jsxs as mi}from"react/jsx-runtime";var mt={type:"ANNOTATION_EDGE",zIndex:2e3},zo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,selected:i,data:l})=>{let c=pi(),{zoom:y}=ui(),{isMultipleSelection:b}=O(),g=c.find(x=>x.id===t),E=c.find(x=>x.id===o),[m,h,v]=ci({sourceX:n,sourceY:a,targetX:r,targetY:s}),T=i||(g==null?void 0:g.selected)||(E==null?void 0:E.selected),f=1/y;return mi("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":T}),children:[ut(li,{id:e,path:m,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)]":T&&!(l!=null&&l.hasError)})}),ut(di,{children:ut("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&&!b&&ut(ve,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${f})`}})})})]})};import{BaseEdge as Ei,EdgeLabelRenderer as bi,getSmoothStepPath as yi,MarkerType as Wo,useNodes as hi,useReactFlow as Ni,useViewport as vi}from"@xyflow/react";import{useState as Ti}from"react";import{useEffect as Uo,useRef as gi,useState as fi}from"react";import{jsx as Fo}from"react/jsx-runtime";var B=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:a,className:r,style:s})=>{let i=gi(null),[l,c]=fi(!1);Uo(()=>{c(n!=null?n:!1)},[n]),Uo(()=>{if(l&&i.current){i.current.focus();let m=document.createRange();m.selectNodeContents(i.current),m.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(m))}},[l]);let y=m=>{if(m.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))},b=m=>{let h=m.currentTarget.innerText.trim(),v=t&&h.length>=t,T=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],f=m.ctrlKey||m.metaKey,x=f&&m.key==="a",d=f&&m.key==="c",u=f&&m.key==="x",_=f&&m.key==="v";function p(A){return/\w/.test(A)}if(h.length===0&&!p(m.key)&&!T.includes(m.key)&&!f){m.preventDefault();return}v&&(T.includes(m.key)||x||d||u||_||m.preventDefault())},g=m=>{if(!t)return;m.preventDefault();let h=m.clipboardData.getData("text/plain"),v=m.currentTarget.innerText,T=window.getSelection();if(!T||T.rangeCount===0)return;let f=T.getRangeAt(0);if((v.substring(0,f.startOffset)+h+v.substring(f.endOffset)).length>t){let d=t-(v.length-(f.endOffset-f.startOffset)),u=h.substring(0,Math.max(0,d));u&&(f.deleteContents(),f.insertNode(document.createTextNode(u)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f))}else f.deleteContents(),f.insertNode(document.createTextNode(h)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f)},E=m=>{c(!1);let h=m.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),m.currentTarget.innerText=h,a==null||a(),h!==e&&(o==null||o(h))};return Fo("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",r,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:y,children:Fo("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:b,onPaste:g,onBlur:E,children:e})})};import{jsx as gt,jsxs as Ko}from"react/jsx-runtime";var ee={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Wo.ArrowClosed},markerEnd:{type:Wo.Arrow},data:{label:""}},Yo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=hi(),{zoom:g}=vi(),{updateEdgeData:E}=Ni(),{isMultipleSelection:m}=O(),[h,v]=Ti(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=yi({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return Ko("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[gt(Ei,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),gt(bi,{children:Ko("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&>(ve,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${A})`}}),N&>(B,{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:I})]})})]})};var ft=e=>e.some(t=>t.type==="START_EVENT"),Et=(e,t,o)=>{var r;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((r=n.data)==null?void 0:r.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},bt=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},yt=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},ht=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.target===e).some(r=>{let s=t.find(i=>i.id===r.source);return(s==null?void 0:s.type)==="START_EVENT"})},Nt=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.source===e).some(r=>{let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)==="END_EVENT"})},vt=(e,t)=>t.filter(n=>n.source===e).length>0,Tt=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>{if(r.source!==e)return!1;let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)!=="ANNOTATION"}).length>=2};var _i=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Et(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:!(bt(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(yt(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(ht(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:!(vt(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"})],$o=e=>{for(let t of _i){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var wi=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Et(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:ft(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bt(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yt(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ht(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:vt(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"})}],Zo=e=>{let t=wi.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),a=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&a});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Xo=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=xi();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 $o(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?qo(w(w({},s),mt),i):qo(w(w({},s),ee),i)})}}};import{useState as an}from"react";import{useTranslation as Ci}from"lecom-ui";import{useReactFlow as Ai}from"@xyflow/react";var Me=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ce=(e=[])=>e.filter(t=>t.type==="END_EVENT"),se=(e=[])=>e.filter(t=>t.type==="TASK")||[],jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),_t=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Qo=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),q=(e,t=[])=>t.filter(o=>o.source===e),Oe=(e,t=[])=>t.filter(o=>o.target===e),en=(e,t)=>{var n,a;let o=(n=t.nodes)==null?void 0:n.find(r=>r.id===e);return((a=o==null?void 0:o.properties)==null?void 0:a.attribute)==="LOOP"},tn=(e,t)=>{let o=q(e,t.edges||[]);for(let n of o){let a=(t.nodes||[]).find(r=>r.id===n.target);if(a&&a.type==="END_EVENT")return!0}return!1},on=e=>e?/\w/g.test(e.trim()):!1,V=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:[]}},te=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},nn=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Ge=[{id:"start_event_not_found",validate:e=>{let t=Me(e.nodes);return V({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ce(e.nodes);return V({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Me(e.nodes),o=t.length===1;if(t.length===0)return V({isValid:!0});if(!o)return V({isValid:!1,nodeIds:t.map(r=>r.id)});let n=q(t[0].id,e.edges);if(!(n.length<=1)){let r=[...t.map(s=>s.id),...n.map(s=>s.target)];return V({isValid:!1,nodeIds:[...new Set(r)]})}return V({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=se(e.nodes),o=te(t,n=>q(n.id,e.edges).length<=2);return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=se(e.nodes),o=te(t,n=>!!n.label&&n.label.trim()!=="");return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=se(e.nodes),n=te(o,a=>!a.label||a.label.length<=60);return V({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=se(e.nodes),o=new Map;for(let a of t){if(!a.label)continue;let r=a.label.trim();r&&(o.has(r)||o.set(r,[]),o.get(r).push(a))}let n=[];for(let[,a]of o.entries())a.length>1&&a.forEach(r=>n.push(r.id));return V({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=_t(e.nodes),o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Me(e.nodes),...ce(e.nodes)],o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ce(e.nodes),o=[],n=[];for(let a of t){let r=Oe(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=q(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return V({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Qo(e.nodes),o=te(t,a=>q(a.id,e.edges).length<=2),n=o.invalidIds.flatMap(a=>q(a,e.edges).map(r=>r.id));return V({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=se(e.nodes),o=te(t,n=>!n.label||on(n.label));return V({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 V({isValid:!0});let t=ce(e.nodes)[0];if(!t)return V({isValid:!0});let o=Oe(t.id,e.edges);if(!o.length)return V({isValid:!0});let a=se(e.nodes).filter(l=>o.some(c=>c.source===l.id)),r=te(a,l=>!en(l.id,e));return V({isValid:r.isValid,nodeIds:r.isValid?[]:[t.id,...r.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=se(e.nodes),o=ce(e.nodes)[0];if(!o)return V({isValid:!0});let n=t.filter(l=>{let c=Oe(l.id,e.edges),y=q(l.id,e.edges),b=c.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.source))==null?void 0:m.type)==="START_EVENT"}),g=y.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.target))==null?void 0:m.type)==="END_EVENT"});return b&&g}),a=Oe(o.id,e.edges),r=a.length>1,s=a.map(l=>l.source),i={isValid:n.length===0&&!r,nodeIds:[...n.map(l=>l.id),...r?s:[]]};return V(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=_t(e.nodes),o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=_t(e.nodes),o=te(t,n=>q(n.id,e.edges).length>=1);return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Me(e.nodes),...ce(e.nodes)],o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=jo(e.nodes),o=te(t,n=>!tn(n.id,e));return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Jo(e.nodes),o=te(t,n=>{var a,r;return((a=n.properties)==null?void 0:a.subprocessRef)!==void 0&&((r=n.properties)==null?void 0:r.subprocessRef)!==""});return V({isValid:o.isValid,nodeIds:o.invalidIds})}}];var rn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Ge){let a=n.validate(e);a.isValid||t.push({id:n.id,message:n.id,nodeIds:a.nodeIds||[],edgeIds:a.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var sn=()=>{let{t:e}=Ci(),[t,o]=an(null),{setNodes:n,setEdges:a,getNodes:r,getEdges:s}=Ai(),[i,l]=an(!1);return{validationResult:t,validateDiagram:g=>{let E=nn(g.nodes,g.edges),m=rn(E),h=m.errors.map(v=>C(w({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:m.isValid,errors:h}},handleValidationComplete:g=>{if(o(g),!g)return;let E=[],m=[];g.errors.forEach(p=>{p.nodeIds&&p.nodeIds.length>0&&p.nodeIds.forEach(N=>E.push(N)),p.edgeIds&&p.edgeIds.length>0&&p.edgeIds.forEach(N=>m.push(N))});let h=[...new Set(E)];n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})}))),a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})})));let v=r(),T=s(),f=new Set(h),x=new Set;g.errors.forEach(p=>{var P,L;let N=Ge.find(I=>I.id===p.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=p.edgeIds)==null||P.forEach(I=>x.add(I)),(L=p.nodeIds)==null||L.forEach(I=>{T.forEach(S=>{(S.source===I||S.target===I)&&x.add(S.id)})}))});let d=new Set,u=new Set,_=new Set;v.forEach(p=>{p.type==="START_EVENT"?d.add(p.id):p.type==="END_EVENT"&&u.add(p.id)}),T.forEach(p=>{d.has(p.source)&&_.add(p.target),u.has(p.target)&&_.add(p.source)}),_.forEach(p=>{var N,A;if(f.has(p)){let P=(N=g.errors.find(I=>{var S;return(S=I.nodeIds)==null?void 0:S.includes(p)}))==null?void 0:N.id;((A=Ge.find(I=>I.id===P))==null?void 0:A.highlightRelatedEdges)!==!1&&T.forEach(I=>{I.source===p&&u.has(I.target)&&(f.add(I.target),x.add(I.id)),I.target===p&&d.has(I.source)&&(f.add(I.source),x.add(I.id))})}}),f.size>0&&n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:f.has(N.id)})}))),x.size>0&&a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})}))),a(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})})))},isAutoValidationEnabled:i}};import{useReactFlow as Ii}from"@xyflow/react";import{useTranslation as Si}from"lecom-ui";import{useEffect as ki}from"react";import{v7 as ln}from"uuid";var wt=(e,t)=>{let n=e.filter(r=>r.type==="TASK").map(r=>{var i;let s=(i=r.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(r=>r>0),a=n.length>0?Math.max(...n)+1:1;return`${t} ${a}`},Te=(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 a=e.replace(/\s+\(\d+\)$/,""),r=n.filter(i=>i===a||i.startsWith(`${a} (`)).map(i=>{if(i===a)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;r.includes(s);)s++;return`${a} (${s})`};var Li=15,dn="bpmn:selection",Pi=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},cn=e=>{if(!Pi(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},pn=({offset:e=Li}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=Ii(),{t:r}=Si();ki(()=>{let s=l=>{var h,v;if(!cn(l))return;let c=t(),y=n(),b=c.filter(T=>T.selected);if(!b.length)return;l.preventDefault(),l.stopPropagation();let g=y.filter(T=>b.some(f=>f.id===T.source)&&b.some(f=>f.id===T.target)),m=JSON.stringify({nodes:b,edges:g});(h=l.clipboardData)==null||h.setData(dn,m),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${b.length} nodes`)},i=l=>{var x,d;if(!cn(l))return;let c=(x=l.clipboardData)==null?void 0:x.getData(dn);if(!c)return;l.preventDefault(),l.stopPropagation();let y;try{y=JSON.parse(c)}catch(u){return}if(!((d=y.nodes)!=null&&d.length))return;let b=new Map,g=t(),E=[],m=g.some(u=>u.type==="START_EVENT"),h=y.nodes.filter(u=>u.type==="START_EVENT"),v=y.nodes;if(m&&h.length>0&&(v=y.nodes.filter(u=>u.type!=="START_EVENT"),v.length===0))return;let T=v.map(u=>{var N;let _=ln();b.set(u.id,_);let p=C(w({},u),{id:_,selected:!0,position:{x:u.position.x+e,y:u.position.y+e}});if(u.type==="TASK"){let A=(N=u.data)==null?void 0:N.label,P=Te(A||r("bpmn.task.label.prefix"),[...g,...E]);p.data=C(w({},u.data),{label:P})}return E.push(p),p}),f=y.edges.map(u=>C(w({},u),{id:ln(),selected:!0,source:b.get(u.source)||u.source,target:b.get(u.target)||u.target}));o(u=>[...u.map(_=>C(w({},_),{selected:!1})),...T]),a(u=>[...u.map(_=>C(w({},_),{selected:!1})),...f])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,a,e,r])};import{useReactFlow as Qi,useStoreApi as es}from"@xyflow/react";import{useTranslation as ts}from"lecom-ui";import{v7 as Tn}from"uuid";var Di={MIN_WIDTH:36,MIN_HEIGHT:36},Ri={MIN_WIDTH:36,MIN_HEIGHT:36},Vi={MIN_WIDTH:56,MIN_HEIGHT:56},xt={MIN_WIDTH:176,MIN_HEIGHT:96},Ct={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},F={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},At={MIN_WIDTH:176,MIN_HEIGHT:64},Mi={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:Di,END_EVENT:Ri,GATEWAY:Vi,TASK:xt,LANE:F,ANNOTATION:At,UNSUPPORTED:Mi};import gn from"@dagrejs/dagre";import{getNodesBounds as Bi}from"@xyflow/react";import{orderBy as zi}from"lodash";import{orderBy as Oi}from"lodash";var ie=e=>{var t,o,n,a,r,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(a=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?a:0,w:(s=(r=e.measured)==null?void 0:r.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},pe=e=>Oi(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),un=(e,t)=>{let{x:o,y:n}=ie(e),{x:a,y:r}=ie(t);return{x:o-a,y:n-r}};var _e=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(a=>a.parentId===e&&(!o.length||o.includes(a.type))&&!n.includes(a.type)),Gi=(e,t)=>{let{x:o,y:n}=ie(e),{x:a,y:r}=ie(t),s=o-a,i=n-r;return Math.sqrt(s*s+i*i)},Hi=(e,t)=>{let{x:o,y:n,w:a,h:r}=ie(e),{x:s,y:i,w:l,h:c}=ie(t);return o<s+l&&s<o+a&&n<i+c&&i<n+r},He=(e,t)=>{let o=null,n=1/0;for(let a of t)if(a.id!==e.id&&Hi(e,a)){let r=Gi(e,a);r<n&&(n=r,o=a)}return o},mn=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var a,r;return Math.max(o,(r=(a=n.measured)==null?void 0:a.width)!=null?r:0)},0);var fn=(e=[],t=[],o="LR")=>{let n=new gn.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:r,width:s,height:i})=>n.setNode(r,{width:s,height:i})),t.forEach(r=>n.setEdge(r.source,r.target)),gn.layout(n),{nodes:e.map(r=>{let s=n.node(r.id);return C(w({},r),{position:{x:s.x-r.width/2,y:s.y-r.height/2}})}),edges:t}},ue=(e,t)=>{var g,E;let o=[...t],n=o.find(m=>m.id===e);if(!n)return o;let a=o.filter(m=>m.parentId===e&&m.type==="LANE");if(a.length===0)return o;let r=zi(a,["position.y"]),s=Math.max((E=(g=n.measured)==null?void 0:g.width)!=null?E:0,Ct.MIN_WIDTH),i=mn(e,r)||F.MIN_WIDTH,l=Math.max(s,i),c=0,y=0;r.forEach(m=>{var h,v,T,f;o=o.map(x=>x.id===m.id?C(w({},x),{width:l-F.HEADER_WIDTH,measured:C(w({},x.measured),{width:l-F.HEADER_WIDTH}),position:{x:F.HEADER_WIDTH,y:c}}):x),c+=(v=(h=m.measured)==null?void 0:h.height)!=null?v:0,y+=(f=(T=m.measured)==null?void 0:T.height)!=null?f:0}),o=o.map(m=>m.id===e?C(w({},m),{height:y,width:l,measured:C(w({},m.measured),{height:y,width:l})}):m);let b=o.find(m=>m.id===e);return b!=null&&b.parentId&&(o=ue(b.parentId,o)),o},En=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Ui=50,bn=(e,t=Ui)=>{let o=Bi(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as Fi}from"zustand";var we=Fi(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Wi,EdgeLabelRenderer as Ki,getSmoothStepPath as Yi,MarkerType as $i,useNodes as Zi,useReactFlow as qi,useViewport as Xi}from"@xyflow/react";import{useState as ji}from"react";import{jsx as It,jsxs as yn}from"react/jsx-runtime";var Rm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:$i.Arrow},data:{label:""}},hn=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=Zi(),{zoom:g}=Xi(),{updateEdgeData:E}=qi(),{isMultipleSelection:m}=O(),[h,v]=ji(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=Yi({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return yn("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[It(Wi,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),It(Ki,{children:yn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&&It(ve,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${A})`}}),N&&It(B,{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:I})]})})]})};import{jsx as Nn,jsxs as Ji}from"react/jsx-runtime";var vn=({fromX:e,fromY:t,toX:o,toY:n})=>Ji("g",{children:[Nn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),Nn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var _n=({nodes:e,setNodes:t,setEdges:o})=>{let n=es(),{draggableNode:a,setDraggableNode:r}=we(),{getInternalNode:s,screenToFlowPosition:i}=Qi(),{t:l}=ts(),c=d=>{let u="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(_=>_.map(p=>C(w({},p),{className:p.id===d?u:""})))},y=()=>{let{nodeLookup:d}=n.getState();return Array.from(d.values())},b=d=>{let u=s(d.id),_=y();if(d.type==="LANE"){if(_e({parentId:d.id,nodes:e,includeTypes:["LANE"]})){c();return}let I=_.filter(M=>M.id!==d.id&&M.type==="LANE"&&!M.parentId),S=He(u,I);if(!S){c();return}if(_e({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(S.id);return}let N=_.filter(L=>L.id!==d.id&&L.type==="LANE"),A=He(u,N);if(!A){c();return}if(_e({parentId:A.id,nodes:e,includeTypes:["LANE"]})){c();return}c(A.id)},g=d=>d.map(u=>C(w({},u),{className:void 0})),E=d=>d.some(_=>_.dragging)?d.map(_=>_.dragging?C(w({},_),{dragging:!1}):_):d,m=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move"},h=(d,u)=>{d.preventDefault(),b(u)},v=(d,u,_)=>{var L,I;let p=[..._];if(d.parentId===u.id)return p=ue(u.id,p),g(p);if(d.type==="LANE"){if(_e({parentId:u.id,nodes:p,excludeTypes:["LANE"]}))return p;let M=p.filter(X=>X.parentId===u.id).reduce((X,be)=>{var Ye,$e;return X+(($e=(Ye=be.measured)==null?void 0:Ye.height)!=null?$e:0)},0),Z={x:F.HEADER_WIDTH,y:M};return p=p.map(X=>X.id===d.id?C(w({},X),{parentId:u.id,position:Z,className:void 0}):C(w({},X),{className:void 0})),p=ue(u.id,p),p}if(_e({parentId:u.id,nodes:p,includeTypes:["LANE"]})){let S;if(d.parentId){let R=s(d.parentId),{x:M,y:Z}=ie(R);S={x:M+((L=d.position.x)!=null?L:0),y:Z+((I=d.position.y)!=null?I:0)}}return p=p.map(R=>R.id===d.id?C(w({},R),{position:S!=null?S:R.position,parentId:void 0,className:void 0}):C(w({},R),{className:void 0})),p}let P=un(d,u);return p=p.map(S=>S.id===d.id?C(w({},S),{parentId:u.id,position:P,className:void 0}):C(w({},S),{className:void 0})),p},T=d=>{if(d.preventDefault(),!(a!=null&&a.type))return;let u=i({x:d.clientX,y:d.clientY}),_={width:G[a.type].MIN_WIDTH,height:G[a.type].MIN_HEIGHT},p={id:Tn(),type:a.type,position:u,measured:_,data:{label:a.type==="TASK"?wt(e,l("bpmn.task.label.prefix")):"",variant:a.variant,attribute:a.attribute}},N=C(w({},p),{internals:{positionAbsolute:u}}),A=y(),P=a.type==="LANE",L=A.filter(M=>P?M.type==="LANE"&&!M.parentId:M.type==="LANE"),I=He(N,L),S=[...e,p];I&&(S=v(N,I,S)),t(pe(S));let R=d.dataTransfer.getData("sourceId");if(R){let M={id:Tn(),source:R,target:p.id};if(a.type==="ANNOTATION"){o(Z=>Z.concat(w(w({},M),mt)));return}o(Z=>Z.concat(w(w({},M),ee)))}r(null)},f=async(d,u,_)=>{let p=[...e];_.forEach(N=>{let A=y(),P=s(N.id),L=N.type==="LANE",I=A.filter(R=>R.id!==N.id&&(L?R.type==="LANE"&&!R.parentId:R.type==="LANE")),S=He(P,I);if(S){p=v(P,S,p);return}N.parentId&&(p=x(N,p))}),p=E(p),t(pe(p))},x=(d,u)=>{var P,L;let _=s(d.parentId),{x:p,y:N}=ie(_),A={x:p+((P=d.position.x)!=null?P:0),y:N+((L=d.position.y)!=null?L:0)};return u=u.map(I=>I.id===d.id?C(w({},I),{position:A,parentId:void 0}):I),u=ue(d.parentId,u),u};return{onDragOver:m,onDrop:T,onNodeDrag:h,onNodeDragStop:f}};import{useReactFlow as os}from"@xyflow/react";import{useTranslation as ns}from"lecom-ui";import{useEffect as rs}from"react";import{v7 as wn}from"uuid";var as=30,is=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},ss=e=>!is(e.target),xn=({offset:e=as}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=os(),{t:r}=ns();rs(()=>{let s=i=>{if(i.ctrlKey&&i.key.toLowerCase()==="d"&&ss(i)){i.preventDefault(),i.stopPropagation();let l=t(),c=n(),y=l.filter(x=>x.selected);if(!y.length)return;let b=new Map,g=[],E=l.some(x=>x.type==="START_EVENT"),m=y.filter(x=>x.type==="START_EVENT"),h=y;if(E&&m.length>0&&(h=y.filter(x=>x.type!=="START_EVENT"),h.length===0))return;let v=c.filter(x=>h.some(d=>d.id===x.source)&&h.some(d=>d.id===x.target)),T=h.map(x=>{var _;let d=wn();b.set(x.id,d);let u=C(w({},x),{id:d,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let p=(_=x.data)==null?void 0:_.label,N=Te(p||r("bpmn.task.label.prefix"),[...l,...g]);u.data=C(w({},x.data),{label:N})}return g.push(u),u}),f=v.map(x=>C(w({},x),{id:wn(),selected:!0,source:b.get(x.source)||x.source,target:b.get(x.target)||x.target}));o(x=>[...x.map(d=>C(w({},d),{selected:!1})),...T]),a(x=>[...x.map(d=>C(w({},d),{selected:!1})),...f])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[t,o,n,a,e,r])};import{applyNodeChanges as ls}from"@xyflow/react";import{useCallback as ds,useState as An}from"react";function Cn(e,t,o=5){var l,c,y,b,g,E,m,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},a=t.find(v=>v.id===e.id);if(!a||!e.position)return n;let r={left:e.position.x,right:e.position.x+((c=(l=a.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((b=(y=a.measured)==null?void 0:y.height)!=null?b:0),width:(E=(g=a.measured)==null?void 0:g.width)!=null?E:0,height:(h=(m=a.measured)==null?void 0:m.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==a.id).reduce((v,T)=>{var L,I,S,R,M,Z,X,be;let f={left:T.position.x,right:T.position.x+((I=(L=T.measured)==null?void 0:L.width)!=null?I:0),top:T.position.y,bottom:T.position.y+((R=(S=T.measured)==null?void 0:S.height)!=null?R:0),width:(Z=(M=T.measured)==null?void 0:M.width)!=null?Z:0,height:(be=(X=T.measured)==null?void 0:X.height)!=null?be:0},x=Math.abs(r.left-f.left);x<i&&(v.snapPosition.x=f.left,v.vertical=f.left,i=x);let d=Math.abs(r.right-f.right);d<i&&(v.snapPosition.x=f.right-r.width,v.vertical=f.right,i=d);let u=Math.abs(r.left-f.right);u<i&&(v.snapPosition.x=f.right,v.vertical=f.right,i=u);let _=Math.abs(r.right-f.left);_<i&&(v.snapPosition.x=f.left-r.width,v.vertical=f.left,i=_);let p=Math.abs(r.top-f.top);p<s&&(v.snapPosition.y=f.top,v.horizontal=f.top,s=p);let N=Math.abs(r.bottom-f.top);N<s&&(v.snapPosition.y=f.top-r.height,v.horizontal=f.top,s=N);let A=Math.abs(r.bottom-f.bottom);A<s&&(v.snapPosition.y=f.bottom-r.height,v.horizontal=f.bottom,s=A);let P=Math.abs(r.top-f.bottom);return P<s&&(v.snapPosition.y=f.bottom,v.horizontal=f.bottom,s=P),v},n)}var In=()=>{let[e,t]=An(void 0),[o,n]=An(void 0),a=ds((r,s)=>{var i,l;if(t(void 0),n(void 0),r.length===1&&r[0].type==="position"&&r[0].dragging&&r[0].position){let c=Cn(r[0],s);r[0].position.x=(i=c.snapPosition.x)!=null?i:r[0].position.x,r[0].position.y=(l=c.snapPosition.y)!=null?l:r[0].position.y,t(c.horizontal),n(c.vertical)}return ls(r,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:a}};import{useReactFlow as ps}from"@xyflow/react";import{v7 as Dn}from"uuid";var kn={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ln={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Sn=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],a=e.match(/(\{.*?\})/)||[],r=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],"")),a.length&&(s="gateway-exclusive",i=a[1].replace(/\{|\}/g,""),e=e.replace(a[1],"")),r.length&&(l=r[1].replace(/(\||--)/g,""),e=e.replace(r[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},cs=e=>{e=e||"";let t=e.trim().split(`
|
|
1
|
+
var Ta=Object.defineProperty,_a=Object.defineProperties;var wa=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var Co=Object.prototype.hasOwnProperty,Ao=Object.prototype.propertyIsEnumerable;var xo=(e,t,o)=>t in e?Ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,w=(e,t)=>{for(var o in t||(t={}))Co.call(t,o)&&xo(e,o,t[o]);if(Xe)for(var o of Xe(t))Ao.call(t,o)&&xo(e,o,t[o]);return e},C=(e,t)=>_a(e,wa(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 xa,Notification as Ca}from"lecom-ui";import{jsx as Aa,jsxs as Ia}from"react/jsx-runtime";function Io({children:e}){return Ia(xa,{children:[Aa(Ca,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as jd,MiniMap as Jd,ReactFlow as Qd,ReactFlowProvider as ec,SelectionMode as tc,useEdgesState as oc,useNodesState as nc,useOnSelectionChange as rc,useReactFlow as ac}from"@xyflow/react";import{i18n as jr}from"lecom-ui";import{forwardRef as ic,useCallback as fo,useEffect as yo,useImperativeHandle as sc,useRef as lc,useState as dc}from"react";import{useDebouncedCallback as cc}from"use-debounce";import{v7 as Eo}from"uuid";var je=(a=>(a.ACTIVITY="activity",a.ROUTING="routing",a.GATEWAY="gateway",a.SUB_PROCESS="sub_process",a))(je||{}),Bt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(Bt||{}),zt=(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))(zt||{}),Ut=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ut||{}),Ft=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ft||{});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 Qe=({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 he=({size:e=24,className:t})=>So("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",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 ke,jsxs as ka}from"react/jsx-runtime";var et=({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:[ke("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"}),ke("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),ke("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),ke("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),ke("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Wt,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:[Wt("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"}),Wt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Wt("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 tt=({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 Yt,jsxs as Da}from"react/jsx-runtime";var ko=({size:e=24,className:t})=>Yt("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:[Yt("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"}),Yt("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 Le=(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 $t}from"react/jsx-runtime";var Do=({size:e=24,className:t})=>$t("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:$t("g",{children:$t("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 ot=({size:e=24,className:t})=>Ro("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",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 Pe=({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 Zt,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:[Zt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Zt("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Zt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as De,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:[De("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"}),De("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"}),De("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"}),De("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),De("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as nt,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:[nt("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"}),nt("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),nt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),nt("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 rt={SCRIPT:{icon:za},SUBPROCESS:{icon:Ua}};var at={LOOP:{icon:Ba}},Q=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Q||{}),qt={EXCLUSIVE:{icon:Ne},PARALLEL:{icon:tt},COMPLEX:{icon:et}};import{create as Fa}from"zustand";var O=Fa(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as qo,useReactFlow as xi}from"@xyflow/react";import{BaseEdge as li,EdgeLabelRenderer as di,getStraightPath as ci,useNodes as pi,useViewport as ui}from"@xyflow/react";import{getIncomers as Re,getOutgoers as Xt,useReactFlow as Ya}from"@xyflow/react";import{Button as $a,Tooltip as Za,TooltipContent as qa,TooltipTrigger as Xa,useTranslation as ja}from"lecom-ui";import{Settings as Ja}from"lucide-react";import{createContext as Wa,useContext as Ka}from"react";var Ho=Wa(null),Bo=Ho.Provider,it=()=>{let e=Ka(Ho);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as st,jsxs as Qa}from"react/jsx-runtime";var Ve=({elementId:e,elementType:t="node"})=>{let{t:o}=ja(),{getNode:n,getEdge:a,getNodes:r,getEdges:s}=Ya(),{onConfigureElement:i}=it(),l=d=>{var u,_,p,N,A;return d?d.type==="TASK"&&((u=d.data)==null?void 0:u.variant)==="SUBPROCESS"?{id:d.id,type:"sub_process",variant:y(d),label:(_=d.data)==null?void 0:_.label}:d.type==="GATEWAY"?{id:d.id,type:"gateway",variant:((p=d.data)==null?void 0:p.variant)||"EXCLUSIVE",label:(N=d.data)==null?void 0:N.label}:{id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label}:null},c=d=>{let u=r(),_=s(),p=Re(d,u,_);if(p.length===0)return;let N=p[0];return l(N)||void 0},y=d=>{let u=r(),_=s(),p=Re(d,u,_),N=Xt(d,u,_),A=p.some(L=>L.type==="START_EVENT"),P=N.some(L=>L.type==="END_EVENT");return A?"start":P?"end":"between"},b=d=>{var L,I,S,R;let u=r(),_=s(),p=n(d.source),N=n(d.target);if(!p||!N)return"simple";if(Xt(p,u,_).some(M=>M.type==="END_EVENT"))return"final";if(p.type==="GATEWAY")switch((L=p.data)==null?void 0:L.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(p.type==="TASK"){let M=(I=p.data)==null?void 0:I.variant,Z=(S=p.data)==null?void 0:S.attribute;return N.type==="TASK"&&((R=N.data)==null?void 0:R.variant)==="SUBPROCESS"?"to_sub_process":M==="SCRIPT"?"script":Z==="LOOP"?"loop":"simple"}return"simple"},g=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="COMPLEX")return;let _=r(),p=s(),N=Re(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A&&P)return"script_loop";if(A)return"script";if(P)return"loop"},E=d=>{var L;let u=n(d.source);if(!u||u.type!=="GATEWAY"||((L=u.data)==null?void 0:L.variant)!=="EXCLUSIVE")return;let _=r(),p=s(),N=Re(u,_,p),A=!1,P=!1;if(N.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(A=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(P=!0))}),A&&P)return"script_loop";if(A)return"script";if(P)return"loop"},m=d=>{var P,L;if(d.type!=="GATEWAY")return;let u=r(),_=s(),p=Re(d,u,_),N=!1,A=!1;if(p.forEach(I=>{var S,R;I.type==="TASK"&&(((S=I.data)==null?void 0:S.variant)==="SCRIPT"&&(N=!0),((R=I.data)==null?void 0:R.attribute)==="LOOP"&&(A=!0))}),((P=d.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}else if(((L=d.data)==null?void 0:L.variant)==="EXCLUSIVE"){if(N&&A)return"script_loop";if(N)return"script";if(A)return"loop"}},h=d=>Xt(d,r(),s()).map(p=>{var N,A;return{id:p.id,type:p.type,variant:(N=p.data)==null?void 0:N.variant,label:(A=p.data)==null?void 0:A.label}}),v=d=>s().filter(p=>p.source===d.id).map(p=>{var N;return{id:p.id,type:"routing",variant:b(p),label:(N=p.data)==null?void 0:N.label,target:n(p.target)}}),T=()=>{var _,p,N,A,P,L;let d=n(e);if(!d)return;let u=c(d);if(d.type==="TASK"&&((_=d.data)==null?void 0:_.variant)==="SUBPROCESS"){i==null||i({id:d.id,type:"sub_process",variant:y(d),label:(p=d.data)==null?void 0:p.label,origin:u,targets:h(d),edgeTargets:v(d)}),console.log({id:d.id,type:"sub_process",variant:y(d),label:(N=d.data)==null?void 0:N.label,origin:u,targets:h(d),edgeTargets:v(d)});return}if(d.type!=="GATEWAY"){i==null||i({id:d.id,type:"activity",variant:y(d),label:(A=d.data)==null?void 0:A.label,origin:u,targets:h(d),edgeTargets:v(d)});return}i==null||i({id:d.id,type:"gateway",variant:((P=d.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(L=d.data)==null?void 0:L.label,origin:u,subVariant:m(d),targets:h(d)})},f=()=>{let d=a(e);if(d){let u=b(d),_;u==="complex"?_=g(d):u==="exclusive"&&(_=E(d));let p=n(d.source),N=p&&l(p)||void 0;i==null||i({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)}),console.log({id:d.id,type:"routing",variant:u,subVariant:_,origin:N,target:n(d.target)})}};return Qa(Za,{children:[st(Xa,{asChild:!0,children:st($a,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":T();break;case"edge":f();break}},children:st(Ja,{size:16})})}),st(qa,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as ei}from"@xyflow/react";import{Button as ti,Tooltip as oi,TooltipContent as ni,TooltipTrigger as ri,useTranslation as ai}from"lecom-ui";import{TrashIcon as ii}from"lucide-react";import{jsx as lt,jsxs as si}from"react/jsx-runtime";var dt=({elementId:e,elementType:t="node"})=>{let{t:o}=ai(),{deleteElements:n}=ei();return si(oi,{children:[lt(ri,{asChild:!0,children:lt(ti,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:lt(ii,{size:16})})}),lt(ni,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as ct}from"react/jsx-runtime";var ve=n=>{var a=n,{edgeId:e,edgeType:t}=a,o=ae(a,["edgeId","edgeType"]);var i;let r=[{component:ct(dt,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:ct(Ve,{elementId:e,elementType:"edge"})},...r],MESSAGE_EDGE:[...r],ANNOTATION_EDGE:[...r]};return ct("div",C(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)=>ct("div",{children:l.component},c))}))};import{jsx as ut,jsxs as mi}from"react/jsx-runtime";var mt={type:"ANNOTATION_EDGE",zIndex:2e3},zo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,selected:i,data:l})=>{let c=pi(),{zoom:y}=ui(),{isMultipleSelection:b}=O(),g=c.find(x=>x.id===t),E=c.find(x=>x.id===o),[m,h,v]=ci({sourceX:n,sourceY:a,targetX:r,targetY:s}),T=i||(g==null?void 0:g.selected)||(E==null?void 0:E.selected),f=1/y;return mi("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":T}),children:[ut(li,{id:e,path:m,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)]":T&&!(l!=null&&l.hasError)})}),ut(di,{children:ut("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&&!b&&ut(ve,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${f})`}})})})]})};import{BaseEdge as Ei,EdgeLabelRenderer as bi,getSmoothStepPath as yi,MarkerType as Wo,useNodes as hi,useReactFlow as Ni,useViewport as vi}from"@xyflow/react";import{useState as Ti}from"react";import{useEffect as Uo,useRef as gi,useState as fi}from"react";import{jsx as Fo}from"react/jsx-runtime";var B=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:a,className:r,style:s})=>{let i=gi(null),[l,c]=fi(!1);Uo(()=>{c(n!=null?n:!1)},[n]),Uo(()=>{if(l&&i.current){i.current.focus();let m=document.createRange();m.selectNodeContents(i.current),m.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(m))}},[l]);let y=m=>{if(m.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))},b=m=>{let h=m.currentTarget.innerText.trim(),v=t&&h.length>=t,T=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],f=m.ctrlKey||m.metaKey,x=f&&m.key==="a",d=f&&m.key==="c",u=f&&m.key==="x",_=f&&m.key==="v";function p(A){return/\w/.test(A)}if(h.length===0&&!p(m.key)&&!T.includes(m.key)&&!f){m.preventDefault();return}v&&(T.includes(m.key)||x||d||u||_||m.preventDefault())},g=m=>{if(!t)return;m.preventDefault();let h=m.clipboardData.getData("text/plain"),v=m.currentTarget.innerText,T=window.getSelection();if(!T||T.rangeCount===0)return;let f=T.getRangeAt(0);if((v.substring(0,f.startOffset)+h+v.substring(f.endOffset)).length>t){let d=t-(v.length-(f.endOffset-f.startOffset)),u=h.substring(0,Math.max(0,d));u&&(f.deleteContents(),f.insertNode(document.createTextNode(u)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f))}else f.deleteContents(),f.insertNode(document.createTextNode(h)),f.setStartAfter(f.endContainer),f.collapse(!0),T.removeAllRanges(),T.addRange(f)},E=m=>{c(!1);let h=m.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),m.currentTarget.innerText=h,a==null||a(),h!==e&&(o==null||o(h))};return Fo("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",r,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:y,children:Fo("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:b,onPaste:g,onBlur:E,children:e})})};import{jsx as gt,jsxs as Ko}from"react/jsx-runtime";var ee={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:Wo.ArrowClosed},markerEnd:{type:Wo.Arrow},data:{label:""}},Yo=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=hi(),{zoom:g}=vi(),{updateEdgeData:E}=Ni(),{isMultipleSelection:m}=O(),[h,v]=Ti(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=yi({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return Ko("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[gt(Ei,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),gt(bi,{children:Ko("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&>(ve,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${A})`}}),N&>(B,{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:I})]})})]})};var ft=e=>e.some(t=>t.type==="START_EVENT"),Et=(e,t,o)=>{var r;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((r=n.data)==null?void 0:r.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},bt=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},yt=(e,t)=>{var n;let o=t.find(a=>a.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},ht=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.target===e).some(r=>{let s=t.find(i=>i.id===r.source);return(s==null?void 0:s.type)==="START_EVENT"})},Nt=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>r.source===e).some(r=>{let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)==="END_EVENT"})},vt=(e,t)=>t.filter(n=>n.source===e).length>0,Tt=(e,t,o)=>{let n=t.find(r=>r.id===e);return!n||n.type!=="TASK"?!1:o.filter(r=>{if(r.source!==e)return!1;let s=t.find(i=>i.id===r.target);return(s==null?void 0:s.type)!=="ANNOTATION"}).length>=2};var _i=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Et(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:!(bt(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(yt(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(ht(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:!(vt(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"})],$o=e=>{for(let t of _i){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var wi=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Et(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:ft(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bt(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yt(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ht(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:vt(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"})}],Zo=e=>{let t=wi.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),a=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&a});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var Xo=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=xi();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 $o(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?qo(w(w({},s),mt),i):qo(w(w({},s),ee),i)})}}};import{useState as an}from"react";import{useTranslation as Ci}from"lecom-ui";import{useReactFlow as Ai}from"@xyflow/react";var Me=(e=[])=>e.filter(t=>t.type==="START_EVENT"),ce=(e=[])=>e.filter(t=>t.type==="END_EVENT"),se=(e=[])=>e.filter(t=>t.type==="TASK")||[],jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Jo=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),_t=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Qo=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),q=(e,t=[])=>t.filter(o=>o.source===e),Oe=(e,t=[])=>t.filter(o=>o.target===e),en=(e,t)=>{var n,a;let o=(n=t.nodes)==null?void 0:n.find(r=>r.id===e);return((a=o==null?void 0:o.properties)==null?void 0:a.attribute)==="LOOP"},tn=(e,t)=>{let o=q(e,t.edges||[]);for(let n of o){let a=(t.nodes||[]).find(r=>r.id===n.target);if(a&&a.type==="END_EVENT")return!0}return!1},on=e=>e?/\w/g.test(e.trim()):!1,V=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:[]}},te=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},nn=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Ge=[{id:"start_event_not_found",validate:e=>{let t=Me(e.nodes);return V({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=ce(e.nodes);return V({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Me(e.nodes),o=t.length===1;if(t.length===0)return V({isValid:!0});if(!o)return V({isValid:!1,nodeIds:t.map(r=>r.id)});let n=q(t[0].id,e.edges);if(!(n.length<=1)){let r=[...t.map(s=>s.id),...n.map(s=>s.target)];return V({isValid:!1,nodeIds:[...new Set(r)]})}return V({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=se(e.nodes),o=te(t,n=>q(n.id,e.edges).length<=2);return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=se(e.nodes),o=te(t,n=>!!n.label&&n.label.trim()!=="");return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=se(e.nodes),n=te(o,a=>!a.label||a.label.length<=60);return V({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=se(e.nodes),o=new Map;for(let a of t){if(!a.label)continue;let r=a.label.trim();r&&(o.has(r)||o.set(r,[]),o.get(r).push(a))}let n=[];for(let[,a]of o.entries())a.length>1&&a.forEach(r=>n.push(r.id));return V({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=_t(e.nodes),o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Me(e.nodes),...ce(e.nodes)],o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=ce(e.nodes),o=[],n=[];for(let a of t){let r=Oe(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=q(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return V({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Qo(e.nodes),o=te(t,a=>q(a.id,e.edges).length<=2),n=o.invalidIds.flatMap(a=>q(a,e.edges).map(r=>r.id));return V({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=se(e.nodes),o=te(t,n=>!n.label||on(n.label));return V({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 V({isValid:!0});let t=ce(e.nodes)[0];if(!t)return V({isValid:!0});let o=Oe(t.id,e.edges);if(!o.length)return V({isValid:!0});let a=se(e.nodes).filter(l=>o.some(c=>c.source===l.id)),r=te(a,l=>!en(l.id,e));return V({isValid:r.isValid,nodeIds:r.isValid?[]:[t.id,...r.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=se(e.nodes),o=ce(e.nodes)[0];if(!o)return V({isValid:!0});let n=t.filter(l=>{let c=Oe(l.id,e.edges),y=q(l.id,e.edges),b=c.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.source))==null?void 0:m.type)==="START_EVENT"}),g=y.some(E=>{var m;return((m=e.nodes.find(h=>h.id===E.target))==null?void 0:m.type)==="END_EVENT"});return b&&g}),a=Oe(o.id,e.edges),r=a.length>1,s=a.map(l=>l.source),i={isValid:n.length===0&&!r,nodeIds:[...n.map(l=>l.id),...r?s:[]]};return V(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=_t(e.nodes),o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=_t(e.nodes),o=te(t,n=>q(n.id,e.edges).length>=1);return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Me(e.nodes),...ce(e.nodes)],o=[],n=[];for(let a of t){let r=q(a.id,e.edges);for(let s of r){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(a.id,i.id),n.push(s.id))}}return V({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=jo(e.nodes),o=te(t,n=>!tn(n.id,e));return V({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Jo(e.nodes),o=te(t,n=>{var a,r;return((a=n.properties)==null?void 0:a.subprocessRef)!==void 0&&((r=n.properties)==null?void 0:r.subprocessRef)!==""});return V({isValid:o.isValid,nodeIds:o.invalidIds})}}];var rn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Ge){let a=n.validate(e);a.isValid||t.push({id:n.id,message:n.id,nodeIds:a.nodeIds||[],edgeIds:a.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var sn=()=>{let{t:e}=Ci(),[t,o]=an(null),{setNodes:n,setEdges:a,getNodes:r,getEdges:s}=Ai(),[i,l]=an(!1);return{validationResult:t,validateDiagram:g=>{let E=nn(g.nodes,g.edges),m=rn(E),h=m.errors.map(v=>C(w({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:m.isValid,errors:h}},handleValidationComplete:g=>{if(o(g),!g)return;let E=[],m=[];g.errors.forEach(p=>{p.nodeIds&&p.nodeIds.length>0&&p.nodeIds.forEach(N=>E.push(N)),p.edgeIds&&p.edgeIds.length>0&&p.edgeIds.forEach(N=>m.push(N))});let h=[...new Set(E)];n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})}))),a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:!1})})));let v=r(),T=s(),f=new Set(h),x=new Set;g.errors.forEach(p=>{var P,L;let N=Ge.find(I=>I.id===p.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=p.edgeIds)==null||P.forEach(I=>x.add(I)),(L=p.nodeIds)==null||L.forEach(I=>{T.forEach(S=>{(S.source===I||S.target===I)&&x.add(S.id)})}))});let d=new Set,u=new Set,_=new Set;v.forEach(p=>{p.type==="START_EVENT"?d.add(p.id):p.type==="END_EVENT"&&u.add(p.id)}),T.forEach(p=>{d.has(p.source)&&_.add(p.target),u.has(p.target)&&_.add(p.source)}),_.forEach(p=>{var N,A;if(f.has(p)){let P=(N=g.errors.find(I=>{var S;return(S=I.nodeIds)==null?void 0:S.includes(p)}))==null?void 0:N.id;((A=Ge.find(I=>I.id===P))==null?void 0:A.highlightRelatedEdges)!==!1&&T.forEach(I=>{I.source===p&&u.has(I.target)&&(f.add(I.target),x.add(I.id)),I.target===p&&d.has(I.source)&&(f.add(I.source),x.add(I.id))})}}),f.size>0&&n(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:f.has(N.id)})}))),x.size>0&&a(p=>p.map(N=>C(w({},N),{data:C(w({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})}))),a(g=>g.map(E=>C(w({},E),{data:C(w({},E.data),{hasError:!1})})))},isAutoValidationEnabled:i}};import{useReactFlow as Ii}from"@xyflow/react";import{useTranslation as Si}from"lecom-ui";import{useEffect as ki}from"react";import{v7 as ln}from"uuid";var wt=(e,t)=>{let n=e.filter(r=>r.type==="TASK").map(r=>{var i;let s=(i=r.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(r=>r>0),a=n.length>0?Math.max(...n)+1:1;return`${t} ${a}`},Te=(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 a=e.replace(/\s+\(\d+\)$/,""),r=n.filter(i=>i===a||i.startsWith(`${a} (`)).map(i=>{if(i===a)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;r.includes(s);)s++;return`${a} (${s})`};var Li=15,dn="bpmn:selection",Pi=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},cn=e=>{if(!Pi(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},pn=({offset:e=Li}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=Ii(),{t:r}=Si();ki(()=>{let s=l=>{var h,v;if(!cn(l))return;let c=t(),y=n(),b=c.filter(T=>T.selected);if(!b.length)return;l.preventDefault(),l.stopPropagation();let g=y.filter(T=>b.some(f=>f.id===T.source)&&b.some(f=>f.id===T.target)),m=JSON.stringify({nodes:b,edges:g});(h=l.clipboardData)==null||h.setData(dn,m),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${b.length} nodes`)},i=l=>{var x,d;if(!cn(l))return;let c=(x=l.clipboardData)==null?void 0:x.getData(dn);if(!c)return;l.preventDefault(),l.stopPropagation();let y;try{y=JSON.parse(c)}catch(u){return}if(!((d=y.nodes)!=null&&d.length))return;let b=new Map,g=t(),E=[],m=g.some(u=>u.type==="START_EVENT"),h=y.nodes.filter(u=>u.type==="START_EVENT"),v=y.nodes;if(m&&h.length>0&&(v=y.nodes.filter(u=>u.type!=="START_EVENT"),v.length===0))return;let T=v.map(u=>{var N;let _=ln();b.set(u.id,_);let p=C(w({},u),{id:_,selected:!0,position:{x:u.position.x+e,y:u.position.y+e}});if(u.type==="TASK"){let A=(N=u.data)==null?void 0:N.label,P=Te(A||r("bpmn.task.label.prefix"),[...g,...E]);p.data=C(w({},u.data),{label:P})}return E.push(p),p}),f=y.edges.map(u=>C(w({},u),{id:ln(),selected:!0,source:b.get(u.source)||u.source,target:b.get(u.target)||u.target}));o(u=>[...u.map(_=>C(w({},_),{selected:!1})),...T]),a(u=>[...u.map(_=>C(w({},_),{selected:!1})),...f])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,a,e,r])};import{useReactFlow as Qi,useStoreApi as es}from"@xyflow/react";import{useTranslation as ts}from"lecom-ui";import{v7 as Tn}from"uuid";var Di={MIN_WIDTH:36,MIN_HEIGHT:36},Ri={MIN_WIDTH:36,MIN_HEIGHT:36},Vi={MIN_WIDTH:56,MIN_HEIGHT:56},xt={MIN_WIDTH:176,MIN_HEIGHT:96},Ct={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},F={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},At={MIN_WIDTH:176,MIN_HEIGHT:64},Mi={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:Di,END_EVENT:Ri,GATEWAY:Vi,TASK:xt,LANE:F,ANNOTATION:At,UNSUPPORTED:Mi};import gn from"@dagrejs/dagre";import{getNodesBounds as Bi}from"@xyflow/react";import{orderBy as zi}from"lodash";import{orderBy as Oi}from"lodash";var ie=e=>{var t,o,n,a,r,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(a=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?a:0,w:(s=(r=e.measured)==null?void 0:r.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},pe=e=>Oi(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),un=(e,t)=>{let{x:o,y:n}=ie(e),{x:a,y:r}=ie(t);return{x:o-a,y:n-r}};var _e=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(a=>a.parentId===e&&(!o.length||o.includes(a.type))&&!n.includes(a.type)),Gi=(e,t)=>{let{x:o,y:n}=ie(e),{x:a,y:r}=ie(t),s=o-a,i=n-r;return Math.sqrt(s*s+i*i)},Hi=(e,t)=>{let{x:o,y:n,w:a,h:r}=ie(e),{x:s,y:i,w:l,h:c}=ie(t);return o<s+l&&s<o+a&&n<i+c&&i<n+r},He=(e,t)=>{let o=null,n=1/0;for(let a of t)if(a.id!==e.id&&Hi(e,a)){let r=Gi(e,a);r<n&&(n=r,o=a)}return o},mn=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var a,r;return Math.max(o,(r=(a=n.measured)==null?void 0:a.width)!=null?r:0)},0);var fn=(e=[],t=[],o="LR")=>{let n=new gn.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:r,width:s,height:i})=>n.setNode(r,{width:s,height:i})),t.forEach(r=>n.setEdge(r.source,r.target)),gn.layout(n),{nodes:e.map(r=>{let s=n.node(r.id);return C(w({},r),{position:{x:s.x-r.width/2,y:s.y-r.height/2}})}),edges:t}},ue=(e,t)=>{var g,E;let o=[...t],n=o.find(m=>m.id===e);if(!n)return o;let a=o.filter(m=>m.parentId===e&&m.type==="LANE");if(a.length===0)return o;let r=zi(a,["position.y"]),s=Math.max((E=(g=n.measured)==null?void 0:g.width)!=null?E:0,Ct.MIN_WIDTH),i=mn(e,r)||F.MIN_WIDTH,l=Math.max(s,i),c=0,y=0;r.forEach(m=>{var h,v,T,f;o=o.map(x=>x.id===m.id?C(w({},x),{width:l-F.HEADER_WIDTH,measured:C(w({},x.measured),{width:l-F.HEADER_WIDTH}),position:{x:F.HEADER_WIDTH,y:c}}):x),c+=(v=(h=m.measured)==null?void 0:h.height)!=null?v:0,y+=(f=(T=m.measured)==null?void 0:T.height)!=null?f:0}),o=o.map(m=>m.id===e?C(w({},m),{height:y,width:l,measured:C(w({},m.measured),{height:y,width:l})}):m);let b=o.find(m=>m.id===e);return b!=null&&b.parentId&&(o=ue(b.parentId,o)),o},En=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Ui=50,bn=(e,t=Ui)=>{let o=Bi(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as Fi}from"zustand";var we=Fi(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Wi,EdgeLabelRenderer as Ki,getSmoothStepPath as Yi,MarkerType as $i,useNodes as Zi,useReactFlow as qi,useViewport as Xi}from"@xyflow/react";import{useState as ji}from"react";import{jsx as It,jsxs as yn}from"react/jsx-runtime";var Rm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:$i.Arrow},data:{label:""}},hn=({id:e,source:t,target:o,sourceX:n,sourceY:a,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:y})=>{let b=Zi(),{zoom:g}=Xi(),{updateEdgeData:E}=qi(),{isMultipleSelection:m}=O(),[h,v]=ji(!1),T=b.find(S=>S.id===t),f=b.find(S=>S.id===o),[x,d,u]=Yi({sourceX:n,sourceY:a,sourcePosition:i,targetX:r,targetY:s,targetPosition:l}),_=y||(T==null?void 0:T.selected)||(f==null?void 0:f.selected),p=_?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,A=1/g,P=()=>{v(!0)},L=()=>{v(!1)},I=S=>{E(e,{label:S.trim()})};return yn("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":_}),onBlur:L,onDoubleClick:P,children:[It(Wi,{id:e,path:x,markerEnd:`url(#${p})`,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)]":_&&!(c!=null&&c.hasError)})}),It(Ki,{children:yn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${d}px, ${u}px)`},children:[y&&!m&&It(ve,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${A})`}}),N&&It(B,{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:I})]})})]})};import{jsx as Nn,jsxs as Ji}from"react/jsx-runtime";var vn=({fromX:e,fromY:t,toX:o,toY:n})=>Ji("g",{children:[Nn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),Nn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var _n=({nodes:e,setNodes:t,setEdges:o})=>{let n=es(),{draggableNode:a,setDraggableNode:r}=we(),{getInternalNode:s,screenToFlowPosition:i}=Qi(),{t:l}=ts(),c=d=>{let u="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(_=>_.map(p=>C(w({},p),{className:p.id===d?u:""})))},y=()=>{let{nodeLookup:d}=n.getState();return Array.from(d.values())},b=d=>{let u=s(d.id),_=y();if(d.type==="LANE"){if(_e({parentId:d.id,nodes:e,includeTypes:["LANE"]})){c();return}let I=_.filter(M=>M.id!==d.id&&M.type==="LANE"&&!M.parentId),S=He(u,I);if(!S){c();return}if(_e({parentId:S.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(S.id);return}let N=_.filter(L=>L.id!==d.id&&L.type==="LANE"),A=He(u,N);if(!A){c();return}if(_e({parentId:A.id,nodes:e,includeTypes:["LANE"]})){c();return}c(A.id)},g=d=>d.map(u=>C(w({},u),{className:void 0})),E=d=>d.some(_=>_.dragging)?d.map(_=>_.dragging?C(w({},_),{dragging:!1}):_):d,m=d=>{d.preventDefault(),d.dataTransfer.dropEffect="move"},h=(d,u)=>{d.preventDefault(),b(u)},v=(d,u,_)=>{var L,I;let p=[..._];if(d.parentId===u.id)return p=ue(u.id,p),g(p);if(d.type==="LANE"){if(_e({parentId:u.id,nodes:p,excludeTypes:["LANE"]}))return p;let M=p.filter(X=>X.parentId===u.id).reduce((X,be)=>{var Ye,$e;return X+(($e=(Ye=be.measured)==null?void 0:Ye.height)!=null?$e:0)},0),Z={x:F.HEADER_WIDTH,y:M};return p=p.map(X=>X.id===d.id?C(w({},X),{parentId:u.id,position:Z,className:void 0}):C(w({},X),{className:void 0})),p=ue(u.id,p),p}if(_e({parentId:u.id,nodes:p,includeTypes:["LANE"]})){let S;if(d.parentId){let R=s(d.parentId),{x:M,y:Z}=ie(R);S={x:M+((L=d.position.x)!=null?L:0),y:Z+((I=d.position.y)!=null?I:0)}}return p=p.map(R=>R.id===d.id?C(w({},R),{position:S!=null?S:R.position,parentId:void 0,className:void 0}):C(w({},R),{className:void 0})),p}let P=un(d,u);return p=p.map(S=>S.id===d.id?C(w({},S),{parentId:u.id,position:P,className:void 0}):C(w({},S),{className:void 0})),p},T=d=>{if(d.preventDefault(),!(a!=null&&a.type))return;let u=i({x:d.clientX,y:d.clientY}),_={width:G[a.type].MIN_WIDTH,height:G[a.type].MIN_HEIGHT},p={id:Tn(),type:a.type,position:u,measured:_,data:{label:a.type==="TASK"?wt(e,l("bpmn.task.label.prefix")):"",variant:a.variant,attribute:a.attribute}},N=C(w({},p),{internals:{positionAbsolute:u}}),A=y(),P=a.type==="LANE",L=A.filter(M=>P?M.type==="LANE"&&!M.parentId:M.type==="LANE"),I=He(N,L),S=[...e,p];I&&(S=v(N,I,S)),t(pe(S));let R=d.dataTransfer.getData("sourceId");if(R){let M={id:Tn(),source:R,target:p.id};if(a.type==="ANNOTATION"){o(Z=>Z.concat(w(w({},M),mt)));return}o(Z=>Z.concat(w(w({},M),ee)))}r(null)},f=async(d,u,_)=>{let p=[...e];_.forEach(N=>{let A=y(),P=s(N.id),L=N.type==="LANE",I=A.filter(R=>R.id!==N.id&&(L?R.type==="LANE"&&!R.parentId:R.type==="LANE")),S=He(P,I);if(S){p=v(P,S,p);return}N.parentId&&(p=x(N,p))}),p=E(p),t(pe(p))},x=(d,u)=>{var P,L;let _=s(d.parentId),{x:p,y:N}=ie(_),A={x:p+((P=d.position.x)!=null?P:0),y:N+((L=d.position.y)!=null?L:0)};return u=u.map(I=>I.id===d.id?C(w({},I),{position:A,parentId:void 0}):I),u=ue(d.parentId,u),u};return{onDragOver:m,onDrop:T,onNodeDrag:h,onNodeDragStop:f}};import{useReactFlow as os}from"@xyflow/react";import{useTranslation as ns}from"lecom-ui";import{useEffect as rs}from"react";import{v7 as wn}from"uuid";var as=30,is=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,a=t==="select",r=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||a||r},ss=e=>!is(e.target),xn=({offset:e=as}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:a}=os(),{t:r}=ns();rs(()=>{let s=i=>{if(i.ctrlKey&&i.key.toLowerCase()==="d"&&ss(i)){i.preventDefault(),i.stopPropagation();let l=t(),c=n(),y=l.filter(x=>x.selected);if(!y.length)return;let b=new Map,g=[],E=l.some(x=>x.type==="START_EVENT"),m=y.filter(x=>x.type==="START_EVENT"),h=y;if(E&&m.length>0&&(h=y.filter(x=>x.type!=="START_EVENT"),h.length===0))return;let v=c.filter(x=>h.some(d=>d.id===x.source)&&h.some(d=>d.id===x.target)),T=h.map(x=>{var _;let d=wn();b.set(x.id,d);let u=C(w({},x),{id:d,selected:!0,position:{x:x.position.x+e,y:x.position.y+e}});if(x.type==="TASK"){let p=(_=x.data)==null?void 0:_.label,N=Te(p||r("bpmn.task.label.prefix"),[...l,...g]);u.data=C(w({},x.data),{label:N})}return g.push(u),u}),f=v.map(x=>C(w({},x),{id:wn(),selected:!0,source:b.get(x.source)||x.source,target:b.get(x.target)||x.target}));o(x=>[...x.map(d=>C(w({},d),{selected:!1})),...T]),a(x=>[...x.map(d=>C(w({},d),{selected:!1})),...f])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[t,o,n,a,e,r])};import{applyNodeChanges as ls}from"@xyflow/react";import{useCallback as ds,useState as An}from"react";function Cn(e,t,o=5){var l,c,y,b,g,E,m,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},a=t.find(v=>v.id===e.id);if(!a||!e.position)return n;let r={left:e.position.x,right:e.position.x+((c=(l=a.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((b=(y=a.measured)==null?void 0:y.height)!=null?b:0),width:(E=(g=a.measured)==null?void 0:g.width)!=null?E:0,height:(h=(m=a.measured)==null?void 0:m.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==a.id).reduce((v,T)=>{var L,I,S,R,M,Z,X,be;let f={left:T.position.x,right:T.position.x+((I=(L=T.measured)==null?void 0:L.width)!=null?I:0),top:T.position.y,bottom:T.position.y+((R=(S=T.measured)==null?void 0:S.height)!=null?R:0),width:(Z=(M=T.measured)==null?void 0:M.width)!=null?Z:0,height:(be=(X=T.measured)==null?void 0:X.height)!=null?be:0},x=Math.abs(r.left-f.left);x<i&&(v.snapPosition.x=f.left,v.vertical=f.left,i=x);let d=Math.abs(r.right-f.right);d<i&&(v.snapPosition.x=f.right-r.width,v.vertical=f.right,i=d);let u=Math.abs(r.left-f.right);u<i&&(v.snapPosition.x=f.right,v.vertical=f.right,i=u);let _=Math.abs(r.right-f.left);_<i&&(v.snapPosition.x=f.left-r.width,v.vertical=f.left,i=_);let p=Math.abs(r.top-f.top);p<s&&(v.snapPosition.y=f.top,v.horizontal=f.top,s=p);let N=Math.abs(r.bottom-f.top);N<s&&(v.snapPosition.y=f.top-r.height,v.horizontal=f.top,s=N);let A=Math.abs(r.bottom-f.bottom);A<s&&(v.snapPosition.y=f.bottom-r.height,v.horizontal=f.bottom,s=A);let P=Math.abs(r.top-f.bottom);return P<s&&(v.snapPosition.y=f.bottom,v.horizontal=f.bottom,s=P),v},n)}var In=()=>{let[e,t]=An(void 0),[o,n]=An(void 0),a=ds((r,s)=>{var i,l;if(t(void 0),n(void 0),r.length===1&&r[0].type==="position"&&r[0].dragging&&r[0].position){let c=Cn(r[0],s);r[0].position.x=(i=c.snapPosition.x)!=null?i:r[0].position.x,r[0].position.y=(l=c.snapPosition.y)!=null?l:r[0].position.y,t(c.horizontal),n(c.vertical)}return ls(r,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:a}};import{useReactFlow as ps}from"@xyflow/react";import{v7 as Dn}from"uuid";var kn={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Ln={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Sn=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],a=e.match(/(\{.*?\})/)||[],r=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],"")),a.length&&(s="gateway-exclusive",i=a[1].replace(/\{|\}/g,""),e=e.replace(a[1],"")),r.length&&(l=r[1].replace(/(\||--)/g,""),e=e.replace(r[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},cs=e=>{e=e||"";let t=e.trim().split(`
|
|
2
2
|
`),o={},n=[];return t.forEach(a=>{a=a||"";let r=a.trim().split("-->");if(r.length!==2){console.warn("Invalid number of steps");return}let s=Sn(r[0],o),i=Sn(r[1],o);s&&i&&n.push({sourceId:s.step,targetId:i.step,label:s.edgeLabel||i.edgeLabel||""})}),{components:o,connections:n}},Pn=e=>{let{components:t,connections:o}=cs(e);return{nodes:t,edges:o}};var Rn=()=>{let{setNodes:e,setEdges:t,fitView:o}=ps();return{createDiagram:a=>{let{nodes:r,edges:s}=Pn(a),i=[],l=new Map;for(let[g,E]of Object.entries(r)){let m=Dn(),h=kn[E.type],v=Ln[E.type];l.set(g,m);let T=G[h].MIN_WIDTH,f=G[h].MIN_HEIGHT;i.push({id:m,type:h,data:{label:E.label||"",variant:v,attribute:""},position:{x:0,y:0},width:T,height:f,measured:{width:T,height:f}})}let c=[];for(let g of s){let E=C(w({},ee),{id:Dn(),source:l.get(g.sourceId)||g.sourceId,target:l.get(g.targetId)||g.targetId});c.push(E)}let{nodes:y,edges:b}=fn(i,c);e(y),t(b),o()}}};import{useEffect as us,useCallback as ms}from"react";var gs={origin:"*",debug:!1};function Vn(e,t=gs){let{origin:o,debug:n}=t,a=ms((r,s)=>{n&&console.debug("[postMessage] sending:",{type:r,payload:s}),window.parent.postMessage({type:r,payload:s},o||"*")},[o,n]);return us(()=>{let r=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",r),()=>window.removeEventListener("message",r)},[e,n]),{sendMessage:a}}import{useReactFlow as fs}from"@xyflow/react";var Mn=(e,t)=>{let{getNodes:o,getEdges:n}=fs();return{selectElement:s=>{let i=o().map(c=>C(w({},c),{selected:c.id===s})),l=n().map(c=>C(w({},c),{selected:c.id===s}));return e(i),t(l),!0},isReady:()=>!0}};import{useReactFlow as Es}from"@xyflow/react";import{useCallback as xe,useState as On,useEffect as bs}from"react";import{useDebouncedCallback as ys}from"use-debounce";var Gn=[{nodes:[],edges:[]}],hs=500,Hn=100,Bn=(e=Gn)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:a}=Es(),[r,s]=On(e),[i,l]=On(0),c=r[i],y=i>0,b=i<r.length-1,g=xe(d=>{n(r[d].nodes),a(r[d].edges)},[r,n,a]),E=xe(()=>{if(i>0){let d=i-1;l(d),g(d)}},[i,g]),m=xe(()=>{if(i<r.length-1){let d=i+1;l(d),g(d)}},[r,i,g]),h=d=>{let _=[...r.slice(0,i+1),d],p=_.length>Hn?_.slice(_.length-Hn):_;s(p),l(p.length-1)},v=ys(()=>{let d=t(),u=o(),_=d.map(A=>C(w({},A),{selected:!1,className:""})),p={nodes:pe(_),edges:u};JSON.stringify(c)!==JSON.stringify(p)&&h(p)},hs),T=xe(d=>{if(d==="forceSave"){v();return}d.some(p=>p.type==="select")||d.some(p=>p.type==="position"&&p.dragging)||v()},[v]),f=xe(d=>{s(d||Gn),l(0)},[]),x=xe(()=>{s([]),l(0)},[]);return bs(()=>{let d=u=>{(u.ctrlKey||u.metaKey)&&(u.shiftKey&&u.key.toLowerCase()==="z"?(u.preventDefault(),m()):u.key.toLowerCase()==="z"&&(u.preventDefault(),E()))};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[E,m]),{history:r,undo:E,redo:m,canUndo:y,canRedo:b,saveHistory:T,resetHistory:f,clearHistory:x}};import{jsx as zn}from"react/jsx-runtime";var Jt=({id:e,className:t})=>zn("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:zn("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Qt,jsxs as Ns}from"react/jsx-runtime";var Un=()=>Qt("svg",{style:{position:"absolute",top:0,left:0},children:Ns("defs",{children:[Qt(Jt,{id:"sequence-edge-marker",className:"text-grey-400"}),Qt(Jt,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});import{useKeyPress as ir}from"@xyflow/react";import{Button as no,Tooltip as ro,TooltipContent as ao,TooltipTrigger as io,useTranslation as yl}from"lecom-ui";import{HandIcon as hl,MapIcon as Nl,MousePointerIcon as vl}from"lucide-react";import{useCallback as Tl,useEffect as sr}from"react";import{useStore as vs}from"@xyflow/react";var Ts=e=>({unselectAll:e.unselectNodesAndEdges}),Be=()=>{let{unselectAll:e}=vs(Ts);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as qs,TooltipContent as Xs,TooltipTrigger as js,useNotificationToast as Js,useTranslation as Qs}from"lecom-ui";var ze=(f=>(f.START_EVENT="START_EVENT",f.END_EVENT="END_EVENT",f.TASK="TASK",f.SUBPROCESS="SUBPROCESS",f.GATEWAY="GATEWAY",f.LANE="LANE",f.ANNOTATION="ANNOTATION",f.CONNECTION="CONNECTION",f.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",f.ACTIVITY="ACTIVITY",f.PROCESS_INTERFACE="PROCESS_INTERFACE",f.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",f.VARIANT_ACTIVITY="VARIANT_ACTIVITY",f.AUTO_ACTIVITY="AUTO_ACTIVITY",f.DATA_STORE="DATA_STORE",f.DATA_OBJECT="DATA_OBJECT",f.DATA_OUTPUT="DATA_OUTPUT",f.DATA_INPUT="DATA_INPUT",f))(ze||{});import{useReactFlow as Bs}from"@xyflow/react";import{useNotificationToast as zs,useTranslation as Us,Button as Fs}from"lecom-ui";var Fn=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=a=>{var r;t((r=a.target)==null?void 0:r.result)},n.onerror=a=>{var r;o((r=a.target)==null?void 0:r.error)},n.readAsText(e)});function Wn({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let a="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
|
|
3
3
|
`),r=encodeURI(a);St(r,`${o}.csv`)}var St=(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 Rs}from"uuid";import{xml2json as _s,json2xml as of}from"xml-js";var ws={compact:!0,spaces:4},xs=e=>e.replaceAll(`
|
|
4
4
|
`,"
");function Kn(e,t=ws){if(e)return JSON.parse(_s(e,C(w({},t),{attributeValueFn:xs})))}function Yn(e){return e==null?void 0:e.replaceAll("
"," ")}import{v7 as As}from"uuid";var df={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},$n={script:"SCRIPT",subprocess:"SUBPROCESS"},Zn={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var me=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:a}=e,{value:r,parent:s}=n,i=Number(a._attributes.width),l=Number(a._attributes.height),c=s==="1"?void 0:s;return{id:n.id,parentId:c,type:t,data:{label:r||"",variant:o,attribute:""},position:{x:Number(a._attributes.x)||0,y:Number(a._attributes.y)||0},width:i,height:l,measured:{width:i,height:l}}},Is=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:me({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ss=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:me({cell:e,type:"END_EVENT"}),status:n,originalType:o}},ks=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=$n[t],a="imported";return["script","none"].includes(t)||(a="adapted"),e.mxGeometry._attributes.width=Le(e.mxGeometry._attributes.width,G.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Le(e.mxGeometry._attributes.height,G.TASK.MIN_HEIGHT),{node:me({cell:e,type:"TASK",variant:n}),status:a,originalType:o}},Ls=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Zn[o],a=["none","inclusive","event-based"],r="imported";return a.includes(o)&&(r="adapted"),e.mxGeometry._attributes.width=G.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=G.GATEWAY.MIN_HEIGHT,{node:me({cell:e,type:"GATEWAY",variant:n}),status:r,originalType:t}},Ps=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:me({cell:e,type:"LANE"}),status:"imported",originalType:t}},Ds=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Le(e.mxGeometry._attributes.width,G.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Le(e.mxGeometry._attributes.height,G.ANNOTATION.MIN_HEIGHT),{node:me({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},qn=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:me({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Xn=(e,t)=>{let{source:o,target:n,value:a}=e._attributes;return C(w({},ee),{id:As(),source:t.get(o)||o,target:t.get(n)||n,data:{label:a||""}})},jn={TASK:ks,GATEWAY:Ls,START_EVENT:Is,END_EVENT:Ss,LANE:Ps,ANNOTATION:Ds};var Vs=(e,t)=>{let o=e.filter(n=>n.parentId);for(let n of o){let a=t.get(n.parentId);a&&(n.parentId=a)}return e},Ms=e=>{var s;let t=new Map,o=Object.values(ze),n=e.filter(i=>{var l;return o.includes((l=i._attributes)==null?void 0:l.type)}),a=[],r=[];for(let i of n){let l=Rs(),{type:c}=i._attributes,y=jn[c]||qn;t.set((s=i._attributes)==null?void 0:s.id,l),i._attributes.id=l;let{node:b,status:g,originalType:E}=y(i);r.push(b),a.push({originalType:E,type:b.type,variant:b.data.variant,value:Yn(b.data.label),status:g})}return r=Vs(r,t),{nodes:r,governanceIdToNodeIdMap:t,summary:a}},Os=(e,t)=>e.filter(a=>{var r;return(r=a._attributes)==null?void 0:r.edge}).map(a=>Xn(a,t)),Gs=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:a}=Ms(t.root.mxCell),r=Os(t.root.mxCell,n);return{nodes:o,edges:r,summary:a}},Hs=async e=>{let t=await Fn(e),o=Kn(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:a}=o.modeler||{},r=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=a==null?void 0:a.root;if(!r||!s)throw new Error("INVALID_FILE");if(!Object.keys(a.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:a}},Jn=async e=>{try{let t=await Hs(e),{nodes:o,edges:n,summary:a}=Gs(t)||{};return{nodes:o,edges:n,summary:a}}catch(t){throw t}};import{jsx as Ws}from"react/jsx-runtime";var Qn=()=>{let{t:e}=Us(),{toast:t}=zs(),{setNodes:o,setEdges:n,fitView:a}=Bs(),r=i=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=i.map(y=>[y.originalType,y.value,e(`adapter.governance.report.status.${y.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:Ws(Fs,{size:"small",variant:"ghost",onClick:()=>Wn({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:y}=await Jn(i);if(o(g=>g.concat(l)),n(g=>g.concat(c)),a(),y.some(g=>g.status==="unsupported")){r(y);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 Ks}from"lecom-ui";import{useRef as Ys}from"react";import{Fragment as $s,jsx as er,jsxs as Zs}from"react/jsx-runtime";var tr=i=>{var l=i,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:a,onFilesSelected:r}=l,s=ae(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Ys(null),y=g=>{let E=g.target.files;E!=null&&E.length&&r(E),c.current&&(c.current.value="")};return Zs($s,{children:[er(Ks,C(w({onClick:g=>{var E;(E=c.current)==null||E.click(),a==null||a(g)}},s),{children:e})),er("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:y})]})};import{jsx as kt,jsxs as el}from"react/jsx-runtime";var or=({disabled:e=!1})=>{let{t}=Qs(),{toast:o}=Js(),{createDiagram:n}=Qn(),a=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},r=s=>{let i=s[0];if(!i){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(i)};return el(qs,{children:[kt(js,{asChild:!0,children:kt(tr,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:a,onFilesSelected:r,children:kt(ko,{})})}),kt(Xs,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as tl}from"react/jsx-runtime";var eo=({shortcut:e})=>tl("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 ll,DropdownMenu as dl,DropdownMenuContent as cl,DropdownMenuItem as oo,DropdownMenuTrigger as pl,Tooltip as Lt,TooltipContent as Pt,TooltipTrigger as Dt,useTranslation as ul}from"lecom-ui";import{FileCodeIcon as ml,FileImageIcon as gl,FolderOutputIcon as fl,PrinterIcon as El}from"lucide-react";import{useState as bl}from"react";import{useReactFlow as ol}from"@xyflow/react";import{toPng as nr,toSvg as nl}from"html-to-image";import{toast as rl,useTranslation as al}from"lecom-ui";import{useState as il}from"react";var sl=3,to="diagram",rr=()=>{let{t:e}=al(),{getNodes:t}=ol(),{deselectAll:o}=Be(),[n,a]=il({png:!1,html:!1,print:!1}),r=()=>{let{x:y,y:b,width:g,height:E}=bn(t());return{width:g,height:E,style:{width:`${g}px`,height:`${E}px`,transform:`translate(${-y}px, ${-b}px)`}}},s=async(y,b)=>{a(C(w({},n),{[b]:!0})),await o();try{let g=En();if(!g)throw new Error("Flow element not found");let E=r();return await y(g,E)}catch(g){rl({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{a(C(w({},n),{[b]:!1}))}};return{exportAsPng:async(y=to)=>{await s(async(b,g)=>{let E=await nr(b,C(w({},g),{backgroundColor:"#fcfcfc"}));St(E,`${y}.png`)},"png")},exportAsHtml:async(y=to)=>{await s(async(b,g)=>{let E=await nl(b,C(w({},g),{backgroundColor:"#fcfcfc"})),m=`
|