lecom-modeler 0.2.2 → 0.2.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var bi=Object.create;var Tt=Object.defineProperty,yi=Object.defineProperties,hi=Object.getOwnPropertyDescriptor,vi=Object.getOwnPropertyDescriptors,Ni=Object.getOwnPropertyNames,Ft=Object.getOwnPropertySymbols,_i=Object.getPrototypeOf,zo=Object.prototype.hasOwnProperty,En=Object.prototype.propertyIsEnumerable;var fn=(e,t,o)=>t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))zo.call(t,o)&&fn(e,o,t[o]);if(Ft)for(var o of Ft(t))En.call(t,o)&&fn(e,o,t[o]);return e},w=(e,t)=>yi(e,vi(t));var ke=(e,t)=>{var o={};for(var n in e)zo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Ft)for(var n of Ft(e))t.indexOf(n)<0&&En.call(e,n)&&(o[n]=e[n]);return o};var Ti=(e,t)=>{for(var o in t)Tt(e,o,{get:t[o],enumerable:!0})},bn=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ni(t))!zo.call(e,r)&&r!==o&&Tt(e,r,{get:()=>t[r],enumerable:!(n=hi(t,r))||n.enumerable});return e};var xi=(e,t,o)=>(o=e!=null?bi(_i(e)):{},bn(t||!e||!e.__esModule?Tt(o,"default",{value:e,enumerable:!0}):o,e)),wi=e=>bn(Tt({},"__esModule",{value:!0}),e);var is={};Ti(is,{ActivityVariant:()=>$t,ComplexVariant:()=>Xt,ElementType:()=>Kt,ExclusiveVariant:()=>qt,GatewayVariant:()=>he,Modeler:()=>as,RoutingVariant:()=>Zt,useSelectionUtils:()=>gt});module.exports=wi(is);var Wt=require("lecom-ui"),Yt=require("react/jsx-runtime");function yn({children:e}){return(0,Yt.jsxs)(Wt.TooltipProvider,{children:[(0,Yt.jsx)(Wt.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}var J=require("@xyflow/react"),ln=require("lecom-ui"),re=require("react"),Ya=require("use-debounce"),Ho=require("uuid");var Kt=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Kt||{}),$t=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))($t||{}),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||{}),Xt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Xt||{}),qt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(qt||{});var lt=require("lucide-react");var Fe=require("react/jsx-runtime"),jt=({size:e=24,className:t})=>(0,Fe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,Fe.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Fe.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Fe.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Fe.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Uo=require("react/jsx-runtime"),ot=({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:"#f87171",stroke:"#ef4444",strokeWidth:3,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 Ve=require("react/jsx-runtime"),Jt=({size:e=24,className:t})=>(0,Ve.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,Ve.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,Ve.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ve.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ve.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ve.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var nt=require("react/jsx-runtime"),rt=({size:e=24,className:t})=>(0,nt.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,nt.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,nt.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,nt.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var at=require("react/jsx-runtime"),Qt=({size:e=24,className:t})=>(0,at.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,at.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,at.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,at.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var it=require("react/jsx-runtime"),hn=({size:e=24,className:t})=>(0,it.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,it.jsxs)("g",{children:[(0,it.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,it.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var vn=require("clsx"),Nn=require("tailwind-merge");function k(...e){return(0,Nn.twMerge)((0,vn.clsx)(e))}var xt=(e,t)=>e<t?t:e;var wt=require("react/jsx-runtime"),_n=({size:e=24,className:t})=>(0,wt.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,wt.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,wt.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var eo=require("react/jsx-runtime"),Tn=({size:e=24,className:t})=>(0,eo.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,eo.jsx)("g",{children:(0,eo.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 Fo=require("react/jsx-runtime"),to=({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:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:(0,Fo.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 Wo=require("react/jsx-runtime"),Ct=({size:e=24,className:t})=>(0,Wo.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,Wo.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 st=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,st.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,st.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,st.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,st.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Me=require("react/jsx-runtime"),wn=({size:e=24,className:t})=>(0,Me.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,Me.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,Me.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,Me.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,Me.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Me.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var We=require("react/jsx-runtime"),Cn=({size:e=24,className:t})=>(0,We.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,We.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,We.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,We.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,We.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 oo={SCRIPT:{icon:lt.ScrollText},SUBPROCESS:{icon:lt.SquarePlus}};var no={LOOP:{icon:lt.RotateCcw}},he=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(he||{}),ro={EXCLUSIVE:{icon:rt},PARALLEL:{icon:Qt},COMPLEX:{icon:Jt}};var Yo=xi(require("@dagrejs/dagre"),1),kn=require("@xyflow/react"),Ln=require("lodash");var Ci={MIN_WIDTH:36,MIN_HEIGHT:36},Ai={MIN_WIDTH:36,MIN_HEIGHT:36},Ii={MIN_WIDTH:56,MIN_HEIGHT:56},ao={MIN_WIDTH:176,MIN_HEIGHT:96},io={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},so={MIN_WIDTH:176,MIN_HEIGHT:64},Si={MIN_WIDTH:128,MIN_HEIGHT:64},$={START_EVENT:Ci,END_EVENT:Ai,GATEWAY:Ii,TASK:ao,LANE:ae,ANNOTATION:so,UNSUPPORTED:Si};var An=require("lodash");var Le=e=>{var t,o,n,r,a,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(a=e.measured)==null?void 0:a.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},Pe=e=>(0,An.orderBy)(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),In=(e,t)=>{let{x:o,y:n}=Le(e),{x:r,y:a}=Le(t);return{x:o-r,y:n-a}};var dt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),ki=(e,t)=>{let{x:o,y:n}=Le(e),{x:r,y:a}=Le(t),s=o-r,i=n-a;return Math.sqrt(s*s+i*i)},Li=(e,t)=>{let{x:o,y:n,w:r,h:a}=Le(e),{x:s,y:i,w:l,h:c}=Le(t);return o<s+l&&s<o+r&&n<i+c&&i<n+a},At=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Li(e,r)){let a=ki(e,r);a<n&&(n=a,o=r)}return o},Sn=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,a;return Math.max(o,(a=(r=n.measured)==null?void 0:r.width)!=null?a:0)},0);var Pn=(e=[],t=[],o="LR")=>{let n=new Yo.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:a,width:s,height:i})=>n.setNode(a,{width:s,height:i})),t.forEach(a=>n.setEdge(a.source,a.target)),Yo.default.layout(n),{nodes:e.map(a=>{let s=n.node(a.id);return w(_({},a),{position:{x:s.x-a.width/2,y:s.y-a.height/2}})}),edges:t}},Ye=(e,t)=>{var m,y;let o=[...t],n=o.find(E=>E.id===e);if(!n)return o;let r=o.filter(E=>E.parentId===e&&E.type==="LANE");if(r.length===0)return o;let a=(0,Ln.orderBy)(r,["position.y"]),s=Math.max((y=(m=n.measured)==null?void 0:m.width)!=null?y:0,io.MIN_WIDTH),i=Sn(e,a)||ae.MIN_WIDTH,l=Math.max(s,i),c=0,g=0;a.forEach(E=>{var h,v,p,d;o=o.map(x=>x.id===E.id?w(_({},x),{width:l-ae.HEADER_WIDTH,measured:w(_({},x.measured),{width:l-ae.HEADER_WIDTH}),position:{x:ae.HEADER_WIDTH,y:c}}):x),c+=(v=(h=E.measured)==null?void 0:h.height)!=null?v:0,g+=(d=(p=E.measured)==null?void 0:p.height)!=null?d:0}),o=o.map(E=>E.id===e?w(_({},E),{height:g,width:l,measured:w(_({},E.measured),{height:g,width:l})}):E);let f=o.find(E=>E.id===e);return f!=null&&f.parentId&&(o=Ye(f.parentId,o)),o},Dn=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Pi=50,Rn=(e,t=Pi)=>{let o=(0,kn.getNodesBounds)(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Vn=require("zustand"),H=(0,Vn.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 kt=require("@xyflow/react");var Te=require("@xyflow/react");var Ee=require("@xyflow/react"),Ne=require("lecom-ui"),Hn=require("lucide-react");var lo=require("react"),Mn=(0,lo.createContext)(null),On=Mn.Provider,Gn=()=>{let e=(0,lo.useContext)(Mn);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};var Ke=require("react/jsx-runtime"),It=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Ne.useTranslation)(),{getNode:n,getEdge:r,getNodes:a,getEdges:s}=(0,Ee.useReactFlow)(),{onConfigureElement:i}=Gn(),l=u=>{var T,I,b,N,S;return u?u.type==="TASK"&&((T=u.data)==null?void 0:T.variant)==="SUBPROCESS"?{id:u.id,type:"sub_process",variant:g(u),label:(I=u.data)==null?void 0:I.label}:u.type==="GATEWAY"?{id:u.id,type:"gateway",variant:((b=u.data)==null?void 0:b.variant)||"EXCLUSIVE",label:(N=u.data)==null?void 0:N.label}:{id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label}:null},c=u=>{let T=a(),I=s(),b=(0,Ee.getIncomers)(u,T,I);if(b.length===0)return;let N=b[0];return l(N)||void 0},g=u=>{let T=a(),I=s(),b=(0,Ee.getIncomers)(u,T,I),N=(0,Ee.getOutgoers)(u,T,I),S=b.some(C=>C.type==="START_EVENT"),P=N.some(C=>C.type==="END_EVENT");return S?"start":P?"end":"between"},f=u=>{var C,A,L,U;let T=a(),I=s(),b=n(u.source),N=n(u.target);if(!b||!N)return"simple";if((0,Ee.getOutgoers)(b,T,I).some(K=>K.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((C=b.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let K=(A=b.data)==null?void 0:A.variant,X=(L=b.data)==null?void 0:L.attribute;return N.type==="TASK"&&((U=N.data)==null?void 0:U.variant)==="SUBPROCESS"?"to_sub_process":K==="SCRIPT"?"script":X==="LOOP"?"loop":"simple"}return"simple"},m=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="COMPLEX")return;let I=a(),b=s(),N=(0,Ee.getIncomers)(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,U;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((U=A.data)==null?void 0:U.attribute)==="LOOP"&&(P=!0))}),S&&P)return"script_loop";if(S)return"script";if(P)return"loop"},y=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let I=a(),b=s(),N=(0,Ee.getIncomers)(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,U;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((U=A.data)==null?void 0:U.attribute)==="LOOP"&&(P=!0))}),S)return"script";if(P)return"loop"},E=u=>{var P,C;if(u.type!=="GATEWAY")return;let T=a(),I=s(),b=(0,Ee.getIncomers)(u,T,I),N=!1,S=!1;if(b.forEach(A=>{var L,U;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(N=!0),((U=A.data)==null?void 0:U.attribute)==="LOOP"&&(S=!0))}),((P=u.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&S)return"script_loop";if(N)return"script";if(S)return"loop"}else if(((C=u.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(N)return"script";if(S)return"loop"}},h=u=>(0,Ee.getOutgoers)(u,a(),s()).map(b=>{var N,S;return{id:b.id,type:b.type,variant:(N=b.data)==null?void 0:N.variant,label:(S=b.data)==null?void 0:S.label}}),v=u=>s().filter(b=>b.source===u.id).map(b=>{var N;return{id:b.id,type:"routing",variant:f(b),label:(N=b.data)==null?void 0:N.label,target:n(b.target)}}),p=()=>{var I,b,N,S,P,C;let u=n(e);if(!u)return;let T=c(u);if(u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"){i==null||i({id:u.id,type:"sub_process",variant:g(u),label:(b=u.data)==null?void 0:b.label,origin:T,targets:h(u),edgeTargets:v(u)}),console.log({id:u.id,type:"sub_process",variant:g(u),label:(N=u.data)==null?void 0:N.label,origin:T,targets:h(u),edgeTargets:v(u)});return}if(u.type!=="GATEWAY"){i==null||i({id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label,origin:T,targets:h(u),edgeTargets:v(u)});return}i==null||i({id:u.id,type:"gateway",variant:((P=u.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(C=u.data)==null?void 0:C.label,origin:T,subVariant:E(u),targets:h(u)})},d=()=>{let u=r(e);if(u){let T=f(u),I;T==="complex"?I=m(u):T==="exclusive"&&(I=y(u));let b=n(u.source),N=b&&l(b)||void 0;i==null||i({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)}),console.log({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)})}};return(0,Ke.jsxs)(Ne.Tooltip,{children:[(0,Ke.jsx)(Ne.TooltipTrigger,{asChild:!0,children:(0,Ke.jsx)(Ne.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":p();break;case"edge":d();break}},children:(0,Ke.jsx)(Hn.PencilIcon,{size:16})})}),(0,Ke.jsx)(Ne.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var Bn=require("@xyflow/react"),_e=require("lecom-ui"),zn=require("lucide-react"),$e=require("react/jsx-runtime"),co=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,_e.useTranslation)(),{deleteElements:n}=(0,Bn.useReactFlow)();return(0,$e.jsxs)(_e.Tooltip,{children:[(0,$e.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,$e.jsx)(_e.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:(0,$e.jsx)(zn.TrashIcon,{size:16})})}),(0,$e.jsx)(_e.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var St=require("react/jsx-runtime"),pt=n=>{var r=n,{edgeId:e,edgeType:t}=r,o=ke(r,["edgeId","edgeType"]);var i;let a=[{component:(0,St.jsx)(co,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:(0,St.jsx)(It,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return(0,St.jsx)("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(i=s[t])==null?void 0:i.map((l,c)=>(0,St.jsx)("div",{children:l.component},c))}))};var Ze=require("react/jsx-runtime"),uo={type:"ANNOTATION_EDGE",zIndex:2e3},Un=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,selected:i,data:l})=>{let c=(0,Te.useNodes)(),{zoom:g}=(0,Te.useViewport)(),{isMultipleSelection:f}=H(),m=c.find(x=>x.id===t),y=c.find(x=>x.id===o),[E,h,v]=(0,Te.getStraightPath)({sourceX:n,sourceY:r,targetX:a,targetY:s}),p=i||(m==null?void 0:m.selected)||(y==null?void 0:y.selected),d=1/g;return(0,Ze.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":p}),children:[(0,Ze.jsx)(Te.BaseEdge,{id:e,path:E,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":p&&!(l!=null&&l.hasError)})}),(0,Ze.jsx)(Te.EdgeLabelRenderer,{children:(0,Ze.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&&!f&&(0,Ze.jsx)(pt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};var ie=require("@xyflow/react"),Fn=require("react");var Xe=require("react");var $o=require("react/jsx-runtime"),ee=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:r,className:a,style:s})=>{let i=(0,Xe.useRef)(null),[l,c]=(0,Xe.useState)(!1);(0,Xe.useEffect)(()=>{c(n!=null?n:!1)},[n]),(0,Xe.useEffect)(()=>{if(l&&i.current){i.current.focus();let E=document.createRange();E.selectNodeContents(i.current),E.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(E))}},[l]);let g=E=>{if(E.stopPropagation(),!l){c(!0);return}if(!i.current)return;let h=document.createRange();h.selectNodeContents(i.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(h))},f=E=>{let h=E.currentTarget.innerText.trim(),v=t&&h.length>=t,p=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=E.ctrlKey||E.metaKey,x=d&&E.key==="a",u=d&&E.key==="c",T=d&&E.key==="x",I=d&&E.key==="v";function b(S){return/\w/.test(S)}if(h.length===0&&!b(E.key)&&!p.includes(E.key)&&!d){E.preventDefault();return}v&&(p.includes(E.key)||x||u||T||I||E.preventDefault())},m=E=>{if(!t)return;E.preventDefault();let h=E.clipboardData.getData("text/plain"),v=E.currentTarget.innerText,p=window.getSelection();if(!p||p.rangeCount===0)return;let d=p.getRangeAt(0);if((v.substring(0,d.startOffset)+h+v.substring(d.endOffset)).length>t){let u=t-(v.length-(d.endOffset-d.startOffset)),T=h.substring(0,Math.max(0,u));T&&(d.deleteContents(),d.insertNode(document.createTextNode(T)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(h)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d)},y=E=>{c(!1);let h=E.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),E.currentTarget.innerText=h,r==null||r(),h!==e&&(o==null||o(h))};return(0,$o.jsx)("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:g,children:(0,$o.jsx)("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:f,onPaste:m,onBlur:y,children:e})})};var Oe=require("react/jsx-runtime"),xe={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:ie.MarkerType.ArrowClosed},markerEnd:{type:ie.MarkerType.Arrow},data:{label:""}},Wn=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=(0,ie.useNodes)(),{zoom:m}=(0,ie.useViewport)(),{updateEdgeData:y}=(0,ie.useReactFlow)(),{isMultipleSelection:E}=H(),[h,v]=(0,Fn.useState)(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=(0,ie.getSmoothStepPath)({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return(0,Oe.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[(0,Oe.jsx)(ie.BaseEdge,{id:e,path:x,markerEnd:`url(#${b})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),(0,Oe.jsx)(ie.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(${u}px, ${T}px)`},children:[g&&!E&&(0,Oe.jsx)(pt,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${S})`}}),N&&(0,Oe.jsx)(ee,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};var mo=e=>e.some(t=>t.type==="START_EVENT"),go=(e,t,o)=>{var a;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((a=n.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},fo=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},Eo=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},bo=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.target===e).some(a=>{let s=t.find(i=>i.id===a.source);return(s==null?void 0:s.type)==="START_EVENT"})},yo=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).some(a=>{let s=t.find(i=>i.id===a.target);return(s==null?void 0:s.type)==="END_EVENT"})},ho=(e,t)=>t.filter(n=>n.source===e).length>0,vo=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).length>=2};var Di=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!go(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!vo(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:!(fo(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Eo(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(bo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(yo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(ho(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"})],Yn=e=>{for(let t of Di){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ri=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:go(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:mo(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fo(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Eo(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:yo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ho(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:vo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Kn=e=>{let t=Ri.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var $n=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=(0,kt.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 Yn(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?(0,kt.addEdge)(_(_({},s),uo),i):(0,kt.addEdge)(_(_({},s),xe),i)})}}};var Zo=require("react"),or=require("lecom-ui"),nr=require("@xyflow/react");var Lt=(e=[])=>e.filter(t=>t.type==="START_EVENT"),qe=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ge=(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"}),Xn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),No=(e=[])=>e.filter(t=>t.type==="GATEWAY"),qn=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),me=(e,t=[])=>t.filter(o=>o.source===e),Pt=(e,t=[])=>t.filter(o=>o.target===e),jn=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(a=>a.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},Jn=(e,t)=>{let o=me(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(a=>a.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Qn=e=>e?/\w/g.test(e.trim()):!1,M=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},we=(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)}},er=(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 Dt=[{id:"start_event_not_found",validate:e=>{let t=Lt(e.nodes);return M({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=qe(e.nodes);return M({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Lt(e.nodes),o=t.length===1;if(t.length===0)return M({isValid:!0});if(!o)return M({isValid:!1,nodeIds:t.map(a=>a.id)});let n=me(t[0].id,e.edges);if(!(n.length<=1)){let a=[...t.map(s=>s.id),...n.map(s=>s.target)];return M({isValid:!1,nodeIds:[...new Set(a)]})}return M({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ge(e.nodes),o=we(t,n=>me(n.id,e.edges).length<=2);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ge(e.nodes),o=we(t,n=>!!n.label&&n.label.trim()!=="");return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ge(e.nodes),n=we(o,r=>!r.label||r.label.length<=60);return M({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ge(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let a=r.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(a=>n.push(a.id));return M({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=No(e.nodes),o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Lt(e.nodes),...qe(e.nodes)],o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(r.id,i.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=qe(e.nodes),o=[],n=[];for(let r of t){let a=Pt(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=me(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return M({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=qn(e.nodes),o=we(t,r=>me(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>me(r,e.edges).map(a=>a.id));return M({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ge(e.nodes),o=we(t,n=>!n.label||Qn(n.label));return M({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 M({isValid:!0});let t=qe(e.nodes)[0];if(!t)return M({isValid:!0});let o=Pt(t.id,e.edges);if(!o.length)return M({isValid:!0});let r=Ge(e.nodes).filter(l=>o.some(c=>c.source===l.id)),a=we(r,l=>!jn(l.id,e));return M({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ge(e.nodes),o=qe(e.nodes)[0];if(!o)return M({isValid:!0});let n=t.filter(l=>{let c=Pt(l.id,e.edges),g=me(l.id,e.edges),f=c.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.source))==null?void 0:E.type)==="START_EVENT"}),m=g.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.target))==null?void 0:E.type)==="END_EVENT"});return f&&m}),r=Pt(o.id,e.edges),a=r.length>1,s=r.map(l=>l.source),i={isValid:n.length===0&&!a,nodeIds:[...n.map(l=>l.id),...a?s:[]]};return M(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=No(e.nodes),o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(r.id,i.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=No(e.nodes),o=we(t,n=>me(n.id,e.edges).length>=1);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Lt(e.nodes),...qe(e.nodes)],o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return M({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=we(t,n=>!Jn(n.id,e));return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Xn(e.nodes),o=we(t,n=>{var r,a;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((a=n.properties)==null?void 0:a.subprocessRef)!==""});return M({isValid:o.isValid,nodeIds:o.invalidIds})}}];var tr=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Dt){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var rr=()=>{let{t:e}=(0,or.useTranslation)(),[t,o]=(0,Zo.useState)(null),{setNodes:n,setEdges:r,getNodes:a,getEdges:s}=(0,nr.useReactFlow)(),[i,l]=(0,Zo.useState)(!1);return{validationResult:t,validateDiagram:m=>{let y=er(m.nodes,m.edges),E=tr(y),h=E.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:E.isValid,errors:h}},handleValidationComplete:m=>{if(o(m),!m)return;let y=[],E=[];m.errors.forEach(b=>{b.nodeIds&&b.nodeIds.length>0&&b.nodeIds.forEach(N=>y.push(N)),b.edgeIds&&b.edgeIds.length>0&&b.edgeIds.forEach(N=>E.push(N))});let h=[...new Set(y)];n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})}))),r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})})));let v=a(),p=s(),d=new Set(h),x=new Set;m.errors.forEach(b=>{var P,C;let N=Dt.find(A=>A.id===b.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=b.edgeIds)==null||P.forEach(A=>x.add(A)),(C=b.nodeIds)==null||C.forEach(A=>{p.forEach(L=>{(L.source===A||L.target===A)&&x.add(L.id)})}))});let u=new Set,T=new Set,I=new Set;v.forEach(b=>{b.type==="START_EVENT"?u.add(b.id):b.type==="END_EVENT"&&T.add(b.id)}),p.forEach(b=>{u.has(b.source)&&I.add(b.target),T.has(b.target)&&I.add(b.source)}),I.forEach(b=>{var N,S;if(d.has(b)){let P=(N=m.errors.find(A=>{var L;return(L=A.nodeIds)==null?void 0:L.includes(b)}))==null?void 0:N.id;((S=Dt.find(A=>A.id===P))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(A=>{A.source===b&&T.has(A.target)&&(d.add(A.target),x.add(A.id)),A.target===b&&u.has(A.source)&&(d.add(A.source),x.add(A.id))})}}),d.size>0&&n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:d.has(N.id)})}))),x.size>0&&r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),r(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},isAutoValidationEnabled:i}};var sr=require("@xyflow/react"),lr=require("lecom-ui"),dr=require("react"),Xo=require("uuid");var _o=(e,t)=>{let n=e.filter(a=>a.type==="TASK").map(a=>{var i;let s=(i=a.data)==null?void 0:i.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(a=>a>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},To=(e,t)=>{let n=t.filter(i=>i.type==="TASK").map(i=>{var l;return(l=i.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),a=n.filter(i=>i===r||i.startsWith(`${r} (`)).map(i=>{if(i===r)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;a.includes(s);)s++;return`${r} (${s})`};var Vi=15,ar="bpmn:selection",Mi=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",a=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||a},ir=e=>{if(!Mi(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},cr=({offset:e=Vi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=(0,sr.useReactFlow)(),{t:a}=(0,lr.useTranslation)();(0,dr.useEffect)(()=>{let s=l=>{var h,v;if(!ir(l))return;let c=t(),g=n(),f=c.filter(p=>p.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let m=g.filter(p=>f.some(d=>d.id===p.source)&&f.some(d=>d.id===p.target)),E=JSON.stringify({nodes:f,edges:m});(h=l.clipboardData)==null||h.setData(ar,E),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},i=l=>{var v,p;if(!ir(l))return;let c=(v=l.clipboardData)==null?void 0:v.getData(ar);if(!c)return;l.preventDefault(),l.stopPropagation();let g;try{g=JSON.parse(c)}catch(d){return}if(!((p=g.nodes)!=null&&p.length))return;let f=new Map,m=t(),y=[],E=g.nodes.map(d=>{var T;let x=(0,Xo.v7)();f.set(d.id,x);let u=w(_({},d),{id:x,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let I=(T=d.data)==null?void 0:T.label,b=To(I||a("bpmn.task.label.prefix"),[...m,...y]);u.data=w(_({},d.data),{label:b})}return y.push(u),u}),h=g.edges.map(d=>w(_({},d),{id:(0,Xo.v7)(),selected:!0,source:f.get(d.source)||d.source,target:f.get(d.target)||d.target}));o(d=>[...d.map(x=>w(_({},x),{selected:!1})),...E]),r(d=>[...d.map(x=>w(_({},x),{selected:!1})),...h])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,r,e,a])};var xo=require("@xyflow/react"),fr=require("lecom-ui"),qo=require("uuid");var pr=require("zustand"),ut=(0,pr.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var de=require("@xyflow/react"),ur=require("react");var He=require("react/jsx-runtime"),Id={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:de.MarkerType.Arrow},data:{label:""}},mr=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=(0,de.useNodes)(),{zoom:m}=(0,de.useViewport)(),{updateEdgeData:y}=(0,de.useReactFlow)(),{isMultipleSelection:E}=H(),[h,v]=(0,ur.useState)(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=(0,de.getSmoothStepPath)({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return(0,He.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[(0,He.jsx)(de.BaseEdge,{id:e,path:x,markerEnd:`url(#${b})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),(0,He.jsx)(de.EdgeLabelRenderer,{children:(0,He.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${T}px)`},children:[g&&!E&&(0,He.jsx)(pt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),N&&(0,He.jsx)(ee,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};var Rt=require("react/jsx-runtime"),gr=({fromX:e,fromY:t,toX:o,toY:n})=>(0,Rt.jsxs)("g",{children:[(0,Rt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),(0,Rt.jsx)("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var Er=({nodes:e,setNodes:t,setEdges:o})=>{let n=(0,xo.useStoreApi)(),{draggableNode:r,setDraggableNode:a}=ut(),{getInternalNode:s,screenToFlowPosition:i}=(0,xo.useReactFlow)(),{t:l}=(0,fr.useTranslation)(),c=p=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(x=>x.map(u=>w(_({},u),{className:u.id===p?d:""})))},g=()=>{let{nodeLookup:p}=n.getState();return Array.from(p.values())},f=p=>{let d=s(p.id),x=g();if(p.type==="LANE"){if(dt({parentId:p.id,nodes:e,includeTypes:["LANE"]})){c();return}let S=x.filter(A=>A.id!==p.id&&A.type==="LANE"&&!A.parentId),P=At(d,S);if(!P){c();return}if(dt({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let T=x.filter(N=>N.id!==p.id&&N.type==="LANE"),I=At(d,T);if(!I){c();return}if(dt({parentId:I.id,nodes:e,includeTypes:["LANE"]})){c();return}c(I.id)},m=p=>{p.preventDefault(),p.dataTransfer.dropEffect="move"},y=(p,d)=>{p.preventDefault(),f(d)},E=(p,d,x)=>{var S,P;let u=C=>C.map(A=>w(_({},A),{className:void 0}));if(p.parentId===d.id){let C=Ye(d.id,x);t(Pe(u(C)));return}if(p.type==="LANE"){if(dt({parentId:d.id,nodes:x,excludeTypes:["LANE"]}))return;let L=x.filter(X=>X.parentId===d.id).reduce((X,Qe)=>{var Ue,et;return X+((et=(Ue=Qe.measured)==null?void 0:Ue.height)!=null?et:0)},0),U={x:ae.HEADER_WIDTH,y:L},K=x.map(X=>X.id===p.id?w(_({},X),{parentId:d.id,position:U,className:void 0}):w(_({},X),{className:void 0}));K=Ye(d.id,K),t(Pe(K));return}if(dt({parentId:d.id,nodes:x,includeTypes:["LANE"]})){let C;if(p.parentId){let L=s(p.parentId),{x:U,y:K}=Le(L);C={x:U+((S=p.position.x)!=null?S:0),y:K+((P=p.position.y)!=null?P:0)}}let A=x.map(L=>L.id===p.id?w(_({},L),{position:C!=null?C:L.position,parentId:void 0,className:void 0}):w(_({},L),{className:void 0}));t(Pe(A));return}let b=In(p,d),N=x.map(C=>C.id===p.id?w(_({},C),{parentId:d.id,position:b,className:void 0}):w(_({},C),{className:void 0}));t(Pe(N))};return{onDragOver:m,onDrop:p=>{if(p.preventDefault(),!(r!=null&&r.type))return;let d=i({x:p.clientX,y:p.clientY}),x={width:$[r.type].MIN_WIDTH,height:$[r.type].MIN_HEIGHT},u={id:(0,qo.v7)(),type:r.type,position:d,measured:x,data:{label:r.type==="TASK"?_o(e,l("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute}},T=w(_({},u),{internals:{positionAbsolute:d}}),I=g(),b=r.type==="LANE",N=I.filter(C=>b?C.type==="LANE"&&!C.parentId:C.type==="LANE"),S=At(T,N);S?E(T,S,[...I,T]):t(C=>{let A=C.concat(u);return Pe(A)});let P=p.dataTransfer.getData("sourceId");if(P){let C={id:(0,qo.v7)(),source:P,target:u.id};if(r.type==="ANNOTATION"){o(A=>A.concat(_(_({},C),uo)));return}o(A=>A.concat(_(_({},C),xe)))}a(null)},onNodeDrag:y,onNodeDragStop:async(p,d)=>{var S,P;let{nodeLookup:x}=n.getState(),u=s(d.id),T=Array.from(x.values()),I=d.type==="LANE",b=T.filter(C=>C.id!==d.id&&(I?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=At(u,b);if(N){E(u,N,T);return}if(d.parentId){let C=s(d.parentId),{x:A,y:L}=Le(C),U={x:A+((S=d.position.x)!=null?S:0),y:L+((P=d.position.y)!=null?P:0)},K=e.map(X=>X.id===d.id?w(_({},X),{position:U,parentId:void 0}):X);K=Ye(d.parentId,K),t(Pe(K))}}}};var yr=require("@xyflow/react"),Vt=require("react");function br(e,t,o=5){var l,c,g,f,m,y,E,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},r=t.find(v=>v.id===e.id);if(!r||!e.position)return n;let a={left:e.position.x,right:e.position.x+((c=(l=r.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((f=(g=r.measured)==null?void 0:g.height)!=null?f:0),width:(y=(m=r.measured)==null?void 0:m.width)!=null?y:0,height:(h=(E=r.measured)==null?void 0:E.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==r.id).reduce((v,p)=>{var C,A,L,U,K,X,Qe,Ue;let d={left:p.position.x,right:p.position.x+((A=(C=p.measured)==null?void 0:C.width)!=null?A:0),top:p.position.y,bottom:p.position.y+((U=(L=p.measured)==null?void 0:L.height)!=null?U:0),width:(X=(K=p.measured)==null?void 0:K.width)!=null?X:0,height:(Ue=(Qe=p.measured)==null?void 0:Qe.height)!=null?Ue:0},x=Math.abs(a.left-d.left);x<i&&(v.snapPosition.x=d.left,v.vertical=d.left,i=x);let u=Math.abs(a.right-d.right);u<i&&(v.snapPosition.x=d.right-a.width,v.vertical=d.right,i=u);let T=Math.abs(a.left-d.right);T<i&&(v.snapPosition.x=d.right,v.vertical=d.right,i=T);let I=Math.abs(a.right-d.left);I<i&&(v.snapPosition.x=d.left-a.width,v.vertical=d.left,i=I);let b=Math.abs(a.top-d.top);b<s&&(v.snapPosition.y=d.top,v.horizontal=d.top,s=b);let N=Math.abs(a.bottom-d.top);N<s&&(v.snapPosition.y=d.top-a.height,v.horizontal=d.top,s=N);let S=Math.abs(a.bottom-d.bottom);S<s&&(v.snapPosition.y=d.bottom-a.height,v.horizontal=d.bottom,s=S);let P=Math.abs(a.top-d.bottom);return P<s&&(v.snapPosition.y=d.bottom,v.horizontal=d.bottom,s=P),v},n)}var hr=()=>{let[e,t]=(0,Vt.useState)(void 0),[o,n]=(0,Vt.useState)(void 0),r=(0,Vt.useCallback)((a,s)=>{var i,l;if(t(void 0),n(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let c=br(a[0],s);a[0].position.x=(i=c.snapPosition.x)!=null?i:a[0].position.x,a[0].position.y=(l=c.snapPosition.y)!=null?l:a[0].position.y,t(c.horizontal),n(c.vertical)}return(0,yr.applyNodeChanges)(a,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:r}};var xr=require("@xyflow/react"),jo=require("uuid");var Nr={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},_r={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},vr=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],s="",i="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",i=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",i=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},Oi=e=>{e=e||"";let t=e.trim().split(`
1
+ "use strict";var bi=Object.create;var Tt=Object.defineProperty,yi=Object.defineProperties,hi=Object.getOwnPropertyDescriptor,vi=Object.getOwnPropertyDescriptors,Ni=Object.getOwnPropertyNames,Ft=Object.getOwnPropertySymbols,_i=Object.getPrototypeOf,zo=Object.prototype.hasOwnProperty,En=Object.prototype.propertyIsEnumerable;var fn=(e,t,o)=>t in e?Tt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))zo.call(t,o)&&fn(e,o,t[o]);if(Ft)for(var o of Ft(t))En.call(t,o)&&fn(e,o,t[o]);return e},w=(e,t)=>yi(e,vi(t));var ke=(e,t)=>{var o={};for(var n in e)zo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Ft)for(var n of Ft(e))t.indexOf(n)<0&&En.call(e,n)&&(o[n]=e[n]);return o};var Ti=(e,t)=>{for(var o in t)Tt(e,o,{get:t[o],enumerable:!0})},bn=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ni(t))!zo.call(e,r)&&r!==o&&Tt(e,r,{get:()=>t[r],enumerable:!(n=hi(t,r))||n.enumerable});return e};var xi=(e,t,o)=>(o=e!=null?bi(_i(e)):{},bn(t||!e||!e.__esModule?Tt(o,"default",{value:e,enumerable:!0}):o,e)),wi=e=>bn(Tt({},"__esModule",{value:!0}),e);var is={};Ti(is,{ActivityVariant:()=>$t,ComplexVariant:()=>Xt,ElementType:()=>Kt,ExclusiveVariant:()=>qt,GatewayVariant:()=>he,Modeler:()=>as,RoutingVariant:()=>Zt,useSelectionUtils:()=>gt});module.exports=wi(is);var Wt=require("lecom-ui"),Yt=require("react/jsx-runtime");function yn({children:e}){return(0,Yt.jsxs)(Wt.TooltipProvider,{children:[(0,Yt.jsx)(Wt.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}var J=require("@xyflow/react"),ln=require("lecom-ui"),re=require("react"),Ya=require("use-debounce"),Ho=require("uuid");var Kt=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Kt||{}),$t=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))($t||{}),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||{}),Xt=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Xt||{}),qt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(qt||{});var lt=require("lucide-react");var Fe=require("react/jsx-runtime"),jt=({size:e=24,className:t})=>(0,Fe.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,Fe.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Fe.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Fe.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Fe.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Uo=require("react/jsx-runtime"),ot=({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:"#f87171",stroke:"#ef4444",strokeWidth:3,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 Ve=require("react/jsx-runtime"),Jt=({size:e=24,className:t})=>(0,Ve.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,Ve.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,Ve.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ve.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ve.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ve.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var nt=require("react/jsx-runtime"),rt=({size:e=24,className:t})=>(0,nt.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,nt.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,nt.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,nt.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var at=require("react/jsx-runtime"),Qt=({size:e=24,className:t})=>(0,at.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,at.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,at.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,at.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var it=require("react/jsx-runtime"),hn=({size:e=24,className:t})=>(0,it.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,it.jsxs)("g",{children:[(0,it.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,it.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var vn=require("clsx"),Nn=require("tailwind-merge");function k(...e){return(0,Nn.twMerge)((0,vn.clsx)(e))}var xt=(e,t)=>e<t?t:e;var wt=require("react/jsx-runtime"),_n=({size:e=24,className:t})=>(0,wt.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,wt.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,wt.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var eo=require("react/jsx-runtime"),Tn=({size:e=24,className:t})=>(0,eo.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,eo.jsx)("g",{children:(0,eo.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 Fo=require("react/jsx-runtime"),to=({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:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:(0,Fo.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 Wo=require("react/jsx-runtime"),Ct=({size:e=24,className:t})=>(0,Wo.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,Wo.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 st=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,st.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,st.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,st.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,st.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Me=require("react/jsx-runtime"),wn=({size:e=24,className:t})=>(0,Me.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,Me.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,Me.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,Me.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,Me.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Me.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var We=require("react/jsx-runtime"),Cn=({size:e=24,className:t})=>(0,We.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,We.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,We.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,We.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,We.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 oo={SCRIPT:{icon:lt.ScrollText},SUBPROCESS:{icon:lt.SquarePlus}};var no={LOOP:{icon:lt.RotateCcw}},he=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(he||{}),ro={EXCLUSIVE:{icon:rt},PARALLEL:{icon:Qt},COMPLEX:{icon:Jt}};var Yo=xi(require("@dagrejs/dagre"),1),kn=require("@xyflow/react"),Ln=require("lodash");var Ci={MIN_WIDTH:36,MIN_HEIGHT:36},Ai={MIN_WIDTH:36,MIN_HEIGHT:36},Ii={MIN_WIDTH:56,MIN_HEIGHT:56},ao={MIN_WIDTH:176,MIN_HEIGHT:96},io={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ae={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},so={MIN_WIDTH:176,MIN_HEIGHT:64},Si={MIN_WIDTH:128,MIN_HEIGHT:64},$={START_EVENT:Ci,END_EVENT:Ai,GATEWAY:Ii,TASK:ao,LANE:ae,ANNOTATION:so,UNSUPPORTED:Si};var An=require("lodash");var Le=e=>{var t,o,n,r,a,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(a=e.measured)==null?void 0:a.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},Pe=e=>(0,An.orderBy)(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),In=(e,t)=>{let{x:o,y:n}=Le(e),{x:r,y:a}=Le(t);return{x:o-r,y:n-a}};var dt=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),ki=(e,t)=>{let{x:o,y:n}=Le(e),{x:r,y:a}=Le(t),s=o-r,i=n-a;return Math.sqrt(s*s+i*i)},Li=(e,t)=>{let{x:o,y:n,w:r,h:a}=Le(e),{x:s,y:i,w:l,h:c}=Le(t);return o<s+l&&s<o+r&&n<i+c&&i<n+a},At=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Li(e,r)){let a=ki(e,r);a<n&&(n=a,o=r)}return o},Sn=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,a;return Math.max(o,(a=(r=n.measured)==null?void 0:r.width)!=null?a:0)},0);var Pn=(e=[],t=[],o="LR")=>{let n=new Yo.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:a,width:s,height:i})=>n.setNode(a,{width:s,height:i})),t.forEach(a=>n.setEdge(a.source,a.target)),Yo.default.layout(n),{nodes:e.map(a=>{let s=n.node(a.id);return w(_({},a),{position:{x:s.x-a.width/2,y:s.y-a.height/2}})}),edges:t}},Ye=(e,t)=>{var m,y;let o=[...t],n=o.find(E=>E.id===e);if(!n)return o;let r=o.filter(E=>E.parentId===e&&E.type==="LANE");if(r.length===0)return o;let a=(0,Ln.orderBy)(r,["position.y"]),s=Math.max((y=(m=n.measured)==null?void 0:m.width)!=null?y:0,io.MIN_WIDTH),i=Sn(e,a)||ae.MIN_WIDTH,l=Math.max(s,i),c=0,g=0;a.forEach(E=>{var h,v,p,d;o=o.map(x=>x.id===E.id?w(_({},x),{width:l-ae.HEADER_WIDTH,measured:w(_({},x.measured),{width:l-ae.HEADER_WIDTH}),position:{x:ae.HEADER_WIDTH,y:c}}):x),c+=(v=(h=E.measured)==null?void 0:h.height)!=null?v:0,g+=(d=(p=E.measured)==null?void 0:p.height)!=null?d:0}),o=o.map(E=>E.id===e?w(_({},E),{height:g,width:l,measured:w(_({},E.measured),{height:g,width:l})}):E);let f=o.find(E=>E.id===e);return f!=null&&f.parentId&&(o=Ye(f.parentId,o)),o},Dn=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Pi=50,Rn=(e,t=Pi)=>{let o=(0,kn.getNodesBounds)(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Vn=require("zustand"),H=(0,Vn.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 kt=require("@xyflow/react");var Te=require("@xyflow/react");var Ee=require("@xyflow/react"),Ne=require("lecom-ui"),Hn=require("lucide-react");var lo=require("react"),Mn=(0,lo.createContext)(null),On=Mn.Provider,Gn=()=>{let e=(0,lo.useContext)(Mn);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};var Ke=require("react/jsx-runtime"),It=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Ne.useTranslation)(),{getNode:n,getEdge:r,getNodes:a,getEdges:s}=(0,Ee.useReactFlow)(),{onConfigureElement:i}=Gn(),l=u=>{var T,I,b,N,S;return u?u.type==="TASK"&&((T=u.data)==null?void 0:T.variant)==="SUBPROCESS"?{id:u.id,type:"sub_process",variant:g(u),label:(I=u.data)==null?void 0:I.label}:u.type==="GATEWAY"?{id:u.id,type:"gateway",variant:((b=u.data)==null?void 0:b.variant)||"EXCLUSIVE",label:(N=u.data)==null?void 0:N.label}:{id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label}:null},c=u=>{let T=a(),I=s(),b=(0,Ee.getIncomers)(u,T,I);if(b.length===0)return;let N=b[0];return l(N)||void 0},g=u=>{let T=a(),I=s(),b=(0,Ee.getIncomers)(u,T,I),N=(0,Ee.getOutgoers)(u,T,I),S=b.some(C=>C.type==="START_EVENT"),P=N.some(C=>C.type==="END_EVENT");return S?"start":P?"end":"between"},f=u=>{var C,A,L,U;let T=a(),I=s(),b=n(u.source),N=n(u.target);if(!b||!N)return"simple";if((0,Ee.getOutgoers)(b,T,I).some(K=>K.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((C=b.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let K=(A=b.data)==null?void 0:A.variant,X=(L=b.data)==null?void 0:L.attribute;return N.type==="TASK"&&((U=N.data)==null?void 0:U.variant)==="SUBPROCESS"?"to_sub_process":K==="SCRIPT"?"script":X==="LOOP"?"loop":"simple"}return"simple"},m=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="COMPLEX")return;let I=a(),b=s(),N=(0,Ee.getIncomers)(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,U;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((U=A.data)==null?void 0:U.attribute)==="LOOP"&&(P=!0))}),S&&P)return"script_loop";if(S)return"script";if(P)return"loop"},y=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let I=a(),b=s(),N=(0,Ee.getIncomers)(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,U;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((U=A.data)==null?void 0:U.attribute)==="LOOP"&&(P=!0))}),S)return"script";if(P)return"loop"},E=u=>{var P,C;if(u.type!=="GATEWAY")return;let T=a(),I=s(),b=(0,Ee.getIncomers)(u,T,I),N=!1,S=!1;if(b.forEach(A=>{var L,U;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(N=!0),((U=A.data)==null?void 0:U.attribute)==="LOOP"&&(S=!0))}),((P=u.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&S)return"script_loop";if(N)return"script";if(S)return"loop"}else if(((C=u.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(N)return"script";if(S)return"loop"}},h=u=>(0,Ee.getOutgoers)(u,a(),s()).map(b=>{var N,S;return{id:b.id,type:b.type,variant:(N=b.data)==null?void 0:N.variant,label:(S=b.data)==null?void 0:S.label}}),v=u=>s().filter(b=>b.source===u.id).map(b=>{var N;return{id:b.id,type:"routing",variant:f(b),label:(N=b.data)==null?void 0:N.label,target:n(b.target)}}),p=()=>{var I,b,N,S,P,C;let u=n(e);if(!u)return;let T=c(u);if(u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"){i==null||i({id:u.id,type:"sub_process",variant:g(u),label:(b=u.data)==null?void 0:b.label,origin:T,targets:h(u),edgeTargets:v(u)}),console.log({id:u.id,type:"sub_process",variant:g(u),label:(N=u.data)==null?void 0:N.label,origin:T,targets:h(u),edgeTargets:v(u)});return}if(u.type!=="GATEWAY"){i==null||i({id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label,origin:T,targets:h(u),edgeTargets:v(u)});return}i==null||i({id:u.id,type:"gateway",variant:((P=u.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(C=u.data)==null?void 0:C.label,origin:T,subVariant:E(u),targets:h(u)})},d=()=>{let u=r(e);if(u){let T=f(u),I;T==="complex"?I=m(u):T==="exclusive"&&(I=y(u));let b=n(u.source),N=b&&l(b)||void 0;i==null||i({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)}),console.log({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)})}};return(0,Ke.jsxs)(Ne.Tooltip,{children:[(0,Ke.jsx)(Ne.TooltipTrigger,{asChild:!0,children:(0,Ke.jsx)(Ne.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":p();break;case"edge":d();break}},children:(0,Ke.jsx)(Hn.Settings,{size:16})})}),(0,Ke.jsx)(Ne.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var Bn=require("@xyflow/react"),_e=require("lecom-ui"),zn=require("lucide-react"),$e=require("react/jsx-runtime"),co=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,_e.useTranslation)(),{deleteElements:n}=(0,Bn.useReactFlow)();return(0,$e.jsxs)(_e.Tooltip,{children:[(0,$e.jsx)(_e.TooltipTrigger,{asChild:!0,children:(0,$e.jsx)(_e.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:(0,$e.jsx)(zn.TrashIcon,{size:16})})}),(0,$e.jsx)(_e.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var St=require("react/jsx-runtime"),pt=n=>{var r=n,{edgeId:e,edgeType:t}=r,o=ke(r,["edgeId","edgeType"]);var i;let a=[{component:(0,St.jsx)(co,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:(0,St.jsx)(It,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return(0,St.jsx)("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(i=s[t])==null?void 0:i.map((l,c)=>(0,St.jsx)("div",{children:l.component},c))}))};var Ze=require("react/jsx-runtime"),uo={type:"ANNOTATION_EDGE",zIndex:2e3},Un=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,selected:i,data:l})=>{let c=(0,Te.useNodes)(),{zoom:g}=(0,Te.useViewport)(),{isMultipleSelection:f}=H(),m=c.find(x=>x.id===t),y=c.find(x=>x.id===o),[E,h,v]=(0,Te.getStraightPath)({sourceX:n,sourceY:r,targetX:a,targetY:s}),p=i||(m==null?void 0:m.selected)||(y==null?void 0:y.selected),d=1/g;return(0,Ze.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":p}),children:[(0,Ze.jsx)(Te.BaseEdge,{id:e,path:E,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":p&&!(l!=null&&l.hasError)})}),(0,Ze.jsx)(Te.EdgeLabelRenderer,{children:(0,Ze.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&&!f&&(0,Ze.jsx)(pt,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};var ie=require("@xyflow/react"),Fn=require("react");var Xe=require("react");var $o=require("react/jsx-runtime"),ee=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:r,className:a,style:s})=>{let i=(0,Xe.useRef)(null),[l,c]=(0,Xe.useState)(!1);(0,Xe.useEffect)(()=>{c(n!=null?n:!1)},[n]),(0,Xe.useEffect)(()=>{if(l&&i.current){i.current.focus();let E=document.createRange();E.selectNodeContents(i.current),E.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(E))}},[l]);let g=E=>{if(E.stopPropagation(),!l){c(!0);return}if(!i.current)return;let h=document.createRange();h.selectNodeContents(i.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(h))},f=E=>{let h=E.currentTarget.innerText.trim(),v=t&&h.length>=t,p=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=E.ctrlKey||E.metaKey,x=d&&E.key==="a",u=d&&E.key==="c",T=d&&E.key==="x",I=d&&E.key==="v";function b(S){return/\w/.test(S)}if(h.length===0&&!b(E.key)&&!p.includes(E.key)&&!d){E.preventDefault();return}v&&(p.includes(E.key)||x||u||T||I||E.preventDefault())},m=E=>{if(!t)return;E.preventDefault();let h=E.clipboardData.getData("text/plain"),v=E.currentTarget.innerText,p=window.getSelection();if(!p||p.rangeCount===0)return;let d=p.getRangeAt(0);if((v.substring(0,d.startOffset)+h+v.substring(d.endOffset)).length>t){let u=t-(v.length-(d.endOffset-d.startOffset)),T=h.substring(0,Math.max(0,u));T&&(d.deleteContents(),d.insertNode(document.createTextNode(T)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(h)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d)},y=E=>{c(!1);let h=E.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),E.currentTarget.innerText=h,r==null||r(),h!==e&&(o==null||o(h))};return(0,$o.jsx)("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:g,children:(0,$o.jsx)("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:f,onPaste:m,onBlur:y,children:e})})};var Oe=require("react/jsx-runtime"),xe={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:ie.MarkerType.ArrowClosed},markerEnd:{type:ie.MarkerType.Arrow},data:{label:""}},Wn=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=(0,ie.useNodes)(),{zoom:m}=(0,ie.useViewport)(),{updateEdgeData:y}=(0,ie.useReactFlow)(),{isMultipleSelection:E}=H(),[h,v]=(0,Fn.useState)(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=(0,ie.getSmoothStepPath)({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return(0,Oe.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[(0,Oe.jsx)(ie.BaseEdge,{id:e,path:x,markerEnd:`url(#${b})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),(0,Oe.jsx)(ie.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(${u}px, ${T}px)`},children:[g&&!E&&(0,Oe.jsx)(pt,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${S})`}}),N&&(0,Oe.jsx)(ee,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};var mo=e=>e.some(t=>t.type==="START_EVENT"),go=(e,t,o)=>{var a;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((a=n.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},fo=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},Eo=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},bo=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.target===e).some(a=>{let s=t.find(i=>i.id===a.source);return(s==null?void 0:s.type)==="START_EVENT"})},yo=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).some(a=>{let s=t.find(i=>i.id===a.target);return(s==null?void 0:s.type)==="END_EVENT"})},ho=(e,t)=>t.filter(n=>n.source===e).length>0,vo=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).length>=2};var Di=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!go(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!vo(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:!(fo(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Eo(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(bo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(yo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(ho(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"})],Yn=e=>{for(let t of Di){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ri=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:go(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:mo(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:fo(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Eo(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:bo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:yo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ho(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:vo(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],Kn=e=>{let t=Ri.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var $n=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=(0,kt.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 Yn(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?(0,kt.addEdge)(_(_({},s),uo),i):(0,kt.addEdge)(_(_({},s),xe),i)})}}};var Zo=require("react"),or=require("lecom-ui"),nr=require("@xyflow/react");var Lt=(e=[])=>e.filter(t=>t.type==="START_EVENT"),qe=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Ge=(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"}),Xn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),No=(e=[])=>e.filter(t=>t.type==="GATEWAY"),qn=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),me=(e,t=[])=>t.filter(o=>o.source===e),Pt=(e,t=[])=>t.filter(o=>o.target===e),jn=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(a=>a.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},Jn=(e,t)=>{let o=me(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(a=>a.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Qn=e=>e?/\w/g.test(e.trim()):!1,M=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},we=(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)}},er=(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 Dt=[{id:"start_event_not_found",validate:e=>{let t=Lt(e.nodes);return M({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=qe(e.nodes);return M({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Lt(e.nodes),o=t.length===1;if(t.length===0)return M({isValid:!0});if(!o)return M({isValid:!1,nodeIds:t.map(a=>a.id)});let n=me(t[0].id,e.edges);if(!(n.length<=1)){let a=[...t.map(s=>s.id),...n.map(s=>s.target)];return M({isValid:!1,nodeIds:[...new Set(a)]})}return M({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Ge(e.nodes),o=we(t,n=>me(n.id,e.edges).length<=2);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Ge(e.nodes),o=we(t,n=>!!n.label&&n.label.trim()!=="");return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Ge(e.nodes),n=we(o,r=>!r.label||r.label.length<=60);return M({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Ge(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let a=r.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(a=>n.push(a.id));return M({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=No(e.nodes),o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Lt(e.nodes),...qe(e.nodes)],o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(r.id,i.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=qe(e.nodes),o=[],n=[];for(let r of t){let a=Pt(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=me(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return M({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=qn(e.nodes),o=we(t,r=>me(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>me(r,e.edges).map(a=>a.id));return M({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Ge(e.nodes),o=we(t,n=>!n.label||Qn(n.label));return M({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 M({isValid:!0});let t=qe(e.nodes)[0];if(!t)return M({isValid:!0});let o=Pt(t.id,e.edges);if(!o.length)return M({isValid:!0});let r=Ge(e.nodes).filter(l=>o.some(c=>c.source===l.id)),a=we(r,l=>!jn(l.id,e));return M({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Ge(e.nodes),o=qe(e.nodes)[0];if(!o)return M({isValid:!0});let n=t.filter(l=>{let c=Pt(l.id,e.edges),g=me(l.id,e.edges),f=c.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.source))==null?void 0:E.type)==="START_EVENT"}),m=g.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.target))==null?void 0:E.type)==="END_EVENT"});return f&&m}),r=Pt(o.id,e.edges),a=r.length>1,s=r.map(l=>l.source),i={isValid:n.length===0&&!a,nodeIds:[...n.map(l=>l.id),...a?s:[]]};return M(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=No(e.nodes),o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(r.id,i.id),n.push(s.id))}}return M({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=No(e.nodes),o=we(t,n=>me(n.id,e.edges).length>=1);return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Lt(e.nodes),...qe(e.nodes)],o=[],n=[];for(let r of t){let a=me(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return M({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=we(t,n=>!Jn(n.id,e));return M({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Xn(e.nodes),o=we(t,n=>{var r,a;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((a=n.properties)==null?void 0:a.subprocessRef)!==""});return M({isValid:o.isValid,nodeIds:o.invalidIds})}}];var tr=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Dt){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var rr=()=>{let{t:e}=(0,or.useTranslation)(),[t,o]=(0,Zo.useState)(null),{setNodes:n,setEdges:r,getNodes:a,getEdges:s}=(0,nr.useReactFlow)(),[i,l]=(0,Zo.useState)(!1);return{validationResult:t,validateDiagram:m=>{let y=er(m.nodes,m.edges),E=tr(y),h=E.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:E.isValid,errors:h}},handleValidationComplete:m=>{if(o(m),!m)return;let y=[],E=[];m.errors.forEach(b=>{b.nodeIds&&b.nodeIds.length>0&&b.nodeIds.forEach(N=>y.push(N)),b.edgeIds&&b.edgeIds.length>0&&b.edgeIds.forEach(N=>E.push(N))});let h=[...new Set(y)];n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})}))),r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})})));let v=a(),p=s(),d=new Set(h),x=new Set;m.errors.forEach(b=>{var P,C;let N=Dt.find(A=>A.id===b.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=b.edgeIds)==null||P.forEach(A=>x.add(A)),(C=b.nodeIds)==null||C.forEach(A=>{p.forEach(L=>{(L.source===A||L.target===A)&&x.add(L.id)})}))});let u=new Set,T=new Set,I=new Set;v.forEach(b=>{b.type==="START_EVENT"?u.add(b.id):b.type==="END_EVENT"&&T.add(b.id)}),p.forEach(b=>{u.has(b.source)&&I.add(b.target),T.has(b.target)&&I.add(b.source)}),I.forEach(b=>{var N,S;if(d.has(b)){let P=(N=m.errors.find(A=>{var L;return(L=A.nodeIds)==null?void 0:L.includes(b)}))==null?void 0:N.id;((S=Dt.find(A=>A.id===P))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(A=>{A.source===b&&T.has(A.target)&&(d.add(A.target),x.add(A.id)),A.target===b&&u.has(A.source)&&(d.add(A.source),x.add(A.id))})}}),d.size>0&&n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:d.has(N.id)})}))),x.size>0&&r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),r(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},isAutoValidationEnabled:i}};var sr=require("@xyflow/react"),lr=require("lecom-ui"),dr=require("react"),Xo=require("uuid");var _o=(e,t)=>{let n=e.filter(a=>a.type==="TASK").map(a=>{var i;let s=(i=a.data)==null?void 0:i.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(a=>a>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},To=(e,t)=>{let n=t.filter(i=>i.type==="TASK").map(i=>{var l;return(l=i.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),a=n.filter(i=>i===r||i.startsWith(`${r} (`)).map(i=>{if(i===r)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;a.includes(s);)s++;return`${r} (${s})`};var Vi=15,ar="bpmn:selection",Mi=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",a=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||a},ir=e=>{if(!Mi(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},cr=({offset:e=Vi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=(0,sr.useReactFlow)(),{t:a}=(0,lr.useTranslation)();(0,dr.useEffect)(()=>{let s=l=>{var h,v;if(!ir(l))return;let c=t(),g=n(),f=c.filter(p=>p.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let m=g.filter(p=>f.some(d=>d.id===p.source)&&f.some(d=>d.id===p.target)),E=JSON.stringify({nodes:f,edges:m});(h=l.clipboardData)==null||h.setData(ar,E),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},i=l=>{var v,p;if(!ir(l))return;let c=(v=l.clipboardData)==null?void 0:v.getData(ar);if(!c)return;l.preventDefault(),l.stopPropagation();let g;try{g=JSON.parse(c)}catch(d){return}if(!((p=g.nodes)!=null&&p.length))return;let f=new Map,m=t(),y=[],E=g.nodes.map(d=>{var T;let x=(0,Xo.v7)();f.set(d.id,x);let u=w(_({},d),{id:x,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let I=(T=d.data)==null?void 0:T.label,b=To(I||a("bpmn.task.label.prefix"),[...m,...y]);u.data=w(_({},d.data),{label:b})}return y.push(u),u}),h=g.edges.map(d=>w(_({},d),{id:(0,Xo.v7)(),selected:!0,source:f.get(d.source)||d.source,target:f.get(d.target)||d.target}));o(d=>[...d.map(x=>w(_({},x),{selected:!1})),...E]),r(d=>[...d.map(x=>w(_({},x),{selected:!1})),...h])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,r,e,a])};var xo=require("@xyflow/react"),fr=require("lecom-ui"),qo=require("uuid");var pr=require("zustand"),ut=(0,pr.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var de=require("@xyflow/react"),ur=require("react");var He=require("react/jsx-runtime"),Id={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:de.MarkerType.Arrow},data:{label:""}},mr=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=(0,de.useNodes)(),{zoom:m}=(0,de.useViewport)(),{updateEdgeData:y}=(0,de.useReactFlow)(),{isMultipleSelection:E}=H(),[h,v]=(0,ur.useState)(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=(0,de.getSmoothStepPath)({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return(0,He.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[(0,He.jsx)(de.BaseEdge,{id:e,path:x,markerEnd:`url(#${b})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),(0,He.jsx)(de.EdgeLabelRenderer,{children:(0,He.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${T}px)`},children:[g&&!E&&(0,He.jsx)(pt,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),N&&(0,He.jsx)(ee,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};var Rt=require("react/jsx-runtime"),gr=({fromX:e,fromY:t,toX:o,toY:n})=>(0,Rt.jsxs)("g",{children:[(0,Rt.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),(0,Rt.jsx)("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var Er=({nodes:e,setNodes:t,setEdges:o})=>{let n=(0,xo.useStoreApi)(),{draggableNode:r,setDraggableNode:a}=ut(),{getInternalNode:s,screenToFlowPosition:i}=(0,xo.useReactFlow)(),{t:l}=(0,fr.useTranslation)(),c=p=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(x=>x.map(u=>w(_({},u),{className:u.id===p?d:""})))},g=()=>{let{nodeLookup:p}=n.getState();return Array.from(p.values())},f=p=>{let d=s(p.id),x=g();if(p.type==="LANE"){if(dt({parentId:p.id,nodes:e,includeTypes:["LANE"]})){c();return}let S=x.filter(A=>A.id!==p.id&&A.type==="LANE"&&!A.parentId),P=At(d,S);if(!P){c();return}if(dt({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let T=x.filter(N=>N.id!==p.id&&N.type==="LANE"),I=At(d,T);if(!I){c();return}if(dt({parentId:I.id,nodes:e,includeTypes:["LANE"]})){c();return}c(I.id)},m=p=>{p.preventDefault(),p.dataTransfer.dropEffect="move"},y=(p,d)=>{p.preventDefault(),f(d)},E=(p,d,x)=>{var S,P;let u=C=>C.map(A=>w(_({},A),{className:void 0}));if(p.parentId===d.id){let C=Ye(d.id,x);t(Pe(u(C)));return}if(p.type==="LANE"){if(dt({parentId:d.id,nodes:x,excludeTypes:["LANE"]}))return;let L=x.filter(X=>X.parentId===d.id).reduce((X,Qe)=>{var Ue,et;return X+((et=(Ue=Qe.measured)==null?void 0:Ue.height)!=null?et:0)},0),U={x:ae.HEADER_WIDTH,y:L},K=x.map(X=>X.id===p.id?w(_({},X),{parentId:d.id,position:U,className:void 0}):w(_({},X),{className:void 0}));K=Ye(d.id,K),t(Pe(K));return}if(dt({parentId:d.id,nodes:x,includeTypes:["LANE"]})){let C;if(p.parentId){let L=s(p.parentId),{x:U,y:K}=Le(L);C={x:U+((S=p.position.x)!=null?S:0),y:K+((P=p.position.y)!=null?P:0)}}let A=x.map(L=>L.id===p.id?w(_({},L),{position:C!=null?C:L.position,parentId:void 0,className:void 0}):w(_({},L),{className:void 0}));t(Pe(A));return}let b=In(p,d),N=x.map(C=>C.id===p.id?w(_({},C),{parentId:d.id,position:b,className:void 0}):w(_({},C),{className:void 0}));t(Pe(N))};return{onDragOver:m,onDrop:p=>{if(p.preventDefault(),!(r!=null&&r.type))return;let d=i({x:p.clientX,y:p.clientY}),x={width:$[r.type].MIN_WIDTH,height:$[r.type].MIN_HEIGHT},u={id:(0,qo.v7)(),type:r.type,position:d,measured:x,data:{label:r.type==="TASK"?_o(e,l("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute}},T=w(_({},u),{internals:{positionAbsolute:d}}),I=g(),b=r.type==="LANE",N=I.filter(C=>b?C.type==="LANE"&&!C.parentId:C.type==="LANE"),S=At(T,N);S?E(T,S,[...I,T]):t(C=>{let A=C.concat(u);return Pe(A)});let P=p.dataTransfer.getData("sourceId");if(P){let C={id:(0,qo.v7)(),source:P,target:u.id};if(r.type==="ANNOTATION"){o(A=>A.concat(_(_({},C),uo)));return}o(A=>A.concat(_(_({},C),xe)))}a(null)},onNodeDrag:y,onNodeDragStop:async(p,d)=>{var S,P;let{nodeLookup:x}=n.getState(),u=s(d.id),T=Array.from(x.values()),I=d.type==="LANE",b=T.filter(C=>C.id!==d.id&&(I?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=At(u,b);if(N){E(u,N,T);return}if(d.parentId){let C=s(d.parentId),{x:A,y:L}=Le(C),U={x:A+((S=d.position.x)!=null?S:0),y:L+((P=d.position.y)!=null?P:0)},K=e.map(X=>X.id===d.id?w(_({},X),{position:U,parentId:void 0}):X);K=Ye(d.parentId,K),t(Pe(K))}}}};var yr=require("@xyflow/react"),Vt=require("react");function br(e,t,o=5){var l,c,g,f,m,y,E,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},r=t.find(v=>v.id===e.id);if(!r||!e.position)return n;let a={left:e.position.x,right:e.position.x+((c=(l=r.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((f=(g=r.measured)==null?void 0:g.height)!=null?f:0),width:(y=(m=r.measured)==null?void 0:m.width)!=null?y:0,height:(h=(E=r.measured)==null?void 0:E.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==r.id).reduce((v,p)=>{var C,A,L,U,K,X,Qe,Ue;let d={left:p.position.x,right:p.position.x+((A=(C=p.measured)==null?void 0:C.width)!=null?A:0),top:p.position.y,bottom:p.position.y+((U=(L=p.measured)==null?void 0:L.height)!=null?U:0),width:(X=(K=p.measured)==null?void 0:K.width)!=null?X:0,height:(Ue=(Qe=p.measured)==null?void 0:Qe.height)!=null?Ue:0},x=Math.abs(a.left-d.left);x<i&&(v.snapPosition.x=d.left,v.vertical=d.left,i=x);let u=Math.abs(a.right-d.right);u<i&&(v.snapPosition.x=d.right-a.width,v.vertical=d.right,i=u);let T=Math.abs(a.left-d.right);T<i&&(v.snapPosition.x=d.right,v.vertical=d.right,i=T);let I=Math.abs(a.right-d.left);I<i&&(v.snapPosition.x=d.left-a.width,v.vertical=d.left,i=I);let b=Math.abs(a.top-d.top);b<s&&(v.snapPosition.y=d.top,v.horizontal=d.top,s=b);let N=Math.abs(a.bottom-d.top);N<s&&(v.snapPosition.y=d.top-a.height,v.horizontal=d.top,s=N);let S=Math.abs(a.bottom-d.bottom);S<s&&(v.snapPosition.y=d.bottom-a.height,v.horizontal=d.bottom,s=S);let P=Math.abs(a.top-d.bottom);return P<s&&(v.snapPosition.y=d.bottom,v.horizontal=d.bottom,s=P),v},n)}var hr=()=>{let[e,t]=(0,Vt.useState)(void 0),[o,n]=(0,Vt.useState)(void 0),r=(0,Vt.useCallback)((a,s)=>{var i,l;if(t(void 0),n(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let c=br(a[0],s);a[0].position.x=(i=c.snapPosition.x)!=null?i:a[0].position.x,a[0].position.y=(l=c.snapPosition.y)!=null?l:a[0].position.y,t(c.horizontal),n(c.vertical)}return(0,yr.applyNodeChanges)(a,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:r}};var xr=require("@xyflow/react"),jo=require("uuid");var Nr={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},_r={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},vr=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],s="",i="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",i=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",i=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},Oi=e=>{e=e||"";let t=e.trim().split(`
2
2
  `),o={},n=[];return t.forEach(r=>{r=r||"";let a=r.trim().split("-->");if(a.length!==2){console.warn("Invalid number of steps");return}let s=vr(a[0],o),i=vr(a[1],o);s&&i&&n.push({sourceId:s.step,targetId:i.step,label:s.edgeLabel||i.edgeLabel||""})}),{components:o,connections:n}},Tr=e=>{let{components:t,connections:o}=Oi(e);return{nodes:t,edges:o}};var wr=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,xr.useReactFlow)();return{createDiagram:r=>{let{nodes:a,edges:s}=Tr(r),i=[],l=new Map;for(let[m,y]of Object.entries(a)){let E=(0,jo.v7)(),h=Nr[y.type],v=_r[y.type];l.set(m,E);let p=$[h].MIN_WIDTH,d=$[h].MIN_HEIGHT;i.push({id:E,type:h,data:{label:y.label||"",variant:v,attribute:""},position:{x:0,y:0},width:p,height:d,measured:{width:p,height:d}})}let c=[];for(let m of s){let y=w(_({},xe),{id:(0,jo.v7)(),source:l.get(m.sourceId)||m.sourceId,target:l.get(m.targetId)||m.targetId});c.push(y)}let{nodes:g,edges:f}=Pn(i,c);e(g),t(f),o()}}};var wo=require("react"),Gi={origin:"*",debug:!1};function Cr(e,t=Gi){let{origin:o,debug:n}=t,r=(0,wo.useCallback)((a,s)=>{n&&console.debug("[postMessage] sending:",{type:a,payload:s}),window.parent.postMessage({type:a,payload:s},o||"*")},[o,n]);return(0,wo.useEffect)(()=>{let a=s=>{let{type:i,data:l}=s.data||{};n&&console.debug("[postMessage] received:",s.data),i&&e[i]&&e[i](l)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[e,n]),{sendMessage:r}}var Ar=require("@xyflow/react");var Ir=(e,t)=>{let{getNodes:o,getEdges:n}=(0,Ar.useReactFlow)();return{selectElement:s=>{let i=o().map(c=>w(_({},c),{selected:c.id===s})),l=n().map(c=>w(_({},c),{selected:c.id===s}));return e(i),t(l),!0},isReady:()=>!0}};var kr=require("@xyflow/react"),De=require("react"),Lr=require("use-debounce"),Hi={nodes:[],edges:[]},Bi=500,Sr=10,Pr=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,kr.useReactFlow)(),[r,a]=(0,De.useState)([Hi]),[s,i]=(0,De.useState)(0),l=r[s],c=s>0,g=s<r.length-1,f=(0,De.useCallback)(d=>{o(r[d].nodes),n(r[d].edges)},[r,o,n]),m=(0,De.useCallback)(()=>{if(s>0){let d=s-1;i(d),f(d)}},[s,f]),y=(0,De.useCallback)(()=>{if(s<r.length-1){let d=s+1;i(d),f(d)}},[r,s,f]),E=d=>{let u=[...r.slice(0,s+1),d],T=u.length>Sr?u.slice(u.length-Sr):u;a(T),i(T.length-1)},h=(0,Lr.useDebouncedCallback)(()=>{let d=e(),x=t(),u={nodes:d,edges:x};JSON.stringify(l)!==JSON.stringify(u)&&E(u)},Bi),v=(0,De.useCallback)(d=>{if(d==="forceSave"){h();return}d.some(u=>u.type!=="select")&&h()},[h]),p=(0,De.useCallback)(()=>{a([]),i(0)},[]);return{undo:m,redo:y,saveHistory:v,canUndo:c,canRedo:g,clearHistory:p}};var Jo=require("react/jsx-runtime"),Qo=({id:e,className:t})=>(0,Jo.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,Jo.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var mt=require("react/jsx-runtime"),Dr=()=>(0,mt.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,mt.jsxs)("defs",{children:[(0,mt.jsx)(Qo,{id:"sequence-edge-marker",className:"text-grey-400"}),(0,mt.jsx)(Qo,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var nn=require("@xyflow/react"),j=require("lecom-ui"),bt=require("lucide-react"),Gt=require("react");var Rr=require("@xyflow/react"),zi=e=>({unselectAll:e.unselectNodesAndEdges}),gt=()=>{let{unselectAll:e}=(0,Rr.useStore)(zi);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};var Ce=require("lecom-ui");var Mt=(p=>(p.START_EVENT="START_EVENT",p.END_EVENT="END_EVENT",p.TASK="TASK",p.SUBPROCESS="SUBPROCESS",p.GATEWAY="GATEWAY",p.ANNOTATION="ANNOTATION",p.CONNECTION="CONNECTION",p.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",p.ACTIVITY="ACTIVITY",p.PROCESS_INTERFACE="PROCESS_INTERFACE",p.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",p.VARIANT_ACTIVITY="VARIANT_ACTIVITY",p.AUTO_ACTIVITY="AUTO_ACTIVITY",p.DATA_STORE="DATA_STORE",p.DATA_OBJECT="DATA_OBJECT",p.DATA_OUTPUT="DATA_OUTPUT",p.DATA_INPUT="DATA_INPUT",p))(Mt||{});var $r=require("@xyflow/react"),Et=require("lecom-ui");var Vr=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var a;t((a=r.target)==null?void 0:a.result)},n.onerror=r=>{var a;o((a=r.target)==null?void 0:a.error)},n.readAsText(e)});function Mr({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
3
3
  `),a=encodeURI(r);Co(a,`${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 Yr=require("uuid");var en=require("xml-js");var Ui={compact:!0,spaces:4},Fi=e=>e.replaceAll(`
4
4
  `,"&#xA;");function Or(e,t=Ui){if(e)return JSON.parse((0,en.xml2json)(e,w(_({},t),{attributeValueFn:Fi})))}function Gr(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var zr=require("uuid");var Ac={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Hr={script:"SCRIPT",subprocess:"SUBPROCESS"},Br={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var ft=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:a}=n,s=Number(r._attributes.width),i=Number(r._attributes.height);return{id:n.id,type:t,data:{label:a||"",variant:o,attribute:""},position:{x:Number(r._attributes.x),y:Number(r._attributes.y)},width:s,height:i,measured:{width:s,height:i}}},Yi=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=$.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=$.START_EVENT.MIN_HEIGHT,{node:ft({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ki=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=$.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=$.END_EVENT.MIN_HEIGHT,{node:ft({cell:e,type:"END_EVENT"}),status:n,originalType:o}},$i=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Hr[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=xt(e.mxGeometry._attributes.width,$.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=xt(e.mxGeometry._attributes.height,$.TASK.MIN_HEIGHT),{node:ft({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},Zi=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Br[o],r=["none","inclusive","event-based"],a="imported";return r.includes(o)&&(a="adapted"),e.mxGeometry._attributes.width=$.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=$.GATEWAY.MIN_HEIGHT,{node:ft({cell:e,type:"GATEWAY",variant:n}),status:a,originalType:t}},Xi=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=xt(e.mxGeometry._attributes.width,$.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=xt(e.mxGeometry._attributes.height,$.ANNOTATION.MIN_HEIGHT),{node:ft({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Ur=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=$.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=$.UNSUPPORTED.MIN_HEIGHT,{node:ft({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Fr=(e,t)=>{let{source:o,target:n}=e._attributes;return w(_({},xe),{id:(0,zr.v7)(),source:t.get(o)||o,target:t.get(n)||n})},Wr={TASK:$i,GATEWAY:Zi,START_EVENT:Yi,END_EVENT:Ki,ANNOTATION:Xi};var qi=e=>{var s;let t=new Map,o=Object.values(Mt),n=e.filter(i=>{var l;return o.includes((l=i._attributes)==null?void 0:l.type)}),r=[],a=[];for(let i of n){let l=(0,Yr.v7)(),{type:c}=i._attributes,g=Wr[c]||Ur;t.set((s=i._attributes)==null?void 0:s.id,l),i._attributes.id=l;let{node:f,status:m,originalType:y}=g(i);r.push(f),a.push({originalType:y,type:f.type,variant:f.data.variant,value:Gr(f.data.label),status:m})}return{nodes:r,governanceIdToNodeIdMap:t,summary:a}},ji=(e,t)=>e.filter(r=>{var a;return(a=r._attributes)==null?void 0:a.edge}).map(r=>Fr(r,t)),Ji=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=qi(t.root.mxCell),a=ji(t.root.mxCell,n);return{nodes:o,edges:a,summary:r}},Qi=async e=>{let t=await Vr(e),o=Or(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},a=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!a||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Kr=async e=>{try{let t=await Qi(e),{nodes:o,edges:n,summary:r}=Ji(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Xr=require("react/jsx-runtime"),Zr=()=>{let{t:e}=(0,Et.useTranslation)(),{toast:t}=(0,Et.useNotificationToast)(),{setNodes:o,setEdges:n,fitView:r}=(0,$r.useReactFlow)(),a=i=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=i.map(g=>[g.originalType,g.value,e(`adapter.governance.report.status.${g.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Xr.jsx)(Et.Button,{size:"small",variant:"ghost",onClick:()=>Mr({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{createDiagram:async i=>{try{let{nodes:l,edges:c,summary:g}=await Kr(i);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r(),g.some(m=>m.status==="unsupported")){a(g);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};var qr=require("lecom-ui"),jr=require("react");var je=require("react/jsx-runtime"),Jr=i=>{var l=i,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:a}=l,s=ke(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,jr.useRef)(null),g=m=>{let y=m.target.files;y!=null&&y.length&&a(y),c.current&&(c.current.value="")};return(0,je.jsxs)(je.Fragment,{children:[(0,je.jsx)(qr.Button,w(_({onClick:m=>{var y;(y=c.current)==null||y.click(),r==null||r(m)}},s),{children:e})),(0,je.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:g})]})};var Je=require("react/jsx-runtime"),Qr=({disabled:e=!1})=>{let{t}=(0,Ce.useTranslation)(),{toast:o}=(0,Ce.useNotificationToast)(),{createDiagram:n}=Zr(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},a=s=>{let i=s[0];if(!i){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(i)};return(0,Je.jsxs)(Ce.Tooltip,{children:[(0,Je.jsx)(Ce.TooltipTrigger,{asChild:!0,children:(0,Je.jsx)(Jr,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:a,children:(0,Je.jsx)(hn,{})})}),(0,Je.jsx)(Ce.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var ea=require("react/jsx-runtime"),tn=({shortcut:e})=>(0,ea.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 R=require("lecom-ui"),Be=require("lucide-react"),ra=require("react");var ta=require("@xyflow/react"),Ot=require("html-to-image"),Ao=require("lecom-ui"),oa=require("react");var es=3,on="diagram",na=()=>{let{t:e}=(0,Ao.useTranslation)(),{getNodes:t}=(0,ta.useReactFlow)(),{deselectAll:o}=gt(),[n,r]=(0,oa.useState)({png:!1,html:!1,print:!1}),a=()=>{let{x:g,y:f,width:m,height:y}=Rn(t());return{width:m,height:y,style:{width:`${m}px`,height:`${y}px`,transform:`translate(${-g}px, ${-f}px)`}}},s=async(g,f)=>{r(w(_({},n),{[f]:!0})),await o();try{let m=Dn();if(!m)throw new Error("Flow element not found");let y=a();return await g(m,y)}catch(m){(0,Ao.toast)({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(w(_({},n),{[f]:!1}))}};return{exportAsPng:async(g=on)=>{await s(async(f,m)=>{let y=await(0,Ot.toPng)(f,w(_({},m),{backgroundColor:"#fcfcfc"}));Co(y,`${g}.png`)},"png")},exportAsHtml:async(g=on)=>{await s(async(f,m)=>{let y=await(0,Ot.toSvg)(f,w(_({},m),{backgroundColor:"#fcfcfc"})),E=`
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var _a=Object.defineProperty,Ta=Object.defineProperties;var xa=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var wo=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable;var xo=(e,t,o)=>t in e?_a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))wo.call(t,o)&&xo(e,o,t[o]);if(Xe)for(var o of Xe(t))Co.call(t,o)&&xo(e,o,t[o]);return e},w=(e,t)=>Ta(e,xa(t));var ae=(e,t)=>{var o={};for(var n in e)wo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Xe)for(var n of Xe(e))t.indexOf(n)<0&&Co.call(e,n)&&(o[n]=e[n]);return o};import{TooltipProvider as wa,Notification as Ca}from"lecom-ui";import{jsx as Aa,jsxs as Ia}from"react/jsx-runtime";function Ao({children:e}){return Ia(wa,{children:[Aa(Ca,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as nc,MiniMap as rc,ReactFlow as ac,ReactFlowProvider as ic,SelectionMode as sc,useEdgesState as lc,useNodesState as dc,useOnSelectionChange as cc,useReactFlow as pc}from"@xyflow/react";import{i18n as Xr}from"lecom-ui";import{forwardRef as uc,useCallback as fo,useEffect as yo,useImperativeHandle as mc,useRef as gc,useState as fc}from"react";import{useDebouncedCallback as Ec}from"use-debounce";import{v7 as Eo}from"uuid";var Bt=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Bt||{}),zt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(zt||{}),Ut=(l=>(l.SIMPLE="simple",l.LOOP="loop",l.SCRIPT="script",l.COMPLEX="complex",l.EXCLUSIVE="exclusive",l.PARALLEL="parallel",l.FINAL="final",l.TO_SUB_PROCESS="to_sub_process",l))(Ut||{}),Ft=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ft||{}),Wt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Wt||{});import{RotateCcw as Ba,ScrollText as za,SquarePlus as Ua}from"lucide-react";import{jsx as qe,jsxs as Sa}from"react/jsx-runtime";var je=({size:e=24,className:t})=>Sa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[qe("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),qe("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),qe("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),qe("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Io}from"react/jsx-runtime";var ve=({size:e=24,className:t})=>Io("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#f87171",stroke:"#ef4444",strokeWidth:3,className:t,children:Io("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Pe,jsxs as ka}from"react/jsx-runtime";var Je=({size:e=24,className:t})=>ka("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Pe("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yt,jsxs as La}from"react/jsx-runtime";var Ne=({size:e=24,className:t})=>La("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Yt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Yt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Yt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Kt,jsxs as Pa}from"react/jsx-runtime";var Qe=({size:e=24,className:t})=>Pa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Kt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Kt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Kt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $t,jsxs as Da}from"react/jsx-runtime";var So=({size:e=24,className:t})=>$t("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Da("g",{children:[$t("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),$t("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ra}from"clsx";import{twMerge as Va}from"tailwind-merge";function k(...e){return Va(Ra(e))}var De=(e,t)=>e<t?t:e;import{jsx as ko,jsxs as Ma}from"react/jsx-runtime";var Lo=({size:e=24,className:t})=>Ma("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:k("stroke-2",t),children:[ko("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),ko("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zt}from"react/jsx-runtime";var Po=({size:e=24,className:t})=>Zt("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Zt("g",{children:Zt("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as Do}from"react/jsx-runtime";var et=({size:e=24,className:t})=>Do("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:Do("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ro}from"react/jsx-runtime";var Re=({size:e=24,className:t})=>Ro("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:k("stroke-2",t),children:Ro("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Xt,jsxs as Oa}from"react/jsx-runtime";var Vo=({size:e=24,className:t})=>Oa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Xt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ve,jsxs as Ga}from"react/jsx-runtime";var Mo=({size:e=24,className:t})=>Ga("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Ve("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as tt,jsxs as Ha}from"react/jsx-runtime";var Oo=({size:e=24,className:t})=>Ha("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[tt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),tt("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),tt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),tt("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var D=(i=>(i.START_EVENT="START_EVENT",i.END_EVENT="END_EVENT",i.TASK="TASK",i.LANE="LANE",i.GATEWAY="GATEWAY",i.ANNOTATION="ANNOTATION",i.UNSUPPORTED="UNSUPPORTED",i))(D||{});var ot={SCRIPT:{icon:za},SUBPROCESS:{icon:Ua}};var nt={LOOP:{icon:Ba}},ee=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ee||{}),rt={EXCLUSIVE:{icon:Ne},PARALLEL:{icon:Qe},COMPLEX:{icon:Je}};import Bo from"@dagrejs/dagre";import{getNodesBounds as qa}from"@xyflow/react";import{orderBy as ja}from"lodash";var Fa={MIN_WIDTH:36,MIN_HEIGHT:36},Wa={MIN_WIDTH:36,MIN_HEIGHT:36},Ya={MIN_WIDTH:56,MIN_HEIGHT:56},at={MIN_WIDTH:176,MIN_HEIGHT:96},it={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},K={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},st={MIN_WIDTH:176,MIN_HEIGHT:64},Ka={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:Fa,END_EVENT:Wa,GATEWAY:Ya,TASK:at,LANE:K,ANNOTATION:st,UNSUPPORTED:Ka};import{orderBy as $a}from"lodash";var ie=e=>{var t,o,n,r,a,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(a=e.measured)==null?void 0:a.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},se=e=>$a(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),Go=(e,t)=>{let{x:o,y:n}=ie(e),{x:r,y:a}=ie(t);return{x:o-r,y:n-a}};var _e=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Za=(e,t)=>{let{x:o,y:n}=ie(e),{x:r,y:a}=ie(t),s=o-r,i=n-a;return Math.sqrt(s*s+i*i)},Xa=(e,t)=>{let{x:o,y:n,w:r,h:a}=ie(e),{x:s,y:i,w:l,h:c}=ie(t);return o<s+l&&s<o+r&&n<i+c&&i<n+a},Me=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Xa(e,r)){let a=Za(e,r);a<n&&(n=a,o=r)}return o},Ho=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,a;return Math.max(o,(a=(r=n.measured)==null?void 0:r.width)!=null?a:0)},0);var zo=(e=[],t=[],o="LR")=>{let n=new Bo.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:a,width:s,height:i})=>n.setNode(a,{width:s,height:i})),t.forEach(a=>n.setEdge(a.source,a.target)),Bo.layout(n),{nodes:e.map(a=>{let s=n.node(a.id);return w(_({},a),{position:{x:s.x-a.width/2,y:s.y-a.height/2}})}),edges:t}},ue=(e,t)=>{var m,y;let o=[...t],n=o.find(E=>E.id===e);if(!n)return o;let r=o.filter(E=>E.parentId===e&&E.type==="LANE");if(r.length===0)return o;let a=ja(r,["position.y"]),s=Math.max((y=(m=n.measured)==null?void 0:m.width)!=null?y:0,it.MIN_WIDTH),i=Ho(e,a)||K.MIN_WIDTH,l=Math.max(s,i),c=0,g=0;a.forEach(E=>{var h,v,p,d;o=o.map(x=>x.id===E.id?w(_({},x),{width:l-K.HEADER_WIDTH,measured:w(_({},x.measured),{width:l-K.HEADER_WIDTH}),position:{x:K.HEADER_WIDTH,y:c}}):x),c+=(v=(h=E.measured)==null?void 0:h.height)!=null?v:0,g+=(d=(p=E.measured)==null?void 0:p.height)!=null?d:0}),o=o.map(E=>E.id===e?w(_({},E),{height:g,width:l,measured:w(_({},E.measured),{height:g,width:l})}):E);let f=o.find(E=>E.id===e);return f!=null&&f.parentId&&(o=ue(f.parentId,o)),o},Uo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Ja=50,Fo=(e,t=Ja)=>{let o=qa(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as Qa}from"zustand";var V=Qa(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as tn,useReactFlow as Vi}from"@xyflow/react";import{BaseEdge as yi,EdgeLabelRenderer as hi,getStraightPath as vi,useNodes as Ni,useViewport as _i}from"@xyflow/react";import{getIncomers as Oe,getOutgoers as qt,useReactFlow as oi}from"@xyflow/react";import{Button as ni,Tooltip as ri,TooltipContent as ai,TooltipTrigger as ii,useTranslation as si}from"lecom-ui";import{PencilIcon as li}from"lucide-react";import{createContext as ei,useContext as ti}from"react";var Wo=ei(null),Yo=Wo.Provider,Ko=()=>{let e=ti(Wo);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as lt,jsxs as di}from"react/jsx-runtime";var Ge=({elementId:e,elementType:t="node"})=>{let{t:o}=si(),{getNode:n,getEdge:r,getNodes:a,getEdges:s}=oi(),{onConfigureElement:i}=Ko(),l=u=>{var T,I,b,N,S;return u?u.type==="TASK"&&((T=u.data)==null?void 0:T.variant)==="SUBPROCESS"?{id:u.id,type:"sub_process",variant:g(u),label:(I=u.data)==null?void 0:I.label}:u.type==="GATEWAY"?{id:u.id,type:"gateway",variant:((b=u.data)==null?void 0:b.variant)||"EXCLUSIVE",label:(N=u.data)==null?void 0:N.label}:{id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label}:null},c=u=>{let T=a(),I=s(),b=Oe(u,T,I);if(b.length===0)return;let N=b[0];return l(N)||void 0},g=u=>{let T=a(),I=s(),b=Oe(u,T,I),N=qt(u,T,I),S=b.some(C=>C.type==="START_EVENT"),P=N.some(C=>C.type==="END_EVENT");return S?"start":P?"end":"between"},f=u=>{var C,A,L,M;let T=a(),I=s(),b=n(u.source),N=n(u.target);if(!b||!N)return"simple";if(qt(b,T,I).some(O=>O.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((C=b.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let O=(A=b.data)==null?void 0:A.variant,H=(L=b.data)==null?void 0:L.attribute;return N.type==="TASK"&&((M=N.data)==null?void 0:M.variant)==="SUBPROCESS"?"to_sub_process":O==="SCRIPT"?"script":H==="LOOP"?"loop":"simple"}return"simple"},m=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="COMPLEX")return;let I=a(),b=s(),N=Oe(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(P=!0))}),S&&P)return"script_loop";if(S)return"script";if(P)return"loop"},y=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let I=a(),b=s(),N=Oe(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(P=!0))}),S)return"script";if(P)return"loop"},E=u=>{var P,C;if(u.type!=="GATEWAY")return;let T=a(),I=s(),b=Oe(u,T,I),N=!1,S=!1;if(b.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(N=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(S=!0))}),((P=u.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&S)return"script_loop";if(N)return"script";if(S)return"loop"}else if(((C=u.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(N)return"script";if(S)return"loop"}},h=u=>qt(u,a(),s()).map(b=>{var N,S;return{id:b.id,type:b.type,variant:(N=b.data)==null?void 0:N.variant,label:(S=b.data)==null?void 0:S.label}}),v=u=>s().filter(b=>b.source===u.id).map(b=>{var N;return{id:b.id,type:"routing",variant:f(b),label:(N=b.data)==null?void 0:N.label,target:n(b.target)}}),p=()=>{var I,b,N,S,P,C;let u=n(e);if(!u)return;let T=c(u);if(u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"){i==null||i({id:u.id,type:"sub_process",variant:g(u),label:(b=u.data)==null?void 0:b.label,origin:T,targets:h(u),edgeTargets:v(u)}),console.log({id:u.id,type:"sub_process",variant:g(u),label:(N=u.data)==null?void 0:N.label,origin:T,targets:h(u),edgeTargets:v(u)});return}if(u.type!=="GATEWAY"){i==null||i({id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label,origin:T,targets:h(u),edgeTargets:v(u)});return}i==null||i({id:u.id,type:"gateway",variant:((P=u.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(C=u.data)==null?void 0:C.label,origin:T,subVariant:E(u),targets:h(u)})},d=()=>{let u=r(e);if(u){let T=f(u),I;T==="complex"?I=m(u):T==="exclusive"&&(I=y(u));let b=n(u.source),N=b&&l(b)||void 0;i==null||i({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)}),console.log({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)})}};return di(ri,{children:[lt(ii,{asChild:!0,children:lt(ni,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":p();break;case"edge":d();break}},children:lt(li,{size:16})})}),lt(ai,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as ci}from"@xyflow/react";import{Button as pi,Tooltip as ui,TooltipContent as mi,TooltipTrigger as gi,useTranslation as fi}from"lecom-ui";import{TrashIcon as Ei}from"lucide-react";import{jsx as dt,jsxs as bi}from"react/jsx-runtime";var ct=({elementId:e,elementType:t="node"})=>{let{t:o}=fi(),{deleteElements:n}=ci();return bi(ui,{children:[dt(gi,{asChild:!0,children:dt(pi,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:dt(Ei,{size:16})})}),dt(mi,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as pt}from"react/jsx-runtime";var xe=n=>{var r=n,{edgeId:e,edgeType:t}=r,o=ae(r,["edgeId","edgeType"]);var i;let a=[{component:pt(ct,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:pt(Ge,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return pt("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(i=s[t])==null?void 0:i.map((l,c)=>pt("div",{children:l.component},c))}))};import{jsx as mt,jsxs as Ti}from"react/jsx-runtime";var gt={type:"ANNOTATION_EDGE",zIndex:2e3},$o=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,selected:i,data:l})=>{let c=Ni(),{zoom:g}=_i(),{isMultipleSelection:f}=V(),m=c.find(x=>x.id===t),y=c.find(x=>x.id===o),[E,h,v]=vi({sourceX:n,sourceY:r,targetX:a,targetY:s}),p=i||(m==null?void 0:m.selected)||(y==null?void 0:y.selected),d=1/g;return Ti("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":p}),children:[mt(yi,{id:e,path:E,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":p&&!(l!=null&&l.hasError)})}),mt(hi,{children:mt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${v}px)`},children:i&&!f&&mt(xe,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};import{BaseEdge as Ci,EdgeLabelRenderer as Ai,getSmoothStepPath as Ii,MarkerType as qo,useNodes as Si,useReactFlow as ki,useViewport as Li}from"@xyflow/react";import{useState as Pi}from"react";import{useEffect as Zo,useRef as xi,useState as wi}from"react";import{jsx as Xo}from"react/jsx-runtime";var F=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:r,className:a,style:s})=>{let i=xi(null),[l,c]=wi(!1);Zo(()=>{c(n!=null?n:!1)},[n]),Zo(()=>{if(l&&i.current){i.current.focus();let E=document.createRange();E.selectNodeContents(i.current),E.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(E))}},[l]);let g=E=>{if(E.stopPropagation(),!l){c(!0);return}if(!i.current)return;let h=document.createRange();h.selectNodeContents(i.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(h))},f=E=>{let h=E.currentTarget.innerText.trim(),v=t&&h.length>=t,p=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=E.ctrlKey||E.metaKey,x=d&&E.key==="a",u=d&&E.key==="c",T=d&&E.key==="x",I=d&&E.key==="v";function b(S){return/\w/.test(S)}if(h.length===0&&!b(E.key)&&!p.includes(E.key)&&!d){E.preventDefault();return}v&&(p.includes(E.key)||x||u||T||I||E.preventDefault())},m=E=>{if(!t)return;E.preventDefault();let h=E.clipboardData.getData("text/plain"),v=E.currentTarget.innerText,p=window.getSelection();if(!p||p.rangeCount===0)return;let d=p.getRangeAt(0);if((v.substring(0,d.startOffset)+h+v.substring(d.endOffset)).length>t){let u=t-(v.length-(d.endOffset-d.startOffset)),T=h.substring(0,Math.max(0,u));T&&(d.deleteContents(),d.insertNode(document.createTextNode(T)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(h)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d)},y=E=>{c(!1);let h=E.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),E.currentTarget.innerText=h,r==null||r(),h!==e&&(o==null||o(h))};return Xo("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:g,children:Xo("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:f,onPaste:m,onBlur:y,children:e})})};import{jsx as ft,jsxs as jo}from"react/jsx-runtime";var te={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:qo.ArrowClosed},markerEnd:{type:qo.Arrow},data:{label:""}},Jo=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=Si(),{zoom:m}=Li(),{updateEdgeData:y}=ki(),{isMultipleSelection:E}=V(),[h,v]=Pi(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=Ii({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return jo("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[ft(Ci,{id:e,path:x,markerEnd:`url(#${b})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),ft(Ai,{children:jo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${T}px)`},children:[g&&!E&&ft(xe,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${S})`}}),N&&ft(F,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};var Et=e=>e.some(t=>t.type==="START_EVENT"),bt=(e,t,o)=>{var a;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((a=n.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},yt=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},ht=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},vt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.target===e).some(a=>{let s=t.find(i=>i.id===a.source);return(s==null?void 0:s.type)==="START_EVENT"})},Nt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).some(a=>{let s=t.find(i=>i.id===a.target);return(s==null?void 0:s.type)==="END_EVENT"})},_t=(e,t)=>t.filter(n=>n.source===e).length>0,Tt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).length>=2};var Di=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!bt(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!Tt(e.sourceNodeId,e.nodes,e.edges),reason:"task_limit_reached"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="GATEWAY"),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(yt(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(ht(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(vt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(Nt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(_t(e.sourceNodeId,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION"],LANE:["ANNOTATION"],ANNOTATION:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],Qo=e=>{for(let t of Di){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ri=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:bt(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:Et(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yt(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ht(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:vt(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Nt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:_t(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Tt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],en=e=>{let t=Ri.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var on=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Vi();return{isValidConnection:s=>{let i=t(s.source),l=t(s.target);if(!i||!l)return!1;let c={sourceNodeId:i.id,targetNodeId:l.id,sourceNodeType:i.type,targetNodeType:l.type,nodes:n(),edges:o()};return Qo(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?tn(_(_({},s),gt),i):tn(_(_({},s),te),i)})}}};import{useState as un}from"react";import{useTranslation as Mi}from"lecom-ui";import{useReactFlow as Oi}from"@xyflow/react";var He=(e=[])=>e.filter(t=>t.type==="START_EVENT"),me=(e=[])=>e.filter(t=>t.type==="END_EVENT"),de=(e=[])=>e.filter(t=>t.type==="TASK")||[],nn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),rn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),xt=(e=[])=>e.filter(t=>t.type==="GATEWAY"),an=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),j=(e,t=[])=>t.filter(o=>o.source===e),Be=(e,t=[])=>t.filter(o=>o.target===e),sn=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(a=>a.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},ln=(e,t)=>{let o=j(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(a=>a.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},dn=e=>e?/\w/g.test(e.trim()):!1,R=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},oe=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},cn=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var ze=[{id:"start_event_not_found",validate:e=>{let t=He(e.nodes);return R({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=me(e.nodes);return R({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=He(e.nodes),o=t.length===1;if(t.length===0)return R({isValid:!0});if(!o)return R({isValid:!1,nodeIds:t.map(a=>a.id)});let n=j(t[0].id,e.edges);if(!(n.length<=1)){let a=[...t.map(s=>s.id),...n.map(s=>s.target)];return R({isValid:!1,nodeIds:[...new Set(a)]})}return R({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=de(e.nodes),o=oe(t,n=>j(n.id,e.edges).length<=2);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=oe(t,n=>!!n.label&&n.label.trim()!=="");return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=de(e.nodes),n=oe(o,r=>!r.label||r.label.length<=60);return R({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let a=r.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(a=>n.push(a.id));return R({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=xt(e.nodes),o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...He(e.nodes),...me(e.nodes)],o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=me(e.nodes),o=[],n=[];for(let r of t){let a=Be(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=j(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return R({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=an(e.nodes),o=oe(t,r=>j(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>j(r,e.edges).map(a=>a.id));return R({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=de(e.nodes),o=oe(t,n=>!n.label||dn(n.label));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,i;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((i=e==null?void 0:e.edges)!=null&&i.length))return R({isValid:!0});let t=me(e.nodes)[0];if(!t)return R({isValid:!0});let o=Be(t.id,e.edges);if(!o.length)return R({isValid:!0});let r=de(e.nodes).filter(l=>o.some(c=>c.source===l.id)),a=oe(r,l=>!sn(l.id,e));return R({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=de(e.nodes),o=me(e.nodes)[0];if(!o)return R({isValid:!0});let n=t.filter(l=>{let c=Be(l.id,e.edges),g=j(l.id,e.edges),f=c.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.source))==null?void 0:E.type)==="START_EVENT"}),m=g.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.target))==null?void 0:E.type)==="END_EVENT"});return f&&m}),r=Be(o.id,e.edges),a=r.length>1,s=r.map(l=>l.source),i={isValid:n.length===0&&!a,nodeIds:[...n.map(l=>l.id),...a?s:[]]};return R(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=xt(e.nodes),o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=xt(e.nodes),o=oe(t,n=>j(n.id,e.edges).length>=1);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...He(e.nodes),...me(e.nodes)],o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=nn(e.nodes),o=oe(t,n=>!ln(n.id,e));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=rn(e.nodes),o=oe(t,n=>{var r,a;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((a=n.properties)==null?void 0:a.subprocessRef)!==""});return R({isValid:o.isValid,nodeIds:o.invalidIds})}}];var pn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of ze){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var mn=()=>{let{t:e}=Mi(),[t,o]=un(null),{setNodes:n,setEdges:r,getNodes:a,getEdges:s}=Oi(),[i,l]=un(!1);return{validationResult:t,validateDiagram:m=>{let y=cn(m.nodes,m.edges),E=pn(y),h=E.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:E.isValid,errors:h}},handleValidationComplete:m=>{if(o(m),!m)return;let y=[],E=[];m.errors.forEach(b=>{b.nodeIds&&b.nodeIds.length>0&&b.nodeIds.forEach(N=>y.push(N)),b.edgeIds&&b.edgeIds.length>0&&b.edgeIds.forEach(N=>E.push(N))});let h=[...new Set(y)];n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})}))),r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})})));let v=a(),p=s(),d=new Set(h),x=new Set;m.errors.forEach(b=>{var P,C;let N=ze.find(A=>A.id===b.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=b.edgeIds)==null||P.forEach(A=>x.add(A)),(C=b.nodeIds)==null||C.forEach(A=>{p.forEach(L=>{(L.source===A||L.target===A)&&x.add(L.id)})}))});let u=new Set,T=new Set,I=new Set;v.forEach(b=>{b.type==="START_EVENT"?u.add(b.id):b.type==="END_EVENT"&&T.add(b.id)}),p.forEach(b=>{u.has(b.source)&&I.add(b.target),T.has(b.target)&&I.add(b.source)}),I.forEach(b=>{var N,S;if(d.has(b)){let P=(N=m.errors.find(A=>{var L;return(L=A.nodeIds)==null?void 0:L.includes(b)}))==null?void 0:N.id;((S=ze.find(A=>A.id===P))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(A=>{A.source===b&&T.has(A.target)&&(d.add(A.target),x.add(A.id)),A.target===b&&u.has(A.source)&&(d.add(A.source),x.add(A.id))})}}),d.size>0&&n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:d.has(N.id)})}))),x.size>0&&r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),r(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},isAutoValidationEnabled:i}};import{useReactFlow as Gi}from"@xyflow/react";import{useTranslation as Hi}from"lecom-ui";import{useEffect as Bi}from"react";import{v7 as gn}from"uuid";var wt=(e,t)=>{let n=e.filter(a=>a.type==="TASK").map(a=>{var i;let s=(i=a.data)==null?void 0:i.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(a=>a>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},Ct=(e,t)=>{let n=t.filter(i=>i.type==="TASK").map(i=>{var l;return(l=i.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),a=n.filter(i=>i===r||i.startsWith(`${r} (`)).map(i=>{if(i===r)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;a.includes(s);)s++;return`${r} (${s})`};var zi=15,fn="bpmn:selection",Ui=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",a=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||a},En=e=>{if(!Ui(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},bn=({offset:e=zi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=Gi(),{t:a}=Hi();Bi(()=>{let s=l=>{var h,v;if(!En(l))return;let c=t(),g=n(),f=c.filter(p=>p.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let m=g.filter(p=>f.some(d=>d.id===p.source)&&f.some(d=>d.id===p.target)),E=JSON.stringify({nodes:f,edges:m});(h=l.clipboardData)==null||h.setData(fn,E),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},i=l=>{var v,p;if(!En(l))return;let c=(v=l.clipboardData)==null?void 0:v.getData(fn);if(!c)return;l.preventDefault(),l.stopPropagation();let g;try{g=JSON.parse(c)}catch(d){return}if(!((p=g.nodes)!=null&&p.length))return;let f=new Map,m=t(),y=[],E=g.nodes.map(d=>{var T;let x=gn();f.set(d.id,x);let u=w(_({},d),{id:x,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let I=(T=d.data)==null?void 0:T.label,b=Ct(I||a("bpmn.task.label.prefix"),[...m,...y]);u.data=w(_({},d.data),{label:b})}return y.push(u),u}),h=g.edges.map(d=>w(_({},d),{id:gn(),selected:!0,source:f.get(d.source)||d.source,target:f.get(d.target)||d.target}));o(d=>[...d.map(x=>w(_({},x),{selected:!1})),...E]),r(d=>[...d.map(x=>w(_({},x),{selected:!1})),...h])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,r,e,a])};import{useReactFlow as Qi,useStoreApi as es}from"@xyflow/react";import{useTranslation as ts}from"lecom-ui";import{v7 as _n}from"uuid";import{create as Fi}from"zustand";var we=Fi(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Wi,EdgeLabelRenderer as Yi,getSmoothStepPath as Ki,MarkerType as $i,useNodes as Zi,useReactFlow as Xi,useViewport as qi}from"@xyflow/react";import{useState as ji}from"react";import{jsx as At,jsxs as yn}from"react/jsx-runtime";var Bm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:$i.Arrow},data:{label:""}},hn=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=Zi(),{zoom:m}=qi(),{updateEdgeData:y}=Xi(),{isMultipleSelection:E}=V(),[h,v]=ji(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=Ki({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return yn("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[At(Wi,{id:e,path:x,markerEnd:`url(#${b})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),At(Yi,{children:yn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${T}px)`},children:[g&&!E&&At(xe,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),N&&At(F,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};import{jsx as vn,jsxs as Ji}from"react/jsx-runtime";var Nn=({fromX:e,fromY:t,toX:o,toY:n})=>Ji("g",{children:[vn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),vn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var Tn=({nodes:e,setNodes:t,setEdges:o})=>{let n=es(),{draggableNode:r,setDraggableNode:a}=we(),{getInternalNode:s,screenToFlowPosition:i}=Qi(),{t:l}=ts(),c=p=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(x=>x.map(u=>w(_({},u),{className:u.id===p?d:""})))},g=()=>{let{nodeLookup:p}=n.getState();return Array.from(p.values())},f=p=>{let d=s(p.id),x=g();if(p.type==="LANE"){if(_e({parentId:p.id,nodes:e,includeTypes:["LANE"]})){c();return}let S=x.filter(A=>A.id!==p.id&&A.type==="LANE"&&!A.parentId),P=Me(d,S);if(!P){c();return}if(_e({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let T=x.filter(N=>N.id!==p.id&&N.type==="LANE"),I=Me(d,T);if(!I){c();return}if(_e({parentId:I.id,nodes:e,includeTypes:["LANE"]})){c();return}c(I.id)},m=p=>{p.preventDefault(),p.dataTransfer.dropEffect="move"},y=(p,d)=>{p.preventDefault(),f(d)},E=(p,d,x)=>{var S,P;let u=C=>C.map(A=>w(_({},A),{className:void 0}));if(p.parentId===d.id){let C=ue(d.id,x);t(se(u(C)));return}if(p.type==="LANE"){if(_e({parentId:d.id,nodes:x,excludeTypes:["LANE"]}))return;let L=x.filter(H=>H.parentId===d.id).reduce((H,be)=>{var pe,ye;return H+((ye=(pe=be.measured)==null?void 0:pe.height)!=null?ye:0)},0),M={x:K.HEADER_WIDTH,y:L},O=x.map(H=>H.id===p.id?w(_({},H),{parentId:d.id,position:M,className:void 0}):w(_({},H),{className:void 0}));O=ue(d.id,O),t(se(O));return}if(_e({parentId:d.id,nodes:x,includeTypes:["LANE"]})){let C;if(p.parentId){let L=s(p.parentId),{x:M,y:O}=ie(L);C={x:M+((S=p.position.x)!=null?S:0),y:O+((P=p.position.y)!=null?P:0)}}let A=x.map(L=>L.id===p.id?w(_({},L),{position:C!=null?C:L.position,parentId:void 0,className:void 0}):w(_({},L),{className:void 0}));t(se(A));return}let b=Go(p,d),N=x.map(C=>C.id===p.id?w(_({},C),{parentId:d.id,position:b,className:void 0}):w(_({},C),{className:void 0}));t(se(N))};return{onDragOver:m,onDrop:p=>{if(p.preventDefault(),!(r!=null&&r.type))return;let d=i({x:p.clientX,y:p.clientY}),x={width:G[r.type].MIN_WIDTH,height:G[r.type].MIN_HEIGHT},u={id:_n(),type:r.type,position:d,measured:x,data:{label:r.type==="TASK"?wt(e,l("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute}},T=w(_({},u),{internals:{positionAbsolute:d}}),I=g(),b=r.type==="LANE",N=I.filter(C=>b?C.type==="LANE"&&!C.parentId:C.type==="LANE"),S=Me(T,N);S?E(T,S,[...I,T]):t(C=>{let A=C.concat(u);return se(A)});let P=p.dataTransfer.getData("sourceId");if(P){let C={id:_n(),source:P,target:u.id};if(r.type==="ANNOTATION"){o(A=>A.concat(_(_({},C),gt)));return}o(A=>A.concat(_(_({},C),te)))}a(null)},onNodeDrag:y,onNodeDragStop:async(p,d)=>{var S,P;let{nodeLookup:x}=n.getState(),u=s(d.id),T=Array.from(x.values()),I=d.type==="LANE",b=T.filter(C=>C.id!==d.id&&(I?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=Me(u,b);if(N){E(u,N,T);return}if(d.parentId){let C=s(d.parentId),{x:A,y:L}=ie(C),M={x:A+((S=d.position.x)!=null?S:0),y:L+((P=d.position.y)!=null?P:0)},O=e.map(H=>H.id===d.id?w(_({},H),{position:M,parentId:void 0}):H);O=ue(d.parentId,O),t(se(O))}}}};import{applyNodeChanges as os}from"@xyflow/react";import{useCallback as ns,useState as wn}from"react";function xn(e,t,o=5){var l,c,g,f,m,y,E,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},r=t.find(v=>v.id===e.id);if(!r||!e.position)return n;let a={left:e.position.x,right:e.position.x+((c=(l=r.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((f=(g=r.measured)==null?void 0:g.height)!=null?f:0),width:(y=(m=r.measured)==null?void 0:m.width)!=null?y:0,height:(h=(E=r.measured)==null?void 0:E.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==r.id).reduce((v,p)=>{var C,A,L,M,O,H,be,pe;let d={left:p.position.x,right:p.position.x+((A=(C=p.measured)==null?void 0:C.width)!=null?A:0),top:p.position.y,bottom:p.position.y+((M=(L=p.measured)==null?void 0:L.height)!=null?M:0),width:(H=(O=p.measured)==null?void 0:O.width)!=null?H:0,height:(pe=(be=p.measured)==null?void 0:be.height)!=null?pe:0},x=Math.abs(a.left-d.left);x<i&&(v.snapPosition.x=d.left,v.vertical=d.left,i=x);let u=Math.abs(a.right-d.right);u<i&&(v.snapPosition.x=d.right-a.width,v.vertical=d.right,i=u);let T=Math.abs(a.left-d.right);T<i&&(v.snapPosition.x=d.right,v.vertical=d.right,i=T);let I=Math.abs(a.right-d.left);I<i&&(v.snapPosition.x=d.left-a.width,v.vertical=d.left,i=I);let b=Math.abs(a.top-d.top);b<s&&(v.snapPosition.y=d.top,v.horizontal=d.top,s=b);let N=Math.abs(a.bottom-d.top);N<s&&(v.snapPosition.y=d.top-a.height,v.horizontal=d.top,s=N);let S=Math.abs(a.bottom-d.bottom);S<s&&(v.snapPosition.y=d.bottom-a.height,v.horizontal=d.bottom,s=S);let P=Math.abs(a.top-d.bottom);return P<s&&(v.snapPosition.y=d.bottom,v.horizontal=d.bottom,s=P),v},n)}var Cn=()=>{let[e,t]=wn(void 0),[o,n]=wn(void 0),r=ns((a,s)=>{var i,l;if(t(void 0),n(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let c=xn(a[0],s);a[0].position.x=(i=c.snapPosition.x)!=null?i:a[0].position.x,a[0].position.y=(l=c.snapPosition.y)!=null?l:a[0].position.y,t(c.horizontal),n(c.vertical)}return os(a,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:r}};import{useReactFlow as as}from"@xyflow/react";import{v7 as Ln}from"uuid";var In={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Sn={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},An=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],s="",i="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",i=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",i=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},rs=e=>{e=e||"";let t=e.trim().split(`
1
+ var _a=Object.defineProperty,Ta=Object.defineProperties;var xa=Object.getOwnPropertyDescriptors;var Xe=Object.getOwnPropertySymbols;var wo=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable;var xo=(e,t,o)=>t in e?_a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))wo.call(t,o)&&xo(e,o,t[o]);if(Xe)for(var o of Xe(t))Co.call(t,o)&&xo(e,o,t[o]);return e},w=(e,t)=>Ta(e,xa(t));var ae=(e,t)=>{var o={};for(var n in e)wo.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&Xe)for(var n of Xe(e))t.indexOf(n)<0&&Co.call(e,n)&&(o[n]=e[n]);return o};import{TooltipProvider as wa,Notification as Ca}from"lecom-ui";import{jsx as Aa,jsxs as Ia}from"react/jsx-runtime";function Ao({children:e}){return Ia(wa,{children:[Aa(Ca,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),e]})}import{Background as nc,MiniMap as rc,ReactFlow as ac,ReactFlowProvider as ic,SelectionMode as sc,useEdgesState as lc,useNodesState as dc,useOnSelectionChange as cc,useReactFlow as pc}from"@xyflow/react";import{i18n as Xr}from"lecom-ui";import{forwardRef as uc,useCallback as fo,useEffect as yo,useImperativeHandle as mc,useRef as gc,useState as fc}from"react";import{useDebouncedCallback as Ec}from"use-debounce";import{v7 as Eo}from"uuid";var Bt=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(Bt||{}),zt=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(zt||{}),Ut=(l=>(l.SIMPLE="simple",l.LOOP="loop",l.SCRIPT="script",l.COMPLEX="complex",l.EXCLUSIVE="exclusive",l.PARALLEL="parallel",l.FINAL="final",l.TO_SUB_PROCESS="to_sub_process",l))(Ut||{}),Ft=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Ft||{}),Wt=(o=>(o.SCRIPT="script",o.LOOP="loop",o))(Wt||{});import{RotateCcw as Ba,ScrollText as za,SquarePlus as Ua}from"lucide-react";import{jsx as qe,jsxs as Sa}from"react/jsx-runtime";var je=({size:e=24,className:t})=>Sa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[qe("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),qe("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),qe("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),qe("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});import{jsx as Io}from"react/jsx-runtime";var ve=({size:e=24,className:t})=>Io("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#f87171",stroke:"#ef4444",strokeWidth:3,className:t,children:Io("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Pe,jsxs as ka}from"react/jsx-runtime";var Je=({size:e=24,className:t})=>ka("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Pe("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Pe("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Yt,jsxs as La}from"react/jsx-runtime";var Ne=({size:e=24,className:t})=>La("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Yt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Yt("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),Yt("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Kt,jsxs as Pa}from"react/jsx-runtime";var Qe=({size:e=24,className:t})=>Pa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[Kt("path",{d:"M2.69991 10.2997C2.47586 10.5235 2.29812 10.7893 2.17685 11.0818C2.05558 11.3744 1.99316 11.688 1.99316 12.0047C1.99316 12.3214 2.05558 12.635 2.17685 12.9275C2.29812 13.2201 2.47586 13.4859 2.69991 13.7097L10.2899 21.2997C10.5137 21.5237 10.7795 21.7015 11.0721 21.8227C11.3646 21.944 11.6782 22.0064 11.9949 22.0064C12.3116 22.0064 12.6252 21.944 12.9177 21.8227C13.2103 21.7015 13.4761 21.5237 13.6999 21.2997L21.2899 13.7097C21.514 13.4859 21.6917 13.2201 21.813 12.9275C21.9342 12.635 21.9967 12.3214 21.9967 12.0047C21.9967 11.688 21.9342 11.3744 21.813 11.0818C21.6917 10.7893 21.514 10.5235 21.2899 10.2997L13.6999 2.70968C13.4761 2.48562 13.2103 2.30788 12.9177 2.18662C12.6252 2.06535 12.3116 2.00293 11.9949 2.00293C11.6782 2.00293 11.3646 2.06535 11.0721 2.18662C10.7795 2.30788 10.5137 2.48562 10.2899 2.70968L2.69991 10.2997Z",strokeLinecap:"round",strokeLinejoin:"round"}),Kt("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),Kt("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as $t,jsxs as Da}from"react/jsx-runtime";var So=({size:e=24,className:t})=>$t("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:Da("g",{children:[$t("path",{d:"M8.6543 11.4141V15.2148C8.51302 15.4017 8.29199 15.6068 7.99121 15.8301C7.69499 16.0488 7.30078 16.238 6.80859 16.3975C6.31641 16.557 5.70345 16.6367 4.96973 16.6367C4.34538 16.6367 3.77344 16.5319 3.25391 16.3223C2.73438 16.1081 2.28548 15.7959 1.90723 15.3857C1.53353 14.9756 1.24414 14.4766 1.03906 13.8887C0.833984 13.2962 0.731445 12.6217 0.731445 11.8652V11.1748C0.731445 10.4229 0.82487 9.75293 1.01172 9.16504C1.20312 8.57259 1.47656 8.07129 1.83203 7.66113C2.1875 7.25098 2.61589 6.94108 3.11719 6.73145C3.62305 6.51725 4.19499 6.41016 4.83301 6.41016C5.64876 6.41016 6.32324 6.54688 6.85645 6.82031C7.39421 7.08919 7.80892 7.46289 8.10059 7.94141C8.39225 8.41992 8.57682 8.9668 8.6543 9.58203H6.97266C6.91797 9.23568 6.81087 8.92578 6.65137 8.65234C6.49642 8.37891 6.27311 8.16471 5.98145 8.00977C5.69434 7.85026 5.32064 7.77051 4.86035 7.77051C4.46387 7.77051 4.11523 7.8457 3.81445 7.99609C3.51367 8.14648 3.26302 8.36751 3.0625 8.65918C2.86654 8.95085 2.71842 9.30632 2.61816 9.72559C2.5179 10.1449 2.46777 10.6234 2.46777 11.1611V11.8652C2.46777 12.4121 2.52474 12.8975 2.63867 13.3213C2.75716 13.7451 2.92578 14.1029 3.14453 14.3945C3.36784 14.6862 3.639 14.9072 3.95801 15.0576C4.27702 15.2035 4.63704 15.2764 5.03809 15.2764C5.43001 15.2764 5.7513 15.2445 6.00195 15.1807C6.2526 15.1123 6.45085 15.0326 6.59668 14.9414C6.74707 14.8457 6.86328 14.7546 6.94531 14.668V12.6924H4.87402V11.4141H8.6543ZM17.0912 11.25V11.7969C17.0912 12.5488 16.9932 13.2233 16.7973 13.8203C16.6013 14.4173 16.321 14.9255 15.9564 15.3447C15.5964 15.764 15.1635 16.0853 14.6576 16.3086C14.1518 16.5273 13.5912 16.6367 12.976 16.6367C12.3653 16.6367 11.807 16.5273 11.3012 16.3086C10.7999 16.0853 10.3646 15.764 9.99551 15.3447C9.62637 14.9255 9.33926 14.4173 9.13418 13.8203C8.93366 13.2233 8.8334 12.5488 8.8334 11.7969V11.25C8.8334 10.498 8.93366 9.82585 9.13418 9.2334C9.3347 8.63639 9.61725 8.12826 9.98184 7.70898C10.351 7.28516 10.7862 6.96387 11.2875 6.74512C11.7934 6.52181 12.3516 6.41016 12.9623 6.41016C13.5775 6.41016 14.1381 6.52181 14.6439 6.74512C15.1498 6.96387 15.585 7.28516 15.9496 7.70898C16.3142 8.12826 16.5945 8.63639 16.7904 9.2334C16.991 9.82585 17.0912 10.498 17.0912 11.25ZM15.3754 11.7969V11.2363C15.3754 10.6803 15.3207 10.1904 15.2113 9.7666C15.1065 9.33822 14.9493 8.98047 14.7396 8.69336C14.5346 8.40169 14.2816 8.18294 13.9809 8.03711C13.6801 7.88672 13.3406 7.81152 12.9623 7.81152C12.584 7.81152 12.2468 7.88672 11.9506 8.03711C11.6544 8.18294 11.4014 8.40169 11.1918 8.69336C10.9867 8.98047 10.8295 9.33822 10.7201 9.7666C10.6107 10.1904 10.5561 10.6803 10.5561 11.2363V11.7969C10.5561 12.3529 10.6107 12.8451 10.7201 13.2734C10.8295 13.7018 10.989 14.0641 11.1986 14.3604C11.4128 14.652 11.668 14.873 11.9643 15.0234C12.2605 15.1693 12.5977 15.2422 12.976 15.2422C13.3588 15.2422 13.6983 15.1693 13.9945 15.0234C14.2908 14.873 14.5414 14.652 14.7465 14.3604C14.9516 14.0641 15.1065 13.7018 15.2113 13.2734C15.3207 12.8451 15.3754 12.3529 15.3754 11.7969ZM20.6678 14.6816L23.2859 6.54688H25.1795L21.6111 16.5H20.3328L20.6678 14.6816ZM18.2479 6.54688L20.8455 14.6816L21.201 16.5H19.9158L16.3611 6.54688H18.2479Z"}),$t("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});import{clsx as Ra}from"clsx";import{twMerge as Va}from"tailwind-merge";function k(...e){return Va(Ra(e))}var De=(e,t)=>e<t?t:e;import{jsx as ko,jsxs as Ma}from"react/jsx-runtime";var Lo=({size:e=24,className:t})=>Ma("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"#6b7280",strokeWidth:2,xmlns:"http://www.w3.org/2000/svg",className:k("stroke-2",t),children:[ko("path",{d:"M19 3H5C3.89543 3 3 3.89543 3 5V19C3 20.1046 3.89543 21 5 21H19C20.1046 21 21 20.1046 21 19V5C21 3.89543 20.1046 3 19 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),ko("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Zt}from"react/jsx-runtime";var Po=({size:e=24,className:t})=>Zt("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:Zt("g",{children:Zt("path",{d:"M4.85372 6.17472L5.31292 5.71552L5.31993 5.70863C6.88908 4.1924 8.98352 3.34122 11.1655 3.33301L11.1668 3.33301C11.167 3.33301 11.1673 3.33301 11.1675 3.33301C12.7165 3.33314 14.2308 3.79255 15.5188 4.65317C16.807 5.5139 17.811 6.7373 18.4039 8.16866C18.9968 9.60001 19.1519 11.175 18.8497 12.6945C18.5986 13.9567 18.0414 15.1334 17.232 16.1236L16.9457 16.4738L17.2655 16.7936L20.6617 20.1899L20.6617 20.1899C20.7919 20.3201 20.7919 20.5311 20.6617 20.6612L20.6616 20.6613C20.5316 20.7915 20.3205 20.7915 20.1903 20.6613L16.7941 17.265L16.4743 16.9452L16.1241 17.2315C15.1339 18.0409 13.9571 18.5981 12.695 18.8492C11.1755 19.1514 9.6005 18.9963 8.16915 18.4034C6.73778 17.8105 5.51439 16.8065 4.65365 15.5183C3.79291 14.2301 3.3335 12.7156 3.3335 11.1663C3.3335 10.9822 3.48273 10.833 3.66683 10.833C3.85093 10.833 4.00016 10.9822 4.00016 11.1663C4.00016 12.5838 4.42048 13.9694 5.20796 15.148C5.99545 16.3265 7.11474 17.245 8.42426 17.7874C9.73378 18.3299 11.1748 18.4719 12.565 18.1953C13.9552 17.9188 15.2321 17.2362 16.2344 16.234L16.2345 16.234C17.2367 15.2316 17.9193 13.9547 18.1958 12.5645C18.4724 11.1743 18.3304 9.7333 17.7879 8.42378C17.2455 7.11426 16.327 5.99497 15.1484 5.20748L14.8707 5.62322L15.1484 5.20748C13.9703 4.42031 12.5854 4.00001 11.1685 3.99968L11.1664 3.99969C9.15876 4.00767 7.23176 4.7903 5.78712 6.18424L5.78706 6.18418L5.78075 6.1905L5.32512 6.64613L4.47156 7.49968H5.67867H7.8335C8.01759 7.49968 8.16683 7.64892 8.16683 7.83302C8.16683 8.01711 8.01759 8.16635 7.8335 8.16635H3.66683C3.48274 8.16635 3.3335 8.01711 3.3335 7.83302V3.66635C3.3335 3.48225 3.48274 3.33302 3.66683 3.33302C3.85092 3.33302 4.00016 3.48225 4.00016 3.66635V5.82117V7.02827L4.85372 6.17472Z"})})});import{jsx as Do}from"react/jsx-runtime";var et=({size:e=24,className:t})=>Do("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#84cc16",stroke:"#65a30d",strokeWidth:"2",className:t,children:Do("path",{d:"M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Ro}from"react/jsx-runtime";var Re=({size:e=24,className:t})=>Ro("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:k("stroke-2",t),children:Ro("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"})});import{jsx as Xt,jsxs as Oa}from"react/jsx-runtime";var Vo=({size:e=24,className:t})=>Oa("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Xt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M7.5 12C7.5 12.89 7.76392 13.76 8.25839 14.5001C8.75285 15.2401 9.45566 15.8169 10.2779 16.1575C11.1002 16.4981 12.005 16.5872 12.8779 16.4135C13.7508 16.2399 14.5526 15.8113 15.182 15.182C15.8113 14.5526 16.2399 13.7508 16.4135 12.8779C16.5872 12.005 16.4981 11.1002 16.1575 10.2779C15.8169 9.45566 15.2401 8.75285 14.5001 8.25839C13.76 7.76392 12.89 7.5 12 7.5C10.742 7.50473 9.53448 7.99561 8.63 8.87L7.5 10",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Xt("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as Ve,jsxs as Ga}from"react/jsx-runtime";var Mo=({size:e=24,className:t})=>Ga("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[Ve("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M15.5 14.5V8.5C15.5 8.23478 15.3946 7.98043 15.2071 7.79289C15.0196 7.60536 14.7652 7.5 14.5 7.5H8",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M10 16.5H16C16.2652 16.5 16.5196 16.3946 16.7071 16.2071C16.8946 16.0196 17 15.7652 17 15.5V15C17 14.8674 16.9473 14.7402 16.8536 14.6464C16.7598 14.5527 16.6326 14.5 16.5 14.5H11.5C11.3674 14.5 11.2402 14.5527 11.1464 14.6464C11.0527 14.7402 11 14.8674 11 15V15.5C11 15.7652 10.8946 16.0196 10.7071 16.2071C10.5196 16.3946 10.2652 16.5 10 16.5ZM10 16.5C9.73478 16.5 9.48043 16.3946 9.29289 16.2071C9.10536 16.0196 9 15.7652 9 15.5V8.5C9 8.23478 8.89464 7.98043 8.70711 7.79289C8.51957 7.60536 8.26522 7.5 8 7.5C7.73478 7.5 7.48043 7.60536 7.29289 7.79289C7.10536 7.98043 7 8.23478 7 8.5V9.5C7 9.63261 7.05268 9.75979 7.14645 9.85355C7.24021 9.94732 7.36739 10 7.5 10H9",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),Ve("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});import{jsx as tt,jsxs as Ha}from"react/jsx-runtime";var Oo=({size:e=24,className:t})=>Ha("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:2,className:t,children:[tt("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),tt("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),tt("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),tt("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var D=(i=>(i.START_EVENT="START_EVENT",i.END_EVENT="END_EVENT",i.TASK="TASK",i.LANE="LANE",i.GATEWAY="GATEWAY",i.ANNOTATION="ANNOTATION",i.UNSUPPORTED="UNSUPPORTED",i))(D||{});var ot={SCRIPT:{icon:za},SUBPROCESS:{icon:Ua}};var nt={LOOP:{icon:Ba}},ee=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(ee||{}),rt={EXCLUSIVE:{icon:Ne},PARALLEL:{icon:Qe},COMPLEX:{icon:Je}};import Bo from"@dagrejs/dagre";import{getNodesBounds as qa}from"@xyflow/react";import{orderBy as ja}from"lodash";var Fa={MIN_WIDTH:36,MIN_HEIGHT:36},Wa={MIN_WIDTH:36,MIN_HEIGHT:36},Ya={MIN_WIDTH:56,MIN_HEIGHT:56},at={MIN_WIDTH:176,MIN_HEIGHT:96},it={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},K={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},st={MIN_WIDTH:176,MIN_HEIGHT:64},Ka={MIN_WIDTH:128,MIN_HEIGHT:64},G={START_EVENT:Fa,END_EVENT:Wa,GATEWAY:Ya,TASK:at,LANE:K,ANNOTATION:st,UNSUPPORTED:Ka};import{orderBy as $a}from"lodash";var ie=e=>{var t,o,n,r,a,s,i,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(a=e.measured)==null?void 0:a.width)!=null?s:0,h:(l=(i=e.measured)==null?void 0:i.height)!=null?l:0}},se=e=>$a(e,[t=>t.parentId?1:t.type!=="LANE"?2:0],["asc"]),Go=(e,t)=>{let{x:o,y:n}=ie(e),{x:r,y:a}=ie(t);return{x:o-r,y:n-a}};var _e=({parentId:e,nodes:t,includeTypes:o=[...Object.values(D)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Za=(e,t)=>{let{x:o,y:n}=ie(e),{x:r,y:a}=ie(t),s=o-r,i=n-a;return Math.sqrt(s*s+i*i)},Xa=(e,t)=>{let{x:o,y:n,w:r,h:a}=ie(e),{x:s,y:i,w:l,h:c}=ie(t);return o<s+l&&s<o+r&&n<i+c&&i<n+a},Me=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Xa(e,r)){let a=Za(e,r);a<n&&(n=a,o=r)}return o},Ho=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,a;return Math.max(o,(a=(r=n.measured)==null?void 0:r.width)!=null?a:0)},0);var zo=(e=[],t=[],o="LR")=>{let n=new Bo.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:a,width:s,height:i})=>n.setNode(a,{width:s,height:i})),t.forEach(a=>n.setEdge(a.source,a.target)),Bo.layout(n),{nodes:e.map(a=>{let s=n.node(a.id);return w(_({},a),{position:{x:s.x-a.width/2,y:s.y-a.height/2}})}),edges:t}},ue=(e,t)=>{var m,y;let o=[...t],n=o.find(E=>E.id===e);if(!n)return o;let r=o.filter(E=>E.parentId===e&&E.type==="LANE");if(r.length===0)return o;let a=ja(r,["position.y"]),s=Math.max((y=(m=n.measured)==null?void 0:m.width)!=null?y:0,it.MIN_WIDTH),i=Ho(e,a)||K.MIN_WIDTH,l=Math.max(s,i),c=0,g=0;a.forEach(E=>{var h,v,p,d;o=o.map(x=>x.id===E.id?w(_({},x),{width:l-K.HEADER_WIDTH,measured:w(_({},x.measured),{width:l-K.HEADER_WIDTH}),position:{x:K.HEADER_WIDTH,y:c}}):x),c+=(v=(h=E.measured)==null?void 0:h.height)!=null?v:0,g+=(d=(p=E.measured)==null?void 0:p.height)!=null?d:0}),o=o.map(E=>E.id===e?w(_({},E),{height:g,width:l,measured:w(_({},E.measured),{height:g,width:l})}):E);let f=o.find(E=>E.id===e);return f!=null&&f.parentId&&(o=ue(f.parentId,o)),o},Uo=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Ja=50,Fo=(e,t=Ja)=>{let o=qa(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};import{create as Qa}from"zustand";var V=Qa(e=>({isMoveTool:!0,isHandTool:!1,isReadOnly:!1,isMultipleSelection:!1,isMinimapOpen:!1,activeMoveTool:()=>{e({isMoveTool:!0,isHandTool:!1})},activeHandTool:()=>{e({isHandTool:!0,isMoveTool:!1})},setIsReadOnly:t=>{e({isReadOnly:t})},setIsMultipleSelection:t=>{e({isMultipleSelection:t})},setIsMinimapOpen:t=>{e({isMinimapOpen:t})}}));import{addEdge as tn,useReactFlow as Vi}from"@xyflow/react";import{BaseEdge as yi,EdgeLabelRenderer as hi,getStraightPath as vi,useNodes as Ni,useViewport as _i}from"@xyflow/react";import{getIncomers as Oe,getOutgoers as qt,useReactFlow as oi}from"@xyflow/react";import{Button as ni,Tooltip as ri,TooltipContent as ai,TooltipTrigger as ii,useTranslation as si}from"lecom-ui";import{Settings as li}from"lucide-react";import{createContext as ei,useContext as ti}from"react";var Wo=ei(null),Yo=Wo.Provider,Ko=()=>{let e=ti(Wo);if(!e)throw new Error("useEditor must be used within an <EditorProvider />");return e};import{jsx as lt,jsxs as di}from"react/jsx-runtime";var Ge=({elementId:e,elementType:t="node"})=>{let{t:o}=si(),{getNode:n,getEdge:r,getNodes:a,getEdges:s}=oi(),{onConfigureElement:i}=Ko(),l=u=>{var T,I,b,N,S;return u?u.type==="TASK"&&((T=u.data)==null?void 0:T.variant)==="SUBPROCESS"?{id:u.id,type:"sub_process",variant:g(u),label:(I=u.data)==null?void 0:I.label}:u.type==="GATEWAY"?{id:u.id,type:"gateway",variant:((b=u.data)==null?void 0:b.variant)||"EXCLUSIVE",label:(N=u.data)==null?void 0:N.label}:{id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label}:null},c=u=>{let T=a(),I=s(),b=Oe(u,T,I);if(b.length===0)return;let N=b[0];return l(N)||void 0},g=u=>{let T=a(),I=s(),b=Oe(u,T,I),N=qt(u,T,I),S=b.some(C=>C.type==="START_EVENT"),P=N.some(C=>C.type==="END_EVENT");return S?"start":P?"end":"between"},f=u=>{var C,A,L,M;let T=a(),I=s(),b=n(u.source),N=n(u.target);if(!b||!N)return"simple";if(qt(b,T,I).some(O=>O.type==="END_EVENT"))return"final";if(b.type==="GATEWAY")switch((C=b.data)==null?void 0:C.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(b.type==="TASK"){let O=(A=b.data)==null?void 0:A.variant,H=(L=b.data)==null?void 0:L.attribute;return N.type==="TASK"&&((M=N.data)==null?void 0:M.variant)==="SUBPROCESS"?"to_sub_process":O==="SCRIPT"?"script":H==="LOOP"?"loop":"simple"}return"simple"},m=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="COMPLEX")return;let I=a(),b=s(),N=Oe(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(P=!0))}),S&&P)return"script_loop";if(S)return"script";if(P)return"loop"},y=u=>{var C;let T=n(u.source);if(!T||T.type!=="GATEWAY"||((C=T.data)==null?void 0:C.variant)!=="EXCLUSIVE")return;let I=a(),b=s(),N=Oe(T,I,b),S=!1,P=!1;if(N.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(S=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(P=!0))}),S)return"script";if(P)return"loop"},E=u=>{var P,C;if(u.type!=="GATEWAY")return;let T=a(),I=s(),b=Oe(u,T,I),N=!1,S=!1;if(b.forEach(A=>{var L,M;A.type==="TASK"&&(((L=A.data)==null?void 0:L.variant)==="SCRIPT"&&(N=!0),((M=A.data)==null?void 0:M.attribute)==="LOOP"&&(S=!0))}),((P=u.data)==null?void 0:P.variant)==="COMPLEX"){if(N&&S)return"script_loop";if(N)return"script";if(S)return"loop"}else if(((C=u.data)==null?void 0:C.variant)==="EXCLUSIVE"){if(N)return"script";if(S)return"loop"}},h=u=>qt(u,a(),s()).map(b=>{var N,S;return{id:b.id,type:b.type,variant:(N=b.data)==null?void 0:N.variant,label:(S=b.data)==null?void 0:S.label}}),v=u=>s().filter(b=>b.source===u.id).map(b=>{var N;return{id:b.id,type:"routing",variant:f(b),label:(N=b.data)==null?void 0:N.label,target:n(b.target)}}),p=()=>{var I,b,N,S,P,C;let u=n(e);if(!u)return;let T=c(u);if(u.type==="TASK"&&((I=u.data)==null?void 0:I.variant)==="SUBPROCESS"){i==null||i({id:u.id,type:"sub_process",variant:g(u),label:(b=u.data)==null?void 0:b.label,origin:T,targets:h(u),edgeTargets:v(u)}),console.log({id:u.id,type:"sub_process",variant:g(u),label:(N=u.data)==null?void 0:N.label,origin:T,targets:h(u),edgeTargets:v(u)});return}if(u.type!=="GATEWAY"){i==null||i({id:u.id,type:"activity",variant:g(u),label:(S=u.data)==null?void 0:S.label,origin:T,targets:h(u),edgeTargets:v(u)});return}i==null||i({id:u.id,type:"gateway",variant:((P=u.data)==null?void 0:P.variant)||"EXCLUSIVE",label:(C=u.data)==null?void 0:C.label,origin:T,subVariant:E(u),targets:h(u)})},d=()=>{let u=r(e);if(u){let T=f(u),I;T==="complex"?I=m(u):T==="exclusive"&&(I=y(u));let b=n(u.source),N=b&&l(b)||void 0;i==null||i({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)}),console.log({id:u.id,type:"routing",variant:T,subVariant:I,origin:N,target:n(u.target)})}};return di(ri,{children:[lt(ii,{asChild:!0,children:lt(ni,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{switch(t){case"node":p();break;case"edge":d();break}},children:lt(li,{size:16})})}),lt(ai,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};import{useReactFlow as ci}from"@xyflow/react";import{Button as pi,Tooltip as ui,TooltipContent as mi,TooltipTrigger as gi,useTranslation as fi}from"lecom-ui";import{TrashIcon as Ei}from"lucide-react";import{jsx as dt,jsxs as bi}from"react/jsx-runtime";var ct=({elementId:e,elementType:t="node"})=>{let{t:o}=fi(),{deleteElements:n}=ci();return bi(ui,{children:[dt(gi,{asChild:!0,children:dt(pi,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:dt(Ei,{size:16})})}),dt(mi,{color:"black",children:o("editor.toolbar.delete")})]})};import{jsx as pt}from"react/jsx-runtime";var xe=n=>{var r=n,{edgeId:e,edgeType:t}=r,o=ae(r,["edgeId","edgeType"]);var i;let a=[{component:pt(ct,{elementId:e,elementType:"edge"})}],s={SEQUENCE_EDGE:[{component:pt(Ge,{elementId:e,elementType:"edge"})},...a],MESSAGE_EDGE:[...a],ANNOTATION_EDGE:[...a]};return pt("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},o),{children:(i=s[t])==null?void 0:i.map((l,c)=>pt("div",{children:l.component},c))}))};import{jsx as mt,jsxs as Ti}from"react/jsx-runtime";var gt={type:"ANNOTATION_EDGE",zIndex:2e3},$o=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,selected:i,data:l})=>{let c=Ni(),{zoom:g}=_i(),{isMultipleSelection:f}=V(),m=c.find(x=>x.id===t),y=c.find(x=>x.id===o),[E,h,v]=vi({sourceX:n,sourceY:r,targetX:a,targetY:s}),p=i||(m==null?void 0:m.selected)||(y==null?void 0:y.selected),d=1/g;return Ti("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":p}),children:[mt(yi,{id:e,path:E,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":l==null?void 0:l.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":p&&!(l!=null&&l.hasError)})}),mt(hi,{children:mt("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${h}px, ${v}px)`},children:i&&!f&&mt(xe,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${d})`}})})})]})};import{BaseEdge as Ci,EdgeLabelRenderer as Ai,getSmoothStepPath as Ii,MarkerType as qo,useNodes as Si,useReactFlow as ki,useViewport as Li}from"@xyflow/react";import{useState as Pi}from"react";import{useEffect as Zo,useRef as xi,useState as wi}from"react";import{jsx as Xo}from"react/jsx-runtime";var F=({value:e,maxLength:t,onChange:o,isEditing:n,onBlur:r,className:a,style:s})=>{let i=xi(null),[l,c]=wi(!1);Zo(()=>{c(n!=null?n:!1)},[n]),Zo(()=>{if(l&&i.current){i.current.focus();let E=document.createRange();E.selectNodeContents(i.current),E.collapse(!1);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(E))}},[l]);let g=E=>{if(E.stopPropagation(),!l){c(!0);return}if(!i.current)return;let h=document.createRange();h.selectNodeContents(i.current);let v=window.getSelection();v&&(v.removeAllRanges(),v.addRange(h))},f=E=>{let h=E.currentTarget.innerText.trim(),v=t&&h.length>=t,p=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],d=E.ctrlKey||E.metaKey,x=d&&E.key==="a",u=d&&E.key==="c",T=d&&E.key==="x",I=d&&E.key==="v";function b(S){return/\w/.test(S)}if(h.length===0&&!b(E.key)&&!p.includes(E.key)&&!d){E.preventDefault();return}v&&(p.includes(E.key)||x||u||T||I||E.preventDefault())},m=E=>{if(!t)return;E.preventDefault();let h=E.clipboardData.getData("text/plain"),v=E.currentTarget.innerText,p=window.getSelection();if(!p||p.rangeCount===0)return;let d=p.getRangeAt(0);if((v.substring(0,d.startOffset)+h+v.substring(d.endOffset)).length>t){let u=t-(v.length-(d.endOffset-d.startOffset)),T=h.substring(0,Math.max(0,u));T&&(d.deleteContents(),d.insertNode(document.createTextNode(T)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d))}else d.deleteContents(),d.insertNode(document.createTextNode(h)),d.setStartAfter(d.endContainer),d.collapse(!0),p.removeAllRanges(),p.addRange(d)},y=E=>{c(!1);let h=E.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),E.currentTarget.innerText=h,r==null||r(),h!==e&&(o==null||o(h))};return Xo("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis text-sm text-center",a,{"border border-dashed border-grey-400":l}),style:s,onDoubleClick:g,children:Xo("div",{ref:i,className:"outline-none whitespace-pre-wrap overflow-hidden",contentEditable:l,suppressContentEditableWarning:!0,onKeyDown:f,onPaste:m,onBlur:y,children:e})})};import{jsx as ft,jsxs as jo}from"react/jsx-runtime";var te={type:"SEQUENCE_EDGE",zIndex:2e3,markerStart:{type:qo.ArrowClosed},markerEnd:{type:qo.Arrow},data:{label:""}},Jo=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=Si(),{zoom:m}=Li(),{updateEdgeData:y}=ki(),{isMultipleSelection:E}=V(),[h,v]=Pi(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=Ii({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return jo("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[ft(Ci,{id:e,path:x,markerEnd:`url(#${b})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),ft(Ai,{children:jo("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${T}px)`},children:[g&&!E&&ft(xe,{edgeId:e,edgeType:"SEQUENCE_EDGE",style:{transform:`scale(${S})`}}),N&&ft(F,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};var Et=e=>e.some(t=>t.type==="START_EVENT"),bt=(e,t,o)=>{var a;let n=t.find(s=>s.id===e);return!n||n.type!=="GATEWAY"||((a=n.data)==null?void 0:a.variant)!=="EXCLUSIVE"?!1:o.filter(s=>s.source===e).length>=2},yt=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.variant)==="SCRIPT"},ht=(e,t)=>{var n;let o=t.find(r=>r.id===e);return!o||o.type!=="TASK"?!1:((n=o.data)==null?void 0:n.attribute)==="LOOP"},vt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.target===e).some(a=>{let s=t.find(i=>i.id===a.source);return(s==null?void 0:s.type)==="START_EVENT"})},Nt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).some(a=>{let s=t.find(i=>i.id===a.target);return(s==null?void 0:s.type)==="END_EVENT"})},_t=(e,t)=>t.filter(n=>n.source===e).length>0,Tt=(e,t,o)=>{let n=t.find(a=>a.id===e);return!n||n.type!=="TASK"?!1:o.filter(a=>a.source===e).length>=2};var Di=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!bt(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"}),e=>({isValid:!Tt(e.sourceNodeId,e.nodes,e.edges),reason:"task_limit_reached"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="GATEWAY"),reason:"gateway_to_gateway_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="END_EVENT"),reason:"start_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(yt(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(ht(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(vt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!(Nt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(_t(e.sourceNodeId,e.edges)&&e.targetNodeType==="END_EVENT"),reason:"activity_has_outgoing_connections"}),e=>({isValid:({START_EVENT:["TASK","ANNOTATION"],END_EVENT:["ANNOTATION"],TASK:["TASK","END_EVENT","GATEWAY","ANNOTATION"],GATEWAY:["TASK","END_EVENT","ANNOTATION"],LANE:["ANNOTATION"],ANNOTATION:[],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],Qo=e=>{for(let t of Di){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Ri=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:bt(e.sourceNodeId,e.nodes,e.edges),reason:"gateway_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:Et(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:yt(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ht(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:vt(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Nt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:_t(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Tt(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],en=e=>{let t=Ri.filter(o=>{let n=!o.sourceTypes||o.sourceTypes.includes(e.sourceNodeType),r=!o.targetTypes||o.targetTypes.includes(e.targetNodeType);return n&&r});for(let o of t){let n=o.validate(e);if(n.shouldDisable)return n}return{shouldDisable:!1}};var on=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=Vi();return{isValidConnection:s=>{let i=t(s.source),l=t(s.target);if(!i||!l)return!1;let c={sourceNodeId:i.id,targetNodeId:l.id,sourceNodeType:i.type,targetNodeType:l.type,nodes:n(),edges:o()};return Qo(c).isValid},onConnect:s=>{e(i=>{let l=t(s.target);return(l==null?void 0:l.type)==="ANNOTATION"?tn(_(_({},s),gt),i):tn(_(_({},s),te),i)})}}};import{useState as un}from"react";import{useTranslation as Mi}from"lecom-ui";import{useReactFlow as Oi}from"@xyflow/react";var He=(e=[])=>e.filter(t=>t.type==="START_EVENT"),me=(e=[])=>e.filter(t=>t.type==="END_EVENT"),de=(e=[])=>e.filter(t=>t.type==="TASK")||[],nn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),rn=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),xt=(e=[])=>e.filter(t=>t.type==="GATEWAY"),an=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),j=(e,t=[])=>t.filter(o=>o.source===e),Be=(e,t=[])=>t.filter(o=>o.target===e),sn=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(a=>a.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},ln=(e,t)=>{let o=j(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(a=>a.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},dn=e=>e?/\w/g.test(e.trim()):!1,R=e=>{let{isValid:t,nodeIds:o,edgeIds:n}=e;return{isValid:t,nodeIds:!t&&o&&o.length>0?o:[],edgeIds:!t&&n&&n.length>0?n:[]}},oe=(e=[],t)=>{if(!e||e.length===0)return{isValid:!0,invalidIds:[]};let o=e.filter(n=>!t(n));return{isValid:o.length===0,invalidIds:o.map(n=>n.id)}},cn=(e=[],t=[])=>({nodes:e.map(o=>{var n;return{id:o.id,type:o.type||"",label:typeof((n=o.data)==null?void 0:n.label)=="string"?o.data.label:void 0,properties:o.data}}),edges:t.map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var ze=[{id:"start_event_not_found",validate:e=>{let t=He(e.nodes);return R({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=me(e.nodes);return R({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=He(e.nodes),o=t.length===1;if(t.length===0)return R({isValid:!0});if(!o)return R({isValid:!1,nodeIds:t.map(a=>a.id)});let n=j(t[0].id,e.edges);if(!(n.length<=1)){let a=[...t.map(s=>s.id),...n.map(s=>s.target)];return R({isValid:!1,nodeIds:[...new Set(a)]})}return R({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=de(e.nodes),o=oe(t,n=>j(n.id,e.edges).length<=2);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=oe(t,n=>!!n.label&&n.label.trim()!=="");return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=de(e.nodes),n=oe(o,r=>!r.label||r.label.length<=60);return R({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=de(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let a=r.label.trim();a&&(o.has(a)||o.set(a,[]),o.get(a).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(a=>n.push(a.id));return R({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=xt(e.nodes),o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...He(e.nodes),...me(e.nodes)],o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&(i.type==="START_EVENT"||i.type==="END_EVENT")&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=me(e.nodes),o=[],n=[];for(let r of t){let a=Be(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.source);if(i&&i.type==="TASK"){let l=j(i.id,e.edges);l.length>1&&(o.push(i.id),l.forEach(c=>n.push(c.id)))}}}return R({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=an(e.nodes),o=oe(t,r=>j(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>j(r,e.edges).map(a=>a.id));return R({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=de(e.nodes),o=oe(t,n=>!n.label||dn(n.label));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,i;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((i=e==null?void 0:e.edges)!=null&&i.length))return R({isValid:!0});let t=me(e.nodes)[0];if(!t)return R({isValid:!0});let o=Be(t.id,e.edges);if(!o.length)return R({isValid:!0});let r=de(e.nodes).filter(l=>o.some(c=>c.source===l.id)),a=oe(r,l=>!sn(l.id,e));return R({isValid:a.isValid,nodeIds:a.isValid?[]:[t.id,...a.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=de(e.nodes),o=me(e.nodes)[0];if(!o)return R({isValid:!0});let n=t.filter(l=>{let c=Be(l.id,e.edges),g=j(l.id,e.edges),f=c.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.source))==null?void 0:E.type)==="START_EVENT"}),m=g.some(y=>{var E;return((E=e.nodes.find(h=>h.id===y.target))==null?void 0:E.type)==="END_EVENT"});return f&&m}),r=Be(o.id,e.edges),a=r.length>1,s=r.map(l=>l.source),i={isValid:n.length===0&&!a,nodeIds:[...n.map(l=>l.id),...a?s:[]]};return R(i)}},{id:"gateway_flow_to_event",validate:e=>{let t=xt(e.nodes),o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="END_EVENT"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=xt(e.nodes),o=oe(t,n=>j(n.id,e.edges).length>=1);return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...He(e.nodes),...me(e.nodes)],o=[],n=[];for(let r of t){let a=j(r.id,e.edges);for(let s of a){let i=e.nodes.find(l=>l.id===s.target);i&&i.type==="GATEWAY"&&(o.push(r.id,i.id),n.push(s.id))}}return R({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=nn(e.nodes),o=oe(t,n=>!ln(n.id,e));return R({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=rn(e.nodes),o=oe(t,n=>{var r,a;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((a=n.properties)==null?void 0:a.subprocessRef)!==""});return R({isValid:o.isValid,nodeIds:o.invalidIds})}}];var pn=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of ze){let r=n.validate(e);r.isValid||t.push({id:n.id,message:n.id,nodeIds:r.nodeIds||[],edgeIds:r.edgeIds||[]})}return{isValid:t.length===0,errors:t}};var mn=()=>{let{t:e}=Mi(),[t,o]=un(null),{setNodes:n,setEdges:r,getNodes:a,getEdges:s}=Oi(),[i,l]=un(!1);return{validationResult:t,validateDiagram:m=>{let y=cn(m.nodes,m.edges),E=pn(y),h=E.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return i||l(!0),{isValid:E.isValid,errors:h}},handleValidationComplete:m=>{if(o(m),!m)return;let y=[],E=[];m.errors.forEach(b=>{b.nodeIds&&b.nodeIds.length>0&&b.nodeIds.forEach(N=>y.push(N)),b.edgeIds&&b.edgeIds.length>0&&b.edgeIds.forEach(N=>E.push(N))});let h=[...new Set(y)];n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})}))),r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:!1})})));let v=a(),p=s(),d=new Set(h),x=new Set;m.errors.forEach(b=>{var P,C;let N=ze.find(A=>A.id===b.id);(N==null?void 0:N.highlightRelatedEdges)!==!1&&((P=b.edgeIds)==null||P.forEach(A=>x.add(A)),(C=b.nodeIds)==null||C.forEach(A=>{p.forEach(L=>{(L.source===A||L.target===A)&&x.add(L.id)})}))});let u=new Set,T=new Set,I=new Set;v.forEach(b=>{b.type==="START_EVENT"?u.add(b.id):b.type==="END_EVENT"&&T.add(b.id)}),p.forEach(b=>{u.has(b.source)&&I.add(b.target),T.has(b.target)&&I.add(b.source)}),I.forEach(b=>{var N,S;if(d.has(b)){let P=(N=m.errors.find(A=>{var L;return(L=A.nodeIds)==null?void 0:L.includes(b)}))==null?void 0:N.id;((S=ze.find(A=>A.id===P))==null?void 0:S.highlightRelatedEdges)!==!1&&p.forEach(A=>{A.source===b&&T.has(A.target)&&(d.add(A.target),x.add(A.id)),A.target===b&&u.has(A.source)&&(d.add(A.source),x.add(A.id))})}}),d.size>0&&n(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:d.has(N.id)})}))),x.size>0&&r(b=>b.map(N=>w(_({},N),{data:w(_({},N.data),{hasError:x.has(N.id)})})))},clearValidation:()=>{o(null),l(!1),n(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),r(m=>m.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},isAutoValidationEnabled:i}};import{useReactFlow as Gi}from"@xyflow/react";import{useTranslation as Hi}from"lecom-ui";import{useEffect as Bi}from"react";import{v7 as gn}from"uuid";var wt=(e,t)=>{let n=e.filter(a=>a.type==="TASK").map(a=>{var i;let s=(i=a.data)==null?void 0:i.label;if(s&&s.startsWith(`${t} `)){let l=s.match(new RegExp(`^${t} (\\d+)$`));return l?parseInt(l[1],10):0}return 0}).filter(a=>a>0),r=n.length>0?Math.max(...n)+1:1;return`${t} ${r}`},Ct=(e,t)=>{let n=t.filter(i=>i.type==="TASK").map(i=>{var l;return(l=i.data)==null?void 0:l.label}).filter(Boolean);if(!n.includes(e))return e;let r=e.replace(/\s+\(\d+\)$/,""),a=n.filter(i=>i===r||i.startsWith(`${r} (`)).map(i=>{if(i===r)return 1;let l=i.match(/\s+\((\d+)\)$/);return l?parseInt(l[1],10):0}).filter(i=>i>0),s=2;for(;a.includes(s);)s++;return`${r} (${s})`};var zi=15,fn="bpmn:selection",Ui=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",a=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||a},En=e=>{if(!Ui(e.target))return!0;let t=window.getSelection(),o=t&&t.toString().length>0;if(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement){let n=e.target;return n.selectionStart===n.selectionEnd&&!o}return!o},bn=({offset:e=zi}={})=>{let{getNodes:t,setNodes:o,getEdges:n,setEdges:r}=Gi(),{t:a}=Hi();Bi(()=>{let s=l=>{var h,v;if(!En(l))return;let c=t(),g=n(),f=c.filter(p=>p.selected);if(!f.length)return;l.preventDefault(),l.stopPropagation();let m=g.filter(p=>f.some(d=>d.id===p.source)&&f.some(d=>d.id===p.target)),E=JSON.stringify({nodes:f,edges:m});(h=l.clipboardData)==null||h.setData(fn,E),(v=l.clipboardData)==null||v.setData("text/plain",`BPMN Selection: ${f.length} nodes`)},i=l=>{var v,p;if(!En(l))return;let c=(v=l.clipboardData)==null?void 0:v.getData(fn);if(!c)return;l.preventDefault(),l.stopPropagation();let g;try{g=JSON.parse(c)}catch(d){return}if(!((p=g.nodes)!=null&&p.length))return;let f=new Map,m=t(),y=[],E=g.nodes.map(d=>{var T;let x=gn();f.set(d.id,x);let u=w(_({},d),{id:x,selected:!0,position:{x:d.position.x+e,y:d.position.y+e}});if(d.type==="TASK"){let I=(T=d.data)==null?void 0:T.label,b=Ct(I||a("bpmn.task.label.prefix"),[...m,...y]);u.data=w(_({},d.data),{label:b})}return y.push(u),u}),h=g.edges.map(d=>w(_({},d),{id:gn(),selected:!0,source:f.get(d.source)||d.source,target:f.get(d.target)||d.target}));o(d=>[...d.map(x=>w(_({},x),{selected:!1})),...E]),r(d=>[...d.map(x=>w(_({},x),{selected:!1})),...h])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",i,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",i,!0)}},[t,o,n,r,e,a])};import{useReactFlow as Qi,useStoreApi as es}from"@xyflow/react";import{useTranslation as ts}from"lecom-ui";import{v7 as _n}from"uuid";import{create as Fi}from"zustand";var we=Fi(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));import{BaseEdge as Wi,EdgeLabelRenderer as Yi,getSmoothStepPath as Ki,MarkerType as $i,useNodes as Zi,useReactFlow as Xi,useViewport as qi}from"@xyflow/react";import{useState as ji}from"react";import{jsx as At,jsxs as yn}from"react/jsx-runtime";var Bm={type:"MESSAGE_EDGE",zIndex:2e3,markerEnd:{type:$i.Arrow},data:{label:""}},hn=({id:e,source:t,target:o,sourceX:n,sourceY:r,targetX:a,targetY:s,sourcePosition:i,targetPosition:l,data:c,selected:g})=>{let f=Zi(),{zoom:m}=qi(),{updateEdgeData:y}=Xi(),{isMultipleSelection:E}=V(),[h,v]=ji(!1),p=f.find(L=>L.id===t),d=f.find(L=>L.id===o),[x,u,T]=Ki({sourceX:n,sourceY:r,sourcePosition:i,targetX:a,targetY:s,targetPosition:l}),I=g||(p==null?void 0:p.selected)||(d==null?void 0:d.selected),b=I?"sequence-edge-marker-highlighted":"sequence-edge-marker",N=h||(c==null?void 0:c.label.trim().length)>0,S=1/m,P=()=>{v(!0)},C=()=>{v(!1)},A=L=>{y(e,{label:L.trim()})};return yn("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":I}),onBlur:C,onDoubleClick:P,children:[At(Wi,{id:e,path:x,markerEnd:`url(#${b})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":c==null?void 0:c.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":I&&!(c!=null&&c.hasError)})}),At(Yi,{children:yn("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${u}px, ${T}px)`},children:[g&&!E&&At(xe,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${S})`}}),N&&At(F,{value:c==null?void 0:c.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:h,onChange:A})]})})]})};import{jsx as vn,jsxs as Ji}from"react/jsx-runtime";var Nn=({fromX:e,fromY:t,toX:o,toY:n})=>Ji("g",{children:[vn("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:`M${e},${t} C${e} ${n} ${e} ${n} ${o},${n}`}),vn("circle",{cx:o,cy:n,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]});var Tn=({nodes:e,setNodes:t,setEdges:o})=>{let n=es(),{draggableNode:r,setDraggableNode:a}=we(),{getInternalNode:s,screenToFlowPosition:i}=Qi(),{t:l}=ts(),c=p=>{let d="[&>div]:bg-blue-50 [&>div]:outline [&>div]:outline-2 [&>div]:outline-blue-500";t(x=>x.map(u=>w(_({},u),{className:u.id===p?d:""})))},g=()=>{let{nodeLookup:p}=n.getState();return Array.from(p.values())},f=p=>{let d=s(p.id),x=g();if(p.type==="LANE"){if(_e({parentId:p.id,nodes:e,includeTypes:["LANE"]})){c();return}let S=x.filter(A=>A.id!==p.id&&A.type==="LANE"&&!A.parentId),P=Me(d,S);if(!P){c();return}if(_e({parentId:P.id,nodes:e,excludeTypes:["LANE"]})){c();return}c(P.id);return}let T=x.filter(N=>N.id!==p.id&&N.type==="LANE"),I=Me(d,T);if(!I){c();return}if(_e({parentId:I.id,nodes:e,includeTypes:["LANE"]})){c();return}c(I.id)},m=p=>{p.preventDefault(),p.dataTransfer.dropEffect="move"},y=(p,d)=>{p.preventDefault(),f(d)},E=(p,d,x)=>{var S,P;let u=C=>C.map(A=>w(_({},A),{className:void 0}));if(p.parentId===d.id){let C=ue(d.id,x);t(se(u(C)));return}if(p.type==="LANE"){if(_e({parentId:d.id,nodes:x,excludeTypes:["LANE"]}))return;let L=x.filter(H=>H.parentId===d.id).reduce((H,be)=>{var pe,ye;return H+((ye=(pe=be.measured)==null?void 0:pe.height)!=null?ye:0)},0),M={x:K.HEADER_WIDTH,y:L},O=x.map(H=>H.id===p.id?w(_({},H),{parentId:d.id,position:M,className:void 0}):w(_({},H),{className:void 0}));O=ue(d.id,O),t(se(O));return}if(_e({parentId:d.id,nodes:x,includeTypes:["LANE"]})){let C;if(p.parentId){let L=s(p.parentId),{x:M,y:O}=ie(L);C={x:M+((S=p.position.x)!=null?S:0),y:O+((P=p.position.y)!=null?P:0)}}let A=x.map(L=>L.id===p.id?w(_({},L),{position:C!=null?C:L.position,parentId:void 0,className:void 0}):w(_({},L),{className:void 0}));t(se(A));return}let b=Go(p,d),N=x.map(C=>C.id===p.id?w(_({},C),{parentId:d.id,position:b,className:void 0}):w(_({},C),{className:void 0}));t(se(N))};return{onDragOver:m,onDrop:p=>{if(p.preventDefault(),!(r!=null&&r.type))return;let d=i({x:p.clientX,y:p.clientY}),x={width:G[r.type].MIN_WIDTH,height:G[r.type].MIN_HEIGHT},u={id:_n(),type:r.type,position:d,measured:x,data:{label:r.type==="TASK"?wt(e,l("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute}},T=w(_({},u),{internals:{positionAbsolute:d}}),I=g(),b=r.type==="LANE",N=I.filter(C=>b?C.type==="LANE"&&!C.parentId:C.type==="LANE"),S=Me(T,N);S?E(T,S,[...I,T]):t(C=>{let A=C.concat(u);return se(A)});let P=p.dataTransfer.getData("sourceId");if(P){let C={id:_n(),source:P,target:u.id};if(r.type==="ANNOTATION"){o(A=>A.concat(_(_({},C),gt)));return}o(A=>A.concat(_(_({},C),te)))}a(null)},onNodeDrag:y,onNodeDragStop:async(p,d)=>{var S,P;let{nodeLookup:x}=n.getState(),u=s(d.id),T=Array.from(x.values()),I=d.type==="LANE",b=T.filter(C=>C.id!==d.id&&(I?C.type==="LANE"&&!C.parentId:C.type==="LANE")),N=Me(u,b);if(N){E(u,N,T);return}if(d.parentId){let C=s(d.parentId),{x:A,y:L}=ie(C),M={x:A+((S=d.position.x)!=null?S:0),y:L+((P=d.position.y)!=null?P:0)},O=e.map(H=>H.id===d.id?w(_({},H),{position:M,parentId:void 0}):H);O=ue(d.parentId,O),t(se(O))}}}};import{applyNodeChanges as os}from"@xyflow/react";import{useCallback as ns,useState as wn}from"react";function xn(e,t,o=5){var l,c,g,f,m,y,E,h;let n={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},r=t.find(v=>v.id===e.id);if(!r||!e.position)return n;let a={left:e.position.x,right:e.position.x+((c=(l=r.measured)==null?void 0:l.width)!=null?c:0),top:e.position.y,bottom:e.position.y+((f=(g=r.measured)==null?void 0:g.height)!=null?f:0),width:(y=(m=r.measured)==null?void 0:m.width)!=null?y:0,height:(h=(E=r.measured)==null?void 0:E.height)!=null?h:0},s=o,i=o;return t.filter(v=>v.id!==r.id).reduce((v,p)=>{var C,A,L,M,O,H,be,pe;let d={left:p.position.x,right:p.position.x+((A=(C=p.measured)==null?void 0:C.width)!=null?A:0),top:p.position.y,bottom:p.position.y+((M=(L=p.measured)==null?void 0:L.height)!=null?M:0),width:(H=(O=p.measured)==null?void 0:O.width)!=null?H:0,height:(pe=(be=p.measured)==null?void 0:be.height)!=null?pe:0},x=Math.abs(a.left-d.left);x<i&&(v.snapPosition.x=d.left,v.vertical=d.left,i=x);let u=Math.abs(a.right-d.right);u<i&&(v.snapPosition.x=d.right-a.width,v.vertical=d.right,i=u);let T=Math.abs(a.left-d.right);T<i&&(v.snapPosition.x=d.right,v.vertical=d.right,i=T);let I=Math.abs(a.right-d.left);I<i&&(v.snapPosition.x=d.left-a.width,v.vertical=d.left,i=I);let b=Math.abs(a.top-d.top);b<s&&(v.snapPosition.y=d.top,v.horizontal=d.top,s=b);let N=Math.abs(a.bottom-d.top);N<s&&(v.snapPosition.y=d.top-a.height,v.horizontal=d.top,s=N);let S=Math.abs(a.bottom-d.bottom);S<s&&(v.snapPosition.y=d.bottom-a.height,v.horizontal=d.bottom,s=S);let P=Math.abs(a.top-d.bottom);return P<s&&(v.snapPosition.y=d.bottom,v.horizontal=d.bottom,s=P),v},n)}var Cn=()=>{let[e,t]=wn(void 0),[o,n]=wn(void 0),r=ns((a,s)=>{var i,l;if(t(void 0),n(void 0),a.length===1&&a[0].type==="position"&&a[0].dragging&&a[0].position){let c=xn(a[0],s);a[0].position.x=(i=c.snapPosition.x)!=null?i:a[0].position.x,a[0].position.y=(l=c.snapPosition.y)!=null?l:a[0].position.y,t(c.horizontal),n(c.vertical)}return os(a,s)},[]);return{helperLineHorizontal:e,helperLineVertical:o,customApplyNodeChanges:r}};import{useReactFlow as as}from"@xyflow/react";import{v7 as Ln}from"uuid";var In={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Sn={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},An=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],a=e.match(/(--.*|\|.*?\|)/i)||[],s="",i="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",i=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(s="gateway-exclusive",i=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a.length&&(l=a[1].replace(/(\||--)/g,""),e=e.replace(a[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:i}),{step:e,type:s,label:i,edgeLabel:l}},rs=e=>{e=e||"";let t=e.trim().split(`
2
2
  `),o={},n=[];return t.forEach(r=>{r=r||"";let a=r.trim().split("-->");if(a.length!==2){console.warn("Invalid number of steps");return}let s=An(a[0],o),i=An(a[1],o);s&&i&&n.push({sourceId:s.step,targetId:i.step,label:s.edgeLabel||i.edgeLabel||""})}),{components:o,connections:n}},kn=e=>{let{components:t,connections:o}=rs(e);return{nodes:t,edges:o}};var Pn=()=>{let{setNodes:e,setEdges:t,fitView:o}=as();return{createDiagram:r=>{let{nodes:a,edges:s}=kn(r),i=[],l=new Map;for(let[m,y]of Object.entries(a)){let E=Ln(),h=In[y.type],v=Sn[y.type];l.set(m,E);let p=G[h].MIN_WIDTH,d=G[h].MIN_HEIGHT;i.push({id:E,type:h,data:{label:y.label||"",variant:v,attribute:""},position:{x:0,y:0},width:p,height:d,measured:{width:p,height:d}})}let c=[];for(let m of s){let y=w(_({},te),{id:Ln(),source:l.get(m.sourceId)||m.sourceId,target:l.get(m.targetId)||m.targetId});c.push(y)}let{nodes:g,edges:f}=zo(i,c);e(g),t(f),o()}}};import{useEffect as is,useCallback as ss}from"react";var ls={origin:"*",debug:!1};function Dn(e,t=ls){let{origin:o,debug:n}=t,r=ss((a,s)=>{n&&console.debug("[postMessage] sending:",{type:a,payload:s}),window.parent.postMessage({type:a,payload:s},o||"*")},[o,n]);return is(()=>{let a=s=>{let{type:i,data:l}=s.data||{};n&&console.debug("[postMessage] received:",s.data),i&&e[i]&&e[i](l)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[e,n]),{sendMessage:r}}import{useReactFlow as ds}from"@xyflow/react";var Rn=(e,t)=>{let{getNodes:o,getEdges:n}=ds();return{selectElement:s=>{let i=o().map(c=>w(_({},c),{selected:c.id===s})),l=n().map(c=>w(_({},c),{selected:c.id===s}));return e(i),t(l),!0},isReady:()=>!0}};import{useReactFlow as cs}from"@xyflow/react";import{useCallback as Ue,useState as Vn}from"react";import{useDebouncedCallback as ps}from"use-debounce";var us={nodes:[],edges:[]},ms=500,Mn=10,On=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=cs(),[r,a]=Vn([us]),[s,i]=Vn(0),l=r[s],c=s>0,g=s<r.length-1,f=Ue(d=>{o(r[d].nodes),n(r[d].edges)},[r,o,n]),m=Ue(()=>{if(s>0){let d=s-1;i(d),f(d)}},[s,f]),y=Ue(()=>{if(s<r.length-1){let d=s+1;i(d),f(d)}},[r,s,f]),E=d=>{let u=[...r.slice(0,s+1),d],T=u.length>Mn?u.slice(u.length-Mn):u;a(T),i(T.length-1)},h=ps(()=>{let d=e(),x=t(),u={nodes:d,edges:x};JSON.stringify(l)!==JSON.stringify(u)&&E(u)},ms),v=Ue(d=>{if(d==="forceSave"){h();return}d.some(u=>u.type!=="select")&&h()},[h]),p=Ue(()=>{a([]),i(0)},[]);return{undo:m,redo:y,saveHistory:v,canUndo:c,canRedo:g,clearHistory:p}};import{jsx as Gn}from"react/jsx-runtime";var Jt=({id:e,className:t})=>Gn("marker",{id:e,className:k("react-flow__arrowhead",t),viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"7",markerHeight:"7",orient:"auto",markerUnits:"userSpaceOnUse",fill:"currentColor",stroke:"currentColor",children:Gn("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});import{jsx as Qt,jsxs as gs}from"react/jsx-runtime";var Hn=()=>Qt("svg",{style:{position:"absolute",top:0,left:0},children:gs("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 nr}from"@xyflow/react";import{Button as no,Tooltip as ro,TooltipContent as ao,TooltipTrigger as io,useTranslation as cl}from"lecom-ui";import{HandIcon as pl,MapIcon as ul,MousePointerIcon as ml}from"lucide-react";import{useCallback as gl,useEffect as rr}from"react";import{useStore as fs}from"@xyflow/react";var Es=e=>({unselectAll:e.unselectNodesAndEdges}),Fe=()=>{let{unselectAll:e}=fs(Es);return{deselectAll:async()=>(e(),new Promise(o=>{setTimeout(o,1e3)}))}};import{Tooltip as zs,TooltipContent as Us,TooltipTrigger as Fs,useNotificationToast as Ws,useTranslation as Ys}from"lecom-ui";var We=(p=>(p.START_EVENT="START_EVENT",p.END_EVENT="END_EVENT",p.TASK="TASK",p.SUBPROCESS="SUBPROCESS",p.GATEWAY="GATEWAY",p.ANNOTATION="ANNOTATION",p.CONNECTION="CONNECTION",p.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",p.ACTIVITY="ACTIVITY",p.PROCESS_INTERFACE="PROCESS_INTERFACE",p.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",p.VARIANT_ACTIVITY="VARIANT_ACTIVITY",p.AUTO_ACTIVITY="AUTO_ACTIVITY",p.DATA_STORE="DATA_STORE",p.DATA_OBJECT="DATA_OBJECT",p.DATA_OUTPUT="DATA_OUTPUT",p.DATA_INPUT="DATA_INPUT",p))(We||{});import{useReactFlow as Ps}from"@xyflow/react";import{useNotificationToast as Ds,useTranslation as Rs,Button as Vs}from"lecom-ui";var Bn=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var a;t((a=r.target)==null?void 0:a.result)},n.onerror=r=>{var a;o((a=r.target)==null?void 0:a.error)},n.readAsText(e)});function zn({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
3
3
  `),a=encodeURI(r);It(a,`${o}.csv`)}var It=(e,t)=>{let o=document.createElement("a");o.setAttribute("download",t),o.setAttribute("href",e),document.body.appendChild(o),o.click(),document.body.removeChild(o)};import{v7 as As}from"uuid";import{xml2json as bs,json2xml as Jg}from"xml-js";var ys={compact:!0,spaces:4},hs=e=>e.replaceAll(`
4
4
  `,"&#xA;");function Un(e,t=ys){if(e)return JSON.parse(bs(e,w(_({},t),{attributeValueFn:hs})))}function Fn(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}import{v7 as Ns}from"uuid";var rf={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Wn={script:"SCRIPT",subprocess:"SUBPROCESS"},Yn={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL"};var Ce=({cell:e,type:t,variant:o=""})=>{let{_attributes:n,mxGeometry:r}=e,{value:a}=n,s=Number(r._attributes.width),i=Number(r._attributes.height);return{id:n.id,type:t,data:{label:a||"",variant:o,attribute:""},position:{x:Number(r._attributes.x),y:Number(r._attributes.y)},width:s,height:i,measured:{width:s,height:i}}},_s=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=G.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.START_EVENT.MIN_HEIGHT,{node:Ce({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ts=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=G.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=G.END_EVENT.MIN_HEIGHT,{node:Ce({cell:e,type:"END_EVENT"}),status:n,originalType:o}},xs=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n=Wn[t],r="imported";return["script","none"].includes(t)||(r="adapted"),e.mxGeometry._attributes.width=De(e.mxGeometry._attributes.width,G.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=De(e.mxGeometry._attributes.height,G.TASK.MIN_HEIGHT),{node:Ce({cell:e,type:"TASK",variant:n}),status:r,originalType:o}},ws=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Yn[o],r=["none","inclusive","event-based"],a="imported";return r.includes(o)&&(a="adapted"),e.mxGeometry._attributes.width=G.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=G.GATEWAY.MIN_HEIGHT,{node:Ce({cell:e,type:"GATEWAY",variant:n}),status:a,originalType:t}},Cs=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=De(e.mxGeometry._attributes.width,G.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=De(e.mxGeometry._attributes.height,G.ANNOTATION.MIN_HEIGHT),{node:Ce({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Kn=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=G.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=G.UNSUPPORTED.MIN_HEIGHT,{node:Ce({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},$n=(e,t)=>{let{source:o,target:n}=e._attributes;return w(_({},te),{id:Ns(),source:t.get(o)||o,target:t.get(n)||n})},Zn={TASK:xs,GATEWAY:ws,START_EVENT:_s,END_EVENT:Ts,ANNOTATION:Cs};var Is=e=>{var s;let t=new Map,o=Object.values(We),n=e.filter(i=>{var l;return o.includes((l=i._attributes)==null?void 0:l.type)}),r=[],a=[];for(let i of n){let l=As(),{type:c}=i._attributes,g=Zn[c]||Kn;t.set((s=i._attributes)==null?void 0:s.id,l),i._attributes.id=l;let{node:f,status:m,originalType:y}=g(i);r.push(f),a.push({originalType:y,type:f.type,variant:f.data.variant,value:Fn(f.data.label),status:m})}return{nodes:r,governanceIdToNodeIdMap:t,summary:a}},Ss=(e,t)=>e.filter(r=>{var a;return(a=r._attributes)==null?void 0:a.edge}).map(r=>$n(r,t)),ks=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Is(t.root.mxCell),a=Ss(t.root.mxCell,n);return{nodes:o,edges:a,summary:r}},Ls=async e=>{let t=await Bn(e),o=Un(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},a=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),s=r==null?void 0:r.root;if(!a||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Xn=async e=>{try{let t=await Ls(e),{nodes:o,edges:n,summary:r}=ks(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};import{jsx as Ms}from"react/jsx-runtime";var qn=()=>{let{t:e}=Rs(),{toast:t}=Ds(),{setNodes:o,setEdges:n,fitView:r}=Ps(),a=i=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=i.map(g=>[g.originalType,g.value,e(`adapter.governance.report.status.${g.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:Ms(Vs,{size:"small",variant:"ghost",onClick:()=>zn({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{createDiagram:async i=>{try{let{nodes:l,edges:c,summary:g}=await Xn(i);if(o(m=>m.concat(l)),n(m=>m.concat(c)),r(),g.some(m=>m.status==="unsupported")){a(g);return}t({variant:"success",content:e("adapter.governance.success.default")})}catch(l){let c=l instanceof Error?l.message:"DEFAULT";t({variant:"error",content:e(`adapter.governance.error.${c}`)})}}}};import{Button as Os}from"lecom-ui";import{useRef as Gs}from"react";import{Fragment as Hs,jsx as jn,jsxs as Bs}from"react/jsx-runtime";var Jn=i=>{var l=i,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:a}=l,s=ae(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=Gs(null),g=m=>{let y=m.target.files;y!=null&&y.length&&a(y),c.current&&(c.current.value="")};return Bs(Hs,{children:[jn(Os,w(_({onClick:m=>{var y;(y=c.current)==null||y.click(),r==null||r(m)}},s),{children:e})),jn("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:g})]})};import{jsx as St,jsxs as Ks}from"react/jsx-runtime";var Qn=({disabled:e=!1})=>{let{t}=Ys(),{toast:o}=Ws(),{createDiagram:n}=qn(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},a=s=>{let i=s[0];if(!i){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(i)};return Ks(zs,{children:[St(Fs,{asChild:!0,children:St(Jn,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:a,children:St(So,{})})}),St(Us,{color:"black",children:t("editor.controls.actions.import_governance")})]})};import{jsx as $s}from"react/jsx-runtime";var eo=({shortcut:e})=>$s("span",{className:"min-h-7.5 inline-flex justify-center items-center py-0.5 px-1.5 bg-grey-100 border border-grey-300 font-mono text-gray-800 shadow-lg rounded-md text-grey-900",children:e});import{Button as el,DropdownMenu as tl,DropdownMenuContent as ol,DropdownMenuItem as oo,DropdownMenuTrigger as nl,Tooltip as kt,TooltipContent as Lt,TooltipTrigger as Pt,useTranslation as rl}from"lecom-ui";import{FileCodeIcon as al,FileImageIcon as il,FolderOutputIcon as sl,PrinterIcon as ll}from"lucide-react";import{useState as dl}from"react";import{useReactFlow as Zs}from"@xyflow/react";import{toPng as er,toSvg as Xs}from"html-to-image";import{toast as qs,useTranslation as js}from"lecom-ui";import{useState as Js}from"react";var Qs=3,to="diagram",tr=()=>{let{t:e}=js(),{getNodes:t}=Zs(),{deselectAll:o}=Fe(),[n,r]=Js({png:!1,html:!1,print:!1}),a=()=>{let{x:g,y:f,width:m,height:y}=Fo(t());return{width:m,height:y,style:{width:`${m}px`,height:`${y}px`,transform:`translate(${-g}px, ${-f}px)`}}},s=async(g,f)=>{r(w(_({},n),{[f]:!0})),await o();try{let m=Uo();if(!m)throw new Error("Flow element not found");let y=a();return await g(m,y)}catch(m){qs({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(w(_({},n),{[f]:!1}))}};return{exportAsPng:async(g=to)=>{await s(async(f,m)=>{let y=await er(f,w(_({},m),{backgroundColor:"#fcfcfc"}));It(y,`${g}.png`)},"png")},exportAsHtml:async(g=to)=>{await s(async(f,m)=>{let y=await Xs(f,w(_({},m),{backgroundColor:"#fcfcfc"})),E=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lecom-modeler",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",