lecom-modeler 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1,5 +1,8 @@
1
- "use strict";var zu=Object.create;var gn=Object.defineProperty,Fu=Object.defineProperties,Wu=Object.getOwnPropertyDescriptor,Yu=Object.getOwnPropertyDescriptors,Uu=Object.getOwnPropertyNames,ir=Object.getOwnPropertySymbols,$u=Object.getPrototypeOf,ki=Object.prototype.hasOwnProperty,vs=Object.prototype.propertyIsEnumerable;var Ns=(e,t,o)=>t in e?gn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))ki.call(t,o)&&Ns(e,o,t[o]);if(ir)for(var o of ir(t))vs.call(t,o)&&Ns(e,o,t[o]);return e},N=(e,t)=>Fu(e,Yu(t));var yt=(e,t)=>{var o={};for(var n in e)ki.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&ir)for(var n of ir(e))t.indexOf(n)<0&&vs.call(e,n)&&(o[n]=e[n]);return o};var Xu=(e,t)=>{for(var o in t)gn(e,o,{get:t[o],enumerable:!0})},ws=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Uu(t))!ki.call(e,r)&&r!==o&&gn(e,r,{get:()=>t[r],enumerable:!(n=Wu(t,r))||n.enumerable});return e};var Ku=(e,t,o)=>(o=e!=null?zu($u(e)):{},ws(t||!e||!e.__esModule?gn(o,"default",{value:e,enumerable:!0}):o,e)),qu=e=>ws(gn({},"__esModule",{value:!0}),e);var Eg={};Xu(Eg,{EditorMode:()=>Ye,ElementPosition:()=>ar,ElementType:()=>hn,GatewayElementVariant:()=>lr,GatewayVariant:()=>st,Modeler:()=>Bu,ModelerProvider:()=>Ou,NodeAttribute:()=>dt,NodeType:()=>Q,NodeVariant:()=>it,RoutingVariant:()=>cr,useModeler:()=>Mi});module.exports=qu(Eg);var Di=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var sr=require("@produto-lecom/lecom-ui");var As={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting..."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Is={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Cs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando..."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de Atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Ss={pt_BR:Cs,en_US:As,es_ES:Is};var Ms,Ps,Zu=(Ps=(Ms=Di("LecomUserLanguage"))!=null?Ms:Di("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Ps:sr.Translations.PT_BR;(0,sr.initializeI18n)({lng:Zu,resources:Ss});var Ye=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ye||{});var hn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(hn||{}),ar=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(ar||{}),lr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(lr||{}),cr=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(cr||{});var Vo=require("lucide-react");var io=require("react/jsx-runtime"),dr=({size:e=24,className:t})=>(0,io.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,io.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,io.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,io.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,io.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ri=require("react/jsx-runtime"),So=({size:e=24,className:t})=>(0,Ri.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,Ri.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 Dt=require("react/jsx-runtime"),Mo=({size:e=24,className:t})=>(0,Dt.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,Dt.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,Dt.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Dt.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Dt.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Dt.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var Po=require("react/jsx-runtime"),Lo=({size:e=24,className:t})=>(0,Po.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,Po.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,Po.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Po.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var ko=require("react/jsx-runtime"),Do=({size:e=24,className:t})=>(0,ko.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,ko.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,ko.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ko.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var Ro=require("react/jsx-runtime"),Ls=({size:e=24,className:t})=>(0,Ro.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,Ro.jsxs)("g",{children:[(0,Ro.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,Ro.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var ks=require("clsx"),Ds=require("tailwind-merge");function D(...e){return(0,Ds.twMerge)((0,ks.clsx)(e))}var Rt=(e=0,t=0)=>e<t?t:e,ur=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var yn=require("react/jsx-runtime"),Rs=({size:e=24,className:t})=>(0,yn.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:D("stroke-2",t),children:[(0,yn.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,yn.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var pr=require("react/jsx-runtime"),Os=({size:e=24,className:t})=>(0,pr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,pr.jsx)("g",{children:(0,pr.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 Oi=require("react/jsx-runtime"),fr=({size:e=24,className:t})=>(0,Oi.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,Oi.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 Vi=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,Vi.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",className:D("stroke-2",t),children:(0,Vi.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 Oo=require("react/jsx-runtime"),Vs=({size:e=24,className:t})=>(0,Oo.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,Oo.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,Oo.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,Oo.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Ot=require("react/jsx-runtime"),Hs=({size:e=24,className:t})=>(0,Ot.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"#6b7280",strokeWidth:"2",className:t,children:[(0,Ot.jsx)("path",{d:"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,Ot.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,Ot.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,Ot.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Ot.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var so=require("react/jsx-runtime"),Gs=({size:e=24,className:t})=>(0,so.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,so.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,so.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,so.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,so.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Q=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(Q||{}),it=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(it||{}),mr={SCRIPT:{icon:Vo.ScrollText},SUBPROCESS:{icon:Vo.SquarePlus}},dt=(t=>(t.LOOP="LOOP",t))(dt||{}),gr={LOOP:{icon:Vo.RotateCcw}},st=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(st||{}),Hi={EXCLUSIVE:{icon:Lo},PARALLEL:{icon:Do},COMPLEX:{icon:Mo}};var Vu=require("@xyflow/react"),Ae=require("react");var Qt=require("@xyflow/react"),Ci=require("react");var qt=require("@xyflow/react"),kt=require("react");var Bs=require("zustand"),zs=require("@xyflow/react"),Fs=require("react");var hr=()=>{let{setEdges:e}=(0,zs.useReactFlow)();return(0,Fs.useCallback)(()=>{let o=ao.getState().pathEdgeIds;e(n=>n.map(r=>N(b({},r),{selected:o.includes(r.id)})))},[e])},ao=(0,Bs.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=b({},n.statusByNodeId),i=b({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:g,path:x}=p.shift();if(g===u)return x;let m=a[g]||[];for(let{targetId:E,edgeId:y}of m)f.has(E)||(f.add(E),p.push({node:E,path:[...x,y]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));var Fo=require("@xyflow/react");var Ju={value:()=>{}};function Ys(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new yr(o)}function yr(e){this._=e}function Qu(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}yr.prototype=Ys.prototype={constructor:yr,on:function(e,t){var o=this._,n=Qu(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=ju(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=Ws(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Ws(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new yr(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var o=new Array(r),n=0,r,i;n<r;++n)o[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],n=0,r=i.length;n<r;++n)i[n].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],r=0,i=n.length;r<i;++r)n[r].value.apply(t,o)}};function ju(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Ws(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Ju,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Gi=Ys;var xr="http://www.w3.org/1999/xhtml",Bi={svg:"http://www.w3.org/2000/svg",xhtml:xr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ct(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Bi.hasOwnProperty(t)?{space:Bi[t],local:e}:e}function ep(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===xr&&t.documentElement.namespaceURI===xr?t.createElement(e):t.createElementNS(o,e)}}function tp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Er(e){var t=Ct(e);return(t.local?tp:ep)(t)}function op(){}function lo(e){return e==null?op:function(){return this.querySelector(e)}}function Us(e){typeof e!="function"&&(e=lo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Le(n,this._parents)}function zi(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function np(){return[]}function En(e){return e==null?np:function(){return this.querySelectorAll(e)}}function rp(e){return function(){return zi(e.apply(this,arguments))}}function $s(e){typeof e=="function"?e=rp(e):e=En(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Le(n,r)}function bn(e){return function(){return this.matches(e)}}function br(e){return function(t){return t.matches(e)}}var ip=Array.prototype.find;function sp(e){return function(){return ip.call(this.children,e)}}function ap(){return this.firstElementChild}function Xs(e){return this.select(e==null?ap:sp(typeof e=="function"?e:br(e)))}var lp=Array.prototype.filter;function cp(){return Array.from(this.children)}function dp(e){return function(){return lp.call(this.children,e)}}function Ks(e){return this.selectAll(e==null?cp:dp(typeof e=="function"?e:br(e)))}function qs(e){typeof e!="function"&&(e=bn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Le(n,this._parents)}function _r(e){return new Array(e.length)}function Zs(){return new Le(this._enter||this._groups.map(_r),this._parents)}function _n(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}_n.prototype={constructor:_n,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Js(e){return function(){return e}}function up(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new _n(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function pp(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new _n(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function fp(e){return e.__data__}function Qs(e,t){if(!arguments.length)return Array.from(this,fp);var o=t?pp:up,n=this._parents,r=this._groups;typeof e!="function"&&(e=Js(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=mp(e.call(d,d&&d.__data__,c,n)),g=f.length,x=s[c]=new Array(g),m=a[c]=new Array(g),E=l[c]=new Array(p);o(d,u,x,m,E,f,t);for(var y=0,h=0,v,T;y<g;++y)if(v=x[y]){for(y>=h&&(h=y+1);!(T=m[h])&&++h<g;);v._next=T||null}}return a=new Le(a,n),a._enter=s,a._exit=l,a}function mp(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function js(){return new Le(this._exit||this._groups.map(_r),this._parents)}function ea(e,t,o){var n=this.enter(),r=this,i=this.exit();return typeof e=="function"?(n=e(n),n&&(n=n.selection())):n=n.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),o==null?i.remove():o(i),n&&r?n.merge(r).order():r}function ta(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,p=s[l]=new Array(u),f,g=0;g<u;++g)(f=c[g]||d[g])&&(p[g]=f);for(;l<r;++l)s[l]=o[l];return new Le(s,this._parents)}function oa(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function na(e){e||(e=gp);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Le(r,this._parents).order()}function gp(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ra(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ia(){return Array.from(this)}function sa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function aa(){let e=0;for(let t of this)++e;return e}function la(){return!this.node()}function ca(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function hp(e){return function(){this.removeAttribute(e)}}function yp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xp(e,t){return function(){this.setAttribute(e,t)}}function Ep(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function bp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function _p(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function da(e,t){var o=Ct(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?yp:hp:typeof t=="function"?o.local?_p:bp:o.local?Ep:xp)(o,t))}function Tr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Tp(e){return function(){this.style.removeProperty(e)}}function Np(e,t,o){return function(){this.style.setProperty(e,t,o)}}function vp(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function ua(e,t,o){return arguments.length>1?this.each((t==null?Tp:typeof t=="function"?vp:Np)(e,t,o==null?"":o)):Vt(this.node(),e)}function Vt(e,t){return e.style.getPropertyValue(t)||Tr(e).getComputedStyle(e,null).getPropertyValue(t)}function wp(e){return function(){delete this[e]}}function Ap(e,t){return function(){this[e]=t}}function Ip(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function pa(e,t){return arguments.length>1?this.each((t==null?wp:typeof t=="function"?Ip:Ap)(e,t)):this.node()[e]}function fa(e){return e.trim().split(/^|\s+/)}function Fi(e){return e.classList||new ma(e)}function ma(e){this._node=e,this._names=fa(e.getAttribute("class")||"")}ma.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ga(e,t){for(var o=Fi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function ha(e,t){for(var o=Fi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Cp(e){return function(){ga(this,e)}}function Sp(e){return function(){ha(this,e)}}function Mp(e,t){return function(){(t.apply(this,arguments)?ga:ha)(this,e)}}function ya(e,t){var o=fa(e+"");if(arguments.length<2){for(var n=Fi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Mp:t?Cp:Sp)(o,t))}function Pp(){this.textContent=""}function Lp(e){return function(){this.textContent=e}}function kp(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function xa(e){return arguments.length?this.each(e==null?Pp:(typeof e=="function"?kp:Lp)(e)):this.node().textContent}function Dp(){this.innerHTML=""}function Rp(e){return function(){this.innerHTML=e}}function Op(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ea(e){return arguments.length?this.each(e==null?Dp:(typeof e=="function"?Op:Rp)(e)):this.node().innerHTML}function Vp(){this.nextSibling&&this.parentNode.appendChild(this)}function ba(){return this.each(Vp)}function Hp(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _a(){return this.each(Hp)}function Ta(e){var t=typeof e=="function"?e:Er(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Gp(){return null}function Na(e,t){var o=typeof e=="function"?e:Er(e),n=t==null?Gp:typeof t=="function"?t:lo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Bp(){var e=this.parentNode;e&&e.removeChild(this)}function va(){return this.each(Bp)}function zp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fp(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wa(e){return this.select(e?Fp:zp)}function Aa(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Wp(e){return function(t){e.call(this,t,this.__data__)}}function Yp(e){return e.trim().split(/^|\s+/).map(function(t){var o="",n=t.indexOf(".");return n>=0&&(o=t.slice(n+1),t=t.slice(0,n)),{type:t,name:o}})}function Up(e){return function(){var t=this.__on;if(t){for(var o=0,n=-1,r=t.length,i;o<r;++o)i=t[o],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++n]=i;++n?t.length=n:delete this.__on}}}function $p(e,t,o){return function(){var n=this.__on,r,i=Wp(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Ia(e,t,o){var n=Yp(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?$p:Up,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Ca(e,t,o){var n=Tr(e),r=n.CustomEvent;typeof r=="function"?r=new r(t,o):(r=n.document.createEvent("Event"),o?(r.initEvent(t,o.bubbles,o.cancelable),r.detail=o.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Xp(e,t){return function(){return Ca(this,e,t)}}function Kp(e,t){return function(){return Ca(this,e,t.apply(this,arguments))}}function Sa(e,t){return this.each((typeof t=="function"?Kp:Xp)(e,t))}function*Ma(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var qp=[null];function Le(e,t){this._groups=e,this._parents=t}function Pa(){return new Le([[document.documentElement]],qp)}function Zp(){return this}Le.prototype=Pa.prototype={constructor:Le,select:Us,selectAll:$s,selectChild:Xs,selectChildren:Ks,filter:qs,data:Qs,enter:Zs,exit:js,join:ea,merge:ta,selection:Zp,order:oa,sort:na,call:ra,nodes:ia,node:sa,size:aa,empty:la,each:ca,attr:da,style:ua,property:pa,classed:ya,text:xa,html:Ea,raise:ba,lower:_a,append:Ta,insert:Na,remove:va,clone:wa,datum:Aa,on:Ia,dispatch:Sa,[Symbol.iterator]:Ma};var St=Pa;function Nr(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Wi(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function vn(){}var Tn=.7,Ar=1/Tn,Ho="\\s*([+-]?\\d+)\\s*",Nn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Jp=/^#([0-9a-f]{3,8})$/,Qp=new RegExp(`^rgb\\(${Ho},${Ho},${Ho}\\)$`),jp=new RegExp(`^rgb\\(${xt},${xt},${xt}\\)$`),ef=new RegExp(`^rgba\\(${Ho},${Ho},${Ho},${Nn}\\)$`),tf=new RegExp(`^rgba\\(${xt},${xt},${xt},${Nn}\\)$`),of=new RegExp(`^hsl\\(${Nn},${xt},${xt}\\)$`),nf=new RegExp(`^hsla\\(${Nn},${xt},${xt},${Nn}\\)$`),La={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Nr(vn,Ht,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ka,formatHex:ka,formatHex8:rf,formatHsl:sf,formatRgb:Da,toString:Da});function ka(){return this.rgb().formatHex()}function rf(){return this.rgb().formatHex8()}function sf(){return Ba(this).formatHsl()}function Da(){return this.rgb().formatRgb()}function Ht(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Jp.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ra(t):o===3?new Ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?vr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?vr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Qp.exec(e))?new Ue(t[1],t[2],t[3],1):(t=jp.exec(e))?new Ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ef.exec(e))?vr(t[1],t[2],t[3],t[4]):(t=tf.exec(e))?vr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=of.exec(e))?Ha(t[1],t[2]/100,t[3]/100,1):(t=nf.exec(e))?Ha(t[1],t[2]/100,t[3]/100,t[4]):La.hasOwnProperty(e)?Ra(La[e]):e==="transparent"?new Ue(NaN,NaN,NaN,0):null}function Ra(e){return new Ue(e>>16&255,e>>8&255,e&255,1)}function vr(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ue(e,t,o,n)}function af(e){return e instanceof vn||(e=Ht(e)),e?(e=e.rgb(),new Ue(e.r,e.g,e.b,e.opacity)):new Ue}function Go(e,t,o,n){return arguments.length===1?af(e):new Ue(e,t,o,n==null?1:n)}function Ue(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Nr(Ue,Go,Wi(vn,{brighter(e){return e=e==null?Ar:Math.pow(Ar,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Tn:Math.pow(Tn,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ue(uo(this.r),uo(this.g),uo(this.b),Ir(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Oa,formatHex:Oa,formatHex8:lf,formatRgb:Va,toString:Va}));function Oa(){return`#${co(this.r)}${co(this.g)}${co(this.b)}`}function lf(){return`#${co(this.r)}${co(this.g)}${co(this.b)}${co((isNaN(this.opacity)?1:this.opacity)*255)}`}function Va(){let e=Ir(this.opacity);return`${e===1?"rgb(":"rgba("}${uo(this.r)}, ${uo(this.g)}, ${uo(this.b)}${e===1?")":`, ${e})`}`}function Ir(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function uo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function co(e){return e=uo(e),(e<16?"0":"")+e.toString(16)}function Ha(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new ut(e,t,o,n)}function Ba(e){if(e instanceof ut)return new ut(e.h,e.s,e.l,e.opacity);if(e instanceof vn||(e=Ht(e)),!e)return new ut;if(e instanceof ut)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new ut(a,s,l,e.opacity)}function za(e,t,o,n){return arguments.length===1?Ba(e):new ut(e,t,o,n==null?1:n)}function ut(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Nr(ut,za,Wi(vn,{brighter(e){return e=e==null?Ar:Math.pow(Ar,e),new ut(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Tn:Math.pow(Tn,e),new ut(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ue(Yi(e>=240?e-240:e+120,r,n),Yi(e,r,n),Yi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new ut(Ga(this.h),wr(this.s),wr(this.l),Ir(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Ir(this.opacity);return`${e===1?"hsl(":"hsla("}${Ga(this.h)}, ${wr(this.s)*100}%, ${wr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ga(e){return e=(e||0)%360,e<0?e+360:e}function wr(e){return Math.max(0,Math.min(1,e||0))}function Yi(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function Ui(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function Fa(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Ui((o-n/t)*t,a,r,i,s)}}function Wa(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return Ui((o-n/t)*t,r,i,a,s)}}var $i=e=>()=>e;function cf(e,t){return function(o){return e+o*t}}function df(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function Ya(e){return(e=+e)==1?Cr:function(t,o){return o-t?df(t,o,e):$i(isNaN(t)?o:t)}}function Cr(e,t){var o=t-e;return o?cf(e,o):$i(isNaN(e)?t:e)}var Sr=function e(t){var o=Ya(t);function n(r,i){var a=o((r=Go(r)).r,(i=Go(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=Cr(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Ua(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=Go(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var uf=Ua(Fa),pf=Ua(Wa);function at(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Ki=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Xi=new RegExp(Ki.source,"g");function ff(e){return function(){return e}}function mf(e){return function(t){return e(t)+""}}function qi(e,t){var o=Ki.lastIndex=Xi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=Ki.exec(e))&&(r=Xi.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:at(n,r)})),o=Xi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?mf(l[0].x):ff(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var $a=180/Math.PI,Mr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Zi(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*$a,skewX:Math.atan(l)*$a,scaleX:a,scaleY:s}}var Pr;function Xa(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mr:Zi(t.a,t.b,t.c,t.d,t.e,t.f)}function Ka(e){return e==null?Mr:(Pr||(Pr=document.createElementNS("http://www.w3.org/2000/svg","g")),Pr.setAttribute("transform",e),(e=Pr.transform.baseVal.consolidate())?(e=e.matrix,Zi(e.a,e.b,e.c,e.d,e.e,e.f)):Mr)}function qa(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,g){if(c!==u||d!==p){var x=f.push("translate(",null,t,null,o);g.push({i:x-4,x:at(c,u)},{i:x-2,x:at(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:at(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:at(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,g){if(c!==u||d!==p){var x=f.push(r(f)+"scale(",null,",",null,")");g.push({i:x-4,x:at(c,u)},{i:x-2,x:at(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var g=-1,x=p.length,m;++g<x;)u[(m=p[g]).i]=m.x(f);return u.join("")}}}var Ji=qa(Xa,"px, ","px)","deg)"),Qi=qa(Ka,", ",")",")");var Bo=0,An=0,wn=0,Ja=1e3,Lr,In,kr=0,po=0,Dr=0,Cn=typeof performance=="object"&&performance.now?performance:Date,Qa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Mn(){return po||(Qa(gf),po=Cn.now()+Dr)}function gf(){po=0}function Sn(){this._call=this._time=this._next=null}Sn.prototype=Rr.prototype={constructor:Sn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Mn():+o)+(t==null?0:+t),!this._next&&In!==this&&(In?In._next=this:Lr=this,In=this),this._call=e,this._time=o,ji()},stop:function(){this._call&&(this._call=null,this._time=1/0,ji())}};function Rr(e,t,o){var n=new Sn;return n.restart(e,t,o),n}function ja(){Mn(),++Bo;for(var e=Lr,t;e;)(t=po-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Bo}function Za(){po=(kr=Cn.now())+Dr,Bo=An=0;try{ja()}finally{Bo=0,yf(),po=0}}function hf(){var e=Cn.now(),t=e-kr;t>Ja&&(Dr-=t,kr=e)}function yf(){for(var e,t=Lr,o,n=1/0;t;)t._call?(n>t._time&&(n=t._time),e=t,t=t._next):(o=t._next,t._next=null,t=e?e._next=o:Lr=o);In=e,ji(n)}function ji(e){if(!Bo){An&&(An=clearTimeout(An));var t=e-po;t>24?(e<1/0&&(An=setTimeout(Za,e-Cn.now()-Dr)),wn&&(wn=clearInterval(wn))):(wn||(kr=Cn.now(),wn=setInterval(hf,Ja)),Bo=1,Qa(Za))}}function Or(e,t,o){var n=new Sn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var xf=Gi("start","end","cancel","interrupt"),Ef=[],ol=0,el=1,Hr=2,Vr=3,tl=4,Gr=5,Pn=6;function Gt(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;bf(e,o,{name:t,index:n,group:r,on:xf,tween:Ef,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ol})}function Ln(e,t){var o=ke(e,t);if(o.state>ol)throw new Error("too late; already scheduled");return o}function Oe(e,t){var o=ke(e,t);if(o.state>Vr)throw new Error("too late; already running");return o}function ke(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function bf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Rr(i,0,o.time);function i(c){o.state=el,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==el)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Vr)return Or(a);f.state===tl?(f.state=Pn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=Pn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Or(function(){o.state===Vr&&(o.state=tl,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Hr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Hr){for(o.state=Vr,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Gr,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Gr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=Pn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function es(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Hr&&n.state<Gr,n.state=Pn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function nl(e){return this.each(function(){es(this,e)})}function _f(e,t){var o,n;return function(){var r=Oe(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Tf(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=Oe(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function rl(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=ke(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?_f:Tf)(o,e,t))}function zo(e,t,o){var n=e._id;return e.each(function(){var r=Oe(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return ke(r,n).value[t]}}function Br(e,t){var o;return(typeof t=="number"?at:t instanceof Ht?Sr:(o=Ht(t))?(t=o,Sr):qi)(e,t)}function Nf(e){return function(){this.removeAttribute(e)}}function vf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function wf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function Af(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function If(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Cf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function il(e,t){var o=Ct(e),n=o==="transform"?Qi:Br;return this.attrTween(e,typeof t=="function"?(o.local?Cf:If)(o,n,zo(this,"attr."+e,t)):t==null?(o.local?vf:Nf)(o):(o.local?Af:wf)(o,n,t))}function Sf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Mf(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Pf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Mf(e,i)),o}return r._value=t,r}function Lf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Sf(e,i)),o}return r._value=t,r}function sl(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=Ct(e);return this.tween(o,(n.local?Pf:Lf)(n,t))}function kf(e,t){return function(){Ln(this,e).delay=+t.apply(this,arguments)}}function Df(e,t){return t=+t,function(){Ln(this,e).delay=t}}function al(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?kf:Df)(t,e)):ke(this.node(),t).delay}function Rf(e,t){return function(){Oe(this,e).duration=+t.apply(this,arguments)}}function Of(e,t){return t=+t,function(){Oe(this,e).duration=t}}function ll(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Rf:Of)(t,e)):ke(this.node(),t).duration}function Vf(e,t){if(typeof t!="function")throw new Error;return function(){Oe(this,e).ease=t}}function cl(e){var t=this._id;return arguments.length?this.each(Vf(t,e)):ke(this.node(),t).ease}function Hf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;Oe(this,e).ease=o}}function dl(e){if(typeof e!="function")throw new Error;return this.each(Hf(this._id,e))}function ul(e){typeof e!="function"&&(e=bn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Be(n,this._parents,this._name,this._id)}function pl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new Be(a,this._parents,this._name,this._id)}function Gf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function Bf(e,t,o){var n,r,i=Gf(t)?Ln:Oe;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function fl(e,t){var o=this._id;return arguments.length<2?ke(this.node(),o).on.on(e):this.each(Bf(o,e,t))}function zf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function ml(){return this.on("end.remove",zf(this._id))}function gl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=lo(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,Gt(c[p],t,o,p,c,ke(d,o)));return new Be(i,this._parents,t,o)}function hl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=En(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,g=ke(d,o),x=0,m=p.length;x<m;++x)(f=p[x])&&Gt(f,t,o,x,p,g);i.push(p),a.push(d)}return new Be(i,a,t,o)}var Ff=St.prototype.constructor;function yl(){return new Ff(this._groups,this._parents)}function Wf(e,t){var o,n,r;return function(){var i=Vt(this,e),a=(this.style.removeProperty(e),Vt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function xl(e){return function(){this.style.removeProperty(e)}}function Yf(e,t,o){var n,r=o+"",i;return function(){var a=Vt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function Uf(e,t,o){var n,r,i;return function(){var a=Vt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Vt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function $f(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=Oe(this,e),c=l.on,d=l.value[i]==null?s||(s=xl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function El(e,t,o){var n=(e+="")=="transform"?Ji:Br;return t==null?this.styleTween(e,Wf(e,n)).on("end.style."+e,xl(e)):typeof t=="function"?this.styleTween(e,Uf(e,n,zo(this,"style."+e,t))).each($f(this._id,e)):this.styleTween(e,Yf(e,n,t),o).on("end.style."+e,null)}function Xf(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Kf(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&Xf(e,a,o)),n}return i._value=t,i}function bl(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,Kf(e,t,o==null?"":o))}function qf(e){return function(){this.textContent=e}}function Zf(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function _l(e){return this.tween("text",typeof e=="function"?Zf(zo(this,"text",e)):qf(e==null?"":e+""))}function Jf(e){return function(t){this.textContent=e.call(this,t)}}function Qf(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Jf(r)),t}return n._value=e,n}function Tl(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Qf(e))}function Nl(){for(var e=this._name,t=this._id,o=zr(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=ke(l,t);Gt(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Be(n,this._parents,e,o)}function vl(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=Oe(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var jf=0;function Be(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function wl(e){return St().transition(e)}function zr(){return++jf}var Mt=St.prototype;Be.prototype=wl.prototype={constructor:Be,select:gl,selectAll:hl,selectChild:Mt.selectChild,selectChildren:Mt.selectChildren,filter:ul,merge:pl,selection:yl,transition:Nl,call:Mt.call,nodes:Mt.nodes,node:Mt.node,size:Mt.size,empty:Mt.empty,each:Mt.each,on:fl,attr:il,attrTween:sl,style:El,styleTween:bl,text:_l,textTween:Tl,remove:ml,tween:rl,delay:al,duration:ll,ease:cl,easeVarying:dl,end:vl,[Symbol.iterator]:Mt[Symbol.iterator]};function Fr(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var em={time:null,delay:0,duration:250,ease:Fr};function tm(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function Al(e){var t,o;e instanceof Be?(t=e._id,e=e._name):(t=zr(),(o=em).time=Mn(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&Gt(l,e,t,c,a,o||tm(l,t));return new Be(n,this._parents,e,t)}St.prototype.interrupt=nl;St.prototype.transition=Al;function Bt(e,t,o){this.k=e,this.x=t,this.y=o}Bt.prototype={constructor:Bt,scale:function(e){return e===1?this:new Bt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Bt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Wr=new Bt(1,0,0);Yr.prototype=Bt.prototype;function Yr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Wr;return e.__zoom}var nm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Il;(function(e){e.Strict="strict",e.Loose="loose"})(Il||(Il={}));var Cl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Cl||(Cl={}));var Sl;(function(e){e.Partial="partial",e.Full="full"})(Sl||(Sl={}));var Ml;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ml||(Ml={}));var Pl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Pl||(Pl={}));var $e;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})($e||($e={}));var wE={[$e.Left]:$e.Right,[$e.Right]:$e.Left,[$e.Top]:$e.Bottom,[$e.Bottom]:$e.Top};var rm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var im=(e,t=[0,0])=>{var s;let{width:o,height:n}=sm(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var Ze=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=rm(e)?e.internals.positionAbsolute:im(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function sm(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var AE={[$e.Left]:{x:-1,y:0},[$e.Right]:{x:1,y:0},[$e.Top]:{x:0,y:-1},[$e.Bottom]:{x:0,y:1}};var am={nodeOrigin:[0,0],nodeExtent:nm,elevateNodesOnSelect:!0,defaults:{}},IE=N(b({},am),{checkEquality:!0});var Ll;(function(e){e.Line="line",e.Handle="handle"})(Ll||(Ll={}));var lm={width:0,height:0,x:0,y:0},CE=N(b({},lm),{pointerX:0,pointerY:0,aspectRatio:1});var Je=require("react"),Ol=require("zustand/shallow");var cm=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function dm(e,t){let o=Math.max(0,Math.min(e.x2,t.x2)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y2,t.y2)-Math.max(e.y,t.y));return o*n}function um(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var Ur=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r){let i=t==="horizontal"?this.yLines:this.xLines,[a,s]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],l=[];for(let p of i){if(p.position<a)continue;if(p.position>s)break;if(p.node.id===n.id||p.node.parentId===n.id||!cm(p.nodeBox,r))continue;let f=Math.abs(p.position-o);if(f>$r)continue;let x=dm(p.nodeBox,Ze(n))>0?0:um(p.nodeBox,Ze(n));l.push({line:p,lineDist:f,nodeDist:x})}let c=.5,d=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;l.sort((p,f)=>{if(d){if(p.line===d&&f.line!==d)return-1;if(f.line===d&&p.line!==d)return 1}return Math.abs(p.lineDist-f.lineDist)<=c?p.nodeDist-f.nodeDist:p.lineDist-f.lineDist});let u=l.length>0?l[0].line:void 0;return u&&(t==="horizontal"?this.lastHorizontalLine=u:this.lastVerticalLine=u),u}};function kl(e,t=fo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Ze(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({nodeBox:a,node:r,orientation:l.orientation,position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,anchorName:s})})}),n}function Dl(e,t,o,n,r=Object.keys(fo)){let i=[];for(let s of r){let l=fo[s],c=l.resolve(o,n),d=e.search(l.orientation,c,o,t);d&&i.push({anchorName:s,sourcePosition:c,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Rl(e,t,o,n,r,i,a,s){var u,p,f,g,x,m,E,y;if(!(o!=null&&o.position))return{snappedX:!1,snappedY:!1};let l=!1,c=!1,d={x:o.position.x,y:o.position.y,x2:o.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),y2:o.position.y+((g=(f=e.measured)==null?void 0:f.height)!=null?g:0)};if(a){let v=a.anchor.resolve(e,d)-a.line.position;if(Math.abs(v)<=$r){if(o.position.y-=v,r!=null&&r.dimensions)if(n){let T=t.internals.positionAbsolute.y+((m=(x=e.measured)==null?void 0:x.height)!=null?m:0);r.dimensions.height=T-a.line.position}else r.dimensions.height=a.line.position-t.internals.positionAbsolute.y;c=!0}}if(s){let v=s.anchor.resolve(e,d)-s.line.position;if(Math.abs(v)<=$r){if(o.position.x-=v,r!=null&&r.dimensions)if(n){let T=t.internals.positionAbsolute.x+((y=(E=e.measured)==null?void 0:E.width)!=null?y:0);r.dimensions.width=T-s.line.position}else r.dimensions.width=s.line.position-t.internals.positionAbsolute.x;l=!0}}return i&&(l||c)&&(o.position.x-=i.position.x,o.position.y-=i.position.y),{snappedX:l,snappedY:c}}var $r=10,fo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var Vl=require("react/jsx-runtime"),pm=new Ur;function Xr(){let[e,t]=(0,Je.useState)(void 0),[o,n]=(0,Je.useState)(void 0),{width:r,height:i}=(0,Fo.useStore)(m=>({width:m.width,height:m.height}),Ol.shallow),a=(0,Fo.useNodesInitialized)(),s=(0,Je.useRef)(pm),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Fo.useReactFlow)(),u=(0,Je.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,Je.useCallback)(m=>{let E=m!=null?m:d();u();let y=kl(E,fo,c);s.current.initialize(y)},[c,u,d]),f=(0,Je.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,Je.useEffect)(()=>{a&&p(d())},[a,p,d]);let g=(0,Je.useCallback)((m,E)=>{var q,M,O,H,z;if(!s.current||m.length===0||m.length>2)return m;u();let y,h,v=Object.keys(fo);m.length===1?m[0].type==="position"?y=m[0]:m[0].type==="dimensions"&&(h=m[0],v=["right","bottom"]):m[0].type==="position"&&m[1].type==="dimensions"&&m[1].dimensions&&(y=m[0],h=m[1],v=["top","left"]);let T=E.find(Z=>Z.id===m[0].id);if(!T)return m;let _=c(T.id);if(!_)throw new Error(`Node with id ${T.id} not found in internal nodes`);let I=c((q=_.parentId)!=null?q:""),C=Ze(_);h!=null&&h.dimensions&&(C.x2=C.x+h.dimensions.width,C.y2=C.y+h.dimensions.height);let{x:L,y:A}=l({x:0,y:0}),{x:R,y:S}=l({x:r,y:i}),k={x:L,y:A,x2:R,y2:S},{horizontal:V,vertical:w}=Dl(s.current,k,T,C,v),P={id:T.id,type:"position",position:{x:_.internals.positionAbsolute.x,y:_.internals.positionAbsolute.y},dragging:!1};y!=null&&y.position&&P.position&&(I?(P.position.x=y.position.x+((O=(M=I==null?void 0:I.position)==null?void 0:M.x)!=null?O:0),P.position.y=y.position.y+((z=(H=I==null?void 0:I.position)==null?void 0:H.y)!=null?z:0)):(P.position.x=y.position.x,P.position.y=y.position.y));let{snappedX:F,snappedY:X}=Rl(T,_,P,y,h,I,V,w);if(F||X){if((h!=null&&h.resizing||y!=null&&y.dragging)&&(F&&n(w==null?void 0:w.line),X&&t(V==null?void 0:V.line)),h&&y)return[P,h];if(y)return[P];if(h)return[h]}return m},[l,c,r,i,t,n,u]),x=(0,Je.useCallback)(()=>(0,Vl.jsx)(Hl,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:g,helperLineHorizontal:e,helperLineVertical:o,HelperLines:x}}var Ei=require("@xyflow/react"),vt=require("react");var zt=e=>new Map(e.map(t=>[t.id,t])),kn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),Gl=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),ts=e=>e.some(t=>t.type==="START_EVENT"),Ft=(e,t)=>e==="START_EVENT"?!ts(t):!0,Bl=(e,t,o,n,r)=>{let i=zt(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:kn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},zl=(e,t,o,n,r)=>{let i=zt(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Gl(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Kr=(e,t,o,n,r)=>{var c;let i=zt(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:kn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},Fl=(e,t,o)=>{var a,s,l,c;let n=zt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},qr=(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"},Wl=(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)==="SUBPROCESS"},Zr=(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"},Dn=(e,t,o,n)=>{let r=zt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Gl(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},Rn=(e,t,o,n)=>{let r=zt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:kn(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Yl=(e,t,o,n,r)=>{let i=zt(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?Rn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?Dn(e,o,n,r):!1},Jr=(e,t,o)=>kn(e,t,o).length>0,Qr=(e,t,o,n,r)=>{let i=zt(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:kn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Ul=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var fm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Ul(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Bl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!zl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Kr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Qr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:Fl(e.sourceNodeId,e.targetNodeId,e.nodes),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==="START_EVENT"&&Wl(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_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:!(qr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Zr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Dn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Yl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Rn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(Jr(e.sourceNodeId,e.edges,e.reconnectingEdgeId)&&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","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:["START_EVENT","END_EVENT","TASK","GATEWAY","LANE"],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],os=e=>{for(let t of fm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var mm=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Kr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:ts(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:qr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Zr(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Dn(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Rn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Jr(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Qr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],$l=e=>{let t=mm.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 pt=require("@xyflow/react");var Wo=require("@xyflow/react");function Xl(e,t){var h,v,T,_;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((v=(h=t==null?void 0:t.measured)==null?void 0:h.width)!=null?v:0)/2,u=i.y+((_=(T=t==null?void 0:t.measured)==null?void 0:T.height)!=null?_:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),g=1/(Math.abs(p)+Math.abs(f)||1),x=g*p,m=g*f,E=a*(x+m)+l,y=s*(-x+m)+c;return{x:E,y}}function Kl(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Wo.Position.Left:s>=i+n-1?Wo.Position.Right:l<=a+1?Wo.Position.Top:l>=a+r-1?Wo.Position.Bottom:Wo.Position.Top}function Wt(e,t){let o=Xl(e,t),n=Xl(t,e),r=Kl(e,o),i=Kl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function jr(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY"}}var Et=require("@produto-lecom/lecom-ui"),Zl=require("lucide-react");var lt=require("@xyflow/react");var ql=require("@xyflow/react"),Yt=()=>{let e=(0,ql.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await ur(),!0}}};var ei=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,lt.useReactFlow)(),{selectElements:r}=Yt(),i=m=>{let E=o(),y=n(),h=(0,lt.getIncomers)(m,E,y),v=(0,lt.getOutgoers)(m,E,y),T=h.some(I=>I.type==="START_EVENT"),_=v.some(I=>I.type==="END_EVENT");return T?"start":_?"end":"between"},a=(m,E,y)=>{var T,_,I,C;if(!m)return;let h={type:m.type,variant:(T=m.data)==null?void 0:T.variant,attribute:(_=m.data)==null?void 0:_.attribute},v={id:m.id,position:i(m),label:(I=m.data)==null?void 0:I.label,node:h};return m.type==="TASK"&&((C=m.data)==null?void 0:C.variant)==="SUBPROCESS"?N(b({},v),{type:"sub_process"}):m.type==="GATEWAY"?N(b({},v),{type:"gateway",variant:s(m,E,y)}):N(b({},v),{type:"activity"})},s=(m,E,y)=>{if(m.type!=="GATEWAY")return;let h=(0,lt.getIncomers)(m,E,y),v=!1,T=!1;if(h.forEach(_=>{var I,C;_.type==="TASK"&&(((I=_.data)==null?void 0:I.variant)==="SCRIPT"&&(v=!0),((C=_.data)==null?void 0:C.attribute)==="LOOP"&&(T=!0))}),v&&T)return"script_loop";if(v)return"script";if(T)return"loop"},l=(m,E,y)=>{var I,C,L,A;let h=e(m.source),v=e(m.target);if(!h||!v)return"simple";if((0,lt.getOutgoers)(h,E,y).some(R=>R.type==="END_EVENT"))return"final";if(h.type==="GATEWAY")switch((I=h.data)==null?void 0:I.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(h.type==="TASK"){let R=(C=h.data)==null?void 0:C.variant,S=(L=h.data)==null?void 0:L.attribute;if(R==="SUBPROCESS")return"from_sub_process";if(v.type==="TASK"&&((A=v.data)==null?void 0:A.variant)==="SUBPROCESS")return"to_sub_process";let k=R==="SCRIPT",V=S==="LOOP";return k&&V?"script_loop":k?"script":V?"loop":"simple"}return"simple"},c=(m,E,y)=>{let h=[];function v(_,I,C=0){let L=a(_,E,y);if(L.depth=C,I.push(L),_.type==="TASK"){h.push([...I]),I.pop();return}let A=(0,lt.getIncomers)(_,E,y);if(A.length)for(let R of A)v(R,I,C+1);I.pop()}let T=(0,lt.getIncomers)(m,E,y);for(let _ of T)v(_,[]);return h},d=(m,E,y)=>{let h=[];function v(_,I,C=0){let L=a(_,E,y);if(L.depth=C,I.push(L),_.type==="TASK"){h.push([...I]),I.pop();return}let A=(0,lt.getOutgoers)(_,E,y);if(A.length)for(let R of A)v(R,I,C+1);I.pop()}let T=(0,lt.getOutgoers)(m,E,y);for(let _ of T)v(_,[]);return h},u=(m,E,y)=>(y=y.filter(v=>v.source===m.id),y.map(v=>{var I;let T=e(v.target),_;return T&&(_=a(T,E,y)),{id:v.id,type:"routing",variant:l(v,E,y),label:(I=v.data)==null?void 0:I.label,target:_}})),p=m=>{let E=e(m);if(!E)return;let y=o(),h=n(),v=a(E,y,h);return v.sources=c(E,y,h),v.targets=d(E,y,h),v.edgeTargets=u(E,y,h),E.type==="GATEWAY"&&(v.variant=s(E,y,h)),v},f=m=>{let E=t(m);if(!E)return;let y=o(),h=n(),v=l(E,y,h),_={id:E.id,type:"routing",variant:v,gatewayVariant:void 0},I=e(E.source);if(I){let L=a(I,y,h);_.source=L;let A=s(I,y,h);if(_.gatewayVariant=A,I.type==="TASK")_.sources=[[L]];else{let R=c(I,y,h);_.sources=R.length?R:[[L]]}}let C=e(E.target);if(C){let L=a(C,y,h);if(_.target=L,C.type==="TASK")_.targets=[[L]];else{let A=d(C,y,h);_.targets=A.length?A:[[L]]}}return _},g=m=>{let E=e(m);if(E)return p(E.id);let y=t(m);if(y)return f(y.id)};return{configureElement:m=>{let E=g(m);if(E)return r([m]),E},getConfigureElement:g,getNodeConfigure:p,getEdgeConfigure:f}};var mo=require("react/jsx-runtime"),Ut=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Et.useTranslation)(),{onConfigureElement:n}=U(),{getConfigureElement:r}=ei();return(0,mo.jsxs)(Et.Tooltip,{children:[(0,mo.jsx)(Et.TooltipTrigger,{asChild:!0,children:(0,mo.jsx)(Et.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,mo.jsx)(Zl.Settings,{size:16})})}),(0,mo.jsx)(Et.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var Jl=require("@xyflow/react"),bt=require("@produto-lecom/lecom-ui"),Ql=require("lucide-react"),go=require("react/jsx-runtime"),ti=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,bt.useTranslation)(),{deleteElements:n}=(0,Jl.useReactFlow)();return(0,go.jsxs)(bt.Tooltip,{children:[(0,go.jsx)(bt.TooltipTrigger,{asChild:!0,children:(0,go.jsx)(bt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{n(t==="node"?{nodes:[{id:e}]}:{edges:[{id:e}]})},children:(0,go.jsx)(Ql.TrashIcon,{size:16})})}),(0,go.jsx)(bt.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var _t=require("@produto-lecom/lecom-ui"),jl=require("lucide-react"),ec=require("react"),ho=require("react/jsx-runtime"),Yo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,_t.useTranslation)(),r=(0,ec.useCallback)(i=>{i.stopPropagation();let a=document.querySelector(`[data-id="${e}"]`);if(!a)return;let s=a.querySelector(".react-flow__handle.source");if(!s)return;let l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,ho.jsxs)(_t.Tooltip,{children:[(0,ho.jsx)(_t.TooltipTrigger,{asChild:!0,children:(0,ho.jsx)(_t.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,ho.jsx)(jl.MoveUpRightIcon,{size:16})})}),(0,ho.jsx)(_t.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Uo=require("react/jsx-runtime"),Xo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=yt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=U(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=jr(o,n),u=!l&&!c&&!d,p=[{component:(0,Uo.jsx)(ti,{elementId:e,elementType:"edge"})}],f=()=>s==="view"?u?[{component:(0,Uo.jsx)(Ut,{elementId:e,elementType:"edge"})}]:[]:u?[{component:(0,Uo.jsx)(Ut,{elementId:e,elementType:"edge"})},...p]:p,x=(m=>{switch(m){case"SEQUENCE_EDGE":return f();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(x.length===0||s==="view"))return(0,Uo.jsx)("div",N(b({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:x.map((m,E)=>(0,Uo.jsx)("div",{children:m.component},E))}))};var yo=require("react/jsx-runtime"),Ko={type:"ANNOTATION_EDGE",reconnectable:!0},tc=({id:e,source:t,target:o,selected:n,data:r})=>{let{zoom:i}=(0,pt.useViewport)(),{isMultipleSelection:a}=U(),s=(0,pt.useInternalNode)(t),l=(0,pt.useInternalNode)(o);if(!s||!l)return null;let{sx:c,sy:d,tx:u,ty:p}=Wt(s,l),[f,g,x]=(0,pt.getStraightPath)({sourceX:c,sourceY:d,targetX:u,targetY:p}),m=n||(s==null?void 0:s.selected)||(l==null?void 0:l.selected),E=1/i;return(0,yo.jsxs)("g",{className:D("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":m}),children:[(0,yo.jsx)(pt.BaseEdge,{id:e,path:f,strokeDasharray:4,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":m&&!(r!=null&&r.hasError)})}),(0,yo.jsx)(pt.EdgeLabelRenderer,{children:(0,yo.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${x}px)`},children:n&&!a&&(0,yo.jsx)(Xo,{edgeId:e,edgeType:"ANNOTATION_EDGE",style:{transform:`scale(${E})`}})})})]})};var ze=require("react"),ye=require("@xyflow/react");var xo=require("react");var ns=require("react/jsx-runtime"),Ge=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c})=>{let d=(0,xo.useRef)(null),[u,p]=(0,xo.useState)(!1);(0,xo.useEffect)(()=>{p(i!=null?i:!1)},[i]),(0,xo.useEffect)(()=>{if(u&&d.current){d.current.focus();let y=document.createRange();y.selectNodeContents(d.current);let h=window.getSelection();h&&(h.removeAllRanges(),h.addRange(y))}},[u]);let f=y=>{y.stopPropagation(),u||p(!0)},g=y=>{let h=y.currentTarget.innerText.replace(/\n$/,""),v=t&&h.length>=t,T=window.getSelection(),_=(T==null?void 0:T.toString())||"",I=_.length>0,C=y.ctrlKey||y.metaKey,L=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],A=C&&y.key==="a",R=C&&y.key==="c",S=C&&y.key==="x",k=C&&y.key==="v";function V(P){return/[a-zA-Z0-9À-ÖØ-öø-ÿ]/.test(P)}if((h.length===0||I&&_.length===h.length)&&!V(y.key)&&!L.includes(y.key)&&!C){y.preventDefault();return}if(y.key==="Enter"){y.preventDefault(),y.currentTarget.blur();return}v&&!I&&(L.includes(y.key)||A||R||S||k||y.preventDefault())},x=y=>{y.preventDefault();let h=y.clipboardData.getData("text/plain").replace(/[\n\r]+/g," "),v=y.currentTarget.innerText.replace(/\n$/,""),T=window.getSelection();if(!T||T.rangeCount===0)return;let _=T.toString(),I=v.length-_.length,C=t?Math.max(0,t-I):1/0;if(C<=0&&_.length===0)return;let L=h;if(L.length>C&&(L=L.substring(0,C)),!L&&_.length===0)return;let A=T.getRangeAt(0);if(A.startOffset===0&&(A.startContainer===y.currentTarget||A.startContainer.parentNode===y.currentTarget)&&L.length>0){let k=L[0];if(!/[a-zA-Z0-9À-ÖØ-öø-ÿ]/.test(k)){c==null||c();return}}A.deleteContents();let S=document.createTextNode(L);A.insertNode(S),A.setStartAfter(S),A.collapse(!0),T.removeAllRanges(),T.addRange(A),l==null||l(y.currentTarget.innerText.replace(/\n$/,""))},m=y=>{l==null||l(y.currentTarget.innerText.replace(/\n$/,""))},E=y=>{p(!1);let h=y.currentTarget.innerText.trim();t&&h.length>t&&(h=h.substring(0,t)),y.currentTarget.innerText=h,s==null||s(),h!==e&&(a==null||a(h))};return(0,ns.jsx)("div",{className:D("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white":u,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:(0,ns.jsx)("div",{ref:d,className:D("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":u}),contentEditable:u,suppressContentEditableWarning:!0,onKeyDown:g,onPaste:x,onInput:m,onBlur:E,children:e})})};var On=require("@xyflow/react"),Vn=e=>e===On.Position.Left||e===On.Position.Right,rs=(e,t=30)=>e===On.Position.Right||e===On.Position.Bottom?t:-t,is=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,qo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),oi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Hn={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function gm(e,t,o,n,r,i,a=0){let s=rs(r,Hn.OFFSET),l=rs(i,Hn.OFFSET),c=Vn(r),d=Vn(i),u=c?0:a,p=c?a:0,f=d?0:a,g=d?a:0,x={x:e+u,y:t+p},m={x:o+f,y:n+g};if(c&&d){let E=(t+n)/2+a;return[x,{x:e+s,y:t+a},{x:e+s,y:E},{x:o+l,y:E},{x:o+l,y:n+a},m]}if(!c&&!d){let E=(e+o)/2+a;return[x,{x:e+a,y:t+s},{x:E,y:t+s},{x:E,y:n+l},{x:o+a,y:n+l},m]}return c?[x,{x:e+s,y:t+a},{x:e+s,y:n+l+a},{x:o+a,y:n+l+a},m]:[x,{x:e+a,y:t+s},{x:o+l+a,y:t+s},{x:o+l+a,y:n+a},m]}function oc(e,t,o,n,r,i,a,s=0){let l=gm(e,t,o,n,r,i,s);if(!(a!=null&&a.length))return l;let c=[...a];if(c.length>0){let d={x:e,y:t},u=c[0],p=Vn(r);p&&Math.abs(d.y-u.y)>1?c.unshift({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.unshift({x:d.x,y:u.y})}if(c.length>0){let d={x:o,y:n},u=c[c.length-1],p=Vn(i);p&&Math.abs(d.y-u.y)>1?c.push({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.push({x:d.x,y:u.y})}return[{x:e,y:t},...c,{x:o,y:n}]}var nc=e=>{if(e.length<2)return"";let[t,...o]=e;return`M ${t.x},${t.y}${o.map(n=>` L ${n.x},${n.y}`).join("")}`};var me=require("react"),ni=require("@xyflow/react");var hm=50,rc=.1,ym=.6,ri=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,ni.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=U(),p=(0,ni.useStore)(M=>M.isValidConnection),[f,g]=(0,me.useState)(null),[x,m]=(0,me.useState)(null),[E,y]=(0,me.useState)(null),[h,v]=(0,me.useState)(null),[T,_]=(0,me.useState)(null),[I,C]=(0,me.useState)(!1),L=(0,me.useRef)(null),A=(0,me.useRef)(null),R=(0,me.useRef)(null),S=(0,me.useRef)(t),k=(0,me.useRef)(o);(0,me.useEffect)(()=>{S.current=t,k.current=o},[t,o]),(0,me.useEffect)(()=>{L.current=f},[f]),(0,me.useEffect)(()=>{A.current=T},[T]);let V=(0,me.useCallback)(M=>{let O=s(),H=O.find(re=>re.id===M);if(!H)return{x:0,y:0};let z=H.position.x,Z=H.position.y,Y=H.parentId;for(;Y;){let re=O.find(G=>G.id===Y);if(!re)break;z+=re.position.x,Z+=re.position.y,Y=re.parentId}return{x:z,y:Z}},[s]),w=(0,me.useCallback)(M=>{var Y,re,G,$,K,W;let O=s(),H=null,z=hm,Z=O.filter(B=>B.type!=="LANE"&&B.type!=="ANNOTATION");for(let B of Z){if(B.id===e)continue;let J=V(B.id),j=(G=(re=(Y=B.measured)==null?void 0:Y.width)!=null?re:B.width)!=null?G:0,oe=(W=(K=($=B.measured)==null?void 0:$.height)!=null?K:B.height)!=null?W:0;if(M.x>=J.x&&M.x<=J.x+j&&M.y>=J.y&&M.y<=J.y+oe)return B.id;let he=Math.max(J.x-M.x,0,M.x-(J.x+j)),_e=Math.max(J.y-M.y,0,M.y-(J.y+oe)),De=Math.sqrt(he*he+_e*_e);De<z&&(z=De,H=B.id)}return H},[s,V,e]),P=(0,me.useCallback)((M,O)=>{var he,_e,De,Re,He,Pe;let H=a(M);if(!H)return null;let z=V(M),Z=(De=(_e=(he=H.measured)==null?void 0:he.width)!=null?_e:H.width)!=null?De:0,Y=(Pe=(He=(Re=H.measured)==null?void 0:Re.height)!=null?He:H.height)!=null?Pe:0,re=Math.abs(z.x+Z-O.x),G=Math.abs(O.x-z.x),$=Math.abs(z.y+Y-O.y),K=Math.abs(O.y-z.y),W={right:re,left:G,bottom:$,top:K},B=Object.entries(W).reduce((pe,[ee,fe])=>fe<pe[1]?[ee,fe]:pe,["right",W.right])[0],J=R.current;if(J&&J!==B){let pe=W[B],ee=W[J],fe=Math.abs(ee-pe),We=Math.min(Math.abs(ee),Math.abs(pe));fe<We*ym&&(B=J)}let j=B,oe,Ie;if(j==="right"||j==="left"){let ee=(Math.max(z.y,Math.min(z.y+Y,O.y))-z.y)/(Y||1);Math.abs(ee-.5)<rc&&(ee=.5),Ie=ee,oe={x:j==="right"?z.x+Z:z.x,y:z.y+Ie*Y}}else{let ee=(Math.max(z.x,Math.min(z.x+Z,O.x))-z.x)/(Z||1);Math.abs(ee-.5)<rc&&(ee=.5),Ie=ee,oe={x:z.x+Ie*Z,y:j==="bottom"?z.y+Y:z.y}}return{side:j,snapPosition:oe,offset:Ie}},[a,V]),F=(0,me.useCallback)(M=>{var G,$,K;let O=L.current;if(!O)return;let H=c({x:M.clientX,y:M.clientY}),z=w(H);y(z);let Z=H,Y=null,re=null;if(z){let W=P(z,H);W&&(Y=W.side,Z=W.snapPosition,re=W.offset,R.current=Y);let B=l(e),J={source:O==="source"?z:S.current,target:O==="target"?z:k.current,sourceHandle:O==="source"?Y:(G=B==null?void 0:B.sourceHandle)!=null?G:null,targetHandle:O==="target"?Y:($=B==null?void 0:B.targetHandle)!=null?$:null},j=(K=p==null?void 0:p(J))!=null?K:!0;C(j)}else R.current=null,C(!1);v(Y),_(re),m(Z)},[w,P,l,e,c,p]),X=(0,me.useCallback)(M=>{var Y,re,G,$,K;let O=L.current;if(!O)return;let H=c({x:M.clientX,y:M.clientY}),z=w(H);if(z){let W=P(z,H),B=(Y=W==null?void 0:W.side)!=null?Y:null,J=(re=W==null?void 0:W.offset)!=null?re:.5,j=l(e),oe={source:O==="source"?z:S.current,target:O==="target"?z:k.current,sourceHandle:O==="source"?B:(G=j==null?void 0:j.sourceHandle)!=null?G:null,targetHandle:O==="target"?B:($=j==null?void 0:j.targetHandle)!=null?$:null};((K=p==null?void 0:p(oe))==null||K)&&i(Ie=>Ie.map(he=>{var _e,De;return he.id===e?N(b({},he),{source:oe.source,target:oe.target,sourceHandle:oe.sourceHandle,targetHandle:oe.targetHandle,data:N(b({},he.data),{points:void 0,sourceOffset:O==="source"?J:(_e=he.data)==null?void 0:_e.sourceOffset,targetOffset:O==="target"?J:(De=he.data)==null?void 0:De.targetOffset})}):he}))}g(null),m(null),y(null),v(null),_(null),d(!1),C(!1),u(null),R.current=null,document.removeEventListener("mouseup",X),document.removeEventListener("mousemove",F);let Z=Tt.get(n);Z==null||Z.clearReconnectingEdge()},[e,w,P,l,i,n,F,p,c,d,u]),q=(0,me.useCallback)((M,O)=>{if(r||O.button!==0)return;O.stopPropagation(),O.preventDefault(),i(z=>z.map(Z=>Z.id===e?N(b({},Z),{data:N(b({},Z.data),{points:void 0})}):Z)),g(M),u(e);let H=Tt.get(n);H==null||H.setReconnectingEdge(e),document.addEventListener("mousemove",F),document.addEventListener("mouseup",X)},[r,e,n,F,X,u,i]);return(0,me.useEffect)(()=>()=>{if(L.current){document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",X),u(null);let M=Tt.get(n);M==null||M.clearReconnectingEdge()}},[n,F,X,u]),{reconnectingHandle:f,cursorPosition:x,hoveredNodeId:E,reconnectingSide:h,reconnectingOffset:T,isValidReconnection:I,handleReconnectStart:q}};var ae=require("react/jsx-runtime"),ft={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:ye.MarkerType.ArrowClosed},markerEnd:{type:ye.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:ii,MIN_SEGMENT_LENGTH:xm,PARALLEL_OFFSET:ic}=Hn;function Em(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*ic}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*ic}var sc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var re;let{zoom:c}=(0,ye.useViewport)(),{updateEdgeData:d}=(0,ye.useReactFlow)(),u=(0,ye.useEdges)(),{isMultipleSelection:p,mode:f,instanceId:g}=U(),[x,m]=(0,ze.useState)(!1),[E,y]=(0,ze.useState)(null),h=(0,ze.useRef)(null),v=(0,ze.useRef)(null),T=f!=="edit",{reconnectingHandle:_,cursorPosition:I,hoveredNodeId:C,reconnectingSide:L,isValidReconnection:A,handleReconnectStart:R}=ri({edgeId:e,source:t,target:o,instanceId:g,isReadOnly:T}),S=(0,ye.useInternalNode)(t),k=(0,ye.useInternalNode)(o),{sx:V,sy:w,tx:P,ty:F,sourcePos:X,targetPos:q}=(0,ze.useMemo)(()=>{var _e,De;let G=S&&k?Wt(S,k):{sx:0,sy:0,tx:0,ty:0,sourcePos:ye.Position.Right,targetPos:ye.Position.Left},$=s?i:G.sourcePos,K=l?a:G.targetPos,W=(Re,He,Pe)=>{var to,oo,no,ro,Li,mn;let{x:pe,y:ee}=Re.internals.positionAbsolute,fe=(no=(oo=(to=Re.measured)==null?void 0:to.width)!=null?oo:Re.width)!=null?no:0,We=(mn=(Li=(ro=Re.measured)==null?void 0:ro.height)!=null?Li:Re.height)!=null?mn:0;switch(He){case ye.Position.Top:return{x:pe+fe*Pe,y:ee};case ye.Position.Bottom:return{x:pe+fe*Pe,y:ee+We};case ye.Position.Left:return{x:pe,y:ee+We*Pe};case ye.Position.Right:return{x:pe+fe,y:ee+We*Pe};default:return{x:pe+fe/2,y:ee+We/2}}},B=(_e=n==null?void 0:n.sourceOffset)!=null?_e:.5,J=(De=n==null?void 0:n.targetOffset)!=null?De:.5,j=S?W(S,$,B).x:G.sx,oe=S?W(S,$,B).y:G.sy,Ie=k?W(k,K,J).x:G.tx,he=k?W(k,K,J).y:G.ty;return _==="source"&&I?(j=I.x,oe=I.y,L&&($=L)):_==="target"&&I&&(Ie=I.x,he=I.y,L&&(K=L)),{sx:j,sy:oe,tx:Ie,ty:he,sourcePos:$,targetPos:K}},[S,k,s,l,i,a,_,I,L,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,ze.useEffect)(()=>{var K;if(!v.current){v.current={sx:V,sy:w,tx:P,ty:F,sourcePos:X,targetPos:q};return}let G=v.current;(Math.abs(V-G.sx)>ii||Math.abs(w-G.sy)>ii||Math.abs(P-G.tx)>ii||Math.abs(F-G.ty)>ii||G.sourcePos!==X||G.targetPos!==q)&&((K=n==null?void 0:n.points)!=null&&K.length)&&!_&&d(e,N(b({},n),{points:void 0})),v.current={sx:V,sy:w,tx:P,ty:F,sourcePos:X,targetPos:q}},[V,w,P,F,X,q,n,e,d,_]);let M=(0,ze.useMemo)(()=>{let G=Em(e,t,o,u);return oc(V,w,P,F,X,q,n==null?void 0:n.points,G)},[V,w,P,F,X,q,n==null?void 0:n.points,u,e,t,o]),O=(0,ze.useMemo)(()=>{if(M.length<2)return oi({x:V,y:w},{x:P,y:F});let G=0;for(let W=0;W<M.length-1;W++)G+=qo(M[W],M[W+1]);let $=G/2,K=0;for(let W=0;W<M.length-1;W++){let B=qo(M[W],M[W+1]);if(K+B>=$){let J=($-K)/B,j=M[W],oe=M[W+1];return{x:j.x+(oe.x-j.x)*J,y:j.y+(oe.y-j.y)*J}}K+=B}return oi({x:V,y:w},{x:P,y:F})},[M,V,w,P,F]),H=(0,ze.useMemo)(()=>{if(M.length<2){let B=Math.abs(P-V);return Math.abs(F-w)>B?{x:-60,y:0}:{x:0,y:-60}}let $=0;for(let B=0;B<M.length-1;B++)$+=qo(M[B],M[B+1]);let K=$/2,W=0;for(let B=0;B<M.length-1;B++){let J=qo(M[B],M[B+1]);if(W+J>=K){let j=M[B],oe=M[B+1],Ie=Math.abs(oe.x-j.x);return Math.abs(oe.y-j.y)>Ie?{x:-60,y:0}:{x:0,y:-60}}W+=J}return{x:0,y:-60}},[M,V,w,P,F]),z=(0,ze.useCallback)((G,$)=>{if(f!=="edit"||$.button!==0)return;$.stopPropagation(),$.preventDefault();let K=M[G],W=M[G+1],B=is(K,W,"y"),J=B?K.y:K.x,j=[...M],oe=j.length,Ie=G,he=G+1;y(G);let _e=Re=>{let He=J+(B?Re.clientY-$.clientY:Re.clientX-$.clientX)/c;h.current=B?{x:(K.x+W.x)/2,y:He}:{x:He,y:(K.y+W.y)/2};let Pe=[];for(let pe=1;pe<oe-1;pe++){let ee=j[pe];pe===Ie||pe===he?B?Pe.push({x:ee.x,y:He}):Pe.push({x:He,y:ee.y}):Pe.push(b({},ee))}d(e,N(b({},n),{points:Pe}))},De=()=>{y(null),h.current=null,document.removeEventListener("mousemove",_e),document.removeEventListener("mouseup",De)};document.addEventListener("mousemove",_e),document.addEventListener("mouseup",De)},[f,M,c,n,e,d]);if(!S||!k)return null;let Z=nc(M),Y=r||S.selected||k.selected;return(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)("g",{className:D("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":Y}),onDoubleClick:()=>m(!0),children:[(0,ae.jsx)(ye.BaseEdge,{id:e,path:Z,markerEnd:`url(#${Y?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||_&&C&&!A,"stroke-green-500":_&&C&&A,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":Y&&!(n!=null&&n.hasError)&&!_})}),r&&!p&&!T&&(0,ae.jsx)("g",{children:M.slice(0,-1).map((G,$)=>{let K=M[$+1];if($===0||$===M.length-2||qo(G,K)<xm)return null;let W=is(G,K,"y"),B=E===$,J=B&&h.current?h.current:oi(G,K);return(0,ae.jsxs)("g",{children:[(0,ae.jsx)("line",{x1:G.x,y1:G.y,x2:K.x,y2:K.y,stroke:"transparent",strokeWidth:20/c,className:D("cursor-pointer",{"cursor-ns-resize":W,"cursor-ew-resize":!W}),onMouseDown:j=>z($,j)}),(0,ae.jsx)("circle",{cx:J.x,cy:J.y,r:4/c,fill:B?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ae.jsx)("circle",{cx:J.x,cy:J.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:B?.6:.3,className:"pointer-events-none"})]},$)})})]}),(0,ae.jsxs)(ye.EdgeLabelRenderer,{children:[(0,ae.jsxs)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${O.x}px, ${O.y}px)`},children:[r&&!p&&(0,ae.jsx)("div",{className:"absolute pointer-events-auto",style:{transform:`translate(${H.x}px, ${H.y}px)`},children:(0,ae.jsx)(Xo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:S,targetNode:k,style:{transform:`scale(${1/c})`}})}),(x||((re=n==null?void 0:n.label)==null?void 0:re.trim()))&&(0,ae.jsx)(Ge,{value:n==null?void 0:n.label,className:D("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":x,"pointer-events-none":!x}),isEditing:x,onBlur:()=>m(!1),onChange:G=>d(e,{label:G.trim()})})]}),r&&!p&&!T&&(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${M[0].x}px, ${M[0].y}px)`},children:(0,ae.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ae.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ae.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:_==="source"?.6:.3,className:"pointer-events-none"}),(0,ae.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!_||_!=="source","cursor-not-allowed":_==="source"&&C&&!A,"cursor-grabbing":_==="source"&&(!C||A)}),onMouseDown:G=>R("source",G.nativeEvent)})]})}),(0,ae.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${M[M.length-1].x}px, ${M[M.length-1].y}px)`},children:(0,ae.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,ae.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,ae.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:_==="target"?.6:.3,className:"pointer-events-none"}),(0,ae.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!_||_!=="target","cursor-not-allowed":_==="target"&&C&&!A,"cursor-grabbing":_==="target"&&(!C||A)}),onMouseDown:G=>R("target",G.nativeEvent)})]})})]})]})]})};var yd=require("use-debounce");var hd=require("@xyflow/react"),fs=require("react");var Gn=(d=>(d.START_EVENT="start-event",d.END_EVENT_TERMINATE="end-event-terminate",d.TASK="task",d.TASK_SCRIPT="task-script",d.SUBPROCESS="subprocess-collapsed",d.GATEWAY_EXCLUSIVE="gateway-exclusive",d.GATEWAY_PARALLEL="gateway-parallel",d.GATEWAY_COMPLEX="gateway-complex",d.ANNOTATION="annotation",d.LANE="lane",d))(Gn||{});var si=require("xml-js");var ac={compact:!0,spaces:4},bm=e=>e.replaceAll(`
2
- `,"&#xA;");function ai(e,t=ac){if(e)return JSON.parse((0,si.xml2json)(e,N(b({},t),{attributeValueFn:bm})))}function lc(e,t=ac){return e?(0,si.json2xml)(e,t):""}var _m={MIN_WIDTH:36,MIN_HEIGHT:36},Tm={MIN_WIDTH:36,MIN_HEIGHT:36},Nm={MIN_WIDTH:56,MIN_HEIGHT:56},Bn={MIN_WIDTH:176,MIN_HEIGHT:96},li={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},Te={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},ci={MIN_WIDTH:176,MIN_HEIGHT:64},vm={MIN_WIDTH:128,MIN_HEIGHT:64},te={START_EVENT:_m,END_EVENT:Tm,GATEWAY:Nm,TASK:Bn,LANE:Te,ANNOTATION:ci,UNSUPPORTED:vm};var cc={"attribute-loop":"LOOP"},dc={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},uc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},pc={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},fc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Zo=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=Rt(Number(n),t),a=Rt(Number(r),o);return{width:i,height:a,measured:{width:i,height:a}}},Jo=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Am=e=>{let{mxGeometry:t}=e,o=Jo(e),n=Zo(t,te.START_EVENT.MIN_WIDTH,te.START_EVENT.MIN_HEIGHT);return N(b(b({},o),n),{type:"START_EVENT"})},Im=e=>{let{mxGeometry:t}=e,o=Jo(e),n=Zo(t,te.END_EVENT.MIN_WIDTH,te.END_EVENT.MIN_HEIGHT);return N(b(b({},o),n),{type:"END_EVENT"})},ss=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Jo(e),i=Zo(n,te.TASK.MIN_WIDTH,te.TASK.MIN_HEIGHT),a=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(a){let{style:l}=a._attributes,c=cc[l];c&&(r.data.attribute=c)}let s=dc[o.style];return s&&(r.data.variant=s),N(b(b({},r),i),{type:"TASK"})},as=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Jo(e),i=Zo(o,te.GATEWAY.MIN_WIDTH,te.GATEWAY.MIN_HEIGHT);return r.data.variant=uc[n],N(b(b({},r),i),{type:"GATEWAY"})},Cm=e=>{let{mxGeometry:t}=e,o=Jo(e),n=Zo(t,te.ANNOTATION.MIN_WIDTH,te.ANNOTATION.MIN_HEIGHT);return N(b(b({},o),n),{type:"ANNOTATION"})},Sm=e=>{let{mxGeometry:t}=e,o=Jo(e),n=Zo(t,te.LANE.MIN_WIDTH,te.LANE.MIN_HEIGHT);return N(b(b({},o),n),{type:"LANE"})},mc={task:ss,"task-script":ss,"subprocess-collapsed":ss,"start-event":Am,"end-event-terminate":Im,"gateway-parallel":as,"gateway-exclusive":as,"gateway-complex":as,annotation:Cm,lane:Sm},Mm=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},gc=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s}=t,l=Mm(o==null?void 0:o.Array),c={id:n,source:r,target:i,data:b({label:a||""},l&&l.length>0?{points:l}:{})};return s.includes("association")&&s.includes('endArrow=""')?b(b({},Ko),c):b(b({},ft),c)},hc=(e,t)=>{let{id:o,type:n,source:r,target:i,data:a}=e,s=t==null?void 0:t.find(u=>u.id===r),l="";n==="ANNOTATION_EDGE"&&(l='association;endArrow=""');let c={_attributes:{as:"geometry",relative:"1"}};return a!=null&&a.points&&Array.isArray(a.points)&&a.points.length>0&&(c.Array=a.points.map(u=>({_attributes:{as:"mxPoint",x:u.x,y:u.y}}))),{_attributes:{id:o,parent:(s==null?void 0:s.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(a==null?void 0:a.label)||""},mxGeometry:c}},Qo=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},Pm=e=>{let{variant:t}=e.data,o=Qo(e);return N(b({},o),{_attributes:N(b({},o._attributes),{style:pc[t]||"task"})})},Lm=e=>{let t=Qo(e);return N(b({},t),{_attributes:N(b({},t._attributes),{style:"start-event"})})},km=e=>{let t=Qo(e);return N(b({},t),{_attributes:N(b({},t._attributes),{style:"end-event-terminate"})})},Dm=e=>{let{variant:t}=e.data,o=Qo(e);return N(b({},o),{_attributes:N(b({},o._attributes),{style:fc[t]})})},Rm=e=>{let t=Qo(e);return N(b({},t),{_attributes:N(b({},t._attributes),{style:"lane"})})},Om=e=>{let t=Qo(e);return N(b({},t),{_attributes:N(b({},t._attributes),{style:"annotation"})})},yc={TASK:Pm,START_EVENT:Lm,END_EVENT:km,GATEWAY:Dm,ANNOTATION:Om,LANE:Rm},xc=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var ls=Ku(require("@dagrejs/dagre"),1),Tc=require("@xyflow/react");var Nc=require("lodash");var Ec=require("lodash");var Pt=e=>{var t,o,n,r,i,a,s,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:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},Eo=e=>(0,Ec.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),bc=(e,t)=>{let{x:o,y:n}=Pt(e),{x:r,y:i}=Pt(t);return{x:o-r,y:n-i}};var jo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(Q)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Vm=(e,t)=>{let{x:o,y:n}=Pt(e),{x:r,y:i}=Pt(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Hm=(e,t)=>{let{x:o,y:n,w:r,h:i}=Pt(e),{x:a,y:s,w:l,h:c}=Pt(t);return o<a+l&&a<o+r&&n<s+c&&s<n+i},zn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Hm(e,r)){let i=Vm(e,r);i<n&&(n=i,o=r)}return o},_c=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var vc=(e=[],t=[],o="LR")=>{let n=new ls.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),ls.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return N(b({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Fn=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=Wn(n.id,o)}),o},Wn=(e,t)=>{var f,g;let o=[...t],n=o.find(x=>x.id===e);if(!n)return o;let r=o.filter(x=>x.parentId===e&&x.type==="LANE");if(r.length===0)return o;let i=(0,Nc.orderBy)(r,["position.y"]),a=Math.max((g=(f=n.measured)==null?void 0:f.width)!=null?g:0,li.MIN_WIDTH),s=_c(e,i)||Te.MIN_WIDTH,l=Math.max(a,s),c=a-Te.HEADER_WIDTH>=s,d=0,u=0;i.forEach(x=>{var m,E,y,h;o=o.map(v=>v.id===x.id?N(b({},v),{width:c?l-Te.HEADER_WIDTH:l,measured:N(b({},v.measured),{width:c?l-Te.HEADER_WIDTH:l}),position:{x:Te.HEADER_WIDTH,y:d}}):v),d+=(E=(m=x.measured)==null?void 0:m.height)!=null?E:0,u+=(h=(y=x.measured)==null?void 0:y.height)!=null?h:0}),o=o.map(x=>x.id===e?N(b({},x),{height:u,width:c?l:l+Te.HEADER_WIDTH,measured:N(b({},x.measured),{height:u,width:c?l:l+Te.HEADER_WIDTH})}):x);let p=o.find(x=>x.id===e);return p!=null&&p.parentId&&(o=Wn(p.parentId,o)),o},wc=(e,t,o)=>{if(e.type==="LANE")return o;let n=Ze(t),r=Ze(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+Te.HEADER_WIDTH&&(e.position.x=Te.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?N(b({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?N(b({},i),{position:e.position}):i),o},Ac=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Gm=50,Ic=(e,t=Gm)=>{let o=(0,Tc.getNodesBounds)(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Yn=1,Cc=e=>`<mxGraphModel>
1
+ "use strict";var ju=Object.create;var yn=Object.defineProperty,ep=Object.defineProperties,tp=Object.getOwnPropertyDescriptor,op=Object.getOwnPropertyDescriptors,np=Object.getOwnPropertyNames,cr=Object.getOwnPropertySymbols,rp=Object.getPrototypeOf,Hi=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable;var Ms=(e,t,o)=>t in e?yn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,E=(e,t)=>{for(var o in t||(t={}))Hi.call(t,o)&&Ms(e,o,t[o]);if(cr)for(var o of cr(t))Ps.call(t,o)&&Ms(e,o,t[o]);return e},v=(e,t)=>ep(e,op(t));var bt=(e,t)=>{var o={};for(var n in e)Hi.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&cr)for(var n of cr(e))t.indexOf(n)<0&&Ps.call(e,n)&&(o[n]=e[n]);return o};var ip=(e,t)=>{for(var o in t)yn(e,o,{get:t[o],enumerable:!0})},Ls=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of np(t))!Hi.call(e,r)&&r!==o&&yn(e,r,{get:()=>t[r],enumerable:!(n=tp(t,r))||n.enumerable});return e};var sp=(e,t,o)=>(o=e!=null?ju(rp(e)):{},Ls(t||!e||!e.__esModule?yn(o,"default",{value:e,enumerable:!0}):o,e)),ap=e=>Ls(yn({},"__esModule",{value:!0}),e);var Lg={};ip(Lg,{EditorMode:()=>Fe,ElementPosition:()=>ur,ElementType:()=>xn,GatewayElementVariant:()=>pr,GatewayVariant:()=>lt,Modeler:()=>Zu,ModelerProvider:()=>$u,NodeAttribute:()=>ft,NodeType:()=>ee,NodeVariant:()=>at,RoutingVariant:()=>fr,useModeler:()=>Oi});module.exports=ap(Lg);var Gi=e=>{if(typeof document=="undefined")return;let t=document.cookie.match(new RegExp(`(?:^|; )${e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")}=([^;]*)`));return t?decodeURIComponent(t[1]):void 0};var dr=require("@produto-lecom/lecom-ui");var ks={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",configure_node:"Configure activity",configure_edge:"Configure routing",initial_task:"Initial Activity",gateway_limit_reached:"Exclusive gateway cannot have more than 2 outgoing connections",task_limit_reached:"Task cannot have more than 2 outgoing connections",start_event_limit_reached:"Start event can only connect to a single element",gateway_to_gateway_not_allowed:"Gateways cannot connect directly to other gateways",start_event_already_exists:"A start event already exists. Delete the current event to add another",script_to_end_not_allowed:"Script activities cannot connect directly to the end event",loop_to_end_not_allowed:"Loop activities cannot connect directly to the end event",initial_activity_to_end_not_allowed:"Initial activity cannot connect directly to the end event",final_activity_cannot_connect:"Final activity cannot connect to other elements",activity_has_outgoing_connections:"Activity with outgoing connections cannot connect to end event",end_event_cannot_connect_to_initial_activity:"End event cannot connect to an initial activity",initial_activity_cannot_connect_to_start_event:"Initial activity cannot connect to start event",concurrent_initial_and_final_activity:"An activity cannot be connected to both start and end events",duplicate_connection_not_allowed:"A connection already exists between these elements",connect_node:"Connect element",connecting:"Connecting...",delete_pool_lane_error:"Cannot delete the pool or lane while there are elements inside it."},controls:{zoom:{fit:"Fit zoom",in:"Zoom in",out:"Zoom out",reset:"Reset zoom"},actions:{move_tool:"Select elements",hand_tool:"Navigate the diagram",check:"Check diagram",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{delete_elements:{title:"Delete elements",callout:"When deleting, the activity and routing settings will be deleted.",content:"Are you sure you want to delete?",confirm:"Delete",cancel:"Cancel"}},task_menu:{loop_not_allowed_when_connected_to_end:"Cannot create loop on activity connected to end event",script_not_allowed_when_connected_to_end:"Cannot transform to Script activity connected to end event",loop_not_allowed_when_subprocess:"Cannot create loop on subprocess",loop:"Activity with loop"}},validation:{success:{title:"Validation Successful",message:"The diagram was validated successfully with no errors."},errors:{title:"The diagram contains errors",subtitle:"Please review the following:",task_label_length:"Task name exceeds the maximum character limit",multiple_start_event_not_allowed:"Multiple start events are not allowed",task_flows_limit_exceeds:"The number of output connections exceeds the limit of two",duplicate_task_name:"There are multiple activities with the same name",flows_on_end_tasks_not_allowed:"Activities connected to end events cannot have other connections",conditions_flows_limit_exceeds:"Exclusive gateway has too many output connections (maximum of two)",task_label_empty:"One or more activities have no name",activity_name_invalid:"Activity name is invalid",final_activity_has_loop:"Final activities cannot have loops",nested_gateway:"Connecting gateways directly is not allowed",concurrent_initial_and_final_event:"The same activity cannot have both initial and final events",gateway_flow_to_event:"Connecting a gateway to an output event is not allowed",gateway_missing_output_streams:"The gateway does not have the correct number of outputs",events_nested:"Connecting events directly is not allowed",event_to_condition:"Connecting an event directly to a gateway is not allowed",script_in_final_activity:"Final activity cannot be a script type",subprocess_referenced_not_configured:"The subprocess reference is not properly configured",start_event_not_found:"At least one start event is required",end_event_not_found:"At least one end event is required"}},bpmn:{start_event:{variant:{default:"Start event"}},end_event:{variant:{default:"End event"}},annotation:{variant:{default:"Annotation"}},gateway:{menu:{title:"Change gateway type"},variant:{default:"Gateway",exclusive:"Exclusive gateway",parallel:"Parallel gateway",complex:"Complex gateway"}},task:{menu:{title:"Change task type"},variant:{default:"Task",script:"Script task",subprocess:"Subprocess"},attribute:{loop:"Task with loop"},label:{prefix:"Activity"},feedback:{label_empty:{prefix:"Activity name was automatically set to"},label_already_exists:{prefix:"The name",middle:"already exists. The name was changed to"},invalid_first_character:"Activity name must start with a letter or number"}},lane:{variant:{default:"Pool / Lane"}},unsupported:{variant:{default:"Unsupported element"}}},adapter:{governance:{error:{DEFAULT:"Error importing diagram",NO_FILE:"No file selected",EMPTY_FILE:"Empty file",INVALID_FILE:"Invalid file",CONTAIN_NO_CELLS:"No cells found to be imported",ALREADY_INITIALIZED:"It is not possible to import the diagram from the Governance platform, since the diagram has already been initialized"},success:{default:"The diagram was imported from the Governance platform successfully and without any incompatibility detected.",incompatible_cells:"The diagram was imported from the Governance platform with incompatibilities. To know more details, click on the button below."},report:{columns:{type:"Type",value:"Value",status:"Status"},status:{imported:"Imported",adapted:"Adapted",unsupported:"Unsupported"}},action:{download:"Download report"}}}}};var Rs={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",initial_task:"Actividad Inicial",gateway_limit_reached:"Compuerta exclusiva no puede tener m\xE1s de 2 conexiones de salida",task_limit_reached:"Actividad no puede tener m\xE1s de 2 conexiones de salida",start_event_limit_reached:"Evento inicial solo puede conectarse a un \xFAnico elemento",gateway_to_gateway_not_allowed:"Las compuertas no pueden conectarse directamente con otras compuertas",start_event_already_exists:"Ya existe un evento de inicio. Elimine el evento actual para agregar otro",script_to_end_not_allowed:"Las actividades Script no pueden conectarse directamente al evento final",loop_to_end_not_allowed:"Las actividades Loop no pueden conectarse directamente al evento final",initial_activity_to_end_not_allowed:"Actividad inicial no puede conectarse directamente al evento final",final_activity_cannot_connect:"Actividad final no puede conectarse a otros elementos",activity_has_outgoing_connections:"Actividad con conexiones de salida no puede conectarse al evento final",end_event_cannot_connect_to_initial_activity:"El evento final no puede conectarse a una actividad inicial",initial_activity_cannot_connect_to_start_event:"Actividad inicial no puede conectarse a evento de inicio",concurrent_initial_and_final_activity:"Una actividad no puede estar conectada al evento inicial y final al mismo tiempo",duplicate_connection_not_allowed:"Ya existe una conexi\xF3n entre estos elementos",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"No se puede eliminar la piscina o carril mientras haya elementos dentro."},controls:{zoom:{fit:"Ajustar zoom",in:"Acercar",out:"Alejar",reset:"Restablecer zoom"},actions:{move_tool:"Seleccionar elementos",hand_tool:"Navegar por el diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{delete_elements:{title:"Eliminar elementos",callout:"Al eliminar, las configuraciones de actividades y enrutamiento ser\xE1n eliminadas.",content:"\xBFEst\xE1s seguro de querer eliminar?",confirm:"Eliminar",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"No se puede crear bucle en actividad conectada al evento final",script_not_allowed_when_connected_to_end:"No se puede transformar a Script actividad conectada al evento final",loop_not_allowed_when_subprocess:"No se puede crear bucle en subproceso",loop:"Actividad con loop"}},validation:{success:{title:"Validaci\xF3n exitosa",message:"El diagrama ha sido validado correctamente sin errores."},errors:{title:"El diagrama contiene errores",subtitle:"Revise lo siguiente:",task_label_length:"El nombre de la actividad excede el l\xEDmite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"No se permite tener m\xE1s de un evento de inicio",task_flows_limit_exceeds:"El n\xFAmero de conexiones de salida supera el l\xEDmite de dos",duplicate_task_name:"Hay varias actividades con el mismo nombre",flows_on_end_tasks_not_allowed:"Las actividades conectadas a eventos finales no pueden tener otras conexiones",conditions_flows_limit_exceeds:"Compuerta exclusiva con exceso de conexiones de salida (m\xE1ximo de dos)",task_label_empty:"El nombre de una o m\xE1s actividades no ha sido completado",activity_name_invalid:"El nombre de la actividad no es v\xE1lido",final_activity_has_loop:"Las actividades finales no pueden tener bucles",nested_gateway:"No se permite conectar compuertas directamente",concurrent_initial_and_final_event:"Una misma actividad no puede tener eventos iniciales y finales",gateway_flow_to_event:"No se permite conectar una compuerta a un evento de salida",gateway_missing_output_streams:"La compuerta no tiene el n\xFAmero correcto de salidas",events_nested:"No se permite conectar eventos directamente",event_to_condition:"No se permite conectar un evento directamente a una compuerta",script_in_final_activity:"La actividad final no puede ser de tipo script",subprocess_referenced_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente",start_event_not_found:"Es necesario tener al menos un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final"}},bpmn:{start_event:{variant:{default:"Evento de inicio"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anotaci\xF3n"}},gateway:{menu:{title:"Cambiar tipo de compuerta"},variant:{default:"Compuerta",exclusive:"Compuerta exclusiva",parallel:"Compuerta paralela",complex:"Compuerta compleja"}},task:{menu:{title:"Cambiar tipo de tarea"},variant:{default:"Tarea",script:"Tarea de script",subprocess:"Subproceso"},attribute:{loop:"Tarea con bucle"},label:{prefix:"Actividad"},feedback:{label_empty:{prefix:"El nombre de la actividad se estableci\xF3 autom\xE1ticamente como"},label_already_exists:{prefix:"El nombre",middle:"ya existe. El nombre fue cambiado a"},invalid_first_character:"El nombre de la actividad debe comenzar con una letra o n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento no soportado"}}},adapter:{governance:{error:{DEFAULT:"Error al importar diagrama",NO_FILE:"No se ha seleccionado ning\xFAn archivo",EMPTY_FILE:"Archivo vac\xEDo",INVALID_FILE:"Archivo inv\xE1lido",CONTAIN_NO_CELLS:"No se encontraron c\xE9lulas para importar",ALREADY_INITIALIZED:"No es posible importar el diagrama de la plataforma Governance, ya que el diagrama ya ha sido iniciado"},success:{default:"El diagrama se ha importado de la plataforma Governance correctamente y sin ninguna incompatibilidad detectada.",incompatible_cells:"El diagrama se ha importado de la plataforma Governance con incompatibilidades. Para saber m\xE1s detalles, haz click en el bot\xF3n de abajo."},report:{columns:{type:"Tipo",value:"Valor",status:"Estado"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"No soportado"}},action:{download:"Descargar informe"}}}}};var Ds={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",initial_task:"Atividade Inicial",gateway_limit_reached:"Gateway exclusivo n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",task_limit_reached:"Atividade n\xE3o pode ter mais de 2 conex\xF5es de sa\xEDda",start_event_limit_reached:"Evento inicial s\xF3 pode se conectar a um \xFAnico elemento",gateway_to_gateway_not_allowed:"Gateways n\xE3o podem se conectar diretamente com outros gateways",start_event_already_exists:"J\xE1 existe um evento de in\xEDcio. Exclua o evento atual para adicionar outro",script_to_end_not_allowed:"Atividades Script n\xE3o podem se conectar diretamente ao evento final",loop_to_end_not_allowed:"Atividades Loop n\xE3o podem se conectar diretamente ao evento final",initial_activity_to_end_not_allowed:"Atividade inicial n\xE3o pode se conectar diretamente ao evento final",final_activity_cannot_connect:"Atividade final n\xE3o pode se conectar a outros elementos",activity_has_outgoing_connections:"Atividade com conex\xF5es de sa\xEDda n\xE3o pode se conectar a um evento final",end_event_cannot_connect_to_initial_activity:"O evento final n\xE3o pode ser conectado a uma atividade inicial",initial_activity_cannot_connect_to_start_event:"Atividade inicial n\xE3o pode se conectar a evento de in\xEDcio",concurrent_initial_and_final_activity:"Uma atividade n\xE3o pode estar conectada ao evento inicial e final ao mesmo tempo",duplicate_connection_not_allowed:"J\xE1 existe uma conex\xE3o entre esses elementos",start_event_to_subprocess_not_allowed:"Evento inicial n\xE3o pode se conectar a um subprocesso",connect_node:"Conectar elemento",connecting:"Conectando...",delete_pool_lane_error:"N\xE3o \xE9 poss\xEDvel excluir a piscina ou raia enquanto houver elementos dentro dela."},controls:{zoom:{fit:"Ajustar o zoom",in:"Aumentar o zoom",out:"Diminuir o zoom",reset:"Resetar o zoom"},actions:{move_tool:"Selecionar elementos",hand_tool:"Navegar pelo diagrama",check:"Validar diagrama",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{delete_elements:{title:"Excluir elementos",callout:"Ao excluir, as configura\xE7\xF5es de atividades e roteamento ser\xE3o exclu\xEDdas.",content:"Deseja realmente excluir?",confirm:"Excluir",cancel:"Cancelar"}},task_menu:{loop_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel criar loop em atividade conectada ao evento final",script_not_allowed_when_connected_to_end:"N\xE3o \xE9 poss\xEDvel transformar em Script atividade conectada ao evento final",loop_not_allowed_when_subprocess:"N\xE3o \xE9 poss\xEDvel criar loop em subprocesso",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama v\xE1lidado com sucesso!",message:"Nenhum erro encontrado."},errors:{title:"O diagrama cont\xE9m erros",subtitle:"Veja abaixo o que precisa ser corrigido:",task_label_length:"O nome da atividade excede o limite m\xE1ximo de caracteres",multiple_start_event_not_allowed:"N\xE3o \xE9 permitido ter mais de um evento de in\xEDcio",task_flows_limit_exceeds:"O n\xFAmero de conex\xF5es de sa\xEDda ultrapassa o limite de dois",duplicate_task_name:"H\xE1 v\xE1rias atividades com o mesmo nome",flows_on_end_tasks_not_allowed:"Atividades conectadas a eventos finais n\xE3o podem ter outras conex\xF5es",conditions_flows_limit_exceeds:"Gateway exclusivo com excesso de conex\xF5es de sa\xEDda (m\xE1ximo de dois)",task_label_empty:"O nome de uma ou mais atividades n\xE3o foi preenchido",activity_name_invalid:"O nome da atividade n\xE3o \xE9 v\xE1lido",final_activity_has_loop:"Atividades finais n\xE3o podem ter loops",nested_gateway:"N\xE3o \xE9 permitido conectar gateways",concurrent_initial_and_final_event:"Uma mesma atividade n\xE3o pode ter eventos iniciais e finais",gateway_flow_to_event:"N\xE3o \xE9 permitido conectar um gateway a um evento de sa\xEDda",gateway_missing_output_streams:"O gateway n\xE3o possui o n\xFAmero correto de sa\xEDdas",events_nested:"N\xE3o \xE9 permitido conectar eventos",event_to_condition:"N\xE3o \xE9 permitido conectar um evento diretamente em um gateway",script_in_final_activity:"Atividade final n\xE3o pode ser do tipo script",subprocess_referenced_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente",start_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final"}},bpmn:{start_event:{variant:{default:"Evento inicial"}},end_event:{variant:{default:"Evento final"}},annotation:{variant:{default:"Anota\xE7\xE3o"}},gateway:{menu:{title:"Alterar tipo de gateway"},variant:{default:"Gateway",exclusive:"Gateway exclusivo",parallel:"Gateway paralelo",complex:"Gateway complexo"}},task:{menu:{title:"Alterar tipo de Atividade"},variant:{default:"Atividade",script:"Atividade de script",subprocess:"Subprocesso"},attribute:{loop:"Atividade com loop"},label:{prefix:"Atividade"},feedback:{label_empty:{prefix:"O nome da atividade foi definido automaticamente como"},label_already_exists:{prefix:"O nome",middle:"j\xE1 existe. O nome foi alterado para"},invalid_first_character:"O nome da atividade deve come\xE7ar com uma letra ou n\xFAmero"}},lane:{variant:{default:"Piscina / Raia"}},unsupported:{variant:{default:"Elemento n\xE3o suportado"}}},adapter:{governance:{error:{DEFAULT:"Erro ao importar diagrama",NO_FILE:"Nenhum arquivo selecionado",EMPTY_FILE:"Arquivo vazio",INVALID_FILE:"Arquivo inv\xE1lido",CONTAIN_NO_CELLS:"N\xE3o foram encontradas c\xE9lulas para serem importadas",ALREADY_INITIALIZED:"N\xE3o \xE9 poss\xEDvel importar o diagrama da plataforma Governance, pois o diagrama j\xE1 foi iniciado"},success:{default:"O diagrama foi importado da plataforma Governance com sucesso e sem nenhuma incompatibilidade detectada.",incompatible_cells:"O diagrama foi importado da plataforma Governance com incompatibilidades. Para saber mais detalhes, clique no bot\xE3o abaixo."},report:{columns:{type:"Tipo do elemento",value:"Valor",status:"Status"},status:{imported:"Importado",adapted:"Adaptado",unsupported:"N\xE3o suportado"}},action:{download:"Baixar relat\xF3rio"}}}}};var Os={pt_BR:Ds,en_US:ks,es_ES:Rs};var Vs,Hs,lp=(Hs=(Vs=Gi("LecomUserLanguage"))!=null?Vs:Gi("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?Hs:dr.Translations.PT_BR;(0,dr.initializeI18n)({lng:lp,resources:Os});var Fe=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Fe||{});var xn=(r=>(r.ACTIVITY="activity",r.ROUTING="routing",r.GATEWAY="gateway",r.SUB_PROCESS="sub_process",r))(xn||{}),ur=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(ur||{}),pr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(pr||{}),fr=(d=>(d.SIMPLE="simple",d.LOOP="loop",d.SCRIPT="script",d.SCRIPT_LOOP="script_loop",d.COMPLEX="complex",d.EXCLUSIVE="exclusive",d.PARALLEL="parallel",d.FINAL="final",d.TO_SUB_PROCESS="to_sub_process",d.FROM_SUB_PROCESS="from_sub_process",d))(fr||{});var Go=require("lucide-react");var so=require("react/jsx-runtime"),mr=({size:e=24,className:t})=>(0,so.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#6b7280",className:t,children:[(0,so.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,so.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,so.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,so.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Bi=require("react/jsx-runtime"),Po=({size:e=24,className:t})=>(0,Bi.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#ff6565",stroke:"#ec1616",strokeWidth:3,className:t,children:(0,Bi.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 zt=require("react/jsx-runtime"),Lo=({size:e=24,className:t})=>(0,zt.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,zt.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,zt.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,zt.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,zt.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,zt.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var ko=require("react/jsx-runtime"),Ro=({size:e=24,className:t})=>(0,ko.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,ko.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,ko.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ko.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var Do=require("react/jsx-runtime"),Oo=({size:e=24,className:t})=>(0,Do.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,Do.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,Do.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Do.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var Vo=require("react/jsx-runtime"),Gs=({size:e=24,className:t})=>(0,Vo.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,Vo.jsxs)("g",{children:[(0,Vo.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,Vo.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Bs=require("clsx"),zs=require("tailwind-merge");function k(...e){return(0,zs.twMerge)((0,Bs.clsx)(e))}var Ft=(e=0,t=0)=>e<t?t:e,gr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var En=require("react/jsx-runtime"),Fs=({size:e=24,className:t})=>(0,En.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,En.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,En.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var hr=require("react/jsx-runtime"),Ws=({size:e=24,className:t})=>(0,hr.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,hr.jsx)("g",{children:(0,hr.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 zi=require("react/jsx-runtime"),yr=({size:e=24,className:t})=>(0,zi.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"#5fd9b0",stroke:"#1cad86",strokeWidth:"2",className:t,children:(0,zi.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 Fi=require("react/jsx-runtime"),bn=({size:e=24,className:t})=>(0,Fi.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,Fi.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 Ho=require("react/jsx-runtime"),Ys=({size:e=24,className:t})=>(0,Ho.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,Ho.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,Ho.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,Ho.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var Wt=require("react/jsx-runtime"),Us=({size:e=24,className:t})=>(0,Wt.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,Wt.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,Wt.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,Wt.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,Wt.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Wt.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ao=require("react/jsx-runtime"),$s=({size:e=24,className:t})=>(0,ao.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,ao.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,ao.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,ao.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,ao.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var ee=(s=>(s.START_EVENT="START_EVENT",s.END_EVENT="END_EVENT",s.TASK="TASK",s.LANE="LANE",s.GATEWAY="GATEWAY",s.ANNOTATION="ANNOTATION",s.UNSUPPORTED="UNSUPPORTED",s))(ee||{}),at=(o=>(o.SCRIPT="SCRIPT",o.SUBPROCESS="SUBPROCESS",o))(at||{}),xr={SCRIPT:{icon:Go.ScrollText},SUBPROCESS:{icon:Go.SquarePlus}},ft=(t=>(t.LOOP="LOOP",t))(ft||{}),Er={LOOP:{icon:Go.RotateCcw}},lt=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(lt||{}),Wi={EXCLUSIVE:{icon:Ro},PARALLEL:{icon:Oo},COMPLEX:{icon:Lo}};var Xu=require("@xyflow/react"),Ce=require("react");var Lt=require("@xyflow/react"),Ri=require("react");var St=require("@xyflow/react"),Si=require("@produto-lecom/lecom-ui"),xt=require("react");var Xs=require("zustand"),Ks=require("@xyflow/react"),qs=require("react");var br=()=>{let{setEdges:e}=(0,Ks.useReactFlow)();return(0,qs.useCallback)(()=>{let o=lo.getState().pathEdgeIds;e(n=>n.map(r=>v(E({},r),{selected:o.includes(r.id)})))},[e])},lo=(0,Xs.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=E({},n.statusByNodeId),i=E({},n.statusData),a=!1;return o.forEach(s=>{let l=`${s.diagramId}-${s.activityId}`;r[s.diagramId]!==s.status&&(r[s.diagramId]=s.status,i[l]=s,a=!0)}),a?{statusByNodeId:r,statusData:i}:n})},getTaskStatus:o=>t().statusByNodeId[o]||null,clearTaskStatuses:()=>e({statusByNodeId:{},statusData:{},pathEdgeIds:[]}),setPathEdges:o=>{e({pathEdgeIds:o})},getPathEdgeIds:()=>t().pathEdgeIds,clearPathEdges:()=>{e({pathEdgeIds:[]})},calculateFlowPath:(o,n)=>{if(!o.length||!n.length)return;t().clearPathEdges();let r=n.filter(d=>t().statusByNodeId[d]);if(r.length<=1)return;let i=[],a={};o.forEach(d=>{a[d.source]||(a[d.source]=[]),a[d.source].push({targetId:d.target,edgeId:d.id})});let s=r[0],l=r[r.length-1];o.forEach(d=>{d.target===s&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],f=new Set;for(p.push({node:d,path:[]}),f.add(d);p.length>0;){let{node:h,path:y}=p.shift();if(h===u)return y;let g=a[h]||[];for(let{targetId:b,edgeId:x}of g)f.has(b)||(f.add(b),p.push({node:b,path:[...y,x]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],f=c(u,p);f.length>0&&i.push(...f)}i.length>0&&e({pathEdgeIds:i})}}));var Yo=require("@xyflow/react"),je=require("react"),Wl=require("zustand/shallow");var cp={value:()=>{}};function Js(){for(var e=0,t=arguments.length,o={},n;e<t;++e){if(!(n=arguments[e]+"")||n in o||/[\s.]/.test(n))throw new Error("illegal type: "+n);o[n]=[]}return new _r(o)}function _r(e){this._=e}function dp(e,t){return e.trim().split(/^|\s+/).map(function(o){var n="",r=o.indexOf(".");if(r>=0&&(n=o.slice(r+1),o=o.slice(0,r)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:n}})}_r.prototype=Js.prototype={constructor:_r,on:function(e,t){var o=this._,n=dp(e+"",o),r,i=-1,a=n.length;if(arguments.length<2){for(;++i<a;)if((r=(e=n[i]).type)&&(r=up(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(r=(e=n[i]).type)o[r]=Zs(o[r],e.name,t);else if(t==null)for(r in o)o[r]=Zs(o[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new _r(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var o=new Array(r),n=0,r,i;n<r;++n)o[n]=arguments[n+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],n=0,r=i.length;n<r;++n)i[n].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var n=this._[e],r=0,i=n.length;r<i;++r)n[r].value.apply(t,o)}};function up(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function Zs(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=cp,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Yi=Js;var Tr="http://www.w3.org/1999/xhtml",Ui={svg:"http://www.w3.org/2000/svg",xhtml:Tr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function kt(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Ui.hasOwnProperty(t)?{space:Ui[t],local:e}:e}function pp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Tr&&t.documentElement.namespaceURI===Tr?t.createElement(e):t.createElementNS(o,e)}}function fp(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function vr(e){var t=kt(e);return(t.local?fp:pp)(t)}function mp(){}function co(e){return e==null?mp:function(){return this.querySelector(e)}}function Qs(e){typeof e!="function"&&(e=co(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=new Array(a),l,c,d=0;d<a;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),s[d]=c);return new Oe(n,this._parents)}function $i(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function gp(){return[]}function _n(e){return e==null?gp:function(){return this.querySelectorAll(e)}}function hp(e){return function(){return $i(e.apply(this,arguments))}}function js(e){typeof e=="function"?e=hp(e):e=_n(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var a=t[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&(n.push(e.call(l,l.__data__,c,a)),r.push(l));return new Oe(n,r)}function Tn(e){return function(){return this.matches(e)}}function Nr(e){return function(t){return t.matches(e)}}var yp=Array.prototype.find;function xp(e){return function(){return yp.call(this.children,e)}}function Ep(){return this.firstElementChild}function ea(e){return this.select(e==null?Ep:xp(typeof e=="function"?e:Nr(e)))}var bp=Array.prototype.filter;function _p(){return Array.from(this.children)}function Tp(e){return function(){return bp.call(this.children,e)}}function ta(e){return this.selectAll(e==null?_p:Tp(typeof e=="function"?e:Nr(e)))}function oa(e){typeof e!="function"&&(e=Tn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new Oe(n,this._parents)}function wr(e){return new Array(e.length)}function na(){return new Oe(this._enter||this._groups.map(wr),this._parents)}function vn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}vn.prototype={constructor:vn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function ra(e){return function(){return e}}function vp(e,t,o,n,r,i){for(var a=0,s,l=t.length,c=i.length;a<c;++a)(s=t[a])?(s.__data__=i[a],n[a]=s):o[a]=new vn(e,i[a]);for(;a<l;++a)(s=t[a])&&(r[a]=s)}function Np(e,t,o,n,r,i,a){var s,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(s=0;s<d;++s)(l=t[s])&&(p[s]=f=a.call(l,l.__data__,s,t)+"",c.has(f)?r[s]=l:c.set(f,l));for(s=0;s<u;++s)f=a.call(e,i[s],s,i)+"",(l=c.get(f))?(n[s]=l,l.__data__=i[s],c.delete(f)):o[s]=new vn(e,i[s]);for(s=0;s<d;++s)(l=t[s])&&c.get(p[s])===l&&(r[s]=l)}function wp(e){return e.__data__}function ia(e,t){if(!arguments.length)return Array.from(this,wp);var o=t?Np:vp,n=this._parents,r=this._groups;typeof e!="function"&&(e=ra(e));for(var i=r.length,a=new Array(i),s=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=Ap(e.call(d,d&&d.__data__,c,n)),h=f.length,y=s[c]=new Array(h),g=a[c]=new Array(h),b=l[c]=new Array(p);o(d,u,y,g,b,f,t);for(var x=0,m=0,N,T;x<h;++x)if(N=y[x]){for(x>=m&&(m=x+1);!(T=g[m])&&++m<h;);N._next=T||null}}return a=new Oe(a,n),a._enter=s,a._exit=l,a}function Ap(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function sa(){return new Oe(this._exit||this._groups.map(wr),this._parents)}function aa(e,t,o){var n=this.enter(),r=this,i=this.exit();return typeof e=="function"?(n=e(n),n&&(n=n.selection())):n=n.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),o==null?i.remove():o(i),n&&r?n.merge(r).order():r}function la(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,a=Math.min(r,i),s=new Array(r),l=0;l<a;++l)for(var c=o[l],d=n[l],u=c.length,p=s[l]=new Array(u),f,h=0;h<u;++h)(f=c[h]||d[h])&&(p[h]=f);for(;l<r;++l)s[l]=o[l];return new Oe(s,this._parents)}function ca(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],a;--r>=0;)(a=n[r])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function da(e){e||(e=Ip);function t(u,p){return u&&p?e(u.__data__,p.__data__):!u-!p}for(var o=this._groups,n=o.length,r=new Array(n),i=0;i<n;++i){for(var a=o[i],s=a.length,l=r[i]=new Array(s),c,d=0;d<s;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Oe(r,this._parents).order()}function Ip(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ua(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function pa(){return Array.from(this)}function fa(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length;r<i;++r){var a=n[r];if(a)return a}return null}function ma(){let e=0;for(let t of this)++e;return e}function ga(){return!this.node()}function ha(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,a=r.length,s;i<a;++i)(s=r[i])&&e.call(s,s.__data__,i,r);return this}function Cp(e){return function(){this.removeAttribute(e)}}function Sp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mp(e,t){return function(){this.setAttribute(e,t)}}function Pp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Lp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function kp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function ya(e,t){var o=kt(e);if(arguments.length<2){var n=this.node();return o.local?n.getAttributeNS(o.space,o.local):n.getAttribute(o)}return this.each((t==null?o.local?Sp:Cp:typeof t=="function"?o.local?kp:Lp:o.local?Pp:Mp)(o,t))}function Ar(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Rp(e){return function(){this.style.removeProperty(e)}}function Dp(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Op(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function xa(e,t,o){return arguments.length>1?this.each((t==null?Rp:typeof t=="function"?Op:Dp)(e,t,o==null?"":o)):Yt(this.node(),e)}function Yt(e,t){return e.style.getPropertyValue(t)||Ar(e).getComputedStyle(e,null).getPropertyValue(t)}function Vp(e){return function(){delete this[e]}}function Hp(e,t){return function(){this[e]=t}}function Gp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Ea(e,t){return arguments.length>1?this.each((t==null?Vp:typeof t=="function"?Gp:Hp)(e,t)):this.node()[e]}function ba(e){return e.trim().split(/^|\s+/)}function Xi(e){return e.classList||new _a(e)}function _a(e){this._node=e,this._names=ba(e.getAttribute("class")||"")}_a.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ta(e,t){for(var o=Xi(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function va(e,t){for(var o=Xi(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Bp(e){return function(){Ta(this,e)}}function zp(e){return function(){va(this,e)}}function Fp(e,t){return function(){(t.apply(this,arguments)?Ta:va)(this,e)}}function Na(e,t){var o=ba(e+"");if(arguments.length<2){for(var n=Xi(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Fp:t?Bp:zp)(o,t))}function Wp(){this.textContent=""}function Yp(e){return function(){this.textContent=e}}function Up(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function wa(e){return arguments.length?this.each(e==null?Wp:(typeof e=="function"?Up:Yp)(e)):this.node().textContent}function $p(){this.innerHTML=""}function Xp(e){return function(){this.innerHTML=e}}function Kp(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Aa(e){return arguments.length?this.each(e==null?$p:(typeof e=="function"?Kp:Xp)(e)):this.node().innerHTML}function qp(){this.nextSibling&&this.parentNode.appendChild(this)}function Ia(){return this.each(qp)}function Zp(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ca(){return this.each(Zp)}function Sa(e){var t=typeof e=="function"?e:vr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Jp(){return null}function Ma(e,t){var o=typeof e=="function"?e:vr(e),n=t==null?Jp:typeof t=="function"?t:co(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Qp(){var e=this.parentNode;e&&e.removeChild(this)}function Pa(){return this.each(Qp)}function jp(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ef(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function La(e){return this.select(e?ef:jp)}function ka(e){return arguments.length?this.property("__data__",e):this.node().__data__}function tf(e){return function(t){e.call(this,t,this.__data__)}}function of(e){return e.trim().split(/^|\s+/).map(function(t){var o="",n=t.indexOf(".");return n>=0&&(o=t.slice(n+1),t=t.slice(0,n)),{type:t,name:o}})}function nf(e){return function(){var t=this.__on;if(t){for(var o=0,n=-1,r=t.length,i;o<r;++o)i=t[o],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++n]=i;++n?t.length=n:delete this.__on}}}function rf(e,t,o){return function(){var n=this.__on,r,i=tf(t);if(n){for(var a=0,s=n.length;a<s;++a)if((r=n[a]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=o),r.value=t;return}}this.addEventListener(e.type,i,o),r={type:e.type,name:e.name,value:t,listener:i,options:o},n?n.push(r):this.__on=[r]}}function Ra(e,t,o){var n=of(e+""),r,i=n.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var l=0,c=s.length,d;l<c;++l)for(r=0,d=s[l];r<i;++r)if((a=n[r]).type===d.type&&a.name===d.name)return d.value}return}for(s=t?rf:nf,r=0;r<i;++r)this.each(s(n[r],t,o));return this}function Da(e,t,o){var n=Ar(e),r=n.CustomEvent;typeof r=="function"?r=new r(t,o):(r=n.document.createEvent("Event"),o?(r.initEvent(t,o.bubbles,o.cancelable),r.detail=o.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function sf(e,t){return function(){return Da(this,e,t)}}function af(e,t){return function(){return Da(this,e,t.apply(this,arguments))}}function Oa(e,t){return this.each((typeof t=="function"?af:sf)(e,t))}function*Va(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,a;r<i;++r)(a=n[r])&&(yield a)}var lf=[null];function Oe(e,t){this._groups=e,this._parents=t}function Ha(){return new Oe([[document.documentElement]],lf)}function cf(){return this}Oe.prototype=Ha.prototype={constructor:Oe,select:Qs,selectAll:js,selectChild:ea,selectChildren:ta,filter:oa,data:ia,enter:na,exit:sa,join:aa,merge:la,selection:cf,order:ca,sort:da,call:ua,nodes:pa,node:fa,size:ma,empty:ga,each:ha,attr:ya,style:xa,property:Ea,classed:Na,text:wa,html:Aa,raise:Ia,lower:Ca,append:Sa,insert:Ma,remove:Pa,clone:La,datum:ka,on:Ra,dispatch:Oa,[Symbol.iterator]:Va};var Rt=Ha;function Ir(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Ki(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function An(){}var Nn=.7,Mr=1/Nn,Bo="\\s*([+-]?\\d+)\\s*",wn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_t="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",df=/^#([0-9a-f]{3,8})$/,uf=new RegExp(`^rgb\\(${Bo},${Bo},${Bo}\\)$`),pf=new RegExp(`^rgb\\(${_t},${_t},${_t}\\)$`),ff=new RegExp(`^rgba\\(${Bo},${Bo},${Bo},${wn}\\)$`),mf=new RegExp(`^rgba\\(${_t},${_t},${_t},${wn}\\)$`),gf=new RegExp(`^hsl\\(${wn},${_t},${_t}\\)$`),hf=new RegExp(`^hsla\\(${wn},${_t},${_t},${wn}\\)$`),Ga={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ir(An,Ut,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ba,formatHex:Ba,formatHex8:yf,formatHsl:xf,formatRgb:za,toString:za});function Ba(){return this.rgb().formatHex()}function yf(){return this.rgb().formatHex8()}function xf(){return Xa(this).formatHsl()}function za(){return this.rgb().formatRgb()}function Ut(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=df.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Fa(t):o===3?new Ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?Cr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?Cr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=uf.exec(e))?new Ue(t[1],t[2],t[3],1):(t=pf.exec(e))?new Ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ff.exec(e))?Cr(t[1],t[2],t[3],t[4]):(t=mf.exec(e))?Cr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gf.exec(e))?Ua(t[1],t[2]/100,t[3]/100,1):(t=hf.exec(e))?Ua(t[1],t[2]/100,t[3]/100,t[4]):Ga.hasOwnProperty(e)?Fa(Ga[e]):e==="transparent"?new Ue(NaN,NaN,NaN,0):null}function Fa(e){return new Ue(e>>16&255,e>>8&255,e&255,1)}function Cr(e,t,o,n){return n<=0&&(e=t=o=NaN),new Ue(e,t,o,n)}function Ef(e){return e instanceof An||(e=Ut(e)),e?(e=e.rgb(),new Ue(e.r,e.g,e.b,e.opacity)):new Ue}function zo(e,t,o,n){return arguments.length===1?Ef(e):new Ue(e,t,o,n==null?1:n)}function Ue(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}Ir(Ue,zo,Ki(An,{brighter(e){return e=e==null?Mr:Math.pow(Mr,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Nn:Math.pow(Nn,e),new Ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ue(po(this.r),po(this.g),po(this.b),Pr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wa,formatHex:Wa,formatHex8:bf,formatRgb:Ya,toString:Ya}));function Wa(){return`#${uo(this.r)}${uo(this.g)}${uo(this.b)}`}function bf(){return`#${uo(this.r)}${uo(this.g)}${uo(this.b)}${uo((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ya(){let e=Pr(this.opacity);return`${e===1?"rgb(":"rgba("}${po(this.r)}, ${po(this.g)}, ${po(this.b)}${e===1?")":`, ${e})`}`}function Pr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function po(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function uo(e){return e=po(e),(e<16?"0":"")+e.toString(16)}function Ua(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new mt(e,t,o,n)}function Xa(e){if(e instanceof mt)return new mt(e.h,e.s,e.l,e.opacity);if(e instanceof An||(e=Ut(e)),!e)return new mt;if(e instanceof mt)return e;e=e.rgb();var t=e.r/255,o=e.g/255,n=e.b/255,r=Math.min(t,o,n),i=Math.max(t,o,n),a=NaN,s=i-r,l=(i+r)/2;return s?(t===i?a=(o-n)/s+(o<n)*6:o===i?a=(n-t)/s+2:a=(t-o)/s+4,s/=l<.5?i+r:2-i-r,a*=60):s=l>0&&l<1?0:a,new mt(a,s,l,e.opacity)}function Ka(e,t,o,n){return arguments.length===1?Xa(e):new mt(e,t,o,n==null?1:n)}function mt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}Ir(mt,Ka,Ki(An,{brighter(e){return e=e==null?Mr:Math.pow(Mr,e),new mt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Nn:Math.pow(Nn,e),new mt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,n=o+(o<.5?o:1-o)*t,r=2*o-n;return new Ue(qi(e>=240?e-240:e+120,r,n),qi(e,r,n),qi(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new mt($a(this.h),Sr(this.s),Sr(this.l),Pr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=Pr(this.opacity);return`${e===1?"hsl(":"hsla("}${$a(this.h)}, ${Sr(this.s)*100}%, ${Sr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function $a(e){return e=(e||0)%360,e<0?e+360:e}function Sr(e){return Math.max(0,Math.min(1,e||0))}function qi(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}function Zi(e,t,o,n,r){var i=e*e,a=i*e;return((1-3*e+3*i-a)*t+(4-6*i+3*a)*o+(1+3*e+3*i-3*a)*n+a*r)/6}function qa(e){var t=e.length-1;return function(o){var n=o<=0?o=0:o>=1?(o=1,t-1):Math.floor(o*t),r=e[n],i=e[n+1],a=n>0?e[n-1]:2*r-i,s=n<t-1?e[n+2]:2*i-r;return Zi((o-n/t)*t,a,r,i,s)}}function Za(e){var t=e.length;return function(o){var n=Math.floor(((o%=1)<0?++o:o)*t),r=e[(n+t-1)%t],i=e[n%t],a=e[(n+1)%t],s=e[(n+2)%t];return Zi((o-n/t)*t,r,i,a,s)}}var Ji=e=>()=>e;function _f(e,t){return function(o){return e+o*t}}function Tf(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(n){return Math.pow(e+n*t,o)}}function Ja(e){return(e=+e)==1?Lr:function(t,o){return o-t?Tf(t,o,e):Ji(isNaN(t)?o:t)}}function Lr(e,t){var o=t-e;return o?_f(e,o):Ji(isNaN(e)?t:e)}var kr=function e(t){var o=Ja(t);function n(r,i){var a=o((r=zo(r)).r,(i=zo(i)).r),s=o(r.g,i.g),l=o(r.b,i.b),c=Lr(r.opacity,i.opacity);return function(d){return r.r=a(d),r.g=s(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function Qa(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),a,s;for(a=0;a<o;++a)s=zo(t[a]),n[a]=s.r||0,r[a]=s.g||0,i[a]=s.b||0;return n=e(n),r=e(r),i=e(i),s.opacity=1,function(l){return s.r=n(l),s.g=r(l),s.b=i(l),s+""}}}var vf=Qa(qa),Nf=Qa(Za);function ct(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var ji=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qi=new RegExp(ji.source,"g");function wf(e){return function(){return e}}function Af(e){return function(t){return e(t)+""}}function es(e,t){var o=ji.lastIndex=Qi.lastIndex=0,n,r,i,a=-1,s=[],l=[];for(e=e+"",t=t+"";(n=ji.exec(e))&&(r=Qi.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:ct(n,r)})),o=Qi.lastIndex;return o<t.length&&(i=t.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?l[0]?Af(l[0].x):wf(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)s[(u=l[d]).i]=u.x(c);return s.join("")})}var ja=180/Math.PI,Rr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ts(e,t,o,n,r,i){var a,s,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(s=Math.sqrt(o*o+n*n))&&(o/=s,n/=s,l/=s),e*n<t*o&&(e=-e,t=-t,l=-l,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ja,skewX:Math.atan(l)*ja,scaleX:a,scaleY:s}}var Dr;function el(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Rr:ts(t.a,t.b,t.c,t.d,t.e,t.f)}function tl(e){return e==null?Rr:(Dr||(Dr=document.createElementNS("http://www.w3.org/2000/svg","g")),Dr.setAttribute("transform",e),(e=Dr.transform.baseVal.consolidate())?(e=e.matrix,ts(e.a,e.b,e.c,e.d,e.e,e.f)):Rr)}function ol(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,f,h){if(c!==u||d!==p){var y=f.push("translate(",null,t,null,o);h.push({i:y-4,x:ct(c,u)},{i:y-2,x:ct(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function a(c,d,u,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:u.push(r(u)+"rotate(",null,n)-2,x:ct(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function s(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:ct(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,h){if(c!==u||d!==p){var y=f.push(r(f)+"scale(",null,",",null,")");h.push({i:y-4,x:ct(c,u)},{i:y-2,x:ct(d,p)})}else(u!==1||p!==1)&&f.push(r(f)+"scale("+u+","+p+")")}return function(c,d){var u=[],p=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,p),a(c.rotate,d.rotate,u,p),s(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(f){for(var h=-1,y=p.length,g;++h<y;)u[(g=p[h]).i]=g.x(f);return u.join("")}}}var os=ol(el,"px, ","px)","deg)"),ns=ol(tl,", ",")",")");var Fo=0,Cn=0,In=0,rl=1e3,Or,Sn,Vr=0,fo=0,Hr=0,Mn=typeof performance=="object"&&performance.now?performance:Date,il=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ln(){return fo||(il(If),fo=Mn.now()+Hr)}function If(){fo=0}function Pn(){this._call=this._time=this._next=null}Pn.prototype=Gr.prototype={constructor:Pn,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Ln():+o)+(t==null?0:+t),!this._next&&Sn!==this&&(Sn?Sn._next=this:Or=this,Sn=this),this._call=e,this._time=o,rs()},stop:function(){this._call&&(this._call=null,this._time=1/0,rs())}};function Gr(e,t,o){var n=new Pn;return n.restart(e,t,o),n}function sl(){Ln(),++Fo;for(var e=Or,t;e;)(t=fo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Fo}function nl(){fo=(Vr=Mn.now())+Hr,Fo=Cn=0;try{sl()}finally{Fo=0,Sf(),fo=0}}function Cf(){var e=Mn.now(),t=e-Vr;t>rl&&(Hr-=t,Vr=e)}function Sf(){for(var e,t=Or,o,n=1/0;t;)t._call?(n>t._time&&(n=t._time),e=t,t=t._next):(o=t._next,t._next=null,t=e?e._next=o:Or=o);Sn=e,rs(n)}function rs(e){if(!Fo){Cn&&(Cn=clearTimeout(Cn));var t=e-fo;t>24?(e<1/0&&(Cn=setTimeout(nl,e-Mn.now()-Hr)),In&&(In=clearInterval(In))):(In||(Vr=Mn.now(),In=setInterval(Cf,rl)),Fo=1,il(nl))}}function Br(e,t,o){var n=new Pn;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var Mf=Yi("start","end","cancel","interrupt"),Pf=[],cl=0,al=1,Fr=2,zr=3,ll=4,Wr=5,kn=6;function $t(e,t,o,n,r,i){var a=e.__transition;if(!a)e.__transition={};else if(o in a)return;Lf(e,o,{name:t,index:n,group:r,on:Mf,tween:Pf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:cl})}function Rn(e,t){var o=Ve(e,t);if(o.state>cl)throw new Error("too late; already scheduled");return o}function He(e,t){var o=Ve(e,t);if(o.state>zr)throw new Error("too late; already running");return o}function Ve(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Lf(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Gr(i,0,o.time);function i(c){o.state=al,o.timer.restart(a,o.delay,o.time),o.delay<=c&&a(c-o.delay)}function a(c){var d,u,p,f;if(o.state!==al)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===zr)return Br(a);f.state===ll?(f.state=kn,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=kn,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(Br(function(){o.state===zr&&(o.state=ll,o.timer.restart(s,o.delay,o.time),s(c))}),o.state=Fr,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Fr){for(o.state=zr,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(f=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=f);r.length=u+1}}function s(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Wr,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Wr&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=kn,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function is(e,t){var o=e.__transition,n,r,i=!0,a;if(o){t=t==null?null:t+"";for(a in o){if((n=o[a]).name!==t){i=!1;continue}r=n.state>Fr&&n.state<Wr,n.state=kn,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[a]}i&&delete e.__transition}}function dl(e){return this.each(function(){is(this,e)})}function kf(e,t){var o,n;return function(){var r=He(this,e),i=r.tween;if(i!==o){n=o=i;for(var a=0,s=n.length;a<s;++a)if(n[a].name===t){n=n.slice(),n.splice(a,1);break}}r.tween=n}}function Rf(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=He(this,e),a=i.tween;if(a!==n){r=(n=a).slice();for(var s={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=s;break}l===c&&r.push(s)}i.tween=r}}function ul(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Ve(this.node(),o).tween,r=0,i=n.length,a;r<i;++r)if((a=n[r]).name===e)return a.value;return null}return this.each((t==null?kf:Rf)(o,e,t))}function Wo(e,t,o){var n=e._id;return e.each(function(){var r=He(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Ve(r,n).value[t]}}function Yr(e,t){var o;return(typeof t=="number"?ct:t instanceof Ut?kr:(o=Ut(t))?(t=o,kr):es)(e,t)}function Df(e){return function(){this.removeAttribute(e)}}function Of(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Vf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttribute(e);return a===r?null:a===n?i:i=t(n=a,o)}}function Hf(e,t,o){var n,r=o+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===r?null:a===n?i:i=t(n=a,o)}}function Gf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function Bf(e,t,o){var n,r,i;return function(){var a,s=o(this),l;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=s+"",a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s)))}}function pl(e,t){var o=kt(e),n=o==="transform"?ns:Yr;return this.attrTween(e,typeof t=="function"?(o.local?Bf:Gf)(o,n,Wo(this,"attr."+e,t)):t==null?(o.local?Of:Df)(o):(o.local?Hf:Vf)(o,n,t))}function zf(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Ff(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Wf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Ff(e,i)),o}return r._value=t,r}function Yf(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&zf(e,i)),o}return r._value=t,r}function fl(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var n=kt(e);return this.tween(o,(n.local?Wf:Yf)(n,t))}function Uf(e,t){return function(){Rn(this,e).delay=+t.apply(this,arguments)}}function $f(e,t){return t=+t,function(){Rn(this,e).delay=t}}function ml(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Uf:$f)(t,e)):Ve(this.node(),t).delay}function Xf(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function Kf(e,t){return t=+t,function(){He(this,e).duration=t}}function gl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Xf:Kf)(t,e)):Ve(this.node(),t).duration}function qf(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function hl(e){var t=this._id;return arguments.length?this.each(qf(t,e)):Ve(this.node(),t).ease}function Zf(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;He(this,e).ease=o}}function yl(e){if(typeof e!="function")throw new Error;return this.each(Zf(this._id,e))}function xl(e){typeof e!="function"&&(e=Tn(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],a=i.length,s=n[r]=[],l,c=0;c<a;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&s.push(l);return new We(n,this._parents,this._name,this._id)}function El(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,n=t.length,r=o.length,i=Math.min(n,r),a=new Array(n),s=0;s<i;++s)for(var l=t[s],c=o[s],d=l.length,u=a[s]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;s<n;++s)a[s]=t[s];return new We(a,this._parents,this._name,this._id)}function Jf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function Qf(e,t,o){var n,r,i=Jf(t)?Rn:He;return function(){var a=i(this,e),s=a.on;s!==n&&(r=(n=s).copy()).on(t,o),a.on=r}}function bl(e,t){var o=this._id;return arguments.length<2?Ve(this.node(),o).on.on(e):this.each(Qf(o,e,t))}function jf(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function _l(){return this.on("end.remove",jf(this._id))}function Tl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=co(e));for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a)for(var s=n[a],l=s.length,c=i[a]=new Array(l),d,u,p=0;p<l;++p)(d=s[p])&&(u=e.call(d,d.__data__,p,s))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,$t(c[p],t,o,p,c,Ve(d,o)));return new We(i,this._parents,t,o)}function vl(e){var t=this._name,o=this._id;typeof e!="function"&&(e=_n(e));for(var n=this._groups,r=n.length,i=[],a=[],s=0;s<r;++s)for(var l=n[s],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),f,h=Ve(d,o),y=0,g=p.length;y<g;++y)(f=p[y])&&$t(f,t,o,y,p,h);i.push(p),a.push(d)}return new We(i,a,t,o)}var em=Rt.prototype.constructor;function Nl(){return new em(this._groups,this._parents)}function tm(e,t){var o,n,r;return function(){var i=Yt(this,e),a=(this.style.removeProperty(e),Yt(this,e));return i===a?null:i===o&&a===n?r:r=t(o=i,n=a)}}function wl(e){return function(){this.style.removeProperty(e)}}function om(e,t,o){var n,r=o+"",i;return function(){var a=Yt(this,e);return a===r?null:a===n?i:i=t(n=a,o)}}function nm(e,t,o){var n,r,i;return function(){var a=Yt(this,e),s=o(this),l=s+"";return s==null&&(l=s=(this.style.removeProperty(e),Yt(this,e))),a===l?null:a===n&&l===r?i:(r=l,i=t(n=a,s))}}function rm(e,t){var o,n,r,i="style."+t,a="end."+i,s;return function(){var l=He(this,e),c=l.on,d=l.value[i]==null?s||(s=wl(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(a,r=d),l.on=n}}function Al(e,t,o){var n=(e+="")=="transform"?os:Yr;return t==null?this.styleTween(e,tm(e,n)).on("end.style."+e,wl(e)):typeof t=="function"?this.styleTween(e,nm(e,n,Wo(this,"style."+e,t))).each(rm(this._id,e)):this.styleTween(e,om(e,n,t),o).on("end.style."+e,null)}function im(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function sm(e,t,o){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&im(e,a,o)),n}return i._value=t,i}function Il(e,t,o){var n="style."+(e+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;return this.tween(n,sm(e,t,o==null?"":o))}function am(e){return function(){this.textContent=e}}function lm(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Cl(e){return this.tween("text",typeof e=="function"?lm(Wo(this,"text",e)):am(e==null?"":e+""))}function cm(e){return function(t){this.textContent=e.call(this,t)}}function dm(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&cm(r)),t}return n._value=e,n}function Sl(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,dm(e))}function Ml(){for(var e=this._name,t=this._id,o=Ur(),n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)if(l=a[c]){var d=Ve(l,t);$t(l,e,o,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new We(n,this._parents,e,o)}function Pl(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,a){var s={value:a},l={value:function(){--r===0&&i()}};o.each(function(){var c=He(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(l)),c.on=t}),r===0&&i()})}var um=0;function We(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Ll(e){return Rt().transition(e)}function Ur(){return++um}var Dt=Rt.prototype;We.prototype=Ll.prototype={constructor:We,select:Tl,selectAll:vl,selectChild:Dt.selectChild,selectChildren:Dt.selectChildren,filter:xl,merge:El,selection:Nl,transition:Ml,call:Dt.call,nodes:Dt.nodes,node:Dt.node,size:Dt.size,empty:Dt.empty,each:Dt.each,on:bl,attr:pl,attrTween:fl,style:Al,styleTween:Il,text:Cl,textTween:Sl,remove:_l,tween:ul,delay:ml,duration:gl,ease:hl,easeVarying:yl,end:Pl,[Symbol.iterator]:Dt[Symbol.iterator]};function $r(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var pm={time:null,delay:0,duration:250,ease:$r};function fm(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function kl(e){var t,o;e instanceof We?(t=e._id,e=e._name):(t=Ur(),(o=pm).time=Ln(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var a=n[i],s=a.length,l,c=0;c<s;++c)(l=a[c])&&$t(l,e,t,c,a,o||fm(l,t));return new We(n,this._parents,e,t)}Rt.prototype.interrupt=dl;Rt.prototype.transition=kl;function Xt(e,t,o){this.k=e,this.x=t,this.y=o}Xt.prototype={constructor:Xt,scale:function(e){return e===1?this:new Xt(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Xt(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Xr=new Xt(1,0,0);Kr.prototype=Xt.prototype;function Kr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Xr;return e.__zoom}var gm=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var Rl;(function(e){e.Strict="strict",e.Loose="loose"})(Rl||(Rl={}));var Dl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Dl||(Dl={}));var Ol;(function(e){e.Partial="partial",e.Full="full"})(Ol||(Ol={}));var Vl;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Vl||(Vl={}));var Hl;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Hl||(Hl={}));var $e;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})($e||($e={}));var GE={[$e.Left]:$e.Right,[$e.Right]:$e.Left,[$e.Top]:$e.Bottom,[$e.Bottom]:$e.Top};var hm=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var ym=(e,t=[0,0])=>{var s;let{width:o,height:n}=xm(e),r=(s=e.origin)!=null?s:t,i=o*r[0],a=n*r[1];return{x:e.position.x-i,y:e.position.y-a}};var Ot=(e,t=[0,0])=>{var r,i,a,s,l,c,d,u;let{x:o,y:n}=hm(e)?e.internals.positionAbsolute:ym(e,t);return{x:o,y:n,x2:o+((s=(a=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?a:e.initialWidth)!=null?s:0),y2:n+((u=(d=(c=(l=e.measured)==null?void 0:l.height)!=null?c:e.height)!=null?d:e.initialHeight)!=null?u:0)}};function xm(e){var t,o,n,r,i,a,s,l;return{width:(r=(n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:e.initialWidth)!=null?r:0,height:(l=(s=(a=(i=e.measured)==null?void 0:i.height)!=null?a:e.height)!=null?s:e.initialHeight)!=null?l:0}}var BE={[$e.Left]:{x:-1,y:0},[$e.Right]:{x:1,y:0},[$e.Top]:{x:0,y:-1},[$e.Bottom]:{x:0,y:1}};var Em={nodeOrigin:[0,0],nodeExtent:gm,elevateNodesOnSelect:!0,defaults:{}},zE=v(E({},Em),{checkEquality:!0});var Gl;(function(e){e.Line="line",e.Handle="handle"})(Gl||(Gl={}));var bm={width:0,height:0,x:0,y:0},FE=v(E({},bm),{pointerX:0,pointerY:0,aspectRatio:1});var _m=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function Tm(e,t){let o=Math.max(0,Math.min(e.x2,t.x2)-Math.max(e.x,t.x)),n=Math.max(0,Math.min(e.y2,t.y2)-Math.max(e.y,t.y));return o*n}function vm(e,t){let o=Math.max(0,Math.max(e.x-t.x2,t.x-e.x2)),n=Math.max(0,Math.max(e.y-t.y2,t.y-e.y2));return Math.sqrt(o*o+n*n)}var qr=class{constructor(){this.xLines=[];this.yLines=[]}initialize(t){this.xLines=t.filter(o=>o.orientation==="vertical"),this.yLines=t.filter(o=>o.orientation==="horizontal"),this.xLines.sort((o,n)=>o.position-n.position),this.yLines.sort((o,n)=>o.position-n.position),this.lastHorizontalLine=void 0,this.lastVerticalLine=void 0}search(t,o,n,r,i){let a=t==="horizontal"?this.yLines:this.xLines,[s,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of a){if(f.position<s)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!_m(f.nodeBox,r))continue;let h=Math.abs(f.position-o);if(h>Zr)continue;let g=Tm(f.nodeBox,n)>0?0:vm(f.nodeBox,n);c.push({line:f,lineDist:h,nodeDist:g})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((f,h)=>{if(u){if(f.line===u&&h.line!==u)return-1;if(h.line===u&&f.line!==u)return 1}return Math.abs(f.lineDist-h.lineDist)<=d?f.nodeDist-h.nodeDist:f.lineDist-h.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function Bl(e,t=mo,o){let n=[];return e==null||e.forEach(r=>{let i=o(r.id);if(!i)throw new Error(`Node with id ${r.id} not found in internal nodes.`);let a=Ot(i);Object.entries(t).forEach(([s,l])=>{var c;n.push({position:l.resolve(r,a),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:s,nodeBox:a,node:r})})}),n}function zl(e,t,o,n,r=Object.keys(mo)){let i=[];for(let s of r){let l=mo[s],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:s,anchor:l,line:d})}let a={horizontal:void 0,vertical:void 0};for(let s of i){let l=a[s.anchor.orientation],c=Math.abs(s.sourcePosition-s.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(a[s.anchor.orientation]=s)}return a}function Fl(e,t,o){let n=0,r=0,i=!1,a=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Zr&&(r=l,a=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Zr&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:a}}var Zr=10,mo={top:{orientation:"horizontal",resolve:(e,t)=>t.y},bottom:{orientation:"horizontal",resolve:(e,t)=>t.y2},left:{orientation:"vertical",resolve:(e,t)=>t.x},right:{orientation:"vertical",resolve:(e,t)=>t.x2},centerX:{orientation:"vertical",resolve:(e,t)=>(t.x+t.x2)/2},centerY:{orientation:"horizontal",resolve:(e,t)=>(t.y+t.y2)/2}};var Yl=require("react/jsx-runtime"),Nm=new qr;function Jr(){let[e,t]=(0,je.useState)(void 0),[o,n]=(0,je.useState)(void 0),{width:r,height:i}=(0,Yo.useStore)(g=>({width:g.width,height:g.height}),Wl.shallow),a=(0,Yo.useNodesInitialized)(),s=(0,je.useRef)(Nm),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Yo.useReactFlow)(),u=(0,je.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,je.useCallback)(g=>{let b=g!=null?g:d();u();let x=Bl(b,mo,c);s.current.initialize(x)},[c,u,d]),f=(0,je.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,je.useEffect)(()=>{a&&p(d())},[a,p,d]);let h=(0,je.useCallback)((g,b)=>{var D,V,K,B,oe,H,$,J,Y,U;if(!s.current||g.length===0)return g;u();let x=g.filter(W=>W.type==="position"&&!!W.position),m=g.find(W=>W.type==="dimensions");if(x.length===0&&!m)return g;let N=Object.keys(mo),T=new Set,_=1/0,w=1/0,S=-1/0,P=-1/0;if(x.length>0)x.forEach(W=>{var Se,be,ce,ie,Be,Je;let q=b.find(Bt=>Bt.id===W.id);if(!q)return;T.add(q.id);let j=c(q.id);if(!j)return;let le=j.parentId?c(j.parentId):void 0,re=W.position.x+((Se=le==null?void 0:le.internals.positionAbsolute.x)!=null?Se:0),fe=W.position.y+((be=le==null?void 0:le.internals.positionAbsolute.y)!=null?be:0),ve=(ie=(ce=q.measured)==null?void 0:ce.width)!=null?ie:0,Me=(Je=(Be=q.measured)==null?void 0:Be.height)!=null?Je:0;_=Math.min(_,re),w=Math.min(w,fe),S=Math.max(S,re+ve),P=Math.max(P,fe+Me)}),m&&(N=["top","left"]);else if(m){let W=b.find(ve=>ve.id===m.id);if(!W)return g;T.add(W.id);let q=c(W.id);if(!q)return g;let j=q.internals.positionAbsolute.x,le=q.internals.positionAbsolute.y,re=(B=(K=(D=m.dimensions)==null?void 0:D.width)!=null?K:(V=W.measured)==null?void 0:V.width)!=null?B:0,fe=(J=($=(oe=m.dimensions)==null?void 0:oe.height)!=null?$:(H=W.measured)==null?void 0:H.height)!=null?J:0;_=j,w=le,S=j+re,P=le+fe,N=["right","bottom"]}if(_===1/0)return g;let I={x:_,y:w,x2:S,y2:P},{x:O,y:C}=l({x:0,y:0}),{x:L,y:z}=l({x:r,y:i}),A={x:O,y:C,x2:L,y2:z},{horizontal:G,vertical:Q}=zl(s.current,A,I,T,N),{deltaX:Z,deltaY:F,snappedX:M,snappedY:R}=Fl(I,G,Q);if(M||R){let W=x.some(j=>j.dragging),q=!!(m!=null&&m.resizing);(W||q)&&(M&&n(Q==null?void 0:Q.line),R&&t(G==null?void 0:G.line)),M&&(x.forEach(j=>{j.position&&(j.position.x-=Z)}),(m==null?void 0:m.id)===((Y=x[0])==null?void 0:Y.id)?m.dimensions&&(m.dimensions.width+=Z):m&&!x.length&&m.dimensions&&(m.dimensions.width-=Z)),R&&(x.forEach(j=>{j.position&&(j.position.y-=F)}),(m==null?void 0:m.id)===((U=x[0])==null?void 0:U.id)?m.dimensions&&(m.dimensions.height+=F):m&&!x.length&&m.dimensions&&(m.dimensions.height-=F))}return g},[l,c,r,i,t,n,u]),y=(0,je.useCallback)(()=>(0,Yl.jsx)(Ul,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:y}}var Ni=require("@xyflow/react"),It=require("react");var Kt=e=>new Map(e.map(t=>[t.id,t])),Dn=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),$l=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),ss=e=>e.some(t=>t.type==="START_EVENT"),qt=(e,t)=>e==="START_EVENT"?!ss(t):!0,Xl=(e,t,o,n,r)=>{let i=Kt(o),a=i.get(e);if(!a||a.type!=="START_EVENT")return!1;let s=i.get(t);return(s==null?void 0:s.type)==="ANNOTATION"?!1:Dn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Kl=(e,t,o,n,r)=>{let i=Kt(o),a=i.get(t);if(!a||a.type!=="END_EVENT")return!1;let s=i.get(e);return(s==null?void 0:s.type)==="ANNOTATION"?!1:$l(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Qr=(e,t,o,n,r)=>{var c;let i=Kt(o),a=i.get(e);if(!a||a.type!=="GATEWAY"||((c=a.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Dn(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},ql=(e,t,o)=>{var a,s,l,c;let n=Kt(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((a=r==null?void 0:r.data)==null?void 0:a.variant)==="EXCLUSIVE"&&((s=i==null?void 0:i.data)==null?void 0:s.variant)==="PARALLEL"||((l=r==null?void 0:r.data)==null?void 0:l.variant)==="COMPLEX"&&((c=i==null?void 0:i.data)==null?void 0:c.variant)==="PARALLEL"},jr=(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"},Zl=(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)==="SUBPROCESS"},ei=(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"},On=(e,t,o,n)=>{let r=Kt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:$l(e,o,n).some(s=>{let l=r.get(s.source);return(l==null?void 0:l.type)==="START_EVENT"})},Vn=(e,t,o,n)=>{let r=Kt(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Dn(e,o,n).some(s=>{let l=r.get(s.target);return(l==null?void 0:l.type)==="END_EVENT"})},Jl=(e,t,o,n,r)=>{let i=Kt(o),a=i.get(e),s=i.get(t);return(a==null?void 0:a.type)==="START_EVENT"&&(s==null?void 0:s.type)==="TASK"?Vn(t,o,n,r):(s==null?void 0:s.type)==="END_EVENT"&&(a==null?void 0:a.type)==="TASK"?On(e,o,n,r):!1},ti=(e,t,o)=>Dn(e,t,o).length>0,oi=(e,t,o,n,r)=>{let i=Kt(o),a=i.get(e);if(!a||a.type!=="TASK")return!1;let s=t?i.get(t):null;return(s==null?void 0:s.type)==="ANNOTATION"?!1:Dn(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Ql=(e,t,o,n)=>o.some(r=>n&&r.id===n?!1:r.source===e&&r.target===t);var wm=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Ql(e.sourceNodeId,e.targetNodeId,e.edges,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!Xl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!Kl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Qr(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!oi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:ql(e.sourceNodeId,e.targetNodeId,e.nodes),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==="START_EVENT"&&Zl(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_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:!(jr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(ei(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(On(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!Jl(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Vn(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(ti(e.sourceNodeId,e.edges,e.reconnectingEdgeId)&&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","GATEWAY"],LANE:["ANNOTATION"],ANNOTATION:["START_EVENT","END_EVENT","TASK","GATEWAY","LANE"],UNSUPPORTED:[]}[e.sourceNodeType]||[]).includes(e.targetNodeType),reason:"connection_type_not_allowed"})],as=e=>{for(let t of wm){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var Am=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Qr(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"gateway_limit_reached"})},{sourceTypes:["START_EVENT"],validate:e=>({shouldDisable:e.edges.some(o=>{if(o.source!==e.sourceNodeId)return!1;let n=e.nodes.find(r=>r.id===o.target);return(n==null?void 0:n.type)!=="ANNOTATION"})&&e.targetNodeType!=="ANNOTATION",reason:"start_event_limit_reached"})},{targetTypes:["START_EVENT"],validate:e=>({shouldDisable:ss(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:jr(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ei(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:On(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Vn(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:ti(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:oi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],jl=e=>{let t=Am.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 Vt=require("@xyflow/react");var Uo=require("@xyflow/react");function ec(e,t){var m,N,T,_;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,a=o/2,s=n/2,l=r.x+a,c=r.y+s,d=i.x+((N=(m=t==null?void 0:t.measured)==null?void 0:m.width)!=null?N:0)/2,u=i.y+((_=(T=t==null?void 0:t.measured)==null?void 0:T.height)!=null?_:0)/2,p=(d-l)/(2*a)-(u-c)/(2*s),f=(d-l)/(2*a)+(u-c)/(2*s),h=1/(Math.abs(p)+Math.abs(f)||1),y=h*p,g=h*f,b=a*(y+g)+l,x=s*(-y+g)+c;return{x:b,y:x}}function tc(e,t){var c,d,u,p;let{positionAbsolute:o}=e.internals,n=(d=(c=e.measured)==null?void 0:c.width)!=null?d:0,r=(p=(u=e.measured)==null?void 0:u.height)!=null?p:0,i=Math.round(o.x),a=Math.round(o.y),s=Math.round(t.x),l=Math.round(t.y);return s<=i+1?Uo.Position.Left:s>=i+n-1?Uo.Position.Right:l<=a+1?Uo.Position.Top:l>=a+r-1?Uo.Position.Bottom:Uo.Position.Top}function $o(e,t){let o=ec(e,t),n=ec(t,e),r=tc(e,o),i=tc(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function ni(e,t){return{isFromStartEvent:(e==null?void 0:e.type)==="START_EVENT",isGatewayToGateway:(e==null?void 0:e.type)==="GATEWAY"&&(t==null?void 0:t.type)==="GATEWAY",isActiviyToAndGateway:(e==null?void 0:e.type)==="TASK"&&(t==null?void 0:t.type)==="GATEWAY"}}var Tt=require("@produto-lecom/lecom-ui"),nc=require("lucide-react");var dt=require("@xyflow/react");var oc=require("@xyflow/react"),Zt=()=>{let e=(0,oc.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:a,triggerNodeChanges:s}=e.getState(),l=i.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]),c=r.reduce((d,u)=>[...d,{id:u.id,type:"select",selected:n.includes(u.id)}],[]);return s(l),a(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await gr(),!0}}};var ri=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,dt.useReactFlow)(),{selectElements:r}=Zt(),i=g=>{let b=o(),x=n(),m=(0,dt.getIncomers)(g,b,x),N=(0,dt.getOutgoers)(g,b,x),T=m.some(w=>w.type==="START_EVENT"),_=N.some(w=>w.type==="END_EVENT");return T?"start":_?"end":"between"},a=(g,b,x)=>{var T,_,w,S;if(!g)return;let m={type:g.type,variant:(T=g.data)==null?void 0:T.variant,attribute:(_=g.data)==null?void 0:_.attribute},N={id:g.id,position:i(g),label:(w=g.data)==null?void 0:w.label,node:m};return g.type==="TASK"&&((S=g.data)==null?void 0:S.variant)==="SUBPROCESS"?v(E({},N),{type:"sub_process"}):g.type==="GATEWAY"?v(E({},N),{type:"gateway",variant:s(g,b,x)}):v(E({},N),{type:"activity"})},s=(g,b,x)=>{if(g.type!=="GATEWAY")return;let m=(0,dt.getIncomers)(g,b,x),N=!1,T=!1;if(m.forEach(_=>{var w,S;_.type==="TASK"&&(((w=_.data)==null?void 0:w.variant)==="SCRIPT"&&(N=!0),((S=_.data)==null?void 0:S.attribute)==="LOOP"&&(T=!0))}),N&&T)return"script_loop";if(N)return"script";if(T)return"loop"},l=(g,b,x)=>{var w,S,P,I;let m=e(g.source),N=e(g.target);if(!m||!N)return"simple";if((0,dt.getOutgoers)(m,b,x).some(O=>O.type==="END_EVENT"))return"final";if(m.type==="GATEWAY")switch((w=m.data)==null?void 0:w.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(m.type==="TASK"){let O=(S=m.data)==null?void 0:S.variant,C=(P=m.data)==null?void 0:P.attribute;if(O==="SUBPROCESS")return"from_sub_process";if(N.type==="TASK"&&((I=N.data)==null?void 0:I.variant)==="SUBPROCESS")return"to_sub_process";let L=O==="SCRIPT",z=C==="LOOP";return L&&z?"script_loop":L?"script":z?"loop":"simple"}return"simple"},c=(g,b,x)=>{let m=[];function N(_,w,S=0){let P=a(_,b,x);if(P.depth=S,w.push(P),_.type==="TASK"){m.push([...w]),w.pop();return}let I=(0,dt.getIncomers)(_,b,x);if(I.length)for(let O of I)N(O,w,S+1);w.pop()}let T=(0,dt.getIncomers)(g,b,x);for(let _ of T)N(_,[]);return m},d=(g,b,x)=>{let m=[];function N(_,w,S=0){let P=a(_,b,x);if(P.depth=S,w.push(P),_.type==="TASK"){m.push([...w]),w.pop();return}let I=(0,dt.getOutgoers)(_,b,x);if(I.length)for(let O of I)N(O,w,S+1);w.pop()}let T=(0,dt.getOutgoers)(g,b,x);for(let _ of T)N(_,[]);return m},u=(g,b,x)=>(x=x.filter(N=>N.source===g.id),x.map(N=>{var w;let T=e(N.target),_;return T&&(_=a(T,b,x)),{id:N.id,type:"routing",variant:l(N,b,x),label:(w=N.data)==null?void 0:w.label,target:_}})),p=g=>{let b=e(g);if(!b)return;let x=o(),m=n(),N=a(b,x,m);return N.sources=c(b,x,m),N.targets=d(b,x,m),N.edgeTargets=u(b,x,m),b.type==="GATEWAY"&&(N.variant=s(b,x,m)),N},f=g=>{let b=t(g);if(!b)return;let x=o(),m=n(),N=l(b,x,m),_={id:b.id,type:"routing",variant:N,gatewayVariant:void 0},w=e(b.source);if(w){let P=a(w,x,m);_.source=P;let I=s(w,x,m);if(_.gatewayVariant=I,w.type==="TASK")_.sources=[[P]];else{let O=c(w,x,m);_.sources=O.length?O:[[P]]}}let S=e(b.target);if(S){let P=a(S,x,m);if(_.target=P,S.type==="TASK")_.targets=[[P]];else{let I=d(S,x,m);_.targets=I.length?I:[[P]]}}return _},h=g=>{let b=e(g);if(b)return p(b.id);let x=t(g);if(x)return f(x.id)};return{configureElement:g=>{let b=h(g);if(b)return r([g]),b},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:f}};var go=require("react/jsx-runtime"),Jt=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Tt.useTranslation)(),{onConfigureElement:n}=X(),{getConfigureElement:r}=ri();return(0,go.jsxs)(Tt.Tooltip,{children:[(0,go.jsx)(Tt.TooltipTrigger,{asChild:!0,children:(0,go.jsx)(Tt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let a=r(e);a&&(n==null||n(a))},children:(0,go.jsx)(nc.Settings,{size:16})})}),(0,go.jsx)(Tt.TooltipContent,{color:"black",children:o(t==="node"?"editor.toolbar.configure_node":"editor.toolbar.configure_edge")})]})};var rc=require("@xyflow/react"),ut=require("@produto-lecom/lecom-ui"),ic=require("lucide-react");var ho=require("react/jsx-runtime"),ii=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,ut.useTranslation)(),{deleteElements:n,getNodes:r}=(0,rc.useReactFlow)();return(0,ho.jsxs)(ut.Tooltip,{children:[(0,ho.jsx)(ut.TooltipTrigger,{asChild:!0,children:(0,ho.jsx)(ut.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(t==="node"){let a=r(),s=a.find(l=>l.id===e);if((s==null?void 0:s.type)==="LANE"&&a.some(c=>c.parentId===e)){(0,ut.toast)({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}n({nodes:[{id:e}]})}else n({edges:[{id:e}]})},children:(0,ho.jsx)(ic.TrashIcon,{size:16})})}),(0,ho.jsx)(ut.TooltipContent,{color:"black",children:o("editor.toolbar.delete")})]})};var vt=require("@produto-lecom/lecom-ui"),sc=require("lucide-react"),ac=require("react"),yo=require("react/jsx-runtime"),xo=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,vt.useTranslation)(),r=(0,ac.useCallback)(i=>{i.stopPropagation();let a=document.querySelector(`[data-id="${e}"]`);if(!a)return;let s=a.querySelector(".react-flow__handle.source");if(!s)return;let l=s.getBoundingClientRect(),c=l.left+l.width/2,d=l.top+l.height/2,u=new MouseEvent("mousedown",{clientX:c,clientY:d,bubbles:!0,cancelable:!0});s.dispatchEvent(u)},[e]);return(0,yo.jsxs)(vt.Tooltip,{children:[(0,yo.jsx)(vt.TooltipTrigger,{asChild:!0,children:(0,yo.jsx)(vt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:t,className:t?"opacity-50 cursor-not-allowed":"",onMouseDown:t?void 0:r,children:(0,yo.jsx)(sc.MoveUpRightIcon,{size:16})})}),(0,yo.jsx)(vt.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Xo=require("react/jsx-runtime"),qo=i=>{var a=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=a,r=bt(a,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:s}=X(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d}=ni(o,n),u=!l&&!c&&!d,p=[{component:(0,Xo.jsx)(ii,{elementId:e,elementType:"edge"})}],f=()=>s==="view"?u?[{component:(0,Xo.jsx)(Jt,{elementId:e,elementType:"edge"})}]:[]:u?[{component:(0,Xo.jsx)(Jt,{elementId:e,elementType:"edge"})},...p]:p,y=(g=>{switch(g){case"SEQUENCE_EDGE":return f();case"MESSAGE_EDGE":return s==="view"?[]:[...p];case"ANNOTATION_EDGE":return s==="view"?[]:[...p];default:return[]}})(t);if(!(y.length===0||s==="view"))return(0,Xo.jsx)("div",v(E({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:y.map((g,b)=>(0,Xo.jsx)("div",{children:g.component},b))}))};var lc=require("@xyflow/react"),cc=require("react");var ls=require("react/jsx-runtime"),Nt=12,Zo=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:a}=(0,lc.useViewport)(),s=1/a,l=(0,cc.useMemo)(()=>t===n?{bottom:`${Nt}px`,transform:"translateX(-50%)"}:e===o?{left:`${Nt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${Nt}px`,bottom:`${Nt}px`}:n>t&&o<e?{right:`${Nt}px`,bottom:`${Nt}px`}:t>n&&o>e?{right:`${Nt}px`,bottom:`${Nt}px`}:{left:`${Nt}px`,bottom:`${Nt}px`},[e,t,o,n,r]);return(0,ls.jsx)("div",{style:{transform:`scale(${s})`},children:(0,ls.jsx)("div",{className:"absolute pointer-events-auto",style:E({},l),children:i})})};var Qt=require("react/jsx-runtime"),Jo={type:"ANNOTATION_EDGE",reconnectable:!0},dc=({id:e,source:t,target:o,selected:n,data:r})=>{let{isMultipleSelection:i}=X(),a=(0,Vt.useInternalNode)(t),s=(0,Vt.useInternalNode)(o);if(!a||!s)return null;let{sx:l,sy:c,tx:d,ty:u}=$o(a,s),[p,f,h]=(0,Vt.getStraightPath)({sourceX:l,sourceY:c,targetX:d,targetY:u}),y=n||(a==null?void 0:a.selected)||(s==null?void 0:s.selected);return(0,Qt.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":y}),children:[(0,Qt.jsx)(Vt.BaseEdge,{id:e,path:p,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":y&&!(r!=null&&r.hasError)})}),(0,Qt.jsx)(Vt.EdgeLabelRenderer,{children:(0,Qt.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${f}px, ${h}px)`},children:n&&!i&&(0,Qt.jsx)(Zo,{sx:l,sy:c,tx:d,ty:u,children:(0,Qt.jsx)(qo,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})};var Xe=require("react"),_e=require("@xyflow/react");var Eo=require("react");var cs=require("react/jsx-runtime"),ze=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:a,onBlur:s,onInput:l,onInvalidFirstCharacter:c})=>{let d=(0,Eo.useRef)(null),[u,p]=(0,Eo.useState)(!1);(0,Eo.useEffect)(()=>{p(i!=null?i:!1)},[i]),(0,Eo.useEffect)(()=>{if(u&&d.current){d.current.focus();let x=document.createRange();x.selectNodeContents(d.current);let m=window.getSelection();m&&(m.removeAllRanges(),m.addRange(x))}},[u]);let f=x=>{x.stopPropagation(),u||p(!0)},h=x=>{let m=x.currentTarget.innerText.replace(/\n$/,""),N=t&&m.length>=t,T=window.getSelection(),_=(T==null?void 0:T.toString())||"",w=_.length>0,S=x.ctrlKey||x.metaKey,P=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Enter","Escape","Shift"],I=S&&x.key==="a",O=S&&x.key==="c",C=S&&x.key==="x",L=S&&x.key==="v";function z(G){return/[a-zA-Z0-9À-ÖØ-öø-ÿ]/.test(G)}if((m.length===0||w&&_.length===m.length)&&!z(x.key)&&!P.includes(x.key)&&!S){x.preventDefault();return}if(x.key==="Enter"&&!x.shiftKey){x.preventDefault(),x.currentTarget.blur();return}N&&!w&&(P.includes(x.key)||I||O||C||L||x.preventDefault())},y=x=>{x.preventDefault();let m=x.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
+ `).replace(/\r/g,`
3
+ `),N=x.currentTarget.innerText.replace(/\n$/,""),T=window.getSelection();if(!T||T.rangeCount===0)return;let _=T.toString(),w=N.length-_.length,S=t?Math.max(0,t-w):1/0;if(S<=0&&_.length===0)return;let P=m;if(P.length>S&&(P=P.substring(0,S)),!P&&_.length===0)return;let I=T.getRangeAt(0);if(I.startOffset===0&&(I.startContainer===x.currentTarget||I.startContainer.parentNode===x.currentTarget)&&P.length>0){let L=P[0];if(!/[a-zA-Z0-9À-ÖØ-öø-ÿ]/.test(L)){c==null||c();return}}I.deleteContents();let C=document.createTextNode(P);I.insertNode(C),I.setStartAfter(C),I.collapse(!0),T.removeAllRanges(),T.addRange(I),l==null||l(x.currentTarget.innerText.replace(/\n$/,""))},g=x=>{l==null||l(x.currentTarget.innerText.replace(/\n$/,""))},b=x=>{p(!1);let m=x.currentTarget.innerText.replace(/\r\n/g,`
4
+ `).replace(/\r/g,`
5
+ `).trim();t&&m.length>t&&(m=m.substring(0,t)),x.currentTarget.innerText=m,s==null||s(),m!==e&&(a==null||a(m))};return(0,cs.jsx)("div",{className:k("flex-1 p-2 self-stretch content-center border border-transparent overflow-hidden text-ellipsis body-medium-400 text-center rounded-sm",{"border border-dashed border-grey-400 bg-white shadow-md":u,"bg-white":e.length>0},n),style:o,onDoubleClick:f,children:(0,cs.jsx)("div",{ref:d,className:k("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":u}),contentEditable:u,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:y,onInput:g,onBlur:b,children:e})})};var Hn=require("@xyflow/react"),Gn=e=>e===Hn.Position.Left||e===Hn.Position.Right,ds=(e,t=30)=>e===Hn.Position.Right||e===Hn.Position.Bottom?t:-t,us=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,si=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),ai=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});var Bn={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15};function Im(e,t,o,n,r,i,a=0){let s=ds(r,Bn.OFFSET),l=ds(i,Bn.OFFSET),c=Gn(r),d=Gn(i),u=c?0:a,p=c?a:0,f=d?0:a,h=d?a:0,y={x:e+u,y:t+p},g={x:o+f,y:n+h};if(c&&d){let b=(t+n)/2+a;return[y,{x:e+s,y:t+a},{x:e+s,y:b},{x:o+l,y:b},{x:o+l,y:n+a},g]}if(!c&&!d){let b=(e+o)/2+a;return[y,{x:e+a,y:t+s},{x:b,y:t+s},{x:b,y:n+l},{x:o+a,y:n+l},g]}return c?[y,{x:e+s,y:t+a},{x:e+s,y:n+l+a},{x:o+a,y:n+l+a},g]:[y,{x:e+a,y:t+s},{x:o+l+a,y:t+s},{x:o+l+a,y:n+a},g]}function uc(e,t,o,n,r,i,a,s=0){let l=Im(e,t,o,n,r,i,s);if(!(a!=null&&a.length))return l;let c=[...a];if(c.length>0){let d={x:e,y:t},u=c[0],p=Gn(r);p&&Math.abs(d.y-u.y)>1?c.unshift({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.unshift({x:d.x,y:u.y})}if(c.length>0){let d={x:o,y:n},u=c[c.length-1],p=Gn(i);p&&Math.abs(d.y-u.y)>1?c.push({x:u.x,y:d.y}):!p&&Math.abs(d.x-u.x)>1&&c.push({x:d.x,y:u.y})}return[{x:e,y:t},...c,{x:o,y:n}]}var pc=e=>{if(e.length<2)return"";let[t,...o]=e;return`M ${t.x},${t.y}${o.map(n=>` L ${n.x},${n.y}`).join("")}`};var he=require("react"),li=require("@xyflow/react");var Cm=50,fc=.1,Sm=.6,ci=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:a,getNodes:s,getEdge:l,screenToFlowPosition:c}=(0,li.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=X(),p=(0,li.useStore)(M=>M.isValidConnection),[f,h]=(0,he.useState)(null),[y,g]=(0,he.useState)(null),[b,x]=(0,he.useState)(null),[m,N]=(0,he.useState)(null),[T,_]=(0,he.useState)(null),[w,S]=(0,he.useState)(!1),P=(0,he.useRef)(null),I=(0,he.useRef)(null),O=(0,he.useRef)(null),C=(0,he.useRef)(t),L=(0,he.useRef)(o);(0,he.useEffect)(()=>{C.current=t,L.current=o},[t,o]),(0,he.useEffect)(()=>{P.current=f},[f]),(0,he.useEffect)(()=>{I.current=T},[T]);let z=(0,he.useCallback)(M=>{let R=s(),D=R.find(oe=>oe.id===M);if(!D)return{x:0,y:0};let V=D.position.x,K=D.position.y,B=D.parentId;for(;B;){let oe=R.find(H=>H.id===B);if(!oe)break;V+=oe.position.x,K+=oe.position.y,B=oe.parentId}return{x:V,y:K}},[s]),A=(0,he.useCallback)(M=>{var B,oe,H,$,J,Y;let R=s(),D=null,V=Cm,K=R.filter(U=>U.type!=="LANE"&&U.type!=="ANNOTATION");for(let U of K){if(U.id===e)continue;let W=z(U.id),q=(H=(oe=(B=U.measured)==null?void 0:B.width)!=null?oe:U.width)!=null?H:0,j=(Y=(J=($=U.measured)==null?void 0:$.height)!=null?J:U.height)!=null?Y:0;if(M.x>=W.x&&M.x<=W.x+q&&M.y>=W.y&&M.y<=W.y+j)return U.id;let re=Math.max(W.x-M.x,0,M.x-(W.x+q)),fe=Math.max(W.y-M.y,0,M.y-(W.y+j)),ve=Math.sqrt(re*re+fe*fe);ve<V&&(V=ve,D=U.id)}return D},[s,z,e]),G=(0,he.useCallback)((M,R)=>{var re,fe,ve,Me,Se,be;let D=a(M);if(!D)return null;let V=z(M),K=(ve=(fe=(re=D.measured)==null?void 0:re.width)!=null?fe:D.width)!=null?ve:0,B=(be=(Se=(Me=D.measured)==null?void 0:Me.height)!=null?Se:D.height)!=null?be:0,oe=Math.abs(V.x+K-R.x),H=Math.abs(R.x-V.x),$=Math.abs(V.y+B-R.y),J=Math.abs(R.y-V.y),Y={right:oe,left:H,bottom:$,top:J},U=Object.entries(Y).reduce((ce,[ie,Be])=>Be<ce[1]?[ie,Be]:ce,["right",Y.right])[0],W=O.current;if(W&&W!==U){let ce=Y[U],ie=Y[W],Be=Math.abs(ie-ce),Je=Math.min(Math.abs(ie),Math.abs(ce));Be<Je*Sm&&(U=W)}let q=U,j,le;if(q==="right"||q==="left"){let ie=(Math.max(V.y,Math.min(V.y+B,R.y))-V.y)/(B||1);Math.abs(ie-.5)<fc&&(ie=.5),le=ie,j={x:q==="right"?V.x+K:V.x,y:V.y+le*B}}else{let ie=(Math.max(V.x,Math.min(V.x+K,R.x))-V.x)/(K||1);Math.abs(ie-.5)<fc&&(ie=.5),le=ie,j={x:V.x+le*K,y:q==="bottom"?V.y+B:V.y}}return{side:q,snapPosition:j,offset:le}},[a,z]),Q=(0,he.useCallback)(M=>{var H,$,J;let R=P.current;if(!R)return;let D=c({x:M.clientX,y:M.clientY}),V=A(D);x(V);let K=D,B=null,oe=null;if(V){let Y=G(V,D);Y&&(B=Y.side,K=Y.snapPosition,oe=Y.offset,O.current=B);let U=l(e),W={source:R==="source"?V:C.current,target:R==="target"?V:L.current,sourceHandle:R==="source"?B:(H=U==null?void 0:U.sourceHandle)!=null?H:null,targetHandle:R==="target"?B:($=U==null?void 0:U.targetHandle)!=null?$:null},q=(J=p==null?void 0:p(W))!=null?J:!0;S(q)}else O.current=null,S(!1);N(B),_(oe),g(K)},[A,G,l,e,c,p]),Z=(0,he.useCallback)(M=>{var B,oe,H,$,J;let R=P.current;if(!R)return;let D=c({x:M.clientX,y:M.clientY}),V=A(D);if(V){let Y=G(V,D),U=(B=Y==null?void 0:Y.side)!=null?B:null,W=(oe=Y==null?void 0:Y.offset)!=null?oe:.5,q=l(e),j={source:R==="source"?V:C.current,target:R==="target"?V:L.current,sourceHandle:R==="source"?U:(H=q==null?void 0:q.sourceHandle)!=null?H:null,targetHandle:R==="target"?U:($=q==null?void 0:q.targetHandle)!=null?$:null};((J=p==null?void 0:p(j))==null||J)&&i(le=>le.map(re=>{var fe,ve;return re.id===e?v(E({},re),{source:j.source,target:j.target,sourceHandle:j.sourceHandle,targetHandle:j.targetHandle,data:v(E({},re.data),{points:void 0,sourceOffset:R==="source"?W:(fe=re.data)==null?void 0:fe.sourceOffset,targetOffset:R==="target"?W:(ve=re.data)==null?void 0:ve.targetOffset})}):re}))}h(null),g(null),x(null),N(null),_(null),d(!1),S(!1),u(null),O.current=null,document.removeEventListener("mouseup",Z),document.removeEventListener("mousemove",Q);let K=wt.get(n);K==null||K.clearReconnectingEdge()},[e,A,G,l,i,n,Q,p,c,d,u]),F=(0,he.useCallback)((M,R)=>{if(r||R.button!==0)return;R.stopPropagation(),R.preventDefault(),i(V=>V.map(K=>K.id===e?v(E({},K),{data:v(E({},K.data),{points:void 0})}):K)),h(M),u(e);let D=wt.get(n);D==null||D.setReconnectingEdge(e),document.addEventListener("mousemove",Q),document.addEventListener("mouseup",Z)},[r,e,n,Q,Z,u,i]);return(0,he.useEffect)(()=>()=>{if(P.current){document.removeEventListener("mousemove",Q),document.removeEventListener("mouseup",Z),u(null);let M=wt.get(n);M==null||M.clearReconnectingEdge()}},[n,Q,Z,u]),{reconnectingHandle:f,cursorPosition:y,hoveredNodeId:b,reconnectingSide:m,reconnectingOffset:T,isValidReconnection:w,handleReconnectStart:F}};var de=require("react/jsx-runtime"),gt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:_e.MarkerType.ArrowClosed},markerEnd:{type:_e.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:di,MIN_SEGMENT_LENGTH:Mm,PARALLEL_OFFSET:mc}=Bn;function Pm(e,t,o,n){let r=n.filter(s=>s.source===t&&s.target===o||s.source===o&&s.target===t);if(r.length<=1){let s=n.filter(d=>d.source===t);if(s.length<=1)return 0;let l=s.findIndex(d=>d.id===e);if(l<=0)return 0;let c=(s.length-1)/2;return(l-c)*mc}let i=r.findIndex(s=>s.id===e),a=(r.length-1)/2;return(i-a)*mc}var gc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var B,oe;let{zoom:c}=(0,_e.useViewport)(),{updateEdgeData:d}=(0,_e.useReactFlow)(),u=(0,_e.useEdges)(),{isMultipleSelection:p,mode:f,instanceId:h}=X(),[y,g]=(0,Xe.useState)(!1),[b,x]=(0,Xe.useState)(null),m=(0,Xe.useRef)(null),N=(0,Xe.useRef)(null),T=f!=="edit",{reconnectingHandle:_,cursorPosition:w,hoveredNodeId:S,reconnectingSide:P,isValidReconnection:I,handleReconnectStart:O}=ci({edgeId:e,source:t,target:o,instanceId:h,isReadOnly:T}),C=(0,_e.useInternalNode)(t),L=(0,_e.useInternalNode)(o),{sx:z,sy:A,tx:G,ty:Q,sourcePos:Z,targetPos:F}=(0,Xe.useMemo)(()=>{var fe,ve;let H=C&&L?$o(C,L):{sx:0,sy:0,tx:0,ty:0,sourcePos:_e.Position.Right,targetPos:_e.Position.Left},$=s?i:H.sourcePos,J=l?a:H.targetPos,Y=(Me,Se,be)=>{var Bt,Re,De,Qe,Mo,lr;let{x:ce,y:ie}=Me.internals.positionAbsolute,Be=(De=(Re=(Bt=Me.measured)==null?void 0:Bt.width)!=null?Re:Me.width)!=null?De:0,Je=(lr=(Mo=(Qe=Me.measured)==null?void 0:Qe.height)!=null?Mo:Me.height)!=null?lr:0;switch(Se){case _e.Position.Top:return{x:ce+Be*be,y:ie};case _e.Position.Bottom:return{x:ce+Be*be,y:ie+Je};case _e.Position.Left:return{x:ce,y:ie+Je*be};case _e.Position.Right:return{x:ce+Be,y:ie+Je*be};default:return{x:ce+Be/2,y:ie+Je/2}}},U=(fe=n==null?void 0:n.sourceOffset)!=null?fe:.5,W=(ve=n==null?void 0:n.targetOffset)!=null?ve:.5,q=C?Y(C,$,U).x:H.sx,j=C?Y(C,$,U).y:H.sy,le=L?Y(L,J,W).x:H.tx,re=L?Y(L,J,W).y:H.ty;return _==="source"&&w?(q=w.x,j=w.y,P&&($=P)):_==="target"&&w&&(le=w.x,re=w.y,P&&(J=P)),{sx:q,sy:j,tx:le,ty:re,sourcePos:$,targetPos:J}},[C,L,s,l,i,a,_,w,P,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,Xe.useEffect)(()=>{var J;if(!N.current){N.current={sx:z,sy:A,tx:G,ty:Q,sourcePos:Z,targetPos:F};return}let H=N.current;(Math.abs(z-H.sx)>di||Math.abs(A-H.sy)>di||Math.abs(G-H.tx)>di||Math.abs(Q-H.ty)>di||H.sourcePos!==Z||H.targetPos!==F)&&((J=n==null?void 0:n.points)!=null&&J.length)&&!_&&d(e,v(E({},n),{points:void 0})),N.current={sx:z,sy:A,tx:G,ty:Q,sourcePos:Z,targetPos:F}},[z,A,G,Q,Z,F,n,e,d,_]);let M=(0,Xe.useMemo)(()=>{let H=Pm(e,t,o,u);return uc(z,A,G,Q,Z,F,n==null?void 0:n.points,H)},[z,A,G,Q,Z,F,n==null?void 0:n.points,u,e,t,o]),R=(0,Xe.useMemo)(()=>{if(M.length<2)return ai({x:z,y:A},{x:G,y:Q});let H=0;for(let Y=0;Y<M.length-1;Y++)H+=si(M[Y],M[Y+1]);let $=H/2,J=0;for(let Y=0;Y<M.length-1;Y++){let U=si(M[Y],M[Y+1]);if(J+U>=$){let W=($-J)/U,q=M[Y],j=M[Y+1];return{x:q.x+(j.x-q.x)*W,y:q.y+(j.y-q.y)*W}}J+=U}return ai({x:z,y:A},{x:G,y:Q})},[M,z,A,G,Q]),D=(0,Xe.useCallback)((H,$)=>{if(f!=="edit"||$.button!==0)return;$.stopPropagation(),$.preventDefault();let J=M[H],Y=M[H+1],U=us(J,Y,"y"),W=U?J.y:J.x,q=[...M],j=q.length,le=H,re=H+1;x(H);let fe=Me=>{let Se=W+(U?Me.clientY-$.clientY:Me.clientX-$.clientX)/c;m.current=U?{x:(J.x+Y.x)/2,y:Se}:{x:Se,y:(J.y+Y.y)/2};let be=[];for(let ce=1;ce<j-1;ce++){let ie=q[ce];ce===le||ce===re?U?be.push({x:ie.x,y:Se}):be.push({x:Se,y:ie.y}):be.push(E({},ie))}d(e,v(E({},n),{points:be}))},ve=()=>{x(null),m.current=null,document.removeEventListener("mousemove",fe),document.removeEventListener("mouseup",ve)};document.addEventListener("mousemove",fe),document.addEventListener("mouseup",ve)},[f,M,c,n,e,d]);if(!C||!L)return null;let V=pc(M),K=r||C.selected||L.selected;return(0,de.jsxs)(de.Fragment,{children:[(0,de.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":K}),onDoubleClick:()=>g(!0),children:[(0,de.jsx)(_e.BaseEdge,{id:e,path:V,markerEnd:`url(#${K?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||_&&S&&!I,"stroke-green-500":_&&S&&I,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":K&&!(n!=null&&n.hasError)&&!_})}),r&&!p&&!T&&(0,de.jsx)("g",{children:M.slice(0,-1).map((H,$)=>{let J=M[$+1];if($===0||$===M.length-2||si(H,J)<Mm)return null;let Y=us(H,J,"y"),U=b===$,W=U&&m.current?m.current:ai(H,J);return(0,de.jsxs)("g",{children:[(0,de.jsx)("line",{x1:H.x,y1:H.y,x2:J.x,y2:J.y,stroke:"transparent",strokeWidth:20/c,className:k("cursor-pointer",{"cursor-ns-resize":Y,"cursor-ew-resize":!Y}),onMouseDown:q=>D($,q)}),(0,de.jsx)("circle",{cx:W.x,cy:W.y,r:4/c,fill:U?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,de.jsx)("circle",{cx:W.x,cy:W.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:U?.6:.3,className:"pointer-events-none"})]},$)})})]}),(0,de.jsxs)(_e.EdgeLabelRenderer,{children:[(0,de.jsxs)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${R.x}px, ${R.y}px)`},children:[r&&!p&&(0,de.jsx)(Zo,{sx:z,sy:A,tx:G,ty:Q,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:(0,de.jsx)(qo,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:C,targetNode:L})}),(y||((oe=n==null?void 0:n.label)==null?void 0:oe.trim()))&&(0,de.jsx)(ze,{value:n==null?void 0:n.label,className:k("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>g(!1),onChange:H=>d(e,{label:H.trim()})})]}),r&&!p&&!T&&(0,de.jsxs)(de.Fragment,{children:[(0,de.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${M[0].x}px, ${M[0].y}px)`},children:(0,de.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,de.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,de.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:_==="source"?.6:.3,className:"pointer-events-none"}),(0,de.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!_||_!=="source","cursor-not-allowed":_==="source"&&S&&!I,"cursor-grabbing":_==="source"&&(!S||I)}),onMouseDown:H=>O("source",H.nativeEvent)})]})}),(0,de.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${M[M.length-1].x}px, ${M[M.length-1].y}px)`},children:(0,de.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,de.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:_==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,de.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:_==="target"?.6:.3,className:"pointer-events-none"}),(0,de.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!_||_!=="target","cursor-not-allowed":_==="target"&&S&&!I,"cursor-grabbing":_==="target"&&(!S||I)}),onMouseDown:H=>O("target",H.nativeEvent)})]})})]})]})]})};var wd=require("use-debounce");var Nd=require("@xyflow/react"),Es=require("react");var zn=(d=>(d.START_EVENT="start-event",d.END_EVENT_TERMINATE="end-event-terminate",d.TASK="task",d.TASK_SCRIPT="task-script",d.SUBPROCESS="subprocess-collapsed",d.GATEWAY_EXCLUSIVE="gateway-exclusive",d.GATEWAY_PARALLEL="gateway-parallel",d.GATEWAY_COMPLEX="gateway-complex",d.ANNOTATION="annotation",d.LANE="lane",d))(zn||{});var ui=require("xml-js");var hc={compact:!0,spaces:4},Lm=e=>e.replace(/\n/g,"&#xA;");function pi(e,t=hc){if(e)return JSON.parse((0,ui.xml2json)(e,t))}function yc(e,t=hc){return e?(0,ui.json2xml)(e,v(E({},t),{attributeValueFn:Lm})):""}var km={MIN_WIDTH:36,MIN_HEIGHT:36},Rm={MIN_WIDTH:36,MIN_HEIGHT:36},Dm={MIN_WIDTH:56,MIN_HEIGHT:56},Qo={MIN_WIDTH:176,MIN_HEIGHT:96},fi={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},Ne={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},mi={MIN_WIDTH:176,MIN_HEIGHT:64},Om={MIN_WIDTH:128,MIN_HEIGHT:64},te={START_EVENT:km,END_EVENT:Rm,GATEWAY:Dm,TASK:Qo,LANE:Ne,ANNOTATION:mi,UNSUPPORTED:Om};var xc={"attribute-loop":"LOOP"},Ec={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS"},bc={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},_c={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed"},Tc={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var jo=(e,t,o)=>{let n=e._attributes.width||0,r=e._attributes.height||0,i=Ft(Number(n),t),a=Ft(Number(r),o);return{width:i,height:a,measured:{width:i,height:a}}},en=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,a={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},s={id:n,position:a,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(s.parentId=l),s},Hm=e=>{let{mxGeometry:t}=e,o=en(e),n=jo(t,te.START_EVENT.MIN_WIDTH,te.START_EVENT.MIN_HEIGHT);return v(E(E({},o),n),{type:"START_EVENT"})},Gm=e=>{let{mxGeometry:t}=e,o=en(e),n=jo(t,te.END_EVENT.MIN_WIDTH,te.END_EVENT.MIN_HEIGHT);return v(E(E({},o),n),{type:"END_EVENT"})},ps=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=en(e),i=jo(n,te.TASK.MIN_WIDTH,te.TASK.MIN_HEIGHT),a=t==null?void 0:t.find(l=>{let{parent:c}=l._attributes;return c===e._attributes.id});if(a){let{style:l}=a._attributes,c=xc[l];c&&(r.data.attribute=c)}let s=Ec[o.style];return s&&(r.data.variant=s),v(E(E({},r),i),{type:"TASK"})},fs=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=en(e),i=jo(o,te.GATEWAY.MIN_WIDTH,te.GATEWAY.MIN_HEIGHT);return r.data.variant=bc[n],v(E(E({},r),i),{type:"GATEWAY"})},Bm=e=>{let{mxGeometry:t}=e,o=en(e),n=jo(t,te.ANNOTATION.MIN_WIDTH,te.ANNOTATION.MIN_HEIGHT);return v(E(E({},o),n),{type:"ANNOTATION"})},zm=e=>{let{mxGeometry:t}=e,o=en(e),n=jo(t,te.LANE.MIN_WIDTH,te.LANE.MIN_HEIGHT);return v(E(E({},o),n),{type:"LANE"})},vc={task:ps,"task-script":ps,"subprocess-collapsed":ps,"start-event":Hm,"end-event-terminate":Gm,"gateway-parallel":fs,"gateway-exclusive":fs,"gateway-complex":fs,annotation:Bm,lane:zm},Fm=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Nc=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:a,style:s}=t,l=Fm(o==null?void 0:o.Array),c={id:n,source:r,target:i,data:E({label:a||""},l&&l.length>0?{points:l}:{})};return s.includes("association")&&s.includes('endArrow=""')?E(E({},Jo),c):E(E({},gt),c)},wc=(e,t)=>{let{id:o,type:n,source:r,target:i,data:a}=e,s=t==null?void 0:t.find(u=>u.id===r),l="";n==="ANNOTATION_EDGE"&&(l='association;endArrow=""');let c={_attributes:{as:"geometry",relative:"1"}};return a!=null&&a.points&&Array.isArray(a.points)&&a.points.length>0&&(c.Array=a.points.map(u=>({_attributes:{as:"mxPoint",x:u.x,y:u.y}}))),{_attributes:{id:o,parent:(s==null?void 0:s.parentId)||"1",edge:"1",style:l,source:r,target:i,value:(a==null?void 0:a.label)||""},mxGeometry:c}},tn=e=>{let{id:t,parentId:o,position:n,measured:r,data:i}=e;return{_attributes:{id:t,parent:o||"1",value:i.label,vertex:"1"},mxGeometry:{_attributes:{as:"geometry",width:(r==null?void 0:r.width)||0,height:(r==null?void 0:r.height)||0,x:n.x||0,y:n.y||0}}}},Wm=e=>{let{variant:t}=e.data,o=tn(e);return v(E({},o),{_attributes:v(E({},o._attributes),{style:_c[t]||"task"})})},Ym=e=>{let t=tn(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"start-event"})})},Um=e=>{let t=tn(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"end-event-terminate"})})},$m=e=>{let{variant:t}=e.data,o=tn(e);return v(E({},o),{_attributes:v(E({},o._attributes),{style:Tc[t]})})},Xm=e=>{let t=tn(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"lane"})})},Km=e=>{let t=tn(e);return v(E({},t),{_attributes:v(E({},t._attributes),{style:"annotation"})})},Ac={TASK:Wm,START_EVENT:Ym,END_EVENT:Um,GATEWAY:$m,ANNOTATION:Km,LANE:Xm},Ic=(e,t)=>{var a,s;let r=((a=e.measured)==null?void 0:a.width)||0,i=((s=e.measured)==null?void 0:s.height)||0;return{_attributes:{id:`${t+1}`,parent:e.id,style:"attribute-loop",connectable:"0"},mxGeometry:{_attributes:{as:"geometry",x:r/2-22/2,y:i-22,width:22,height:22}}}};var ms=sp(require("@dagrejs/dagre"),1),Pc=require("@xyflow/react");var Lc=require("lodash");var Cc=require("lodash");var Ht=e=>{var t,o,n,r,i,a,s,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:(a=(i=e.measured)==null?void 0:i.width)!=null?a:0,h:(l=(s=e.measured)==null?void 0:s.height)!=null?l:0}},bo=e=>(0,Cc.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),Sc=(e,t)=>{let{x:o,y:n}=Ht(e),{x:r,y:i}=Ht(t);return{x:o-r,y:n-i}};var on=({parentId:e,nodes:t,includeTypes:o=[...Object.values(ee)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),qm=(e,t)=>{let{x:o,y:n}=Ht(e),{x:r,y:i}=Ht(t),a=o-r,s=n-i;return Math.sqrt(a*a+s*s)},Zm=(e,t)=>{let{x:o,y:n,w:r,h:i}=Ht(e),{x:a,y:s,w:l,h:c}=Ht(t);return o<a+l&&a<o+r&&n<s+c&&s<n+i},Fn=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Zm(e,r)){let i=qm(e,r);i<n&&(n=i,o=r)}return o},Mc=(e,t)=>t.filter(o=>o.parentId===e).reduce((o,n)=>{var r,i;return Math.max(o,(i=(r=n.measured)==null?void 0:r.width)!=null?i:0)},0);var kc=(e=[],t=[],o="LR")=>{let n=new ms.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:a,height:s})=>n.setNode(i,{width:a,height:s})),t.forEach(i=>n.setEdge(i.source,i.target)),ms.default.layout(n),{nodes:e.map(i=>{let a=n.node(i.id);return v(E({},i),{position:{x:a.x-i.width/2,y:a.y-i.height/2}})}),edges:t}},Wn=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId),o=[...e];return t.forEach(n=>{o=Yn(n.id,o)}),o},Yn=(e,t)=>{var f,h;let o=[...t],n=o.find(y=>y.id===e);if(!n)return o;let r=o.filter(y=>y.parentId===e&&y.type==="LANE");if(r.length===0)return o;let i=(0,Lc.orderBy)(r,["position.y"]),a=Math.max((h=(f=n.measured)==null?void 0:f.width)!=null?h:0,fi.MIN_WIDTH),s=Mc(e,i)||Ne.MIN_WIDTH,l=Math.max(a,s),c=a-Ne.HEADER_WIDTH>=s,d=0,u=0;i.forEach(y=>{var g,b,x,m;o=o.map(N=>N.id===y.id?v(E({},N),{width:c?l-Ne.HEADER_WIDTH:l,measured:v(E({},N.measured),{width:c?l-Ne.HEADER_WIDTH:l}),position:{x:Ne.HEADER_WIDTH,y:d}}):N),d+=(b=(g=y.measured)==null?void 0:g.height)!=null?b:0,u+=(m=(x=y.measured)==null?void 0:x.height)!=null?m:0}),o=o.map(y=>y.id===e?v(E({},y),{height:u,width:c?l:l+Ne.HEADER_WIDTH,measured:v(E({},y.measured),{height:u,width:c?l:l+Ne.HEADER_WIDTH})}):y);let p=o.find(y=>y.id===e);return p!=null&&p.parentId&&(o=Yn(p.parentId,o)),o},Rc=(e,t,o)=>{if(e.type==="LANE")return o;let n=Ot(t),r=Ot(e);return r.y<n.y&&(e.position.y=0),r.x<n.x+Ne.HEADER_WIDTH&&(e.position.x=Ne.HEADER_WIDTH),r.y2>n.y2&&(t.height=r.y2-n.y,t.measured.height=r.y2-n.y),r.x2>n.x2&&(t.width=r.x2-n.x,t.measured.width=r.x2-n.x),o=o.map(i=>i.id===t.id?v(E({},i),{height:t.height,width:t.width,measured:t.measured}):i.id===e.id?v(E({},i),{position:e.position}):i),o},Dc=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)},Jm=50,Oc=(e,t=Jm)=>{let o=(0,Pc.getNodesBounds)(e);return{x:o.x-t,y:o.y-t,width:o.width+t*2,height:o.height+t*2}};var Un=1,Vc=e=>`<mxGraphModel>
3
6
  <root version="1.1">
4
7
  <mxCell id="0" />
5
8
  <mxCell id="1" parent="0" />
@@ -32,9 +35,10 @@
32
35
  <mxGeometry as="geometry" relative="1" />
33
36
  </mxCell>
34
37
  </root>
35
- </mxGraphModel>`,Sc=(e,t)=>{if(!e.length&&!t.length)return Yn;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Bm=e=>{let t=Object.values(Gn),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=mc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},zm=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=gc(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},Fm=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=yc)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=xc(n,t);o.push(l)}}),o},Wm=(e,t)=>{let o=[];return e.forEach(n=>{let r=hc(n,t);o.push(r)}),o},Mc=(e=[],t=[],o)=>{let n=Fm(e,o),r=Wm(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return lc(JSON.stringify(i),{compact:!0,spaces:0})},Pc=async e=>{var s,l,c,d,u;let t=await ai(e),o=((l=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||Yn),r=Bm(o),i=zm(o,r);return{nodes:Eo(Fn(r)),edges:i,lastElementId:n}};var To=require("@xyflow/react");var Un=require("@xyflow/react");var cs=require("react/jsx-runtime"),ie=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=yt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,cs.jsx)(Un.Handle,b({type:e,position:t,className:D("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},Fe=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=yt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Un.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(x=>x.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(x=>x.source===e).length>=2;if(t==="START_EVENT"){let g=d();return f.filter(m=>{if(m.source!==e)return!1;let E=g.find(y=>y.id===m.target);return(E==null?void 0:E.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,cs.jsx)(Un.Handle,b({type:n,position:r,className:D("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},a))};var di=require("@xyflow/react"),Lc=require("lodash");var kc=require("react/jsx-runtime"),en=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=yt(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=(0,di.useReactFlow)(),{isMultipleSelection:l}=U(),c=({width:u,height:p})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let g=[...a()],x=!f.parentId,m=x?f.id:f.parentId,E=g.filter(v=>v.type==="LANE"&&v.parentId===m);if(!E.length)return;let y=(0,Lc.orderBy)(E,["position.y"]),h=0;y.forEach((v,T)=>{var C,L;let _=T===y.length-1,I=(L=(C=v.measured)==null?void 0:C.height)!=null?L:0;g=g.map(A=>{if(A.id===v.id){let R=x?u-Te.HEADER_WIDTH:u,S=N(b({},A),{width:R,measured:N(b({},A.measured),{width:R}),position:N(b({},A.position),{y:h})});return _&&x&&(S.height=p-h),S}return A}),h+=I}),g=g.map(v=>{if(v.id===m){let T=x?u:u+Te.HEADER_WIDTH;return N(b({},v),{width:T,height:x?p:h,measured:{width:T,height:x?p:h}})}return v}),s(g)};return(0,kc.jsx)(di.NodeResizer,b({nodeId:e,handleClassName:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,p)=>c(p)},o))};var fi=require("@xyflow/react"),Nt=require("@produto-lecom/lecom-ui"),_o=require("react");var Dc=require("zustand"),tn=(0,Dc.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var ui=require("react"),Rc=(e,t=!1)=>{let[o,n]=(0,ui.useState)({width:0,height:0});return(0,ui.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var $t=require("@xyflow/react"),Oc=require("react"),Ym=120,Um=12,Vc=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,$t.useReactFlow)(),{instanceId:i}=U();return(0,Oc.useMemo)(()=>{var f,g;if(!t)return{position:$t.Position.Right,align:"start"};let a=n(e);if(!a)return{position:$t.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(g=document.getElementById(`modeler-${i}`))==null?void 0:g.clientWidth;if(!d)return{position:$t.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||Ym;return{position:l+c+u+Um>d?$t.Position.Left:$t.Position.Right}},[i,e,t,o,n,r])};var pi=require("@xyflow/react"),le=require("@produto-lecom/lecom-ui"),Hc=require("lucide-react");var ge=require("react/jsx-runtime"),Gc=({nodeId:e})=>{let{t}=(0,le.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,pi.useReactFlow)(),i=(0,pi.useNodesData)(e),s=n().filter(f=>f.source===e).some(f=>{let g=r(f.target);return(g==null?void 0:g.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return(0,ge.jsxs)(le.DropdownMenu,{children:[(0,ge.jsxs)(le.Tooltip,{children:[(0,ge.jsx)(le.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)(le.DropdownMenuTrigger,{asChild:!0,children:(0,ge.jsx)(le.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,ge.jsx)(Hc.WrenchIcon,{})})})}),(0,ge.jsx)(le.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,ge.jsxs)(le.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,ge.jsxs)(le.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,ge.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,ge.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(gr).map(([u,p])=>{let f=u==="LOOP"&&(s||l),x=(()=>{if(u==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess")})();return(0,ge.jsxs)(le.Tooltip,{children:[(0,ge.jsx)(le.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)(le.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:D({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:(0,ge.jsx)(p.icon,{className:"stroke-inherit"})})}),x&&(0,ge.jsx)(le.TooltipContent,{color:"black",children:x})]},u)})})]}),(0,ge.jsx)(le.DropdownMenuGroup,{children:(0,ge.jsxs)(le.Tooltip,{children:[(0,ge.jsx)(le.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)("div",{className:D({"cursor-not-allowed":s}),children:(0,ge.jsxs)(le.DropdownMenuItem,{className:D({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[(0,ge.jsx)(mr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,ge.jsx)(le.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var xe=require("react/jsx-runtime"),bo={START_EVENT:{type:"START_EVENT",icon:xn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:So,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:xn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:dr,label:"bpmn.annotation.variant.default"}},$m={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Lo,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Do,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Mo,label:"bpmn.gateway.variant.complex"}},Xe=({nodeId:e,nodeType:t,nodeVariant:o,isChild:n,isVisible:r})=>{let i=(0,_o.useRef)(null),a=(0,_o.useRef)(null),{t:s}=(0,Nt.useTranslation)(),{setDraggableNode:l}=tn(),{getEdges:c,getNodes:d}=(0,fi.useReactFlow)(),{setIsDragging:u,mode:p}=U(),{dimensions:f}=Rc(i,r),{position:g}=Vc(e,r,f),[x,m]=(0,_o.useState)(void 0),E=d(),y=c(),h=o==="SUBPROCESS",v=(0,_o.useCallback)((w,P)=>{u(!1),l({type:P.type,variant:P.variant,attribute:P.attribute,icon:P.icon}),P.icon&&m((0,xe.jsx)(P.icon,{})),w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("sourceId",e),a.current&&w.dataTransfer.setDragImage(a.current,10,10),setTimeout(()=>{u(!0)},100)},[e,l,u]),T=[{component:(0,xe.jsx)(ti,{elementId:e})}],_=()=>{if(p==="view")return[];let w=!y.some(P=>{var F;return P.source===e&&((F=E.find(X=>X.id===P.target))==null?void 0:F.type)!=="ANNOTATION"});return[{component:(0,xe.jsx)(Yo,{nodeId:e,disabled:!w,tooltipMessage:w?void 0:s("editor.toolbar.start_event_limit_reached")})},bo.TASK,bo.ANNOTATION,...T]},I=()=>p==="view"?[{component:(0,xe.jsx)(Ut,{elementId:e})}]:[{component:(0,xe.jsx)(Ut,{elementId:e})},...h?[]:[{component:(0,xe.jsx)(Gc,{nodeId:e})}],{component:(0,xe.jsx)(Yo,{nodeId:e})},bo.TASK,...Object.values($m),...T],C=()=>p==="view"?[{component:(0,xe.jsx)(Ut,{elementId:e})}]:[{component:(0,xe.jsx)(Ut,{elementId:e})},{component:(0,xe.jsx)(Yo,{nodeId:e})},bo.TASK,bo.ANNOTATION,...T],L=()=>p==="view"?[]:[{component:(0,xe.jsx)(Yo,{nodeId:e})},bo.ANNOTATION,...T],A=()=>p==="view"?[]:[...n?[]:[bo.ANNOTATION],...T],R=()=>p==="view"?[]:[{component:(0,xe.jsx)(Yo,{nodeId:e})},...T],S=()=>p==="view"?[]:[...T],V=(w=>{switch(w){case"START_EVENT":return _();case"TASK":return I();case"GATEWAY":return C();case"END_EVENT":return L();case"LANE":return A();case"ANNOTATION":return R();case"UNSUPPORTED":return S();default:return[]}})(t);if(!(V.length===0||p==="readonly"))return(0,xe.jsxs)(fi.NodeToolbar,{position:g,align:"start",className:"-top-8",isVisible:r,children:[(0,xe.jsx)("div",{ref:i,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:V.map((w,P)=>{if(w.component)return(0,xe.jsx)("div",{children:w.component},P);let F={sourceNodeType:t,targetNodeType:w.type,sourceNodeId:e,nodes:E,edges:y},X=$l(F),q={gateway_limit_reached:s("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:s("editor.toolbar.start_event_limit_reached"),start_event_already_exists:s("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:s("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:s("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:s("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:s("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:s("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:s("editor.toolbar.task_limit_reached")},M=X.shouldDisable&&X.reason?q[X.reason]||s(w.label):s(w.label)||"";return(0,xe.jsxs)(Nt.Tooltip,{children:[(0,xe.jsx)(Nt.TooltipTrigger,{asChild:!0,children:(0,xe.jsx)(Nt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!X.shouldDisable,disabled:X.shouldDisable,className:X.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:X.shouldDisable?void 0:O=>v(O,w),children:w.icon&&(0,xe.jsx)(w.icon,{size:16})})}),(0,xe.jsx)(Nt.TooltipContent,{color:"black",children:M})]},P)})}),(0,xe.jsx)("div",{ref:a,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:x})]})};var Xt=require("react/jsx-runtime"),Bc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,To.useReactFlow)(),{inProgress:i,fromNode:a}=(0,To.useConnection)(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=U(),u=i&&(a==null?void 0:a.id)!==e,p=g=>{r(e,{label:g})},f=!l&&!c&&!d;return(0,Xt.jsxs)("div",{className:D("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"text-blue-500 hover:text-blue-600 shadow-md":o,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[(0,Xt.jsx)(Ge,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p}),(0,Xt.jsx)(Xe,{nodeId:e,nodeType:"ANNOTATION",isVisible:!n&&o&&f}),s==="edit"&&(0,Xt.jsx)(en,{minWidth:ci.MIN_WIDTH,minHeight:ci.MIN_HEIGHT,isVisible:!n&&o}),!i&&(0,Xt.jsx)(ie,{type:"source",position:To.Position.Right}),(!i||u)&&(0,Xt.jsx)(ie,{type:"target",position:To.Position.Left,className:D({"annotation-handle":u})})]})};var Qe=require("@xyflow/react"),zc=require("react");var Ce=require("react/jsx-runtime"),Fc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Qe.useReactFlow)(),{inProgress:i,fromNode:a}=(0,Qe.useConnection)(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=U(),[u,p]=(0,zc.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!d,g=y=>{r(e,{label:y})},x=()=>{p(!0)},m=()=>{p(!1)},E=!s&&!l&&!c;return(0,Ce.jsxs)("div",{className:"relative",onDoubleClick:x,children:[(0,Ce.jsx)(So,{className:D("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Ce.jsx)("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ce.jsx)(Ge,{value:t.label,isEditing:u,onBlur:m,onChange:g})}),(0,Ce.jsx)(Xe,{nodeId:e,nodeType:"END_EVENT",isVisible:!n&&o&&E}),(!i||f)&&(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)(ie,{type:"target",position:Qe.Position.Left,id:"left",className:D({"event-handle":f})}),(0,Ce.jsx)(ie,{type:"target",position:Qe.Position.Right,id:"right",className:D({"event-handle":f})}),(0,Ce.jsx)(ie,{type:"target",position:Qe.Position.Top,id:"top",className:D({"event-handle":f})}),(0,Ce.jsx)(ie,{type:"target",position:Qe.Position.Bottom,id:"bottom",className:D({"event-handle":f})})]}),!i&&(0,Ce.jsxs)(Ce.Fragment,{children:[(0,Ce.jsx)(ie,{type:"source",position:Qe.Position.Left,id:"left"}),(0,Ce.jsx)(ie,{type:"source",position:Qe.Position.Right,id:"right"}),(0,Ce.jsx)(ie,{type:"source",position:Qe.Position.Top,id:"top"}),(0,Ce.jsx)(ie,{type:"source",position:Qe.Position.Bottom,id:"bottom"})]})]})};var je=require("@xyflow/react"),mi=require("react");var Se=require("react/jsx-runtime"),Wc=({id:e,data:t,selected:o,dragging:n})=>{let r=Hi[t.variant].icon,{updateNodeData:i}=(0,je.useReactFlow)(),{inProgress:a,fromNode:s}=(0,je.useConnection)(),{isConnecting:l,isDragging:c,isMultipleSelection:d,reconnectingEdgeId:u}=U(),[p,f]=(0,mi.useState)(!1),g=a&&(s==null?void 0:s.id)!==e||!!u,x=(0,mi.useCallback)(h=>{i(e,{label:h})},[e,i]),m=()=>{f(!0)},E=()=>{f(!1)},y=!l&&!c&&!d;return(0,Se.jsxs)("div",{className:"relative",onDoubleClick:m,children:[(0,Se.jsx)(r,{className:D("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Se.jsx)("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Se.jsx)(Ge,{value:t.label,isEditing:p,onBlur:E,onChange:x})}),(0,Se.jsx)(Xe,{nodeId:e,nodeType:"GATEWAY",isVisible:!n&&o&&y}),(!a||g)&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(ie,{type:"target",position:je.Position.Left,id:"left",className:D({"gateway-handle":g})}),(0,Se.jsx)(ie,{type:"target",position:je.Position.Right,id:"right",className:D({"gateway-handle":g})}),(0,Se.jsx)(ie,{type:"target",position:je.Position.Top,id:"top",className:D({"gateway-handle":g})}),(0,Se.jsx)(ie,{type:"target",position:je.Position.Bottom,id:"bottom",className:D({"gateway-handle":g})})]}),!a&&(0,Se.jsxs)(Se.Fragment,{children:[(0,Se.jsx)(Fe,{type:"source",position:je.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Se.jsx)(Fe,{type:"source",position:je.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Se.jsx)(Fe,{type:"source",position:je.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Se.jsx)(Fe,{type:"source",position:je.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var Yc=require("@xyflow/react"),mt=require("@produto-lecom/lecom-ui"),Xm=require("lucide-react");var Uc=require("react/jsx-runtime");var et=require("@xyflow/react"),$c=require("react");var Me=require("react/jsx-runtime"),Xc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,et.useReactFlow)(),{inProgress:i,fromNode:a}=(0,et.useConnection)(),{isConnecting:s,isDragging:l,isMultipleSelection:c,reconnectingEdgeId:d}=U(),[u,p]=(0,$c.useState)(!1),f=i&&(a==null?void 0:a.id)!==e||!!d,g=y=>{r(e,{label:y})},x=()=>{p(!0)},m=()=>{p(!1)},E=!s&&!l&&!c;return(0,Me.jsxs)("div",{className:"relative",onDoubleClick:x,children:[(0,Me.jsx)(fr,{className:D("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Me.jsx)("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Me.jsx)(Ge,{value:t.label,isEditing:u,onBlur:m,onChange:g})}),(0,Me.jsx)(Xe,{nodeId:e,nodeType:"START_EVENT",isVisible:!n&&o&&E}),(!i||f)&&(0,Me.jsxs)(Me.Fragment,{children:[(0,Me.jsx)(ie,{type:"target",position:et.Position.Left,id:"left",className:D({"event-handle":f})}),(0,Me.jsx)(ie,{type:"target",position:et.Position.Right,id:"right",className:D({"event-handle":f})}),(0,Me.jsx)(ie,{type:"target",position:et.Position.Top,id:"top",className:D({"event-handle":f})}),(0,Me.jsx)(ie,{type:"target",position:et.Position.Bottom,id:"bottom",className:D({"event-handle":f})})]}),!i&&(0,Me.jsxs)(Me.Fragment,{children:[(0,Me.jsx)(Fe,{type:"source",position:et.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Me.jsx)(Fe,{type:"source",position:et.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Me.jsx)(Fe,{type:"source",position:et.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Me.jsx)(Fe,{type:"source",position:et.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var tt=require("@xyflow/react"),nn=require("@produto-lecom/lecom-ui"),qn=require("react");var $n=60,gi=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=$n?i:i.substring(0,$n).trim()},on=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>$n&&(n=n.substring(0,$n).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=$n-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var Xn=require("react/jsx-runtime"),Kc=e=>(0,Xn.jsxs)("svg",N(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Xn.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,Xn.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ds=require("react/jsx-runtime"),qc=e=>(0,ds.jsx)("svg",N(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,ds.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var Kn=require("react/jsx-runtime"),Zc=e=>(0,Kn.jsxs)("svg",N(b({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Kn.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Kn.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ne=require("react/jsx-runtime"),Km={APROVADO:Kc,EM_ANDAMENTO:qc,REJEITADO:Zc},us={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},Jc=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=(0,nn.useTranslation)(),{updateNodeData:i,getNodes:a,setNodes:s}=(0,tt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,tt.useConnection)(),{mode:d,isConnecting:u,isDragging:p,isMultipleSelection:f,onSubprocessValidationClick:g,reconnectingEdgeId:x}=U(),{getTaskStatus:m}=ao(),E=l&&(c==null?void 0:c.id)!==e||!!x,y=(0,qn.useCallback)(P=>{let q=Math.max(Bn.MIN_WIDTH,P.length*7+48);s(M=>M.map(O=>O.id===e?N(b({},O),{width:q,style:N(b({},O.style),{width:q})}):O))},[e,s]),h=(0,qn.useCallback)(P=>{let F=P.trim(),X=t.label||"";if(F===X)return;let q=F,M=a();if(!(F&&F!=="")){q=gi(M,r("bpmn.task.label.prefix")),i(e,{label:q}),y(q),(0,nn.toast)({variant:"warning",content:(0,ne.jsxs)(ne.Fragment,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",(0,ne.jsx)("strong",{children:q})]})});return}let H=on(q,M);H===X||(i(e,{label:H}),y(H),H!==q&&(0,nn.toast)({variant:"warning",content:(0,ne.jsxs)(ne.Fragment,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",(0,ne.jsx)("strong",{children:F})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",(0,ne.jsx)("strong",{children:H})]})}))},[t.label,a,e,r,i,y]),v=(0,qn.useCallback)(P=>{y(P)},[y]),T=(0,qn.useCallback)(()=>{(0,nn.toast)({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r]),_=m(e),I=_?Km[_]:null,C=t.variant?mr[t.variant].icon:null,L=t.attribute?gr[t.attribute].icon:null,A=t.variant==="SUBPROCESS",R=C&&!A,S=L||A,k=()=>t.hasError?us.error:_?us[_]:us.default,V=()=>{g==null||g({id:e,type:"sub_process",label:t.label})},w=!u&&!p&&!f;return(0,ne.jsxs)("div",{className:D("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",k(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[(0,ne.jsx)(Ge,{value:t.label,maxLength:60,className:D("m-1",{"py-6":R||S}),onChange:h,onInput:v,onInvalidFirstCharacter:T}),C&&(0,ne.jsx)("div",{className:D("absolute flex items-center p-1",A?"bottom-0":"top-0 left-0"),children:(0,ne.jsx)(C,{size:16,className:D(t.hasError?"text-red-500":"text-grey-500",A&&"cursor-pointer"),onClick:A?V:void 0})}),L&&(0,ne.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,ne.jsx)("div",{className:D("flex items-center w-16 p-1",A?"justify-between":"justify-center"),children:(0,ne.jsx)(L,{size:16,className:D(t.hasError?"text-red-500":"text-grey-500")})})}),I&&(0,ne.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,ne.jsx)(I,{})}),(0,ne.jsx)(Xe,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant,isVisible:!n&&o&&w}),d==="edit"&&(0,ne.jsx)(en,{minWidth:Bn.MIN_WIDTH,minHeight:Bn.MIN_HEIGHT,isVisible:!n&&o}),(!l||E)&&(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(ie,{type:"target",position:tt.Position.Left,id:"left",className:D({"task-handle":E})}),(0,ne.jsx)(ie,{type:"target",position:tt.Position.Right,id:"right",className:D({"task-handle":E})}),(0,ne.jsx)(ie,{type:"target",position:tt.Position.Top,id:"top",className:D({"task-handle":E})}),(0,ne.jsx)(ie,{type:"target",position:tt.Position.Bottom,id:"bottom",className:D({"task-handle":E})})]}),!l&&(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(Fe,{type:"source",position:tt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,ne.jsx)(Fe,{type:"source",position:tt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,ne.jsx)(Fe,{type:"source",position:tt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,ne.jsx)(Fe,{type:"source",position:tt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var ps=require("@xyflow/react");var Lt=require("react/jsx-runtime"),Qc=({id:e,data:t,selected:o,dragging:n})=>{let{isConnecting:r,isDragging:i,isMultipleSelection:a}=U(),s=!r&&!i&&!a;return(0,Lt.jsxs)(Lt.Fragment,{children:[(0,Lt.jsx)("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,Lt.jsx)(Xe,{nodeId:e,nodeType:"UNSUPPORTED",isVisible:!n&&o&&s}),(0,Lt.jsx)(ie,{type:"source",position:ps.Position.Right}),(0,Lt.jsx)(ie,{type:"target",position:ps.Position.Left})]})};var Ne=require("@xyflow/react"),hi=require("react");var Ee=require("react/jsx-runtime"),$v={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Ne.MarkerType.Arrow},data:{label:""}},jc=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{let{zoom:c}=(0,Ne.useViewport)(),{updateEdgeData:d}=(0,Ne.useReactFlow)(),{isMultipleSelection:u,mode:p,instanceId:f}=U(),g=p!=="edit",[x,m]=(0,hi.useState)(!1),{reconnectingHandle:E,cursorPosition:y,hoveredNodeId:h,reconnectingSide:v,isValidReconnection:T,handleReconnectStart:_}=ri({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:g}),I=(0,Ne.useInternalNode)(t),C=(0,Ne.useInternalNode)(o),{sx:L,sy:A,tx:R,ty:S,sourcePos:k,targetPos:V}=(0,hi.useMemo)(()=>{var Ie,he;if(!I||!C)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Ne.Position.Left,targetPos:Ne.Position.Right};let Y=Wt(I,C),re=s?i:Y.sourcePos,G=l?a:Y.targetPos,$=(_e,De,Re)=>{var fe,We,to,oo,no,ro;let{x:He,y:Pe}=_e.internals.positionAbsolute,pe=(to=(We=(fe=_e.measured)==null?void 0:fe.width)!=null?We:_e.width)!=null?to:0,ee=(ro=(no=(oo=_e.measured)==null?void 0:oo.height)!=null?no:_e.height)!=null?ro:0;switch(De){case Ne.Position.Top:return{x:He+pe*Re,y:Pe};case Ne.Position.Bottom:return{x:He+pe*Re,y:Pe+ee};case Ne.Position.Left:return{x:He,y:Pe+ee*Re};case Ne.Position.Right:return{x:He+pe,y:Pe+ee*Re};default:return{x:He+pe/2,y:Pe+ee/2}}},K=(Ie=n==null?void 0:n.sourceOffset)!=null?Ie:.5,W=(he=n==null?void 0:n.targetOffset)!=null?he:.5,B=I?$(I,re,K).x:Y.sx,J=I?$(I,re,K).y:Y.sy,j=C?$(C,G,W).x:Y.tx,oe=C?$(C,G,W).y:Y.ty;return E==="source"&&y?(B=y.x,J=y.y,v&&(re=v)):E==="target"&&y&&(j=y.x,oe=y.y,v&&(G=v)),{sx:B,sy:J,tx:j,ty:oe,sourcePos:re,targetPos:G}},[I,C,s,l,i,a,E,y,v,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!I||!C)return null;let[w,P,F]=(0,Ne.getSmoothStepPath)({sourceX:L,sourceY:A,targetX:R,targetY:S,sourcePosition:k,targetPosition:V}),X=r||(I==null?void 0:I.selected)||(C==null?void 0:C.selected),q=X?"sequence-edge-marker-highlighted":"sequence-edge-marker",M=x||(n==null?void 0:n.label.trim().length)>0,O=1/c,H=()=>{m(!0)},z=()=>{m(!1)},Z=Y=>{d(e,{label:Y.trim()})};return(0,Ee.jsx)(Ee.Fragment,{children:(0,Ee.jsxs)("g",{className:D("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":X}),onDoubleClick:H,children:[(0,Ee.jsx)(Ne.BaseEdge,{id:e,path:w,markerEnd:`url(#${q})`,strokeDasharray:4,className:D("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||E&&h&&!T,"stroke-green-500":E&&h&&T,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":X&&!(n!=null&&n.hasError)&&!E})}),(0,Ee.jsxs)(Ne.EdgeLabelRenderer,{children:[(0,Ee.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${P}px, ${F}px)`},children:[r&&!u&&(0,Ee.jsx)(Xo,{edgeId:e,edgeType:"MESSAGE_EDGE",style:{transform:`scale(${O})`}}),M&&(0,Ee.jsx)(Ge,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:x,onBlur:z,onChange:Z})]}),r&&!u&&!g&&(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${A}px)`},children:(0,Ee.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="source"?.6:.3,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!E||E!=="source","cursor-not-allowed":E==="source"&&h&&!T,"cursor-grabbing":E==="source"&&(!h||T)}),onMouseDown:Y=>_("source",Y.nativeEvent)})]})}),(0,Ee.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${R}px, ${S}px)`},children:(0,Ee.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:E==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:E==="target"?.6:.3,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:D("pointer-events-auto",{"cursor-move":!E||E!=="target","cursor-not-allowed":E==="target"&&h&&!T,"cursor-grabbing":E==="target"&&(!h||T)}),onMouseDown:Y=>_("target",Y.nativeEvent)})]})})]})]})]})})};var ed=require("@xyflow/react"),Zn=require("react/jsx-runtime"),td=({toX:e,toY:t,fromNode:o})=>{if(!o)return null;let n={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:t}}},{sx:r,sy:i,tx:a,ty:s}=Wt(o,n),[l]=(0,ed.getStraightPath)({sourceX:r,sourceY:i,targetX:a||e,targetY:s||t});return(0,Zn.jsxs)("g",{children:[(0,Zn.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:l}),(0,Zn.jsx)("circle",{cx:a||e,cy:s||t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};var yi=require("@xyflow/react"),od=require("lodash"),Jn=require("react");var ot=require("react/jsx-runtime"),nd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=(0,yi.useReactFlow)(),{mode:s,isConnecting:l,isDragging:c,isMultipleSelection:d}=U(),[u,p]=(0,Jn.useState)(!1),f=a(),g=!r,x=(0,Jn.useMemo)(()=>(0,od.orderBy)([...f.filter(_=>_.parentId===e&&_.type==="LANE")],"position.y","asc"),[f,e]),m=g?li.MIN_WIDTH:Te.MIN_WIDTH,E=(0,Jn.useMemo)(()=>{if(g&&x.length>1){let _=[...x];return _.pop(),_.reduce((C,L)=>{var A,R;return C+((R=(A=L.measured)==null?void 0:A.height)!=null?R:0)},0)+Te.MIN_HEIGHT}return Te.MIN_HEIGHT},[g,x]),y=_=>{i(e,{label:_})},h=()=>{p(!0)},v=()=>{p(!1)},T=!l&&!c&&!d;return(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)("div",{className:D("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[(0,ot.jsx)("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onDoubleClick:h,children:(0,ot.jsx)("div",{className:D("relative flex-1",{"[writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180":!u}),children:(0,ot.jsx)(Ge,{value:t.label,className:"w-full h-full self-auto",contentClassName:D({"whitespace-nowrap":u}),isEditing:u,onBlur:v,onChange:y})})}),(0,ot.jsx)("div",{className:"flex-1"})]}),(0,ot.jsx)(Xe,{nodeId:e,nodeType:"LANE",isChild:!g,isVisible:!n&&o&&T}),s==="edit"&&(0,ot.jsx)(en,{nodeId:e,minWidth:m,minHeight:E,isVisible:!n&&o}),g&&(0,ot.jsx)(ie,{type:"source",position:yi.Position.Right})]})};var rd={START_EVENT:Xc,END_EVENT:Fc,TASK:Jc,GATEWAY:Wc,ANNOTATION:Bc,LANE:nd,UNSUPPORTED:Qc},id={SEQUENCE_EDGE:sc,MESSAGE_EDGE:jc,ANNOTATION_EDGE:tc},sd="#fafafa",ad="#bebebe",ld=1,cd=10,dd="bottom-left",ud=.2,pd=5,rn=.5,sn=.4,an=1,fd={x:0,y:0,zoom:.75},qm=1,Zm=2,md=[qm,Zm];var gd=require("@xyflow/react");var ct=()=>{let{getEdges:e,getNodes:t}=(0,gd.useReactFlow)(),{lastElementId:o}=U(),n=()=>{let i=t(),a=e(),s=Sc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var ln=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=(0,hd.useReactFlow)(),{getLastId:i}=ct(),{setLastElementId:a}=U(),s=(0,fs.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await Pc(c);o(d),n(u),a(p),r({padding:rn,minZoom:sn,maxZoom:an})},[o,n,a,r]),l=(0,fs.useCallback)((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return Mc(u,p,f)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};var ms=require("react"),Jm=500,xi=()=>{let{isInitialized:e,onElementChanges:t}=U(),{exportToMxGraph:o}=ln(),n=(0,yd.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},Jm),r=(0,ms.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,ms.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var xd=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=(0,Ei.useReactFlow)(),{emitElementChanges:r}=xi(),i=(0,vt.useRef)(null),{getNextId:a}=ct(),s=(0,vt.useCallback)(g=>{var h;let x=t(g.source),m=t(g.target);if(!x||!m)return!1;let E={sourceNodeId:x.id,targetNodeId:m.id,sourceNodeType:x.type,targetNodeType:m.type,nodes:n(),edges:o(),reconnectingEdgeId:(h=i.current)!=null?h:void 0};return os(E).isValid},[t,o,n]),l=(0,vt.useCallback)(g=>{let x=a(),m=t(g.source),E=t(g.target),y=(E==null?void 0:E.type)==="ANNOTATION"||(m==null?void 0:m.type)==="ANNOTATION"?Ko:ft,h=N(b(b({},g),y),{id:String(x)});e(v=>v.concat(h)),r()},[t,a,e,r]),c=(0,vt.useCallback)((g,x)=>{i.current=x.id},[]),d=(0,vt.useCallback)(()=>{i.current=null},[]),u=(0,vt.useCallback)((g,x)=>{let m=t(x.source),E=t(x.target);if(!m||!E){i.current=null;return}let y={sourceNodeId:m.id,targetNodeId:E.id,sourceNodeType:m.type,targetNodeType:E.type,nodes:n(),edges:o(),reconnectingEdgeId:g.id};if(!os(y).isValid){i.current=null;return}e(v=>(0,Ei.reconnectEdge)(g,x,v).map(_=>_.id===g.id?N(b({},_),{data:N(b({},_.data),{points:void 0})}):_)),i.current=null,r()},[t,n,o,e,r]),p=(0,vt.useCallback)(g=>{i.current=g},[]),f=(0,vt.useCallback)(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};var Id=require("@xyflow/react"),_i=require("@produto-lecom/lecom-ui"),gt=require("react");var Qn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),No=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Kt=(e=[])=>e.filter(t=>t.type==="TASK")||[],Ed=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),bd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),bi=(e=[])=>e.filter(t=>t.type==="GATEWAY"),_d=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),nt=(e,t=[])=>t.filter(o=>o.source===e),jn=(e,t=[])=>t.filter(o=>o.target===e),Td=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},Nd=(e,t)=>{let o=nt(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},vd=e=>e?/[^\s]/.test(e.trim()):!1,de=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:[]}},wt=(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)}},wd=(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 er=[{id:"start_event_not_found",validate:e=>{let t=Qn(e.nodes);return de({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=No(e.nodes);return de({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Qn(e.nodes),o=t.length===1;if(t.length===0)return de({isValid:!0});if(!o)return de({isValid:!1,nodeIds:t.map(i=>i.id)});let n=nt(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return de({isValid:!1,nodeIds:[...new Set(i)]})}return de({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Kt(e.nodes),o=wt(t,n=>nt(n.id,e.edges).length<=2);return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Kt(e.nodes),o=wt(t,n=>!!n.label&&n.label.trim()!=="");return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Kt(e.nodes),n=wt(o,r=>!r.label||r.label.length<=60);return de({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Kt(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return de({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=bi(e.nodes),o=[],n=[];for(let r of t){let i=nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Qn(e.nodes),...No(e.nodes)],o=[],n=[];for(let r of t){let i=nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=No(e.nodes),o=[],n=[];for(let r of t){let i=jn(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=nt(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return de({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=_d(e.nodes),o=wt(t,r=>nt(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>nt(r,e.edges).map(i=>i.id));return de({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Kt(e.nodes),o=wt(t,n=>!n.label||vd(n.label));return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return de({isValid:!0});let t=No(e.nodes)[0];if(!t)return de({isValid:!0});let o=jn(t.id,e.edges);if(!o.length)return de({isValid:!0});let r=Kt(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=wt(r,l=>!Td(l.id,e));return de({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Kt(e.nodes),o=No(e.nodes)[0];if(!o)return de({isValid:!0});let n=t.filter(l=>{let c=jn(l.id,e.edges),d=nt(l.id,e.edges),u=c.some(f=>{var g;return((g=e.nodes.find(x=>x.id===f.source))==null?void 0:g.type)==="START_EVENT"}),p=d.some(f=>{var g;return((g=e.nodes.find(x=>x.id===f.target))==null?void 0:g.type)==="END_EVENT"});return u&&p}),r=jn(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return de(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=bi(e.nodes),o=[],n=[];for(let r of t){let i=nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=bi(e.nodes),o=wt(t,n=>nt(n.id,e.edges).length>=1);return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Qn(e.nodes),...No(e.nodes)],o=[],n=[];for(let r of t){let i=nt(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return de({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Ed(e.nodes),o=wt(t,n=>!Nd(n.id,e));return de({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=bd(e.nodes),o=wt(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return de({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Ad=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of er){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 vo=require("react/jsx-runtime"),Cd=()=>{let{t:e}=(0,_i.useTranslation)(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=(0,Id.useReactFlow)(),[i,a]=(0,gt.useState)(!1),s=(0,gt.useRef)(!1),l=(0,gt.useRef)(!1),c=(0,gt.useCallback)(g=>{let x=wd(g.nodes,g.edges),m=Ad(x),E=m.errors.map(y=>N(b({},y),{message:e(`validation.errors.${y.id}`)}));return i||a(!0),{isValid:m.isValid,errors:E}},[i,e]),d=(0,gt.useCallback)((g,x=!0)=>{if(x&&g&&(0,_i.toast)({variant:g.isValid?"success":"error",duration:5e3,title:g.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,vo.jsxs)("div",{className:"flex flex-col gap-1",children:[!g.isValid&&(0,vo.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,vo.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:g.isValid?(0,vo.jsx)("li",{children:e("validation.success.message")}):g.errors.map(A=>(0,vo.jsx)("li",{className:"text-xs",children:A.message},A.id))})]})}),!g)return;s.current=!0,l.current=!0;let m=[],E=[];g.errors.forEach(A=>{A.nodeIds&&A.nodeIds.length>0&&A.nodeIds.forEach(R=>m.push(R)),A.edgeIds&&A.edgeIds.length>0&&A.edgeIds.forEach(R=>E.push(R))});let y=[...new Set(m)];t(A=>A.map(R=>N(b({},R),{data:N(b({},R.data),{hasError:!1})}))),o(A=>A.map(R=>N(b({},R),{data:N(b({},R.data),{hasError:!1})})));let h=n(),v=r(),T=new Set(y),_=new Set;g.errors.forEach(A=>{var k,V;let R=er.find(w=>w.id===A.id);(R==null?void 0:R.highlightRelatedEdges)!==!1&&((k=A.edgeIds)==null||k.forEach(w=>_.add(w)),(V=A.nodeIds)==null||V.forEach(w=>{v.forEach(P=>{(P.source===w||P.target===w)&&_.add(P.id)})}))});let I=new Set,C=new Set,L=new Set;h.forEach(A=>{A.type==="START_EVENT"?I.add(A.id):A.type==="END_EVENT"&&C.add(A.id)}),v.forEach(A=>{I.has(A.source)&&L.add(A.target),C.has(A.target)&&L.add(A.source)}),L.forEach(A=>{var R,S;if(T.has(A)){let k=(R=g.errors.find(w=>{var P;return(P=w.nodeIds)==null?void 0:P.includes(A)}))==null?void 0:R.id;((S=er.find(w=>w.id===k))==null?void 0:S.highlightRelatedEdges)!==!1&&v.forEach(w=>{w.source===A&&C.has(w.target)&&(T.add(w.target),_.add(w.id)),w.target===A&&I.has(w.source)&&(T.add(w.source),_.add(w.id))})}}),T.size>0&&t(A=>A.map(R=>N(b({},R),{data:N(b({},R.data),{hasError:T.has(R.id)})}))),_.size>0&&o(A=>A.map(R=>N(b({},R),{data:N(b({},R.data),{hasError:_.has(R.id)})}))),setTimeout(()=>{s.current=!1},0)},[e,r,n,o,t]),u=(0,gt.useCallback)(()=>{a(!1),l.current=!1,t(g=>g.map(x=>N(b({},x),{data:N(b({},x.data),{hasError:!1})}))),o(g=>g.map(x=>N(b({},x),{data:N(b({},x.data),{hasError:!1})})))},[o,t]),p=(0,gt.useCallback)(()=>{l.current&&(s.current=!0,l.current=!1,t(g=>g.map(x=>N(b({},x),{data:N(b({},x.data),{hasError:!1})}))),o(g=>g.map(x=>N(b({},x),{data:N(b({},x.data),{hasError:!1})}))),setTimeout(()=>{s.current=!1},0))},[o,t]),f=(0,gt.useCallback)(()=>s.current,[]);return{validateDiagram:c,handleValidationComplete:d,clearValidation:u,dismissValidationPanel:p,isAutoValidationEnabled:i,getIsClearingValidation:f}};var Pd=require("@xyflow/react"),Ld=require("@produto-lecom/lecom-ui"),kd=require("react");var Qm=15,Sd="bpmn:selection",jm=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Md=e=>{if(!jm(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},Dd=({offset:e=Qm}={})=>{let{t}=(0,Ld.useTranslation)(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=(0,Pd.useReactFlow)(),{getNextId:a}=ct();(0,kd.useEffect)(()=>{let s=c=>{var m,E;if(!Md(c))return;let d=o(),u=r(),p=d.filter(y=>y.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(y=>p.some(h=>h.id===y.source)&&p.some(h=>h.id===y.target)),x=JSON.stringify({nodes:p,edges:f});(m=c.clipboardData)==null||m.setData(Sd,x),(E=c.clipboardData)==null||E.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var h,v;if(!Md(c))return;let d=(h=c.clipboardData)==null?void 0:h.getData(Sd);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(T){return}if(!((v=u.nodes)!=null&&v.length))return;let p=new Map,f=o(),g=[],x=u.nodes.filter(T=>Ft(T.type,f));if(x.length===0)return;let m=a(),E=x.map(T=>{var C;let _=String(m++);p.set(T.id,_);let I=N(b({},T),{id:_,selected:!0,position:{x:T.position.x+e,y:T.position.y+e}});if(T.type==="TASK"){let L=(C=T.data)==null?void 0:C.label,A=on(L||t("bpmn.task.label.prefix"),[...f,...g]);I.data=N(b({},T.data),{label:A})}return g.push(I),I}),y=u.edges.map(T=>N(b({},T),{id:String(m++),selected:!0,source:p.get(T.source)||T.source,target:p.get(T.target)||T.target}));n(T=>[...T.map(_=>N(b({},_),{selected:!1})),...E]),i(T=>[...T.map(_=>N(b({},_),{selected:!1})),...y])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,a,e,t])};var Ti=require("@xyflow/react");var Rd=require("@produto-lecom/lecom-ui"),Od=require("react");var Vd=({nodes:e,setNodes:t,setEdges:o})=>{let n=(0,Ti.useStoreApi)(),{draggableNode:r,setDraggableNode:i}=tn(),{t:a}=(0,Rd.useTranslation)(),{getInternalNode:s,getNodes:l,screenToFlowPosition:c}=(0,Ti.useReactFlow)(),{getNextId:d}=ct(),{setIsDragging:u}=U(),{rebuildIndex:p,forceRebuildIndex:f}=Xr(),[g,x]=(0,Od.useState)(null),m=(S,k=!1)=>{let V=k?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(w=>w.map(P=>N(b({},P),{className:P.id===S?V:""})))},E=()=>{let{nodeLookup:S}=n.getState();return Array.from(S.values())},y=S=>{let k=s(S.id),V=E();if(S.type==="LANE"){if(jo({parentId:S.id,nodes:e,includeTypes:["LANE"]})){m();return}let M=V.filter(z=>z.id!==S.id&&z.type==="LANE"&&!z.parentId),O=zn(k,M);if(!O){m();return}if(jo({parentId:O.id,nodes:e,excludeTypes:["LANE"]})){m(O.id,!0);return}m(O.id);return}let P=V.filter(q=>q.id!==S.id&&q.type==="LANE"),F=zn(k,P);if(!F){m();return}if(jo({parentId:F.id,nodes:e,includeTypes:["LANE"]})){m();return}m(F.id)},h=S=>S.map(k=>N(b({},k),{className:void 0})),v=S=>S.some(V=>V.dragging)?S.map(V=>V.dragging?N(b({},V),{dragging:!1}):V):S,T=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},_=(S,k)=>{S.preventDefault(),y(k)},I=(S,k,V)=>{var q,M;let w=[...V];if(S.parentId===k.id)return w=wc(S,k,w),w=Fn(w),h(w);if(S.type==="LANE"){if(jo({parentId:k.id,nodes:w,excludeTypes:["LANE"]})){let Y=Ze(k),re=50,G=50;return w.map($=>{var K,W;return $.id===S.id?N(b({},$),{position:{x:(K=g==null?void 0:g.x)!=null?K:Y.x+re,y:(W=g==null?void 0:g.y)!=null?W:Y.y2+G}}):$})}let z=w.filter(Y=>Y.parentId===k.id).reduce((Y,re)=>{var G,$;return Y+(($=(G=re.measured)==null?void 0:G.height)!=null?$:0)},0),Z={x:Te.HEADER_WIDTH,y:z};return w=w.map(Y=>Y.id===S.id?N(b({},Y),{parentId:k.id,position:Z,className:void 0}):N(b({},Y),{className:void 0})),w=Wn(k.id,w),w}if(jo({parentId:k.id,nodes:w,includeTypes:["LANE"]})){let O;if(S.parentId){let H=s(S.parentId),{x:z,y:Z}=Pt(H);O={x:z+((q=S.position.x)!=null?q:0),y:Z+((M=S.position.y)!=null?M:0)}}return w=w.map(H=>H.id===S.id?N(b({},H),{position:O!=null?O:H.position,parentId:void 0,className:void 0}):N(b({},H),{className:void 0})),w}let X=bc(S,k);return w=w.map(O=>{if(O.id===S.id){let H=Ze(S),z=Ze(k);return H.y<z.y&&(X.y=0),H.x<z.x+Te.HEADER_WIDTH&&(X.x=Te.HEADER_WIDTH),N(b({},O),{parentId:k.id,position:X,className:void 0})}return N(b({},O),{className:void 0})}),w=Fn(w),w},C=S=>{if(S.preventDefault(),!(r!=null&&r.type))return;if(!Ft(r.type,l())){u(!1),i(null);return}let k=c({x:S.clientX,y:S.clientY}),V={width:te[r.type].MIN_WIDTH,height:te[r.type].MIN_HEIGHT},w=d(),P={id:String(w),type:r.type,position:k,measured:V,data:{label:r.type==="TASK"?gi(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},F=N(b({},P),{internals:{positionAbsolute:k}}),X=E(),q=r.type==="LANE",M=X.filter(Z=>q?Z.type==="LANE"&&!Z.parentId:Z.type==="LANE"),O=zn(F,M),H=[...e.map(Z=>N(b({},Z),{selected:!1})),P];O&&(H=I(F,O,H)),H=Eo(H),t(H),f();let z=S.dataTransfer.getData("sourceId");if(z){let Z={id:String(w+1),source:z,target:P.id};r.type==="ANNOTATION"?o(Y=>Y.concat(b(b({},Z),Ko))):o(Y=>Y.concat(b(b({},Z),ft)))}u(!1),i(null)},L=async(S,k,V)=>{let w=[...e];V.forEach(P=>{let F=E(),X=s(P.id),q=P.type==="LANE",M=F.filter(H=>H.id!==P.id&&(q?H.type==="LANE"&&!H.parentId:H.type==="LANE")),O=zn(X,M);if(O){w=I(X,O,w);return}P.parentId&&(w=R(P,w))}),w=v(w),w=Eo(w),w=h(w),t(w),p(w),x(null)},A=(S,k)=>{x({x:k.position.x,y:k.position.y})},R=(S,k)=>{var X,q;let V=s(S.parentId),{x:w,y:P}=Pt(V),F={x:w+((X=S.position.x)!=null?X:0),y:P+((q=S.position.y)!=null?q:0)};return k=k.map(M=>M.id===S.id?N(b({},M),{position:F,parentId:void 0}):M),k=Wn(S.parentId,k),k};return{onDragOver:T,onDrop:C,onNodeDrag:_,onNodeDragStart:A,onNodeDragStop:L}};var Hd=require("@xyflow/react"),Gd=require("@produto-lecom/lecom-ui"),Bd=require("react");var eg=30,tg=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},og=e=>!tg(e.target),zd=({offset:e=eg}={})=>{let{t}=(0,Gd.useTranslation)(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=(0,Hd.useReactFlow)(),{getNextId:a}=ct();(0,Bd.useEffect)(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&og(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(h=>h.selected);if(!u.length)return;let p=new Map,f=[],g=u.filter(h=>Ft(h.type,c));if(g.length===0)return;let x=d.filter(h=>g.some(v=>v.id===h.source)&&g.some(v=>v.id===h.target)),m=a(),E=g.map(h=>{var _;let v=String(m++);p.set(h.id,v);let T=N(b({},h),{id:v,selected:!0,position:{x:h.position.x+e,y:h.position.y+e}});if(h.type==="TASK"){let I=(_=h.data)==null?void 0:_.label,C=on(I||t("bpmn.task.label.prefix"),[...c,...f]);T.data=N(b({},h.data),{label:C})}return f.push(T),T}),y=x.map(h=>N(b({},h),{id:String(m++),selected:!0,source:p.get(h.source)||h.source,target:p.get(h.target)||h.target}));n(h=>[...h.map(v=>N(b({},v),{selected:!1})),...E]),i(h=>[...h.map(v=>N(b({},v),{selected:!1})),...y])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};var $d=require("@xyflow/react");var Wd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Yd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Fd=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},ng=e=>{e=e||"";let t=e.trim().split(`
36
- `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=Fd(i[0],o),s=Fd(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},Ud=e=>{let{components:t,connections:o}=ng(e);return{nodes:t,edges:o}};var Xd=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,$d.useReactFlow)(),{getNextId:n}=ct();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=Ud(a),c=[],d=new Map,u=!1,p=n();for(let[m,E]of Object.entries(s)){let y=String(p++),h=Wd[E.type],v=Yd[E.type];h==="START_EVENT"&&(u=!0),d.set(m,y);let T=te[h].MIN_WIDTH,_=te[h].MIN_HEIGHT;c.push({id:y,type:h,data:{label:E.label||"",variant:v,attribute:""},position:{x:0,y:0},width:T,height:_,measured:{width:T,height:_}})}let f=[];for(let m of l){let E=N(b({},ft),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(E)}if(!u&&c.length>0){let m=String(p++),E={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT,measured:{width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT}};c.unshift(E);let y=c[1];if(y){let h=N(b({},ft),{id:String(p++),source:m,target:y.id});f.unshift(h)}}let{nodes:g,edges:x}=vc(c,f);e(g),t(x),o({padding:rn,minZoom:sn,maxZoom:an})}}};var Ni=require("react"),rg={origin:"*",debug:!1};function Kd(e,t=rg){let{origin:o,debug:n}=t,r=(0,Ni.useCallback)((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return(0,Ni.useEffect)(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var qd=require("@xyflow/react"),gs=require("react");var Zd=()=>{let e=(0,qd.useNodesInitialized)(),{initialDiagram:t,setIsInitialized:o}=U(),{importFromMxGraph:n}=ln();(0,gs.useEffect)(()=>{t&&n(t)},[t,n,o]),(0,gs.useEffect)(()=>{if(!e)return;(async()=>{await ur(),o(!0)})()},[e,o])};var hs=require("react"),Jd=require("@xyflow/react");function Qd(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=ao(),{getEdges:n}=(0,Jd.useReactFlow)(),r=hr(),i=(0,hs.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=(0,hs.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}var eu=require("@xyflow/react"),Ke=require("react"),tu=require("use-debounce");var ig=500,jd=100,ou=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,eu.useReactFlow)(),[i,a]=(0,Ke.useState)({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=s[l],d=l>0,u=l<s.length-1,p=(0,Ke.useCallback)((T,_)=>{n(T[_].nodes),r(T[_].edges)},[n,r]),f=(0,Ke.useCallback)(()=>{if(l>0){let T=l-1;a(_=>N(b({},_),{currentStep:T})),p(s,T)}},[l,s,p]),g=(0,Ke.useCallback)(()=>{if(l<s.length-1){let T=l+1;a(_=>N(b({},_),{currentStep:T})),p(s,T)}},[s,l,p]),x=(0,Ke.useCallback)(T=>{a(_=>{let C=[..._.history.slice(0,_.currentStep+1),T],L=C.length>jd?C.slice(C.length-jd):C;return{history:L,currentStep:L.length-1}})},[]),m=(0,Ke.useCallback)(()=>{let T=t(),_=o(),I=T.map(L=>N(b({},L),{selected:!1,className:"",data:N(b({},L.data),{hasError:!1})})),C=_.map(L=>N(b({},L),{data:N(b({},L.data),{hasError:!1})}));return{nodes:Eo(I),edges:C}},[t,o]),E=(0,tu.useDebouncedCallback)(()=>{let T=m();JSON.stringify(c)!==JSON.stringify(T)&&x(T)},ig),y=(0,Ke.useCallback)(T=>{if(!e)return;if(s.length===0){let C=m();a({history:[C],currentStep:0})}if(T==="forceSave"){E();return}T.some(C=>C.type==="select")||T.some(C=>C.type==="position"&&C.dragging)||E()},[e,E,s.length,m]);(0,Ke.useEffect)(()=>{if(e&&s.length===0){let T=m();a({history:[T],currentStep:0})}},[e,s.length,m]);let h=(0,Ke.useCallback)(T=>{a({history:T||[],currentStep:0})},[]),v=(0,Ke.useCallback)(()=>{a({history:[],currentStep:0})},[]);return(0,Ke.useEffect)(()=>{let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),g()):_.key.toLowerCase()==="z"&&(_.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,g]),{history:s,undo:f,redo:g,canUndo:d,canRedo:u,saveHistory:y,resetHistory:h,clearHistory:v}};var nu=()=>{let[e,t,o]=(0,qt.useNodesState)([]),[n,r,i]=(0,qt.useEdgesState)([]),{getNode:a}=(0,qt.useReactFlow)(),{instanceId:s,isInitialized:l,setIsConnecting:c,setIsMultipleSelection:d,onElementClick:u}=U(),{updateHelperLines:p,HelperLines:f}=Xr(),{undo:g,redo:x,canUndo:m,canRedo:E,saveHistory:y}=ou(l),{onNodeDrag:h,onDrop:v,onDragOver:T,onNodeDragStop:_,onNodeDragStart:I}=Vd({nodes:e,setNodes:t,setEdges:r}),{isValidConnection:C,onConnect:L,onReconnect:A,onReconnectStart:R,onReconnectEnd:S,setReconnectingEdge:k,clearReconnectingEdge:V}=xd({setEdges:r}),{handleValidationComplete:w,clearValidation:P,dismissValidationPanel:F,validateDiagram:X,getIsClearingValidation:q}=Cd(),{importFromLia:M}=Xd(),{handleTasksStatus:O,handleClearTaskStatus:H}=Qd(),{clearPathEdges:z}=ao(),Z=hr(),{emitElementChanges:Y,handleNodeChanges:re,handleEdgeChanges:G}=xi();Dd(),zd(),Zd();let $=(0,kt.useCallback)(()=>{t([]),r([]),z(),setTimeout(()=>{Z()},0)},[t,r,z,Z]);Kd({LIA_CREATE_DIAGRAM:M,CLEAR_DIAGRAM:$,TASKS_STATUS:O,CLEAR_TASKS_STATUS:H});let{selectElements:K,clearSelection:W}=Yt(),{importFromMxGraph:B,exportToMxGraph:J}=ln(),{configureElement:j,getConfigureElement:oe}=ei(),Ie=(0,kt.useCallback)(()=>e.length+n.length,[e,n]);(0,kt.useEffect)(()=>(Tt.set(s,{importFromMxGraph:B,exportToMxGraph:J,selectElements:K,clearSelection:W,configureElement:j,getConfigureElement:oe,getElementsCount:Ie,setReconnectingEdge:k,clearReconnectingEdge:V}),()=>{Tt.delete(s)}),[s,B,J,K,W,j,oe,Ie,k,V]);let he=(0,kt.useCallback)((ee,fe)=>{if(fe.type!=="TASK"&&fe.type!=="GATEWAY")return;let We=oe(fe.id);We&&(u==null||u(We))},[oe,u]),_e=(0,kt.useCallback)((ee,fe)=>{if(fe.type!=="SEQUENCE_EDGE")return;let We=a(fe.source),to=a(fe.target),{isFromStartEvent:oo,isGatewayToGateway:no,isActiviyToAndGateway:ro}=jr(We,to);if(!(!oo&&!no&&!ro))return;let mn=oe(fe.id);mn&&(u==null||u(mn))},[oe,a,u]),De=(0,kt.useCallback)(ee=>{let fe=p(ee,e);o(fe),y(ee),q()||F(),re(ee)},[e,o,y,q,F,p,re]),Re=(0,kt.useCallback)(ee=>{i(ee),y(ee),q()||F(),G(ee)},[i,y,q,F,G]);return(0,qt.useOnSelectionChange)({onChange:({nodes:ee,edges:fe})=>{d(ee.length+fe.length>1)}}),{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:C,onConnect:L,onReconnect:A,onReconnectStart:R,onReconnectEnd:S,onDrop:v,onDragOver:T,onNodeDrag:h,onNodeDragStop:_,onNodeDragStart:I,onNodeClick:he,onEdgeClick:_e,onDropCapture:()=>{y("forceSave"),Y(),F()},onConnectStart:()=>{c(!0)},onConnectEnd:()=>{c(!1),F()},onNodesChange:De,onEdgesChange:Re},ui:{handleCloseValidationPanel:P},controls:{undo:g,redo:x,canUndo:m,canRedo:E},components:{HelperLines:f},actions:{saveHistory:y,selectElements:K,clearSelection:W,exportToMxGraph:J,validateDiagram:X,handleValidationComplete:w,setReconnectingEdge:k,clearReconnectingEdge:V}}};var ys=require("react/jsx-runtime"),xs=({id:e,className:t})=>(0,ys.jsx)("marker",{id:e,className:D("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,ys.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var cn=require("react/jsx-runtime"),ru=()=>(0,cn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,cn.jsxs)("defs",{children:[(0,cn.jsx)(xs,{id:"sequence-edge-marker",className:"text-grey-400"}),(0,cn.jsx)(xs,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var nr=require("@xyflow/react"),ve=require("@produto-lecom/lecom-ui"),Jt=require("lucide-react"),Co=require("react");var At=require("@produto-lecom/lecom-ui");var tr=(h=>(h.START_EVENT="START_EVENT",h.END_EVENT="END_EVENT",h.TASK="TASK",h.SUBPROCESS="SUBPROCESS",h.GATEWAY="GATEWAY",h.LANE="LANE",h.ANNOTATION="ANNOTATION",h.CONNECTION="CONNECTION",h.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",h.ACTIVITY="ACTIVITY",h.PROCESS_INTERFACE="PROCESS_INTERFACE",h.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",h.VARIANT_ACTIVITY="VARIANT_ACTIVITY",h.AUTO_ACTIVITY="AUTO_ACTIVITY",h.DATA_STORE="DATA_STORE",h.DATA_OBJECT="DATA_OBJECT",h.DATA_OUTPUT="DATA_OUTPUT",h.DATA_INPUT="DATA_INPUT",h.MARKER="MARKER",h))(tr||{});var gu=require("@xyflow/react"),dn=require("@produto-lecom/lecom-ui");var iu=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var i;t((i=r.target)==null?void 0:i.result)},n.onerror=r=>{var i;o((i=r.target)==null?void 0:i.error)},n.readAsText(e)});function su({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
37
- `),i=encodeURI(r);vi(i,`${o}.csv`)}var vi=(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)};function au(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var zA={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},lu={script:"SCRIPT",subprocess:"SUBPROCESS"},cu={"marker-loop":"LOOP"},du={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var wo=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},ag=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.START_EVENT.MIN_HEIGHT,{node:wo({cell:e,type:"START_EVENT"}),status:n,originalType:o}},lg=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.END_EVENT.MIN_HEIGHT,{node:wo({cell:e,type:"END_EVENT"}),status:n,originalType:o}},cg=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=lu[n],a=t.get(o)||"",s=cu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Rt(e.mxGeometry._attributes.width||0,te.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Rt(e.mxGeometry._attributes.height||0,te.TASK.MIN_HEIGHT),{node:wo({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},dg=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=du[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=te.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=te.GATEWAY.MIN_HEIGHT,{node:wo({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},ug=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:wo({cell:e,type:"LANE"}),status:"imported",originalType:t}},pg=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Rt(e.mxGeometry._attributes.width||0,te.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Rt(e.mxGeometry._attributes.height||0,te.ANNOTATION.MIN_HEIGHT),{node:wo({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},uu=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=te.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=te.UNSUPPORTED.MIN_HEIGHT,{node:wo({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},pu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return N(b({},ft),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},fu={TASK:cg,GATEWAY:dg,START_EVENT:ag,END_EVENT:lg,LANE:ug,ANNOTATION:pg};var fg=e=>{let t=new Map,o=Object.values(tr),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=fu[l]||uu,{node:d,status:u,originalType:p}=c(s,r);a.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:au(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},mg=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>pu(r,t)),gg=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=fg(t.root.mxCell),i=mg(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},hg=async e=>{let t=await iu(e),o=ai(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},mu=async e=>{try{let t=await hg(e),{nodes:o,edges:n,summary:r}=gg(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var yu=require("react/jsx-runtime"),hu=()=>{let{t:e}=(0,dn.useTranslation)(),{toast:t}=(0,dn.useNotificationToast)(),{setNodes:o,setEdges:n,fitView:r}=(0,gu.useReactFlow)(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,yu.jsx)(dn.Button,{size:"small",variant:"ghost",onClick:()=>su({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await mu(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:rn,minZoom:sn,maxZoom:an}),d.some(p=>p.status==="unsupported")){i(d);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 xu=require("@produto-lecom/lecom-ui"),Eu=require("react");var Ao=require("react/jsx-runtime"),bu=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=yt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Eu.useRef)(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return(0,Ao.jsxs)(Ao.Fragment,{children:[(0,Ao.jsx)(xu.Button,N(b({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),(0,Ao.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var Io=require("react/jsx-runtime"),_u=({disabled:e=!1})=>{let{t}=(0,At.useTranslation)(),{toast:o}=(0,At.useNotificationToast)(),{importFromGovernance:n}=hu(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return(0,Io.jsxs)(At.Tooltip,{children:[(0,Io.jsx)(At.TooltipTrigger,{asChild:!0,children:(0,Io.jsx)(bu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,Io.jsx)(Ls,{})})}),(0,Io.jsx)(At.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var Tu=require("react/jsx-runtime"),Es=({shortcut:e})=>(0,Tu.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 ce=require("@produto-lecom/lecom-ui"),Zt=require("lucide-react"),Au=require("react");var Nu=require("@xyflow/react"),or=require("html-to-image"),wi=require("@produto-lecom/lecom-ui"),vu=require("react");var yg=3,bs="diagram",wu=()=>{let{t:e}=(0,wi.useTranslation)(),{getNodes:t}=(0,Nu.useReactFlow)(),{clearSelection:o}=Yt(),[n,r]=(0,vu.useState)({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:u,width:p,height:f}=Ic(t());return{width:p,height:f,style:{width:`${p}px`,height:`${f}px`,transform:`translate(${-d}px, ${-u}px)`}}},a=async(d,u)=>{r(N(b({},n),{[u]:!0})),await o();try{let p=Ac();if(!p)throw new Error("Flow element not found");let f=i();return await d(p,f)}catch(p){(0,wi.toast)({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(N(b({},n),{[u]:!1}))}};return{exportAsPng:async(d=bs)=>{await a(async(u,p)=>{let f=await(0,or.toPng)(u,N(b({},p),{backgroundColor:"#fcfcfc"}));vi(f,`${d}.png`)},"png")},exportAsHtml:async(d=bs)=>{await a(async(u,p)=>{let f=await(0,or.toSvg)(u,N(b({},p),{backgroundColor:"#fcfcfc"})),g=`
38
+ </mxGraphModel>`,Hc=(e,t)=>{if(!e.length&&!t.length)return Un;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var Qm=e=>{let t=Object.values(zn),o=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return t.includes(a)}),n=e.filter(i=>{var s;let a=(s=i._attributes)==null?void 0:s.style;return["attribute-loop"].includes(a)}),r=[];for(let i of o){let{style:a}=i._attributes,s=vc[a],l=s==null?void 0:s(i,n);if(!l){console.warn(`Node ${a} not supported`);continue}r.push(l)}return r},jm=(e,t)=>{let o=e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}),n=[];for(let r of o){let i=Nc(r),a=t.find(l=>l.id===i.source),s=t.find(l=>l.id===i.target);(a==null?void 0:a.type)==="LANE"||(s==null?void 0:s.type)==="LANE"||n.push(i)}return n},eg=(e,t)=>{let o=[];return e.forEach(n=>{var a,s;let r=(s=(a=Ac)[n.type])==null?void 0:s.call(a,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=Ic(n,t);o.push(l)}}),o},tg=(e,t)=>{let o=[];return e.forEach(n=>{let r=wc(n,t);o.push(r)}),o},Gc=(e=[],t=[],o)=>{let n=eg(e,o),r=tg(t,e),i={mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}};return yc(JSON.stringify(i),{compact:!0,spaces:0})},Bc=async e=>{var s,l,c,d,u;let t=await pi(e),o=((l=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:l.mxCell)||[],n=Number(((u=(d=(c=t==null?void 0:t.mxGraphModel)==null?void 0:c.root)==null?void 0:d._attributes)==null?void 0:u.lastId)||Un),r=Qm(o),i=jm(o,r);return{nodes:bo(Wn(r)),edges:i,lastElementId:n}};var vo=require("@xyflow/react");var $n=require("@xyflow/react");var gs=require("react/jsx-runtime"),se=i=>{var a=i,{type:e,position:t,className:o,nodeType:n}=a,r=bt(a,["type","position","className","nodeType"]);let s=n==="TASK";return(0,gs.jsx)($n.Handle,E({type:e,position:t,className:k("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":s,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":!s},o)},r))},Ye=s=>{var l=s,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,a=bt(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,$n.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(y=>y.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(y=>y.source===e).length>=2;if(t==="START_EVENT"){let h=d();return f.filter(g=>{if(g.source!==e)return!1;let b=h.find(x=>x.id===g.target);return(b==null?void 0:b.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,gs.jsx)($n.Handle,E({type:n,position:r,className:k("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},a))};var gi=require("@xyflow/react"),zc=require("lodash");var Fc=require("react/jsx-runtime"),nn=n=>{var r=n,{nodeId:e,isVisible:t}=r,o=bt(r,["nodeId","isVisible"]);let{getNode:i,getNodes:a,setNodes:s}=(0,gi.useReactFlow)(),{isMultipleSelection:l}=X(),c=({width:u,height:p})=>{if(!e)return;let f=i(e);if((f==null?void 0:f.type)!=="LANE")return;let h=[...a()],y=!f.parentId,g=y?f.id:f.parentId,b=h.filter(N=>N.type==="LANE"&&N.parentId===g);if(!b.length)return;let x=(0,zc.orderBy)(b,["position.y"]),m=0;x.forEach((N,T)=>{var S,P;let _=T===x.length-1,w=(P=(S=N.measured)==null?void 0:S.height)!=null?P:0;h=h.map(I=>{if(I.id===N.id){let O=y?u-Ne.HEADER_WIDTH:u,C=v(E({},I),{width:O,measured:v(E({},I.measured),{width:O}),position:v(E({},I.position),{y:m})});return _&&y&&(C.height=p-m),C}return I}),m+=w}),h=h.map(N=>{if(N.id===g){let T=y?u:u+Ne.HEADER_WIDTH;return v(E({},N),{width:T,height:y?p:m,measured:{width:T,height:y?p:m}})}return N}),s(h)};return(0,Fc.jsx)(gi.NodeResizer,E({nodeId:e,handleClassName:"size-1.5 bg-blue-400 relative before:content-[''] before:absolute before:w-5 before:h-5 before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2 before:cursor-[inherit]",lineClassName:"border-blue-400/90 border-dashed",isVisible:!l&&t,onResizeEnd:(u,p)=>c(p)},o))};var xi=require("@xyflow/react"),At=require("@produto-lecom/lecom-ui"),To=require("react");var Wc=require("zustand"),rn=(0,Wc.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var hi=require("react"),Yc=(e,t=!1)=>{let[o,n]=(0,hi.useState)({width:0,height:0});return(0,hi.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var jt=require("@xyflow/react"),Uc=require("react"),og=120,ng=12,$c=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,jt.useReactFlow)(),{instanceId:i}=X();return(0,Uc.useMemo)(()=>{var f,h;if(!t)return{position:jt.Position.Right,align:"start"};let a=n(e);if(!a)return{position:jt.Position.Right,align:"start"};let s=r(),l=a.position.x*s.zoom+s.x,c=(((f=a.measured)==null?void 0:f.width)||a.width||100)*s.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:jt.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||og;return{position:l+c+u+ng>d?jt.Position.Left:jt.Position.Right}},[i,e,t,o,n,r])};var yi=require("@xyflow/react"),ue=require("@produto-lecom/lecom-ui"),Xc=require("lucide-react");var ye=require("react/jsx-runtime"),Kc=({nodeId:e})=>{let{t}=(0,ue.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,yi.useReactFlow)(),i=(0,yi.useNodesData)(e),s=n().filter(f=>f.source===e).some(f=>{let h=r(f.target);return(h==null?void 0:h.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=u=>{o(e,{variant:(i==null?void 0:i.data.variant)===u?"":u})},d=u=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===u?"":u})};return(0,ye.jsxs)(ue.DropdownMenu,{children:[(0,ye.jsxs)(ue.Tooltip,{children:[(0,ye.jsx)(ue.TooltipTrigger,{asChild:!0,children:(0,ye.jsx)(ue.DropdownMenuTrigger,{asChild:!0,children:(0,ye.jsx)(ue.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,ye.jsx)(Xc.WrenchIcon,{})})})}),(0,ye.jsx)(ue.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,ye.jsxs)(ue.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,ye.jsxs)(ue.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,ye.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,ye.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(Er).map(([u,p])=>{let f=u==="LOOP"&&(s||l),y=(()=>{if(u==="LOOP"&&s)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(u==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(u==="LOOP")return t("editor.task_menu.loop")})();return(0,ye.jsxs)(ue.Tooltip,{children:[(0,ye.jsx)(ue.TooltipTrigger,{asChild:!0,children:(0,ye.jsx)(ue.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:f,className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===u,"opacity-50 cursor-not-allowed":f}),onClick:f?void 0:()=>d(u),children:(0,ye.jsx)(p.icon,{className:"stroke-inherit"})})}),y&&(0,ye.jsx)(ue.TooltipContent,{color:"black",children:y})]},u)})})]}),(0,ye.jsx)(ue.DropdownMenuGroup,{children:(0,ye.jsxs)(ue.Tooltip,{children:[(0,ye.jsx)(ue.TooltipTrigger,{asChild:!0,children:(0,ye.jsx)("div",{className:k({"cursor-not-allowed":s}),children:(0,ye.jsxs)(ue.DropdownMenuItem,{className:k({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":s}),disabled:s,onClick:()=>c("SCRIPT"),children:[(0,ye.jsx)(xr.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),s&&(0,ye.jsx)(ue.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var xe=require("react/jsx-runtime"),_o={START_EVENT:{type:"START_EVENT",icon:bn,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:Po,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:bn,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:mr,label:"bpmn.annotation.variant.default"}},rg={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Ro,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Oo,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:Lo,label:"bpmn.gateway.variant.complex"}},Ke=({nodeId:e,nodeType:t,nodeVariant:o})=>{let n=(0,To.useRef)(null),r=(0,To.useRef)(null),{t:i}=(0,At.useTranslation)(),{setDraggableNode:a}=rn(),{getEdges:s,getNodes:l,getNode:c}=(0,xi.useReactFlow)(),{setIsDragging:d,mode:u,isConnecting:p,isDragging:f,isMultipleSelection:h}=X(),y=c(e),g=!!(y!=null&&y.selected)&&!y.dragging&&!p&&!f&&!h,{dimensions:b}=Yc(n,g),{position:x}=$c(e,g,b),[m,N]=(0,To.useState)(void 0),T=l(),_=s(),w=o==="SUBPROCESS",S=(0,To.useCallback)((F,M)=>{d(!1),a({type:M.type,variant:M.variant,attribute:M.attribute,icon:M.icon}),M.icon&&N((0,xe.jsx)(M.icon,{})),F.dataTransfer.effectAllowed="move",F.dataTransfer.setData("sourceId",e),r.current&&F.dataTransfer.setDragImage(r.current,10,10),setTimeout(()=>{d(!0)},100)},[e,a,d]),P=[{component:(0,xe.jsx)(ii,{elementId:e})}],I=()=>{if(u==="view")return[];let F=!_.some(M=>{var R;return M.source===e&&((R=T.find(D=>D.id===M.target))==null?void 0:R.type)!=="ANNOTATION"});return[{component:(0,xe.jsx)(xo,{nodeId:e,disabled:!F,tooltipMessage:F?void 0:i("editor.toolbar.start_event_limit_reached")})},_o.TASK,_o.ANNOTATION,...P]},O=()=>u==="view"?[{component:(0,xe.jsx)(Jt,{elementId:e})}]:[{component:(0,xe.jsx)(Jt,{elementId:e})},...w?[]:[{component:(0,xe.jsx)(Kc,{nodeId:e})}],{component:(0,xe.jsx)(xo,{nodeId:e})},_o.TASK,...Object.values(rg),...P],C=()=>u==="view"?[{component:(0,xe.jsx)(Jt,{elementId:e})}]:[{component:(0,xe.jsx)(Jt,{elementId:e})},{component:(0,xe.jsx)(xo,{nodeId:e})},_o.TASK,_o.ANNOTATION,...P],L=()=>u==="view"?[]:[{component:(0,xe.jsx)(xo,{nodeId:e})},_o.ANNOTATION,...P],z=()=>u==="view"?[]:[{component:(0,xe.jsx)(xo,{nodeId:e})},_o.ANNOTATION,...P],A=()=>u==="view"?[]:[{component:(0,xe.jsx)(xo,{nodeId:e})},...P],G=()=>u==="view"?[]:[...P],Z=(F=>{switch(F){case"START_EVENT":return I();case"TASK":return O();case"GATEWAY":return C();case"END_EVENT":return L();case"LANE":return z();case"ANNOTATION":return A();case"UNSUPPORTED":return G();default:return[]}})(t);if(!(Z.length===0||u==="readonly"))return(0,xe.jsxs)(xi.NodeToolbar,{position:x,align:"start",className:"-top-8",isVisible:g,children:[(0,xe.jsx)("div",{ref:n,className:"flex items-center gap-1 px-3 py-2 bg-white rounded-sm shadow-md",children:Z.map((F,M)=>{if(F.component)return(0,xe.jsx)("div",{children:F.component},M);let R={sourceNodeType:t,targetNodeType:F.type,sourceNodeId:e,nodes:T,edges:_},D=jl(R),V={gateway_limit_reached:i("editor.toolbar.gateway_limit_reached"),start_event_limit_reached:i("editor.toolbar.start_event_limit_reached"),start_event_already_exists:i("editor.toolbar.start_event_already_exists"),script_to_end_not_allowed:i("editor.toolbar.script_to_end_not_allowed"),loop_to_end_not_allowed:i("editor.toolbar.loop_to_end_not_allowed"),initial_activity_to_end_not_allowed:i("editor.toolbar.initial_activity_to_end_not_allowed"),final_activity_cannot_connect:i("editor.toolbar.final_activity_cannot_connect"),activity_has_outgoing_connections:i("editor.toolbar.activity_has_outgoing_connections"),task_limit_reached:i("editor.toolbar.task_limit_reached")},K=D.shouldDisable&&D.reason?V[D.reason]||i(F.label):i(F.label)||"";return(0,xe.jsxs)(At.Tooltip,{children:[(0,xe.jsx)(At.TooltipTrigger,{asChild:!0,children:(0,xe.jsx)(At.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!D.shouldDisable,disabled:D.shouldDisable,className:D.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:D.shouldDisable?void 0:B=>S(B,F),children:F.icon&&(0,xe.jsx)(F.icon,{size:16})})}),(0,xe.jsx)(At.TooltipContent,{color:"black",children:K})]},M)})}),(0,xe.jsx)("div",{ref:r,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:m})]})};var eo=require("react/jsx-runtime"),qc=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,vo.useReactFlow)(),{inProgress:i,fromNode:a}=(0,vo.useConnection)(),{mode:s}=X(),l=i&&(a==null?void 0:a.id)!==e,c=d=>{r(e,{label:d})};return(0,eo.jsxs)("div",{className:k("relative w-full h-full min-w-44 min-h-16 flex text-grey-400 hover:text-grey-500 bg-white rounded-sm border-l-2 border-current before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-current after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-current hover:shadow-md transition-colors duration-75",{"text-blue-500 hover:text-blue-600 shadow-md":o,"border-red-500 border-l-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)] before:absolute before:top-0 before:left-0 before:w-4 before:border-t-2 before:border-red-500 after:absolute after:bottom-0 after:left-0 after:w-4 after:border-t-2 after:border-red-500":t.hasError}),children:[(0,eo.jsx)(ze,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:c}),(0,eo.jsx)(Ke,{nodeId:e,nodeType:"ANNOTATION"}),s==="edit"&&(0,eo.jsx)(nn,{minWidth:mi.MIN_WIDTH,minHeight:mi.MIN_HEIGHT,isVisible:!n&&o}),!i&&(0,eo.jsx)(se,{type:"source",position:vo.Position.Right}),(!i||l)&&(0,eo.jsx)(se,{type:"target",position:vo.Position.Left,className:k({"annotation-handle":l})})]})};var et=require("@xyflow/react"),Zc=require("react");var Pe=require("react/jsx-runtime"),Jc=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=(0,et.useReactFlow)(),{inProgress:r,fromNode:i}=(0,et.useConnection)(),{reconnectingEdgeId:a}=X(),[s,l]=(0,Zc.useState)(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return(0,Pe.jsxs)("div",{className:"relative",onDoubleClick:u,children:[(0,Pe.jsx)(Po,{className:k("size-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Pe.jsx)("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Pe.jsx)(ze,{value:t.label,isEditing:s,onBlur:p,onChange:d})}),(0,Pe.jsx)(Ke,{nodeId:e,nodeType:"END_EVENT"}),(!r||c)&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)(se,{type:"target",position:et.Position.Left,id:"left",className:k({"event-handle":c})}),(0,Pe.jsx)(se,{type:"target",position:et.Position.Right,id:"right",className:k({"event-handle":c})}),(0,Pe.jsx)(se,{type:"target",position:et.Position.Top,id:"top",className:k({"event-handle":c})}),(0,Pe.jsx)(se,{type:"target",position:et.Position.Bottom,id:"bottom",className:k({"event-handle":c})})]}),!r&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)(se,{type:"source",position:et.Position.Left,id:"left"}),(0,Pe.jsx)(se,{type:"source",position:et.Position.Right,id:"right"}),(0,Pe.jsx)(se,{type:"source",position:et.Position.Top,id:"top"}),(0,Pe.jsx)(se,{type:"source",position:et.Position.Bottom,id:"bottom"})]})]})};var tt=require("@xyflow/react"),Ei=require("react");var Le=require("react/jsx-runtime"),Qc=({id:e,data:t,selected:o})=>{let n=Wi[t.variant].icon,{updateNodeData:r}=(0,tt.useReactFlow)(),{inProgress:i,fromNode:a}=(0,tt.useConnection)(),{reconnectingEdgeId:s}=X(),[l,c]=(0,Ei.useState)(!1),d=i&&(a==null?void 0:a.id)!==e||!!s,u=(0,Ei.useCallback)(h=>{r(e,{label:h})},[e,r]),p=()=>{c(!0)},f=()=>{c(!1)};return(0,Le.jsxs)("div",{className:"relative",onDoubleClick:p,children:[(0,Le.jsx)(n,{className:k("size-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Le.jsx)("div",{className:"absolute top-14 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Le.jsx)(ze,{value:t.label,isEditing:l,onBlur:f,onChange:u})}),(0,Le.jsx)(Ke,{nodeId:e,nodeType:"GATEWAY"}),(!i||d)&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(se,{type:"target",position:tt.Position.Left,id:"left",className:k({"gateway-handle":d})}),(0,Le.jsx)(se,{type:"target",position:tt.Position.Right,id:"right",className:k({"gateway-handle":d})}),(0,Le.jsx)(se,{type:"target",position:tt.Position.Top,id:"top",className:k({"gateway-handle":d})}),(0,Le.jsx)(se,{type:"target",position:tt.Position.Bottom,id:"bottom",className:k({"gateway-handle":d})})]}),!i&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(Ye,{type:"source",position:tt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Le.jsx)(Ye,{type:"source",position:tt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Le.jsx)(Ye,{type:"source",position:tt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Le.jsx)(Ye,{type:"source",position:tt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})};var jc=require("@xyflow/react"),ht=require("@produto-lecom/lecom-ui"),ig=require("lucide-react");var ed=require("react/jsx-runtime");var ot=require("@xyflow/react"),td=require("react");var ke=require("react/jsx-runtime"),od=({id:e,data:t,selected:o})=>{let{updateNodeData:n}=(0,ot.useReactFlow)(),{inProgress:r,fromNode:i}=(0,ot.useConnection)(),{reconnectingEdgeId:a}=X(),[s,l]=(0,td.useState)(!1),c=r&&(i==null?void 0:i.id)!==e||!!a,d=f=>{n(e,{label:f})},u=()=>{l(!0)},p=()=>{l(!1)};return(0,ke.jsxs)("div",{className:"relative",onDoubleClick:u,children:[(0,ke.jsx)(yr,{className:k("size-9 hover:stroke-[#54890b] transition-colors duration-75",{"stroke-blue-500 hover:stroke-blue-600":o,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,ke.jsx)("div",{className:"absolute top-10 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,ke.jsx)(ze,{value:t.label,isEditing:s,onBlur:p,onChange:d})}),(0,ke.jsx)(Ke,{nodeId:e,nodeType:"START_EVENT"}),(!r||c)&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(se,{type:"target",position:ot.Position.Left,id:"left",className:k({"event-handle":c})}),(0,ke.jsx)(se,{type:"target",position:ot.Position.Right,id:"right",className:k({"event-handle":c})}),(0,ke.jsx)(se,{type:"target",position:ot.Position.Top,id:"top",className:k({"event-handle":c})}),(0,ke.jsx)(se,{type:"target",position:ot.Position.Bottom,id:"bottom",className:k({"event-handle":c})})]}),!r&&(0,ke.jsxs)(ke.Fragment,{children:[(0,ke.jsx)(Ye,{type:"source",position:ot.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,ke.jsx)(Ye,{type:"source",position:ot.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,ke.jsx)(Ye,{type:"source",position:ot.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,ke.jsx)(Ye,{type:"source",position:ot.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var nt=require("@xyflow/react"),an=require("@produto-lecom/lecom-ui"),Zn=require("react");var Xn=60,bi=(e,t)=>{var a;let o=[],n=`${t} `;for(let s of e){if(!(s.type==="TASK"))continue;let c=(a=s.data)==null?void 0:a.label;if(c&&c.startsWith(n)){let d=c.substring(n.length);/^\d{1,15}$/.test(d)&&o.push(parseInt(d,10))}}let r=o.length>0?Math.max(...o)+1:1,i=`${t} ${r}`;return i.length<=Xn?i:i.substring(0,Xn).trim()},sn=(e,t)=>{var s;let o=new Set;for(let l of t)l.type==="TASK"&&((s=l.data)!=null&&s.label)&&o.add(l.data.label);let n=e;if(n.length>Xn&&(n=n.substring(0,Xn).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,a=o.size+2;for(;i<=a;){let l=` (${i})`,c=Xn-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var Kn=require("react/jsx-runtime"),nd=e=>(0,Kn.jsxs)("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Kn.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,Kn.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var hs=require("react/jsx-runtime"),rd=e=>(0,hs.jsx)("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,hs.jsx)("path",{d:"M12 2C8.13 2 5 5.13 5 9C5 14.25 12 22 12 22C12 22 19 14.25 19 9C19 5.13 15.87 2 12 2ZM12 11.5C10.62 11.5 9.5 10.38 9.5 9C9.5 7.62 10.62 6.5 12 6.5C13.38 6.5 14.5 7.62 14.5 9C14.5 10.38 13.38 11.5 12 11.5Z",fill:"#38bdf8"})}));var qn=require("react/jsx-runtime"),id=e=>(0,qn.jsxs)("svg",v(E({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,qn.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,qn.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ne=require("react/jsx-runtime"),sg={APROVADO:nd,EM_ANDAMENTO:rd,REJEITADO:id},ys={APROVADO:"border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 border-[3px] border-solid",default:"border-grey-400 border-2 border-solid",error:"border-red-500 border-[3px] shadow-[0_0_5px_rgba(255,0,0,0.5)]"},sd=({id:e,data:t,selected:o,dragging:n})=>{let{t:r}=(0,an.useTranslation)(),{updateNodeData:i,getNodes:a,setNodes:s}=(0,nt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,nt.useConnection)(),{mode:d,onSubprocessValidationClick:u,reconnectingEdgeId:p}=X(),{getTaskStatus:f}=lo(),h=l&&(c==null?void 0:c.id)!==e||!!p,y=(0,Zn.useCallback)(C=>{let Q=C.split(`
39
+ `),Z=Q.reduce((D,V)=>Math.max(D,V.length),0),F=Q.length,M=Math.max(Qo.MIN_WIDTH,Z*7+48),R=Math.max(Qo.MIN_HEIGHT,F*20+24);s(D=>D.map(V=>V.id===e?v(E({},V),{width:M,height:R,style:v(E({},V.style),{width:M,height:R})}):V))},[e,s]),g=(0,Zn.useCallback)(C=>{let L=C.trim(),z=t.label||"";if(L===z)return;let A=L,G=a();if(!(L&&L!=="")){A=bi(G,r("bpmn.task.label.prefix")),i(e,{label:A}),y(A),(0,an.toast)({variant:"warning",content:(0,ne.jsxs)(ne.Fragment,{children:[r("bpmn.task.feedback.label_empty.prefix")," ",(0,ne.jsx)("strong",{children:A})]})});return}let Z=sn(A,G);Z===z||(i(e,{label:Z}),y(Z),Z!==A&&(0,an.toast)({variant:"warning",content:(0,ne.jsxs)(ne.Fragment,{children:[r("bpmn.task.feedback.label_already_exists.prefix")," ",(0,ne.jsx)("strong",{children:L})," ",r("bpmn.task.feedback.label_already_exists.middle")," ",(0,ne.jsx)("strong",{children:Z})]})}))},[t.label,a,e,r,i,y]),b=(0,Zn.useCallback)(C=>{y(C)},[y]),x=(0,Zn.useCallback)(()=>{(0,an.toast)({variant:"error",content:r("bpmn.task.feedback.invalid_first_character")})},[r]),m=f(e),N=m?sg[m]:null,T=t.variant?xr[t.variant].icon:null,_=t.attribute?Er[t.attribute].icon:null,w=t.variant==="SUBPROCESS",S=T&&!w,P=_||w,I=()=>t.hasError?ys.error:m?ys[m]:ys.default,O=()=>{u==null||u({id:e,type:"sub_process",label:t.label})};return(0,ne.jsxs)("div",{className:k("relative w-full h-full min-w-44 min-h-24 flex items-center justify-center bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",I(),{"border-blue-500 hover:border-blue-600 shadow-md":o,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),children:[(0,ne.jsx)(ze,{value:t.label,maxLength:60,className:k("m-1",{"py-6":S||P}),onChange:g,onInput:b,onInvalidFirstCharacter:x}),T&&(0,ne.jsx)("div",{className:k("absolute flex items-center p-1",w?"bottom-0":"top-0 left-0"),children:(0,ne.jsx)(T,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500",w&&"cursor-pointer"),onClick:w?O:void 0})}),_&&(0,ne.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,ne.jsx)("div",{className:k("flex items-center w-16 p-1",w?"justify-between":"justify-center"),children:(0,ne.jsx)(_,{size:16,className:k(t.hasError?"text-red-500":"text-grey-500")})})}),N&&(0,ne.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,ne.jsx)(N,{})}),(0,ne.jsx)(Ke,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),d==="edit"&&(0,ne.jsx)(nn,{minWidth:Qo.MIN_WIDTH,minHeight:Qo.MIN_HEIGHT,isVisible:!n&&o}),(!l||h)&&(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(se,{type:"target",position:nt.Position.Left,id:"left",className:k({"task-handle":h})}),(0,ne.jsx)(se,{type:"target",position:nt.Position.Right,id:"right",className:k({"task-handle":h})}),(0,ne.jsx)(se,{type:"target",position:nt.Position.Top,id:"top",className:k({"task-handle":h})}),(0,ne.jsx)(se,{type:"target",position:nt.Position.Bottom,id:"bottom",className:k({"task-handle":h})})]}),!l&&(0,ne.jsxs)(ne.Fragment,{children:[(0,ne.jsx)(Ye,{type:"source",position:nt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,ne.jsx)(Ye,{type:"source",position:nt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,ne.jsx)(Ye,{type:"source",position:nt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,ne.jsx)(Ye,{type:"source",position:nt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})};var xs=require("@xyflow/react");var Gt=require("react/jsx-runtime"),ad=({id:e,data:t})=>(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)("div",{className:"relative w-full h-full min-w-32 min-h-16 flex items-center justify-center bg-white border-2 border-red-400 rounded-sm overflow-hidden",children:t.label}),(0,Gt.jsx)(Ke,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,Gt.jsx)(se,{type:"source",position:xs.Position.Right}),(0,Gt.jsx)(se,{type:"target",position:xs.Position.Left})]});var we=require("@xyflow/react"),_i=require("react");var Ee=require("react/jsx-runtime"),aw={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:we.MarkerType.Arrow},data:{label:""}},ld=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:a,sourceHandleId:s,targetHandleId:l})=>{var K;let{zoom:c}=(0,we.useViewport)(),{updateEdgeData:d}=(0,we.useReactFlow)(),{isMultipleSelection:u,mode:p,instanceId:f}=X(),h=p!=="edit",[y,g]=(0,_i.useState)(!1),{reconnectingHandle:b,cursorPosition:x,hoveredNodeId:m,reconnectingSide:N,isValidReconnection:T,handleReconnectStart:_}=ci({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:h}),w=(0,we.useInternalNode)(t),S=(0,we.useInternalNode)(o),{sx:P,sy:I,tx:O,ty:C,sourcePos:L,targetPos:z}=(0,_i.useMemo)(()=>{var le,re;if(!w||!S)return{sx:0,sy:0,tx:0,ty:0,sourcePos:we.Position.Left,targetPos:we.Position.Right};let B=$o(w,S),oe=s?i:B.sourcePos,H=l?a:B.targetPos,$=(fe,ve,Me)=>{var Be,Je,Bt,Re,De,Qe;let{x:Se,y:be}=fe.internals.positionAbsolute,ce=(Bt=(Je=(Be=fe.measured)==null?void 0:Be.width)!=null?Je:fe.width)!=null?Bt:0,ie=(Qe=(De=(Re=fe.measured)==null?void 0:Re.height)!=null?De:fe.height)!=null?Qe:0;switch(ve){case we.Position.Top:return{x:Se+ce*Me,y:be};case we.Position.Bottom:return{x:Se+ce*Me,y:be+ie};case we.Position.Left:return{x:Se,y:be+ie*Me};case we.Position.Right:return{x:Se+ce,y:be+ie*Me};default:return{x:Se+ce/2,y:be+ie/2}}},J=(le=n==null?void 0:n.sourceOffset)!=null?le:.5,Y=(re=n==null?void 0:n.targetOffset)!=null?re:.5,U=w?$(w,oe,J).x:B.sx,W=w?$(w,oe,J).y:B.sy,q=S?$(S,H,Y).x:B.tx,j=S?$(S,H,Y).y:B.ty;return b==="source"&&x?(U=x.x,W=x.y,N&&(oe=N)):b==="target"&&x&&(q=x.x,j=x.y,N&&(H=N)),{sx:U,sy:W,tx:q,ty:j,sourcePos:oe,targetPos:H}},[w,S,s,l,i,a,b,x,N,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!w||!S)return null;let[A,G,Q]=(0,we.getSmoothStepPath)({sourceX:P,sourceY:I,targetX:O,targetY:C,sourcePosition:L,targetPosition:z}),Z=r||(w==null?void 0:w.selected)||(S==null?void 0:S.selected),F=Z?"sequence-edge-marker-highlighted":"sequence-edge-marker",M=y||(n==null?void 0:n.label.trim().length)>0,R=()=>{g(!0)},D=()=>{g(!1)},V=B=>{d(e,{label:B.trim()})};return(0,Ee.jsx)(Ee.Fragment,{children:(0,Ee.jsxs)("g",{className:k("text-grey-400 hover:text-grey-500",{"text-blue-500 hover:text-blue-600":Z}),onDoubleClick:R,children:[(0,Ee.jsx)(we.BaseEdge,{id:e,path:A,markerEnd:`url(#${F})`,strokeDasharray:4,className:k("stroke-2 stroke-current transition-colors duration-75",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||b&&m&&!T,"stroke-green-500":b&&m&&T,"stroke-blue-500 hover:stroke-blue-600 drop-shadow-[0_0_3px_rgba(59,130,246,0.5)]":Z&&!(n!=null&&n.hasError)&&!b})}),(0,Ee.jsxs)(we.EdgeLabelRenderer,{children:[(0,Ee.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${G}px, ${Q}px)`},children:[r&&!u&&(0,Ee.jsx)(Zo,{sx:P,sy:I,tx:O,ty:C,hasLabel:!!((K=n==null?void 0:n.label)!=null&&K.trim()),children:(0,Ee.jsx)(qo,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),M&&(0,Ee.jsx)(ze,{value:n==null?void 0:n.label,className:"min-w-8 max-w-56 bg-white rounded-md px-2 py-1 text-xs",isEditing:y,onBlur:D,onChange:V})]}),r&&!u&&!h&&(0,Ee.jsxs)(Ee.Fragment,{children:[(0,Ee.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${P}px, ${I}px)`},children:(0,Ee.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:b==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:b==="source"?.6:.3,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!b||b!=="source","cursor-not-allowed":b==="source"&&m&&!T,"cursor-grabbing":b==="source"&&(!m||T)}),onMouseDown:B=>_("source",B.nativeEvent)})]})}),(0,Ee.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${O}px, ${C}px)`},children:(0,Ee.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:b==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:b==="target"?.6:.3,className:"pointer-events-none"}),(0,Ee.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:k("pointer-events-auto",{"cursor-move":!b||b!=="target","cursor-not-allowed":b==="target"&&m&&!T,"cursor-grabbing":b==="target"&&(!m||T)}),onMouseDown:B=>_("target",B.nativeEvent)})]})})]})]})]})})};var cd=require("@xyflow/react"),Jn=require("react/jsx-runtime"),dd=({toX:e,toY:t,fromX:o,fromY:n,fromNode:r})=>{if(!r)return null;let[i]=(0,cd.getStraightPath)({sourceX:o,sourceY:n,targetX:e,targetY:t});return(0,Jn.jsxs)("g",{children:[(0,Jn.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-400 animated",d:i}),(0,Jn.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-500"})]})};var Ti=require("@xyflow/react"),ud=require("lodash"),Qn=require("react");var rt=require("react/jsx-runtime"),pd=({id:e,data:t,selected:o,dragging:n,parentId:r})=>{let{updateNodeData:i,getNodes:a}=(0,Ti.useReactFlow)(),{mode:s}=X(),[l,c]=(0,Qn.useState)(!1),d=a(),u=!r,p=(0,Qn.useMemo)(()=>(0,ud.orderBy)([...d.filter(x=>x.parentId===e&&x.type==="LANE")],"position.y","asc"),[d,e]),f=u?fi.MIN_WIDTH:Ne.MIN_WIDTH,h=(0,Qn.useMemo)(()=>{if(u&&p.length>1){let x=[...p];return x.pop(),x.reduce((N,T)=>{var _,w;return N+((w=(_=T.measured)==null?void 0:_.height)!=null?w:0)},0)+Ne.MIN_HEIGHT}return Ne.MIN_HEIGHT},[u,p]),y=x=>{i(e,{label:x})},g=()=>{c(!0)},b=()=>{c(!1)};return(0,rt.jsxs)(rt.Fragment,{children:[(0,rt.jsxs)("div",{className:k("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"outline-offset-2 outline-blue-500 shadow-sm":o}),children:[(0,rt.jsx)("div",{className:"flex align-items justify-center w-10 border-r-2 border-grey-400",onDoubleClick:g,children:(0,rt.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,rt.jsx)(ze,{value:t.label,className:"w-full h-full self-auto",contentClassName:k({"whitespace-nowrap":l}),isEditing:l,onBlur:b,onChange:y})})}),(0,rt.jsx)("div",{className:"flex-1"})]}),(0,rt.jsx)(Ke,{nodeId:e,nodeType:"LANE",isChild:!u}),s==="edit"&&(0,rt.jsx)(nn,{nodeId:e,minWidth:f,minHeight:h,isVisible:!n&&o}),(0,rt.jsx)(se,{type:"source",position:Ti.Position.Right})]})};var fd={START_EVENT:od,END_EVENT:Jc,TASK:sd,GATEWAY:Qc,ANNOTATION:qc,LANE:pd,UNSUPPORTED:ad},md={SEQUENCE_EDGE:gc,MESSAGE_EDGE:ld,ANNOTATION_EDGE:dc},gd="#fafafa",hd="#bebebe",yd=1,xd=10,Ed="bottom-left",bd=.2,_d=5,ln=.5,cn=.4,dn=1,Td={x:0,y:0,zoom:.75};var vd=require("@xyflow/react");var pt=()=>{let{getEdges:e,getNodes:t}=(0,vd.useReactFlow)(),{lastElementId:o}=X(),n=()=>{let i=t(),a=e(),s=Hc(i,a);return Math.max(s,o)};return{getLastId:n,getNextId:()=>n()+1}};var un=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n,fitView:r}=(0,Nd.useReactFlow)(),{getLastId:i}=pt(),{setLastElementId:a}=X(),s=(0,Es.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await Bc(c);o(d),n(u),a(p),r({padding:ln,minZoom:cn,maxZoom:dn})},[o,n,a,r]),l=(0,Es.useCallback)((c,d)=>{let u=c||e()||[],p=d||t()||[],f=i();return Gc(u,p,f)},[e,t,i]);return{importFromMxGraph:s,exportToMxGraph:l}};var bs=require("react"),ag=500,vi=()=>{let{isInitialized:e,onElementChanges:t}=X(),{exportToMxGraph:o}=un(),n=(0,wd.useDebouncedCallback)(()=>{if(!e)return;let a=o();t==null||t(a)},ag),r=(0,bs.useCallback)(a=>{a.every(c=>c.type==="select")||a.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,bs.useCallback)(a=>{a.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Ad=({setEdges:e})=>{let{getNode:t,getEdges:o,getNodes:n}=(0,Ni.useReactFlow)(),{emitElementChanges:r}=vi(),i=(0,It.useRef)(null),{getNextId:a}=pt(),s=(0,It.useCallback)(h=>{var m;let y=t(h.source),g=t(h.target);if(!y||!g)return!1;let b={sourceNodeId:y.id,targetNodeId:g.id,sourceNodeType:y.type,targetNodeType:g.type,nodes:n(),edges:o(),reconnectingEdgeId:(m=i.current)!=null?m:void 0};return as(b).isValid},[t,o,n]),l=(0,It.useCallback)(h=>{let y=a(),g=t(h.source),b=t(h.target),x=(b==null?void 0:b.type)==="ANNOTATION"||(g==null?void 0:g.type)==="ANNOTATION"?Jo:gt,m=v(E(E({},h),x),{id:String(y)});e(N=>N.concat(m)),r()},[t,a,e,r]),c=(0,It.useCallback)((h,y)=>{i.current=y.id},[]),d=(0,It.useCallback)(()=>{i.current=null},[]),u=(0,It.useCallback)((h,y)=>{let g=t(y.source),b=t(y.target);if(!g||!b){i.current=null;return}let x={sourceNodeId:g.id,targetNodeId:b.id,sourceNodeType:g.type,targetNodeType:b.type,nodes:n(),edges:o(),reconnectingEdgeId:h.id};if(!as(x).isValid){i.current=null;return}e(N=>(0,Ni.reconnectEdge)(h,y,N).map(_=>_.id===h.id?v(E({},_),{data:v(E({},_.data),{points:void 0})}):_)),i.current=null,r()},[t,n,o,e,r]),p=(0,It.useCallback)(h=>{i.current=h},[]),f=(0,It.useCallback)(()=>{i.current=null},[]);return{isValidConnection:s,onConnect:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnectingEdge:p,clearReconnectingEdge:f}};var Dd=require("@xyflow/react"),Ai=require("@produto-lecom/lecom-ui"),yt=require("react");var jn=(e=[])=>e.filter(t=>t.type==="START_EVENT"),No=(e=[])=>e.filter(t=>t.type==="END_EVENT"),to=(e=[])=>e.filter(t=>t.type==="TASK")||[],Id=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"}),Cd=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SUBPROCESS"}),wi=(e=[])=>e.filter(t=>t.type==="GATEWAY"),Sd=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),it=(e,t=[])=>t.filter(o=>o.source===e),er=(e,t=[])=>t.filter(o=>o.target===e),Md=(e,t)=>{var n,r;let o=(n=t.nodes)==null?void 0:n.find(i=>i.id===e);return((r=o==null?void 0:o.properties)==null?void 0:r.attribute)==="LOOP"},Pd=(e,t)=>{let o=it(e,t.edges||[]);for(let n of o){let r=(t.nodes||[]).find(i=>i.id===n.target);if(r&&r.type==="END_EVENT")return!0}return!1},Ld=e=>e?/[^\s]/.test(e.trim()):!1,me=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:[]}},Ct=(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)}},kd=(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 tr=[{id:"start_event_not_found",validate:e=>{let t=jn(e.nodes);return me({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=No(e.nodes);return me({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=jn(e.nodes),o=t.length===1;if(t.length===0)return me({isValid:!0});if(!o)return me({isValid:!1,nodeIds:t.map(i=>i.id)});let n=it(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(a=>a.id),...n.map(a=>a.target)];return me({isValid:!1,nodeIds:[...new Set(i)]})}return me({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=to(e.nodes),o=Ct(t,n=>it(n.id,e.edges).length<=2);return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=to(e.nodes),o=Ct(t,n=>!!n.label&&n.label.trim()!=="");return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=to(e.nodes),n=Ct(o,r=>!r.label||r.label.length<=60);return me({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=to(e.nodes),o=new Map;for(let r of t){if(!r.label)continue;let i=r.label.trim();i&&(o.has(i)||o.set(i,[]),o.get(i).push(r))}let n=[];for(let[,r]of o.entries())r.length>1&&r.forEach(i=>n.push(i.id));return me({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{let t=wi(e.nodes),o=[],n=[];for(let r of t){let i=it(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...jn(e.nodes),...No(e.nodes)],o=[],n=[];for(let r of t){let i=it(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&(s.type==="START_EVENT"||s.type==="END_EVENT")&&(o.push(r.id,s.id),n.push(a.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=No(e.nodes),o=[],n=[];for(let r of t){let i=er(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.source);if(s&&s.type==="TASK"){let l=it(s.id,e.edges);l.length>1&&(o.push(s.id),l.forEach(c=>n.push(c.id)))}}}return me({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=Sd(e.nodes),o=Ct(t,r=>it(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>it(r,e.edges).map(i=>i.id));return me({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=to(e.nodes),o=Ct(t,n=>!n.label||Ld(n.label));return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var a,s;if(!((a=e==null?void 0:e.nodes)!=null&&a.length)||!((s=e==null?void 0:e.edges)!=null&&s.length))return me({isValid:!0});let t=No(e.nodes)[0];if(!t)return me({isValid:!0});let o=er(t.id,e.edges);if(!o.length)return me({isValid:!0});let r=to(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Ct(r,l=>!Md(l.id,e));return me({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=to(e.nodes),o=No(e.nodes)[0];if(!o)return me({isValid:!0});let n=t.filter(l=>{let c=er(l.id,e.edges),d=it(l.id,e.edges),u=c.some(f=>{var h;return((h=e.nodes.find(y=>y.id===f.source))==null?void 0:h.type)==="START_EVENT"}),p=d.some(f=>{var h;return((h=e.nodes.find(y=>y.id===f.target))==null?void 0:h.type)==="END_EVENT"});return u&&p}),r=er(o.id,e.edges),i=r.length>1,a=r.map(l=>l.source),s={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?a:[]]};return me(s)}},{id:"gateway_flow_to_event",validate:e=>{let t=wi(e.nodes),o=[],n=[];for(let r of t){let i=it(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="END_EVENT"&&(o.push(r.id,s.id),n.push(a.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=wi(e.nodes),o=Ct(t,n=>it(n.id,e.edges).length>=1);return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...jn(e.nodes),...No(e.nodes)],o=[],n=[];for(let r of t){let i=it(r.id,e.edges);for(let a of i){let s=e.nodes.find(l=>l.id===a.target);s&&s.type==="GATEWAY"&&(o.push(r.id,s.id),n.push(a.id))}}return me({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Id(e.nodes),o=Ct(t,n=>!Pd(n.id,e));return me({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"subprocess_referenced_not_configured",validate:e=>{let t=Cd(e.nodes),o=Ct(t,n=>{var r,i;return((r=n.properties)==null?void 0:r.subprocessRef)!==void 0&&((i=n.properties)==null?void 0:i.subprocessRef)!==""});return me({isValid:o.isValid,nodeIds:o.invalidIds})}}];var Rd=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of tr){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 wo=require("react/jsx-runtime"),Od=()=>{let{t:e}=(0,Ai.useTranslation)(),{setNodes:t,setEdges:o,getNodes:n,getEdges:r}=(0,Dd.useReactFlow)(),[i,a]=(0,yt.useState)(!1),s=(0,yt.useRef)(!1),l=(0,yt.useRef)(!1),c=(0,yt.useCallback)(h=>{let y=kd(h.nodes,h.edges),g=Rd(y),b=g.errors.map(x=>v(E({},x),{message:e(`validation.errors.${x.id}`)}));return i||a(!0),{isValid:g.isValid,errors:b}},[i,e]),d=(0,yt.useCallback)((h,y=!0)=>{if(y&&h&&(0,Ai.toast)({variant:h.isValid?"success":"error",duration:5e3,title:h.isValid?e("validation.success.title"):e("validation.errors.title"),content:(0,wo.jsxs)("div",{className:"flex flex-col gap-1",children:[!h.isValid&&(0,wo.jsx)("span",{className:"body-small-500",children:e("validation.errors.subtitle")}),(0,wo.jsx)("ul",{className:"list-disc list-inside max-h-40 overflow-y-auto",children:h.isValid?(0,wo.jsx)("li",{children:e("validation.success.message")}):h.errors.map(I=>(0,wo.jsx)("li",{className:"text-xs",children:I.message},I.id))})]})}),!h)return;s.current=!0,l.current=!0;let g=[],b=[];h.errors.forEach(I=>{I.nodeIds&&I.nodeIds.length>0&&I.nodeIds.forEach(O=>g.push(O)),I.edgeIds&&I.edgeIds.length>0&&I.edgeIds.forEach(O=>b.push(O))});let x=[...new Set(g)];t(I=>I.map(O=>v(E({},O),{data:v(E({},O.data),{hasError:!1})}))),o(I=>I.map(O=>v(E({},O),{data:v(E({},O.data),{hasError:!1})})));let m=n(),N=r(),T=new Set(x),_=new Set;h.errors.forEach(I=>{var L,z;let O=tr.find(A=>A.id===I.id);(O==null?void 0:O.highlightRelatedEdges)!==!1&&((L=I.edgeIds)==null||L.forEach(A=>_.add(A)),(z=I.nodeIds)==null||z.forEach(A=>{N.forEach(G=>{(G.source===A||G.target===A)&&_.add(G.id)})}))});let w=new Set,S=new Set,P=new Set;m.forEach(I=>{I.type==="START_EVENT"?w.add(I.id):I.type==="END_EVENT"&&S.add(I.id)}),N.forEach(I=>{w.has(I.source)&&P.add(I.target),S.has(I.target)&&P.add(I.source)}),P.forEach(I=>{var O,C;if(T.has(I)){let L=(O=h.errors.find(A=>{var G;return(G=A.nodeIds)==null?void 0:G.includes(I)}))==null?void 0:O.id;((C=tr.find(A=>A.id===L))==null?void 0:C.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===I&&S.has(A.target)&&(T.add(A.target),_.add(A.id)),A.target===I&&w.has(A.source)&&(T.add(A.source),_.add(A.id))})}}),T.size>0&&t(I=>I.map(O=>v(E({},O),{data:v(E({},O.data),{hasError:T.has(O.id)})}))),_.size>0&&o(I=>I.map(O=>v(E({},O),{data:v(E({},O.data),{hasError:_.has(O.id)})}))),setTimeout(()=>{s.current=!1},0)},[e,r,n,o,t]),u=(0,yt.useCallback)(()=>{a(!1),l.current=!1,t(h=>h.map(y=>v(E({},y),{data:v(E({},y.data),{hasError:!1})}))),o(h=>h.map(y=>v(E({},y),{data:v(E({},y.data),{hasError:!1})})))},[o,t]),p=(0,yt.useCallback)(()=>{l.current&&(s.current=!0,l.current=!1,t(h=>h.map(y=>v(E({},y),{data:v(E({},y.data),{hasError:!1})}))),o(h=>h.map(y=>v(E({},y),{data:v(E({},y.data),{hasError:!1})}))),setTimeout(()=>{s.current=!1},0))},[o,t]),f=(0,yt.useCallback)(()=>s.current,[]);return{validateDiagram:c,handleValidationComplete:d,clearValidation:u,dismissValidationPanel:p,isAutoValidationEnabled:i,getIsClearingValidation:f}};var Gd=require("@xyflow/react"),Bd=require("@produto-lecom/lecom-ui"),zd=require("react");var lg=15,Vd="bpmn:selection",cg=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},Hd=e=>{if(!cg(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},Fd=({offset:e=lg}={})=>{let{t}=(0,Bd.useTranslation)(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=(0,Gd.useReactFlow)(),{getNextId:a}=pt();(0,zd.useEffect)(()=>{let s=c=>{var g,b;if(!Hd(c))return;let d=o(),u=r(),p=d.filter(x=>x.selected);if(!p.length)return;c.preventDefault(),c.stopPropagation();let f=u.filter(x=>p.some(m=>m.id===x.source)&&p.some(m=>m.id===x.target)),y=JSON.stringify({nodes:p,edges:f});(g=c.clipboardData)==null||g.setData(Vd,y),(b=c.clipboardData)==null||b.setData("text/plain",`BPMN Selection: ${p.length} nodes`)},l=c=>{var m,N;if(!Hd(c))return;let d=(m=c.clipboardData)==null?void 0:m.getData(Vd);if(!d)return;c.preventDefault(),c.stopPropagation();let u;try{u=JSON.parse(d)}catch(T){return}if(!((N=u.nodes)!=null&&N.length))return;let p=new Map,f=o(),h=[],y=u.nodes.filter(T=>qt(T.type,f));if(y.length===0)return;let g=a(),b=y.map(T=>{var S;let _=String(g++);p.set(T.id,_);let w=v(E({},T),{id:_,selected:!0,position:{x:T.position.x+e,y:T.position.y+e}});if(T.type==="TASK"){let P=(S=T.data)==null?void 0:S.label,I=sn(P||t("bpmn.task.label.prefix"),[...f,...h]);w.data=v(E({},T.data),{label:I})}return h.push(w),w}),x=u.edges.map(T=>v(E({},T),{id:String(g++),selected:!0,source:p.get(T.source)||T.source,target:p.get(T.target)||T.target}));n(T=>[...T.map(_=>v(E({},_),{selected:!1})),...b]),i(T=>[...T.map(_=>v(E({},_),{selected:!1})),...x])};return document.addEventListener("copy",s,!0),document.addEventListener("paste",l,!0),()=>{document.removeEventListener("copy",s,!0),document.removeEventListener("paste",l,!0)}},[o,n,r,i,a,e,t])};var Ii=require("@xyflow/react");var Wd=require("@produto-lecom/lecom-ui"),Yd=require("react");var Ud=({nodes:e,setNodes:t,setEdges:o})=>{let n=(0,Ii.useStoreApi)(),{draggableNode:r,setDraggableNode:i}=rn(),{t:a}=(0,Wd.useTranslation)(),{getInternalNode:s,getNodes:l,screenToFlowPosition:c}=(0,Ii.useReactFlow)(),{getNextId:d}=pt(),{setIsDragging:u}=X(),{rebuildIndex:p,forceRebuildIndex:f}=Jr(),[h,y]=(0,Yd.useState)(null),g=(C,L=!1)=>{let z=L?"[&>div]:bg-red-50 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-red-500":"[&>div]:bg-green-50/75 [&>div]:outline [&>div]:outline-[3px] [&>div]:outline-green-500";t(A=>A.map(G=>v(E({},G),{className:G.id===C?z:""})))},b=()=>{let{nodeLookup:C}=n.getState();return Array.from(C.values())},x=C=>{let L=s(C.id),z=b();if(C.type==="LANE"){if(on({parentId:C.id,nodes:e,includeTypes:["LANE"]})){g();return}let M=z.filter(V=>V.id!==C.id&&V.type==="LANE"&&!V.parentId),R=Fn(L,M);if(!R){g();return}if(on({parentId:R.id,nodes:e,excludeTypes:["LANE"]})){g(R.id,!0);return}g(R.id);return}let G=z.filter(F=>F.id!==C.id&&F.type==="LANE"),Q=Fn(L,G);if(!Q){g();return}if(on({parentId:Q.id,nodes:e,includeTypes:["LANE"]})){g();return}g(Q.id)},m=C=>C.map(L=>v(E({},L),{className:void 0})),N=C=>C.some(z=>z.dragging)?C.map(z=>z.dragging?v(E({},z),{dragging:!1}):z):C,T=C=>{C.preventDefault(),C.dataTransfer.dropEffect="move"},_=(C,L)=>{C.preventDefault(),x(L)},w=(C,L,z)=>{var F,M;let A=[...z];if(C.parentId===L.id)return A=Rc(C,L,A),A=Wn(A),m(A);if(C.type==="LANE"){if(on({parentId:L.id,nodes:A,excludeTypes:["LANE"]})){let B=Ot(L),oe=50,H=50;return A.map($=>{var J,Y;return $.id===C.id?v(E({},$),{position:{x:(J=h==null?void 0:h.x)!=null?J:B.x+oe,y:(Y=h==null?void 0:h.y)!=null?Y:B.y2+H}}):$})}let V=A.filter(B=>B.parentId===L.id).reduce((B,oe)=>{var H,$;return B+(($=(H=oe.measured)==null?void 0:H.height)!=null?$:0)},0),K={x:Ne.HEADER_WIDTH,y:V};return A=A.map(B=>B.id===C.id?v(E({},B),{parentId:L.id,position:K,className:void 0}):v(E({},B),{className:void 0})),A=Yn(L.id,A),A}if(on({parentId:L.id,nodes:A,includeTypes:["LANE"]})){let R;if(C.parentId){let D=s(C.parentId),{x:V,y:K}=Ht(D);R={x:V+((F=C.position.x)!=null?F:0),y:K+((M=C.position.y)!=null?M:0)}}return A=A.map(D=>D.id===C.id?v(E({},D),{position:R!=null?R:D.position,parentId:void 0,className:void 0}):v(E({},D),{className:void 0})),A}let Z=Sc(C,L);return A=A.map(R=>{if(R.id===C.id){let D=Ot(C),V=Ot(L);return D.y<V.y&&(Z.y=0),D.x<V.x+Ne.HEADER_WIDTH&&(Z.x=Ne.HEADER_WIDTH),v(E({},R),{parentId:L.id,position:Z,className:void 0})}return v(E({},R),{className:void 0})}),A=Wn(A),A},S=C=>{if(C.preventDefault(),!(r!=null&&r.type))return;if(!qt(r.type,l())){u(!1),i(null);return}let L=c({x:C.clientX,y:C.clientY}),z={width:te[r.type].MIN_WIDTH,height:te[r.type].MIN_HEIGHT},A=d(),G={id:String(A),type:r.type,position:L,measured:z,data:{label:r.type==="TASK"?bi(e,a("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},Q=v(E({},G),{internals:{positionAbsolute:L}}),Z=b(),F=r.type==="LANE",M=Z.filter(K=>F?K.type==="LANE"&&!K.parentId:K.type==="LANE"),R=Fn(Q,M),D=[...e.map(K=>v(E({},K),{selected:!1})),G];R&&(D=w(Q,R,D)),D=bo(D),t(D),f();let V=C.dataTransfer.getData("sourceId");if(V){let K={id:String(A+1),source:V,target:G.id};r.type==="ANNOTATION"?o(B=>B.concat(E(E({},K),Jo))):o(B=>B.concat(E(E({},K),gt)))}u(!1),i(null)},P=async(C,L,z)=>{let A=[...e];z.forEach(G=>{let Q=b(),Z=s(G.id),F=G.type==="LANE",M=Q.filter(D=>D.id!==G.id&&(F?D.type==="LANE"&&!D.parentId:D.type==="LANE")),R=Fn(Z,M);if(R){A=w(Z,R,A);return}G.parentId&&(A=O(G,A))}),A=N(A),A=bo(A),A=m(A),t(A),p(A),y(null)},I=(C,L)=>{y({x:L.position.x,y:L.position.y})},O=(C,L)=>{var Z,F;let z=s(C.parentId),{x:A,y:G}=Ht(z),Q={x:A+((Z=C.position.x)!=null?Z:0),y:G+((F=C.position.y)!=null?F:0)};return L=L.map(M=>M.id===C.id?v(E({},M),{position:Q,parentId:void 0}):M),L=Yn(C.parentId,L),L};return{onDragOver:T,onDrop:S,onNodeDrag:_,onNodeDragStart:I,onNodeDragStop:P}};var $d=require("@xyflow/react"),Xd=require("@produto-lecom/lecom-ui"),Kd=require("react");var dg=30,ug=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},pg=e=>!ug(e.target),qd=({offset:e=dg}={})=>{let{t}=(0,Xd.useTranslation)(),{getNodes:o,setNodes:n,getEdges:r,setEdges:i}=(0,$d.useReactFlow)(),{getNextId:a}=pt();(0,Kd.useEffect)(()=>{let s=l=>{if(l.ctrlKey&&l.key.toLowerCase()==="d"&&pg(l)){l.preventDefault(),l.stopPropagation();let c=o(),d=r(),u=c.filter(m=>m.selected);if(!u.length)return;let p=new Map,f=[],h=u.filter(m=>qt(m.type,c));if(h.length===0)return;let y=d.filter(m=>h.some(N=>N.id===m.source)&&h.some(N=>N.id===m.target)),g=a(),b=h.map(m=>{var _;let N=String(g++);p.set(m.id,N);let T=v(E({},m),{id:N,selected:!0,position:{x:m.position.x+e,y:m.position.y+e}});if(m.type==="TASK"){let w=(_=m.data)==null?void 0:_.label,S=sn(w||t("bpmn.task.label.prefix"),[...c,...f]);T.data=v(E({},m.data),{label:S})}return f.push(T),T}),x=y.map(m=>v(E({},m),{id:String(g++),selected:!0,source:p.get(m.source)||m.source,target:p.get(m.target)||m.target}));n(m=>[...m.map(N=>v(E({},N),{selected:!1})),...b]),i(m=>[...m.map(N=>v(E({},N),{selected:!1})),...x])}};return document.addEventListener("keydown",s,!0),()=>{document.removeEventListener("keydown",s,!0)}},[o,n,r,i,a,e,t])};var eu=require("@xyflow/react");var Jd={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY"},Qd={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE"},Zd=(e,t)=>{if(!e){console.warn("Step not found");return}e=e.trim();let o=e.match(/(\<.*?\>)/)||[],n=e.match(/(\[.*?\])/)||[],r=e.match(/(\{.*?\})/)||[],i=e.match(/(--.*|\|.*?\|)/i)||[],a="",s="",l="";if(o.length){switch(o[1]){case"<start>":a="start-event";break;case"<end>":a="end-event";break}e=e.replace(o[1],"")}return n.length&&(a="task",s=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a="gateway-exclusive",s=r[1].replace(/\{|\}/g,""),e=e.replace(r[1],"")),a||(a="task",s=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:a,label:s}),{step:e,type:a,label:s,edgeLabel:l}},fg=e=>{e=e||"";let t=e.trim().split(`
40
+ `),o={},n=[];return t.forEach(r=>{r=r||"";let i=r.trim().split("-->");if(i.length!==2){console.warn("Invalid number of steps");return}let a=Zd(i[0],o),s=Zd(i[1],o);a&&s&&n.push({sourceId:a.step,targetId:s.step,label:a.edgeLabel||s.edgeLabel||""})}),{components:o,connections:n}},jd=e=>{let{components:t,connections:o}=fg(e);return{nodes:t,edges:o}};var tu=()=>{let{setNodes:e,setEdges:t,fitView:o}=(0,eu.useReactFlow)(),{getNextId:n}=pt();return{importFromLia:i=>{let a=typeof i=="string"?i:i.diagramXml||"",{nodes:s,edges:l}=jd(a),c=[],d=new Map,u=!1,p=n();for(let[g,b]of Object.entries(s)){let x=String(p++),m=Jd[b.type],N=Qd[b.type];m==="START_EVENT"&&(u=!0),d.set(g,x);let T=te[m].MIN_WIDTH,_=te[m].MIN_HEIGHT;c.push({id:x,type:m,data:{label:b.label||"",variant:N,attribute:""},position:{x:0,y:0},width:T,height:_,measured:{width:T,height:_}})}let f=[];for(let g of l){let b=v(E({},gt),{id:String(p++),source:d.get(g.sourceId)||g.sourceId,target:d.get(g.targetId)||g.targetId});f.push(b)}if(!u&&c.length>0){let g=String(p++),b={id:g,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT,measured:{width:te.START_EVENT.MIN_WIDTH,height:te.START_EVENT.MIN_HEIGHT}};c.unshift(b);let x=c[1];if(x){let m=v(E({},gt),{id:String(p++),source:g,target:x.id});f.unshift(m)}}let{nodes:h,edges:y}=kc(c,f);e(h),t(y),o({padding:ln,minZoom:cn,maxZoom:dn})}}};var nr=require("react"),ou=require("@xyflow/react");var mg=20,gg=50,or={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},hg=e=>{if(!e||!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase(),o=t==="input"||t==="textarea",n=e.isContentEditable,r=t==="select",i=e.closest('[contenteditable="true"], input, textarea, select')!==null;return o||n||r||i},nu=e=>{let{getNodes:t}=(0,ou.useReactFlow)(),{mode:o,isMoveTool:n}=X(),r=(0,nr.useRef)(0),i=(0,nr.useRef)(new Map);(0,nr.useEffect)(()=>{let a=s=>{if(o!=="edit"||!n||hg(s.target)||!Object.values(or).includes(s.key))return;let u=t().filter(x=>x.selected);if(u.length===0){i.current.clear();return}s.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let h=s.shiftKey?gg:mg,y=0,g=0;switch(s.key){case or.UP:g=-h;break;case or.DOWN:g=h;break;case or.LEFT:y=-h;break;case or.RIGHT:y=h;break}let b=u.map(x=>{let m=i.current.get(x.id);(!f||!m)&&(m={x:x.position.x,y:x.position.y});let N={x:m.x+y,y:m.y+g};return i.current.set(x.id,N),{id:x.id,dragging:!0,type:"position",position:N}});e&&e(b)};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[t,e,o,n])};var Ci=require("react"),yg={origin:"*",debug:!1};function ru(e,t=yg){let{origin:o,debug:n}=t,r=(0,Ci.useCallback)((i,a)=>{let s={event:i,data:[i,{event:i,data:a}]};window.parent.postMessage(s,o||"*")},[o]);return(0,Ci.useEffect)(()=>{let i=a=>{let s=a.data;if(!(s!=null&&s.event)||(s==null?void 0:s.data)===void 0)return;let{event:l,data:c}=s,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",s),console.debug("[postMessage] eventData:",d)),l&&e[l]&&e[l](d)};return window.addEventListener("message",i),()=>window.removeEventListener("message",i)},[e,n]),{sendMessage:r}}var iu=require("@xyflow/react"),_s=require("react");var su=()=>{let e=(0,iu.useNodesInitialized)(),{initialDiagram:t,setIsInitialized:o}=X(),{importFromMxGraph:n}=un();(0,_s.useEffect)(()=>{t&&n(t)},[t,n,o]),(0,_s.useEffect)(()=>{if(!e)return;(async()=>{await gr(),o(!0)})()},[e,o])};var Ts=require("react"),au=require("@xyflow/react");function lu(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=lo(),{getEdges:n}=(0,au.useReactFlow)(),r=br(),i=(0,Ts.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let l=s.activities.map(d=>d.diagramId),c=n();o(c,l),setTimeout(()=>{r()},0)},[e,o,n,r]),a=(0,Ts.useCallback)(()=>{t(),setTimeout(()=>{r()},0)},[t,r]);return{handleTasksStatus:i,handleClearTaskStatus:a}}var du=require("@xyflow/react"),qe=require("react"),uu=require("use-debounce");var xg=500,cu=100,pu=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,du.useReactFlow)(),[i,a]=(0,qe.useState)({history:[],currentStep:0}),{history:s,currentStep:l}=i,c=s[l],d=l>0,u=l<s.length-1,p=(0,qe.useCallback)((T,_)=>{n(T[_].nodes),r(T[_].edges)},[n,r]),f=(0,qe.useCallback)(()=>{if(l>0){let T=l-1;a(_=>v(E({},_),{currentStep:T})),p(s,T)}},[l,s,p]),h=(0,qe.useCallback)(()=>{if(l<s.length-1){let T=l+1;a(_=>v(E({},_),{currentStep:T})),p(s,T)}},[s,l,p]),y=(0,qe.useCallback)(T=>{a(_=>{let S=[..._.history.slice(0,_.currentStep+1),T],P=S.length>cu?S.slice(S.length-cu):S;return{history:P,currentStep:P.length-1}})},[]),g=(0,qe.useCallback)(()=>{let T=t(),_=o(),w=T.map(P=>v(E({},P),{selected:!1,className:"",data:v(E({},P.data),{hasError:!1})})),S=_.map(P=>v(E({},P),{data:v(E({},P.data),{hasError:!1})}));return{nodes:bo(w),edges:S}},[t,o]),b=(0,uu.useDebouncedCallback)(()=>{let T=g();JSON.stringify(c)!==JSON.stringify(T)&&y(T)},xg),x=(0,qe.useCallback)(T=>{if(!e)return;if(s.length===0){let S=g();a({history:[S],currentStep:0})}if(T==="forceSave"){b();return}T.some(S=>S.type==="select")||T.some(S=>S.type==="position"&&S.dragging)||b()},[e,b,s.length,g]);(0,qe.useEffect)(()=>{if(e&&s.length===0){let T=g();a({history:[T],currentStep:0})}},[e,s.length,g]);let m=(0,qe.useCallback)(T=>{a({history:T||[],currentStep:0})},[]),N=(0,qe.useCallback)(()=>{a({history:[],currentStep:0})},[]);return(0,qe.useEffect)(()=>{let T=_=>{(_.ctrlKey||_.metaKey)&&(_.shiftKey&&_.key.toLowerCase()==="z"?(_.preventDefault(),h()):_.key.toLowerCase()==="z"&&(_.preventDefault(),f()))};return document.addEventListener("keydown",T),()=>{document.removeEventListener("keydown",T)}},[f,h]),{history:s,undo:f,redo:h,canUndo:d,canRedo:u,saveHistory:x,resetHistory:m,clearHistory:N}};var fu=()=>{let{t:e}=(0,Si.useTranslation)(),[t,o,n]=(0,St.useNodesState)([]),[r,i,a]=(0,St.useEdgesState)([]),{getNode:s}=(0,St.useReactFlow)(),l=(0,St.useStoreApi)(),{instanceId:c,isInitialized:d,setIsConnecting:u,setIsMultipleSelection:p,onElementClick:f}=X(),{updateHelperLines:h,HelperLines:y}=Jr(),{undo:g,redo:b,canUndo:x,canRedo:m,saveHistory:N}=pu(d),{onNodeDrag:T,onDrop:_,onDragOver:w,onNodeDragStop:S,onNodeDragStart:P}=Ud({nodes:t,setNodes:o,setEdges:i}),{isValidConnection:I,onConnect:O,onReconnect:C,onReconnectStart:L,onReconnectEnd:z,setReconnectingEdge:A,clearReconnectingEdge:G}=Ad({setEdges:i}),{handleValidationComplete:Q,clearValidation:Z,dismissValidationPanel:F,validateDiagram:M,getIsClearingValidation:R}=Od(),{importFromLia:D}=tu(),{handleTasksStatus:V,handleClearTaskStatus:K}=lu(),{clearPathEdges:B}=lo(),{emitElementChanges:oe,handleNodeChanges:H,handleEdgeChanges:$}=vi(),J=br();Fd(),qd(),su();let Y=(0,xt.useCallback)(()=>{o([]),i([]),B(),setTimeout(J,0)},[o,i,B,J]);ru({LIA_CREATE_DIAGRAM:D,CLEAR_DIAGRAM:Y,TASKS_STATUS:V,CLEAR_TASKS_STATUS:K});let{selectElements:U,clearSelection:W}=Zt(),{importFromMxGraph:q,exportToMxGraph:j}=un(),{configureElement:le,getConfigureElement:re}=ri(),fe=(0,xt.useCallback)(()=>t.length+r.length,[t,r]);(0,xt.useEffect)(()=>(wt.set(c,{importFromMxGraph:q,exportToMxGraph:j,selectElements:U,clearSelection:W,configureElement:le,getConfigureElement:re,getElementsCount:fe,setReconnectingEdge:A,clearReconnectingEdge:G}),()=>{wt.delete(c)}),[c,q,j,U,W,le,re,fe,A,G]);let ve=(0,xt.useCallback)((Re,De)=>{if(De.type!=="TASK"&&De.type!=="GATEWAY")return;let Qe=re(De.id);Qe&&(f==null||f(Qe))},[re,f]),Me=(0,xt.useCallback)((Re,De)=>{if(De.type!=="SEQUENCE_EDGE")return;let Qe=s(De.source),Mo=s(De.target),{isFromStartEvent:lr,isGatewayToGateway:Ju,isActiviyToAndGateway:Qu}=ni(Qe,Mo);if(!(!lr&&!Ju&&!Qu))return;let Ss=re(De.id);Ss&&(f==null||f(Ss))},[re,s,f]),Se=(0,xt.useCallback)(Re=>{let De=h(Re,t);n(De),N(Re),R()||F(),H(Re)},[t,n,N,R,F,h,H]),be=(0,xt.useCallback)(Re=>{a(Re),N(Re),R()||F(),$(Re)},[a,N,R,F,$]);nu(Se);let ce=(0,xt.useCallback)(({nodes:Re,edges:De})=>{p(Re.length+De.length>=2)},[p]);(0,St.useOnSelectionChange)({onChange:ce});let ie=(0,xt.useCallback)(async({nodes:Re})=>Re.some(Qe=>Qe.type==="LANE"&&t.some(Mo=>Mo.parentId===Qe.id))?((0,Si.toast)({variant:"error",title:e("validation.errors.title"),content:e("editor.toolbar.delete_pool_lane_error")}),!1):!0,[t,e]);return{nodes:t,setNodes:o,edges:r,setEdges:i,events:{isValidConnection:I,onConnect:O,onReconnect:C,onReconnectStart:L,onReconnectEnd:z,onDrop:_,onDragOver:w,onNodeDrag:T,onNodeDragStop:S,onNodeDragStart:P,onNodeClick:ve,onEdgeClick:Me,onDropCapture:()=>{N("forceSave"),oe(),F()},onConnectStart:()=>{u(!0)},onConnectEnd:()=>{u(!1),F()},onSelectionEnd:()=>l.setState({nodesSelectionActive:!1}),onNodesChange:Se,onEdgesChange:be,onBeforeDelete:ie},ui:{handleCloseValidationPanel:Z},controls:{undo:g,redo:b,canUndo:x,canRedo:m},components:{HelperLines:y},actions:{saveHistory:N,selectElements:U,clearSelection:W,exportToMxGraph:j,validateDiagram:M,handleValidationComplete:Q,setReconnectingEdge:A,clearReconnectingEdge:G}}};var vs=require("react/jsx-runtime"),Ns=({id:e,className:t})=>(0,vs.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,vs.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var pn=require("react/jsx-runtime"),mu=()=>(0,pn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,pn.jsxs)("defs",{children:[(0,pn.jsx)(Ns,{id:"sequence-edge-marker",className:"text-grey-400"}),(0,pn.jsx)(Ns,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var ro=require("@produto-lecom/lecom-ui");var sr=require("@xyflow/react"),Ae=require("@produto-lecom/lecom-ui"),no=require("lucide-react"),So=require("react");var Mt=require("@produto-lecom/lecom-ui");var rr=(m=>(m.START_EVENT="START_EVENT",m.END_EVENT="END_EVENT",m.TASK="TASK",m.SUBPROCESS="SUBPROCESS",m.GATEWAY="GATEWAY",m.LANE="LANE",m.ANNOTATION="ANNOTATION",m.CONNECTION="CONNECTION",m.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",m.ACTIVITY="ACTIVITY",m.PROCESS_INTERFACE="PROCESS_INTERFACE",m.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",m.VARIANT_ACTIVITY="VARIANT_ACTIVITY",m.AUTO_ACTIVITY="AUTO_ACTIVITY",m.DATA_STORE="DATA_STORE",m.DATA_OBJECT="DATA_OBJECT",m.DATA_OUTPUT="DATA_OUTPUT",m.DATA_INPUT="DATA_INPUT",m.MARKER="MARKER",m))(rr||{});var wu=require("@xyflow/react"),fn=require("@produto-lecom/lecom-ui");var gu=async e=>new Promise((t,o)=>{let n=new FileReader;n.onload=r=>{var i;t((i=r.target)==null?void 0:i.result)},n.onerror=r=>{var i;o((i=r.target)==null?void 0:i.error)},n.readAsText(e)});function hu({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(a=>a.join(",")).join(`
41
+ `),i=encodeURI(r);Mi(i,`${o}.csv`)}var Mi=(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)};function yu(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var rI={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},xu={script:"SCRIPT",subprocess:"SUBPROCESS"},Eu={"marker-loop":"LOOP"},bu={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var Ao=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:a,parent:s}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=s==="1"?void 0:s;return{id:r.id,parentId:d,type:t,data:{label:a||"",variant:o,attribute:n},position:{x:Number(i._attributes.x)||0,y:Number(i._attributes.y)||0},width:l,height:c,measured:{width:l,height:c}}},bg=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.START_EVENT.MIN_HEIGHT,{node:Ao({cell:e,type:"START_EVENT"}),status:n,originalType:o}},_g=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=te.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=te.END_EVENT.MIN_HEIGHT,{node:Ao({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Tg=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=xu[n],a=t.get(o)||"",s=Eu[a]||"",l=s==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=Ft(e.mxGeometry._attributes.width||0,te.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=Ft(e.mxGeometry._attributes.height||0,te.TASK.MIN_HEIGHT),{node:Ao({cell:e,type:"TASK",variant:i,attribute:s}),status:c,originalType:r}},vg=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=bu[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=te.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=te.GATEWAY.MIN_HEIGHT,{node:Ao({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Ng=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:Ao({cell:e,type:"LANE"}),status:"imported",originalType:t}},wg=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=Ft(e.mxGeometry._attributes.width||0,te.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=Ft(e.mxGeometry._attributes.height||0,te.ANNOTATION.MIN_HEIGHT),{node:Ao({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},_u=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=te.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=te.UNSUPPORTED.MIN_HEIGHT,{node:Ao({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Tu=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return v(E({},gt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},vu={TASK:Tg,GATEWAY:vg,START_EVENT:bg,END_EVENT:_g,LANE:Ng,ANNOTATION:wg};var Ag=e=>{let t=new Map,o=Object.values(rr),n=[],r=new Map;e.forEach(s=>{var c;let l=(c=s._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(s._attributes.parent,s._attributes.style);return}if(o.includes(l)){n.push(s);return}});let i=[],a=[];for(let s of n){let{type:l}=s._attributes,c=vu[l]||_u,{node:d,status:u,originalType:p}=c(s,r);a.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:yu(d.data.label),status:u})}return{nodes:a,governanceIdToNodeIdMap:t,summary:i}},Ig=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Tu(r,t)),Cg=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Ag(t.root.mxCell),i=Ig(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Sg=async e=>{let t=await gu(e),o=pi(t);if(!o)throw new Error("EMPTY_FILE");let{metadata:n,mxGraphModel:r}=o.modeler||{},i=(n==null?void 0:n.app)&&(n==null?void 0:n.diagramType)&&(n==null?void 0:n.version),a=r==null?void 0:r.root;if(!i||!a)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},Nu=async e=>{try{let t=await Sg(e),{nodes:o,edges:n,summary:r}=Cg(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var Iu=require("react/jsx-runtime"),Au=()=>{let{t:e}=(0,fn.useTranslation)(),{toast:t}=(0,fn.useNotificationToast)(),{setNodes:o,setEdges:n,fitView:r}=(0,wu.useReactFlow)(),i=s=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=s.map(d=>[d.originalType,d.value,e(`adapter.governance.report.status.${d.status.toLowerCase()}`)]);t({variant:"warning",content:e("adapter.governance.success.incompatible_cells"),duration:1e3*60*1,action:(0,Iu.jsx)(fn.Button,{size:"small",variant:"ghost",onClick:()=>hu({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async s=>{try{let{nodes:l,edges:c,summary:d}=await Nu(s);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r({padding:ln,minZoom:cn,maxZoom:dn}),d.some(p=>p.status==="unsupported")){i(d);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 Cu=require("@produto-lecom/lecom-ui"),Su=require("react");var Io=require("react/jsx-runtime"),Mu=s=>{var l=s,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,a=bt(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,Su.useRef)(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return(0,Io.jsxs)(Io.Fragment,{children:[(0,Io.jsx)(Cu.Button,v(E({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},a),{children:e})),(0,Io.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var Co=require("react/jsx-runtime"),Pu=({disabled:e=!1})=>{let{t}=(0,Mt.useTranslation)(),{toast:o}=(0,Mt.useNotificationToast)(),{importFromGovernance:n}=Au(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=a=>{let s=a[0];if(!s){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(s)};return(0,Co.jsxs)(Mt.Tooltip,{children:[(0,Co.jsx)(Mt.TooltipTrigger,{asChild:!0,children:(0,Co.jsx)(Mu,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,Co.jsx)(Gs,{})})}),(0,Co.jsx)(Mt.TooltipContent,{color:"black",children:t("editor.controls.actions.import_governance")})]})};var Lu=require("react/jsx-runtime"),ws=({shortcut:e})=>(0,Lu.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 pe=require("@produto-lecom/lecom-ui"),oo=require("lucide-react"),Ou=require("react");var ku=require("@xyflow/react"),ir=require("html-to-image"),Pi=require("@produto-lecom/lecom-ui"),Ru=require("react");var Mg=3,As="diagram",Du=()=>{let{t:e}=(0,Pi.useTranslation)(),{getNodes:t}=(0,ku.useReactFlow)(),{clearSelection:o}=Zt(),[n,r]=(0,Ru.useState)({png:!1,html:!1,print:!1}),i=()=>{let{x:d,y:u,width:p,height:f}=Oc(t());return{width:p,height:f,style:{width:`${p}px`,height:`${f}px`,transform:`translate(${-d}px, ${-u}px)`}}},a=async(d,u)=>{r(v(E({},n),{[u]:!0})),await o();try{let p=Dc();if(!p)throw new Error("Flow element not found");let f=i();return await d(p,f)}catch(p){(0,Pi.toast)({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{r(v(E({},n),{[u]:!1}))}};return{exportAsPng:async(d=As)=>{await a(async(u,p)=>{let f=await(0,ir.toPng)(u,v(E({},p),{backgroundColor:"#fcfcfc"}));Mi(f,`${d}.png`)},"png")},exportAsHtml:async(d=As)=>{await a(async(u,p)=>{let f=await(0,ir.toSvg)(u,v(E({},p),{backgroundColor:"#fcfcfc"})),h=`
38
42
  <!DOCTYPE html>
39
43
  <html>
40
44
  <head>
@@ -48,7 +52,7 @@
48
52
  <img src="${f}" alt="Diagram" />
49
53
  </body>
50
54
  </html>
51
- `,x=new Blob([g],{type:"text/html"}),m=URL.createObjectURL(x);vi(m,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(m),100)},"html")},printDiagram:async(d=bs)=>{await a(async(u,p)=>{let f=await(0,or.toPng)(u,N(b({},p),{pixelRatio:yg})),g=window.open("","_blank");if(!g)throw new Error("Failed to open print window.");let x=g.document;x.open(),x.write(`
55
+ `,y=new Blob([h],{type:"text/html"}),g=URL.createObjectURL(y);Mi(g,`${d}.html`),setTimeout(()=>URL.revokeObjectURL(g),100)},"html")},printDiagram:async(d=As)=>{await a(async(u,p)=>{let f=await(0,ir.toPng)(u,v(E({},p),{pixelRatio:Mg})),h=window.open("","_blank");if(!h)throw new Error("Failed to open print window.");let y=h.document;y.open(),y.write(`
52
56
  <!DOCTYPE html>
53
57
  <html>
54
58
  <head>
@@ -64,4 +68,4 @@
64
68
  <img src="${f}" alt="Diagram" onload="window.print(); window.close();" />
65
69
  </body>
66
70
  </html>
67
- `),x.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};var ue=require("react/jsx-runtime");function Iu(){let{t:e}=(0,ce.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=wu(),[s,l]=(0,Au.useState)(!1);return(0,ue.jsxs)(ce.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,ue.jsx)(ce.DropdownMenuTrigger,{asChild:!0,children:(0,ue.jsx)("div",{children:(0,ue.jsxs)(ce.Tooltip,{children:[(0,ue.jsx)(ce.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ce.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,ue.jsx)(Zt.FolderOutputIcon,{})})}),!s&&(0,ue.jsx)(ce.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,ue.jsxs)(ce.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,ue.jsxs)(ce.Tooltip,{children:[(0,ue.jsx)(ce.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ce.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,ue.jsx)(Zt.FileImageIcon,{})})}),(0,ue.jsx)(ce.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,ue.jsxs)(ce.Tooltip,{children:[(0,ue.jsx)(ce.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ce.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,ue.jsx)(Zt.FileCodeIcon,{})})}),(0,ue.jsx)(ce.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,ue.jsxs)(ce.Tooltip,{children:[(0,ue.jsx)(ce.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(ce.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,ue.jsx)(Zt.PrinterIcon,{})})}),(0,ue.jsx)(ce.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var se=require("react/jsx-runtime"),Cu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,ve.useTranslation)(),{clearSelection:i}=Yt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:p}=U(),{getNodes:f,getEdges:g}=(0,nr.useReactFlow)(),x=(0,nr.useKeyPress)(["v","V"]),m=(0,nr.useKeyPress)(["h","H"]),E=(0,Co.useCallback)(()=>{i(),p(!0),u(!1)},[i,p,u]),y=(0,Co.useCallback)(()=>{u(!0),p(!1)},[u,p]),h=(0,Co.useCallback)(()=>{let v=f(),T=g(),_=o({nodes:v,edges:T});n(_)},[f,g,o,n]);return(0,Co.useEffect)(()=>{x&&!c&&a==="edit"&&y()},[x,y,c,a]),(0,Co.useEffect)(()=>{m&&!d&&a==="edit"&&E()},[m,E,d,a]),(0,se.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)(ve.Tooltip,{children:[(0,se.jsx)(ve.TooltipTrigger,{asChild:!0,children:(0,se.jsx)(ve.Button,{size:"small",variant:"ghost",color:"grey",className:D(c&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,se.jsx)(Jt.MousePointerIcon,{})})}),(0,se.jsxs)(ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,se.jsx)(Es,{shortcut:"V"})]})]}),(0,se.jsxs)(ve.Tooltip,{children:[(0,se.jsx)(ve.TooltipTrigger,{asChild:!0,children:(0,se.jsx)(ve.Button,{size:"small",variant:"ghost",color:"grey",className:D(d&&"bg-grey-400"),iconButton:!0,onClick:E,children:(0,se.jsx)(Jt.HandIcon,{})})}),(0,se.jsxs)(ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,se.jsx)(Es,{shortcut:"H"})]})]})]}),(0,se.jsx)(Iu,{}),a==="edit"&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsxs)(ve.Tooltip,{children:[(0,se.jsx)(ve.TooltipTrigger,{asChild:!0,children:(0,se.jsx)(ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:h,children:(0,se.jsx)(Jt.ListCheckIcon,{})})}),(0,se.jsx)(ve.TooltipContent,{color:"black",children:r("editor.controls.actions.check")})]}),(0,se.jsx)(_u,{disabled:e.length>0||t.length>0})]}),(0,se.jsxs)(ve.Tooltip,{children:[(0,se.jsx)(ve.TooltipTrigger,{asChild:!0,children:(0,se.jsx)(ve.Button,{size:"small",variant:"ghost",color:"grey",className:D(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:(0,se.jsx)(Jt.MapIcon,{})})}),(0,se.jsx)(ve.TooltipContent,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var qe=require("@produto-lecom/lecom-ui"),Ai=require("lucide-react"),rt=require("react/jsx-runtime"),Su=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,qe.useTranslation)();return(0,rt.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,rt.jsxs)(qe.Tooltip,{children:[(0,rt.jsx)(qe.TooltipTrigger,{asChild:!0,children:(0,rt.jsx)(qe.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,rt.jsx)(Ai.UndoIcon,{})})}),(0,rt.jsx)(qe.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,rt.jsxs)(qe.Tooltip,{children:[(0,rt.jsx)(qe.TooltipTrigger,{asChild:!0,children:(0,rt.jsx)(qe.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,rt.jsx)(Ai.RedoIcon,{})})}),(0,rt.jsx)(qe.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var un=require("@xyflow/react"),we=require("@produto-lecom/lecom-ui"),pn=require("lucide-react");var be=require("react/jsx-runtime"),Mu=()=>{let{t:e}=(0,we.useTranslation)(),t=(0,un.useNodes)(),o=(0,un.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,un.useReactFlow)(),s=t.length===0&&o.length===0;return(0,be.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,be.jsx)(pn.ScanIcon,{})})}),(0,be.jsx)(we.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,be.jsx)(pn.ZoomOut,{})})}),(0,be.jsx)(we.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,be.jsx)(Os,{})})}),(0,be.jsx)(we.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,be.jsx)(pn.ZoomIn,{})})}),(0,be.jsx)(we.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Pu=require("@xyflow/react"),It=require("@produto-lecom/lecom-ui"),Ii=require("react");var ht=require("react/jsx-runtime"),Lu=()=>{let e=(0,Ii.useRef)(null),{t}=(0,It.useTranslation)(),{setDraggableNode:o}=tn(),n=(0,Pu.useNodes)(),{setIsDragging:r}=U(),[i,a]=(0,Ii.useState)(void 0),s=[{type:"START_EVENT",icon:fr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:So,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:xn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:Gs,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Hs,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Vs,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Lo,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Do,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Mo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Rs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:dr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,ht.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,ht.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,ht.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!Ft(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,ht.jsxs)(It.Tooltip,{children:[(0,ht.jsx)(It.TooltipTrigger,{asChild:!0,children:(0,ht.jsx)(It.Button,{className:D("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:(0,ht.jsx)(c.icon,{})},d)}),(0,ht.jsx)(It.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,ht.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var jt=require("@produto-lecom/lecom-ui");var Ve=require("react/jsx-runtime"),_s=(0,Ci.forwardRef)((e,t)=>{let{instanceId:o,mode:n,isMinimapOpen:r,isMoveTool:i,isHandTool:a}=U(),{nodes:s,edges:l,actions:c,events:d,components:u,controls:p}=nu(),{t:f}=(0,jt.useTranslation)();return(0,Ci.useImperativeHandle)(t,()=>({selectElements:c.selectElements,clearSelection:c.clearSelection})),(0,Ve.jsxs)("div",{className:"w-full h-full",children:[n==="edit"&&(0,Ve.jsx)(Lu,{}),(0,Ve.jsx)(ru,{}),(0,Ve.jsxs)(Qt.ReactFlow,N(b({},d),{id:`modeler-${o}`,edges:l,nodes:s,nodeTypes:rd,edgeTypes:id,minZoom:ud,maxZoom:pd,panOnDrag:a||n!=="edit"?!0:md,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:n!=="readonly"&&i,nodesConnectable:n==="edit"&&i,nodesDraggable:n==="edit"&&i,connectionLineComponent:td,selectionMode:Qt.SelectionMode.Partial,multiSelectionKeyCode:"Shift",deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:fd,connectOnClick:!1,connectionRadius:30,proOptions:{hideAttribution:!0},children:[(0,Ve.jsx)(Qt.Background,{gap:cd,size:ld,color:ad,bgColor:sd}),r&&(0,Ve.jsxs)(jt.Tooltip,{children:[(0,Ve.jsx)(jt.TooltipTrigger,{asChild:!0,children:(0,Ve.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ve.jsx)(Qt.MiniMap,{pannable:!0,zoomable:!0,position:dd,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ve.jsx)(jt.TooltipContent,{color:"black",children:f("editor.controls.actions.minimap.label")})]}),(0,Ve.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[n==="edit"&&(0,Ve.jsx)(Su,b({},p)),(0,Ve.jsx)(Cu,{nodes:s,edges:l,validateDiagram:c.validateDiagram,handleValidationComplete:c.handleValidationComplete}),(0,Ve.jsx)(Mu,{})]}),(0,Ve.jsx)(u.HelperLines,{})]}))]})});_s.displayName="Editor";var ku=require("@xyflow/react"),Si=require("react"),Du=require("react/jsx-runtime"),xg=e=>({width:e.width,height:e.height,transform:e.transform}),Ts="rgba(51, 103, 217, 0.4)",Hl=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,ku.useStore)(xg),i=(0,Si.useRef)(null);return(0,Si.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Ts,t&&(s.beginPath(),s.strokeStyle=t.color||Ts,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Ts,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,Du.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var fn=require("@produto-lecom/lecom-ui"),eo=require("react");var rr=require("react/jsx-runtime"),Tt=new Map,Ru=(0,eo.createContext)(null),Mi=()=>{let e=(0,eo.useContext)(Ru);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Ou=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=(0,eo.useState)(e||"pt_BR");(0,eo.useEffect)(()=>{e&&(i(e),fn.i18n.changeLanguage(e))},[e]);let a=g=>{let x=Tt.size;if(x===0)throw new Error("No modeler instances found");if(x===1||!g){let[E]=Tt.values();return E}let m=Tt.get(g);if(!m)throw new Error(`Modeler instance with ID "${g}" not found`);return m},s=(g,x)=>{let m=a(x);return m==null?void 0:m.selectElements(g)},l=async g=>{let x=a(g);return x==null?void 0:x.clearSelection()},c=(g,x)=>{let m=a(x);return m==null?void 0:m.configureElement(g)},d=(g,x)=>{let m=a(x);return m==null?void 0:m.getConfigureElement(g)},u=async(g,x)=>{let m=a(x);await(m==null?void 0:m.importFromMxGraph(g))},p=g=>{let x=a(g);return x==null?void 0:x.exportToMxGraph()},f=g=>{let x=a(g);return(x==null?void 0:x.getElementsCount())||0};return(0,rr.jsx)(Ru.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:f},children:(0,rr.jsxs)(fn.TooltipProvider,{children:[o&&(0,rr.jsx)(fn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var Hu=require("@produto-lecom/lecom-ui"),Pi=require("react/jsx-runtime"),Gu=(0,Ae.createContext)(null),U=()=>{let e=(0,Ae.useContext)(Gu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Bu=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=(0,Hu.useTranslation)(),{defaultMode:c}=Mi(),d=(0,Ae.useId)(),[u]=(0,Ae.useState)(o||d),[p,f]=(0,Ae.useState)(n||c||"edit"),[g,x]=(0,Ae.useState)(Yn),[m,E]=(0,Ae.useState)(!1),[y,h]=(0,Ae.useState)(!0),[v,T]=(0,Ae.useState)(!1),[_,I]=(0,Ae.useState)(!1),[C,L]=(0,Ae.useState)(!1),[A,R]=(0,Ae.useState)(!1),[S,k]=(0,Ae.useState)(!1),[V,w]=(0,Ae.useState)(null);(0,Ae.useEffect)(()=>{n&&f(n)},[n]);let P=(0,Ae.useMemo)(()=>t||Cc(l),[t,l]),F={instanceId:u,initialDiagram:P,mode:p,lastElementId:g,isInitialized:m,isMinimapOpen:_,isMoveTool:y,isHandTool:v,isDragging:C,isMultipleSelection:S,isConnecting:A,setLastElementId:x,setIsInitialized:E,reconnectingEdgeId:V,setIsMinimapOpen:I,setIsMoveTool:h,setIsHandTool:T,setIsDragging:L,setIsConnecting:R,setIsMultipleSelection:k,setReconnectingEdgeId:w,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return(0,Pi.jsx)(Vu.ReactFlowProvider,{children:(0,Pi.jsx)(Gu.Provider,{value:F,children:(0,Pi.jsx)(_s,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
71
+ `),y.close()},"print")},isPrintingPng:n.png,isPrintingHtml:n.html,isPrinting:n.print}};var ge=require("react/jsx-runtime");function Vu(){let{t:e}=(0,pe.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:a}=Du(),[s,l]=(0,Ou.useState)(!1);return(0,ge.jsxs)(pe.DropdownMenu,{modal:!1,open:s,onOpenChange:l,children:[(0,ge.jsx)(pe.DropdownMenuTrigger,{asChild:!0,children:(0,ge.jsx)("div",{children:(0,ge.jsxs)(pe.Tooltip,{children:[(0,ge.jsx)(pe.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)(pe.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,ge.jsx)(oo.FolderOutputIcon,{})})}),!s&&(0,ge.jsx)(pe.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,ge.jsxs)(pe.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,ge.jsxs)(pe.Tooltip,{children:[(0,ge.jsx)(pe.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)(pe.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,ge.jsx)(oo.FileImageIcon,{})})}),(0,ge.jsx)(pe.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,ge.jsxs)(pe.Tooltip,{children:[(0,ge.jsx)(pe.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)(pe.DropdownMenuItem,{className:"p-1.5",disabled:a,onClick:()=>o(),children:(0,ge.jsx)(oo.FileCodeIcon,{})})}),(0,ge.jsx)(pe.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,ge.jsxs)(pe.Tooltip,{children:[(0,ge.jsx)(pe.TooltipTrigger,{asChild:!0,children:(0,ge.jsx)(pe.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,ge.jsx)(oo.PrinterIcon,{})})}),(0,ge.jsx)(pe.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var ae=require("react/jsx-runtime"),Hu=({nodes:e,edges:t,validateDiagram:o,handleValidationComplete:n})=>{let{t:r}=(0,Ae.useTranslation)(),{clearSelection:i}=Zt(),{mode:a,isMinimapOpen:s,setIsMinimapOpen:l,isMoveTool:c,isHandTool:d,setIsMoveTool:u,setIsHandTool:p}=X(),{getNodes:f,getEdges:h}=(0,sr.useReactFlow)(),y=(0,sr.useKeyPress)(["v","V"]),g=(0,sr.useKeyPress)(["h","H"]),b=(0,So.useCallback)(()=>{i(),p(!0),u(!1)},[i,p,u]),x=(0,So.useCallback)(()=>{u(!0),p(!1)},[u,p]),m=(0,So.useCallback)(()=>{let N=f(),T=h(),_=o({nodes:N,edges:T});n(_)},[f,h,o,n]);return(0,So.useEffect)(()=>{y&&!c&&a==="edit"&&x()},[y,x,c,a]),(0,So.useEffect)(()=>{g&&!d&&a==="edit"&&b()},[g,b,d,a]),(0,ae.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[a==="edit"&&(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)(Ae.Tooltip,{children:[(0,ae.jsx)(Ae.TooltipTrigger,{asChild:!0,children:(0,ae.jsx)(Ae.Button,{size:"small",variant:"ghost",color:"grey",className:k(c&&"bg-grey-400"),iconButton:!0,onClick:x,children:(0,ae.jsx)(no.MousePointerIcon,{})})}),(0,ae.jsxs)(Ae.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.move_tool"),(0,ae.jsx)(ws,{shortcut:"V"})]})]}),(0,ae.jsxs)(Ae.Tooltip,{children:[(0,ae.jsx)(Ae.TooltipTrigger,{asChild:!0,children:(0,ae.jsx)(Ae.Button,{size:"small",variant:"ghost",color:"grey",className:k(d&&"bg-grey-400"),iconButton:!0,onClick:b,children:(0,ae.jsx)(no.HandIcon,{})})}),(0,ae.jsxs)(Ae.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[r("editor.controls.actions.hand_tool")," ",(0,ae.jsx)(ws,{shortcut:"H"})]})]})]}),(0,ae.jsx)(Vu,{}),a==="edit"&&(0,ae.jsxs)(ae.Fragment,{children:[(0,ae.jsxs)(Ae.Tooltip,{children:[(0,ae.jsx)(Ae.TooltipTrigger,{asChild:!0,children:(0,ae.jsx)(Ae.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,onClick:m,children:(0,ae.jsx)(no.ListCheckIcon,{})})}),(0,ae.jsx)(Ae.TooltipContent,{color:"black",children:r("editor.controls.actions.check")})]}),(0,ae.jsx)(Pu,{disabled:e.length>0||t.length>0})]}),(0,ae.jsxs)(Ae.Tooltip,{children:[(0,ae.jsx)(Ae.TooltipTrigger,{asChild:!0,children:(0,ae.jsx)(Ae.Button,{size:"small",variant:"ghost",color:"grey",className:k(s&&"bg-grey-400"),iconButton:!0,onClick:()=>l(!s),children:(0,ae.jsx)(no.MapIcon,{})})}),(0,ae.jsx)(Ae.TooltipContent,{color:"black",children:r(s?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})};var Ze=require("@produto-lecom/lecom-ui"),Li=require("lucide-react"),st=require("react/jsx-runtime"),Gu=({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,Ze.useTranslation)();return(0,st.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,st.jsxs)(Ze.Tooltip,{children:[(0,st.jsx)(Ze.TooltipTrigger,{asChild:!0,children:(0,st.jsx)(Ze.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,st.jsx)(Li.UndoIcon,{})})}),(0,st.jsx)(Ze.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,st.jsxs)(Ze.Tooltip,{children:[(0,st.jsx)(Ze.TooltipTrigger,{asChild:!0,children:(0,st.jsx)(Ze.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,st.jsx)(Li.RedoIcon,{})})}),(0,st.jsx)(Ze.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})};var mn=require("@xyflow/react"),Ie=require("@produto-lecom/lecom-ui"),gn=require("lucide-react");var Te=require("react/jsx-runtime"),Bu=()=>{let{t:e}=(0,Ie.useTranslation)(),t=(0,mn.useNodes)(),o=(0,mn.useEdges)(),{zoomIn:n,zoomOut:r,zoomTo:i,fitView:a}=(0,mn.useReactFlow)(),s=t.length===0&&o.length===0;return(0,Te.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Te.jsxs)(Ie.Tooltip,{children:[(0,Te.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,Te.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>a(),children:(0,Te.jsx)(gn.ScanIcon,{})})}),(0,Te.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Te.jsxs)(Ie.Tooltip,{children:[(0,Te.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,Te.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>r(),children:(0,Te.jsx)(gn.ZoomOut,{})})}),(0,Te.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Te.jsxs)(Ie.Tooltip,{children:[(0,Te.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,Te.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>i(1),children:(0,Te.jsx)(Ws,{})})}),(0,Te.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Te.jsxs)(Ie.Tooltip,{children:[(0,Te.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,Te.jsx)(Ie.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:s,onClick:()=>n(),children:(0,Te.jsx)(gn.ZoomIn,{})})}),(0,Te.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var zu=require("@xyflow/react"),Pt=require("@produto-lecom/lecom-ui"),ki=require("react");var Et=require("react/jsx-runtime"),Fu=()=>{let e=(0,ki.useRef)(null),{t}=(0,Pt.useTranslation)(),{setDraggableNode:o}=rn(),n=(0,zu.useNodes)(),{setIsDragging:r}=X(),[i,a]=(0,ki.useState)(void 0),s=[{type:"START_EVENT",icon:yr,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:Po,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:bn,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:$s,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SCRIPT",icon:Us,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:Ys,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Ro,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Oo,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:Lo,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:Fs,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:mr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),a((0,Et.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Et.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Et.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:s.map((c,d)=>{let u=!qt(c.type,n),p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Et.jsxs)(Pt.Tooltip,{children:[(0,Et.jsx)(Pt.TooltipTrigger,{asChild:!0,children:(0,Et.jsx)(Pt.Button,{className:k("[&>svg]:size-6",{"opacity-50 cursor-not-allowed":u}),size:"small",variant:"ghost",color:"grey",draggable:!u,disabled:u,iconButton:!0,onDragStart:u?void 0:f=>l(f,c),children:(0,Et.jsx)(c.icon,{})},d)}),(0,Et.jsx)(Pt.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Et.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var Ge=require("react/jsx-runtime"),Is=(0,Ri.forwardRef)((e,t)=>{let o=(0,Lt.useKeyPress)("Space"),{instanceId:n,mode:r,isMinimapOpen:i,isMoveTool:a,isHandTool:s}=X(),{nodes:l,edges:c,actions:d,events:u,components:p,controls:f}=fu(),{t:h}=(0,ro.useTranslation)();(0,Ri.useImperativeHandle)(t,()=>({selectElements:d.selectElements,clearSelection:d.clearSelection}));let y=s||o||r!=="edit",g=r!=="readonly"&&a&&!o,b=r==="edit"&&a&&!o,x=r==="edit"&&a&&!o;return(0,Ge.jsxs)("div",{className:"w-full h-full",children:[r==="edit"&&(0,Ge.jsx)(Fu,{}),(0,Ge.jsx)(mu,{}),(0,Ge.jsxs)(Lt.ReactFlow,v(E({},u),{id:`modeler-${n}`,className:k({"is-hand-tool":s||o}),edges:c,nodes:l,nodeTypes:fd,edgeTypes:md,minZoom:bd,maxZoom:_d,panOnDrag:y,panOnScroll:!0,selectionOnDrag:!0,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!1,elementsSelectable:g,nodesConnectable:b,nodesDraggable:x,connectionLineComponent:dd,selectionMode:Lt.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:"Delete",selectionKeyCode:null,defaultViewport:Td,connectOnClick:!1,connectionRadius:50,proOptions:{hideAttribution:!0},children:[(0,Ge.jsx)(Lt.Background,{gap:xd,size:yd,color:hd,bgColor:gd}),i&&(0,Ge.jsxs)(ro.Tooltip,{children:[(0,Ge.jsx)(ro.TooltipTrigger,{asChild:!0,children:(0,Ge.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,Ge.jsx)(Lt.MiniMap,{pannable:!0,zoomable:!0,position:Ed,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,Ge.jsx)(ro.TooltipContent,{color:"black",children:h("editor.controls.actions.minimap.label")})]}),(0,Ge.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,Ge.jsx)(Gu,E({},f)),(0,Ge.jsx)(Hu,{nodes:l,edges:c,validateDiagram:d.validateDiagram,handleValidationComplete:d.handleValidationComplete}),(0,Ge.jsx)(Bu,{})]}),(0,Ge.jsx)(p.HelperLines,{})]}))]})});Is.displayName="Editor";var Wu=require("@xyflow/react"),Di=require("react"),Yu=require("react/jsx-runtime"),Pg=e=>({width:e.width,height:e.height,transform:e.transform}),Cs="rgba(51, 103, 217, 0.4)",Ul=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Wu.useStore)(Pg),i=(0,Di.useRef)(null);return(0,Di.useEffect)(()=>{let a=i.current,s=a==null?void 0:a.getContext("2d");if(!s||!a)return;let l=window.devicePixelRatio;a.width=o*l,a.height=n*l,s.clearRect(0,0,o,n),s.scale(l,l),s.strokeStyle=Cs,t&&(s.beginPath(),s.strokeStyle=t.color||Cs,s.moveTo(t.position*r[2]+r[0],0),s.lineTo(t.position*r[2]+r[0],n),s.stroke()),e&&(s.beginPath(),s.strokeStyle=e.color||Cs,s.moveTo(0,e.position*r[2]+r[1]),s.lineTo(o,e.position*r[2]+r[1]),s.stroke())},[o,n,r,e,t]),(0,Yu.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var hn=require("@produto-lecom/lecom-ui"),io=require("react");var ar=require("react/jsx-runtime"),wt=new Map,Uu=(0,io.createContext)(null),Oi=()=>{let e=(0,io.useContext)(Uu);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},$u=({locale:e,defaultMode:t="view",showNotification:o=!0,children:n})=>{let[r,i]=(0,io.useState)(e||"pt_BR");(0,io.useEffect)(()=>{e&&(i(e),hn.i18n.changeLanguage(e))},[e]);let a=h=>{let y=wt.size;if(y===0)throw new Error("No modeler instances found");if(y===1||!h){let[b]=wt.values();return b}let g=wt.get(h);if(!g)throw new Error(`Modeler instance with ID "${h}" not found`);return g},s=(h,y)=>{let g=a(y);return g==null?void 0:g.selectElements(h)},l=async h=>{let y=a(h);return y==null?void 0:y.clearSelection()},c=(h,y)=>{let g=a(y);return g==null?void 0:g.configureElement(h)},d=(h,y)=>{let g=a(y);return g==null?void 0:g.getConfigureElement(h)},u=async(h,y)=>{let g=a(y);await(g==null?void 0:g.importFromMxGraph(h))},p=h=>{let y=a(h);return y==null?void 0:y.exportToMxGraph()},f=h=>{let y=a(h);return(y==null?void 0:y.getElementsCount())||0};return(0,ar.jsx)(Uu.Provider,{value:{defaultMode:t,locale:r,selectElements:s,clearSelection:l,configureElement:c,getConfigureElement:d,importDiagram:u,exportDiagram:p,getElementsCount:f},children:(0,ar.jsxs)(hn.TooltipProvider,{children:[o&&(0,ar.jsx)(hn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),n]})})};var Ku=require("@produto-lecom/lecom-ui"),Vi=require("react/jsx-runtime"),qu=(0,Ce.createContext)(null),X=()=>{let e=(0,Ce.useContext)(qu);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Zu=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s})=>{let{t:l}=(0,Ku.useTranslation)(),{defaultMode:c}=Oi(),d=(0,Ce.useId)(),[u]=(0,Ce.useState)(o||d),[p,f]=(0,Ce.useState)(n||c||"edit"),[h,y]=(0,Ce.useState)(Un),[g,b]=(0,Ce.useState)(!1),[x,m]=(0,Ce.useState)(!0),[N,T]=(0,Ce.useState)(!1),[_,w]=(0,Ce.useState)(!1),[S,P]=(0,Ce.useState)(!1),[I,O]=(0,Ce.useState)(!1),[C,L]=(0,Ce.useState)(!1),[z,A]=(0,Ce.useState)(null);(0,Ce.useEffect)(()=>{n&&f(n)},[n]);let G=(0,Ce.useMemo)(()=>t||Vc(l),[t,l]),Q={instanceId:u,initialDiagram:G,mode:p,lastElementId:h,isInitialized:g,isMinimapOpen:_,isMoveTool:x,isHandTool:N,isDragging:S,isMultipleSelection:C,isConnecting:I,setLastElementId:y,setIsInitialized:b,reconnectingEdgeId:z,setIsMinimapOpen:w,setIsMoveTool:m,setIsHandTool:T,setIsDragging:P,setIsConnecting:O,setIsMultipleSelection:L,setReconnectingEdgeId:A,onElementChanges:r,onConfigureElement:i,onElementClick:a,onSubprocessValidationClick:s};return(0,Vi.jsx)(Xu.ReactFlowProvider,{children:(0,Vi.jsx)(qu.Provider,{value:Q,children:(0,Vi.jsx)(Is,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});