lecom-modeler 0.44.0 → 0.45.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,8 +1,8 @@
1
- "use strict";var Gf=Object.create;var er=Object.defineProperty,Bf=Object.defineProperties,zf=Object.getOwnPropertyDescriptor,Yf=Object.getOwnPropertyDescriptors,Ff=Object.getOwnPropertyNames,$r=Object.getOwnPropertySymbols,Wf=Object.getPrototypeOf,Ms=Object.prototype.hasOwnProperty,Ya=Object.prototype.propertyIsEnumerable;var za=(e,t,o)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Ms.call(t,o)&&za(e,o,t[o]);if($r)for(var o of $r(t))Ya.call(t,o)&&za(e,o,t[o]);return e},w=(e,t)=>Bf(e,Yf(t));var Ut=(e,t)=>{var o={};for(var n in e)Ms.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&$r)for(var n of $r(e))t.indexOf(n)<0&&Ya.call(e,n)&&(o[n]=e[n]);return o};var Xf=(e,t)=>{for(var o in t)er(e,o,{get:t[o],enumerable:!0})},Fa=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ff(t))!Ms.call(e,r)&&r!==o&&er(e,r,{get:()=>t[r],enumerable:!(n=zf(t,r))||n.enumerable});return e};var tr=(e,t,o)=>(o=e!=null?Gf(Wf(e)):{},Fa(t||!e||!e.__esModule?er(o,"default",{value:e,enumerable:!0}):o,e)),Uf=e=>Fa(er({},"__esModule",{value:!0}),e);var Qy={};Xf(Qy,{EditorMode:()=>Ge,ElementPosition:()=>qr,ElementType:()=>or,GatewayElementVariant:()=>Zr,GatewayVariant:()=>Et,Modeler:()=>Hf,ModelerProvider:()=>Rf,NodeAttribute:()=>Ht,NodeType:()=>re,NodeVariant:()=>ft,RoutingVariant:()=>Jr,useModeler:()=>Rn});module.exports=Uf(Qy);var Ps=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 Kr=require("@produto-lecom/lecom-ui");var Wa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",deleting:"Deleting...",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"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",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",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.",delete_elements_blocked:"One or more activities cannot be deleted because there are in-progress processes in the Workspace linked to them.",delete_elements_error:"An error occurred. Please try again later."},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",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},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_not_allowed_when_service_task:"Cannot create loop on automatic activity",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:"One or more gateways do 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_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},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",service_task:"RPA"},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:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},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 Xa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",deleting:"Eliminando...",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"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",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",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.",delete_elements_blocked:"No se pueden eliminar una o m\xE1s actividades porque existen procesos en curso en el Workspace vinculados a ellas.",delete_elements_error:"Ocurri\xF3 un error. Int\xE9ntelo de nuevo m\xE1s tarde."},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",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},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_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",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:"Una o m\xE1s compuertas no tienen 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_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},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",service_task:"RPA"},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:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},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 Ua={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",deleting:"Excluindo...",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"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",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",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.",delete_elements_blocked:"Uma ou mais atividades n\xE3o podem ser exclu\xEDdas porque existem processos em andamento no Workspace vinculados a elas.",delete_elements_error:"Ocorreu um erro. Tente novamente mais tarde."},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",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},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_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama validado 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:"Um ou mais gateways n\xE3o possuem 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_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},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",service_task:"RPA"},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:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},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 $a={pt_BR:Ua,en_US:Wa,es_ES:Xa};var Ka,qa,$f=(qa=(Ka=Ps("LecomUserLanguage"))!=null?Ka:Ps("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?qa:Kr.Translations.PT_BR;(0,Kr.initializeI18n)({lng:$f,resources:$a});var Ge=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ge||{});var or=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(or||{}),qr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(qr||{}),Zr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Zr||{}),Jr=(p=>(p.SIMPLE="simple",p.LOOP="loop",p.SCRIPT="script",p.SCRIPT_LOOP="script_loop",p.COMPLEX="complex",p.EXCLUSIVE="exclusive",p.PARALLEL="parallel",p.FINAL="final",p.TO_SUB_PROCESS="to_sub_process",p.FROM_SUB_PROCESS="from_sub_process",p.TO_SERVICE_TASK="to_service_task",p.FROM_SERVICE_TASK="from_service_task",p))(Jr||{});var vo=require("lucide-react");var Yo=require("react/jsx-runtime"),Qr=({size:e=24,className:t})=>(0,Yo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Yo.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Yo.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Yo.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Yo.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ls=require("react/jsx-runtime"),xn=({size:e=24,className:t})=>(0,Ls.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,Ls.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 _o=require("react/jsx-runtime"),En=({size:e=24,className:t})=>(0,_o.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,_o.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,_o.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,_o.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,_o.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,_o.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var _n=require("react/jsx-runtime"),bn=({size:e=24,className:t})=>(0,_n.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,_n.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,_n.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,_n.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var Tn=require("react/jsx-runtime"),vn=({size:e=24,className:t})=>(0,Tn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Tn.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,Tn.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Tn.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var Nn=require("react/jsx-runtime"),Za=({size:e=24,className:t})=>(0,Nn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,Nn.jsxs)("g",{children:[(0,Nn.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,Nn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Ja=require("clsx"),Qa=require("tailwind-merge");function H(...e){return(0,Qa.twMerge)((0,Ja.clsx)(e))}var bo=(e=0,t=0)=>e<t?t:e,jr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var nr=require("react/jsx-runtime"),ja=({size:e=24,className:t})=>(0,nr.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:H("stroke-2",t),children:[(0,nr.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,nr.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var ei=require("react/jsx-runtime"),el=({size:e=24,className:t})=>(0,ei.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,ei.jsx)("g",{children:(0,ei.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 ks=require("react/jsx-runtime"),ti=({size:e=24,className:t})=>(0,ks.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,ks.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 Rs=require("react/jsx-runtime"),rr=({size:e=24,className:t})=>(0,Rs.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:H("stroke-2",t),children:(0,Rs.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 wn=require("react/jsx-runtime"),tl=({size:e=24,className:t})=>(0,wn.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,wn.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,wn.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,wn.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var To=require("react/jsx-runtime"),ol=({size:e=24,className:t})=>(0,To.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,To.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,To.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,To.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,To.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,To.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Fo=require("react/jsx-runtime"),ir=({size:e=24,className:t})=>(0,Fo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Fo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Fo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Fo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Fo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var re=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(re||{}),ft=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(ft||{}),oi={SCRIPT:{icon:vo.ScrollText},SUBPROCESS:{icon:vo.SquarePlus},SERVICE_TASK:{icon:vo.Bot}},Ht=(t=>(t.LOOP="LOOP",t))(Ht||{}),ni={LOOP:{icon:vo.RotateCcw}},Et=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Et||{}),Ds={EXCLUSIVE:{icon:bn},PARALLEL:{icon:vn},COMPLEX:{icon:En}};var Df=require("@produto-lecom/lecom-ui"),Of=require("@xyflow/react"),Ie=require("react");var lo=require("@xyflow/react"),yn=require("react");var Oo=require("@xyflow/react"),io=require("react");var In=require("@xyflow/react");function nl(e,t){var x,T,b,I;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(x=t==null?void 0:t.measured)==null?void 0:x.width)!=null?T:0)/2,u=i.y+((I=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?I:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),f=(d-l)/(2*s)+(u-c)/(2*a),h=1/(Math.abs(p)+Math.abs(f)||1),E=h*p,g=h*f,y=s*(E+g)+l,m=a*(-E+g)+c;return{x:y,y:m}}function rl(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),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?In.Position.Left:a>=i+n-1?In.Position.Right:l<=s+1?In.Position.Top:l>=s+r-1?In.Position.Bottom:In.Position.Top}function An(e,t){let o=nl(e,t),n=nl(t,e),r=rl(e,o),i=rl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function ri(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",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var il=require("lodash");var ii=e=>e.some(t=>t.type==="position"&&t.dragging),sl=e=>new Map(e.map(t=>[t.id,t])),al=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Mt=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},sr=e=>(0,il.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ll=(e,t)=>{let{x:o,y:n}=Mt(e),{x:r,y:i}=Mt(t);return{x:o-r,y:n-i}};var Wo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(re)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),Kf=(e,t)=>{let{x:o,y:n}=Mt(e),{x:r,y:i}=Mt(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},qf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Mt(e),{x:s,y:a,w:l,h:c}=Mt(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},ar=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&qf(e,r)){let i=Kf(e,r);i<n&&(n=i,o=r)}return o},cl=(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 dl=e=>{let t=e.filter(s=>!s.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let{position:a,width:l,height:c}=s,d=a.x+(l||0),u=a.y+(c||0);a.x<o&&(o=a.x),a.y<n&&(n=a.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},ul=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:s=0})=>{let a=t-i*2,l=o-s*2,c=Math.min(a/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+s,zoom:u}};var Os=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=Mt(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=Mt(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var fl=require("react"),ml=require("zustand");var pl=require("@xyflow/react"),$t=()=>{let e=(0,pl.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=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 a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await jr(),!0}}};var gl=()=>{let{selectElements:e}=$t();return(0,fl.useCallback)(()=>{let o=Xo.getState().pathEdgeIds;e(o)},[e])},Xo=(0,ml.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{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=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&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:E}=p.shift();if(h===u)return E;let g=s[h]||[];for(let{targetId:y,edgeId:m}of g)f.has(y)||(f.add(y),p.push({node:y,path:[...E,m]}))}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 Ln=require("@xyflow/react"),_t=require("react"),dd=require("zustand/shallow");var Zf={value:()=>{}};function yl(){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 si(o)}function si(e){this._=e}function Jf(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}})}si.prototype=yl.prototype={constructor:si,on:function(e,t){var o=this._,n=Jf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=Qf(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=hl(o[r],e.name,t);else if(t==null)for(r in o)o[r]=hl(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 si(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 Qf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function hl(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Zf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Vs=yl;var ai="http://www.w3.org/1999/xhtml",Hs={svg:"http://www.w3.org/2000/svg",xhtml:ai,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function uo(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Hs.hasOwnProperty(t)?{space:Hs[t],local:e}:e}function jf(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ai&&t.documentElement.namespaceURI===ai?t.createElement(e):t.createElementNS(o,e)}}function em(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function li(e){var t=uo(e);return(t.local?em:jf)(t)}function tm(){}function Uo(e){return e==null?tm:function(){return this.querySelector(e)}}function xl(e){typeof e!="function"&&(e=Uo(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Ze(n,this._parents)}function Gs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function om(){return[]}function lr(e){return e==null?om:function(){return this.querySelectorAll(e)}}function nm(e){return function(){return Gs(e.apply(this,arguments))}}function El(e){typeof e=="function"?e=nm(e):e=lr(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new Ze(n,r)}function cr(e){return function(){return this.matches(e)}}function ci(e){return function(t){return t.matches(e)}}var rm=Array.prototype.find;function im(e){return function(){return rm.call(this.children,e)}}function sm(){return this.firstElementChild}function _l(e){return this.select(e==null?sm:im(typeof e=="function"?e:ci(e)))}var am=Array.prototype.filter;function lm(){return Array.from(this.children)}function cm(e){return function(){return am.call(this.children,e)}}function bl(e){return this.selectAll(e==null?lm:cm(typeof e=="function"?e:ci(e)))}function Tl(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ze(n,this._parents)}function di(e){return new Array(e.length)}function vl(){return new Ze(this._enter||this._groups.map(di),this._parents)}function dr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}dr.prototype={constructor:dr,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 Nl(e){return function(){return e}}function dm(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new dr(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function um(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,p=new Array(d),f;for(a=0;a<d;++a)(l=t[a])&&(p[a]=f=s.call(l,l.__data__,a,t)+"",c.has(f)?r[a]=l:c.set(f,l));for(a=0;a<u;++a)f=s.call(e,i[a],a,i)+"",(l=c.get(f))?(n[a]=l,l.__data__=i[a],c.delete(f)):o[a]=new dr(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function pm(e){return e.__data__}function wl(e,t){if(!arguments.length)return Array.from(this,pm);var o=t?um:dm,n=this._parents,r=this._groups;typeof e!="function"&&(e=Nl(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,f=fm(e.call(d,d&&d.__data__,c,n)),h=f.length,E=a[c]=new Array(h),g=s[c]=new Array(h),y=l[c]=new Array(p);o(d,u,E,g,y,f,t);for(var m=0,x=0,T,b;m<h;++m)if(T=E[m]){for(m>=x&&(x=m+1);!(b=g[x])&&++x<h;);T._next=b||null}}return s=new Ze(s,n),s._enter=a,s._exit=l,s}function fm(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new Ze(this._exit||this._groups.map(di),this._parents)}function Al(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 Cl(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),f,h=0;h<u;++h)(f=c[h]||d[h])&&(p[h]=f);for(;l<r;++l)a[l]=o[l];return new Ze(a,this._parents)}function Sl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Ml(e){e||(e=mm);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 s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Ze(r,this._parents).order()}function mm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ll(){return Array.from(this)}function kl(){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 s=n[r];if(s)return s}return null}function Rl(){let e=0;for(let t of this)++e;return e}function Dl(){return!this.node()}function Ol(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function gm(e){return function(){this.removeAttribute(e)}}function hm(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ym(e,t){return function(){this.setAttribute(e,t)}}function xm(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Em(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function _m(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 Vl(e,t){var o=uo(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?hm:gm:typeof t=="function"?o.local?_m:Em:o.local?xm:ym)(o,t))}function ui(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function bm(e){return function(){this.style.removeProperty(e)}}function Tm(e,t,o){return function(){this.style.setProperty(e,t,o)}}function vm(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Hl(e,t,o){return arguments.length>1?this.each((t==null?bm:typeof t=="function"?vm:Tm)(e,t,o==null?"":o)):No(this.node(),e)}function No(e,t){return e.style.getPropertyValue(t)||ui(e).getComputedStyle(e,null).getPropertyValue(t)}function Nm(e){return function(){delete this[e]}}function wm(e,t){return function(){this[e]=t}}function Im(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Gl(e,t){return arguments.length>1?this.each((t==null?Nm:typeof t=="function"?Im:wm)(e,t)):this.node()[e]}function Bl(e){return e.trim().split(/^|\s+/)}function Bs(e){return e.classList||new zl(e)}function zl(e){this._node=e,this._names=Bl(e.getAttribute("class")||"")}zl.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 Yl(e,t){for(var o=Bs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Fl(e,t){for(var o=Bs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Am(e){return function(){Yl(this,e)}}function Cm(e){return function(){Fl(this,e)}}function Sm(e,t){return function(){(t.apply(this,arguments)?Yl:Fl)(this,e)}}function Wl(e,t){var o=Bl(e+"");if(arguments.length<2){for(var n=Bs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Sm:t?Am:Cm)(o,t))}function Mm(){this.textContent=""}function Pm(e){return function(){this.textContent=e}}function Lm(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Xl(e){return arguments.length?this.each(e==null?Mm:(typeof e=="function"?Lm:Pm)(e)):this.node().textContent}function km(){this.innerHTML=""}function Rm(e){return function(){this.innerHTML=e}}function Dm(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ul(e){return arguments.length?this.each(e==null?km:(typeof e=="function"?Dm:Rm)(e)):this.node().innerHTML}function Om(){this.nextSibling&&this.parentNode.appendChild(this)}function $l(){return this.each(Om)}function Vm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Kl(){return this.each(Vm)}function ql(e){var t=typeof e=="function"?e:li(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Hm(){return null}function Zl(e,t){var o=typeof e=="function"?e:li(e),n=t==null?Hm:typeof t=="function"?t:Uo(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Gm(){var e=this.parentNode;e&&e.removeChild(this)}function Jl(){return this.each(Gm)}function Bm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zm(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ql(e){return this.select(e?zm:Bm)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ym(e){return function(t){e.call(this,t,this.__data__)}}function Fm(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 Wm(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 Xm(e,t,o){return function(){var n=this.__on,r,i=Ym(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).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 ec(e,t,o){var n=Fm(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Xm:Wm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function tc(e,t,o){var n=ui(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 Um(e,t){return function(){return tc(this,e,t)}}function $m(e,t){return function(){return tc(this,e,t.apply(this,arguments))}}function oc(e,t){return this.each((typeof t=="function"?$m:Um)(e,t))}function*nc(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var Km=[null];function Ze(e,t){this._groups=e,this._parents=t}function rc(){return new Ze([[document.documentElement]],Km)}function qm(){return this}Ze.prototype=rc.prototype={constructor:Ze,select:xl,selectAll:El,selectChild:_l,selectChildren:bl,filter:Tl,data:wl,enter:vl,exit:Il,join:Al,merge:Cl,selection:qm,order:Sl,sort:Ml,call:Pl,nodes:Ll,node:kl,size:Rl,empty:Dl,each:Ol,attr:Vl,style:Hl,property:Gl,classed:Wl,text:Xl,html:Ul,raise:$l,lower:Kl,append:ql,insert:Zl,remove:Jl,clone:Ql,datum:jl,on:ec,dispatch:oc,[Symbol.iterator]:nc};var po=rc;function pi(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function zs(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function fr(){}var ur=.7,gi=1/ur,Cn="\\s*([+-]?\\d+)\\s*",pr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Zm=/^#([0-9a-f]{3,8})$/,Jm=new RegExp(`^rgb\\(${Cn},${Cn},${Cn}\\)$`),Qm=new RegExp(`^rgb\\(${Kt},${Kt},${Kt}\\)$`),jm=new RegExp(`^rgba\\(${Cn},${Cn},${Cn},${pr}\\)$`),eg=new RegExp(`^rgba\\(${Kt},${Kt},${Kt},${pr}\\)$`),tg=new RegExp(`^hsl\\(${pr},${Kt},${Kt}\\)$`),og=new RegExp(`^hsla\\(${pr},${Kt},${Kt},${pr}\\)$`),ic={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};pi(fr,wo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sc,formatHex:sc,formatHex8:ng,formatHsl:rg,formatRgb:ac,toString:ac});function sc(){return this.rgb().formatHex()}function ng(){return this.rgb().formatHex8()}function rg(){return fc(this).formatHsl()}function ac(){return this.rgb().formatRgb()}function wo(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Zm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?lc(t):o===3?new mt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?fi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?fi(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=Jm.exec(e))?new mt(t[1],t[2],t[3],1):(t=Qm.exec(e))?new mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=jm.exec(e))?fi(t[1],t[2],t[3],t[4]):(t=eg.exec(e))?fi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=tg.exec(e))?uc(t[1],t[2]/100,t[3]/100,1):(t=og.exec(e))?uc(t[1],t[2]/100,t[3]/100,t[4]):ic.hasOwnProperty(e)?lc(ic[e]):e==="transparent"?new mt(NaN,NaN,NaN,0):null}function lc(e){return new mt(e>>16&255,e>>8&255,e&255,1)}function fi(e,t,o,n){return n<=0&&(e=t=o=NaN),new mt(e,t,o,n)}function ig(e){return e instanceof fr||(e=wo(e)),e?(e=e.rgb(),new mt(e.r,e.g,e.b,e.opacity)):new mt}function Sn(e,t,o,n){return arguments.length===1?ig(e):new mt(e,t,o,n==null?1:n)}function mt(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}pi(mt,Sn,zs(fr,{brighter(e){return e=e==null?gi:Math.pow(gi,e),new mt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ur:Math.pow(ur,e),new mt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new mt(Ko(this.r),Ko(this.g),Ko(this.b),hi(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:cc,formatHex:cc,formatHex8:sg,formatRgb:dc,toString:dc}));function cc(){return`#${$o(this.r)}${$o(this.g)}${$o(this.b)}`}function sg(){return`#${$o(this.r)}${$o(this.g)}${$o(this.b)}${$o((isNaN(this.opacity)?1:this.opacity)*255)}`}function dc(){let e=hi(this.opacity);return`${e===1?"rgb(":"rgba("}${Ko(this.r)}, ${Ko(this.g)}, ${Ko(this.b)}${e===1?")":`, ${e})`}`}function hi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ko(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $o(e){return e=Ko(e),(e<16?"0":"")+e.toString(16)}function uc(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Gt(e,t,o,n)}function fc(e){if(e instanceof Gt)return new Gt(e.h,e.s,e.l,e.opacity);if(e instanceof fr||(e=wo(e)),!e)return new Gt;if(e instanceof Gt)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),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new Gt(s,a,l,e.opacity)}function mc(e,t,o,n){return arguments.length===1?fc(e):new Gt(e,t,o,n==null?1:n)}function Gt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}pi(Gt,mc,zs(fr,{brighter(e){return e=e==null?gi:Math.pow(gi,e),new Gt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ur:Math.pow(ur,e),new Gt(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 mt(Ys(e>=240?e-240:e+120,r,n),Ys(e,r,n),Ys(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Gt(pc(this.h),mi(this.s),mi(this.l),hi(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=hi(this.opacity);return`${e===1?"hsl(":"hsla("}${pc(this.h)}, ${mi(this.s)*100}%, ${mi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pc(e){return e=(e||0)%360,e<0?e+360:e}function mi(e){return Math.max(0,Math.min(1,e||0))}function Ys(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 Fs(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function gc(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],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return Fs((o-n/t)*t,s,r,i,a)}}function hc(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],s=e[(n+1)%t],a=e[(n+2)%t];return Fs((o-n/t)*t,r,i,s,a)}}var Ws=e=>()=>e;function ag(e,t){return function(o){return e+o*t}}function lg(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 yc(e){return(e=+e)==1?yi:function(t,o){return o-t?lg(t,o,e):Ws(isNaN(t)?o:t)}}function yi(e,t){var o=t-e;return o?ag(e,o):Ws(isNaN(e)?t:e)}var xi=function e(t){var o=yc(t);function n(r,i){var s=o((r=Sn(r)).r,(i=Sn(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=yi(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function xc(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Sn(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var cg=xc(gc),dg=xc(hc);function Pt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Us=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Xs=new RegExp(Us.source,"g");function ug(e){return function(){return e}}function pg(e){return function(t){return e(t)+""}}function $s(e,t){var o=Us.lastIndex=Xs.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=Us.exec(e))&&(r=Xs.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:Pt(n,r)})),o=Xs.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?pg(l[0].x):ug(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Ec=180/Math.PI,Ei={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ks(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ec,skewX:Math.atan(l)*Ec,scaleX:s,scaleY:a}}var _i;function _c(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ei:Ks(t.a,t.b,t.c,t.d,t.e,t.f)}function bc(e){return e==null?Ei:(_i||(_i=document.createElementNS("http://www.w3.org/2000/svg","g")),_i.setAttribute("transform",e),(e=_i.transform.baseVal.consolidate())?(e=e.matrix,Ks(e.a,e.b,e.c,e.d,e.e,e.f)):Ei)}function Tc(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 E=f.push("translate(",null,t,null,o);h.push({i:E-4,x:Pt(c,u)},{i:E-2,x:Pt(d,p)})}else(u||p)&&f.push("translate("+u+t+p+o)}function s(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:Pt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Pt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,f,h){if(c!==u||d!==p){var E=f.push(r(f)+"scale(",null,",",null,")");h.push({i:E-4,x:Pt(c,u)},{i:E-2,x:Pt(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),s(c.rotate,d.rotate,u,p),a(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,E=p.length,g;++h<E;)u[(g=p[h]).i]=g.x(f);return u.join("")}}}var qs=Tc(_c,"px, ","px)","deg)"),Zs=Tc(bc,", ",")",")");var Mn=0,gr=0,mr=0,Nc=1e3,bi,hr,Ti=0,qo=0,vi=0,yr=typeof performance=="object"&&performance.now?performance:Date,wc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Er(){return qo||(wc(fg),qo=yr.now()+vi)}function fg(){qo=0}function xr(){this._call=this._time=this._next=null}xr.prototype=Ni.prototype={constructor:xr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Er():+o)+(t==null?0:+t),!this._next&&hr!==this&&(hr?hr._next=this:bi=this,hr=this),this._call=e,this._time=o,Js()},stop:function(){this._call&&(this._call=null,this._time=1/0,Js())}};function Ni(e,t,o){var n=new xr;return n.restart(e,t,o),n}function Ic(){Er(),++Mn;for(var e=bi,t;e;)(t=qo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mn}function vc(){qo=(Ti=yr.now())+vi,Mn=gr=0;try{Ic()}finally{Mn=0,gg(),qo=0}}function mg(){var e=yr.now(),t=e-Ti;t>Nc&&(vi-=t,Ti=e)}function gg(){for(var e,t=bi,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:bi=o);hr=e,Js(n)}function Js(e){if(!Mn){gr&&(gr=clearTimeout(gr));var t=e-qo;t>24?(e<1/0&&(gr=setTimeout(vc,e-yr.now()-vi)),mr&&(mr=clearInterval(mr))):(mr||(Ti=yr.now(),mr=setInterval(mg,Nc)),Mn=1,wc(vc))}}function wi(e,t,o){var n=new xr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var hg=Vs("start","end","cancel","interrupt"),yg=[],Sc=0,Ac=1,Ai=2,Ii=3,Cc=4,Ci=5,_r=6;function Io(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;xg(e,o,{name:t,index:n,group:r,on:hg,tween:yg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Sc})}function br(e,t){var o=Je(e,t);if(o.state>Sc)throw new Error("too late; already scheduled");return o}function ot(e,t){var o=Je(e,t);if(o.state>Ii)throw new Error("too late; already running");return o}function Je(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function xg(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Ni(i,0,o.time);function i(c){o.state=Ac,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,p,f;if(o.state!==Ac)return l();for(d in n)if(f=n[d],f.name===o.name){if(f.state===Ii)return wi(s);f.state===Cc?(f.state=_r,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete n[d]):+d<t&&(f.state=_r,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete n[d])}if(wi(function(){o.state===Ii&&(o.state=Cc,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Ai,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Ai){for(o.state=Ii,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 a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Ci,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Ci&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=_r,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Qs(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>Ai&&n.state<Ci,n.state=_r,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Mc(e){return this.each(function(){Qs(this,e)})}function Eg(e,t){var o,n;return function(){var r=ot(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function _g(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=ot(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Pc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Je(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?Eg:_g)(o,e,t))}function Pn(e,t,o){var n=e._id;return e.each(function(){var r=ot(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Je(r,n).value[t]}}function Si(e,t){var o;return(typeof t=="number"?Pt:t instanceof wo?xi:(o=wo(t))?(t=o,xi):$s)(e,t)}function bg(e){return function(){this.removeAttribute(e)}}function Tg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function vg(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function Ng(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function wg(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Ig(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Lc(e,t){var o=uo(e),n=o==="transform"?Zs:Si;return this.attrTween(e,typeof t=="function"?(o.local?Ig:wg)(o,n,Pn(this,"attr."+e,t)):t==null?(o.local?Tg:bg)(o):(o.local?Ng:vg)(o,n,t))}function Ag(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Cg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Sg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Cg(e,i)),o}return r._value=t,r}function Mg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Ag(e,i)),o}return r._value=t,r}function kc(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=uo(e);return this.tween(o,(n.local?Sg:Mg)(n,t))}function Pg(e,t){return function(){br(this,e).delay=+t.apply(this,arguments)}}function Lg(e,t){return t=+t,function(){br(this,e).delay=t}}function Rc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Pg:Lg)(t,e)):Je(this.node(),t).delay}function kg(e,t){return function(){ot(this,e).duration=+t.apply(this,arguments)}}function Rg(e,t){return t=+t,function(){ot(this,e).duration=t}}function Dc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?kg:Rg)(t,e)):Je(this.node(),t).duration}function Dg(e,t){if(typeof t!="function")throw new Error;return function(){ot(this,e).ease=t}}function Oc(e){var t=this._id;return arguments.length?this.each(Dg(t,e)):Je(this.node(),t).ease}function Og(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;ot(this,e).ease=o}}function Vc(e){if(typeof e!="function")throw new Error;return this.each(Og(this._id,e))}function Hc(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new at(n,this._parents,this._name,this._id)}function Gc(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),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),p,f=0;f<d;++f)(p=l[f]||c[f])&&(u[f]=p);for(;a<n;++a)s[a]=t[a];return new at(s,this._parents,this._name,this._id)}function Vg(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 Hg(e,t,o){var n,r,i=Vg(t)?br:ot;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Bc(e,t){var o=this._id;return arguments.length<2?Je(this.node(),o).on.on(e):this.each(Hg(o,e,t))}function Gg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function zc(){return this.on("end.remove",Gg(this._id))}function Yc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Uo(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,p=0;p<l;++p)(d=a[p])&&(u=e.call(d,d.__data__,p,a))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,Io(c[p],t,o,p,c,Je(d,o)));return new at(i,this._parents,t,o)}function Fc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=lr(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],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=Je(d,o),E=0,g=p.length;E<g;++E)(f=p[E])&&Io(f,t,o,E,p,h);i.push(p),s.push(d)}return new at(i,s,t,o)}var Bg=po.prototype.constructor;function Wc(){return new Bg(this._groups,this._parents)}function zg(e,t){var o,n,r;return function(){var i=No(this,e),s=(this.style.removeProperty(e),No(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Xc(e){return function(){this.style.removeProperty(e)}}function Yg(e,t,o){var n,r=o+"",i;return function(){var s=No(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Fg(e,t,o){var n,r,i;return function(){var s=No(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),No(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function Wg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=ot(this,e),c=l.on,d=l.value[i]==null?a||(a=Xc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Uc(e,t,o){var n=(e+="")=="transform"?qs:Si;return t==null?this.styleTween(e,zg(e,n)).on("end.style."+e,Xc(e)):typeof t=="function"?this.styleTween(e,Fg(e,n,Pn(this,"style."+e,t))).each(Wg(this._id,e)):this.styleTween(e,Yg(e,n,t),o).on("end.style."+e,null)}function Xg(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function Ug(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Xg(e,s,o)),n}return i._value=t,i}function $c(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,Ug(e,t,o==null?"":o))}function $g(e){return function(){this.textContent=e}}function Kg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Kc(e){return this.tween("text",typeof e=="function"?Kg(Pn(this,"text",e)):$g(e==null?"":e+""))}function qg(e){return function(t){this.textContent=e.call(this,t)}}function Zg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&qg(r)),t}return n._value=e,n}function qc(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,Zg(e))}function Zc(){for(var e=this._name,t=this._id,o=Mi(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Je(l,t);Io(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new at(n,this._parents,e,o)}function Jc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=ot(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Jg=0;function at(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Qc(e){return po().transition(e)}function Mi(){return++Jg}var fo=po.prototype;at.prototype=Qc.prototype={constructor:at,select:Yc,selectAll:Fc,selectChild:fo.selectChild,selectChildren:fo.selectChildren,filter:Hc,merge:Gc,selection:Wc,transition:Zc,call:fo.call,nodes:fo.nodes,node:fo.node,size:fo.size,empty:fo.empty,each:fo.each,on:Bc,attr:Lc,attrTween:kc,style:Uc,styleTween:$c,text:Kc,textTween:qc,remove:zc,tween:Pc,delay:Rc,duration:Dc,ease:Oc,easeVarying:Vc,end:Jc,[Symbol.iterator]:fo[Symbol.iterator]};function Pi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Qg={time:null,delay:0,duration:250,ease:Pi};function jg(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 jc(e){var t,o;e instanceof at?(t=e._id,e=e._name):(t=Mi(),(o=Qg).time=Er(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Io(l,e,t,c,s,o||jg(l,t));return new at(n,this._parents,e,t)}po.prototype.interrupt=Mc;po.prototype.transition=jc;function Ao(e,t,o){this.k=e,this.x=t,this.y=o}Ao.prototype={constructor:Ao,scale:function(e){return e===1?this:new Ao(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ao(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 Li=new Ao(1,0,0);ki.prototype=Ao.prototype;function ki(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Li;return e.__zoom}var th=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ed;(function(e){e.Strict="strict",e.Loose="loose"})(ed||(ed={}));var td;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(td||(td={}));var od;(function(e){e.Partial="partial",e.Full="full"})(od||(od={}));var nd;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(nd||(nd={}));var rd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rd||(rd={}));var gt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(gt||(gt={}));var mT={[gt.Left]:gt.Right,[gt.Right]:gt.Left,[gt.Top]:gt.Bottom,[gt.Bottom]:gt.Top};var oh=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var nh=(e,t=[0,0])=>{var a;let{width:o,height:n}=rh(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var Ri=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=oh(e)?e.internals.positionAbsolute:nh(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a: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 rh(e){var t,o,n,r,i,s,a,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=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var gT={[gt.Left]:{x:-1,y:0},[gt.Right]:{x:1,y:0},[gt.Top]:{x:0,y:-1},[gt.Bottom]:{x:0,y:1}};var ih={nodeOrigin:[0,0],nodeExtent:th,elevateNodesOnSelect:!0,defaults:{}},hT=w(_({},ih),{checkEquality:!0});var id;(function(e){e.Line="line",e.Handle="handle"})(id||(id={}));var sh={width:0,height:0,x:0,y:0},yT=w(_({},sh),{pointerX:0,pointerY:0,aspectRatio:1});var ah=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function lh(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 ch(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 Di=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 s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let f of s){if(f.position<a)continue;if(f.position>l)break;if(i.has(f.node.id)||f.node.parentId&&i.has(f.node.parentId)||!ah(f.nodeBox,r))continue;let h=Math.abs(f.position-o);if(h>Oi)continue;let g=lh(f.nodeBox,n)>0?0:ch(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 sd(e,t=Zo,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 s=Ri(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function ad(e,t,o,n,r=Object.keys(Zo)){let i=[];for(let a of r){let l=Zo[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function ld(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Oi&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Oi&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Oi=10,Zo={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 ud=require("react/jsx-runtime"),dh=new Di;function uh(e,t,o,n){var d,u,p,f,h,E;let r=1/0,i=1/0,s=-1/0,a=-1/0,l=new Set;for(let g of e){let y=t.find(N=>N.id===g.id);if(!y)continue;l.add(y.id);let m=o(y.id);if(!m)continue;let x=m.parentId?o(m.parentId):void 0,T=g.position.x+((d=x==null?void 0:x.internals.positionAbsolute.x)!=null?d:0),b=g.position.y+((u=x==null?void 0:x.internals.positionAbsolute.y)!=null?u:0),I=(f=(p=y.measured)==null?void 0:p.width)!=null?f:0,v=(E=(h=y.measured)==null?void 0:h.height)!=null?E:0;r=Math.min(r,T),i=Math.min(i,b),s=Math.max(s,T+I),a=Math.max(a,b+v)}if(r===1/0)return null;let c=Object.keys(Zo);return{bounds:{x:r,y:i,x2:s,y2:a},excludedNodeIds:l,anchors:n?["top","left"]:c}}function ph(e,t,o){var c,d,u,p,f,h,E,g;let n=t.find(y=>y.id===e.id);if(!n)return null;let r=o(n.id);if(!r)return null;let i=r.internals.positionAbsolute.x,s=r.internals.positionAbsolute.y,a=(p=(u=(c=e.dimensions)==null?void 0:c.width)!=null?u:(d=n.measured)==null?void 0:d.width)!=null?p:0,l=(g=(E=(f=e.dimensions)==null?void 0:f.height)!=null?E:(h=n.measured)==null?void 0:h.height)!=null?g:0;return{bounds:{x:i,y:s,x2:i+a,y2:s+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function fh(e,t,o,n){return e.length>0?uh(e,o,n,!!t):t?ph(t,o,n):null}function cd(e,t,o,n){var r;e!=null&&e.dimensions&&(e.id===((r=t[0])==null?void 0:r.id)?e.dimensions[o]+=n:t.length||(e.dimensions[o]-=n))}function mh(e,t,o,n,r,i){r&&(e.forEach(s=>{s.position&&(s.position.x-=o)}),cd(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),cd(t,e,"height",n))}function Vi(){let[e,t]=(0,_t.useState)(void 0),[o,n]=(0,_t.useState)(void 0),{width:r,height:i}=(0,Ln.useStore)(g=>({width:g.width,height:g.height}),dd.shallow),s=(0,Ln.useNodesInitialized)(),a=(0,_t.useRef)(dh),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,Ln.useReactFlow)(),u=(0,_t.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,_t.useCallback)(g=>{let y=g!=null?g:d();u();let m=sd(y,Zo,c);a.current.initialize(m)},[c,u,d]),f=(0,_t.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,_t.useEffect)(()=>{s&&p(d())},[s,p,d]);let h=(0,_t.useCallback)((g,y)=>{if(!a.current||g.length===0)return;let m=g.filter(A=>A.type==="dimensions");if(m.length>1)return;u();let x=g.filter(A=>A.type==="position"&&!!A.position),T=m[0];if(x.length===0&&!T)return;let b=fh(x,T,y,c);if(!b)return;let{x:I,y:v}=l({x:0,y:0}),{x:N,y:S}=l({x:r,y:i}),M={x:I,y:v,x2:N,y2:S},{horizontal:L,vertical:k}=ad(a.current,M,b.bounds,b.excludedNodeIds,b.anchors),{deltaX:O,deltaY:G,snappedX:Y,snappedY:j}=ld(b.bounds,L,k);if(!Y&&!j)return;let q=x.some(A=>A.dragging),U=!!(T!=null&&T.resizing);(q||U)&&(Y&&n(k==null?void 0:k.line),j&&t(L==null?void 0:L.line)),mh(x,T,O,G,Y,j)},[l,c,r,i,t,n,u]),E=(0,_t.useCallback)(()=>(0,ud.jsx)(pd,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:f,updateHelperLines:h,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var gs=require("@xyflow/react"),ro=require("react");var mo=e=>new Map(e.map(t=>[t.id,t])),Tr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),fd=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),js=e=>e.some(t=>t.type==="START_EVENT"),kn=(e,t)=>e==="START_EVENT"?!js(t):!0,md=(e,t,o,n,r)=>{let i=mo(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Tr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},gd=(e,t,o,n,r)=>{let i=mo(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:fd(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Hi=(e,t,o,n,r)=>{var c;let i=mo(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Tr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},hd=(e,t,o)=>{var s,a,l,c;let n=mo(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.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"},Gi=(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"},yd=(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"},vr=(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)==="SERVICE_TASK"},Bi=(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"},Jo=(e,t,o,n)=>{let r=mo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:fd(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},Nr=(e,t,o,n)=>{let r=mo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Tr(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},xd=(e,t,o,n,r)=>{let i=mo(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?Nr(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?Jo(e,o,n,r):!1},zi=(e,t,o)=>Tr(e,t,o).length>0,Yi=(e,t,o,n,r)=>{let i=mo(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Tr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Ed=(e,t,o,n,r)=>{var a,l;let i=mo(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var gh=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Ed(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!md(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!gd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Hi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Yi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:hd(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"&&yd(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&vr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(vr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"service_task_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(Gi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Bi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Jo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!xd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Nr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(zi(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"})],ea=e=>{for(let t of gh){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var hh=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Hi(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:js(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Gi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Bi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:vr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Jo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Nr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:zi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Yi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],_d=e=>{let t=hh.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 Bt=require("@xyflow/react");var bd=require("react"),Td=require("@xyflow/react");function qt(){return(0,Td.useStore)((0,bd.useCallback)(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}var Zt=require("@produto-lecom/lecom-ui"),vd=require("lucide-react");var Lt=require("@xyflow/react");var Fi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Lt.useReactFlow)(),{selectElements:r}=$t(),i=g=>{let y=o(),m=n(),x=(0,Lt.getIncomers)(g,y,m),T=(0,Lt.getOutgoers)(g,y,m),b=x.some(v=>v.type==="START_EVENT"),I=T.some(v=>v.type==="END_EVENT");return b?"start":I?"end":"between"},s=(g,y,m)=>{var b,I,v,N,S;if(!g)return;let x={type:g.type,variant:(b=g.data)==null?void 0:b.variant,attribute:(I=g.data)==null?void 0:I.attribute},T={id:g.id,position:i(g),label:(v=g.data)==null?void 0:v.label,node:x};return g.type==="TASK"&&((N=g.data)==null?void 0:N.variant)==="SUBPROCESS"?w(_({},T),{type:"sub_process"}):g.type==="TASK"&&((S=g.data)==null?void 0:S.variant)==="SERVICE_TASK"?w(_({},T),{type:"service_task"}):g.type==="GATEWAY"?w(_({},T),{type:"gateway",variant:a(g,y,m)}):w(_({},T),{type:"activity"})},a=(g,y,m)=>{if(g.type!=="GATEWAY")return;let x=(0,Lt.getIncomers)(g,y,m),T=!1,b=!1;if(x.forEach(I=>{var v,N;I.type==="TASK"&&(((v=I.data)==null?void 0:v.variant)==="SCRIPT"&&(T=!0),((N=I.data)==null?void 0:N.attribute)==="LOOP"&&(b=!0))}),T&&b)return"script_loop";if(T)return"script";if(b)return"loop"},l=(g,y,m)=>{var v,N,S,M,L;let x=e(g.source),T=e(g.target);if(!x||!T)return"simple";if((0,Lt.getOutgoers)(x,y,m).some(k=>k.type==="END_EVENT"))return"final";if(x.type==="GATEWAY")switch((v=x.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(x.type==="TASK"){let k=(N=x.data)==null?void 0:N.variant,O=(S=x.data)==null?void 0:S.attribute;if(k==="SUBPROCESS")return"from_sub_process";if(k==="SERVICE_TASK")return"from_service_task";if(T.type==="TASK"&&((M=T.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(T.type==="TASK"&&((L=T.data)==null?void 0:L.variant)==="SERVICE_TASK")return"to_service_task";let G=k==="SCRIPT",Y=O==="LOOP";return G&&Y?"script_loop":G?"script":Y?"loop":"simple"}return"simple"},c=(g,y,m)=>{let x=[];function T(I,v,N=0){let S=s(I,y,m);if(S.depth=N,v.push(S),I.type==="TASK"){x.push([...v]),v.pop();return}let M=(0,Lt.getIncomers)(I,y,m);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let b=(0,Lt.getIncomers)(g,y,m);for(let I of b)T(I,[]);return x},d=(g,y,m)=>{let x=[];function T(I,v,N=0){let S=s(I,y,m);if(S.depth=N,v.push(S),I.type==="TASK"){x.push([...v]),v.pop();return}let M=(0,Lt.getOutgoers)(I,y,m);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let b=(0,Lt.getOutgoers)(g,y,m);for(let I of b)T(I,[]);return x},u=(g,y,m)=>(m=m.filter(T=>T.source===g.id),m.map(T=>{var v;let b=e(T.target),I;return b&&(I=s(b,y,m)),{id:T.id,type:"routing",variant:l(T,y,m),label:(v=T.data)==null?void 0:v.label,target:I}})),p=g=>{let y=e(g);if(!y)return;let m=o(),x=n(),T=s(y,m,x);return T.sources=c(y,m,x),T.targets=d(y,m,x),T.edgeTargets=u(y,m,x),y.type==="GATEWAY"&&(T.variant=a(y,m,x)),T},f=g=>{let y=t(g);if(!y)return;let m=o(),x=n(),T=l(y,m,x),I={id:y.id,type:"routing",variant:T,gatewayVariant:void 0},v=e(y.source);if(v){let S=s(v,m,x);I.source=S;let M=a(v,m,x);if(I.gatewayVariant=M,v.type==="TASK")I.sources=[[S]];else{let L=c(v,m,x);I.sources=L.length?L:[[S]]}}let N=e(y.target);if(N){let S=s(N,m,x);if(I.target=S,N.type==="TASK")I.targets=[[S]];else{let M=d(N,m,x);I.targets=M.length?M:[[S]]}}return I},h=g=>{let y=e(g);if(y)return p(y.id);let m=t(g);if(m)return f(m.id)};return{configureElement:g=>{let y=h(g);if(y)return r([g]),y},getConfigureElement:h,getNodeConfigure:p,getEdgeConfigure:f}};var Qo=require("react/jsx-runtime"),yh={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},Co=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Zt.useTranslation)(),{onConfigureElement:n}=K(),{getConfigureElement:r}=Fi();return(0,Qo.jsxs)(Zt.Tooltip,{children:[(0,Qo.jsx)(Zt.TooltipTrigger,{asChild:!0,children:(0,Qo.jsx)(Zt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:(0,Qo.jsx)(vd.Settings,{size:16})})}),(0,Qo.jsx)(Zt.TooltipContent,{color:"black",children:o(yh[t])})]})};var Jt=require("@produto-lecom/lecom-ui"),wd=require("@xyflow/react"),Id=require("lucide-react");var Nd=require("@produto-lecom/lecom-ui");function et(){let{toast:e}=Rn(),{toast:t}=(0,Nd.useNotificationToast)();return{toast:e||t}}var jo=require("react/jsx-runtime"),Wi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Jt.useTranslation)(),{toast:n}=et(),{deleteElements:r,getNodes:i}=(0,wd.useReactFlow)(),{isRemovingElements:s}=K();return(0,jo.jsxs)(Jt.Tooltip,{children:[(0,jo.jsx)(Jt.TooltipTrigger,{asChild:!0,children:(0,jo.jsx)(Jt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(!s)if(t==="node"){let l=i(),c=l.find(d=>d.id===e);if((c==null?void 0:c.type)==="LANE"&&l.some(u=>u.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},disabled:s,children:(0,jo.jsx)(Id.TrashIcon,{size:16})})}),(0,jo.jsx)(Jt.TooltipContent,{color:"black",children:o(s?"editor.toolbar.deleting":"editor.toolbar.delete")})]})};var Qt=require("@produto-lecom/lecom-ui"),Ad=require("lucide-react"),Cd=require("react"),en=require("react/jsx-runtime"),Dn=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,Qt.useTranslation)(),r=(0,Cd.useCallback)(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,f)=>{let h=p.getBoundingClientRect(),E=f.getBoundingClientRect(),g=Math.hypot(i.clientX-(h.left+h.width/2),i.clientY-(h.top+h.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<g?f:p}),l=a.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});a.dispatchEvent(u)},[e]);return(0,en.jsxs)(Qt.Tooltip,{children:[(0,en.jsx)(Qt.TooltipTrigger,{asChild:!0,children:(0,en.jsx)(Qt.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,en.jsx)(Ad.MoveUpRightIcon,{size:16})})}),(0,en.jsx)(Qt.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var On=require("react/jsx-runtime"),Vn=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Ut(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=K(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=ri(o,n),p=!l&&!c&&!d&&!u,f=[{component:(0,On.jsx)(Wi,{elementId:e,elementType:"edge"})}],h=()=>a==="view"?p?[{component:(0,On.jsx)(Co,{elementId:e,elementType:"edge"})}]:[]:p?[{component:(0,On.jsx)(Co,{elementId:e,elementType:"edge"})},...f]:f,g=(y=>{switch(y){case"SEQUENCE_EDGE":return h();case"MESSAGE_EDGE":return a==="view"?[]:[...f];case"ANNOTATION_EDGE":return a==="view"?[]:[...f];default:return[]}})(t);if(!(g.length===0||a==="readonly"))return(0,On.jsx)("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((y,m)=>(0,On.jsx)("div",{children:y.component},m))}))};var Sd=require("@xyflow/react"),Md=require("react");var ta=require("react/jsx-runtime"),jt=12,Hn=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=(0,Sd.useViewport)(),a=1/s,l=(0,Md.useMemo)(()=>t===n?{bottom:`${jt}px`,transform:"translateX(-50%)"}:e===o?{left:`${jt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${jt}px`,bottom:`${jt}px`}:n>t&&o<e?{right:`${jt}px`,bottom:`${jt}px`}:t>n&&o>e?{right:`${jt}px`,bottom:`${jt}px`}:{left:`${jt}px`,bottom:`${jt}px`},[e,t,o,n,r]);return(0,ta.jsx)("div",{style:{transform:`scale(${a})`},children:(0,ta.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var eo=require("react/jsx-runtime"),Gn={type:"ANNOTATION_EDGE",reconnectable:!0},Pd=({id:e,source:t,target:o,selected:n,data:r})=>{let{isReadOnly:i,edgeHighlight:s}=K(),a=qt(),{zoom:l}=(0,Bt.useViewport)(),c=(0,Bt.useInternalNode)(t),d=(0,Bt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:p,tx:f,ty:h}=An(c,d),[E,g,y]=(0,Bt.getStraightPath)({sourceX:u,sourceY:p,targetX:f,targetY:h}),m=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,eo.jsxs)("g",{className:H("group bpmn-edge",{"is-highlighted":m}),children:[(0,eo.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,eo.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":m}),children:[(0,eo.jsx)(Bt.BaseEdge,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":m&&!(r!=null&&r.hasError)})}),(0,eo.jsx)(Bt.EdgeLabelRenderer,{children:(0,eo.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${y}px)`},children:n&&!a&&(0,eo.jsx)(Hn,{sx:u,sy:p,tx:f,ty:h,children:(0,eo.jsx)(Vn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};var Be=tr(require("react"),1),Me=require("@xyflow/react");var zt=require("react");var na=require("react/jsx-runtime"),oa=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Ld=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],st=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,zt.useRef)(null),p=(0,zt.useRef)(null),[f,h]=(0,zt.useState)(!1);(0,zt.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,zt.useEffect)(()=>{h(i!=null?i:!1)},[i]),(0,zt.useEffect)(()=>{if(f&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let I=window.getSelection();I&&(I.removeAllRanges(),I.addRange(b))}},[f]);let E=(0,zt.useCallback)(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),g=b=>{b.stopPropagation(),f||h(!0)},y=b=>{let I=b.currentTarget.innerText.replace(/\n$/,""),v=t&&I.length>=t,N=window.getSelection(),S=(N==null?void 0:N.toString())||"",M=S.length>0,L=(b.ctrlKey||b.metaKey)&&!b.altKey,k=L&&b.key==="a",O=L&&b.key==="c",G=L&&b.key==="x",Y=L&&b.key==="v",j=I.length===0||M&&S.length===I.length;if(!d&&j&&!oa.test(b.key)&&!Ld.includes(b.key)&&!L){b.preventDefault(),E();return}v&&!M&&(Ld.includes(b.key)||k||O||G||Y||b.preventDefault())},m=b=>{b.preventDefault();let I=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
1
+ "use strict";var Bf=Object.create;var tr=Object.defineProperty,zf=Object.defineProperties,Yf=Object.getOwnPropertyDescriptor,Ff=Object.getOwnPropertyDescriptors,Wf=Object.getOwnPropertyNames,$r=Object.getOwnPropertySymbols,Xf=Object.getPrototypeOf,Ms=Object.prototype.hasOwnProperty,Ya=Object.prototype.propertyIsEnumerable;var za=(e,t,o)=>t in e?tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,_=(e,t)=>{for(var o in t||(t={}))Ms.call(t,o)&&za(e,o,t[o]);if($r)for(var o of $r(t))Ya.call(t,o)&&za(e,o,t[o]);return e},w=(e,t)=>zf(e,Ff(t));var Ut=(e,t)=>{var o={};for(var n in e)Ms.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&$r)for(var n of $r(e))t.indexOf(n)<0&&Ya.call(e,n)&&(o[n]=e[n]);return o};var Uf=(e,t)=>{for(var o in t)tr(e,o,{get:t[o],enumerable:!0})},Fa=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Wf(t))!Ms.call(e,r)&&r!==o&&tr(e,r,{get:()=>t[r],enumerable:!(n=Yf(t,r))||n.enumerable});return e};var or=(e,t,o)=>(o=e!=null?Bf(Xf(e)):{},Fa(t||!e||!e.__esModule?tr(o,"default",{value:e,enumerable:!0}):o,e)),$f=e=>Fa(tr({},"__esModule",{value:!0}),e);var jy={};Uf(jy,{EditorMode:()=>Ge,ElementPosition:()=>qr,ElementType:()=>nr,GatewayElementVariant:()=>Zr,GatewayVariant:()=>Et,Modeler:()=>Gf,ModelerProvider:()=>Df,NodeAttribute:()=>Ht,NodeType:()=>re,NodeVariant:()=>ft,RoutingVariant:()=>Jr,useModeler:()=>Dn});module.exports=$f(jy);var Ps=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 Kr=require("@produto-lecom/lecom-ui");var Wa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Delete",deleting:"Deleting...",configure_node:"Configure activity",configure_edge:"Configure routing",configure_gateway:"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",start_event_to_service_task_not_allowed:"Start event cannot connect to an automatic activity",service_task_to_end_not_allowed:"Automatic activities cannot connect to the end event",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.",delete_elements_blocked:"One or more activities cannot be deleted because there are in-progress processes in the Workspace linked to them.",delete_elements_error:"An error occurred. Please try again later."},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",check_loading:"Validating diagram...",export:{title:"Export diagram",print:"Print",html:"Export as HTML",png:"Export as PNG",feedback:{empty:"Cannot export an empty diagram",error:"Error exporting diagram"}},import_governance:"Import diagram from Governance platform",import_mermaid:"Import Mermaid",import:{title:"Import",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"Could not import the file. Check its content."}},organize:{title:"Align diagram",vertical:"Vertical (top-down)",horizontal:"Horizontal (left-right)",feedback:{pool_lane:"Diagrams with pools or lanes cannot be arranged automatically."}},minimap:{label:"Minimap",open:"Open minimap",close:"Hide minimap"}},history:{undo:"Undo",redo:"Redo"}},modals:{mermaid_import:{title:"Import diagram from Mermaid",description:"Paste the Mermaid text (in the format supported by the modeler) to generate the diagram.",generate:"Generate",cancel:"Cancel",error_empty:"Paste the diagram text before generating.",error_parse:"Could not generate the diagram. Check the pasted text."},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_not_allowed_when_service_task:"Cannot create loop on automatic activity",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:"One or more gateways do 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_not_configured:"The subprocess reference is not properly configured in one or more activities",cannot_validate_subprocess_reference:"Could not validate the subprocess reference in one or more activities",start_event_not_found:"A start event is required",end_event_not_found:"At least one end event is required",service_task_without_rejection_routing:"Automated activity (RPA) without rejection routing configured",service_task_without_automation:"Automated activity (RPA) without a configured robot",service_task_connector_inactive:"Automated activity (RPA) linked to an inactive connector",service_task_integration_suspended:"Automated activity (RPA) linked to a suspended integration",service_task_automation_status_unavailable:"Could not verify the automation (RPA) status",service_task_initial_or_final:"Automated activity (RPA) cannot be an initial, final or concentrator step",service_task_in_loop:"Automated activity (RPA) cannot be in a loop"}},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",service_task:"RPA"},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:"Importing from the Governance platform is only allowed in diagrams without elements. To import, delete the current diagram"},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 Xa={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Eliminar",deleting:"Eliminando...",configure_node:"Configurar actividad",configure_edge:"Configurar enrutamiento",configure_gateway:"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",start_event_to_service_task_not_allowed:"El evento inicial no puede conectarse a una actividad autom\xE1tica",service_task_to_end_not_allowed:"Las actividades autom\xE1ticas no pueden conectarse al evento final",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.",delete_elements_blocked:"No se pueden eliminar una o m\xE1s actividades porque existen procesos en curso en el Workspace vinculados a ellas.",delete_elements_error:"Ocurri\xF3 un error. Int\xE9ntelo de nuevo m\xE1s tarde."},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",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"No es posible exportar un diagrama vac\xEDo",error:"Error al exportar diagrama"}},import_governance:"Importar diagrama de la plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"No fue posible importar el archivo. Verifique el contenido."}},organize:{title:"Alinear diagrama",vertical:"Vertical (de arriba hacia abajo)",horizontal:"Horizontal (de izquierda a derecha)",feedback:{pool_lane:"No es posible ordenar autom\xE1ticamente diagramas con piscinas o carriles."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Deshacer",redo:"Rehacer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Pegue el texto Mermaid (en el formato compatible con el modelador) para generar el diagrama.",generate:"Generar",cancel:"Cancelar",error_empty:"Pegue el texto del diagrama antes de generar.",error_parse:"No fue posible generar el diagrama. Verifique el texto pegado."},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_not_allowed_when_service_task:"No se puede crear bucle en actividad autom\xE1tica",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:"Una o m\xE1s compuertas no tienen 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_not_configured:"La referencia al subproceso no est\xE1 configurada correctamente en una o m\xE1s actividades",cannot_validate_subprocess_reference:"No fue posible validar la referencia al subproceso en una o m\xE1s actividades",start_event_not_found:"Es necesario tener un evento de inicio",end_event_not_found:"Es necesario tener al menos un evento final",service_task_without_rejection_routing:"Actividad autom\xE1tica (RPA) sin enrutamiento de rechazo configurado",service_task_without_automation:"Actividad autom\xE1tica (RPA) sin robot configurado",service_task_connector_inactive:"Actividad autom\xE1tica (RPA) vinculada a un conector inactivo",service_task_integration_suspended:"Actividad autom\xE1tica (RPA) vinculada a una integraci\xF3n suspendida",service_task_automation_status_unavailable:"No se pudo verificar el estado de la automatizaci\xF3n (RPA)",service_task_initial_or_final:"La actividad autom\xE1tica (RPA) no puede ser etapa inicial, final o concentradora",service_task_in_loop:"La actividad autom\xE1tica (RPA) no puede estar en un bucle"}},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",service_task:"RPA"},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:"La importaci\xF3n de la plataforma Governance solo se permite en diagramas sin elementos. Para importar, elimine el diagrama actual"},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 Ua={translations:{general:{layout:{title:"Modeler"}},editor:{toolbar:{delete:"Excluir",deleting:"Excluindo...",configure_node:"Configurar atividade",configure_edge:"Configurar roteamento",configure_gateway:"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",start_event_to_service_task_not_allowed:"Evento inicial n\xE3o pode se conectar a uma atividade autom\xE1tica",service_task_to_end_not_allowed:"Atividades autom\xE1ticas n\xE3o podem se conectar ao evento final",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.",delete_elements_blocked:"Uma ou mais atividades n\xE3o podem ser exclu\xEDdas porque existem processos em andamento no Workspace vinculados a elas.",delete_elements_error:"Ocorreu um erro. Tente novamente mais tarde."},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",check_loading:"Validando diagrama...",export:{title:"Exportar diagrama",print:"Imprimir",html:"Exportar como HTML",png:"Exportar como PNG",feedback:{empty:"N\xE3o \xE9 poss\xEDvel exportar um diagrama vazio",error:"Erro ao exportar o diagrama"}},import_governance:"Importar diagrama da plataforma Governance",import_mermaid:"Importar Mermaid",import:{title:"Importar",xml:"XML",mermaid:"Mermaid",governance:"Governance",feedback:{error:"N\xE3o foi poss\xEDvel importar o arquivo. Verifique o conte\xFAdo."}},organize:{title:"Alinhar diagrama",vertical:"Vertical (de cima para baixo)",horizontal:"Horizontal (da esquerda para a direita)",feedback:{pool_lane:"N\xE3o \xE9 poss\xEDvel ordenar automaticamente diagramas com piscinas ou raias."}},minimap:{label:"Minimapa",open:"Abrir minimapa",close:"Ocultar minimapa"}},history:{undo:"Desfazer",redo:"Refazer"}},modals:{mermaid_import:{title:"Importar diagrama a partir de Mermaid",description:"Cole o texto Mermaid (no formato suportado pelo modelador) para gerar o diagrama.",generate:"Gerar",cancel:"Cancelar",error_empty:"Cole o texto do diagrama antes de gerar.",error_parse:"N\xE3o foi poss\xEDvel gerar o diagrama. Verifique o texto colado."},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_not_allowed_when_service_task:"N\xE3o \xE9 poss\xEDvel criar loop em atividade autom\xE1tica",loop:"Atividade com loop"}},validation:{success:{title:"Diagrama validado 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:"Um ou mais gateways n\xE3o possuem 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_not_configured:"A refer\xEAncia ao subprocesso n\xE3o est\xE1 configurada corretamente em uma ou mais atividades",cannot_validate_subprocess_reference:"N\xE3o foi poss\xEDvel validar a refer\xEAncia ao subprocesso em uma ou mais atividades",start_event_not_found:"\xC9 necess\xE1rio ter um evento inicial",end_event_not_found:"\xC9 necess\xE1rio ter ao menos um evento final",service_task_without_rejection_routing:"Atividade autom\xE1tica (RPA) sem roteamento de rejei\xE7\xE3o configurado",service_task_without_automation:"Atividade autom\xE1tica (RPA) sem rob\xF4 configurado",service_task_connector_inactive:"Atividade autom\xE1tica (RPA) vinculada a um conector inativo",service_task_integration_suspended:"Atividade autom\xE1tica (RPA) vinculada a uma integra\xE7\xE3o suspensa",service_task_automation_status_unavailable:"N\xE3o foi poss\xEDvel verificar o status da automa\xE7\xE3o (RPA)",service_task_initial_or_final:"Atividade autom\xE1tica (RPA) n\xE3o pode ser etapa inicial, final ou concentradora",service_task_in_loop:"Atividade autom\xE1tica (RPA) n\xE3o pode estar em loop"}},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",service_task:"RPA"},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:"A importa\xE7\xE3o da plataforma Governance s\xF3 \xE9 permitida em diagramas sem elementos. Para importar, apague o diagrama atual"},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 $a={pt_BR:Ua,en_US:Wa,es_ES:Xa};var Ka,qa,Kf=(qa=(Ka=Ps("LecomUserLanguage"))!=null?Ka:Ps("org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"))!=null?qa:Kr.Translations.PT_BR;(0,Kr.initializeI18n)({lng:Kf,resources:$a});var Ge=(n=>(n.EDIT="edit",n.VIEW="view",n.READONLY="readonly",n))(Ge||{});var nr=(i=>(i.ACTIVITY="activity",i.ROUTING="routing",i.GATEWAY="gateway",i.SUB_PROCESS="sub_process",i.SERVICE_TASK="service_task",i))(nr||{}),qr=(n=>(n.START="start",n.END="end",n.BETWEEN="between",n))(qr||{}),Zr=(n=>(n.SCRIPT="script",n.LOOP="loop",n.SCRIPT_LOOP="script_loop",n))(Zr||{}),Jr=(p=>(p.SIMPLE="simple",p.LOOP="loop",p.SCRIPT="script",p.SCRIPT_LOOP="script_loop",p.COMPLEX="complex",p.EXCLUSIVE="exclusive",p.PARALLEL="parallel",p.FINAL="final",p.TO_SUB_PROCESS="to_sub_process",p.FROM_SUB_PROCESS="from_sub_process",p.TO_SERVICE_TASK="to_service_task",p.FROM_SERVICE_TASK="from_service_task",p))(Jr||{});var No=require("lucide-react");var Yo=require("react/jsx-runtime"),Qr=({size:e=24,className:t})=>(0,Yo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:[(0,Yo.jsx)("path",{strokeWidth:"2",d:"M16 3V3.5085V11.9998V20.4915V21H16.5411H21.4592H22V19.123H21.4592H17.9974V11.9998V4.8773H21.4592H22V3H21.4592H16.5411H16Z"}),(0,Yo.jsx)("path",{d:"M4.41026 16.9999L2 18.7861L3.89693 21.1103L6.3072 19.324L4.41026 16.9999Z"}),(0,Yo.jsx)("path",{d:"M8.41026 13.9999L6 15.7861L7.89693 18.1103L10.3072 16.324L8.41026 13.9999Z"}),(0,Yo.jsx)("path",{d:"M12.4313 10.954L10.021 12.7402L11.9179 15.0644L14.3282 13.2781L12.4313 10.954Z"})]});var Ls=require("react/jsx-runtime"),En=({size:e=24,className:t})=>(0,Ls.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,Ls.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 bo=require("react/jsx-runtime"),_n=({size:e=24,className:t})=>(0,bo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,bo.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,bo.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,bo.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,bo.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,bo.jsx)("path",{d:"M14.8281 9.17188L9.17127 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var bn=require("react/jsx-runtime"),Tn=({size:e=24,className:t})=>(0,bn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,bn.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,bn.jsx)("path",{d:"M14.8286 9.17188L9.17176 14.8287",strokeLinecap:"round",strokeLinejoin:"round"}),(0,bn.jsx)("path",{d:"M9.17139 9.17188L14.8282 14.8287",strokeLinecap:"round",strokeLinejoin:"round"})]});var vn=require("react/jsx-runtime"),Nn=({size:e=24,className:t})=>(0,vn.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,vn.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,vn.jsx)("path",{d:"M12 8V16",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vn.jsx)("path",{d:"M8 12H16",strokeLinecap:"round",strokeLinejoin:"round"})]});var wn=require("react/jsx-runtime"),Za=({size:e=24,className:t})=>(0,wn.jsx)("svg",{width:e,height:e,viewBox:"0 0 34 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",className:t,children:(0,wn.jsxs)("g",{children:[(0,wn.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,wn.jsx)("path",{d:"M24.5 4.5L28 1M28 1L31.5 4.5M28 1V8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})});var Ja=require("clsx"),Qa=require("tailwind-merge");function G(...e){return(0,Qa.twMerge)((0,Ja.clsx)(e))}var To=(e=0,t=0)=>e<t?t:e,jr=(e=1e3)=>new Promise(t=>{setTimeout(t,e)});var rr=require("react/jsx-runtime"),ja=({size:e=24,className:t})=>(0,rr.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:G("stroke-2",t),children:[(0,rr.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,rr.jsx)("path",{d:"M9 3V21",strokeLinecap:"round",strokeLinejoin:"round"})]});var ei=require("react/jsx-runtime"),el=({size:e=24,className:t})=>(0,ei.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",className:t,children:(0,ei.jsx)("g",{children:(0,ei.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 ks=require("react/jsx-runtime"),ti=({size:e=24,className:t})=>(0,ks.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,ks.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 Rs=require("react/jsx-runtime"),ir=({size:e=24,className:t})=>(0,Rs.jsx)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",className:G("stroke-2",t),children:(0,Rs.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 In=require("react/jsx-runtime"),tl=({size:e=24,className:t})=>(0,In.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,In.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,In.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,In.jsx)("path",{d:"M7.5 7.5V10H10",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"})]});var vo=require("react/jsx-runtime"),ol=({size:e=24,className:t})=>(0,vo.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,vo.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,vo.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,vo.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,vo.jsx)("path",{d:"M13.5 12H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,vo.jsx)("path",{d:"M13.5 10H11",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var Fo=require("react/jsx-runtime"),sr=({size:e=24,className:t})=>(0,Fo.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"white",stroke:"currentColor",strokeWidth:2,className:t,children:[(0,Fo.jsx)("path",{d:"M20 3H4C2.89543 3 2 4.34315 2 6V18C2 19.6569 2.89543 21 4 21H20C21.1046 21 22 19.6569 22 18V6C22 4.34315 21.1046 3 20 3Z",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Fo.jsx)("path",{d:"M8 21V14C8 13.4477 8.44772 13 9 13H15C15.5523 13 16 13.4477 16 14V21",strokeWidth:"1",fill:"none"}),(0,Fo.jsx)("path",{d:"M10.2222 17H13.7777",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),(0,Fo.jsx)("path",{d:"M12 15.2227V18.7782",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]});var re=(a=>(a.START_EVENT="START_EVENT",a.END_EVENT="END_EVENT",a.TASK="TASK",a.LANE="LANE",a.GATEWAY="GATEWAY",a.ANNOTATION="ANNOTATION",a.UNSUPPORTED="UNSUPPORTED",a))(re||{}),ft=(n=>(n.SCRIPT="SCRIPT",n.SUBPROCESS="SUBPROCESS",n.SERVICE_TASK="SERVICE_TASK",n))(ft||{}),oi={SCRIPT:{icon:No.ScrollText},SUBPROCESS:{icon:No.SquarePlus},SERVICE_TASK:{icon:No.Bot}},Ht=(t=>(t.LOOP="LOOP",t))(Ht||{}),ni={LOOP:{icon:No.RotateCcw}},Et=(n=>(n.EXCLUSIVE="EXCLUSIVE",n.PARALLEL="PARALLEL",n.COMPLEX="COMPLEX",n))(Et||{}),Ds={EXCLUSIVE:{icon:Tn},PARALLEL:{icon:Nn},COMPLEX:{icon:_n}};var Of=require("@produto-lecom/lecom-ui"),Vf=require("@xyflow/react"),Te=require("react");var lo=require("@xyflow/react"),xn=require("react");var Oo=require("@xyflow/react"),io=require("react");var An=require("@xyflow/react");function nl(e,t){var y,T,b,I;let{width:o=0,height:n=0}=e.measured||{width:0,height:0},r=e.internals.positionAbsolute,i=t.internals.positionAbsolute,s=o/2,a=n/2,l=r.x+s,c=r.y+a,d=i.x+((T=(y=t==null?void 0:t.measured)==null?void 0:y.width)!=null?T:0)/2,u=i.y+((I=(b=t==null?void 0:t.measured)==null?void 0:b.height)!=null?I:0)/2,p=(d-l)/(2*s)-(u-c)/(2*a),m=(d-l)/(2*s)+(u-c)/(2*a),x=1/(Math.abs(p)+Math.abs(m)||1),E=x*p,g=x*m,h=s*(E+g)+l,f=a*(-E+g)+c;return{x:h,y:f}}function rl(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),s=Math.round(o.y),a=Math.round(t.x),l=Math.round(t.y);return a<=i+1?An.Position.Left:a>=i+n-1?An.Position.Right:l<=s+1?An.Position.Top:l>=s+r-1?An.Position.Bottom:An.Position.Top}function Cn(e,t){let o=nl(e,t),n=nl(t,e),r=rl(e,o),i=rl(t,n);return{sx:o.x,sy:o.y,tx:n.x,ty:n.y,sourcePos:r,targetPos:i}}function ri(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",isToEndEvent:(t==null?void 0:t.type)==="END_EVENT"}}var il=require("lodash");var ii=e=>e.some(t=>t.type==="position"&&t.dragging),sl=e=>new Map(e.map(t=>[t.id,t])),al=(e,t)=>e.map(o=>{var n;return(n=t.get(o.id))!=null?n:o}),Mt=e=>{var t,o,n,r,i,s,a,l;return{x:(o=(t=e.internals)==null?void 0:t.positionAbsolute.x)!=null?o:0,y:(r=(n=e.internals)==null?void 0:n.positionAbsolute.y)!=null?r:0,w:(s=(i=e.measured)==null?void 0:i.width)!=null?s:0,h:(l=(a=e.measured)==null?void 0:a.height)!=null?l:0}},Wo=e=>(0,il.orderBy)(e,[o=>{let n=o.type==="LANE";return n&&!o.parentId?0:n?1:2}],["asc"]),ll=(e,t)=>{let{x:o,y:n}=Mt(e),{x:r,y:i}=Mt(t);return{x:o-r,y:n-i}};var Xo=({parentId:e,nodes:t,includeTypes:o=[...Object.values(re)],excludeTypes:n=[]})=>t.some(r=>r.parentId===e&&(!o.length||o.includes(r.type))&&!n.includes(r.type)),qf=(e,t)=>{let{x:o,y:n}=Mt(e),{x:r,y:i}=Mt(t),s=o-r,a=n-i;return Math.sqrt(s*s+a*a)},Zf=(e,t)=>{let{x:o,y:n,w:r,h:i}=Mt(e),{x:s,y:a,w:l,h:c}=Mt(t),d=o+r/2,u=n+i/2;return d>=s&&d<=s+l&&u>=a&&u<=a+c},ar=(e,t)=>{let o=null,n=1/0;for(let r of t)if(r.id!==e.id&&Zf(e,r)){let i=qf(e,r);i<n&&(n=i,o=r)}return o},cl=(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 dl=e=>{let t=e.filter(s=>!s.parentId);if(t.length===0)return null;let o=1/0,n=1/0,r=-1/0,i=-1/0;for(let s of t){let{position:a,width:l,height:c}=s,d=a.x+(l||0),u=a.y+(c||0);a.x<o&&(o=a.x),a.y<n&&(n=a.y),d>r&&(r=d),u>i&&(i=u)}return{x:o,y:n,w:r-o,h:i-n}},ul=({bounds:e,canvasWidth:t,canvasHeight:o,minZoom:n=.5,maxZoom:r=5,offsetX:i=0,offsetY:s=0})=>{let a=t-i*2,l=o-s*2,c=Math.min(a/e.w,l/e.h),d=Math.min(1,c),u=Math.min(Math.max(d,n),r);return{x:-e.x*u+i,y:-e.y*u+s,zoom:u}};var Os=(e,t)=>{let o=t.find(s=>s.id===e);if(!o||o.type!=="LANE"||o.parentId)return!1;let n=Mt(o),r=n.x+n.w,i=n.y+n.h;return t.some(s=>{if(s.id===e||s.parentId||s.type==="LANE")return!1;let a=Mt(s);return a.x<r&&a.x+a.w>n.x&&a.y<i&&a.y+a.h>n.y})};var fl=require("react"),ml=require("zustand");var pl=require("@xyflow/react"),$t=()=>{let e=(0,pl.useStoreApi)();return{selectElements:n=>{let{edges:r,nodes:i,triggerEdgeChanges:s,triggerNodeChanges:a}=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 a(l),s(c),!0},clearSelection:async()=>{let{unselectNodesAndEdges:n}=e.getState();return n(),await jr(),!0}}};var gl=()=>{let{selectElements:e}=$t();return(0,fl.useCallback)(()=>{let o=Uo.getState().pathEdgeIds;e(o)},[e])},Uo=(0,ml.create)((e,t)=>({statusByNodeId:{},statusData:{},pathEdgeIds:[],setTaskStatuses:o=>{o!=null&&o.length&&e(n=>{let r=_({},n.statusByNodeId),i=_({},n.statusData),s=!1;return o.forEach(a=>{let l=`${a.diagramId}-${a.activityId}`;r[a.diagramId]!==a.status&&(r[a.diagramId]=a.status,i[l]=a,s=!0)}),s?{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=[],s={};o.forEach(d=>{s[d.source]||(s[d.source]=[]),s[d.source].push({targetId:d.target,edgeId:d.id})});let a=r[0],l=r[r.length-1];o.forEach(d=>{d.target===a&&i.push(d.id)}),o.forEach(d=>{d.source===l&&i.push(d.id)});let c=(d,u)=>{let p=[],m=new Set;for(p.push({node:d,path:[]}),m.add(d);p.length>0;){let{node:x,path:E}=p.shift();if(x===u)return E;let g=s[x]||[];for(let{targetId:h,edgeId:f}of g)m.has(h)||(m.add(h),p.push({node:h,path:[...E,f]}))}return[]};for(let d=0;d<r.length-1;d++){let u=r[d],p=r[d+1],m=c(u,p);m.length>0&&i.push(...m)}i.length>0&&e({pathEdgeIds:i})}}));var kn=require("@xyflow/react"),_t=require("react"),dd=require("zustand/shallow");var Jf={value:()=>{}};function yl(){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 si(o)}function si(e){this._=e}function Qf(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}})}si.prototype=yl.prototype={constructor:si,on:function(e,t){var o=this._,n=Qf(e+"",o),r,i=-1,s=n.length;if(arguments.length<2){for(;++i<s;)if((r=(e=n[i]).type)&&(r=jf(o[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=n[i]).type)o[r]=hl(o[r],e.name,t);else if(t==null)for(r in o)o[r]=hl(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 si(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 jf(e,t){for(var o=0,n=e.length,r;o<n;++o)if((r=e[o]).name===t)return r.value}function hl(e,t,o){for(var n=0,r=e.length;n<r;++n)if(e[n].name===t){e[n]=Jf,e=e.slice(0,n).concat(e.slice(n+1));break}return o!=null&&e.push({name:t,value:o}),e}var Vs=yl;var ai="http://www.w3.org/1999/xhtml",Hs={svg:"http://www.w3.org/2000/svg",xhtml:ai,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function uo(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),Hs.hasOwnProperty(t)?{space:Hs[t],local:e}:e}function em(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===ai&&t.documentElement.namespaceURI===ai?t.createElement(e):t.createElementNS(o,e)}}function tm(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function li(e){var t=uo(e);return(t.local?tm:em)(t)}function om(){}function $o(e){return e==null?om:function(){return this.querySelector(e)}}function xl(e){typeof e!="function"&&(e=$o(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=new Array(s),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new Ze(n,this._parents)}function Gs(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function nm(){return[]}function lr(e){return e==null?nm:function(){return this.querySelectorAll(e)}}function rm(e){return function(){return Gs(e.apply(this,arguments))}}function El(e){typeof e=="function"?e=rm(e):e=lr(e);for(var t=this._groups,o=t.length,n=[],r=[],i=0;i<o;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(n.push(e.call(l,l.__data__,c,s)),r.push(l));return new Ze(n,r)}function cr(e){return function(){return this.matches(e)}}function ci(e){return function(t){return t.matches(e)}}var im=Array.prototype.find;function sm(e){return function(){return im.call(this.children,e)}}function am(){return this.firstElementChild}function _l(e){return this.select(e==null?am:sm(typeof e=="function"?e:ci(e)))}var lm=Array.prototype.filter;function cm(){return Array.from(this.children)}function dm(e){return function(){return lm.call(this.children,e)}}function bl(e){return this.selectAll(e==null?cm:dm(typeof e=="function"?e:ci(e)))}function Tl(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ze(n,this._parents)}function di(e){return new Array(e.length)}function vl(){return new Ze(this._enter||this._groups.map(di),this._parents)}function dr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}dr.prototype={constructor:dr,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 Nl(e){return function(){return e}}function um(e,t,o,n,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],n[s]=a):o[s]=new dr(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function pm(e,t,o,n,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,p=new Array(d),m;for(a=0;a<d;++a)(l=t[a])&&(p[a]=m=s.call(l,l.__data__,a,t)+"",c.has(m)?r[a]=l:c.set(m,l));for(a=0;a<u;++a)m=s.call(e,i[a],a,i)+"",(l=c.get(m))?(n[a]=l,l.__data__=i[a],c.delete(m)):o[a]=new dr(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(p[a])===l&&(r[a]=l)}function fm(e){return e.__data__}function wl(e,t){if(!arguments.length)return Array.from(this,fm);var o=t?pm:um,n=this._parents,r=this._groups;typeof e!="function"&&(e=Nl(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=n[c],u=r[c],p=u.length,m=mm(e.call(d,d&&d.__data__,c,n)),x=m.length,E=a[c]=new Array(x),g=s[c]=new Array(x),h=l[c]=new Array(p);o(d,u,E,g,h,m,t);for(var f=0,y=0,T,b;f<x;++f)if(T=E[f]){for(f>=y&&(y=f+1);!(b=g[y])&&++y<x;);T._next=b||null}}return s=new Ze(s,n),s._enter=a,s._exit=l,s}function mm(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Il(){return new Ze(this._exit||this._groups.map(di),this._parents)}function Al(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 Cl(e){for(var t=e.selection?e.selection():e,o=this._groups,n=t._groups,r=o.length,i=n.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=o[l],d=n[l],u=c.length,p=a[l]=new Array(u),m,x=0;x<u;++x)(m=c[x]||d[x])&&(p[x]=m);for(;l<r;++l)a[l]=o[l];return new Ze(a,this._parents)}function Sl(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var n=e[t],r=n.length-1,i=n[r],s;--r>=0;)(s=n[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Ml(e){e||(e=gm);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 s=o[i],a=s.length,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new Ze(r,this._parents).order()}function gm(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Pl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ll(){return Array.from(this)}function kl(){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 s=n[r];if(s)return s}return null}function Rl(){let e=0;for(let t of this)++e;return e}function Dl(){return!this.node()}function Ol(e){for(var t=this._groups,o=0,n=t.length;o<n;++o)for(var r=t[o],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function hm(e){return function(){this.removeAttribute(e)}}function ym(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xm(e,t){return function(){this.setAttribute(e,t)}}function Em(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function _m(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function bm(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 Vl(e,t){var o=uo(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?ym:hm:typeof t=="function"?o.local?bm:_m:o.local?Em:xm)(o,t))}function ui(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Tm(e){return function(){this.style.removeProperty(e)}}function vm(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Nm(e,t,o){return function(){var n=t.apply(this,arguments);n==null?this.style.removeProperty(e):this.style.setProperty(e,n,o)}}function Hl(e,t,o){return arguments.length>1?this.each((t==null?Tm:typeof t=="function"?Nm:vm)(e,t,o==null?"":o)):wo(this.node(),e)}function wo(e,t){return e.style.getPropertyValue(t)||ui(e).getComputedStyle(e,null).getPropertyValue(t)}function wm(e){return function(){delete this[e]}}function Im(e,t){return function(){this[e]=t}}function Am(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Gl(e,t){return arguments.length>1?this.each((t==null?wm:typeof t=="function"?Am:Im)(e,t)):this.node()[e]}function Bl(e){return e.trim().split(/^|\s+/)}function Bs(e){return e.classList||new zl(e)}function zl(e){this._node=e,this._names=Bl(e.getAttribute("class")||"")}zl.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 Yl(e,t){for(var o=Bs(e),n=-1,r=t.length;++n<r;)o.add(t[n])}function Fl(e,t){for(var o=Bs(e),n=-1,r=t.length;++n<r;)o.remove(t[n])}function Cm(e){return function(){Yl(this,e)}}function Sm(e){return function(){Fl(this,e)}}function Mm(e,t){return function(){(t.apply(this,arguments)?Yl:Fl)(this,e)}}function Wl(e,t){var o=Bl(e+"");if(arguments.length<2){for(var n=Bs(this.node()),r=-1,i=o.length;++r<i;)if(!n.contains(o[r]))return!1;return!0}return this.each((typeof t=="function"?Mm:t?Cm:Sm)(o,t))}function Pm(){this.textContent=""}function Lm(e){return function(){this.textContent=e}}function km(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function Xl(e){return arguments.length?this.each(e==null?Pm:(typeof e=="function"?km:Lm)(e)):this.node().textContent}function Rm(){this.innerHTML=""}function Dm(e){return function(){this.innerHTML=e}}function Om(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function Ul(e){return arguments.length?this.each(e==null?Rm:(typeof e=="function"?Om:Dm)(e)):this.node().innerHTML}function Vm(){this.nextSibling&&this.parentNode.appendChild(this)}function $l(){return this.each(Vm)}function Hm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Kl(){return this.each(Hm)}function ql(e){var t=typeof e=="function"?e:li(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Gm(){return null}function Zl(e,t){var o=typeof e=="function"?e:li(e),n=t==null?Gm:typeof t=="function"?t:$o(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),n.apply(this,arguments)||null)})}function Bm(){var e=this.parentNode;e&&e.removeChild(this)}function Jl(){return this.each(Bm)}function zm(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ym(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ql(e){return this.select(e?Ym:zm)}function jl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Fm(e){return function(t){e.call(this,t,this.__data__)}}function Wm(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 Xm(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 Um(e,t,o){return function(){var n=this.__on,r,i=Fm(t);if(n){for(var s=0,a=n.length;s<a;++s)if((r=n[s]).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 ec(e,t,o){var n=Wm(e+""),r,i=n.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=n[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Um:Xm,r=0;r<i;++r)this.each(a(n[r],t,o));return this}function tc(e,t,o){var n=ui(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 $m(e,t){return function(){return tc(this,e,t)}}function Km(e,t){return function(){return tc(this,e,t.apply(this,arguments))}}function oc(e,t){return this.each((typeof t=="function"?Km:$m)(e,t))}function*nc(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var n=e[t],r=0,i=n.length,s;r<i;++r)(s=n[r])&&(yield s)}var qm=[null];function Ze(e,t){this._groups=e,this._parents=t}function rc(){return new Ze([[document.documentElement]],qm)}function Zm(){return this}Ze.prototype=rc.prototype={constructor:Ze,select:xl,selectAll:El,selectChild:_l,selectChildren:bl,filter:Tl,data:wl,enter:vl,exit:Il,join:Al,merge:Cl,selection:Zm,order:Sl,sort:Ml,call:Pl,nodes:Ll,node:kl,size:Rl,empty:Dl,each:Ol,attr:Vl,style:Hl,property:Gl,classed:Wl,text:Xl,html:Ul,raise:$l,lower:Kl,append:ql,insert:Zl,remove:Jl,clone:Ql,datum:jl,on:ec,dispatch:oc,[Symbol.iterator]:nc};var po=rc;function pi(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function zs(e,t){var o=Object.create(e.prototype);for(var n in t)o[n]=t[n];return o}function fr(){}var ur=.7,gi=1/ur,Sn="\\s*([+-]?\\d+)\\s*",pr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Jm=/^#([0-9a-f]{3,8})$/,Qm=new RegExp(`^rgb\\(${Sn},${Sn},${Sn}\\)$`),jm=new RegExp(`^rgb\\(${Kt},${Kt},${Kt}\\)$`),eg=new RegExp(`^rgba\\(${Sn},${Sn},${Sn},${pr}\\)$`),tg=new RegExp(`^rgba\\(${Kt},${Kt},${Kt},${pr}\\)$`),og=new RegExp(`^hsl\\(${pr},${Kt},${Kt}\\)$`),ng=new RegExp(`^hsla\\(${pr},${Kt},${Kt},${pr}\\)$`),ic={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};pi(fr,Io,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sc,formatHex:sc,formatHex8:rg,formatHsl:ig,formatRgb:ac,toString:ac});function sc(){return this.rgb().formatHex()}function rg(){return this.rgb().formatHex8()}function ig(){return fc(this).formatHsl()}function ac(){return this.rgb().formatRgb()}function Io(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=Jm.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?lc(t):o===3?new mt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?fi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?fi(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=Qm.exec(e))?new mt(t[1],t[2],t[3],1):(t=jm.exec(e))?new mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=eg.exec(e))?fi(t[1],t[2],t[3],t[4]):(t=tg.exec(e))?fi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=og.exec(e))?uc(t[1],t[2]/100,t[3]/100,1):(t=ng.exec(e))?uc(t[1],t[2]/100,t[3]/100,t[4]):ic.hasOwnProperty(e)?lc(ic[e]):e==="transparent"?new mt(NaN,NaN,NaN,0):null}function lc(e){return new mt(e>>16&255,e>>8&255,e&255,1)}function fi(e,t,o,n){return n<=0&&(e=t=o=NaN),new mt(e,t,o,n)}function sg(e){return e instanceof fr||(e=Io(e)),e?(e=e.rgb(),new mt(e.r,e.g,e.b,e.opacity)):new mt}function Mn(e,t,o,n){return arguments.length===1?sg(e):new mt(e,t,o,n==null?1:n)}function mt(e,t,o,n){this.r=+e,this.g=+t,this.b=+o,this.opacity=+n}pi(mt,Mn,zs(fr,{brighter(e){return e=e==null?gi:Math.pow(gi,e),new mt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ur:Math.pow(ur,e),new mt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new mt(qo(this.r),qo(this.g),qo(this.b),hi(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:cc,formatHex:cc,formatHex8:ag,formatRgb:dc,toString:dc}));function cc(){return`#${Ko(this.r)}${Ko(this.g)}${Ko(this.b)}`}function ag(){return`#${Ko(this.r)}${Ko(this.g)}${Ko(this.b)}${Ko((isNaN(this.opacity)?1:this.opacity)*255)}`}function dc(){let e=hi(this.opacity);return`${e===1?"rgb(":"rgba("}${qo(this.r)}, ${qo(this.g)}, ${qo(this.b)}${e===1?")":`, ${e})`}`}function hi(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function qo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ko(e){return e=qo(e),(e<16?"0":"")+e.toString(16)}function uc(e,t,o,n){return n<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new Gt(e,t,o,n)}function fc(e){if(e instanceof Gt)return new Gt(e.h,e.s,e.l,e.opacity);if(e instanceof fr||(e=Io(e)),!e)return new Gt;if(e instanceof Gt)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),s=NaN,a=i-r,l=(i+r)/2;return a?(t===i?s=(o-n)/a+(o<n)*6:o===i?s=(n-t)/a+2:s=(t-o)/a+4,a/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new Gt(s,a,l,e.opacity)}function mc(e,t,o,n){return arguments.length===1?fc(e):new Gt(e,t,o,n==null?1:n)}function Gt(e,t,o,n){this.h=+e,this.s=+t,this.l=+o,this.opacity=+n}pi(Gt,mc,zs(fr,{brighter(e){return e=e==null?gi:Math.pow(gi,e),new Gt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ur:Math.pow(ur,e),new Gt(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 mt(Ys(e>=240?e-240:e+120,r,n),Ys(e,r,n),Ys(e<120?e+240:e-120,r,n),this.opacity)},clamp(){return new Gt(pc(this.h),mi(this.s),mi(this.l),hi(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=hi(this.opacity);return`${e===1?"hsl(":"hsla("}${pc(this.h)}, ${mi(this.s)*100}%, ${mi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pc(e){return e=(e||0)%360,e<0?e+360:e}function mi(e){return Math.max(0,Math.min(1,e||0))}function Ys(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 Fs(e,t,o,n,r){var i=e*e,s=i*e;return((1-3*e+3*i-s)*t+(4-6*i+3*s)*o+(1+3*e+3*i-3*s)*n+s*r)/6}function gc(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],s=n>0?e[n-1]:2*r-i,a=n<t-1?e[n+2]:2*i-r;return Fs((o-n/t)*t,s,r,i,a)}}function hc(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],s=e[(n+1)%t],a=e[(n+2)%t];return Fs((o-n/t)*t,r,i,s,a)}}var Ws=e=>()=>e;function lg(e,t){return function(o){return e+o*t}}function cg(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 yc(e){return(e=+e)==1?yi:function(t,o){return o-t?cg(t,o,e):Ws(isNaN(t)?o:t)}}function yi(e,t){var o=t-e;return o?lg(e,o):Ws(isNaN(e)?t:e)}var xi=function e(t){var o=yc(t);function n(r,i){var s=o((r=Mn(r)).r,(i=Mn(i)).r),a=o(r.g,i.g),l=o(r.b,i.b),c=yi(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return n.gamma=e,n}(1);function xc(e){return function(t){var o=t.length,n=new Array(o),r=new Array(o),i=new Array(o),s,a;for(s=0;s<o;++s)a=Mn(t[s]),n[s]=a.r||0,r[s]=a.g||0,i[s]=a.b||0;return n=e(n),r=e(r),i=e(i),a.opacity=1,function(l){return a.r=n(l),a.g=r(l),a.b=i(l),a+""}}}var dg=xc(gc),ug=xc(hc);function Pt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}var Us=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Xs=new RegExp(Us.source,"g");function pg(e){return function(){return e}}function fg(e){return function(t){return e(t)+""}}function $s(e,t){var o=Us.lastIndex=Xs.lastIndex=0,n,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(n=Us.exec(e))&&(r=Xs.exec(t));)(i=r.index)>o&&(i=t.slice(o,i),a[s]?a[s]+=i:a[++s]=i),(n=n[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,l.push({i:s,x:Pt(n,r)})),o=Xs.lastIndex;return o<t.length&&(i=t.slice(o),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?fg(l[0].x):pg(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}var Ec=180/Math.PI,Ei={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Ks(e,t,o,n,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*o+t*n)&&(o-=e*l,n-=t*l),(a=Math.sqrt(o*o+n*n))&&(o/=a,n/=a,l/=a),e*n<t*o&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ec,skewX:Math.atan(l)*Ec,scaleX:s,scaleY:a}}var _i;function _c(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ei:Ks(t.a,t.b,t.c,t.d,t.e,t.f)}function bc(e){return e==null?Ei:(_i||(_i=document.createElementNS("http://www.w3.org/2000/svg","g")),_i.setAttribute("transform",e),(e=_i.transform.baseVal.consolidate())?(e=e.matrix,Ks(e.a,e.b,e.c,e.d,e.e,e.f)):Ei)}function Tc(e,t,o,n){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,p,m,x){if(c!==u||d!==p){var E=m.push("translate(",null,t,null,o);x.push({i:E-4,x:Pt(c,u)},{i:E-2,x:Pt(d,p)})}else(u||p)&&m.push("translate("+u+t+p+o)}function s(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:Pt(c,d)})):d&&u.push(r(u)+"rotate("+d+n)}function a(c,d,u,p){c!==d?p.push({i:u.push(r(u)+"skewX(",null,n)-2,x:Pt(c,d)}):d&&u.push(r(u)+"skewX("+d+n)}function l(c,d,u,p,m,x){if(c!==u||d!==p){var E=m.push(r(m)+"scale(",null,",",null,")");x.push({i:E-4,x:Pt(c,u)},{i:E-2,x:Pt(d,p)})}else(u!==1||p!==1)&&m.push(r(m)+"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),s(c.rotate,d.rotate,u,p),a(c.skewX,d.skewX,u,p),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,p),c=d=null,function(m){for(var x=-1,E=p.length,g;++x<E;)u[(g=p[x]).i]=g.x(m);return u.join("")}}}var qs=Tc(_c,"px, ","px)","deg)"),Zs=Tc(bc,", ",")",")");var Pn=0,gr=0,mr=0,Nc=1e3,bi,hr,Ti=0,Zo=0,vi=0,yr=typeof performance=="object"&&performance.now?performance:Date,wc=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Er(){return Zo||(wc(mg),Zo=yr.now()+vi)}function mg(){Zo=0}function xr(){this._call=this._time=this._next=null}xr.prototype=Ni.prototype={constructor:xr,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Er():+o)+(t==null?0:+t),!this._next&&hr!==this&&(hr?hr._next=this:bi=this,hr=this),this._call=e,this._time=o,Js()},stop:function(){this._call&&(this._call=null,this._time=1/0,Js())}};function Ni(e,t,o){var n=new xr;return n.restart(e,t,o),n}function Ic(){Er(),++Pn;for(var e=bi,t;e;)(t=Zo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Pn}function vc(){Zo=(Ti=yr.now())+vi,Pn=gr=0;try{Ic()}finally{Pn=0,hg(),Zo=0}}function gg(){var e=yr.now(),t=e-Ti;t>Nc&&(vi-=t,Ti=e)}function hg(){for(var e,t=bi,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:bi=o);hr=e,Js(n)}function Js(e){if(!Pn){gr&&(gr=clearTimeout(gr));var t=e-Zo;t>24?(e<1/0&&(gr=setTimeout(vc,e-yr.now()-vi)),mr&&(mr=clearInterval(mr))):(mr||(Ti=yr.now(),mr=setInterval(gg,Nc)),Pn=1,wc(vc))}}function wi(e,t,o){var n=new xr;return t=t==null?0:+t,n.restart(r=>{n.stop(),e(r+t)},t,o),n}var yg=Vs("start","end","cancel","interrupt"),xg=[],Sc=0,Ac=1,Ai=2,Ii=3,Cc=4,Ci=5,_r=6;function Ao(e,t,o,n,r,i){var s=e.__transition;if(!s)e.__transition={};else if(o in s)return;Eg(e,o,{name:t,index:n,group:r,on:yg,tween:xg,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Sc})}function br(e,t){var o=Je(e,t);if(o.state>Sc)throw new Error("too late; already scheduled");return o}function ot(e,t){var o=Je(e,t);if(o.state>Ii)throw new Error("too late; already running");return o}function Je(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function Eg(e,t,o){var n=e.__transition,r;n[t]=o,o.timer=Ni(i,0,o.time);function i(c){o.state=Ac,o.timer.restart(s,o.delay,o.time),o.delay<=c&&s(c-o.delay)}function s(c){var d,u,p,m;if(o.state!==Ac)return l();for(d in n)if(m=n[d],m.name===o.name){if(m.state===Ii)return wi(s);m.state===Cc?(m.state=_r,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete n[d]):+d<t&&(m.state=_r,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete n[d])}if(wi(function(){o.state===Ii&&(o.state=Cc,o.timer.restart(a,o.delay,o.time),a(c))}),o.state=Ai,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Ai){for(o.state=Ii,r=new Array(p=o.tween.length),d=0,u=-1;d<p;++d)(m=o.tween[d].value.call(e,e.__data__,o.index,o.group))&&(r[++u]=m);r.length=u+1}}function a(c){for(var d=c<o.duration?o.ease.call(null,c/o.duration):(o.timer.restart(l),o.state=Ci,1),u=-1,p=r.length;++u<p;)r[u].call(e,d);o.state===Ci&&(o.on.call("end",e,e.__data__,o.index,o.group),l())}function l(){o.state=_r,o.timer.stop(),delete n[t];for(var c in n)return;delete e.__transition}}function Qs(e,t){var o=e.__transition,n,r,i=!0,s;if(o){t=t==null?null:t+"";for(s in o){if((n=o[s]).name!==t){i=!1;continue}r=n.state>Ai&&n.state<Ci,n.state=_r,n.timer.stop(),n.on.call(r?"interrupt":"cancel",e,e.__data__,n.index,n.group),delete o[s]}i&&delete e.__transition}}function Mc(e){return this.each(function(){Qs(this,e)})}function _g(e,t){var o,n;return function(){var r=ot(this,e),i=r.tween;if(i!==o){n=o=i;for(var s=0,a=n.length;s<a;++s)if(n[s].name===t){n=n.slice(),n.splice(s,1);break}}r.tween=n}}function bg(e,t,o){var n,r;if(typeof o!="function")throw new Error;return function(){var i=ot(this,e),s=i.tween;if(s!==n){r=(n=s).slice();for(var a={name:t,value:o},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Pc(e,t){var o=this._id;if(e+="",arguments.length<2){for(var n=Je(this.node(),o).tween,r=0,i=n.length,s;r<i;++r)if((s=n[r]).name===e)return s.value;return null}return this.each((t==null?_g:bg)(o,e,t))}function Ln(e,t,o){var n=e._id;return e.each(function(){var r=ot(this,n);(r.value||(r.value={}))[t]=o.apply(this,arguments)}),function(r){return Je(r,n).value[t]}}function Si(e,t){var o;return(typeof t=="number"?Pt:t instanceof Io?xi:(o=Io(t))?(t=o,xi):$s)(e,t)}function Tg(e){return function(){this.removeAttribute(e)}}function vg(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ng(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===n?i:i=t(n=s,o)}}function wg(e,t,o){var n,r=o+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===n?i:i=t(n=s,o)}}function Ig(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Ag(e,t,o){var n,r,i;return function(){var s,a=o(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a)))}}function Lc(e,t){var o=uo(e),n=o==="transform"?Zs:Si;return this.attrTween(e,typeof t=="function"?(o.local?Ag:Ig)(o,n,Ln(this,"attr."+e,t)):t==null?(o.local?vg:Tg)(o):(o.local?wg:Ng)(o,n,t))}function Cg(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function Sg(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function Mg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Sg(e,i)),o}return r._value=t,r}function Pg(e,t){var o,n;function r(){var i=t.apply(this,arguments);return i!==n&&(o=(n=i)&&Cg(e,i)),o}return r._value=t,r}function kc(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=uo(e);return this.tween(o,(n.local?Mg:Pg)(n,t))}function Lg(e,t){return function(){br(this,e).delay=+t.apply(this,arguments)}}function kg(e,t){return t=+t,function(){br(this,e).delay=t}}function Rc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Lg:kg)(t,e)):Je(this.node(),t).delay}function Rg(e,t){return function(){ot(this,e).duration=+t.apply(this,arguments)}}function Dg(e,t){return t=+t,function(){ot(this,e).duration=t}}function Dc(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Rg:Dg)(t,e)):Je(this.node(),t).duration}function Og(e,t){if(typeof t!="function")throw new Error;return function(){ot(this,e).ease=t}}function Oc(e){var t=this._id;return arguments.length?this.each(Og(t,e)):Je(this.node(),t).ease}function Vg(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;ot(this,e).ease=o}}function Vc(e){if(typeof e!="function")throw new Error;return this.each(Vg(this._id,e))}function Hc(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,o=t.length,n=new Array(o),r=0;r<o;++r)for(var i=t[r],s=i.length,a=n[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new at(n,this._parents,this._name,this._id)}function Gc(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),s=new Array(n),a=0;a<i;++a)for(var l=t[a],c=o[a],d=l.length,u=s[a]=new Array(d),p,m=0;m<d;++m)(p=l[m]||c[m])&&(u[m]=p);for(;a<n;++a)s[a]=t[a];return new at(s,this._parents,this._name,this._id)}function Hg(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 Gg(e,t,o){var n,r,i=Hg(t)?br:ot;return function(){var s=i(this,e),a=s.on;a!==n&&(r=(n=a).copy()).on(t,o),s.on=r}}function Bc(e,t){var o=this._id;return arguments.length<2?Je(this.node(),o).on.on(e):this.each(Gg(o,e,t))}function Bg(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function zc(){return this.on("end.remove",Bg(this._id))}function Yc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=$o(e));for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s)for(var a=n[s],l=a.length,c=i[s]=new Array(l),d,u,p=0;p<l;++p)(d=a[p])&&(u=e.call(d,d.__data__,p,a))&&("__data__"in d&&(u.__data__=d.__data__),c[p]=u,Ao(c[p],t,o,p,c,Je(d,o)));return new at(i,this._parents,t,o)}function Fc(e){var t=this._name,o=this._id;typeof e!="function"&&(e=lr(e));for(var n=this._groups,r=n.length,i=[],s=[],a=0;a<r;++a)for(var l=n[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var p=e.call(d,d.__data__,u,l),m,x=Je(d,o),E=0,g=p.length;E<g;++E)(m=p[E])&&Ao(m,t,o,E,p,x);i.push(p),s.push(d)}return new at(i,s,t,o)}var zg=po.prototype.constructor;function Wc(){return new zg(this._groups,this._parents)}function Yg(e,t){var o,n,r;return function(){var i=wo(this,e),s=(this.style.removeProperty(e),wo(this,e));return i===s?null:i===o&&s===n?r:r=t(o=i,n=s)}}function Xc(e){return function(){this.style.removeProperty(e)}}function Fg(e,t,o){var n,r=o+"",i;return function(){var s=wo(this,e);return s===r?null:s===n?i:i=t(n=s,o)}}function Wg(e,t,o){var n,r,i;return function(){var s=wo(this,e),a=o(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),wo(this,e))),s===l?null:s===n&&l===r?i:(r=l,i=t(n=s,a))}}function Xg(e,t){var o,n,r,i="style."+t,s="end."+i,a;return function(){var l=ot(this,e),c=l.on,d=l.value[i]==null?a||(a=Xc(t)):void 0;(c!==o||r!==d)&&(n=(o=c).copy()).on(s,r=d),l.on=n}}function Uc(e,t,o){var n=(e+="")=="transform"?qs:Si;return t==null?this.styleTween(e,Yg(e,n)).on("end.style."+e,Xc(e)):typeof t=="function"?this.styleTween(e,Wg(e,n,Ln(this,"style."+e,t))).each(Xg(this._id,e)):this.styleTween(e,Fg(e,n,t),o).on("end.style."+e,null)}function Ug(e,t,o){return function(n){this.style.setProperty(e,t.call(this,n),o)}}function $g(e,t,o){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Ug(e,s,o)),n}return i._value=t,i}function $c(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,$g(e,t,o==null?"":o))}function Kg(e){return function(){this.textContent=e}}function qg(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function Kc(e){return this.tween("text",typeof e=="function"?qg(Ln(this,"text",e)):Kg(e==null?"":e+""))}function Zg(e){return function(t){this.textContent=e.call(this,t)}}function Jg(e){var t,o;function n(){var r=e.apply(this,arguments);return r!==o&&(t=(o=r)&&Zg(r)),t}return n._value=e,n}function qc(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,Jg(e))}function Zc(){for(var e=this._name,t=this._id,o=Mi(),n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=Je(l,t);Ao(l,e,o,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new at(n,this._parents,e,o)}function Jc(){var e,t,o=this,n=o._id,r=o.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};o.each(function(){var c=ot(this,n),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Qg=0;function at(e,t,o,n){this._groups=e,this._parents=t,this._name=o,this._id=n}function Qc(e){return po().transition(e)}function Mi(){return++Qg}var fo=po.prototype;at.prototype=Qc.prototype={constructor:at,select:Yc,selectAll:Fc,selectChild:fo.selectChild,selectChildren:fo.selectChildren,filter:Hc,merge:Gc,selection:Wc,transition:Zc,call:fo.call,nodes:fo.nodes,node:fo.node,size:fo.size,empty:fo.empty,each:fo.each,on:Bc,attr:Lc,attrTween:kc,style:Uc,styleTween:$c,text:Kc,textTween:qc,remove:zc,tween:Pc,delay:Rc,duration:Dc,ease:Oc,easeVarying:Vc,end:Jc,[Symbol.iterator]:fo[Symbol.iterator]};function Pi(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var jg={time:null,delay:0,duration:250,ease:Pi};function eh(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 jc(e){var t,o;e instanceof at?(t=e._id,e=e._name):(t=Mi(),(o=jg).time=Er(),e=e==null?null:e+"");for(var n=this._groups,r=n.length,i=0;i<r;++i)for(var s=n[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Ao(l,e,t,c,s,o||eh(l,t));return new at(n,this._parents,e,t)}po.prototype.interrupt=Mc;po.prototype.transition=jc;function Co(e,t,o){this.k=e,this.x=t,this.y=o}Co.prototype={constructor:Co,scale:function(e){return e===1?this:new Co(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Co(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 Li=new Co(1,0,0);ki.prototype=Co.prototype;function ki(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Li;return e.__zoom}var oh=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]];var ed;(function(e){e.Strict="strict",e.Loose="loose"})(ed||(ed={}));var td;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(td||(td={}));var od;(function(e){e.Partial="partial",e.Full="full"})(od||(od={}));var nd;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(nd||(nd={}));var rd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(rd||(rd={}));var gt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(gt||(gt={}));var gT={[gt.Left]:gt.Right,[gt.Right]:gt.Left,[gt.Top]:gt.Bottom,[gt.Bottom]:gt.Top};var nh=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e);var rh=(e,t=[0,0])=>{var a;let{width:o,height:n}=ih(e),r=(a=e.origin)!=null?a:t,i=o*r[0],s=n*r[1];return{x:e.position.x-i,y:e.position.y-s}};var Ri=(e,t=[0,0])=>{var r,i,s,a,l,c,d,u;let{x:o,y:n}=nh(e)?e.internals.positionAbsolute:rh(e,t);return{x:o,y:n,x2:o+((a=(s=(i=(r=e.measured)==null?void 0:r.width)!=null?i:e.width)!=null?s:e.initialWidth)!=null?a: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 ih(e){var t,o,n,r,i,s,a,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=(a=(s=(i=e.measured)==null?void 0:i.height)!=null?s:e.height)!=null?a:e.initialHeight)!=null?l:0}}var hT={[gt.Left]:{x:-1,y:0},[gt.Right]:{x:1,y:0},[gt.Top]:{x:0,y:-1},[gt.Bottom]:{x:0,y:1}};var sh={nodeOrigin:[0,0],nodeExtent:oh,elevateNodesOnSelect:!0,defaults:{}},yT=w(_({},sh),{checkEquality:!0});var id;(function(e){e.Line="line",e.Handle="handle"})(id||(id={}));var ah={width:0,height:0,x:0,y:0},xT=w(_({},ah),{pointerX:0,pointerY:0,aspectRatio:1});var lh=(e,t)=>e.x<t.x2&&e.x2>t.x&&e.y<t.y2&&e.y2>t.y;function ch(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 dh(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 Di=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 s=t==="horizontal"?this.yLines:this.xLines,[a,l]=t==="horizontal"?[r.y,r.y2]:[r.x,r.x2],c=[];for(let m of s){if(m.position<a)continue;if(m.position>l)break;if(i.has(m.node.id)||m.node.parentId&&i.has(m.node.parentId)||!lh(m.nodeBox,r))continue;let x=Math.abs(m.position-o);if(x>Oi)continue;let g=ch(m.nodeBox,n)>0?0:dh(m.nodeBox,n);c.push({line:m,lineDist:x,nodeDist:g})}let d=.5,u=t==="horizontal"?this.lastHorizontalLine:this.lastVerticalLine;c.sort((m,x)=>{if(u){if(m.line===u&&x.line!==u)return-1;if(x.line===u&&m.line!==u)return 1}return Math.abs(m.lineDist-x.lineDist)<=d?m.nodeDist-x.nodeDist:m.lineDist-x.lineDist});let p=c.length>0?c[0].line:void 0;return p&&(t==="horizontal"?this.lastHorizontalLine=p:this.lastVerticalLine=p),p}};function sd(e,t=Jo,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 s=Ri(i);Object.entries(t).forEach(([a,l])=>{var c;n.push({position:l.resolve(r,s),color:(c=r.style)==null?void 0:c.backgroundColor,orientation:l.orientation,anchorName:a,nodeBox:s,node:r})})}),n}function ad(e,t,o,n,r=Object.keys(Jo)){let i=[];for(let a of r){let l=Jo[a],c=l.resolve(null,o),d=e.search(l.orientation,c,o,t,n);d&&i.push({sourcePosition:c,anchorName:a,anchor:l,line:d})}let s={horizontal:void 0,vertical:void 0};for(let a of i){let l=s[a.anchor.orientation],c=Math.abs(a.sourcePosition-a.line.position);(!l||c<Math.abs(l.sourcePosition-l.line.position))&&(s[a.anchor.orientation]=a)}return s}function ld(e,t,o){let n=0,r=0,i=!1,s=!1;if(t){let l=t.anchor.resolve(null,e)-t.line.position;Math.abs(l)<=Oi&&(r=l,s=!0)}if(o){let l=o.anchor.resolve(null,e)-o.line.position;Math.abs(l)<=Oi&&(n=l,i=!0)}return{deltaX:n,deltaY:r,snappedX:i,snappedY:s}}var Oi=10,Jo={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 ud=require("react/jsx-runtime"),uh=new Di;function ph(e,t,o,n){var d,u,p,m,x,E;let r=1/0,i=1/0,s=-1/0,a=-1/0,l=new Set;for(let g of e){let h=t.find(N=>N.id===g.id);if(!h)continue;l.add(h.id);let f=o(h.id);if(!f)continue;let y=f.parentId?o(f.parentId):void 0,T=g.position.x+((d=y==null?void 0:y.internals.positionAbsolute.x)!=null?d:0),b=g.position.y+((u=y==null?void 0:y.internals.positionAbsolute.y)!=null?u:0),I=(m=(p=h.measured)==null?void 0:p.width)!=null?m:0,v=(E=(x=h.measured)==null?void 0:x.height)!=null?E:0;r=Math.min(r,T),i=Math.min(i,b),s=Math.max(s,T+I),a=Math.max(a,b+v)}if(r===1/0)return null;let c=Object.keys(Jo);return{bounds:{x:r,y:i,x2:s,y2:a},excludedNodeIds:l,anchors:n?["top","left"]:c}}function fh(e,t,o){var c,d,u,p,m,x,E,g;let n=t.find(h=>h.id===e.id);if(!n)return null;let r=o(n.id);if(!r)return null;let i=r.internals.positionAbsolute.x,s=r.internals.positionAbsolute.y,a=(p=(u=(c=e.dimensions)==null?void 0:c.width)!=null?u:(d=n.measured)==null?void 0:d.width)!=null?p:0,l=(g=(E=(m=e.dimensions)==null?void 0:m.height)!=null?E:(x=n.measured)==null?void 0:x.height)!=null?g:0;return{bounds:{x:i,y:s,x2:i+a,y2:s+l},excludedNodeIds:new Set([n.id]),anchors:["right","bottom"]}}function mh(e,t,o,n){return e.length>0?ph(e,o,n,!!t):t?fh(t,o,n):null}function cd(e,t,o,n){var r;e!=null&&e.dimensions&&(e.id===((r=t[0])==null?void 0:r.id)?e.dimensions[o]+=n:t.length||(e.dimensions[o]-=n))}function gh(e,t,o,n,r,i){r&&(e.forEach(s=>{s.position&&(s.position.x-=o)}),cd(t,e,"width",o)),i&&(e.forEach(s=>{s.position&&(s.position.y-=n)}),cd(t,e,"height",n))}function Vi(){let[e,t]=(0,_t.useState)(void 0),[o,n]=(0,_t.useState)(void 0),{width:r,height:i}=(0,kn.useStore)(g=>({width:g.width,height:g.height}),dd.shallow),s=(0,kn.useNodesInitialized)(),a=(0,_t.useRef)(uh),{screenToFlowPosition:l,getInternalNode:c,getNodes:d}=(0,kn.useReactFlow)(),u=(0,_t.useCallback)(()=>{t(void 0),n(void 0)},[]),p=(0,_t.useCallback)(g=>{let h=g!=null?g:d();u();let f=sd(h,Jo,c);a.current.initialize(f)},[c,u,d]),m=(0,_t.useCallback)(()=>{setTimeout(()=>{p()},100)},[p]);(0,_t.useEffect)(()=>{s&&p(d())},[s,p,d]);let x=(0,_t.useCallback)((g,h)=>{if(!a.current||g.length===0)return;let f=g.filter(A=>A.type==="dimensions");if(f.length>1)return;u();let y=g.filter(A=>A.type==="position"&&!!A.position),T=f[0];if(y.length===0&&!T)return;let b=mh(y,T,h,c);if(!b)return;let{x:I,y:v}=l({x:0,y:0}),{x:N,y:C}=l({x:r,y:i}),M={x:I,y:v,x2:N,y2:C},{horizontal:L,vertical:R}=ad(a.current,M,b.bounds,b.excludedNodeIds,b.anchors),{deltaX:O,deltaY:V,snappedX:Y,snappedY:j}=ld(b.bounds,L,R);if(!Y&&!j)return;let q=y.some(A=>A.dragging),$=!!(T!=null&&T.resizing);(q||$)&&(Y&&n(R==null?void 0:R.line),j&&t(L==null?void 0:L.line)),gh(y,T,O,V,Y,j)},[l,c,r,i,t,n,u]),E=(0,_t.useCallback)(()=>(0,ud.jsx)(pd,{horizontal:e,vertical:o}),[e,o]);return{rebuildIndex:p,forceRebuildIndex:m,updateHelperLines:x,helperLineHorizontal:e,helperLineVertical:o,HelperLines:E}}var gs=require("@xyflow/react"),ro=require("react");var mo=e=>new Map(e.map(t=>[t.id,t])),Tr=(e,t,o)=>t.filter(n=>!(n.source!==e||o&&n.id===o)),fd=(e,t,o)=>t.filter(n=>!(n.target!==e||o&&n.id===o)),js=e=>e.some(t=>t.type==="START_EVENT"),Rn=(e,t)=>e==="START_EVENT"?!js(t):!0,md=(e,t,o,n,r)=>{let i=mo(o),s=i.get(e);if(!s||s.type!=="START_EVENT")return!1;let a=i.get(t);return(a==null?void 0:a.type)==="ANNOTATION"?!1:Tr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},gd=(e,t,o,n,r)=>{let i=mo(o),s=i.get(t);if(!s||s.type!=="END_EVENT")return!1;let a=i.get(e);return(a==null?void 0:a.type)==="ANNOTATION"?!1:fd(t,n,r).filter(c=>{let d=i.get(c.source);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=1},Hi=(e,t,o,n,r)=>{var c;let i=mo(o),s=i.get(e);if(!s||s.type!=="GATEWAY"||((c=s.data)==null?void 0:c.variant)!=="EXCLUSIVE")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Tr(e,n,r).filter(d=>{let u=i.get(d.target);return(u==null?void 0:u.type)!=="ANNOTATION"}).length>=2},hd=(e,t,o)=>{var s,a,l,c;let n=mo(o),r=n.get(e),i=n.get(t);return(r==null?void 0:r.type)!=="GATEWAY"||(i==null?void 0:i.type)!=="GATEWAY"||((s=r==null?void 0:r.data)==null?void 0:s.variant)==="EXCLUSIVE"&&((a=i==null?void 0:i.data)==null?void 0:a.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"},Gi=(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"},yd=(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"},vr=(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)==="SERVICE_TASK"},Bi=(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"},Qo=(e,t,o,n)=>{let r=mo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:fd(e,o,n).some(a=>{let l=r.get(a.source);return(l==null?void 0:l.type)==="START_EVENT"})},Nr=(e,t,o,n)=>{let r=mo(t),i=r.get(e);return!i||i.type!=="TASK"?!1:Tr(e,o,n).some(a=>{let l=r.get(a.target);return(l==null?void 0:l.type)==="END_EVENT"})},xd=(e,t,o,n,r)=>{let i=mo(o),s=i.get(e),a=i.get(t);return(s==null?void 0:s.type)==="START_EVENT"&&(a==null?void 0:a.type)==="TASK"?Nr(t,o,n,r):(a==null?void 0:a.type)==="END_EVENT"&&(s==null?void 0:s.type)==="TASK"?Qo(e,o,n,r):!1},zi=(e,t,o)=>Tr(e,t,o).length>0,Yi=(e,t,o,n,r)=>{let i=mo(o),s=i.get(e);if(!s||s.type!=="TASK")return!1;let a=t?i.get(t):null;return(a==null?void 0:a.type)==="ANNOTATION"?!1:Tr(e,n,r).filter(c=>{let d=i.get(c.target);return(d==null?void 0:d.type)!=="ANNOTATION"}).length>=2};var Ed=(e,t,o,n,r)=>{var a,l;let i=mo(n),s=((a=i.get(e))==null?void 0:a.type)==="ANNOTATION"||((l=i.get(t))==null?void 0:l.type)==="ANNOTATION";return o.some(c=>r&&c.id===r?!1:!!(c.source===e&&c.target===t||s&&c.source===t&&c.target===e))};var hh=[e=>({isValid:e.sourceNodeId!==e.targetNodeId,reason:"self_connection_not_allowed"}),e=>({isValid:!Ed(e.sourceNodeId,e.targetNodeId,e.edges,e.nodes,e.reconnectingEdgeId),reason:"duplicate_connection_not_allowed"}),e=>({isValid:!md(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"start_event_limit_reached"}),e=>({isValid:!gd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"end_event_limit_reached"}),e=>({isValid:!Hi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"gateway_limit_reached"}),e=>({isValid:!Yi(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"task_limit_reached"}),e=>({isValid:hd(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"&&yd(e.targetNodeId,e.nodes)),reason:"start_event_to_subprocess_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&vr(e.targetNodeId,e.nodes)),reason:"start_event_to_service_task_not_allowed"}),e=>({isValid:!(vr(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"service_task_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="GATEWAY"&&e.targetNodeType==="END_EVENT"),reason:"gateway_to_end_not_allowed"}),e=>({isValid:!(e.sourceNodeType==="START_EVENT"&&e.targetNodeType==="GATEWAY"),reason:"start_to_gateway_not_allowed"}),e=>({isValid:!(Gi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"script_to_end_not_allowed"}),e=>({isValid:!(Bi(e.sourceNodeId,e.nodes)&&e.targetNodeType==="END_EVENT"),reason:"loop_to_end_not_allowed"}),e=>({isValid:!(Qo(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType==="END_EVENT"),reason:"initial_activity_to_end_not_allowed"}),e=>({isValid:!xd(e.sourceNodeId,e.targetNodeId,e.nodes,e.edges,e.reconnectingEdgeId),reason:"concurrent_initial_and_final_activity"}),e=>({isValid:!(Nr(e.sourceNodeId,e.nodes,e.edges,e.reconnectingEdgeId)&&e.targetNodeType!=="ANNOTATION"),reason:"final_activity_cannot_connect"}),e=>({isValid:!(zi(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"})],ea=e=>{for(let t of hh){let o=t(e);if(!o.isValid)return o}return{isValid:!0}};var yh=[{sourceTypes:["GATEWAY"],targetTypes:["TASK","GATEWAY"],validate:e=>({shouldDisable:Hi(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:js(e.nodes),reason:"start_event_already_exists"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Gi(e.sourceNodeId,e.nodes),reason:"script_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Bi(e.sourceNodeId,e.nodes),reason:"loop_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:vr(e.sourceNodeId,e.nodes),reason:"service_task_to_end_not_allowed"})},{sourceTypes:["TASK"],targetTypes:["END_EVENT"],validate:e=>({shouldDisable:Qo(e.sourceNodeId,e.nodes,e.edges),reason:"initial_activity_to_end_not_allowed"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Nr(e.sourceNodeId,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"final_activity_cannot_connect"})},{targetTypes:["END_EVENT"],validate:e=>({shouldDisable:zi(e.sourceNodeId,e.edges),reason:"activity_has_outgoing_connections"})},{sourceTypes:["TASK"],validate:e=>({shouldDisable:Yi(e.sourceNodeId,null,e.nodes,e.edges)&&e.targetNodeType!=="ANNOTATION",reason:"task_limit_reached"})}],_d=e=>{let t=yh.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 Bt=require("@xyflow/react");var bd=require("react"),Td=require("@xyflow/react");function qt(){return(0,Td.useStore)((0,bd.useCallback)(e=>e.nodes.filter(o=>o.selected).length+e.edges.filter(o=>o.selected).length>=2,[]))}var Zt=require("@produto-lecom/lecom-ui"),vd=require("lucide-react");var Lt=require("@xyflow/react");var Fi=()=>{let{getNode:e,getEdge:t,getNodes:o,getEdges:n}=(0,Lt.useReactFlow)(),{selectElements:r}=$t(),i=g=>{let h=o(),f=n(),y=(0,Lt.getIncomers)(g,h,f),T=(0,Lt.getOutgoers)(g,h,f),b=y.some(v=>v.type==="START_EVENT"),I=T.some(v=>v.type==="END_EVENT");return b?"start":I?"end":"between"},s=(g,h,f)=>{var b,I,v,N,C;if(!g)return;let y={type:g.type,variant:(b=g.data)==null?void 0:b.variant,attribute:(I=g.data)==null?void 0:I.attribute},T={id:g.id,position:i(g),label:(v=g.data)==null?void 0:v.label,node:y};return g.type==="TASK"&&((N=g.data)==null?void 0:N.variant)==="SUBPROCESS"?w(_({},T),{type:"sub_process"}):g.type==="TASK"&&((C=g.data)==null?void 0:C.variant)==="SERVICE_TASK"?w(_({},T),{type:"service_task"}):g.type==="GATEWAY"?w(_({},T),{type:"gateway",variant:a(g,h,f)}):w(_({},T),{type:"activity"})},a=(g,h,f)=>{if(g.type!=="GATEWAY")return;let y=(0,Lt.getIncomers)(g,h,f),T=!1,b=!1;if(y.forEach(I=>{var v,N;I.type==="TASK"&&(((v=I.data)==null?void 0:v.variant)==="SCRIPT"&&(T=!0),((N=I.data)==null?void 0:N.attribute)==="LOOP"&&(b=!0))}),T&&b)return"script_loop";if(T)return"script";if(b)return"loop"},l=(g,h,f)=>{var v,N,C,M,L;let y=e(g.source),T=e(g.target);if(!y||!T)return"simple";if((0,Lt.getOutgoers)(y,h,f).some(R=>R.type==="END_EVENT"))return"final";if(y.type==="GATEWAY")switch((v=y.data)==null?void 0:v.variant){case"PARALLEL":return"parallel";case"EXCLUSIVE":return"exclusive";case"COMPLEX":return"complex";default:return"simple"}if(y.type==="TASK"){let R=(N=y.data)==null?void 0:N.variant,O=(C=y.data)==null?void 0:C.attribute;if(R==="SUBPROCESS")return"from_sub_process";if(R==="SERVICE_TASK")return"from_service_task";if(T.type==="TASK"&&((M=T.data)==null?void 0:M.variant)==="SUBPROCESS")return"to_sub_process";if(T.type==="TASK"&&((L=T.data)==null?void 0:L.variant)==="SERVICE_TASK")return"to_service_task";let V=R==="SCRIPT",Y=O==="LOOP";return V&&Y?"script_loop":V?"script":Y?"loop":"simple"}return"simple"},c=(g,h,f)=>{let y=[];function T(I,v,N=0){let C=s(I,h,f);if(C.depth=N,v.push(C),I.type==="TASK"){y.push([...v]),v.pop();return}let M=(0,Lt.getIncomers)(I,h,f);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let b=(0,Lt.getIncomers)(g,h,f);for(let I of b)T(I,[]);return y},d=(g,h,f)=>{let y=[];function T(I,v,N=0){let C=s(I,h,f);if(C.depth=N,v.push(C),I.type==="TASK"){y.push([...v]),v.pop();return}let M=(0,Lt.getOutgoers)(I,h,f);if(M.length)for(let L of M)T(L,v,N+1);v.pop()}let b=(0,Lt.getOutgoers)(g,h,f);for(let I of b)T(I,[]);return y},u=(g,h,f)=>(f=f.filter(T=>T.source===g.id),f.map(T=>{var v;let b=e(T.target),I;return b&&(I=s(b,h,f)),{id:T.id,type:"routing",variant:l(T,h,f),label:(v=T.data)==null?void 0:v.label,target:I}})),p=g=>{let h=e(g);if(!h)return;let f=o(),y=n(),T=s(h,f,y);return T.sources=c(h,f,y),T.targets=d(h,f,y),T.edgeTargets=u(h,f,y),h.type==="GATEWAY"&&(T.variant=a(h,f,y)),T},m=g=>{let h=t(g);if(!h)return;let f=o(),y=n(),T=l(h,f,y),I={id:h.id,type:"routing",variant:T,gatewayVariant:void 0},v=e(h.source);if(v){let C=s(v,f,y);I.source=C;let M=a(v,f,y);if(I.gatewayVariant=M,v.type==="TASK")I.sources=[[C]];else{let L=c(v,f,y);I.sources=L.length?L:[[C]]}}let N=e(h.target);if(N){let C=s(N,f,y);if(I.target=C,N.type==="TASK")I.targets=[[C]];else{let M=d(N,f,y);I.targets=M.length?M:[[C]]}}return I},x=g=>{let h=e(g);if(h)return p(h.id);let f=t(g);if(f)return m(f.id)};return{configureElement:g=>{let h=x(g);if(h)return r([g]),h},getConfigureElement:x,getNodeConfigure:p,getEdgeConfigure:m}};var jo=require("react/jsx-runtime"),xh={node:"editor.toolbar.configure_node",edge:"editor.toolbar.configure_edge",gateway:"editor.toolbar.configure_gateway"},So=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Zt.useTranslation)(),{onConfigureElement:n}=U(),{getConfigureElement:r}=Fi();return(0,jo.jsxs)(Zt.Tooltip,{children:[(0,jo.jsx)(Zt.TooltipTrigger,{asChild:!0,children:(0,jo.jsx)(Zt.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,onClick:()=>{let s=r(e);s&&(n==null||n(s))},children:(0,jo.jsx)(vd.Settings,{size:16})})}),(0,jo.jsx)(Zt.TooltipContent,{color:"black",children:o(xh[t])})]})};var Jt=require("@produto-lecom/lecom-ui"),wd=require("@xyflow/react"),Id=require("lucide-react");var Nd=require("@produto-lecom/lecom-ui");function et(){let{toast:e}=Dn(),{toast:t}=(0,Nd.useNotificationToast)();return{toast:e||t}}var en=require("react/jsx-runtime"),Wi=({elementId:e,elementType:t="node"})=>{let{t:o}=(0,Jt.useTranslation)(),{toast:n}=et(),{deleteElements:r,getNodes:i}=(0,wd.useReactFlow)(),{isRemovingElements:s}=U();return(0,en.jsxs)(Jt.Tooltip,{children:[(0,en.jsx)(Jt.TooltipTrigger,{asChild:!0,children:(0,en.jsx)(Jt.Button,{variant:"ghost",color:"destructive",size:"small",iconButton:!0,onClick:()=>{if(!s)if(t==="node"){let l=i(),c=l.find(d=>d.id===e);if((c==null?void 0:c.type)==="LANE"&&l.some(u=>u.parentId===e)){n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")});return}r({nodes:[{id:e}]})}else r({edges:[{id:e}]})},disabled:s,children:(0,en.jsx)(Id.TrashIcon,{size:16})})}),(0,en.jsx)(Jt.TooltipContent,{color:"black",children:o(s?"editor.toolbar.deleting":"editor.toolbar.delete")})]})};var Qt=require("@produto-lecom/lecom-ui"),Ad=require("lucide-react"),Cd=require("react"),tn=require("react/jsx-runtime"),On=({nodeId:e,disabled:t=!1,tooltipMessage:o})=>{let{t:n}=(0,Qt.useTranslation)(),r=(0,Cd.useCallback)(i=>{i.stopPropagation();let s=document.querySelectorAll(`.react-flow__handle.source[data-nodeid="${e}"]`);if(s.length===0)return;let a=Array.from(s).reduce((p,m)=>{let x=p.getBoundingClientRect(),E=m.getBoundingClientRect(),g=Math.hypot(i.clientX-(x.left+x.width/2),i.clientY-(x.top+x.height/2));return Math.hypot(i.clientX-(E.left+E.width/2),i.clientY-(E.top+E.height/2))<g?m:p}),l=a.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});a.dispatchEvent(u)},[e]);return(0,tn.jsxs)(Qt.Tooltip,{children:[(0,tn.jsx)(Qt.TooltipTrigger,{asChild:!0,children:(0,tn.jsx)(Qt.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,tn.jsx)(Ad.MoveUpRightIcon,{size:16})})}),(0,tn.jsx)(Qt.TooltipContent,{color:"black",children:o||n("editor.toolbar.connect_node")})]})};var Vn=require("react/jsx-runtime"),Hn=i=>{var s=i,{edgeId:e,edgeType:t,sourceNode:o,targetNode:n}=s,r=Ut(s,["edgeId","edgeType","sourceNode","targetNode"]);let{mode:a}=U(),{isFromStartEvent:l,isGatewayToGateway:c,isActiviyToAndGateway:d,isToEndEvent:u}=ri(o,n),p=!l&&!c&&!d&&!u,m=[{component:(0,Vn.jsx)(Wi,{elementId:e,elementType:"edge"})}],x=()=>a==="view"?p?[{component:(0,Vn.jsx)(So,{elementId:e,elementType:"edge"})}]:[]:p?[{component:(0,Vn.jsx)(So,{elementId:e,elementType:"edge"})},...m]:m,g=(h=>{switch(h){case"SEQUENCE_EDGE":return x();case"MESSAGE_EDGE":return a==="view"?[]:[...m];case"ANNOTATION_EDGE":return a==="view"?[]:[...m];default:return[]}})(t);if(!(g.length===0||a==="readonly"))return(0,Vn.jsx)("div",w(_({className:"flex items-center gap-1 w-fit px-3 py-2 bg-white rounded-sm shadow-md"},r),{children:g.map((h,f)=>(0,Vn.jsx)("div",{children:h.component},f))}))};var Sd=require("@xyflow/react"),Md=require("react");var ta=require("react/jsx-runtime"),jt=12,Gn=({sx:e,sy:t,tx:o,ty:n,hasLabel:r=!1,children:i})=>{let{zoom:s}=(0,Sd.useViewport)(),a=1/s,l=(0,Md.useMemo)(()=>t===n?{bottom:`${jt}px`,transform:"translateX(-50%)"}:e===o?{left:`${jt}px`,transform:r?"translateY(-100%)":"translateY(-50%)"}:n>t&&o>e?{left:`${jt}px`,bottom:`${jt}px`}:n>t&&o<e?{right:`${jt}px`,bottom:`${jt}px`}:t>n&&o>e?{right:`${jt}px`,bottom:`${jt}px`}:{left:`${jt}px`,bottom:`${jt}px`},[e,t,o,n,r]);return(0,ta.jsx)("div",{style:{transform:`scale(${a})`},children:(0,ta.jsx)("div",{className:"absolute pointer-events-auto",style:_({},l),children:i})})};var eo=require("react/jsx-runtime"),Bn={type:"ANNOTATION_EDGE",reconnectable:!0},Pd=({id:e,source:t,target:o,selected:n,data:r})=>{let{isReadOnly:i,edgeHighlight:s}=U(),a=qt(),{zoom:l}=(0,Bt.useViewport)(),c=(0,Bt.useInternalNode)(t),d=(0,Bt.useInternalNode)(o);if(!c||!d)return null;let{sx:u,sy:p,tx:m,ty:x}=Cn(c,d),[E,g,h]=(0,Bt.getStraightPath)({sourceX:u,sourceY:p,targetX:m,targetY:x}),f=s&&(n||(c==null?void 0:c.selected)||(d==null?void 0:d.selected));return(0,eo.jsxs)("g",{className:G("group bpmn-edge",{"is-highlighted":f}),children:[(0,eo.jsx)("path",{d:E,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/l),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,eo.jsxs)("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!i,"text-blue-500 group-hover:text-blue-600":f}),children:[(0,eo.jsx)(Bt.BaseEdge,{id:e,path:E,interactionWidth:0,strokeDasharray:4,className:G("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":r==null?void 0:r.hasError,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":f&&!(r!=null&&r.hasError)})}),(0,eo.jsx)(Bt.EdgeLabelRenderer,{children:(0,eo.jsx)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${g}px, ${h}px)`},children:n&&!a&&(0,eo.jsx)(Gn,{sx:u,sy:p,tx:m,ty:x,children:(0,eo.jsx)(Hn,{edgeId:e,edgeType:"ANNOTATION_EDGE"})})})})]})]})};var Be=or(require("react"),1),Me=require("@xyflow/react");var zt=require("react");var na=require("react/jsx-runtime"),oa=/[a-zA-Z0-9À-ÖØ-öø-ÿ]/,Ld=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab","Escape","Shift"],st=({value:e,maxLength:t,style:o,className:n,contentClassName:r,isEditing:i,onChange:s,onBlur:a,onInput:l,onInvalidFirstCharacter:c,skipFirstCharValidation:d})=>{let u=(0,zt.useRef)(null),p=(0,zt.useRef)(null),[m,x]=(0,zt.useState)(!1);(0,zt.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,zt.useEffect)(()=>{x(i!=null?i:!1)},[i]),(0,zt.useEffect)(()=>{if(m&&u.current){u.current.focus();let b=document.createRange();b.selectNodeContents(u.current);let I=window.getSelection();I&&(I.removeAllRanges(),I.addRange(b))}},[m]);let E=(0,zt.useCallback)(()=>{p.current||(c==null||c(),p.current=setTimeout(()=>{p.current=null},500))},[c]),g=b=>{b.stopPropagation(),m||x(!0)},h=b=>{let I=b.currentTarget.innerText.replace(/\n$/,""),v=t&&I.length>=t,N=window.getSelection(),C=(N==null?void 0:N.toString())||"",M=C.length>0,L=(b.ctrlKey||b.metaKey)&&!b.altKey,R=L&&b.key==="a",O=L&&b.key==="c",V=L&&b.key==="x",Y=L&&b.key==="v",j=I.length===0||M&&C.length===I.length;if(!d&&j&&!oa.test(b.key)&&!Ld.includes(b.key)&&!L){b.preventDefault(),E();return}v&&!M&&(Ld.includes(b.key)||R||O||V||Y||b.preventDefault())},f=b=>{b.preventDefault();let I=b.clipboardData.getData("text/plain").replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
- `),v=b.currentTarget.innerText.replace(/\n$/,""),N=window.getSelection();if(!N||N.rangeCount===0)return;let S=N.toString(),M=v.length-S.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&S.length===0)return;let k=I;if(k.length>L&&(k=k.substring(0,L)),!k&&S.length===0)return;let O=N.getRangeAt(0),G=O.startOffset===0&&(O.startContainer===b.currentTarget||O.startContainer.parentNode===b.currentTarget);if(!d&&G&&k.length>0&&!oa.test(k[0])){E();return}O.deleteContents();let Y=document.createTextNode(k);O.insertNode(Y),O.setStartAfter(Y),O.collapse(!0),N.removeAllRanges(),N.addRange(O),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},x=b=>{let I=b.currentTarget,v=I.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!oa.test(v[0])){let N=v.slice(1);if(I.innerText=N,N.length>0&&I.firstChild){let S=document.createRange(),M=window.getSelection();S.setStart(I.firstChild,0),S.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(S)}E(),l==null||l(N);return}l==null||l(v)},T=b=>{h(!1);let I=b.currentTarget.innerText.replace(/\r\n/g,`
3
+ `),v=b.currentTarget.innerText.replace(/\n$/,""),N=window.getSelection();if(!N||N.rangeCount===0)return;let C=N.toString(),M=v.length-C.length,L=t?Math.max(0,t-M):1/0;if(L<=0&&C.length===0)return;let R=I;if(R.length>L&&(R=R.substring(0,L)),!R&&C.length===0)return;let O=N.getRangeAt(0),V=O.startOffset===0&&(O.startContainer===b.currentTarget||O.startContainer.parentNode===b.currentTarget);if(!d&&V&&R.length>0&&!oa.test(R[0])){E();return}O.deleteContents();let Y=document.createTextNode(R);O.insertNode(Y),O.setStartAfter(Y),O.collapse(!0),N.removeAllRanges(),N.addRange(O),l==null||l(b.currentTarget.innerText.replace(/\n$/,""))},y=b=>{let I=b.currentTarget,v=I.innerText.replace(/\n$/,"");if(!d&&v.length>0&&!oa.test(v[0])){let N=v.slice(1);if(I.innerText=N,N.length>0&&I.firstChild){let C=document.createRange(),M=window.getSelection();C.setStart(I.firstChild,0),C.collapse(!0),M==null||M.removeAllRanges(),M==null||M.addRange(C)}E(),l==null||l(N);return}l==null||l(v)},T=b=>{x(!1);let I=b.currentTarget.innerText.replace(/\r\n/g,`
4
4
  `).replace(/\r/g,`
5
- `).trim();t&&I.length>t&&(I=I.substring(0,t)),b.currentTarget.innerText=I,a==null||a(),I!==e&&(s==null||s(I))};return(0,na.jsx)("div",{className:H("flex-1 p-2 self-stretch flex items-center justify-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":f,"bg-white":e.length>0},n),style:o,onDoubleClick:g,children:(0,na.jsx)("div",{ref:u,className:H("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":f}),contentEditable:f,suppressContentEditableWarning:!0,onKeyDown:y,onPaste:m,onInput:x,onBlur:T,children:e})})};var xh=require("@xyflow/react");var ge=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,Bn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Xi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Eh=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return Bn(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return Bn(e,{x:t.x+s*n,y:t.y+s*r})},kd=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,Eh(e,t[n],t[n+1]));return o};var wr=require("@xyflow/react");var So={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=So;function _h(e,t,o){return ge(e,t,"x",ce)&&ge(t,o,"x",ce)&&ge(e,o,"x",ce)}function bh(e,t,o){return ge(e,t,"y",ce)&&ge(t,o,"y",ce)&&ge(e,o,"y",ce)}function Th(e,t,o){if(!_h(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function vh(e,t,o){if(!bh(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Nh(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,s=t.x===n.x&&t.y===n.y,a=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<a?Math.max(e.y,o.y)+a:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<a?Math.max(e.x,o.x)+a:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(s)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<a){let l=Math.max(e.y,o.y)+a,c=o.x+t.x*(a/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<a){let l=Math.max(e.x,o.x)+a,c=o.y+t.y*(a/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function Rd(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ge(n,r,"x",ce)&&ge(r,i,"x",ce)||ge(n,r,"y",ce)&&ge(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Ui(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function wh(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],s=t[n+1];if(Th(r,i,s)||vh(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function Dd(e){let t=Ui(Rd([...e]));return t=wh(t),Ui(Rd(t))}function $i(e){switch(e){case wr.Position.Left:return{x:-1,y:0};case wr.Position.Right:return{x:1,y:0};case wr.Position.Top:return{x:0,y:-1};case wr.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Od(e,t,o,n){let r=So.OFFSET,i=So.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let s=(o.x-e.x)*t.x;s>0&&s<2*So.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*So.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Ih(e,t,o,n,r,i,s=0){let a=$i(r),l=$i(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,p=l.y===0?s:0,f={x:e+c,y:t+d},h={x:o+u,y:n+p},{sourceOffset:E,targetOffset:g}=Od(f,a,h,l),y={x:f.x+a.x*E,y:f.y+a.y*E},m={x:h.x+l.x*g,y:h.y+l.y*g},x=Nh(y,a,m,l),T=[f,y,...x,m,h],b=Dd(T);if(b.length===2&&Ki(f,h)>ce){let I=ge(f,y,"x",ce)&&ge(y,m,"x",ce)&&ge(m,h,"x",ce),v=ge(f,y,"y",ce)&&ge(y,m,"y",ce)&&ge(m,h,"y",ce);if(I||v){let N=v&&(m.x-y.x)*a.x<0,S=I&&(m.y-y.y)*a.y<0;if(!N&&!S)return Ui([f,y,m,h])}}return b}function qi(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Ih(e,t,o,n,r,i,a);let l=$i(r),c=$i(i),d=l.x===0?a:0,u=l.y===0?a:0,p=c.x===0?a:0,f=c.y===0?a:0,h={x:e+d,y:t+u},E={x:o+p,y:n+f},{sourceOffset:g,targetOffset:y}=Od(h,l,E,c),m={x:h.x+l.x*g,y:h.y+l.y*g},x={x:E.x+c.x*y,y:E.y+c.y*y},T=[...s],b=T[0],I=l.y===0;I&&Math.abs(h.y-b.y)>ce?T.unshift({x:b.x,y:h.y}):!I&&Math.abs(h.x-b.x)>ce&&T.unshift({x:h.x,y:b.y});let v=T[T.length-1],N=c.y===0,S=[];(Math.abs(v.x-x.x)>ce||Math.abs(v.y-x.y)>ce)&&(N?S.push({x:x.x,y:v.y}):S.push({x:v.x,y:x.y})),S.push(x);let M=[h,...T,...S,E],L=Dd(M);if(L.length===2&&Ki(h,E)>ce){let k=ge(h,m,"x",ce)&&ge(m,x,"x",ce)&&ge(x,E,"x",ce),O=ge(h,m,"y",ce)&&ge(m,x,"y",ce)&&ge(x,E,"y",ce);if(k||O){let G=O&&(x.x-m.x)*l.x<0,Y=k&&(x.y-m.y)*l.y<0;if(!G&&!Y)return Ui([h,m,x,E])}}return L}var Ki=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ah(e,t,o){return ge(e,t,"x",ce)&&ge(t,o,"x",ce)||ge(e,t,"y",ce)&&ge(t,o,"y",ce)}function Ch(e,t,o,n){if(Ah(e,t,o))return`L${t.x} ${t.y}`;let r=Ki(e,t),i=Ki(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},p={x:c/i,y:d/i},f={x:t.x+u.x*s,y:t.y+u.y*s},h={x:t.x+p.x*s,y:t.y+p.y*s},E=-u.x,g=-u.y,y=p.x,m=p.y,T=E*m-g*y>0?1:0;return`L${f.x} ${f.y}A${s} ${s} 0 0 ${T} ${h.x} ${h.y}`}var Vd=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Ch(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var Te=require("react"),Zi=require("@xyflow/react");var Sh=50,Hd=.1,Mh=.6,Ji=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=(0,Zi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=K(),p=(0,Zi.useStore)(P=>P.isValidConnection),[f,h]=(0,Te.useState)(null),[E,g]=(0,Te.useState)(null),[y,m]=(0,Te.useState)(null),[x,T]=(0,Te.useState)(null),[b,I]=(0,Te.useState)(null),[v,N]=(0,Te.useState)(!1),S=(0,Te.useRef)(null),M=(0,Te.useRef)(null),L=(0,Te.useRef)(null),k=(0,Te.useRef)(t),O=(0,Te.useRef)(o);(0,Te.useEffect)(()=>{k.current=t,O.current=o},[t,o]),(0,Te.useEffect)(()=>{S.current=f},[f]),(0,Te.useEffect)(()=>{M.current=b},[b]);let G=(0,Te.useCallback)(P=>{let R=a(),C=R.find(V=>V.id===P);if(!C)return{x:0,y:0};let B=C.position.x,F=C.position.y,D=C.parentId;for(;D;){let V=R.find(z=>z.id===D);if(!V)break;B+=V.position.x,F+=V.position.y,D=V.parentId}return{x:B,y:F}},[a]),Y=(0,Te.useCallback)(P=>{var D,V,z,$,Z,W;let R=a(),C=null,B=Sh,F=R.filter(X=>X.type!=="LANE"&&X.type!=="ANNOTATION");for(let X of F){if(X.id===e)continue;let Q=G(X.id),ee=(z=(V=(D=X.measured)==null?void 0:D.width)!=null?V:X.width)!=null?z:0,te=(W=(Z=($=X.measured)==null?void 0:$.height)!=null?Z:X.height)!=null?W:0;if(P.x>=Q.x&&P.x<=Q.x+ee&&P.y>=Q.y&&P.y<=Q.y+te)return X.id;let pe=Math.max(Q.x-P.x,0,P.x-(Q.x+ee)),le=Math.max(Q.y-P.y,0,P.y-(Q.y+te)),Ae=Math.sqrt(pe*pe+le*le);Ae<B&&(B=Ae,C=X.id)}return C},[a,G,e]),j=(0,Te.useCallback)((P,R)=>{var pe,le,Ae,Xe,rt,J;let C=s(P);if(!C)return null;let B=G(P),F=(Ae=(le=(pe=C.measured)==null?void 0:pe.width)!=null?le:C.width)!=null?Ae:0,D=(J=(rt=(Xe=C.measured)==null?void 0:Xe.height)!=null?rt:C.height)!=null?J:0,V=Math.abs(B.x+F-R.x),z=Math.abs(R.x-B.x),$=Math.abs(B.y+D-R.y),Z=Math.abs(R.y-B.y),W={right:V,left:z,bottom:$,top:Z},X=Object.entries(W).reduce((se,[oe,ae])=>ae<se[1]?[oe,ae]:se,["right",W.right])[0],Q=L.current;if(Q&&Q!==X){let se=W[X],oe=W[Q],ae=Math.abs(oe-se),Ce=Math.min(Math.abs(oe),Math.abs(se));ae<Ce*Mh&&(X=Q)}let ee=X,te,xe;if(ee==="right"||ee==="left"){let oe=(Math.max(B.y,Math.min(B.y+D,R.y))-B.y)/(D||1);Math.abs(oe-.5)<Hd&&(oe=.5),xe=oe,te={x:ee==="right"?B.x+F:B.x,y:B.y+xe*D}}else{let oe=(Math.max(B.x,Math.min(B.x+F,R.x))-B.x)/(F||1);Math.abs(oe-.5)<Hd&&(oe=.5),xe=oe,te={x:B.x+xe*F,y:ee==="bottom"?B.y+D:B.y}}return{side:ee,snapPosition:te,offset:xe}},[s,G]),q=(0,Te.useCallback)(P=>{var z,$,Z;let R=S.current;if(!R)return;let C=c({x:P.clientX,y:P.clientY}),B=Y(C);m(B);let F=C,D=null,V=null;if(B){let W=j(B,C);W&&(D=W.side,F=W.snapPosition,V=W.offset,L.current=D);let X=l(e),Q={source:R==="source"?B:k.current,target:R==="target"?B:O.current,sourceHandle:R==="source"?D:(z=X==null?void 0:X.sourceHandle)!=null?z:null,targetHandle:R==="target"?D:($=X==null?void 0:X.targetHandle)!=null?$:null},ee=(Z=p==null?void 0:p(Q))!=null?Z:!0;N(ee)}else L.current=null,N(!1);T(D),I(V),g(F)},[Y,j,l,e,c,p]),U=(0,Te.useCallback)(P=>{var D,V,z,$,Z;let R=S.current;if(!R)return;let C=c({x:P.clientX,y:P.clientY}),B=Y(C);if(B){let W=j(B,C),X=(D=W==null?void 0:W.side)!=null?D:null,Q=(V=W==null?void 0:W.offset)!=null?V:.5,ee=l(e),te={source:R==="source"?B:k.current,target:R==="target"?B:O.current,sourceHandle:R==="source"?X:(z=ee==null?void 0:ee.sourceHandle)!=null?z:null,targetHandle:R==="target"?X:($=ee==null?void 0:ee.targetHandle)!=null?$:null};((Z=p==null?void 0:p(te))==null||Z)&&i(xe=>xe.map(pe=>{var le,Ae;return pe.id===e?w(_({},pe),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:w(_({},pe.data),{points:void 0,sourceOffset:R==="source"?Q:(le=pe.data)==null?void 0:le.sourceOffset,targetOffset:R==="target"?Q:(Ae=pe.data)==null?void 0:Ae.targetOffset})}):pe}))}h(null),g(null),m(null),T(null),I(null),d(!1),N(!1),u(null),L.current=null,document.removeEventListener("mouseup",U),document.removeEventListener("mousemove",q);let F=to.get(n);F==null||F.clearReconnectingEdge()},[e,Y,j,l,i,n,q,p,c,d,u]),A=(0,Te.useCallback)((P,R)=>{if(r||R.button!==0)return;R.stopPropagation(),R.preventDefault(),i(B=>B.map(F=>F.id===e?w(_({},F),{data:w(_({},F.data),{points:void 0})}):F)),h(P),u(e);let C=to.get(n);C==null||C.setReconnectingEdge(e),document.addEventListener("mousemove",q),document.addEventListener("mouseup",U)},[r,e,n,q,U,u,i]);return(0,Te.useEffect)(()=>()=>{if(S.current){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",U),u(null);let P=to.get(n);P==null||P.clearReconnectingEdge()}},[n,q,U,u]),{reconnectingHandle:f,cursorPosition:E,hoveredNodeId:y,reconnectingSide:x,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:A}};var me=require("react/jsx-runtime"),kt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Me.MarkerType.ArrowClosed},markerEnd:{type:Me.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Qi,MIN_SEGMENT_LENGTH:Ph,PARALLEL_OFFSET:Gd,MAX_LABEL_DISTANCE:Lh}=So;function kh(e,t,o,n,r){if(r)return 0;let i=n.filter(l=>l.source===t&&l.target===o||l.source===o&&l.target===t);if(i.length<=1){let l=n.filter(u=>u.source===t);if(l.length<=1)return 0;let c=l.findIndex(u=>u.id===e);if(c<=0)return 0;let d=(l.length-1)/2;return(c-d)*Gd}let s=i.findIndex(l=>l.id===e),a=(i.length-1)/2;return(s-a)*Gd}var ra=Be.default.memo(({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var X,Q,ee,te,xe,pe,le,Ae,Xe,rt;let{zoom:c}=(0,Me.useViewport)(),{updateEdgeData:d}=(0,Me.useReactFlow)(),{isReadOnly:u,mode:p,instanceId:f,edgeHighlight:h}=K(),E=qt(),g=(0,Me.useStore)((0,Be.useCallback)(J=>J.edges,[])),y=(0,Me.useStore)((0,Be.useCallback)(J=>{var se,oe;return((se=J.nodeLookup.get(t))==null?void 0:se.type)==="GATEWAY"||((oe=J.nodeLookup.get(o))==null?void 0:oe.type)==="GATEWAY"},[t,o])),m=(0,Be.useMemo)(()=>kh(e,t,o,g,y),[e,t,o,g,y]),[x,T]=(0,Be.useState)(!1),[b,I]=(0,Be.useState)(null),v=(0,Be.useRef)(null),N=(0,Be.useRef)(n==null?void 0:n.labelOffset),S=(0,Be.useRef)(null),M=p!=="edit",{reconnectingHandle:L,cursorPosition:k,hoveredNodeId:O,reconnectingSide:G,isValidReconnection:Y,handleReconnectStart:j}=Ji({edgeId:e,source:t,target:o,instanceId:f,isReadOnly:M}),q=(0,Me.useInternalNode)(t),U=(0,Me.useInternalNode)(o),{sx:A,sy:P,tx:R,ty:C,sourcePos:B,targetPos:F}=(0,Be.useMemo)(()=>{var qe,yt;let J=q&&U?An(q,U):{sx:0,sy:0,tx:0,ty:0,sourcePos:Me.Position.Right,targetPos:Me.Position.Left},se=a?i:J.sourcePos,oe=l?s:J.targetPos,ae=(xt,Vt,pt)=>{var Da,Oa,Va,Ha,Ga,Ba;let{x:Ue,y:it}=xt.internals.positionAbsolute,co=(Va=(Oa=(Da=xt.measured)==null?void 0:Da.width)!=null?Oa:xt.width)!=null?Va:0,Xt=(Ba=(Ga=(Ha=xt.measured)==null?void 0:Ha.height)!=null?Ga:xt.height)!=null?Ba:0;switch(Vt){case Me.Position.Top:return{x:Ue+co*pt,y:it};case Me.Position.Bottom:return{x:Ue+co*pt,y:it+Xt};case Me.Position.Left:return{x:Ue,y:it+Xt*pt};case Me.Position.Right:return{x:Ue+co,y:it+Xt*pt};default:return{x:Ue+co/2,y:it+Xt/2}}},Ce=(qe=n==null?void 0:n.sourceOffset)!=null?qe:.5,$e=(yt=n==null?void 0:n.targetOffset)!=null?yt:.5,Ke=q?ae(q,se,Ce).x:J.sx,ut=q?ae(q,se,Ce).y:J.sy,Eo=U?ae(U,oe,$e).x:J.tx,Se=U?ae(U,oe,$e).y:J.ty;return L==="source"&&k?(Ke=k.x,ut=k.y,G&&(se=G)):L==="target"&&k&&(Eo=k.x,Se=k.y,G&&(oe=G)),{sx:Ke,sy:ut,tx:Eo,ty:Se,sourcePos:se,targetPos:oe}},[q,U,a,l,i,s,L,k,G,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,Be.useEffect)(()=>{var oe;if(!S.current){S.current={sx:A,sy:P,tx:R,ty:C,sourcePos:B,targetPos:F};return}let J=S.current;if(Math.abs(A-J.sx)>Qi||Math.abs(P-J.sy)>Qi||Math.abs(R-J.tx)>Qi||Math.abs(C-J.ty)>Qi||J.sourcePos!==B||J.targetPos!==F){let ae={};(oe=n==null?void 0:n.points)!=null&&oe.length&&(ae.points=void 0),n!=null&&n.labelOffset&&(ae.labelOffset=void 0),Object.keys(ae).length>0&&d(e,_(_({},n),ae))}S.current={sx:A,sy:P,tx:R,ty:C,sourcePos:B,targetPos:F}},[A,P,R,C,B,F,n,e,d,L]);let D=(0,Be.useMemo)(()=>qi(A,P,R,C,B,F,n==null?void 0:n.points,m),[A,P,R,C,B,F,n==null?void 0:n.points,m]),V=(0,Be.useMemo)(()=>{if(D.length<2)return Xi({x:A,y:P},{x:R,y:C});let J=0;for(let ae=0;ae<D.length-1;ae++)J+=Bn(D[ae],D[ae+1]);let se=J/2,oe=0;for(let ae=0;ae<D.length-1;ae++){let Ce=Bn(D[ae],D[ae+1]);if(oe+Ce>=se){let $e=(se-oe)/Ce,Ke=D[ae],ut=D[ae+1];return{x:Ke.x+(ut.x-Ke.x)*$e,y:Ke.y+(ut.y-Ke.y)*$e}}oe+=Ce}return Xi({x:A,y:P},{x:R,y:C})},[D,A,P,R,C]),z=(0,Be.useCallback)((J,se)=>{if(p!=="edit"||se.button!==0)return;se.stopPropagation(),se.preventDefault();let oe=D[J],ae=D[J+1],Ce=ge(oe,ae,"y"),$e=Ce?oe.y:oe.x,Ke=[...D],ut=Ke.length,Eo=J,Se=J+1;I(J);let qe=xt=>{let Vt=$e+(Ce?xt.clientY-se.clientY:xt.clientX-se.clientX)/c;v.current=Ce?{x:(oe.x+ae.x)/2,y:Vt}:{x:Vt,y:(oe.y+ae.y)/2};let pt=[];for(let Ue=1;Ue<ut-1;Ue++){let it=Ke[Ue];Ue===Eo||Ue===Se?Ce?pt.push({x:it.x,y:Vt}):pt.push({x:Vt,y:it.y}):pt.push(_({},it))}d(e,w(_({},n),{points:pt}))},yt=()=>{I(null),v.current=null,document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",yt)};document.addEventListener("mousemove",qe),document.addEventListener("mouseup",yt)},[p,D,c,n,e,d]),$=(0,Be.useCallback)(J=>{var qe,yt,xt,Vt,pt;if(x||M||J.button!==0||!((qe=n==null?void 0:n.label)!=null&&qe.trim()))return;J.stopPropagation(),J.preventDefault();let se=J.clientX,oe=J.clientY,ae=(xt=(yt=n==null?void 0:n.labelOffset)==null?void 0:yt.x)!=null?xt:0,Ce=(pt=(Vt=n==null?void 0:n.labelOffset)==null?void 0:Vt.y)!=null?pt:0,$e=[...D],Ke={x:V.x,y:V.y},ut=!1,Eo=Ue=>{let it=(Ue.clientX-se)/c,co=(Ue.clientY-oe)/c;if(!ut&&Math.abs(it)<3&&Math.abs(co)<3)return;ut=!0;let Xt={x:ae+it,y:Ce+co};N.current=Xt,d(e,w(_({},n),{labelOffset:Xt}))},Se=()=>{document.removeEventListener("mousemove",Eo),document.removeEventListener("mouseup",Se);let Ue=N.current;if(!Ue)return;let it={x:Ke.x+Ue.x,y:Ke.y+Ue.y};kd(it,$e)>Lh&&(N.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",Eo),document.addEventListener("mouseup",Se)},[x,M,c,n,e,d,D,V]);if(!q||!U)return null;let Z=Vd(D),W=h&&(r||q.selected||U.selected);return(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":W}),onDoubleClick:()=>!M&&T(!0),children:[(0,me.jsx)("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:H({"nopan nodrag":!x&&!M&&!!((X=n==null?void 0:n.label)!=null&&X.trim())}),style:{pointerEvents:"stroke",cursor:!x&&!M&&((Q=n==null?void 0:n.label)!=null&&Q.trim())?"move":"pointer"},onMouseDown:$}),(0,me.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!u,"text-blue-500 group-hover:text-blue-600":W}),children:[(0,me.jsx)(Me.BaseEdge,{id:e,path:Z,interactionWidth:0,markerEnd:`url(#${W?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:H("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!u,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||L&&O&&!Y,"stroke-green-500":L&&O&&Y,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":W&&!(n!=null&&n.hasError)&&!L})}),r&&!E&&!M&&(0,me.jsx)("g",{children:D.slice(0,-1).map((J,se)=>{let oe=D[se+1];if(se===0||se===D.length-2||Bn(J,oe)<Ph)return null;let ae=ge(J,oe,"y"),Ce=b===se,$e=Ce&&v.current?v.current:Xi(J,oe);return(0,me.jsxs)("g",{children:[(0,me.jsx)("line",{x1:J.x,y1:J.y,x2:oe.x,y2:oe.y,stroke:"transparent",strokeWidth:20/c,className:H("cursor-pointer",{"cursor-ns-resize":ae,"cursor-ew-resize":!ae}),onMouseDown:Ke=>z(se,Ke)}),(0,me.jsx)("circle",{cx:$e.x,cy:$e.y,r:4/c,fill:Ce?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:$e.x,cy:$e.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:Ce?.6:.3,className:"pointer-events-none"})]},se)})})]})]}),(0,me.jsxs)(Me.EdgeLabelRenderer,{children:[(0,me.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${V.x}px, ${V.y}px)`},children:r&&!E&&(0,me.jsx)(Hn,{sx:A,sy:P,tx:R,ty:C,hasLabel:!!((ee=n==null?void 0:n.label)!=null&&ee.trim()),children:(0,me.jsx)(Vn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:q,targetNode:U})})}),(x||((te=n==null?void 0:n.label)==null?void 0:te.trim()))&&(0,me.jsx)("div",{className:H("absolute nodrag nopan",!x&&!M&&((xe=n==null?void 0:n.label)!=null&&xe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${V.x+((le=(pe=n==null?void 0:n.labelOffset)==null?void 0:pe.x)!=null?le:0)}px, ${V.y+((Xe=(Ae=n==null?void 0:n.labelOffset)==null?void 0:Ae.y)!=null?Xe:0)}px)`,cursor:!x&&!M&&((rt=n==null?void 0:n.label)!=null&&rt.trim())?"move":void 0},onMouseDown:!x&&!M?$:void 0,onDoubleClick:J=>{M||(J.stopPropagation(),T(!0))},children:(0,me.jsx)(st,{value:n==null?void 0:n.label,className:H("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":x,"pointer-events-none":!x}),isEditing:x,onBlur:()=>T(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!E&&!M&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[0].x}px, ${D[0].y}px)`},children:(0,me.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:L==="source"?.6:.3,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!L||L!=="source","cursor-not-allowed":L==="source"&&O&&!Y,"cursor-grabbing":L==="source"&&(!O||Y)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),(0,me.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[D.length-1].x}px, ${D[D.length-1].y}px)`},children:(0,me.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:L==="target"?.6:.3,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!L||L!=="target","cursor-not-allowed":L==="target"&&O&&!Y,"cursor-grabbing":L==="target"&&(!O||Y)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})});ra.displayName="SequenceEdge";var oo=require("@xyflow/react"),Rh={right:oo.Position.Right,left:oo.Position.Left,top:oo.Position.Top,bottom:oo.Position.Bottom},ji=e=>{var t;return(t=Rh[e!=null?e:""])!=null?t:oo.Position.Right},ia=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(ji(t)){case oo.Position.Right:return{x:n+i,y:r+s*o};case oo.Position.Left:return{x:n,y:r+s*o};case oo.Position.Top:return{x:n+i*o,y:r};case oo.Position.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},Bd=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((p,f)=>{let h=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-f.x,o-f.y)<h?f:p}).id};var Rr=require("react"),Zu=require("use-debounce");var qu=require("@xyflow/react"),Ta=require("react");var Ir=(u=>(u.START_EVENT="start-event",u.END_EVENT_TERMINATE="end-event-terminate",u.TASK="task",u.TASK_SCRIPT="task-script",u.SUBPROCESS="subprocess-collapsed",u.GATEWAY_EXCLUSIVE="gateway-exclusive",u.GATEWAY_PARALLEL="gateway-parallel",u.GATEWAY_COMPLEX="gateway-complex",u.SERVICE_TASK="service-task",u.ANNOTATION="annotation",u.LANE="lane",u))(Ir||{});var Ar=1,zd=e=>`<mxGraphModel>
5
+ `).trim();t&&I.length>t&&(I=I.substring(0,t)),b.currentTarget.innerText=I,a==null||a(),I!==e&&(s==null||s(I))};return(0,na.jsx)("div",{className:G("flex-1 p-2 self-stretch flex items-center justify-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":m,"bg-white":e.length>0},n),style:o,onDoubleClick:g,children:(0,na.jsx)("div",{ref:u,className:G("outline-none whitespace-pre-wrap overflow-hidden",r,{"nodrag nopan cursor-text":m}),contentEditable:m,suppressContentEditableWarning:!0,onKeyDown:h,onPaste:f,onInput:y,onBlur:T,children:e})})};var Eh=require("@xyflow/react");var ge=(e,t,o,n=1)=>Math.abs(e[o]-t[o])<n,zn=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Xi=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),_h=(e,t,o)=>{let n=o.x-t.x,r=o.y-t.y,i=n*n+r*r;if(i===0)return zn(e,t);let s=Math.max(0,Math.min(1,((e.x-t.x)*n+(e.y-t.y)*r)/i));return zn(e,{x:t.x+s*n,y:t.y+s*r})},kd=(e,t)=>{let o=1/0;for(let n=0;n<t.length-1;n++)o=Math.min(o,_h(e,t[n],t[n+1]));return o};var wr=require("@xyflow/react");var Mo={OFFSET:30,TOLERANCE:1,MOVE_THRESHOLD:5,MIN_SEGMENT_LENGTH:15,PARALLEL_OFFSET:15,MAX_LABEL_DISTANCE:80};var{TOLERANCE:ce}=Mo;function bh(e,t,o){return ge(e,t,"x",ce)&&ge(t,o,"x",ce)&&ge(e,o,"x",ce)}function Th(e,t,o){return ge(e,t,"y",ce)&&ge(t,o,"y",ce)&&ge(e,o,"y",ce)}function vh(e,t,o){if(!bh(e,t,o))return!1;let n=t.y-e.y,r=o.y-t.y;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function Nh(e,t,o){if(!Th(e,t,o))return!1;let n=t.x-e.x,r=o.x-t.x;return Math.abs(n)<ce||Math.abs(r)<ce?!1:n*r<0}function wh(e,t,o,n){let r=t.x!==0,i=t.x===-n.x&&t.y===-n.y,s=t.x===n.x&&t.y===n.y,a=120;if(i)if(r){if((o.x-e.x)*t.x>=0)return[{x:(e.x+o.x)/2,y:e.y},{x:(e.x+o.x)/2,y:o.y}];{let l=(e.y+o.y)/2,c=Math.abs(e.y-o.y)<a?Math.max(e.y,o.y)+a:l;return[{x:e.x,y:c},{x:o.x,y:c}]}}else{if((o.y-e.y)*t.y>=0)return[{x:e.x,y:(e.y+o.y)/2},{x:o.x,y:(e.y+o.y)/2}];{let l=(e.x+o.x)/2,c=Math.abs(e.x-o.x)<a?Math.max(e.x,o.x)+a:l;return[{x:c,y:e.y},{x:c,y:o.y}]}}else if(s)if(r)if((o.x-e.x)*t.x>0&&Math.abs(e.y-o.y)<a){let l=Math.max(e.y,o.y)+a,c=o.x+t.x*(a/2);return[{x:e.x,y:l},{x:c,y:l},{x:c,y:o.y}]}else{let l=t.x>0?Math.max(e.x,o.x):Math.min(e.x,o.x);return[{x:l,y:e.y},{x:l,y:o.y}]}else if((o.y-e.y)*t.y>0&&Math.abs(e.x-o.x)<a){let l=Math.max(e.x,o.x)+a,c=o.y+t.y*(a/2);return[{x:l,y:e.y},{x:l,y:c},{x:o.x,y:c}]}else{let l=t.y>0?Math.max(e.y,o.y):Math.min(e.y,o.y);return[{x:e.x,y:l},{x:o.x,y:l}]}else{let l=t.x!==0?o.x:e.x,c=t.y!==0?o.y:e.y,d=t.x!==0?(l-e.x)*t.x:(c-e.y)*t.y,u=n.x!==0?(l-o.x)*n.x:(c-o.y)*n.y;return d>=0&&u>=0?[{x:l,y:c}]:r?[{x:e.x,y:o.y}]:[{x:o.x,y:e.y}]}}function Rd(e){if(e.length<=2)return e;let t=[e[0]];for(let o=1;o<e.length-1;o++){let n=t[t.length-1],r=e[o],i=e[o+1];ge(n,r,"x",ce)&&ge(r,i,"x",ce)||ge(n,r,"y",ce)&&ge(r,i,"y",ce)||t.push(r)}return t.push(e[e.length-1]),t}function Ui(e){let t=[];for(let o of e){let n=t[t.length-1];(!n||Math.abs(n.x-o.x)>=ce||Math.abs(n.y-o.y)>=ce)&&t.push(o)}return t}function Ih(e){let t=[...e],o=!0;for(;o;){o=!1;for(let n=1;n<t.length-1;n++){let r=t[n-1],i=t[n],s=t[n+1];if(vh(r,i,s)||Nh(r,i,s)){t.splice(n,1),o=!0;break}}}return t}function Dd(e){let t=Ui(Rd([...e]));return t=Ih(t),Ui(Rd(t))}function $i(e){switch(e){case wr.Position.Left:return{x:-1,y:0};case wr.Position.Right:return{x:1,y:0};case wr.Position.Top:return{x:0,y:-1};case wr.Position.Bottom:return{x:0,y:1};default:return{x:0,y:0}}}function Od(e,t,o,n){let r=Mo.OFFSET,i=Mo.OFFSET;if(t.x===-n.x&&t.y===-n.y)if(t.x!==0){let s=(o.x-e.x)*t.x;s>0&&s<2*Mo.OFFSET&&(r=s/2,i=s/2)}else{let s=(o.y-e.y)*t.y;s>0&&s<2*Mo.OFFSET&&(r=s/2,i=s/2)}return{sourceOffset:r,targetOffset:i}}function Ah(e,t,o,n,r,i,s=0){let a=$i(r),l=$i(i),c=a.x===0?s:0,d=a.y===0?s:0,u=l.x===0?s:0,p=l.y===0?s:0,m={x:e+c,y:t+d},x={x:o+u,y:n+p},{sourceOffset:E,targetOffset:g}=Od(m,a,x,l),h={x:m.x+a.x*E,y:m.y+a.y*E},f={x:x.x+l.x*g,y:x.y+l.y*g},y=wh(h,a,f,l),T=[m,h,...y,f,x],b=Dd(T);if(b.length===2&&Ki(m,x)>ce){let I=ge(m,h,"x",ce)&&ge(h,f,"x",ce)&&ge(f,x,"x",ce),v=ge(m,h,"y",ce)&&ge(h,f,"y",ce)&&ge(f,x,"y",ce);if(I||v){let N=v&&(f.x-h.x)*a.x<0,C=I&&(f.y-h.y)*a.y<0;if(!N&&!C)return Ui([m,h,f,x])}}return b}function qi(e,t,o,n,r,i,s,a=0){if(!(s!=null&&s.length))return Ah(e,t,o,n,r,i,a);let l=$i(r),c=$i(i),d=l.x===0?a:0,u=l.y===0?a:0,p=c.x===0?a:0,m=c.y===0?a:0,x={x:e+d,y:t+u},E={x:o+p,y:n+m},{sourceOffset:g,targetOffset:h}=Od(x,l,E,c),f={x:x.x+l.x*g,y:x.y+l.y*g},y={x:E.x+c.x*h,y:E.y+c.y*h},T=[...s],b=T[0],I=l.y===0;I&&Math.abs(x.y-b.y)>ce?T.unshift({x:b.x,y:x.y}):!I&&Math.abs(x.x-b.x)>ce&&T.unshift({x:x.x,y:b.y});let v=T[T.length-1],N=c.y===0,C=[];(Math.abs(v.x-y.x)>ce||Math.abs(v.y-y.y)>ce)&&(N?C.push({x:y.x,y:v.y}):C.push({x:v.x,y:y.y})),C.push(y);let M=[x,...T,...C,E],L=Dd(M);if(L.length===2&&Ki(x,E)>ce){let R=ge(x,f,"x",ce)&&ge(f,y,"x",ce)&&ge(y,E,"x",ce),O=ge(x,f,"y",ce)&&ge(f,y,"y",ce)&&ge(y,E,"y",ce);if(R||O){let V=O&&(y.x-f.x)*l.x<0,Y=R&&(y.y-f.y)*l.y<0;if(!V&&!Y)return Ui([x,f,y,E])}}return L}var Ki=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Ch(e,t,o){return ge(e,t,"x",ce)&&ge(t,o,"x",ce)||ge(e,t,"y",ce)&&ge(t,o,"y",ce)}function Sh(e,t,o,n){if(Ch(e,t,o))return`L${t.x} ${t.y}`;let r=Ki(e,t),i=Ki(t,o),s=Math.min(r/2,i/2,n);if(s<1)return`L${t.x} ${t.y}`;let a=e.x-t.x,l=e.y-t.y,c=o.x-t.x,d=o.y-t.y,u={x:a/r,y:l/r},p={x:c/i,y:d/i},m={x:t.x+u.x*s,y:t.y+u.y*s},x={x:t.x+p.x*s,y:t.y+p.y*s},E=-u.x,g=-u.y,h=p.x,f=p.y,T=E*f-g*h>0?1:0;return`L${m.x} ${m.y}A${s} ${s} 0 0 ${T} ${x.x} ${x.y}`}var Vd=(e,t=5)=>e.length<2?"":e.reduce((o,n,r)=>{let i="";return r>0&&r<e.length-1?i=Sh(e[r-1],n,e[r+1],t):i=`${r===0?"M":"L"}${n.x} ${n.y}`,o+=i,o},"");var ve=require("react"),Zi=require("@xyflow/react");var Mh=50,Hd=.1,Ph=.6,Ji=({edgeId:e,source:t,target:o,instanceId:n,isReadOnly:r})=>{let{setEdges:i,getNode:s,getNodes:a,getEdge:l,screenToFlowPosition:c}=(0,Zi.useReactFlow)(),{setIsDragging:d,setReconnectingEdgeId:u}=U(),p=(0,Zi.useStore)(P=>P.isValidConnection),[m,x]=(0,ve.useState)(null),[E,g]=(0,ve.useState)(null),[h,f]=(0,ve.useState)(null),[y,T]=(0,ve.useState)(null),[b,I]=(0,ve.useState)(null),[v,N]=(0,ve.useState)(!1),C=(0,ve.useRef)(null),M=(0,ve.useRef)(null),L=(0,ve.useRef)(null),R=(0,ve.useRef)(t),O=(0,ve.useRef)(o);(0,ve.useEffect)(()=>{R.current=t,O.current=o},[t,o]),(0,ve.useEffect)(()=>{C.current=m},[m]),(0,ve.useEffect)(()=>{M.current=b},[b]);let V=(0,ve.useCallback)(P=>{let k=a(),S=k.find(H=>H.id===P);if(!S)return{x:0,y:0};let B=S.position.x,F=S.position.y,D=S.parentId;for(;D;){let H=k.find(z=>z.id===D);if(!H)break;B+=H.position.x,F+=H.position.y,D=H.parentId}return{x:B,y:F}},[a]),Y=(0,ve.useCallback)(P=>{var D,H,z,K,Z,W;let k=a(),S=null,B=Mh,F=k.filter(X=>X.type!=="LANE"&&X.type!=="ANNOTATION");for(let X of F){if(X.id===e)continue;let Q=V(X.id),ee=(z=(H=(D=X.measured)==null?void 0:D.width)!=null?H:X.width)!=null?z:0,te=(W=(Z=(K=X.measured)==null?void 0:K.height)!=null?Z:X.height)!=null?W:0;if(P.x>=Q.x&&P.x<=Q.x+ee&&P.y>=Q.y&&P.y<=Q.y+te)return X.id;let pe=Math.max(Q.x-P.x,0,P.x-(Q.x+ee)),le=Math.max(Q.y-P.y,0,P.y-(Q.y+te)),Ae=Math.sqrt(pe*pe+le*le);Ae<B&&(B=Ae,S=X.id)}return S},[a,V,e]),j=(0,ve.useCallback)((P,k)=>{var pe,le,Ae,Xe,rt,J;let S=s(P);if(!S)return null;let B=V(P),F=(Ae=(le=(pe=S.measured)==null?void 0:pe.width)!=null?le:S.width)!=null?Ae:0,D=(J=(rt=(Xe=S.measured)==null?void 0:Xe.height)!=null?rt:S.height)!=null?J:0,H=Math.abs(B.x+F-k.x),z=Math.abs(k.x-B.x),K=Math.abs(B.y+D-k.y),Z=Math.abs(k.y-B.y),W={right:H,left:z,bottom:K,top:Z},X=Object.entries(W).reduce((se,[oe,ae])=>ae<se[1]?[oe,ae]:se,["right",W.right])[0],Q=L.current;if(Q&&Q!==X){let se=W[X],oe=W[Q],ae=Math.abs(oe-se),Ce=Math.min(Math.abs(oe),Math.abs(se));ae<Ce*Ph&&(X=Q)}let ee=X,te,xe;if(ee==="right"||ee==="left"){let oe=(Math.max(B.y,Math.min(B.y+D,k.y))-B.y)/(D||1);Math.abs(oe-.5)<Hd&&(oe=.5),xe=oe,te={x:ee==="right"?B.x+F:B.x,y:B.y+xe*D}}else{let oe=(Math.max(B.x,Math.min(B.x+F,k.x))-B.x)/(F||1);Math.abs(oe-.5)<Hd&&(oe=.5),xe=oe,te={x:B.x+xe*F,y:ee==="bottom"?B.y+D:B.y}}return{side:ee,snapPosition:te,offset:xe}},[s,V]),q=(0,ve.useCallback)(P=>{var z,K,Z;let k=C.current;if(!k)return;let S=c({x:P.clientX,y:P.clientY}),B=Y(S);f(B);let F=S,D=null,H=null;if(B){let W=j(B,S);W&&(D=W.side,F=W.snapPosition,H=W.offset,L.current=D);let X=l(e),Q={source:k==="source"?B:R.current,target:k==="target"?B:O.current,sourceHandle:k==="source"?D:(z=X==null?void 0:X.sourceHandle)!=null?z:null,targetHandle:k==="target"?D:(K=X==null?void 0:X.targetHandle)!=null?K:null},ee=(Z=p==null?void 0:p(Q))!=null?Z:!0;N(ee)}else L.current=null,N(!1);T(D),I(H),g(F)},[Y,j,l,e,c,p]),$=(0,ve.useCallback)(P=>{var D,H,z,K,Z;let k=C.current;if(!k)return;let S=c({x:P.clientX,y:P.clientY}),B=Y(S);if(B){let W=j(B,S),X=(D=W==null?void 0:W.side)!=null?D:null,Q=(H=W==null?void 0:W.offset)!=null?H:.5,ee=l(e),te={source:k==="source"?B:R.current,target:k==="target"?B:O.current,sourceHandle:k==="source"?X:(z=ee==null?void 0:ee.sourceHandle)!=null?z:null,targetHandle:k==="target"?X:(K=ee==null?void 0:ee.targetHandle)!=null?K:null};((Z=p==null?void 0:p(te))==null||Z)&&i(xe=>xe.map(pe=>{var le,Ae;return pe.id===e?w(_({},pe),{source:te.source,target:te.target,sourceHandle:te.sourceHandle,targetHandle:te.targetHandle,data:w(_({},pe.data),{points:void 0,sourceOffset:k==="source"?Q:(le=pe.data)==null?void 0:le.sourceOffset,targetOffset:k==="target"?Q:(Ae=pe.data)==null?void 0:Ae.targetOffset})}):pe}))}x(null),g(null),f(null),T(null),I(null),d(!1),N(!1),u(null),L.current=null,document.removeEventListener("mouseup",$),document.removeEventListener("mousemove",q);let F=to.get(n);F==null||F.clearReconnectingEdge()},[e,Y,j,l,i,n,q,p,c,d,u]),A=(0,ve.useCallback)((P,k)=>{if(r||k.button!==0)return;k.stopPropagation(),k.preventDefault(),i(B=>B.map(F=>F.id===e?w(_({},F),{data:w(_({},F.data),{points:void 0})}):F)),x(P),u(e);let S=to.get(n);S==null||S.setReconnectingEdge(e),document.addEventListener("mousemove",q),document.addEventListener("mouseup",$)},[r,e,n,q,$,u,i]);return(0,ve.useEffect)(()=>()=>{if(C.current){document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",$),u(null);let P=to.get(n);P==null||P.clearReconnectingEdge()}},[n,q,$,u]),{reconnectingHandle:m,cursorPosition:E,hoveredNodeId:h,reconnectingSide:y,reconnectingOffset:b,isValidReconnection:v,handleReconnectStart:A}};var me=require("react/jsx-runtime"),kt={type:"SEQUENCE_EDGE",reconnectable:!0,markerStart:{type:Me.MarkerType.ArrowClosed},markerEnd:{type:Me.MarkerType.Arrow},data:{label:""}},{MOVE_THRESHOLD:Qi,MIN_SEGMENT_LENGTH:Lh,PARALLEL_OFFSET:Gd,MAX_LABEL_DISTANCE:kh}=Mo;function Rh(e,t,o,n,r){if(r)return 0;let i=n.filter(l=>l.source===t&&l.target===o||l.source===o&&l.target===t);if(i.length<=1){let l=n.filter(u=>u.source===t);if(l.length<=1)return 0;let c=l.findIndex(u=>u.id===e);if(c<=0)return 0;let d=(l.length-1)/2;return(c-d)*Gd}let s=i.findIndex(l=>l.id===e),a=(i.length-1)/2;return(s-a)*Gd}var ra=Be.default.memo(({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var X,Q,ee,te,xe,pe,le,Ae,Xe,rt;let{zoom:c}=(0,Me.useViewport)(),{updateEdgeData:d}=(0,Me.useReactFlow)(),{isReadOnly:u,mode:p,instanceId:m,edgeHighlight:x}=U(),E=qt(),g=(0,Me.useStore)((0,Be.useCallback)(J=>J.edges,[])),h=(0,Me.useStore)((0,Be.useCallback)(J=>{var se,oe;return((se=J.nodeLookup.get(t))==null?void 0:se.type)==="GATEWAY"||((oe=J.nodeLookup.get(o))==null?void 0:oe.type)==="GATEWAY"},[t,o])),f=(0,Be.useMemo)(()=>Rh(e,t,o,g,h),[e,t,o,g,h]),[y,T]=(0,Be.useState)(!1),[b,I]=(0,Be.useState)(null),v=(0,Be.useRef)(null),N=(0,Be.useRef)(n==null?void 0:n.labelOffset),C=(0,Be.useRef)(null),M=p!=="edit",{reconnectingHandle:L,cursorPosition:R,hoveredNodeId:O,reconnectingSide:V,isValidReconnection:Y,handleReconnectStart:j}=Ji({edgeId:e,source:t,target:o,instanceId:m,isReadOnly:M}),q=(0,Me.useInternalNode)(t),$=(0,Me.useInternalNode)(o),{sx:A,sy:P,tx:k,ty:S,sourcePos:B,targetPos:F}=(0,Be.useMemo)(()=>{var qe,yt;let J=q&&$?Cn(q,$):{sx:0,sy:0,tx:0,ty:0,sourcePos:Me.Position.Right,targetPos:Me.Position.Left},se=a?i:J.sourcePos,oe=l?s:J.targetPos,ae=(xt,Vt,pt)=>{var Da,Oa,Va,Ha,Ga,Ba;let{x:Ue,y:it}=xt.internals.positionAbsolute,co=(Va=(Oa=(Da=xt.measured)==null?void 0:Da.width)!=null?Oa:xt.width)!=null?Va:0,Xt=(Ba=(Ga=(Ha=xt.measured)==null?void 0:Ha.height)!=null?Ga:xt.height)!=null?Ba:0;switch(Vt){case Me.Position.Top:return{x:Ue+co*pt,y:it};case Me.Position.Bottom:return{x:Ue+co*pt,y:it+Xt};case Me.Position.Left:return{x:Ue,y:it+Xt*pt};case Me.Position.Right:return{x:Ue+co,y:it+Xt*pt};default:return{x:Ue+co/2,y:it+Xt/2}}},Ce=(qe=n==null?void 0:n.sourceOffset)!=null?qe:.5,$e=(yt=n==null?void 0:n.targetOffset)!=null?yt:.5,Ke=q?ae(q,se,Ce).x:J.sx,ut=q?ae(q,se,Ce).y:J.sy,_o=$?ae($,oe,$e).x:J.tx,Se=$?ae($,oe,$e).y:J.ty;return L==="source"&&R?(Ke=R.x,ut=R.y,V&&(se=V)):L==="target"&&R&&(_o=R.x,Se=R.y,V&&(oe=V)),{sx:Ke,sy:ut,tx:_o,ty:Se,sourcePos:se,targetPos:oe}},[q,$,a,l,i,s,L,R,V,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);(0,Be.useEffect)(()=>{var oe;if(!C.current){C.current={sx:A,sy:P,tx:k,ty:S,sourcePos:B,targetPos:F};return}let J=C.current;if(Math.abs(A-J.sx)>Qi||Math.abs(P-J.sy)>Qi||Math.abs(k-J.tx)>Qi||Math.abs(S-J.ty)>Qi||J.sourcePos!==B||J.targetPos!==F){let ae={};(oe=n==null?void 0:n.points)!=null&&oe.length&&(ae.points=void 0),n!=null&&n.labelOffset&&(ae.labelOffset=void 0),Object.keys(ae).length>0&&d(e,_(_({},n),ae))}C.current={sx:A,sy:P,tx:k,ty:S,sourcePos:B,targetPos:F}},[A,P,k,S,B,F,n,e,d,L]);let D=(0,Be.useMemo)(()=>qi(A,P,k,S,B,F,n==null?void 0:n.points,f),[A,P,k,S,B,F,n==null?void 0:n.points,f]),H=(0,Be.useMemo)(()=>{if(D.length<2)return Xi({x:A,y:P},{x:k,y:S});let J=0;for(let ae=0;ae<D.length-1;ae++)J+=zn(D[ae],D[ae+1]);let se=J/2,oe=0;for(let ae=0;ae<D.length-1;ae++){let Ce=zn(D[ae],D[ae+1]);if(oe+Ce>=se){let $e=(se-oe)/Ce,Ke=D[ae],ut=D[ae+1];return{x:Ke.x+(ut.x-Ke.x)*$e,y:Ke.y+(ut.y-Ke.y)*$e}}oe+=Ce}return Xi({x:A,y:P},{x:k,y:S})},[D,A,P,k,S]),z=(0,Be.useCallback)((J,se)=>{if(p!=="edit"||se.button!==0)return;se.stopPropagation(),se.preventDefault();let oe=D[J],ae=D[J+1],Ce=ge(oe,ae,"y"),$e=Ce?oe.y:oe.x,Ke=[...D],ut=Ke.length,_o=J,Se=J+1;I(J);let qe=xt=>{let Vt=$e+(Ce?xt.clientY-se.clientY:xt.clientX-se.clientX)/c;v.current=Ce?{x:(oe.x+ae.x)/2,y:Vt}:{x:Vt,y:(oe.y+ae.y)/2};let pt=[];for(let Ue=1;Ue<ut-1;Ue++){let it=Ke[Ue];Ue===_o||Ue===Se?Ce?pt.push({x:it.x,y:Vt}):pt.push({x:Vt,y:it.y}):pt.push(_({},it))}d(e,w(_({},n),{points:pt}))},yt=()=>{I(null),v.current=null,document.removeEventListener("mousemove",qe),document.removeEventListener("mouseup",yt)};document.addEventListener("mousemove",qe),document.addEventListener("mouseup",yt)},[p,D,c,n,e,d]),K=(0,Be.useCallback)(J=>{var qe,yt,xt,Vt,pt;if(y||M||J.button!==0||!((qe=n==null?void 0:n.label)!=null&&qe.trim()))return;J.stopPropagation(),J.preventDefault();let se=J.clientX,oe=J.clientY,ae=(xt=(yt=n==null?void 0:n.labelOffset)==null?void 0:yt.x)!=null?xt:0,Ce=(pt=(Vt=n==null?void 0:n.labelOffset)==null?void 0:Vt.y)!=null?pt:0,$e=[...D],Ke={x:H.x,y:H.y},ut=!1,_o=Ue=>{let it=(Ue.clientX-se)/c,co=(Ue.clientY-oe)/c;if(!ut&&Math.abs(it)<3&&Math.abs(co)<3)return;ut=!0;let Xt={x:ae+it,y:Ce+co};N.current=Xt,d(e,w(_({},n),{labelOffset:Xt}))},Se=()=>{document.removeEventListener("mousemove",_o),document.removeEventListener("mouseup",Se);let Ue=N.current;if(!Ue)return;let it={x:Ke.x+Ue.x,y:Ke.y+Ue.y};kd(it,$e)>kh&&(N.current=void 0,d(e,w(_({},n),{labelOffset:void 0})))};document.addEventListener("mousemove",_o),document.addEventListener("mouseup",Se)},[y,M,c,n,e,d,D,H]);if(!q||!$)return null;let Z=Vd(D),W=x&&(r||q.selected||$.selected);return(0,me.jsxs)(me.Fragment,{children:[(0,me.jsxs)("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":W}),onDoubleClick:()=>!M&&T(!0),children:[(0,me.jsx)("path",{d:Z,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),className:G({"nopan nodrag":!y&&!M&&!!((X=n==null?void 0:n.label)!=null&&X.trim())}),style:{pointerEvents:"stroke",cursor:!y&&!M&&((Q=n==null?void 0:n.label)!=null&&Q.trim())?"move":"pointer"},onMouseDown:K}),(0,me.jsxs)("g",{className:G("text-grey-500 transition-colors duration-75",{"group-hover:text-grey-800":!u,"text-blue-500 group-hover:text-blue-600":W}),children:[(0,me.jsx)(Me.BaseEdge,{id:e,path:Z,interactionWidth:0,markerEnd:`url(#${W?"sequence-edge-marker-highlighted":"sequence-edge-marker"})`,className:G("stroke-2 stroke-current transition-[stroke] duration-75",{"group-hover:stroke-[2.5px]":!u,"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||L&&O&&!Y,"stroke-green-500":L&&O&&Y,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":W&&!(n!=null&&n.hasError)&&!L})}),r&&!E&&!M&&(0,me.jsx)("g",{children:D.slice(0,-1).map((J,se)=>{let oe=D[se+1];if(se===0||se===D.length-2||zn(J,oe)<Lh)return null;let ae=ge(J,oe,"y"),Ce=b===se,$e=Ce&&v.current?v.current:Xi(J,oe);return(0,me.jsxs)("g",{children:[(0,me.jsx)("line",{x1:J.x,y1:J.y,x2:oe.x,y2:oe.y,stroke:"transparent",strokeWidth:20/c,className:G("cursor-pointer",{"cursor-ns-resize":ae,"cursor-ew-resize":!ae}),onMouseDown:Ke=>z(se,Ke)}),(0,me.jsx)("circle",{cx:$e.x,cy:$e.y,r:4/c,fill:Ce?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:$e.x,cy:$e.y,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:Ce?.6:.3,className:"pointer-events-none"})]},se)})})]})]}),(0,me.jsxs)(Me.EdgeLabelRenderer,{children:[(0,me.jsx)("div",{className:"absolute z-[3000] pointer-events-none flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${H.x}px, ${H.y}px)`},children:r&&!E&&(0,me.jsx)(Gn,{sx:A,sy:P,tx:k,ty:S,hasLabel:!!((ee=n==null?void 0:n.label)!=null&&ee.trim()),children:(0,me.jsx)(Hn,{edgeId:e,edgeType:"SEQUENCE_EDGE",sourceNode:q,targetNode:$})})}),(y||((te=n==null?void 0:n.label)==null?void 0:te.trim()))&&(0,me.jsx)("div",{className:G("absolute nodrag nopan",!y&&!M&&((xe=n==null?void 0:n.label)!=null&&xe.trim())?"z-[10001] pointer-events-auto":"z-[3000] pointer-events-none"),style:{transform:`translate(-50%, -50%) translate(${H.x+((le=(pe=n==null?void 0:n.labelOffset)==null?void 0:pe.x)!=null?le:0)}px, ${H.y+((Xe=(Ae=n==null?void 0:n.labelOffset)==null?void 0:Ae.y)!=null?Xe:0)}px)`,cursor:!y&&!M&&((rt=n==null?void 0:n.label)!=null&&rt.trim())?"move":void 0},onMouseDown:!y&&!M?K:void 0,onDoubleClick:J=>{M||(J.stopPropagation(),T(!0))},children:(0,me.jsx)(st,{value:n==null?void 0:n.label,className:G("min-w-8 max-w-56 px-2 py-1 body-small-400",{"pointer-events-auto":y,"pointer-events-none":!y}),isEditing:y,onBlur:()=>T(!1),onChange:J=>d(e,{label:J.trim()})})}),r&&!E&&!M&&(0,me.jsxs)(me.Fragment,{children:[(0,me.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[0].x}px, ${D[0].y}px)`},children:(0,me.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:L==="source"?.6:.3,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!L||L!=="source","cursor-not-allowed":L==="source"&&O&&!Y,"cursor-grabbing":L==="source"&&(!O||Y)}),onMouseDown:J=>j("source",J.nativeEvent)})]})}),(0,me.jsx)("div",{className:"absolute z-[10000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${D[D.length-1].x}px, ${D[D.length-1].y}px)`},children:(0,me.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:L==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:L==="target"?.6:.3,className:"pointer-events-none"}),(0,me.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!L||L!=="target","cursor-not-allowed":L==="target"&&O&&!Y,"cursor-grabbing":L==="target"&&(!O||Y)}),onMouseDown:J=>j("target",J.nativeEvent)})]})})]})]})]})});ra.displayName="SequenceEdge";var oo=require("@xyflow/react"),Dh={right:oo.Position.Right,left:oo.Position.Left,top:oo.Position.Top,bottom:oo.Position.Bottom},ji=e=>{var t;return(t=Dh[e!=null?e:""])!=null?t:oo.Position.Right},ia=(e,t,o=.5)=>{var l,c,d,u;let{x:n,y:r}=e.internals.positionAbsolute,i=(c=(l=e.measured)==null?void 0:l.width)!=null?c:0,s=(u=(d=e.measured)==null?void 0:d.height)!=null?u:0;switch(ji(t)){case oo.Position.Right:return{x:n+i,y:r+s*o};case oo.Position.Left:return{x:n,y:r+s*o};case oo.Position.Top:return{x:n+i*o,y:r};case oo.Position.Bottom:return{x:n+i*o,y:r+s};default:return{x:n+i/2,y:r+s/2}}},Bd=(e,t,o)=>{var d,u;let{position:{x:n,y:r},measured:i}=e,s=(d=i.width)!=null?d:0,a=(u=i.height)!=null?u:0;return[{id:"left",x:n,y:r+a/2},{id:"right",x:n+s,y:r+a/2},{id:"top",x:n+s/2,y:r},{id:"bottom",x:n+s/2,y:r+a}].reduce((p,m)=>{let x=Math.hypot(t-p.x,o-p.y);return Math.hypot(t-m.x,o-m.y)<x?m:p}).id};var Rr=require("react"),Ju=require("use-debounce");var Zu=require("@xyflow/react"),Ta=require("react");var Ir=(u=>(u.START_EVENT="start-event",u.END_EVENT_TERMINATE="end-event-terminate",u.TASK="task",u.TASK_SCRIPT="task-script",u.SUBPROCESS="subprocess-collapsed",u.GATEWAY_EXCLUSIVE="gateway-exclusive",u.GATEWAY_PARALLEL="gateway-parallel",u.GATEWAY_COMPLEX="gateway-complex",u.SERVICE_TASK="service-task",u.ANNOTATION="annotation",u.LANE="lane",u))(Ir||{});var la=or(require("@dagrejs/dagre"),1);var es={MIN_WIDTH:36,MIN_HEIGHT:36},ts={MIN_WIDTH:36,MIN_HEIGHT:36},Yn={MIN_WIDTH:56,MIN_HEIGHT:56},Po={MIN_WIDTH:176,MIN_HEIGHT:96},zd={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ie={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Fn={MIN_WIDTH:176,MIN_HEIGHT:64},Oh={MIN_WIDTH:128,MIN_HEIGHT:64},de={START_EVENT:es,END_EVENT:ts,GATEWAY:Yn,TASK:Po,LANE:ie,ANNOTATION:Fn,UNSUPPORTED:Oh};var Vh=50,nn=(e,t)=>{var p,m,x,E,g,h,f,y,T,b,I,v,N,C,M,L;let o=t.find(R=>R.id===e);if(!o)return t;let n=(m=(p=o.position)==null?void 0:p.x)!=null?m:0,r=(E=(x=o.position)==null?void 0:x.y)!=null?E:0,i=(h=(g=o.measured)==null?void 0:g.width)!=null?h:0,s=(y=(f=o.measured)==null?void 0:f.height)!=null?y:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let R of t){if(R.id===e||R.parentId)continue;let O=(b=(T=R.position)==null?void 0:T.y)!=null?b:0,V=(v=(I=R.position)==null?void 0:I.x)!=null?v:0,Y=(C=(N=R.measured)==null?void 0:N.width)!=null?C:0,j=(L=(M=R.measured)==null?void 0:M.height)!=null?L:0;V<l&&V+Y>n&&O<a&&O+j>r&&(c.add(R.id),d=Math.min(d,O))}if(c.size===0)return t;let u=a+Vh-d;return t.map(R=>{var V,Y,j;if(!c.has(R.id))return R;let O=(Y=(V=R.position)==null?void 0:V.y)!=null?Y:0;return w(_({},R),{position:w(_({},(j=R.position)!=null?j:{x:0,y:0}),{y:O+u})})})},De=15,rn=e=>[...e].sort((t,o)=>t.position.y-o.position.y),Hh=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},Gh=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},sa=(e,t,o)=>{var d,u,p,m,x,E,g,h,f,y,T,b,I,v,N;if(t.length===0)return e;let n=(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:0,r=(E=(x=e.height)!=null?x:(m=e.measured)==null?void 0:m.height)!=null?E:0,i=0,s=0;for(let C of t){let M=Hh(C),L=Gh(C);if(((h=(g=C.position)==null?void 0:g.y)!=null?h:0)<De&&(o.set(C.id,w(_({},C),{position:w(_({},C.position),{y:De})})),L=De+((y=(f=C.measured)==null?void 0:f.height)!=null?y:0)),((b=(T=C.position)==null?void 0:T.x)!=null?b:0)<ie.HEADER_WIDTH+De){let R=(I=o.get(C.id))!=null?I:C;o.set(C.id,w(_({},R),{position:w(_({},R.position),{x:ie.HEADER_WIDTH+De})})),M=ie.HEADER_WIDTH+De+((N=(v=C.measured)==null?void 0:v.width)!=null?N:0)}i=Math.max(i,M),s=Math.max(s,L)}let a=Math.max(n,ie.MIN_WIDTH),l=Math.max(r,ie.MIN_HEIGHT);i+De>a&&(a=i+De),s+De>l&&(l=s+De);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},Yd=(e,t,o)=>{var s,a;let n=rn(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(s=r.get(l.id))!=null?s:[],d=sa(l,c,t);t.set(d.id,w(_({},d),{position:{x:ie.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},Fd=(e,t)=>{var x,E,g,h;let o=[];for(let f of t.values())f.parentId===e.id&&o.push(f);let n=rn(o),r=((E=(x=e.measured)==null?void 0:x.width)!=null?E:0)-ie.HEADER_WIDTH,i=cl(e.id,o)||ie.MIN_WIDTH,s=o.reduce((f,y)=>{var T;return f+((T=y.height)!=null?T:ie.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+ie.HEADER_WIDTH,u=c?a-ie.HEADER_WIDTH:a,p=0;for(let f=0;f<n.length;f++){let y=n[f],T=Math.max(ie.MIN_HEIGHT,(g=y.height)!=null?g:ie.MIN_HEIGHT),b=w(_({},y),{width:u,height:T,measured:w(_({},y.measured),{width:u,height:T}),position:{x:ie.HEADER_WIDTH,y:p}});if(f===o.length-1){let I=Math.max(ie.MIN_HEIGHT,l-p);b=w(_({},b),{height:I,measured:w(_({},y.measured),{width:u,height:I})})}t.set(y.id,b),p+=(h=b.height)!=null?h:0}let m=Math.max(l,p);t.set(e.id,w(_({},e),{width:d,height:m,measured:w(_({},e.measured),{width:d,height:m})}))},Wd=(e,t,o,n,r)=>{var x,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(g=>g.type==="LANE"&&g.parentId===s);if(!a.length)return n;let l=rn(a),c=l.findIndex(g=>g.id===e.id),d=(E=(x=e.position)==null?void 0:x.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,p=0,m=[...n];return l.forEach((g,h)=>{var I,v;let f=h===l.length-1,y=g.id===e.id,b=(v=(I=g.measured)==null?void 0:I.height)!=null?v:0;y?b=o:u&&h===c-1&&(b=Math.max(ie.MIN_HEIGHT,r-p)),f&&i&&(b=Math.max(ie.MIN_HEIGHT,o-p)),m=m.map(N=>{if(N.id===g.id){let C=i?t-ie.HEADER_WIDTH:t;return w(_({},N),{width:C,height:b,measured:w(_({},N.measured),{width:C,height:b}),position:{x:ie.HEADER_WIDTH,y:p}})}return N}),y&&u?p=r+o:p+=b}),m=m.map(g=>{if(g.id===s){let h=i?t:t+ie.HEADER_WIDTH;return w(_({},g),{width:h,height:i?o:p,measured:{width:h,height:i?o:p}})}return g}),m};var aa=(e,t,o)=>{var a,l,c,d,u,p,m,x;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<De&&(e.position.y=De),e.position.x<ie.HEADER_WIDTH+De&&(e.position.x=ie.HEADER_WIDTH+De);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((x=(m=e.measured)==null?void 0:m.height)!=null?x:0);return i+De>n&&(t.width=i+De,t.measured.width=i+De),s+De>r&&(t.height=s+De,t.measured.height=s+De),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};var os=(e=[],t=[],o="LR")=>{let n=new la.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),la.default.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},go=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=sl(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){Yd(s,o,r),Fd(n,o);continue}sa(n,i,o)}return al(e,o)},Xd=go,Ud=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var Ar=1,$d=e=>`<mxGraphModel>
6
6
  <root version="1.1">
7
7
  <mxCell id="0" />
8
8
  <mxCell id="1" parent="0" />
@@ -35,17 +35,17 @@
35
35
  <mxGeometry as="geometry" relative="1" />
36
36
  </mxCell>
37
37
  </root>
38
- </mxGraphModel>`,Yd=(e,t)=>{if(!e.length&&!t.length)return Ar;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var es=require("xml-js");var Fd={compact:!0,spaces:4},Dh=e=>e.replace(/\n/g,"&#xA;");function ts(e,t=Fd){if(e)return JSON.parse((0,es.xml2json)(e,t))}function Wd(e,t=Fd){return e?(0,es.json2xml)(e,w(_({},t),{attributeValueFn:Dh})):""}var os={MIN_WIDTH:36,MIN_HEIGHT:36},ns={MIN_WIDTH:36,MIN_HEIGHT:36},zn={MIN_WIDTH:56,MIN_HEIGHT:56},Mo={MIN_WIDTH:176,MIN_HEIGHT:96},Xd={HEADER_WIDTH:40,MIN_WIDTH:840,MIN_HEIGHT:256},ie={HEADER_WIDTH:40,MIN_WIDTH:800,MIN_HEIGHT:256},Yn={MIN_WIDTH:176,MIN_HEIGHT:64},Oh={MIN_WIDTH:128,MIN_HEIGHT:64},de={START_EVENT:os,END_EVENT:ns,GATEWAY:zn,TASK:Mo,LANE:ie,ANNOTATION:Yn,UNSUPPORTED:Oh};var Ud={"attribute-loop":"LOOP"},$d={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},Kd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},qd={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},Zd={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Fn=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let h=n.split(`
39
- `),E=h.length;l=h.reduce((y,m)=>Math.max(y,m.length),0)*7+r,c=E*20+i}let d=Math.max(bo(Number(s),t),l),u=Math.max(bo(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Wn=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,className:void 0,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},Hh=e=>{let{mxGeometry:t}=e,o=Wn(e),n=Fn(t,de.START_EVENT.MIN_WIDTH,de.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},Gh=e=>{let{mxGeometry:t}=e,o=Wn(e),n=Fn(t,de.END_EVENT.MIN_WIDTH,de.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},rs=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Wn(e),a=Fn(n,de.TASK.MIN_WIDTH,de.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=Ud[d];u&&(r.data.attribute=u)}let c=$d[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},sa=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Wn(e),i=Fn(o,de.GATEWAY.MIN_WIDTH,de.GATEWAY.MIN_HEIGHT);return r.data.variant=Kd[n],w(_(_({},r),i),{type:"GATEWAY"})},Bh=e=>{let{mxGeometry:t}=e,o=Wn(e),i=Fn(t,de.ANNOTATION.MIN_WIDTH,de.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},zh=e=>{let{mxGeometry:t}=e,o=Wn(e),n=Fn(t,de.LANE.MIN_WIDTH,de.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},Jd={task:rs,"task-script":rs,"subprocess-collapsed":rs,"service-task":rs,"start-event":Hh,"end-event-terminate":Gh,"gateway-parallel":sa,"gateway-exclusive":sa,"gateway-complex":sa,annotation:Bh,lane:zh},Yh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},Qd=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:p,labelOffsetY:f}=t,h=Yh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,g=u!==void 0?Number(u):void 0,y=p!==void 0?Number(p):void 0,m=f!==void 0?Number(f):void 0,x=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:s||""},h&&h.length>0?{points:h}:{}),E!==void 0?{sourceOffset:E}:{}),g!==void 0?{targetOffset:g}:{}),y!==void 0&&m!==void 0?{labelOffset:{x:y,y:m}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},Gn),x):_(_({},kt),x)},jd=(e,t)=>{var f,h;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((f=l==null?void 0:l.labelOffset)==null?void 0:f.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((h=l==null?void 0:l.labelOffset)==null?void 0:h.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Xn=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}}}},Fh=e=>{let{variant:t}=e.data,o=Xn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:qd[t]||"task"})})},Wh=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},Xh=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Uh=e=>{let{variant:t}=e.data,o=Xn(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:Zd[t]})})},$h=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Kh=e=>{let t=Xn(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},eu={TASK:Fh,START_EVENT:Wh,END_EVENT:Xh,GATEWAY:Uh,ANNOTATION:Kh,LANE:$h},tu=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.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 qh=e=>{let t=Object.values(Ir),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=Jd[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},Zh=(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=Qd(r),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},Jh=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=eu)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=tu(n,t);o.push(l)}}),o},Qh=(e,t)=>{let o=[];return e.forEach(n=>{let r=jd(n,t);o.push(r)}),o},jh=(e=[],t=[],o)=>{let n=Jh(e,o),r=Qh(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},ou=(e=[],t=[],o)=>{let n=jh(e,t,o);return Wd(JSON.stringify(n),{compact:!0,spaces:0})},nu=async e=>{var s,a,l,c,d;let t=await ts(e),o=((a=(s=t==null?void 0:t.mxGraphModel)==null?void 0:s.root)==null?void 0:a.mxCell)||[],n=Number(((d=(c=(l=t==null?void 0:t.mxGraphModel)==null?void 0:l.root)==null?void 0:c._attributes)==null?void 0:d.lastId)||Ar),r=qh(o),i=Zh(o,r);return{lastElementId:n,edges:i,nodes:r}};var fs=require("@xyflow/react"),$u=require("react");var bt=require("@xyflow/react"),ds=require("react");var Cr=require("@xyflow/react");var aa=require("react/jsx-runtime"),ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Ut(s,["type","position","className","nodeType"]);let a=n==="TASK";return(0,aa.jsx)(Cr.Handle,_({type:e,position:t,className:H("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},lt=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Ut(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Cr.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let f=c();if(t==="TASK")return f.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return f.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let h=d();return f.filter(g=>{if(g.source!==e)return!1;let y=h.find(m=>m.id===g.target);return(y==null?void 0:y.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,aa.jsx)(Cr.Handle,_({type:n,position:r,className:H("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};var ua=require("react"),go=require("@xyflow/react");var ru=require("@xyflow/react"),is=()=>{let e=(0,ru.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var da=tr(require("@dagrejs/dagre"),1);var ey=50,on=(e,t)=>{var p,f,h,E,g,y,m,x,T,b,I,v,N,S,M,L;let o=t.find(k=>k.id===e);if(!o)return t;let n=(f=(p=o.position)==null?void 0:p.x)!=null?f:0,r=(E=(h=o.position)==null?void 0:h.y)!=null?E:0,i=(y=(g=o.measured)==null?void 0:g.width)!=null?y:0,s=(x=(m=o.measured)==null?void 0:m.height)!=null?x:0,a=r+s,l=n+i,c=new Set,d=1/0;for(let k of t){if(k.id===e||k.parentId)continue;let O=(b=(T=k.position)==null?void 0:T.y)!=null?b:0,G=(v=(I=k.position)==null?void 0:I.x)!=null?v:0,Y=(S=(N=k.measured)==null?void 0:N.width)!=null?S:0,j=(L=(M=k.measured)==null?void 0:M.height)!=null?L:0;G<l&&G+Y>n&&O<a&&O+j>r&&(c.add(k.id),d=Math.min(d,O))}if(c.size===0)return t;let u=a+ey-d;return t.map(k=>{var G,Y,j;if(!c.has(k.id))return k;let O=(Y=(G=k.position)==null?void 0:G.y)!=null?Y:0;return w(_({},k),{position:w(_({},(j=k.position)!=null?j:{x:0,y:0}),{y:O+u})})})},De=15,nn=e=>[...e].sort((t,o)=>t.position.y-o.position.y),ty=e=>{var t,o,n;return e.position.x+((n=(o=(t=e.measured)==null?void 0:t.width)!=null?o:e.width)!=null?n:0)},oy=e=>{var t,o,n;return e.position.y+((n=(o=(t=e.measured)==null?void 0:t.height)!=null?o:e.height)!=null?n:0)},la=(e,t,o)=>{var d,u,p,f,h,E,g,y,m,x,T,b,I,v,N;if(t.length===0)return e;let n=(p=(u=e.width)!=null?u:(d=e.measured)==null?void 0:d.width)!=null?p:0,r=(E=(h=e.height)!=null?h:(f=e.measured)==null?void 0:f.height)!=null?E:0,i=0,s=0;for(let S of t){let M=ty(S),L=oy(S);if(((y=(g=S.position)==null?void 0:g.y)!=null?y:0)<De&&(o.set(S.id,w(_({},S),{position:w(_({},S.position),{y:De})})),L=De+((x=(m=S.measured)==null?void 0:m.height)!=null?x:0)),((b=(T=S.position)==null?void 0:T.x)!=null?b:0)<ie.HEADER_WIDTH+De){let k=(I=o.get(S.id))!=null?I:S;o.set(S.id,w(_({},k),{position:w(_({},k.position),{x:ie.HEADER_WIDTH+De})})),M=ie.HEADER_WIDTH+De+((N=(v=S.measured)==null?void 0:v.width)!=null?N:0)}i=Math.max(i,M),s=Math.max(s,L)}let a=Math.max(n,ie.MIN_WIDTH),l=Math.max(r,ie.MIN_HEIGHT);i+De>a&&(a=i+De),s+De>l&&(l=s+De);let c=w(_({},e),{width:a,height:l,measured:w(_({},e.measured),{width:a,height:l})});return o.set(e.id,c),c},iu=(e,t,o)=>{var s,a;let n=nn(e),r=new Map;for(let l of o)l.parentId&&(r.has(l.parentId)||r.set(l.parentId,[]),r.get(l.parentId).push(l));let i=0;for(let l of n){let c=(s=r.get(l.id))!=null?s:[],d=la(l,c,t);t.set(d.id,w(_({},d),{position:{x:ie.HEADER_WIDTH,y:i}})),i+=(a=d.height)!=null?a:0}},su=(e,t)=>{var h,E,g,y;let o=[];for(let m of t.values())m.parentId===e.id&&o.push(m);let n=nn(o),r=((E=(h=e.measured)==null?void 0:h.width)!=null?E:0)-ie.HEADER_WIDTH,i=cl(e.id,o)||ie.MIN_WIDTH,s=o.reduce((m,x)=>{var T;return m+((T=x.height)!=null?T:ie.MIN_HEIGHT)},0),a=Math.max(r,i),l=s,c=r>i,d=c?a:a+ie.HEADER_WIDTH,u=c?a-ie.HEADER_WIDTH:a,p=0;for(let m=0;m<n.length;m++){let x=n[m],T=Math.max(ie.MIN_HEIGHT,(g=x.height)!=null?g:ie.MIN_HEIGHT),b=w(_({},x),{width:u,height:T,measured:w(_({},x.measured),{width:u,height:T}),position:{x:ie.HEADER_WIDTH,y:p}});if(m===o.length-1){let I=Math.max(ie.MIN_HEIGHT,l-p);b=w(_({},b),{height:I,measured:w(_({},x.measured),{width:u,height:I})})}t.set(x.id,b),p+=(y=b.height)!=null?y:0}let f=Math.max(l,p);t.set(e.id,w(_({},e),{width:d,height:f,measured:w(_({},e.measured),{width:d,height:f})}))},au=(e,t,o,n,r)=>{var h,E;let i=!e.parentId,s=i?e.id:e.parentId,a=n.filter(g=>g.type==="LANE"&&g.parentId===s);if(!a.length)return n;let l=nn(a),c=l.findIndex(g=>g.id===e.id),d=(E=(h=e.position)==null?void 0:h.y)!=null?E:0,u=!i&&r!==void 0&&c>0&&Math.abs(r-d)>.5,p=0,f=[...n];return l.forEach((g,y)=>{var I,v;let m=y===l.length-1,x=g.id===e.id,b=(v=(I=g.measured)==null?void 0:I.height)!=null?v:0;x?b=o:u&&y===c-1&&(b=Math.max(ie.MIN_HEIGHT,r-p)),m&&i&&(b=Math.max(ie.MIN_HEIGHT,o-p)),f=f.map(N=>{if(N.id===g.id){let S=i?t-ie.HEADER_WIDTH:t;return w(_({},N),{width:S,height:b,measured:w(_({},N.measured),{width:S,height:b}),position:{x:ie.HEADER_WIDTH,y:p}})}return N}),x&&u?p=r+o:p+=b}),f=f.map(g=>{if(g.id===s){let y=i?t:t+ie.HEADER_WIDTH;return w(_({},g),{width:y,height:i?o:p,measured:{width:y,height:i?o:p}})}return g}),f};var ca=(e,t,o)=>{var a,l,c,d,u,p,f,h;if(e.type==="LANE")return o;let n=(l=(a=t.measured)==null?void 0:a.width)!=null?l:0,r=(d=(c=t.measured)==null?void 0:c.height)!=null?d:0;e.position.y<De&&(e.position.y=De),e.position.x<ie.HEADER_WIDTH+De&&(e.position.x=ie.HEADER_WIDTH+De);let i=e.position.x+((p=(u=e.measured)==null?void 0:u.width)!=null?p:0),s=e.position.y+((h=(f=e.measured)==null?void 0:f.height)!=null?h:0);return i+De>n&&(t.width=i+De,t.measured.width=i+De),s+De>r&&(t.height=s+De,t.measured.height=s+De),o=o.map(E=>E.id===t.id?w(_({},E),{height:t.height,width:t.width,measured:t.measured}):E.id===e.id?w(_({},E),{position:e.position}):E),o};var ss=(e=[],t=[],o="LR")=>{let n=new da.default.graphlib.Graph;return n.setDefaultEdgeLabel(()=>({})),n.setGraph({rankdir:o}),e.forEach(({id:i,width:s,height:a})=>n.setNode(i,{width:s,height:a})),t.forEach(i=>n.setEdge(i.source,i.target)),da.default.layout(n),{nodes:e.map(i=>{let s=n.node(i.id);return w(_({},i),{position:{x:s.x-i.width/2,y:s.y-i.height/2}})}),edges:t}},Po=e=>{let t=e.filter(n=>n.type==="LANE"&&!n.parentId);if(t.length===0)return e;let o=sl(e);for(let n of t){let r=[...o.values()],i=r.filter(a=>a.parentId===n.id);if(i.length===0)continue;let s=i.filter(a=>a.type==="LANE");if(s.length>0){iu(s,o,r),su(n,o);continue}la(n,i,o)}return al(e,o)};var lu=()=>{let e=document.querySelector(".react-flow__viewport");return e||(console.error("Flow element (.react-flow__viewport) not found."),null)};var as=require("react/jsx-runtime"),pa=require("react"),ny=["top","right","bottom","left"],ry=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Rt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Ut(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=(0,go.useReactFlow)(),{getInternalNodes:l}=is(),c=qt(),d=(0,go.useStoreApi)(),u=(0,ua.useRef)(0),p=(0,ua.useRef)([]),f=({y,width:m,height:x})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Y,j;if(!e)return;let{nodeLookup:T,onNodesChange:b}=d.getState(),I=T.get(e);if(!I||I.type!=="LANE")return;let v=!I.parentId,N=v?I.id:I.parentId;if(!N)return;let S=Array.from(T.values()).filter(q=>q.type==="LANE"&&q.parentId===N);if(!S.length)return;p.current.length===0&&(p.current=nn(S).map(q=>q.id));let M=p.current.map(q=>S.find(U=>U.id===q)).filter(Boolean),L=[],k=0,O=M.findIndex(q=>q.id===I.id),G=!v&&O>0&&Math.abs(y-I.position.y)>.5;for(let q=0;q<M.length;q++){let U=M[q],A=U.id===I.id,P=q===M.length-1;if(A){k=G?y+x:k+x;continue}let R=(j=(Y=U.measured)==null?void 0:Y.height)!=null?j:0,C=v?m-ie.HEADER_WIDTH:m,B=R;v&&P&&(B=Math.max(ie.MIN_HEIGHT,x-k)),G&&q===O-1&&(B=Math.max(ie.MIN_HEIGHT,y-k)),L.push({id:U.id,type:"dimensions",dimensions:{width:C,height:B},setAttributes:!0}),L.push({id:U.id,type:"position",position:{x:ie.HEADER_WIDTH,y:k}}),k+=B}v?L.push({id:N,type:"dimensions",dimensions:{width:m,height:x},setAttributes:!0}):L.push({id:N,type:"dimensions",dimensions:{width:m+ie.HEADER_WIDTH,height:k},setAttributes:!0}),b==null||b(L)})},h=({y,width:m,height:x})=>{var I;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let T=s(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let b=[...l()];if(T.type!=="LANE"){b=b.map(v=>v.id===e?w(_({},v),{width:m,height:x,measured:{width:m,height:x}}):v),b=Po(b),a(b);return}b=au(T,m,x,b,y),b=Po(b),b=on((I=T.parentId)!=null?I:T.id,b),a(b)};if(!(!c&&t))return null;let g={"--resize-offset":`${o}px`};return(0,as.jsxs)(as.Fragment,{children:[ny.map(y=>(0,pa.createElement)(go.NodeResizeControl,w(_({},n),{key:y,nodeId:e,position:y,variant:go.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:g,onResize:(m,x)=>f(x),onResizeEnd:(m,x)=>h(x)}))),ry.map(y=>(0,pa.createElement)(go.NodeResizeControl,w(_({},n),{key:y,nodeId:e,position:y,className:"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]",style:g,onResize:(m,x)=>f(x),onResizeEnd:(m,x)=>h(x)})))]})};var rn=require("@xyflow/react"),no=require("@produto-lecom/lecom-ui"),nt=tr(require("react"),1);var cu=require("zustand"),Un=(0,cu.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var ls=require("react"),du=(e,t=!1)=>{let[o,n]=(0,ls.useState)({width:0,height:0});return(0,ls.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Lo=require("@xyflow/react"),uu=require("react"),iy=120,sy=12,pu=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Lo.useReactFlow)(),{instanceId:i}=K();return(0,uu.useMemo)(()=>{var f,h;if(!t)return{position:Lo.Position.Right,align:"start"};let s=n(e);if(!s)return{position:Lo.Position.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((f=s.measured)==null?void 0:f.width)||s.width||100)*a.zoom,d=(h=document.getElementById(`modeler-${i}`))==null?void 0:h.clientWidth;if(!d)return{position:Lo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||iy;return{position:l+c+u+sy>d?Lo.Position.Left:Lo.Position.Right}},[i,e,t,o,n,r])};var fa=require("lucide-react");var cs=require("@xyflow/react"),he=require("@produto-lecom/lecom-ui"),fu=require("lucide-react");var ve=require("react/jsx-runtime"),mu=({nodeId:e})=>{let{t}=(0,he.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,cs.useReactFlow)(),i=(0,cs.useNodesData)(e),a=n().filter(h=>h.source===e).some(h=>{let E=r(h.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return(0,ve.jsxs)(he.DropdownMenu,{children:[(0,ve.jsxs)(he.Tooltip,{children:[(0,ve.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)(he.DropdownMenuTrigger,{asChild:!0,children:(0,ve.jsx)(he.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,ve.jsx)(fu.WrenchIcon,{})})})}),(0,ve.jsx)(he.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,ve.jsxs)(he.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,ve.jsxs)(he.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,ve.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,ve.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(ni).map(([p,f])=>{let h=p==="LOOP"&&(a||l||c),g=(()=>{if(p==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return(0,ve.jsxs)(he.Tooltip,{children:[(0,ve.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)(he.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:h,className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":h}),onClick:h?void 0:()=>u(p),children:(0,ve.jsx)(f.icon,{className:"stroke-inherit"})})}),g&&(0,ve.jsx)(he.TooltipContent,{color:"black",children:g})]},p)})})]}),(0,ve.jsx)(he.DropdownMenuGroup,{children:(0,ve.jsxs)(he.Tooltip,{children:[(0,ve.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,ve.jsx)("div",{className:H({"cursor-not-allowed":a}),children:(0,ve.jsxs)(he.DropdownMenuItem,{className:H({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[(0,ve.jsx)(oi.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&(0,ve.jsx)(he.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var ke=require("react/jsx-runtime"),ho={START_EVENT:{type:"START_EVENT",icon:rr,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:xn,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:rr,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Qr,label:"bpmn.annotation.variant.default"}},ay={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:bn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:vn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:En,label:"bpmn.gateway.variant.complex"}},ct=nt.default.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,nt.useRef)(null),i=(0,nt.useRef)(null),{t:s}=(0,no.useTranslation)(),{setDraggableNode:a}=Un(),{getEdges:l,getNodes:c,setNodes:d}=(0,rn.useReactFlow)(),{setIsDragging:u,mode:p,isConnecting:f,isDragging:h}=K(),E=qt(),g=(0,rn.useStore)((0,nt.useCallback)(z=>{var $,Z;return(Z=($=z.nodeLookup.get(e))==null?void 0:$.selected)!=null?Z:!1},[e])),y=(0,rn.useStore)((0,nt.useCallback)(z=>{var $,Z;return(Z=($=z.nodeLookup.get(e))==null?void 0:$.dragging)!=null?Z:!1},[e])),m=g&&!y&&!f&&!h&&!E,{dimensions:x}=du(r,m),{position:T}=pu(e,m,x),[b,I]=(0,nt.useState)(void 0),v=o==="SUBPROCESS",N=o==="SERVICE_TASK",S=(0,nt.useRef)(null),M=(0,nt.useRef)(!1),L=(0,nt.useCallback)(()=>{S.current!==null&&(clearTimeout(S.current),S.current=null),M.current=!1,u(!1),a(null),I(void 0),d(z=>z.map($=>w(_({},$),{className:void 0})))},[u,a,d]);(0,nt.useEffect)(()=>{let z=$=>{M.current&&$.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let k=(0,nt.useCallback)((z,$)=>{M.current=!0,u(!1),a({type:$.type,variant:$.variant,attribute:$.attribute,icon:$.icon}),$.icon&&I((0,ke.jsx)($.icon,{})),z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("sourceId",e),i.current&&z.dataTransfer.setDragImage(i.current,10,10),S.current=setTimeout(()=>{S.current=null,u(!0)},100)},[e,a,u]),O=(0,nt.useCallback)(()=>{L()},[L]);if(!m)return null;let G=c(),Y=l(),j=[{component:(0,ke.jsx)(Wi,{elementId:e})}],q=()=>{if(p==="view")return[];let z=!Y.some($=>{var Z;return $.source===e&&((Z=G.find(W=>W.id===$.target))==null?void 0:Z.type)!=="ANNOTATION"});return[{component:(0,ke.jsx)(Dn,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},ho.TASK,ho.ANNOTATION,...j]},U=()=>p==="view"?[{component:(0,ke.jsx)(Co,{elementId:e})}]:[{component:(0,ke.jsx)(Co,{elementId:e})},...v||N?[]:[{component:(0,ke.jsx)(mu,{nodeId:e})}],{component:(0,ke.jsx)(Dn,{nodeId:e})},ho.TASK,{type:"TASK",variant:"SUBPROCESS",icon:ir,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:fa.Bot,label:"bpmn.task.variant.service_task"},ho.ANNOTATION,...Object.values(ay),...Jo(e,G,Y)?[]:[ho.END_EVENT],...j],A=()=>p==="view"?[{component:(0,ke.jsx)(Co,{elementId:e,elementType:"gateway"})}]:[{component:(0,ke.jsx)(Co,{elementId:e,elementType:"gateway"})},{component:(0,ke.jsx)(Dn,{nodeId:e})},ho.TASK,{type:"TASK",variant:"SUBPROCESS",icon:ir,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:fa.Bot,label:"bpmn.task.variant.service_task"},ho.ANNOTATION,...j],P=()=>p==="view"?[]:[ho.ANNOTATION,...j],R=()=>p==="view"?[]:[...n?[]:[{component:(0,ke.jsx)(Dn,{nodeId:e})}],ho.ANNOTATION,...j],C=()=>p==="view"?[]:[{component:(0,ke.jsx)(Dn,{nodeId:e})},...j],B=()=>p==="view"?[]:[...j],D=(z=>{switch(z){case"START_EVENT":return q();case"TASK":return U();case"GATEWAY":return A();case"END_EVENT":return P();case"LANE":return R();case"ANNOTATION":return C();case"UNSUPPORTED":return B();default:return[]}})(t),V=D.length>6;if(!(D.length===0||p==="readonly"))return(0,ke.jsxs)(rn.NodeToolbar,{position:T,align:"start",className:V?"-top-[4.5rem]":"-top-8",isVisible:m,children:[(0,ke.jsx)("div",{ref:r,className:`${V?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:D.map((z,$)=>{if(z.component)return(0,ke.jsx)("div",{children:z.component},$);let Z={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:G,edges:Y},W=_d(Z),X={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"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},Q=W.shouldDisable&&W.reason?X[W.reason]||s(z.label):s(z.label)||"";return(0,ke.jsxs)(no.Tooltip,{children:[(0,ke.jsx)(no.TooltipTrigger,{asChild:!0,children:(0,ke.jsx)(no.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!W.shouldDisable,disabled:W.shouldDisable,className:W.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:W.shouldDisable?void 0:ee=>k(ee,z),onDragEnd:W.shouldDisable?void 0:O,children:z.icon&&(0,ke.jsx)(z.icon,{size:16})})}),(0,ke.jsx)(no.TooltipContent,{color:"black",children:Q})]},$)})}),(0,ke.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})});ct.displayName="NodeToolbar";var Qe=require("react/jsx-runtime"),gu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,bt.useReactFlow)(),{inProgress:s,fromNode:a}=(0,bt.useConnection)(),{mode:l,isReadOnly:c}=K(),d=s&&(a==null?void 0:a.id)!==e,u=(0,ds.useCallback)(h=>{let x=h.split(`
40
- `),T=x.reduce((N,S)=>Math.max(N,S.length),0),b=x.length,I=Math.max(Yn.MIN_WIDTH,T*7+32),v=Math.max(Yn.MIN_HEIGHT,b*20+24);i(N=>N.map(S=>S.id===e?w(_({},S),{width:I,height:v,style:w(_({},S.style),{width:I,height:v})}):S))},[e,i]),p=(0,ds.useCallback)(h=>{r(e,{label:h}),u(h)},[e,r,u]),f=(0,ds.useCallback)(h=>{u(h)},[u]);return(0,Qe.jsxs)("div",{className:H("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",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"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,Qe.jsx)(st,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:f,skipFirstCharValidation:!0}),(0,Qe.jsx)(ct,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Qe.jsx)(Rt,{nodeId:e,minWidth:Yn.MIN_WIDTH,minHeight:Yn.MIN_HEIGHT,isVisible:!n&&o}),!s&&(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Left,id:"left"}),(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Right,id:"right"}),(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Top,id:"top"}),(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Bottom,id:"bottom"})]}),(!s||d)&&(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Left,id:"left",className:H({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Right,id:"right",className:H({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Top,id:"top",className:H({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Bottom,id:"bottom",className:H({"annotation-handle":d})})]})]})};var Tt=require("@xyflow/react"),hu=require("react");var ze=require("react/jsx-runtime"),yu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Tt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,Tt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=K(),[d,u]=(0,hu.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=g=>{r(e,{label:g})},h=()=>{u(!0)},E=()=>{u(!1)};return(0,ze.jsxs)("div",{className:"relative",onDoubleClick:h,children:[(0,ze.jsx)(xn,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,ze.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,ze.jsx)(st,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),(0,ze.jsx)(ct,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&(0,ze.jsx)(Rt,{nodeId:e,isVisible:!n&&o,minWidth:ns.MIN_WIDTH,minHeight:ns.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Left,id:"left",className:H({"event-handle":p})}),(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Right,id:"right",className:H({"event-handle":p})}),(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Top,id:"top",className:H({"event-handle":p})}),(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Left,id:"left"}),(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Right,id:"right"}),(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Top,id:"top"}),(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Bottom,id:"bottom"})]})]})};var vt=require("@xyflow/react"),$n=require("react");var Ye=require("react/jsx-runtime"),ma=(0,$n.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Ds[t.variant].icon,{updateNodeData:a}=(0,vt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,vt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=K(),[f,h]=(0,$n.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!p,g=(0,$n.useCallback)(x=>{a(e,{label:x})},[e,a]),y=()=>{h(!0)},m=()=>{h(!1)};return(0,Ye.jsxs)("div",{className:"relative",style:{width:o!=null?o:zn.MIN_WIDTH,height:n!=null?n:zn.MIN_HEIGHT},onDoubleClick:y,children:[(0,Ye.jsx)(s,{className:H("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Ye.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ye.jsx)(st,{value:t.label,isEditing:f,onBlur:m,onChange:g})}),(0,Ye.jsx)(ct,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,Ye.jsx)(Rt,{nodeId:e,isVisible:!i&&r,minWidth:zn.MIN_WIDTH,minHeight:zn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Left,id:"left",className:H({"gateway-handle":E})}),(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Right,id:"right",className:H({"gateway-handle":E})}),(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Top,id:"top",className:H({"gateway-handle":E})}),(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Bottom,id:"bottom",className:H({"gateway-handle":E})})]}),!l&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})});ma.displayName="Gateway";var xu=require("@xyflow/react"),Yt=require("@produto-lecom/lecom-ui"),ly=require("lucide-react");var Eu=require("react/jsx-runtime");var Nt=require("@xyflow/react"),_u=require("react");var Fe=require("react/jsx-runtime"),bu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Nt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,Nt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=K(),[d,u]=(0,_u.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,f=g=>{r(e,{label:g})},h=()=>{u(!0)},E=()=>{u(!1)};return(0,Fe.jsxs)("div",{className:"relative",onDoubleClick:h,children:[(0,Fe.jsx)(ti,{className:H("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Fe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Fe.jsx)(st,{value:t.label,isEditing:d,onBlur:E,onChange:f})}),(0,Fe.jsx)(ct,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&(0,Fe.jsx)(Rt,{nodeId:e,isVisible:!n&&o,minWidth:os.MIN_WIDTH,minHeight:os.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Left,id:"left",className:H({"event-handle":p})}),(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Right,id:"right",className:H({"event-handle":p})}),(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Top,id:"top",className:H({"event-handle":p})}),(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Bottom,id:"bottom",className:H({"event-handle":p})})]}),!i&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var wu=require("@produto-lecom/lecom-ui"),wt=require("@xyflow/react"),sn=require("react");var Sr=60,us=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.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<=Sr?i:i.substring(0,Sr).trim()},Kn=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>Sr&&(n=n.substring(0,Sr).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=Sr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var Mr=require("react/jsx-runtime"),Tu=e=>(0,Mr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Mr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,Mr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ga=require("react/jsx-runtime"),vu=e=>(0,ga.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,ga.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 Pr=require("react/jsx-runtime"),Nu=e=>(0,Pr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Pr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Pr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fe=require("react/jsx-runtime"),cy={APROVADO:Tu,EM_ANDAMENTO:vu,REJEITADO:Nu},ha={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover: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)]"},dy={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},ya=(0,sn.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=(0,wu.useTranslation)(),{toast:a}=et(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,wt.useReactFlow)(),{inProgress:u,fromNode:p}=(0,wt.useConnection)(),{mode:f,isReadOnly:h,onSubprocessValidationClick:E,reconnectingEdgeId:g}=K(),{getTaskStatus:y}=Xo(),m=u&&(p==null?void 0:p.id)!==e||!!g,x=y(e),T=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",I=!!t.variant&&!T&&!b||!!x,v=!!t.attribute||T||b,N=(0,sn.useCallback)(U=>{let C=I||v?80:40,B=U.split(`
41
- `),F=B.reduce(($,Z)=>Math.max($,Z.length),0),D=B.length,V=Math.max(Mo.MIN_WIDTH,F*7+64),z=Math.max(Mo.MIN_HEIGHT,D*24+C);d($=>$.map(Z=>Z.id===e?w(_({},Z),{width:V,height:z,style:w(_({},Z.style),{width:V,height:z})}):Z))},[e,d,I,v]),S=(0,sn.useCallback)(U=>{let A=U.trim(),P=t.label||"";if(A===P)return;let R=A,C=c();if(!(A&&A!=="")){R=us(C,s("bpmn.task.label.prefix")),l(e,{label:R}),N(R),a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",(0,fe.jsx)("strong",{children:R})]})});return}let F=Kn(R,C);F===P||(l(e,{label:F}),N(F),F!==R&&a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",(0,fe.jsx)("strong",{children:A})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",(0,fe.jsx)("strong",{children:F})]})}))},[t.label,c,e,s,l,N,a]),M=(0,sn.useCallback)(U=>{N(U)},[N]),L=(0,sn.useCallback)(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),k=x?cy[x]:null,O=t.variant?oi[t.variant].icon:null,G=t.attribute?ni[t.attribute].icon:null,Y=()=>t.hasError?ha.error:x?ha[x]:h?ha.default:"",j=()=>{var U;return r&&(U=dy[x])!=null?U:""},q=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,fe.jsxs)("div",{className:H("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",Y(),{"cursor-pointer":h,"border-blue-500 hover:border-blue-600 shadow-md":r&&!h&&!x,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Mo.MIN_WIDTH,height:n!=null?n:Mo.MIN_HEIGHT},children:[(0,fe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,fe.jsx)(st,{value:t.label,maxLength:60,className:H(j(),{"py-10 px-8":I||v}),onChange:S,onInput:M,onInvalidFirstCharacter:L})}),O&&(0,fe.jsx)("div",{className:H("absolute flex items-center p-1",T||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,fe.jsx)(O,{size:b?20:16,className:H(t.hasError?"text-red-500":"text-grey-500",T&&"cursor-pointer"),onClick:T?q:void 0})}),G&&(0,fe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,fe.jsx)("div",{className:H("flex items-center w-16 p-1",T||b?"justify-between":"justify-center"),children:(0,fe.jsx)(G,{size:16,className:H(t.hasError?"text-red-500":"text-grey-500")})})}),k&&(0,fe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,fe.jsx)(k,{})}),(0,fe.jsx)(ct,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),f==="edit"&&(0,fe.jsx)(Rt,{nodeId:e,isVisible:!i&&r,minWidth:Mo.MIN_WIDTH,minHeight:Mo.MIN_HEIGHT}),(!u||m)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ne,{type:"target",position:wt.Position.Left,id:"left",className:H({"task-handle":m})}),(0,fe.jsx)(ne,{type:"target",position:wt.Position.Right,id:"right",className:H({"task-handle":m})}),(0,fe.jsx)(ne,{type:"target",position:wt.Position.Top,id:"top",className:H({"task-handle":m})}),(0,fe.jsx)(ne,{type:"target",position:wt.Position.Bottom,id:"bottom",className:H({"task-handle":m})})]}),!u&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(lt,{type:"source",position:wt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(lt,{type:"source",position:wt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(lt,{type:"source",position:wt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(lt,{type:"source",position:wt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})});ya.displayName="Task";var xa=require("@xyflow/react");var yo=require("react/jsx-runtime"),Iu=({id:e,data:t})=>(0,yo.jsxs)(yo.Fragment,{children:[(0,yo.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,yo.jsx)(ct,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,yo.jsx)(ne,{type:"source",position:xa.Position.Right}),(0,yo.jsx)(ne,{type:"target",position:xa.Position.Left})]});var Oe=require("@xyflow/react"),ps=require("react");var Pe=require("react/jsx-runtime"),aA={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Oe.MarkerType.Arrow},data:{label:""}},Au=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=(0,Oe.useViewport)(),{updateEdgeData:d}=(0,Oe.useReactFlow)(),{mode:u,instanceId:p}=K(),f=qt(),h=u!=="edit",[E,g]=(0,ps.useState)(!1),{reconnectingHandle:y,cursorPosition:m,hoveredNodeId:x,reconnectingSide:T,isValidReconnection:b,handleReconnectStart:I}=Ji({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:h}),v=(0,Oe.useInternalNode)(t),N=(0,Oe.useInternalNode)(o),{sx:S,sy:M,tx:L,ty:k,sourcePos:O,targetPos:G}=(0,ps.useMemo)(()=>{var te,xe;if(!v||!N)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Oe.Position.Left,targetPos:Oe.Position.Right};let F=An(v,N),D=a?i:F.sourcePos,V=l?s:F.targetPos,z=(pe,le,Ae)=>{var oe,ae,Ce,$e,Ke,ut;let{x:Xe,y:rt}=pe.internals.positionAbsolute,J=(Ce=(ae=(oe=pe.measured)==null?void 0:oe.width)!=null?ae:pe.width)!=null?Ce:0,se=(ut=(Ke=($e=pe.measured)==null?void 0:$e.height)!=null?Ke:pe.height)!=null?ut:0;switch(le){case Oe.Position.Top:return{x:Xe+J*Ae,y:rt};case Oe.Position.Bottom:return{x:Xe+J*Ae,y:rt+se};case Oe.Position.Left:return{x:Xe,y:rt+se*Ae};case Oe.Position.Right:return{x:Xe+J,y:rt+se*Ae};default:return{x:Xe+J/2,y:rt+se/2}}},$=(te=n==null?void 0:n.sourceOffset)!=null?te:.5,Z=(xe=n==null?void 0:n.targetOffset)!=null?xe:.5,W=v?z(v,D,$).x:F.sx,X=v?z(v,D,$).y:F.sy,Q=N?z(N,V,Z).x:F.tx,ee=N?z(N,V,Z).y:F.ty;return y==="source"&&m?(W=m.x,X=m.y,T&&(D=T)):y==="target"&&m&&(Q=m.x,ee=m.y,T&&(V=T)),{sx:W,sy:X,tx:Q,ty:ee,sourcePos:D,targetPos:V}},[v,N,a,l,i,s,y,m,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!N)return null;let[Y,j,q]=(0,Oe.getSmoothStepPath)({sourceX:S,sourceY:M,targetX:L,targetY:k,sourcePosition:O,targetPosition:G}),U=r||(v==null?void 0:v.selected)||(N==null?void 0:N.selected),A=U?"sequence-edge-marker-highlighted":"sequence-edge-marker",P=E||(n==null?void 0:n.label.trim().length)>0,R=()=>{g(!1)},C=F=>{d(e,{label:F.trim()})};return(0,Pe.jsxs)("g",{className:H("group bpmn-arrow-edge",{"is-highlighted":U}),onDoubleClick:()=>!h&&g(!0),children:[(0,Pe.jsx)("path",{d:Y,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Pe.jsxs)("g",{className:H("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":U}),children:[(0,Pe.jsx)(Oe.BaseEdge,{id:e,path:Y,interactionWidth:0,markerEnd:`url(#${A})`,strokeDasharray:4,className:H("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||y&&x&&!b,"stroke-green-500":y&&x&&b,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":U&&!(n!=null&&n.hasError)&&!y})}),(0,Pe.jsxs)(Oe.EdgeLabelRenderer,{children:[(0,Pe.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${q}px)`},children:[r&&!f&&(0,Pe.jsx)(Hn,{sx:S,sy:M,tx:L,ty:k,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:(0,Pe.jsx)(Vn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&(0,Pe.jsx)(st,{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:E,onBlur:R,onChange:C})]}),r&&!f&&!h&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${S}px, ${M}px)`},children:(0,Pe.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:y==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:y==="source"?.6:.3,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!y||y!=="source","cursor-not-allowed":y==="source"&&x&&!b,"cursor-grabbing":y==="source"&&(!x||b)}),onMouseDown:F=>I("source",F.nativeEvent)})]})}),(0,Pe.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${k}px)`},children:(0,Pe.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:y==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:y==="target"?.6:.3,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:H("pointer-events-auto",{"cursor-move":!y||y!=="target","cursor-not-allowed":y==="target"&&x&&!b,"cursor-grabbing":y==="target"&&(!x||b)}),onMouseDown:F=>I("target",F.nativeEvent)})]})})]})]})]})]})};var an=require("@xyflow/react"),Lr=require("react/jsx-runtime"),Cu=({toX:e,toY:t,fromNode:o})=>{var u,p;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(p=i.height)!=null?p:0,c=[{x:n,y:r+a/2,pos:an.Position.Left},{x:n+s,y:r+a/2,pos:an.Position.Right},{x:n+s/2,y:r,pos:an.Position.Top},{x:n+s/2,y:r+a,pos:an.Position.Bottom}].reduce((f,h)=>{let E=Math.hypot(e-f.x,t-f.y);return Math.hypot(e-h.x,t-h.y)<E?h:f}),[d]=(0,an.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Lr.jsxs)("g",{className:"group",children:[(0,Lr.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Lr.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var It=require("@xyflow/react"),Su=require("lodash"),ln=require("react");var Le=require("react/jsx-runtime"),Ea=(0,ln.memo)(({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:s}=(0,It.useReactFlow)(),{mode:a,isReadOnly:l}=K(),{inProgress:c,fromNode:d}=(0,It.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[p,f]=(0,ln.useState)(!1),h=s(),E=!r,g=!E&&((v=h.find(N=>N.id===r))==null?void 0:v.selected),y=(0,ln.useMemo)(()=>(0,Su.orderBy)([...h.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[h,e]),m=E?Xd.MIN_WIDTH:ie.MIN_WIDTH,x=(0,ln.useMemo)(()=>{if(E&&y.length>1){let N=[...y];return N.pop(),N.reduce((M,L)=>{var k,O;return M+((O=(k=L.measured)==null?void 0:k.height)!=null?O:0)},0)+ie.MIN_HEIGHT}return ie.MIN_HEIGHT},[E,y]),T=N=>{i(e,{label:N})},b=()=>{f(!0)},I=()=>{f(!1)};return(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsxs)("div",{className:H("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||g)&&!l}),children:[(0,Le.jsx)("div",{className:H("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||g)&&!l}),onDoubleClick:b,children:(0,Le.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Le.jsx)(st,{value:t.label,className:"w-full h-full self-auto",contentClassName:H({"whitespace-nowrap":p}),isEditing:p,onBlur:I,onChange:T})})}),(0,Le.jsx)("div",{className:"flex-1"})]}),(0,Le.jsx)(ct,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&(0,Le.jsx)(Rt,{nodeId:e,isVisible:!n&&o,minWidth:m,minHeight:x,offset:10}),!c&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(ne,{type:"source",position:It.Position.Left,id:"left"}),(0,Le.jsx)(ne,{type:"source",position:It.Position.Right,id:"right"}),(0,Le.jsx)(ne,{type:"source",position:It.Position.Top,id:"top"}),(0,Le.jsx)(ne,{type:"source",position:It.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(ne,{type:"target",position:It.Position.Left,id:"left",className:H({"annotation-handle":u})}),(0,Le.jsx)(ne,{type:"target",position:It.Position.Right,id:"right",className:H({"annotation-handle":u})}),(0,Le.jsx)(ne,{type:"target",position:It.Position.Top,id:"top",className:H({"annotation-handle":u})}),(0,Le.jsx)(ne,{type:"target",position:It.Position.Bottom,id:"bottom",className:H({"annotation-handle":u})})]})]})});Ea.displayName="Lane";var Mu={START_EVENT:bu,END_EVENT:yu,TASK:ya,GATEWAY:ma,ANNOTATION:gu,LANE:Ea,UNSUPPORTED:Iu},Pu={SEQUENCE_EDGE:ra,MESSAGE_EDGE:Au,ANNOTATION_EDGE:Pd},Lu="#fafafa",ku="#bebebe",Ru=1,Du=10,Ou="bottom-left",_a=.05,Vu=5,Hu=150,Gu=100,Bu=_a,zu=1,Yu={x:0,y:0,zoom:.75},Fu=1,Wu=2,uy={[Fu]:4,[Wu]:2},kr=[Fu,Wu],Xu=[0,1,2],Uu={hideAttribution:!0},ba=kr.reduce((e,t)=>e|uy[t],0);var ko=()=>{let{setViewport:e}=(0,fs.useReactFlow)(),t=(0,fs.useStoreApi)();return{fitToNodes:(0,$u.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=dl(n);if(!s)return;let a=ul({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:Bu,maxZoom:zu,offsetX:Hu,offsetY:Gu});e(a)},[t,e])}};var Ku=require("@xyflow/react");var Dt=()=>{let{getEdges:e,getNodes:t}=(0,Ku.useReactFlow)(),{lastElementId:o}=K(),n=()=>{let i=t(),s=e(),a=Yd(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ro=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,qu.useReactFlow)(),{getLastId:r}=Dt(),{fitToNodes:i}=ko(),{setLastElementId:s}=K(),a=(0,Ta.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await nu(c);i(d),o(d),n(u),s(p)},[o,n,s,i]),l=(0,Ta.useCallback)(()=>{let c=e(),d=t(),u=r();return ou(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var py=500,ms=()=>{let{isInitialized:e,onElementChanges:t}=K(),{exportToMxGraph:o}=Ro(),n=(0,Zu.useDebouncedCallback)(()=>{if(!e)return;let s=o();t==null||t(s)},py);(0,Rr.useEffect)(()=>()=>{n.isPending()&&n.flush()},[n]);let r=(0,Rr.useCallback)(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,Rr.useCallback)(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Ju=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,gs.useReactFlow)(),{emitElementChanges:s}=ms(),a=(0,ro.useRef)(null),{getNextId:l}=Dt(),c=(0,ro.useCallback)(g=>{var b;let y=o(g.source),m=o(g.target);if(!y||!m)return!1;let x={sourceNodeId:y.id,targetNodeId:m.id,sourceNodeType:y.type,targetNodeType:m.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return ea(x).isValid},[o,n,r]),d=(0,ro.useCallback)(g=>{var x,T;let y=l(),m=i(g.source);if(m){let b=i(g.target),I=b?b.internals.positionAbsolute.x+((x=b.measured.width)!=null?x:0)/2:0,v=b?b.internals.positionAbsolute.y+((T=b.measured.height)!=null?T:0)/2:0,N=Bd(m,I,v),S=(b==null?void 0:b.type)==="ANNOTATION"||(m==null?void 0:m.type)==="ANNOTATION",M=S?Gn:kt,L;if(!S&&b&&g.targetHandle){let G=ji(N),Y=ji(g.targetHandle),{x:j,y:q}=ia(m,N),{x:U,y:A}=ia(b,g.targetHandle),R=qi(j,q,U,A,G,Y).slice(1,-1);R.length>0&&(L=R)}let k=w(_(_({},g),M),{id:String(y),sourceHandle:N,data:_(_({},S?{}:kt.data),L?{points:L}:{})}),O=n().concat(k);e(O),t("forceSave",{nodes:r(),edges:O}),s()}},[l,e,s,i,n,r,t]),u=(0,ro.useCallback)((g,y)=>{a.current=y.id},[]),p=(0,ro.useCallback)(()=>{a.current=null},[]),f=(0,ro.useCallback)((g,y)=>{let m=o(y.source),x=o(y.target);if(!m||!x){a.current=null;return}let T={sourceNodeId:m.id,targetNodeId:x.id,sourceNodeType:m.type,targetNodeType:x.type,nodes:r(),edges:n(),reconnectingEdgeId:g.id};if(!ea(T).isValid){a.current=null;return}let I=(0,gs.reconnectEdge)(g,y,n()).map(v=>v.id===g.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(I),t("forceSave",{nodes:r(),edges:I}),a.current=null,s()},[o,r,n,e,s,t]),h=(0,ro.useCallback)(g=>{a.current=g},[]),E=(0,ro.useCallback)(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:f,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:h,clearReconnectingEdge:E}};var Hr=require("@produto-lecom/lecom-ui"),sp=require("@xyflow/react"),Ct=require("react");var Dr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),cn=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Do=(e=[])=>e.filter(t=>t.type==="TASK")||[],Qu=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var hs=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ju=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),At=(e,t=[])=>t.filter(o=>o.source===e),Or=(e,t=[])=>t.filter(o=>o.target===e),ep=(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"},tp=(e,t)=>{let o=At(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},op=e=>e?/[^\s]/.test(e.trim()):!1,Ee=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:[]}},xo=(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)}},fy=(e,t)=>{let o=new Set(e.filter(n=>n.type==="ANNOTATION").map(n=>n.id));return t.filter(n=>!o.has(n.source)&&!o.has(n.target))},np=(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:fy(e,t).map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Vr=[{id:"start_event_not_found",validate:e=>{let t=Dr(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=cn(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Dr(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=At(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Do(e.nodes),o=xo(t,n=>At(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Do(e.nodes),o=xo(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Do(e.nodes),n=xo(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Do(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 Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,s,a;let t=hs(e.nodes),o=[],n=[];for(let l of t){let c=At(l.id,e.edges);for(let d of c){let u=e.nodes.find(h=>h.id===d.target);if((u==null?void 0:u.type)!=="GATEWAY")continue;let p=((r=l.properties)==null?void 0:r.variant)==="EXCLUSIVE"&&((i=u==null?void 0:u.properties)==null?void 0:i.variant)==="PARALLEL",f=((s=l.properties)==null?void 0:s.variant)==="COMPLEX"&&((a=u==null?void 0:u.properties)==null?void 0:a.variant)==="PARALLEL";!p&&!f&&(o.push(l.id,u.id),n.push(d.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Dr(e.nodes),...cn(e.nodes)],o=[],n=[];for(let r of t){let i=At(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=cn(e.nodes),o=[],n=[];for(let r of t){let i=Or(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=At(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ju(e.nodes),o=xo(t,r=>At(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>At(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Do(e.nodes),o=xo(t,n=>!n.label||op(n.label));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return Ee({isValid:!0});let t=cn(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Or(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=Do(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=xo(r,l=>!ep(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Do(e.nodes),o=cn(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Or(l.id,e.edges),d=At(l.id,e.edges),u=c.some(f=>{var h;return((h=e.nodes.find(E=>E.id===f.source))==null?void 0:h.type)==="START_EVENT"}),p=d.some(f=>{var h;return((h=e.nodes.find(E=>E.id===f.target))==null?void 0:h.type)==="END_EVENT"});return u&&p}),r=Or(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return Ee(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=hs(e.nodes),o=[],n=[];for(let r of t){let i=At(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=hs(e.nodes),o=xo(t,n=>At(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Dr(e.nodes),...cn(e.nodes)],o=[],n=[];for(let r of t){let i=At(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=Qu(e.nodes),o=xo(t,n=>!tp(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var rp=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Vr){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}},ip=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var dn=require("react/jsx-runtime"),ap=()=>{let{t:e}=(0,Hr.useTranslation)(),{toast:t}=et(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,sp.useReactFlow)(),{validateCustomDiagram:s}=K(),[a,l]=(0,Ct.useState)(!1),c=(0,Ct.useRef)(!1),d=(0,Ct.useRef)(!1),u=(0,Ct.useRef)(!1),p=(0,Ct.useCallback)(async m=>{let x=np(m.nodes,m.edges),T=rp(x),b=m.nodes.filter(({type:v,data:N})=>v==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(s&&b.length>0){let v=await ip(s,b);T={isValid:T.isValid&&v.isValid,errors:[...T.errors,...v.errors]}}let I=T.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return a||l(!0),{isValid:T.isValid,errors:I}},[a,e,s]),f=(0,Ct.useCallback)((m,x=!0)=>{if(x&&m){let G=m.isValid?e("validation.success.title"):e("validation.errors.title"),Y=m.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:m.isValid?"success":"error",duration:5e3,title:G,content:(0,dn.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,dn.jsx)(Hr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:Y}),!m.isValid&&(0,dn.jsx)("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:m.errors.map(j=>(0,dn.jsx)("li",{children:(0,dn.jsx)(Hr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:j.message})},j.id))})]})})}if(!m)return;c.current=!0,d.current=!0,u.current=!0;let T=[],b=[];m.errors.forEach(G=>{G.nodeIds&&G.nodeIds.length>0&&G.nodeIds.forEach(Y=>T.push(Y)),G.edgeIds&&G.edgeIds.length>0&&G.edgeIds.forEach(Y=>b.push(Y))});let I=[...new Set(T)],v=r(),N=i(),S=new Set(I),M=new Set;m.errors.forEach(G=>{var q,U;let Y=Vr.find(A=>A.id===G.id);(Y==null?void 0:Y.highlightRelatedEdges)!==!1&&((q=G.edgeIds)==null||q.forEach(A=>M.add(A)),(U=G.nodeIds)==null||U.forEach(A=>{N.forEach(P=>{(P.source===A||P.target===A)&&M.add(P.id)})}))});let L=new Set,k=new Set,O=new Set;v.forEach(G=>{G.type==="START_EVENT"?L.add(G.id):G.type==="END_EVENT"&&k.add(G.id)}),N.forEach(G=>{L.has(G.source)&&O.add(G.target),k.has(G.target)&&O.add(G.source)}),O.forEach(G=>{var Y,j;if(S.has(G)){let q=(Y=m.errors.find(A=>{var P;return(P=A.nodeIds)==null?void 0:P.includes(G)}))==null?void 0:Y.id;((j=Vr.find(A=>A.id===q))==null?void 0:j.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===G&&k.has(A.target)&&(S.add(A.target),M.add(A.id)),A.target===G&&L.has(A.source)&&(S.add(A.source),M.add(A.id))})}}),o(G=>G.map(Y=>w(_({},Y),{data:w(_({},Y.data),{hasError:S.has(Y.id)})}))),n(G=>G.map(Y=>w(_({},Y),{data:w(_({},Y.data),{hasError:M.has(Y.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),h=(0,Ct.useCallback)(()=>{l(!1),u.current=!1,o(m=>m.map(x=>w(_({},x),{data:w(_({},x.data),{hasError:!1})}))),n(m=>m.map(x=>w(_({},x),{data:w(_({},x.data),{hasError:!1})})))},[n,o]),E=(0,Ct.useCallback)(()=>{u.current&&(d.current=!0,u.current=!1,o(m=>m.map(x=>w(_({},x),{data:w(_({},x.data),{hasError:!1})}))),n(m=>m.map(x=>w(_({},x),{data:w(_({},x.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),g=(0,Ct.useCallback)(()=>d.current,[]),y=(0,Ct.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:f,clearValidation:h,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:g,getIsValidating:y}};var dp=require("@xyflow/react"),up=require("@produto-lecom/lecom-ui"),pp=require("react");var my=15,lp="bpmn:selection",gy=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},cp=e=>{if(!gy(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},fp=({offset:e=my,saveHistory:t})=>{let{t:o}=(0,up.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,dp.useReactFlow)(),{getNextId:a}=Dt(),{mode:l,containerRef:c}=K();(0,pp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=f=>{var b,I;if(!cp(f)||!d.contains(document.activeElement))return;let E=n(),g=i(),y=E.filter(v=>v.selected);if(!y.length)return;f.preventDefault(),f.stopPropagation();let m=g.filter(v=>y.some(N=>N.id===v.source)&&y.some(N=>N.id===v.target)),T=JSON.stringify({nodes:y,edges:m});(b=f.clipboardData)==null||b.setData(lp,T),(I=f.clipboardData)==null||I.setData("text/plain",`BPMN Selection: ${y.length} nodes`)},p=f=>{var L,k;if(!cp(f)||!d.contains(document.activeElement))return;let E=(L=f.clipboardData)==null?void 0:L.getData(lp);if(!E)return;f.preventDefault(),f.stopPropagation();let g;try{g=JSON.parse(E)}catch(O){return}if(!((k=g.nodes)!=null&&k.length))return;let y=new Map,m=n(),x=[],T=g.nodes.filter(O=>kn(O.type,m));if(T.length===0)return;let b=a(),I=T.map(O=>{var j;let G=String(b++);y.set(O.id,G);let Y=w(_({},O),{id:G,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let q=(j=O.data)==null?void 0:j.label,U=Kn(q||o("bpmn.task.label.prefix"),[...m,...x]);Y.data=w(_({},O.data),{label:U})}return x.push(Y),Y}),v=g.edges.map(O=>w(_({},O),{id:String(b++),selected:!0,source:y.get(O.source)||O.source,target:y.get(O.target)||O.target})),N=[...m.map(O=>w(_({},O),{selected:!1})),...I],M=[...i().map(O=>w(_({},O),{selected:!1})),...v];r(N),s(M),t("forceSave",{nodes:N,edges:M})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",p,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",p,!0)}},[n,r,i,s,a,e,o,t,l,c])};var mp=require("@produto-lecom/lecom-ui"),gp=require("@xyflow/react"),un=require("react");var hp=({nodes:e,setNodes:t})=>{let{t:o}=(0,mp.useTranslation)(),{toast:n}=et(),{getNodes:r}=(0,gp.useReactFlow)(),{setIsRemovingElements:i,validateDeleteElements:s}=K(),a=(0,un.useRef)(!1),l=(0,un.useCallback)(async p=>{try{let{activitiesWithInstances:f}=await s(p);if(f.length)return a.current=!1,i(!1),n({variant:"warning",content:o("editor.toolbar.delete_elements_blocked")}),!1}catch(f){return a.current=!1,i(!1),n({variant:"error",content:o("editor.toolbar.delete_elements_error")}),!1}return!0},[o,n,s,i]),c=(0,un.useCallback)(async({nodes:p})=>{if(a.current)return!1;if(a.current=!0,i(!0),p.some(E=>E.type==="LANE"&&e.some(g=>g.parentId===E.id)))return a.current=!1,i(!1),n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")}),!1;let h=p.filter(E=>E.type==="TASK");if(s&&h.length>0){let E=h.map(g=>g.id);return l(E)}return!0},[e,o,n,s,l,i]),d=(0,un.useCallback)(p=>{a.current=!1,i(!1);let f=new Set(p.filter(h=>h.type==="LANE"&&!!h.parentId).map(h=>h.parentId));f.size!==0&&setTimeout(()=>{var g,y;let h=r(),E=new Map(h.map(m=>[m.id,m]));for(let m of f){let x=nn(h.filter(I=>I.type==="LANE"&&I.parentId===m));if(x.length===0)continue;let T=0;for(let I of x)E.set(I.id,w(_({},I),{position:{x:ie.HEADER_WIDTH,y:T}})),T+=(y=(g=I.measured)==null?void 0:g.height)!=null?y:0;let b=E.get(m);b&&E.set(m,w(_({},b),{height:T,measured:w(_({},b.measured),{height:T})}))}t(h.map(m=>{var x;return(x=E.get(m.id))!=null?x:m}))},0)},[r,t,i]),u=(0,un.useCallback)(()=>{a.current=!1,i(!1)},[i]);return{onBeforeDelete:c,onNodesDelete:d,onEdgesDelete:u}};var yp=require("@produto-lecom/lecom-ui"),xp=require("@xyflow/react");var ys=require("react");var hy=50,Ep=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=Un(),{t:s}=(0,yp.useTranslation)(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,xp.useReactFlow)(),{getNextId:u}=Dt(),{setIsDragging:p}=K(),{getInternalNodes:f}=is(),{rebuildIndex:h,forceRebuildIndex:E}=Vi(),[g,y]=(0,ys.useState)(null),m=(0,ys.useRef)(""),x=(A,P,R)=>{var D;if(A.parentId!==P)return null;let C=R.filter(V=>V.id!==A.id&&V.parentId===P&&V.type==="LANE").sort((V,z)=>V.position.y-z.position.y);if(C.length===0)return null;let B=(D=R.find(V=>V.id===A.id))!=null?D:A,F=C.find(V=>B.position.y<V.position.y);return F?{draggedLaneId:A.id,beforeLaneId:F.id}:{draggedLaneId:A.id,afterLaneId:C[C.length-1].id}},T=(A,P=!1,R)=>{let C=P?"node-drop-target-error":"node-drop-target",B=P?"node-drop-target-lane-error":"node-drop-target-lane";t(F=>{var $,Z,W,X;let D=($=R==null?void 0:R(F))!=null?$:null,V=[A!=null?A:"",P?"error":"valid",(Z=D==null?void 0:D.draggedLaneId)!=null?Z:"",(W=D==null?void 0:D.beforeLaneId)!=null?W:"",(X=D==null?void 0:D.afterLaneId)!=null?X:""].join(":"),z=Q=>{let ee=[];return Q.id===A&&ee.push(C),A!==void 0&&Q.parentId===A&&Q.type==="LANE"&&Q.id!==(D==null?void 0:D.draggedLaneId)&&ee.push(B),Q.id===(D==null?void 0:D.draggedLaneId)&&ee.push("lane-reorder-dragging"),Q.id===(D==null?void 0:D.beforeLaneId)&&ee.push("lane-reorder-before"),Q.id===(D==null?void 0:D.afterLaneId)&&ee.push("lane-reorder-after"),ee.join(" ")||void 0};return m.current===V?F:(m.current=V,F.map(Q=>{let ee=z(Q);return Q.className===ee?Q:w(_({},Q),{className:ee})}))})},b=(A,P)=>{let R=f();if(A.type==="LANE"){if(P){T();return}let V=R.filter(Z=>Z.id!==A.id&&Z.type==="LANE"&&!Z.parentId),z=ar(A,V);if(!z){T();return}if(Wo({parentId:z.id,nodes:e,excludeTypes:["LANE"]})){T(z.id,!0);return}T(z.id,!1,Z=>x(A,z.id,Z));return}let B=R.filter(V=>V.id!==A.id&&V.type==="LANE"),F=ar(A,B);if(!F){T();return}if(Wo({parentId:F.id,nodes:e,includeTypes:["LANE"]})){T();return}T(F.id)},I=A=>{let P=a(A.id),R=A.type==="LANE"&&Wo({parentId:A.id,nodes:e,includeTypes:["LANE"]});b(P,R)},v=A=>(m.current="",A.map(P=>w(_({},P),{className:void 0}))),N=A=>A.some(R=>R.dragging)?A.map(R=>R.dragging?w(_({},R),{dragging:!1}):R):A,S=(A,P)=>{let R=0;for(let C of P){if(C.id===A||C.parentId||C.type==="LANE")continue;let B=Mt(C),F=B.y+B.h;R=Math.max(R,F)}return R+hy},M=(A,P)=>{if(!Os(A,P))return P;let R=S(A,P);return P.map(C=>C.id===A?w(_({},C),{position:w(_({},C.position),{y:R})}):C)},L=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let P=d({x:A.clientX,y:A.clientY}),R={id:"__sidebar_drag__",type:r.type,position:P,measured:{width:1,height:1},internals:{positionAbsolute:P}};b(R,!1)},k=A=>{let P=A.relatedTarget;(!P||!A.currentTarget.contains(P))&&T()},O=(A,P)=>{A.preventDefault(),I(P)},G=(A,P,R)=>{var $,Z;let C=[...R],B=P.parentId?P.parentId:P.id;if(A.parentId===P.id)return C=ca(A,P,C),C=Po(C),C=on(B,C),v(C);if(A.type==="LANE"){if(Wo({parentId:P.id,nodes:C,excludeTypes:["LANE"]})){let te=Ri(P),xe=50,pe=50;return C.map(le=>{var Ae,Xe;return le.id===A.id?w(_({},le),{position:{x:(Ae=g==null?void 0:g.x)!=null?Ae:te.x+xe,y:(Xe=g==null?void 0:g.y)!=null?Xe:te.y2+pe}}):le})}let Q=C.filter(te=>te.parentId===P.id).reduce((te,xe)=>{var pe,le;return te+((le=(pe=xe.measured)==null?void 0:pe.height)!=null?le:0)},0),ee={x:ie.HEADER_WIDTH,y:Q};return C=C.map(te=>te.id===A.id?w(_({},te),{parentId:P.id,position:ee,className:void 0}):w(_({},te),{className:void 0})),C=Po(C),C=M(B,C),C}if(Wo({parentId:P.id,nodes:C,includeTypes:["LANE"]})){let W;if(A.parentId){let X=a(A.parentId),{x:Q,y:ee}=Mt(X);W={x:Q+(($=A.position.x)!=null?$:0),y:ee+((Z=A.position.y)!=null?Z:0)}}return C=C.map(X=>X.id===A.id?w(_({},X),{position:W!=null?W:X.position,parentId:void 0,className:void 0}):w(_({},X),{className:void 0})),C=on(B,C),C}let V=ll(A,P);C=C.map(W=>W.id===A.id?w(_({},W),{parentId:P.id,position:V,className:void 0}):w(_({},W),{className:void 0}));let z=C.find(W=>W.id===A.id);return C=ca(z,P,C),C=Po(C),C=on(B,C),C},Y=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!kn(r.type,l())){p(!1),i(null);return}let P=d({x:A.clientX,y:A.clientY}),R={width:de[r.type].MIN_WIDTH,height:de[r.type].MIN_HEIGHT},C=u(),B={id:String(C),type:r.type,position:P,measured:R,data:{label:r.type==="TASK"?us(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},F=w(_({},B),{internals:{positionAbsolute:P}}),D=w(_({},F),{measured:{width:1,height:1}}),V=f(),z=r.type==="LANE",$=V.filter(te=>z?te.type==="LANE"&&!te.parentId:te.type==="LANE"),Z=ar(D,$),W=[...V.map(te=>w(_({},te),{selected:!1})),F];Z&&(W=G(F,Z,W)),W=sr(W),z&&!Z&&(W=M(F.id,W)),W=v(W),t(W),E();let X=A.dataTransfer.getData("sourceId"),Q=c(),ee=Q;if(X){let te={id:String(C+1),source:X,target:B.id},xe=r.type==="ANNOTATION"?_(_({},te),Gn):_(_({},te),kt);ee=Q.concat(xe),o(ee)}n("forceSave",{nodes:W,edges:ee}),p(!1),i(null)},j=async(A,P,R)=>{let C=[...f()],B=new Set;R.forEach(V=>{let z=a(V.id),$=V.type==="LANE",Z=C.filter(X=>X.id!==V.id&&($?X.type==="LANE"&&!X.parentId:X.type==="LANE")),W=ar(z,Z);if(W){if($&&Wo({parentId:V.id,nodes:C,includeTypes:["LANE"]})){V.parentId&&(C=U(V,C),B.add(V.id));return}C=G(z,W,C);return}V.parentId&&(C=U(V,C),V.type==="LANE"&&B.add(V.id))}),C=N(C);let F=R.filter(V=>V.type==="LANE"&&!V.parentId).map(V=>V.id);for(let V of F)Os(V,C)&&g&&(C=C.map(z=>z.id===V?w(_({},z),{position:_({},g)}):z));for(let V of B)C=M(V,C);if(R.some(V=>V.type!=="LANE"&&!V.parentId)){let V=C.filter(z=>z.type==="LANE"&&!z.parentId).map(z=>z.id);for(let z of V)C=on(z,C)}C=sr(C),C=v(C),t(C),h(C),y(null)},q=(A,P)=>{y({x:P.position.x,y:P.position.y})},U=(A,P)=>{var Z,W,X,Q,ee,te,xe,pe;let R=a(A.parentId);if(!R)return P;let C=A.type==="LANE",B=P.filter(le=>le.parentId===R.id&&le.id!==A.id),F=B.filter(le=>le.type==="LANE"),D;if(C&&F.length===0)D=ie.MIN_HEIGHT;else if(C){let le=(W=(Z=A.measured)==null?void 0:Z.height)!=null?W:ie.MIN_HEIGHT;D=((Q=(X=R.measured)==null?void 0:X.height)!=null?Q:ie.MIN_HEIGHT)-le,D=Math.max(ie.MIN_HEIGHT,D)}else D=B.length>0?B.reduce((le,Ae)=>{var Xe,rt;return le+((rt=(Xe=Ae.measured)==null?void 0:Xe.height)!=null?rt:0)},0)+De:Math.max(ie.MIN_HEIGHT,(te=(ee=R.measured)==null?void 0:ee.height)!=null?te:0);let{x:V,y:z}=Mt(R),$={x:V+((xe=A.position.x)!=null?xe:0),y:z+((pe=A.position.y)!=null?pe:0)};return P=P.map(le=>le.id===A.id?w(_({},le),{position:$,parentId:void 0}):le.id===R.id?w(_({},le),{height:D,measured:w(_({},le.measured),{height:D})}):le),P=Po(P),P};return{onDragOver:L,onDragLeave:k,onDrop:Y,onNodeDrag:O,onNodeDragStart:q,onNodeDragStop:j}};var _p=require("@xyflow/react"),bp=require("@produto-lecom/lecom-ui"),Tp=require("react");var yy=30,xy=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},Ey=e=>!xy(e.target),vp=({offset:e=yy,saveHistory:t})=>{let{t:o}=(0,bp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,_p.useReactFlow)(),{getNextId:a}=Dt(),{mode:l,containerRef:c}=K();(0,Tp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&Ey(p)){p.preventDefault(),p.stopPropagation();let h=n(),E=i(),g=h.filter(M=>M.selected);if(!g.length)return;let y=new Map,m=[],x=g.filter(M=>kn(M.type,h));if(x.length===0)return;let T=E.filter(M=>x.some(L=>L.id===M.source)&&x.some(L=>L.id===M.target)),b=a(),I=x.map(M=>{var O;let L=String(b++);y.set(M.id,L);let k=w(_({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let G=(O=M.data)==null?void 0:O.label,Y=Kn(G||o("bpmn.task.label.prefix"),[...h,...m]);k.data=w(_({},M.data),{label:Y})}return m.push(k),k}),v=T.map(M=>w(_({},M),{id:String(b++),selected:!0,source:y.get(M.source)||M.source,target:y.get(M.target)||M.target})),N=[...h.map(M=>w(_({},M),{selected:!1})),...I],S=[...E.map(M=>w(_({},M),{selected:!1})),...v];r(N),s(S),t("forceSave",{nodes:N,edges:S})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};var Br=require("react"),Np=require("@xyflow/react");var _y=20,by=50,Gr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},Ty=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},wp=e=>{let{getNodes:t}=(0,Np.useReactFlow)(),{mode:o,isMoveTool:n}=K(),r=(0,Br.useRef)(0),i=(0,Br.useRef)(new Map);(0,Br.useEffect)(()=>{let s=a=>{if(o!=="edit"||!n||Ty(a.target)||!Object.values(Gr).includes(a.key))return;let u=t().filter(m=>m.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),f=p-r.current<500;r.current=p;let h=a.shiftKey?by:_y,E=0,g=0;switch(a.key){case Gr.UP:g=-h;break;case Gr.DOWN:g=h;break;case Gr.LEFT:E=-h;break;case Gr.RIGHT:E=h;break}let y=u.map(m=>{let x=i.current.get(m.id);(!f||!x)&&(x={x:m.position.x,y:m.position.y});let T={x:x.x+E,y:x.y+g};return i.current.set(m.id,T),{id:m.id,dragging:!1,type:"position",position:T}});e&&e(y)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};var Mp=require("@xyflow/react");var Ap={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Cp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ip=(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)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a=r[1].replace(/\{|\}/g,""),a.charAt(0)==="+"?(s="gateway-parallel",a=a.slice(1)):a.charAt(0)==="*"?(s="gateway-complex",a=a.slice(1)):s="gateway-exclusive",e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},vy=e=>{e=e||"";let t=e.trim().split(`
42
- `),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 s=Ip(i[0],o),a=Ip(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Sp=e=>{let{components:t,connections:o}=vy(e);return{nodes:t,edges:o}};var Ny=7,wy=48,Iy=340,Ay=(e,t)=>{let o=wy+e.length*Ny;return Math.min(Iy,Math.max(t,o))},xs=()=>{let{setNodes:e,setEdges:t}=(0,Mp.useReactFlow)(),{fitToNodes:o}=ko(),{getNextId:n}=Dt();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=Sp(s),c=[],d=new Map,u=!1,p=n();for(let[m,x]of Object.entries(a)){let T=String(p++),b=Ap[x.type],I=Cp[x.type];b==="START_EVENT"&&(u=!0),d.set(m,T);let v=de[b].MIN_WIDTH,N=de[b].MIN_HEIGHT;c.push({id:T,type:b,data:{label:x.label||"",variant:I,attribute:""},position:{x:0,y:0},width:v,height:N,measured:{width:v,height:N}})}let f=[];for(let m of l){let x=w(_({},kt),{id:String(p++),source:d.get(m.sourceId)||m.sourceId,target:d.get(m.targetId)||m.targetId});f.push(x)}if(!u&&c.length>0){let m=String(p++),x={id:m,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT,measured:{width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT}};c.unshift(x);let T=c[1];if(T){let b=w(_({},kt),{id:String(p++),source:m,target:T.id});f.unshift(b)}}let h=c.map(m=>{var x,T;return m.type==="TASK"?w(_({},m),{width:Ay(String((T=(x=m.data)==null?void 0:x.label)!=null?T:""),de.TASK.MIN_WIDTH)}):m}),{nodes:E}=ss(h,f),g=new Map(E.map(m=>[m.id,m.position])),y=c.map(m=>{var x;return w(_({},m),{position:(x=g.get(m.id))!=null?x:m.position})});e(y),t(f),o(y)}}};var Es=require("react"),Cy={origin:"*",debug:!1};function _s(e,t=Cy){let{origin:o,debug:n}=t,r=(0,Es.useCallback)((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return(0,Es.useEffect)(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),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 Pp=require("@xyflow/react"),qn=require("react");var Lp=()=>{let e=(0,Pp.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=K(),{importFromMxGraph:s,exportToMxGraph:a}=Ro(),{sendMessage:l}=_s(),c=(0,qn.useRef)(!1);(0,qn.useEffect)(()=>{t&&s(t)},[t,s]),(0,qn.useEffect)(()=>{if(!n||!o||c.current)return;c.current=!0;let d=a();i==null||i(d)},[n,o,t,a,i]),(0,qn.useEffect)(()=>{if(!e)return;(async()=>{await jr(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};var kp=require("@xyflow/react"),va=require("react");function Rp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Xo(),{getEdges:n}=(0,kp.useReactFlow)(),r=(0,va.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let a=s.activities.map(c=>c.diagramId),l=n();o(l,a)},[e,o,n]),i=(0,va.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var Op=require("@xyflow/react"),dt=require("react"),Vp=require("use-debounce");var My=500,Dp=100,Hp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,Op.useReactFlow)(),{mode:i,containerRef:s}=K(),[a,l]=(0,dt.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,f=(0,dt.useCallback)((v,N)=>{n(v[N].nodes),r(v[N].edges)},[n,r]),h=(0,dt.useCallback)(()=>{if(d>0){let v=d-1;l(N=>w(_({},N),{currentStep:v})),f(c,v)}},[d,c,f]),E=(0,dt.useCallback)(()=>{if(d<c.length-1){let v=d+1;l(N=>w(_({},N),{currentStep:v})),f(c,v)}},[c,d,f]),g=(0,dt.useCallback)(v=>{l(N=>{let S=N.history[N.currentStep];if(S&&JSON.stringify(S)===JSON.stringify(v))return N;let k=[...N.history.slice(0,N.currentStep+1),v],O=k.length>Dp?k.slice(k.length-Dp):k;return{history:O,currentStep:O.length-1}})},[]),y=(0,dt.useCallback)((v,N)=>{let S=v.map(L=>w(_({},L),{selected:!1,className:"",data:w(_({},L.data),{hasError:!1})})),M=N.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}));return{nodes:sr(S),edges:M}},[]),m=(0,dt.useCallback)(()=>y(t(),o()),[t,o,y]),x=(0,Vp.useDebouncedCallback)(()=>{let v=m();g(v)},My),T=(0,dt.useCallback)((v,N)=>{if(!e)return;if(c.length===0){let M=m();l({history:[M],currentStep:0})}if(v==="forceSave"){if(N){g(y(N.nodes,N.edges));return}x();return}v.some(M=>M.type==="select")||ii(v)||x()},[e,x,c.length,m,g,y]);(0,dt.useEffect)(()=>{if(e&&c.length===0){let v=m();l({history:[v],currentStep:0})}},[e,c.length,m]);let b=(0,dt.useCallback)(v=>{l({history:v||[],currentStep:0})},[]),I=(0,dt.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,dt.useEffect)(()=>{if(i!=="edit")return;let v=s.current;if(!v)return;let N=S=>{if(!v.contains(document.activeElement)||!(S.ctrlKey||S.metaKey))return;let k=S.key.toLowerCase();if(S.shiftKey&&k==="z"){S.preventDefault(),E();return}k==="z"&&(S.preventDefault(),h())};return v.addEventListener("keydown",N),()=>{v.removeEventListener("keydown",N)}},[h,E,i,s]),{history:c,undo:h,redo:E,canUndo:u,canRedo:p,saveHistory:T,resetHistory:b,clearHistory:I}};var Gp=()=>{let[e,t,o]=(0,Oo.useNodesState)([]),[n,r,i]=(0,Oo.useEdgesState)([]),{getNode:s}=(0,Oo.useReactFlow)(),a=(0,Oo.useStoreApi)(),{instanceId:l,isInitialized:c,setIsConnecting:d,onElementClick:u}=K(),{updateHelperLines:p,HelperLines:f}=Vi(),{undo:h,redo:E,canUndo:g,canRedo:y,saveHistory:m}=Hp(c),{onNodeDrag:x,onDrop:T,onDragOver:b,onDragLeave:I,onNodeDragStop:v,onNodeDragStart:N}=Ep({nodes:e,setNodes:t,setEdges:r,saveHistory:m}),{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:k,onReconnectEnd:O,setReconnectingEdge:G,clearReconnectingEdge:Y}=Ju({setEdges:r,saveHistory:m}),{handleValidationComplete:j,clearValidation:q,dismissValidationPanel:U,validateDiagram:A,getIsValidating:P,getIsClearingValidation:R}=ap(),{importFromLia:C}=xs(),{handleTasksStatus:B,handleClearTaskStatus:F}=Rp(),{clearPathEdges:D}=Xo(),{emitElementChanges:V,handleNodeChanges:z,handleEdgeChanges:$}=ms(),Z=gl();fp({saveHistory:m}),vp({saveHistory:m}),Lp();let W=(0,io.useCallback)(()=>{t([]),r([]),D(),setTimeout(Z,0)},[t,r,D,Z]),{selectElements:X,clearSelection:Q}=$t(),{importFromMxGraph:ee,exportToMxGraph:te}=Ro(),{configureElement:xe,getConfigureElement:pe}=Fi(),le=(0,io.useCallback)(Se=>{Se!=null&&Se.id&&X([Se.id])},[X]),{sendMessage:Ae}=_s({LIA_CREATE_DIAGRAM:C,CLEAR_DIAGRAM:W,TASKS_STATUS:B,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:le}),Xe=(0,io.useCallback)(()=>e.length+n.length,[e,n]);(0,io.useEffect)(()=>(to.set(l,{importFromMxGraph:ee,exportToMxGraph:te,selectElements:X,clearSelection:Q,configureElement:xe,getConfigureElement:pe,getElementsCount:Xe,setReconnectingEdge:G,clearReconnectingEdge:Y}),()=>{to.delete(l)}),[l,ee,te,X,Q,xe,pe,Xe,G,Y]);let rt=(0,io.useCallback)((Se,qe)=>{if(qe.type!=="TASK"&&qe.type!=="GATEWAY")return;let yt=pe(qe.id);yt&&(u==null||u(yt)),qe.type==="TASK"&&Ae("SELECT_TASK",{id:qe.id})},[pe,u,Ae]),J=(0,io.useCallback)((Se,qe)=>{if(qe.type!=="SEQUENCE_EDGE")return;let yt=s(qe.source),xt=s(qe.target),{isFromStartEvent:Vt,isGatewayToGateway:pt,isActiviyToAndGateway:Ue,isToEndEvent:it}=ri(yt,xt);if(!(!Vt&&!pt&&!Ue&&!it))return;let Xt=pe(qe.id);Xt&&(u==null||u(Xt))},[pe,s,u]),se=(0,io.useCallback)(Se=>{p(Se,e),o(Se),!ii(Se)&&(m(Se),R()||U(),P()||z(Se))},[e,m,R,U,p,z,P,o]),oe=(0,io.useCallback)(Se=>{i(Se),m(Se),R()||U(),P()||$(Se)},[i,m,R,U,$,P]);wp(se);let{onBeforeDelete:ae,onNodesDelete:Ce,onEdgesDelete:$e}=hp({nodes:e,setNodes:t});return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:S,onConnect:M,onReconnect:L,onReconnectStart:k,onReconnectEnd:O,onDrop:T,onDragOver:b,onDragLeave:I,onNodeDrag:x,onNodeDragStop:v,onNodeDragStart:N,onNodeClick:rt,onEdgeClick:J,onDropCapture:()=>{m("forceSave"),V(),U()},onConnectStart:()=>{d(!0)},onConnectEnd:()=>{d(!1),U()},onSelectionEnd:()=>setTimeout(()=>a.setState({nodesSelectionActive:!1}),0),onNodesChange:se,onEdgesChange:oe,onBeforeDelete:ae,onNodesDelete:Ce,onEdgesDelete:$e},ui:{handleCloseValidationPanel:q},controls:{undo:h,redo:E,canUndo:g,canRedo:y},components:{HelperLines:f},actions:{saveHistory:m,selectElements:X,clearSelection:Q,exportToMxGraph:te,validateDiagram:A,handleValidationComplete:j,setReconnectingEdge:G,clearReconnectingEdge:Y}}};var Bp=require("react"),zp=require("@xyflow/react");function bs(){return(0,zp.useStore)((0,Bp.useCallback)(e=>e.nodes.length+e.edges.length>0,[]))}var Yp=require("@xyflow/react"),Vo=require("react");var Py=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Fp(e,t,o){let[n,r]=(0,Vo.useState)(!1),i=(0,Vo.useRef)(null),{getViewport:s,setViewport:a}=(0,Yp.useReactFlow)(),l=(0,Vo.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Vo.useEffect)(()=>{let c=e.current;if(!c)return;let d=f=>{if(!kr.some(E=>E===f.button)||t.current||o.current||(r(!0),!(f.target instanceof Element))||!f.target.closest(Py))return;f.preventDefault(),f.stopPropagation();let h=s();i.current={pointerX:f.clientX,pointerY:f.clientY,viewportX:h.x,viewportY:h.y,zoom:h.zoom}},u=f=>{let h=i.current;if(h){if((f.buttons&ba)===0){l();return}a({x:h.viewportX+(f.clientX-h.pointerX),y:h.viewportY+(f.clientY-h.pointerY),zoom:h.zoom})}},p=f=>{(f.buttons&ba)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}var Na=require("react/jsx-runtime"),Ts=({id:e,className:t})=>(0,Na.jsx)("marker",{id:e,className:H("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,Na.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var pn=require("react/jsx-runtime"),Wp=()=>(0,pn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,pn.jsxs)("defs",{children:[(0,pn.jsx)(Ts,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,pn.jsx)(Ts,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,pn.jsx)(Ts,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Bo=require("@produto-lecom/lecom-ui");var Wr=require("@xyflow/react"),Ve=require("@produto-lecom/lecom-ui"),so=require("lucide-react"),Ft=tr(require("react"),1);var Ho=require("@produto-lecom/lecom-ui");var zr=(x=>(x.START_EVENT="START_EVENT",x.END_EVENT="END_EVENT",x.TASK="TASK",x.SUBPROCESS="SUBPROCESS",x.GATEWAY="GATEWAY",x.LANE="LANE",x.ANNOTATION="ANNOTATION",x.CONNECTION="CONNECTION",x.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",x.ACTIVITY="ACTIVITY",x.PROCESS_INTERFACE="PROCESS_INTERFACE",x.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",x.VARIANT_ACTIVITY="VARIANT_ACTIVITY",x.AUTO_ACTIVITY="AUTO_ACTIVITY",x.DATA_STORE="DATA_STORE",x.DATA_OBJECT="DATA_OBJECT",x.DATA_OUTPUT="DATA_OUTPUT",x.DATA_INPUT="DATA_INPUT",x.MARKER="MARKER",x))(zr||{});var ws=require("@produto-lecom/lecom-ui"),ef=require("@xyflow/react");var vs=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 Xp({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
- `),i=encodeURI(r);Ns(i,`${o}.csv`)}var Ns=(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 Up(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var YM={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},$p={script:"SCRIPT",subprocess:"SUBPROCESS"},Kp={"marker-loop":"LOOP"},qp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var fn=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",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}}},ky=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=de.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=de.START_EVENT.MIN_HEIGHT,{node:fn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Ry=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=de.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=de.END_EVENT.MIN_HEIGHT,{node:fn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Dy=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=$p[n],s=t.get(o)||"",a=Kp[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=bo(e.mxGeometry._attributes.width||0,de.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=bo(e.mxGeometry._attributes.height||0,de.TASK.MIN_HEIGHT),{node:fn({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},Oy=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=qp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=de.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=de.GATEWAY.MIN_HEIGHT,{node:fn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Vy=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:fn({cell:e,type:"LANE"}),status:"imported",originalType:t}},Hy=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=bo(e.mxGeometry._attributes.width||0,de.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=bo(e.mxGeometry._attributes.height||0,de.ANNOTATION.MIN_HEIGHT),{node:fn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Zp=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=de.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=de.UNSUPPORTED.MIN_HEIGHT,{node:fn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Jp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},kt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},Qp={TASK:Dy,GATEWAY:Oy,START_EVENT:ky,END_EVENT:Ry,LANE:Vy,ANNOTATION:Hy};var Gy=e=>{let t=new Map,o=Object.values(zr),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=Qp[l]||Zp,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:Up(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},By=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Jp(r,t)),zy=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=Gy(t.root.mxCell),i=By(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Yy=async e=>{let t=await vs(e),o=ts(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),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},jp=async e=>{try{let t=await Yy(e),{nodes:o,edges:n,summary:r}=zy(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var of=require("react/jsx-runtime"),tf=()=>{let{t:e}=(0,ws.useTranslation)(),{toast:t}=et(),{setNodes:o,setEdges:n}=(0,ef.useReactFlow)(),{fitToNodes:r}=ko(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.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,of.jsx)(ws.Button,{size:"small",variant:"ghost",onClick:()=>Xp({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await jp(a);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r(l),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 nf=require("@produto-lecom/lecom-ui"),rf=require("react");var mn=require("react/jsx-runtime"),sf=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Ut(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,rf.useRef)(null),d=p=>{let f=p.target.files;f!=null&&f.length&&i(f),c.current&&(c.current.value="")};return(0,mn.jsxs)(mn.Fragment,{children:[(0,mn.jsx)(nf.Button,w(_({disabled:n,onClick:p=>{var f;(f=c.current)==null||f.click(),r==null||r(p)}},s),{children:e})),(0,mn.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var gn=require("react/jsx-runtime"),af=({disabled:e=!1})=>{let{t}=(0,Ho.useTranslation)(),{toast:o}=et(),{importFromGovernance:n}=tf(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return(0,gn.jsxs)(Ho.Tooltip,{children:[(0,gn.jsx)(Ho.TooltipTrigger,{asChild:!0,children:(0,gn.jsx)(sf,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,gn.jsx)(Za,{})})}),(0,gn.jsx)(Ho.TooltipContent,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};var lf=require("react/jsx-runtime"),wa=({shortcut:e})=>(0,lf.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 ye=require("@produto-lecom/lecom-ui"),Go=require("lucide-react"),hf=require("react");var pf=require("@produto-lecom/lecom-ui"),ff=require("@xyflow/react"),Yr=require("html-to-image"),mf=require("react");var cf=require("@xyflow/react"),df=(e,t=0)=>{let o=(0,cf.getNodesBounds)(e),n=document.querySelectorAll(".react-flow__edge-path"),r=o.x,i=o.y,s=o.x+o.width,a=o.y+o.height;return n.forEach(l=>{let c=l.getBBox();r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x+c.width),a=Math.max(a,c.y+c.height)}),{x:r,y:i,width:s-r+t*2,height:a-i+t*2}};var Fy=3,Ia="diagram",Aa=50,Wy=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Ca=e=>!Wy(e),Xy=96,Uy=25.4,$y="sequence-edge-marker",uf=e=>e*Uy/Xy,Ky=e=>{let t=document.getElementById($y);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},gf=()=>{let{t:e}=(0,pf.useTranslation)(),{toast:t}=et(),{getEdges:o,getNodes:n}=(0,ff.useReactFlow)(),{clearSelection:r}=$t(),[i,s]=(0,mf.useState)({png:!1,html:!1,print:!1}),a=()=>{let{x:p,y:f,width:h,height:E}=df(n(),Aa),g=Aa-p,y=Aa-f;return{width:h,height:E,style:{width:`${h}px`,height:`${E}px`,transform:`translate(${g}px, ${y}px)`,transformOrigin:"top left"}}},l=async(p,f)=>{s(h=>w(_({},h),{[f]:!0})),await r();try{let h=n(),E=o();if(h.length===0&&E.length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let g=lu();if(!g)throw new Error("Flow element not found");let y=a(),m=Ky(g);try{return await p(g,y)}finally{m==null||m.remove()}}catch(h){console.error("Diagram export failed",h),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{s(h=>w(_({},h),{[f]:!1}))}};return{exportAsPng:async(p=Ia)=>{await l(async(f,h)=>{let E=await(0,Yr.toPng)(f,w(_({},h),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Ca}));Ns(E,`${p}.png`)},"png")},exportAsHtml:async(p=Ia)=>{await l(async(f,h)=>{let E=await(0,Yr.toSvg)(f,w(_({},h),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Ca})),g=`
38
+ </mxGraphModel>`,Kd=(e,t)=>{if(!e.length&&!t.length)return Ar;let o=[...e.map(r=>r.id),...t.map(r=>r.id)];return Math.max(...o.map(r=>Number(r)))};var ns=require("xml-js");var qd={compact:!0,spaces:4},Bh=e=>e.replace(/\n/g,"&#xA;");function rs(e,t=qd){if(e)return JSON.parse((0,ns.xml2json)(e,t))}function Zd(e,t=qd){return e?(0,ns.json2xml)(e,w(_({},t),{attributeValueFn:Bh})):""}var Jd={"attribute-loop":"LOOP"},Qd={"task-script":"SCRIPT","subprocess-collapsed":"SUBPROCESS","service-task":"SERVICE_TASK"},jd={"gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},eu={SCRIPT:"task-script",SUBPROCESS:"subprocess-collapsed",SERVICE_TASK:"service-task"},tu={EXCLUSIVE:"gateway-exclusive",PARALLEL:"gateway-parallel",COMPLEX:"gateway-complex"};var Wn=(e,t,o,n,r,i)=>{let s=e._attributes.width||0,a=e._attributes.height||0,l=0,c=0;if(n&&r!==void 0&&i!==void 0){let x=n.split(`
39
+ `),E=x.length;l=x.reduce((h,f)=>Math.max(h,f.length),0)*7+r,c=E*20+i}let d=Math.max(To(Number(s),t),l),u=Math.max(To(Number(a),o),c);return{width:d,height:u,measured:{width:d,height:u}}},Xn=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,parent:r,value:i}=t,s={x:Number(o._attributes.x||0),y:Number(o._attributes.y||0)},a={id:n,position:s,className:void 0,data:{label:i||""}},l=r==="1"?void 0:r;return l&&(a.parentId=l),a},Yh=e=>{let{mxGeometry:t}=e,o=Xn(e),n=Wn(t,de.START_EVENT.MIN_WIDTH,de.START_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"START_EVENT"})},Fh=e=>{let{mxGeometry:t}=e,o=Xn(e),n=Wn(t,de.END_EVENT.MIN_WIDTH,de.END_EVENT.MIN_HEIGHT);return w(_(_({},o),n),{type:"END_EVENT"})},is=(e,t)=>{let{_attributes:o,mxGeometry:n}=e,r=Xn(e),a=Wn(n,de.TASK.MIN_WIDTH,de.TASK.MIN_HEIGHT,r.data.label,48,24),l=t==null?void 0:t.find(d=>{let{parent:u}=d._attributes;return u===e._attributes.id});if(l){let{style:d}=l._attributes,u=Jd[d];u&&(r.data.attribute=u)}let c=Qd[o.style];return c&&(r.data.variant=c),w(_(_({},r),a),{type:"TASK"})},ca=e=>{let{_attributes:t,mxGeometry:o}=e,{style:n}=t,r=Xn(e),i=Wn(o,de.GATEWAY.MIN_WIDTH,de.GATEWAY.MIN_HEIGHT);return r.data.variant=jd[n],w(_(_({},r),i),{type:"GATEWAY"})},Wh=e=>{let{mxGeometry:t}=e,o=Xn(e),i=Wn(t,de.ANNOTATION.MIN_WIDTH,de.ANNOTATION.MIN_HEIGHT,o.data.label,32,24);return w(_(_({},o),i),{type:"ANNOTATION"})},Xh=e=>{let{mxGeometry:t}=e,o=Xn(e),n=Wn(t,de.LANE.MIN_WIDTH,de.LANE.MIN_HEIGHT);return w(_(_({},o),n),{type:"LANE"})},ou={task:is,"task-script":is,"subprocess-collapsed":is,"service-task":is,"start-event":Yh,"end-event-terminate":Fh,"gateway-parallel":ca,"gateway-exclusive":ca,"gateway-complex":ca,annotation:Wh,lane:Xh},Uh=e=>{if(e&&Array.isArray(e))return e.map(t=>({x:Number(t._attributes.x),y:Number(t._attributes.y)}))},nu=e=>{let{_attributes:t,mxGeometry:o}=e,{id:n,source:r,target:i,value:s,style:a,sourceHandle:l,targetHandle:c,sourceOffset:d,targetOffset:u,labelOffsetX:p,labelOffsetY:m}=t,x=Uh(o==null?void 0:o.Array),E=d!==void 0?Number(d):void 0,g=u!==void 0?Number(u):void 0,h=p!==void 0?Number(p):void 0,f=m!==void 0?Number(m):void 0,y=w(_(_({id:n,source:r,target:i},l?{sourceHandle:l}:{}),c?{targetHandle:c}:{}),{data:_(_(_(_({label:s||""},x&&x.length>0?{points:x}:{}),E!==void 0?{sourceOffset:E}:{}),g!==void 0?{targetOffset:g}:{}),h!==void 0&&f!==void 0?{labelOffset:{x:h,y:f}}:{})});return a.includes("association")&&a.includes('endArrow=""')?_(_({},Bn),y):_(_({},kt),y)},ru=(e,t)=>{var m,x;let{id:o,type:n,source:r,target:i,sourceHandle:s,targetHandle:a,data:l}=e,c=t==null?void 0:t.find(E=>E.id===r),d="";n==="ANNOTATION_EDGE"&&(d='association;endArrow=""');let u={_attributes:{as:"geometry",relative:"1"}};return l!=null&&l.points&&Array.isArray(l.points)&&l.points.length>0&&(u.Array=l.points.map(E=>({_attributes:{as:"mxPoint",x:E.x,y:E.y}}))),{_attributes:{id:o,parent:(c==null?void 0:c.parentId)||"1",edge:"1",style:d,source:r,target:i,value:(l==null?void 0:l.label)||"",sourceHandle:s!=null?s:void 0,targetHandle:a!=null?a:void 0,sourceOffset:(l==null?void 0:l.sourceOffset)!==void 0?String(l.sourceOffset):void 0,targetOffset:(l==null?void 0:l.targetOffset)!==void 0?String(l.targetOffset):void 0,labelOffsetX:((m=l==null?void 0:l.labelOffset)==null?void 0:m.x)!==void 0?String(l.labelOffset.x):void 0,labelOffsetY:((x=l==null?void 0:l.labelOffset)==null?void 0:x.y)!==void 0?String(l.labelOffset.y):void 0},mxGeometry:u}},Un=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}}}},$h=e=>{let{variant:t}=e.data,o=Un(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:eu[t]||"task"})})},Kh=e=>{let t=Un(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"start-event"})})},qh=e=>{let t=Un(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"end-event-terminate"})})},Zh=e=>{let{variant:t}=e.data,o=Un(e);return w(_({},o),{_attributes:w(_({},o._attributes),{style:tu[t]})})},Jh=e=>{let t=Un(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"lane"})})},Qh=e=>{let t=Un(e);return w(_({},t),{_attributes:w(_({},t._attributes),{style:"annotation"})})},iu={TASK:$h,START_EVENT:Kh,END_EVENT:qh,GATEWAY:Zh,ANNOTATION:Qh,LANE:Jh},su=(e,t)=>{var s,a;let r=((s=e.measured)==null?void 0:s.width)||0,i=((a=e.measured)==null?void 0:a.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 jh=e=>{let t=Object.values(Ir),o=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return t.includes(s)}),n=e.filter(i=>{var a;let s=(a=i._attributes)==null?void 0:a.style;return["attribute-loop"].includes(s)}),r=[];for(let i of o){let{style:s}=i._attributes,a=ou[s],l=a==null?void 0:a(i,n);if(!l){console.warn(`Node ${s} not supported`);continue}r.push(l)}return r},ey=(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=nu(r),s=t.find(c=>c.id===i.source),a=t.find(c=>c.id===i.target);((s==null?void 0:s.type)==="LANE"||(a==null?void 0:a.type)==="LANE")&&i.type!=="ANNOTATION_EDGE"||n.push(i)}return n},ty=(e,t)=>{let o=[];return e.forEach(n=>{var s,a;let r=(a=(s=iu)[n.type])==null?void 0:a.call(s,n);if(!r){console.warn(`Node ${n.type} not supported`);return}if(o.push(r),n.type==="TASK"&&n.data.attribute==="LOOP"){let l=su(n,t);o.push(l)}}),o},oy=(e,t)=>{let o=[];return e.forEach(n=>{let r=ru(n,t);o.push(r)}),o},ny=(e=[],t=[],o)=>{let n=ty(e,o),r=oy(t,e);return{mxGraphModel:{root:{_attributes:{version:"1.1",lastId:o},mxCell:[{_attributes:{id:"0"}},{_attributes:{id:"1",parent:"0"}},...n,...r]}}}},au=(e=[],t=[],o)=>{let n=ny(e,t,o);return Zd(JSON.stringify(n),{compact:!0,spaces:0})},lu=async e=>{var a,l,c,d,u;let t=await rs(e),o=((l=(a=t==null?void 0:t.mxGraphModel)==null?void 0:a.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)||Ar),r=jh(o),i=ey(o,r),s=Wo(Xd(r));return{lastElementId:n,edges:i,nodes:s}};var fs=require("@xyflow/react"),Ku=require("react");var bt=require("@xyflow/react"),ds=require("react");var Cr=require("@xyflow/react");var da=require("react/jsx-runtime"),ne=i=>{var s=i,{type:e,position:t,className:o,nodeType:n}=s,r=Ut(s,["type","position","className","nodeType"]);let a=n==="TASK";return(0,da.jsx)(Cr.Handle,_({type:e,position:t,className:G("size-2.5 border border-grey-400 bg-white relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":a,"before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":!a},o)},r))},lt=a=>{var l=a,{nodeId:e,nodeType:t,gatewayVariant:o,type:n,position:r,className:i}=l,s=Ut(l,["nodeId","nodeType","gatewayVariant","type","position","className"]);let{getEdges:c,getNodes:d}=(0,Cr.useReactFlow)(),p=(()=>{if(n!=="source")return!1;let m=c();if(t==="TASK")return m.filter(E=>E.source===e).length>=2;if(t==="GATEWAY"&&o==="EXCLUSIVE")return m.filter(E=>E.source===e).length>=2;if(t==="START_EVENT"){let x=d();return m.filter(g=>{if(g.source!==e)return!1;let h=x.find(f=>f.id===g.target);return(h==null?void 0:h.type)!=="ANNOTATION"}).length>=1}return!1})();return(0,da.jsx)(Cr.Handle,_({type:n,position:r,className:G("size-2.5 border border-grey-400 bg-white transition-all duration-200 relative",{"before:content-[''] before:absolute before:inset-[-16px] before:bg-transparent before:pointer-events-none":t==="TASK","before:content-[''] before:absolute before:inset-[-4px] before:bg-transparent before:pointer-events-none":t!=="TASK","opacity-50 cursor-not-allowed pointer-events-none":p,"hover:border-grey-500":!p},i),style:{pointerEvents:p?"none":"auto"}},s))};var ua=require("react"),ho=require("@xyflow/react");var cu=require("@xyflow/react"),ss=()=>{let e=(0,cu.useStoreApi)();return{getInternalNodes:()=>{let{nodeLookup:o}=e.getState();return Array.from(o.values())}}};var as=require("react/jsx-runtime"),pa=require("react"),ry=["top","right","bottom","left"],iy=["top-left","top-middle","top-right","right-middle","bottom-left","left-middle","bottom-right","bottom-middle"],Rt=r=>{var i=r,{nodeId:e,isVisible:t,offset:o=8}=i,n=Ut(i,["nodeId","isVisible","offset"]);let{getInternalNode:s,setNodes:a}=(0,ho.useReactFlow)(),{getInternalNodes:l}=ss(),c=qt(),d=(0,ho.useStoreApi)(),u=(0,ua.useRef)(0),p=(0,ua.useRef)([]),m=({y:h,width:f,height:y})=>{cancelAnimationFrame(u.current),u.current=requestAnimationFrame(()=>{var Y,j;if(!e)return;let{nodeLookup:T,onNodesChange:b}=d.getState(),I=T.get(e);if(!I||I.type!=="LANE")return;let v=!I.parentId,N=v?I.id:I.parentId;if(!N)return;let C=Array.from(T.values()).filter(q=>q.type==="LANE"&&q.parentId===N);if(!C.length)return;p.current.length===0&&(p.current=rn(C).map(q=>q.id));let M=p.current.map(q=>C.find($=>$.id===q)).filter(Boolean),L=[],R=0,O=M.findIndex(q=>q.id===I.id),V=!v&&O>0&&Math.abs(h-I.position.y)>.5;for(let q=0;q<M.length;q++){let $=M[q],A=$.id===I.id,P=q===M.length-1;if(A){R=V?h+y:R+y;continue}let k=(j=(Y=$.measured)==null?void 0:Y.height)!=null?j:0,S=v?f-ie.HEADER_WIDTH:f,B=k;v&&P&&(B=Math.max(ie.MIN_HEIGHT,y-R)),V&&q===O-1&&(B=Math.max(ie.MIN_HEIGHT,h-R)),L.push({id:$.id,type:"dimensions",dimensions:{width:S,height:B},setAttributes:!0}),L.push({id:$.id,type:"position",position:{x:ie.HEADER_WIDTH,y:R}}),R+=B}v?L.push({id:N,type:"dimensions",dimensions:{width:f,height:y},setAttributes:!0}):L.push({id:N,type:"dimensions",dimensions:{width:f+ie.HEADER_WIDTH,height:R},setAttributes:!0}),b==null||b(L)})},x=({y:h,width:f,height:y})=>{var I;if(cancelAnimationFrame(u.current),p.current=[],!e)return;let T=s(e);if(!T||T.type!=="LANE"&&!T.parentId)return;let b=[...l()];if(T.type!=="LANE"){b=b.map(v=>v.id===e?w(_({},v),{width:f,height:y,measured:{width:f,height:y}}):v),b=go(b),a(b);return}b=Wd(T,f,y,b,h),b=go(b),b=nn((I=T.parentId)!=null?I:T.id,b),a(b)};if(!(!c&&t))return null;let g={"--resize-offset":`${o}px`};return(0,as.jsxs)(as.Fragment,{children:[ry.map(h=>(0,pa.createElement)(ho.NodeResizeControl,w(_({},n),{key:h,nodeId:e,position:h,variant:ho.ResizeControlVariant.Line,className:"border-blue-400/90 border-dashed",style:g,onResize:(f,y)=>m(y),onResizeEnd:(f,y)=>x(y)}))),iy.map(h=>(0,pa.createElement)(ho.NodeResizeControl,w(_({},n),{key:h,nodeId:e,position:h,className:"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]",style:g,onResize:(f,y)=>m(y),onResizeEnd:(f,y)=>x(y)})))]})};var sn=require("@xyflow/react"),no=require("@produto-lecom/lecom-ui"),nt=or(require("react"),1);var du=require("zustand"),$n=(0,du.create)(e=>({draggableNode:null,setDraggableNode:t=>{e({draggableNode:t})}}));var ls=require("react"),uu=(e,t=!1)=>{let[o,n]=(0,ls.useState)({width:0,height:0});return(0,ls.useEffect)(()=>{if(e.current&&t){let r=e.current.getBoundingClientRect();n({width:r.width,height:r.height})}},[t,e]),{dimensions:o}};var Lo=require("@xyflow/react"),pu=require("react"),sy=120,ay=12,fu=(e,t=!1,o)=>{let{getNode:n,getViewport:r}=(0,Lo.useReactFlow)(),{instanceId:i}=U();return(0,pu.useMemo)(()=>{var m,x;if(!t)return{position:Lo.Position.Right,align:"start"};let s=n(e);if(!s)return{position:Lo.Position.Right,align:"start"};let a=r(),l=s.position.x*a.zoom+a.x,c=(((m=s.measured)==null?void 0:m.width)||s.width||100)*a.zoom,d=(x=document.getElementById(`modeler-${i}`))==null?void 0:x.clientWidth;if(!d)return{position:Lo.Position.Right,align:"start"};let u=(o==null?void 0:o.width)||sy;return{position:l+c+u+ay>d?Lo.Position.Left:Lo.Position.Right}},[i,e,t,o,n,r])};var fa=require("lucide-react");var cs=require("@xyflow/react"),he=require("@produto-lecom/lecom-ui"),mu=require("lucide-react");var Ne=require("react/jsx-runtime"),gu=({nodeId:e})=>{let{t}=(0,he.useTranslation)(),{updateNodeData:o,getEdges:n,getNode:r}=(0,cs.useReactFlow)(),i=(0,cs.useNodesData)(e),a=n().filter(x=>x.source===e).some(x=>{let E=r(x.target);return(E==null?void 0:E.type)==="END_EVENT"}),l=(i==null?void 0:i.data.variant)==="SUBPROCESS",c=(i==null?void 0:i.data.variant)==="SERVICE_TASK",d=p=>{o(e,{variant:(i==null?void 0:i.data.variant)===p?"":p})},u=p=>{o(e,{attribute:(i==null?void 0:i.data.attribute)===p?"":p})};return(0,Ne.jsxs)(he.DropdownMenu,{children:[(0,Ne.jsxs)(he.Tooltip,{children:[(0,Ne.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ne.jsx)(he.DropdownMenuTrigger,{asChild:!0,children:(0,Ne.jsx)(he.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,children:(0,Ne.jsx)(mu.WrenchIcon,{})})})}),(0,Ne.jsx)(he.TooltipContent,{color:"black",children:t("bpmn.task.menu.title")})]}),(0,Ne.jsxs)(he.DropdownMenuContent,{align:"start",className:"w-60 bg-white text-grey-600",children:[(0,Ne.jsxs)(he.DropdownMenuLabel,{className:"flex items-center gap-1",children:[(0,Ne.jsx)("div",{className:"flex-1 body-medium-500",children:t("bpmn.task.menu.title")}),(0,Ne.jsx)("div",{className:"flex items-center gap-1",children:Object.entries(ni).map(([p,m])=>{let x=p==="LOOP"&&(a||l||c),g=(()=>{if(p==="LOOP"&&a)return t("editor.task_menu.loop_not_allowed_when_connected_to_end");if(p==="LOOP"&&l)return t("editor.task_menu.loop_not_allowed_when_subprocess");if(p==="LOOP"&&c)return t("editor.task_menu.loop_not_allowed_when_service_task");if(p==="LOOP")return t("editor.task_menu.loop")})();return(0,Ne.jsxs)(he.Tooltip,{children:[(0,Ne.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ne.jsx)(he.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,disabled:x,className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.attribute)===p,"opacity-50 cursor-not-allowed":x}),onClick:x?void 0:()=>u(p),children:(0,Ne.jsx)(m.icon,{className:"stroke-inherit"})})}),g&&(0,Ne.jsx)(he.TooltipContent,{color:"black",children:g})]},p)})})]}),(0,Ne.jsx)(he.DropdownMenuGroup,{children:(0,Ne.jsxs)(he.Tooltip,{children:[(0,Ne.jsx)(he.TooltipTrigger,{asChild:!0,children:(0,Ne.jsx)("div",{className:G({"cursor-not-allowed":a}),children:(0,Ne.jsxs)(he.DropdownMenuItem,{className:G({"bg-grey-100 text-blue-500":(i==null?void 0:i.data.variant)==="SCRIPT","opacity-50":a}),disabled:a,onClick:()=>d("SCRIPT"),children:[(0,Ne.jsx)(oi.SCRIPT.icon,{className:"stroke-current"}),t(`bpmn.task.variant.${"SCRIPT".toLowerCase()}`)]})})}),a&&(0,Ne.jsx)(he.TooltipContent,{color:"black",children:t("editor.task_menu.script_not_allowed_when_connected_to_end")})]})})]})]})};var ke=require("react/jsx-runtime"),yo={START_EVENT:{type:"START_EVENT",icon:ir,label:"bpmn.start_event.variant.default"},END_EVENT:{type:"END_EVENT",icon:En,label:"bpmn.end_event.variant.default"},TASK:{type:"TASK",icon:ir,label:"bpmn.task.variant.default"},ANNOTATION:{type:"ANNOTATION",icon:Qr,label:"bpmn.annotation.variant.default"}},ly={EXCLUSIVE:{type:"GATEWAY",variant:"EXCLUSIVE",icon:Tn,label:"bpmn.gateway.variant.exclusive"},PARALLEL:{type:"GATEWAY",variant:"PARALLEL",icon:Nn,label:"bpmn.gateway.variant.parallel"},COMPLEX:{type:"GATEWAY",variant:"COMPLEX",icon:_n,label:"bpmn.gateway.variant.complex"}},ct=nt.default.memo(({nodeId:e,nodeType:t,nodeVariant:o,isChild:n})=>{let r=(0,nt.useRef)(null),i=(0,nt.useRef)(null),{t:s}=(0,no.useTranslation)(),{setDraggableNode:a}=$n(),{getEdges:l,getNodes:c,setNodes:d}=(0,sn.useReactFlow)(),{setIsDragging:u,mode:p,isConnecting:m,isDragging:x}=U(),E=qt(),g=(0,sn.useStore)((0,nt.useCallback)(z=>{var K,Z;return(Z=(K=z.nodeLookup.get(e))==null?void 0:K.selected)!=null?Z:!1},[e])),h=(0,sn.useStore)((0,nt.useCallback)(z=>{var K,Z;return(Z=(K=z.nodeLookup.get(e))==null?void 0:K.dragging)!=null?Z:!1},[e])),f=g&&!h&&!m&&!x&&!E,{dimensions:y}=uu(r,f),{position:T}=fu(e,f,y),[b,I]=(0,nt.useState)(void 0),v=o==="SUBPROCESS",N=o==="SERVICE_TASK",C=(0,nt.useRef)(null),M=(0,nt.useRef)(!1),L=(0,nt.useCallback)(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null),M.current=!1,u(!1),a(null),I(void 0),d(z=>z.map(K=>w(_({},K),{className:void 0})))},[u,a,d]);(0,nt.useEffect)(()=>{let z=K=>{M.current&&K.buttons===0&&L()};return document.addEventListener("dragend",L),document.addEventListener("mousemove",z),()=>{document.removeEventListener("dragend",L),document.removeEventListener("mousemove",z)}},[L]);let R=(0,nt.useCallback)((z,K)=>{M.current=!0,u(!1),a({type:K.type,variant:K.variant,attribute:K.attribute,icon:K.icon}),K.icon&&I((0,ke.jsx)(K.icon,{})),z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("sourceId",e),i.current&&z.dataTransfer.setDragImage(i.current,10,10),C.current=setTimeout(()=>{C.current=null,u(!0)},100)},[e,a,u]),O=(0,nt.useCallback)(()=>{L()},[L]);if(!f)return null;let V=c(),Y=l(),j=[{component:(0,ke.jsx)(Wi,{elementId:e})}],q=()=>{if(p==="view")return[];let z=!Y.some(K=>{var Z;return K.source===e&&((Z=V.find(W=>W.id===K.target))==null?void 0:Z.type)!=="ANNOTATION"});return[{component:(0,ke.jsx)(On,{nodeId:e,disabled:!z,tooltipMessage:z?void 0:s("editor.toolbar.start_event_limit_reached")})},yo.TASK,yo.ANNOTATION,...j]},$=()=>p==="view"?[{component:(0,ke.jsx)(So,{elementId:e})}]:[{component:(0,ke.jsx)(So,{elementId:e})},...v||N?[]:[{component:(0,ke.jsx)(gu,{nodeId:e})}],{component:(0,ke.jsx)(On,{nodeId:e})},yo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:sr,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:fa.Bot,label:"bpmn.task.variant.service_task"},yo.ANNOTATION,...Object.values(ly),...Qo(e,V,Y)?[]:[yo.END_EVENT],...j],A=()=>p==="view"?[{component:(0,ke.jsx)(So,{elementId:e,elementType:"gateway"})}]:[{component:(0,ke.jsx)(So,{elementId:e,elementType:"gateway"})},{component:(0,ke.jsx)(On,{nodeId:e})},yo.TASK,{type:"TASK",variant:"SUBPROCESS",icon:sr,label:"bpmn.task.variant.subprocess"},{type:"TASK",variant:"SERVICE_TASK",icon:fa.Bot,label:"bpmn.task.variant.service_task"},yo.ANNOTATION,...j],P=()=>p==="view"?[]:[yo.ANNOTATION,...j],k=()=>p==="view"?[]:[...n?[]:[{component:(0,ke.jsx)(On,{nodeId:e})}],yo.ANNOTATION,...j],S=()=>p==="view"?[]:[{component:(0,ke.jsx)(On,{nodeId:e})},...j],B=()=>p==="view"?[]:[...j],D=(z=>{switch(z){case"START_EVENT":return q();case"TASK":return $();case"GATEWAY":return A();case"END_EVENT":return P();case"LANE":return k();case"ANNOTATION":return S();case"UNSUPPORTED":return B();default:return[]}})(t),H=D.length>6;if(!(D.length===0||p==="readonly"))return(0,ke.jsxs)(sn.NodeToolbar,{position:T,align:"start",className:H?"-top-[4.5rem]":"-top-8",isVisible:f,children:[(0,ke.jsx)("div",{ref:r,className:`${H?"grid grid-cols-6":"flex"} gap-1 px-2 py-2 bg-white rounded-sm shadow-md`,children:D.map((z,K)=>{if(z.component)return(0,ke.jsx)("div",{children:z.component},K);let Z={sourceNodeType:t,targetNodeType:z.type,sourceNodeId:e,nodes:V,edges:Y},W=_d(Z),X={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"),start_event_to_service_task_not_allowed:s("editor.toolbar.start_event_to_service_task_not_allowed"),service_task_to_end_not_allowed:s("editor.toolbar.service_task_to_end_not_allowed")},Q=W.shouldDisable&&W.reason?X[W.reason]||s(z.label):s(z.label)||"";return(0,ke.jsxs)(no.Tooltip,{children:[(0,ke.jsx)(no.TooltipTrigger,{asChild:!0,children:(0,ke.jsx)(no.Button,{variant:"ghost",color:"grey",size:"small",iconButton:!0,draggable:!W.shouldDisable,disabled:W.shouldDisable,className:W.shouldDisable?"opacity-50 cursor-not-allowed":"",onDragStart:W.shouldDisable?void 0:ee=>R(ee,z),onDragEnd:W.shouldDisable?void 0:O,children:z.icon&&(0,ke.jsx)(z.icon,{size:16})})}),(0,ke.jsx)(no.TooltipContent,{color:"black",children:Q})]},K)})}),(0,ke.jsx)("div",{ref:i,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:b})]})});ct.displayName="NodeToolbar";var Qe=require("react/jsx-runtime"),hu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r,setNodes:i}=(0,bt.useReactFlow)(),{inProgress:s,fromNode:a}=(0,bt.useConnection)(),{mode:l,isReadOnly:c}=U(),d=s&&(a==null?void 0:a.id)!==e,u=(0,ds.useCallback)(x=>{let y=x.split(`
40
+ `),T=y.reduce((N,C)=>Math.max(N,C.length),0),b=y.length,I=Math.max(Fn.MIN_WIDTH,T*7+32),v=Math.max(Fn.MIN_HEIGHT,b*20+24);i(N=>N.map(C=>C.id===e?w(_({},C),{width:I,height:v,style:w(_({},C.style),{width:I,height:v})}):C))},[e,i]),p=(0,ds.useCallback)(x=>{r(e,{label:x}),u(x)},[e,r,u]),m=(0,ds.useCallback)(x=>{u(x)},[u]);return(0,Qe.jsxs)("div",{className:G("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",{"pointer-events-none":c,"text-blue-500 hover:text-blue-600 shadow-md":o&&!c,"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,Qe.jsx)(st,{value:t.label,className:"m-1 text-grey-600 text-left",onChange:p,onInput:m,skipFirstCharValidation:!0}),(0,Qe.jsx)(ct,{nodeId:e,nodeType:"ANNOTATION"}),l==="edit"&&(0,Qe.jsx)(Rt,{nodeId:e,minWidth:Fn.MIN_WIDTH,minHeight:Fn.MIN_HEIGHT,isVisible:!n&&o}),!s&&(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Left,id:"left"}),(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Right,id:"right"}),(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Top,id:"top"}),(0,Qe.jsx)(ne,{type:"source",position:bt.Position.Bottom,id:"bottom"})]}),(!s||d)&&(0,Qe.jsxs)(Qe.Fragment,{children:[(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Left,id:"left",className:G({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Right,id:"right",className:G({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Top,id:"top",className:G({"annotation-handle":d})}),(0,Qe.jsx)(ne,{type:"target",position:bt.Position.Bottom,id:"bottom",className:G({"annotation-handle":d})})]})]})};var Tt=require("@xyflow/react"),yu=require("react");var ze=require("react/jsx-runtime"),xu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Tt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,Tt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=(0,yu.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,m=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return(0,ze.jsxs)("div",{className:"relative",onDoubleClick:x,children:[(0,ze.jsx)(En,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#d33b3b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,ze.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,ze.jsx)(st,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,ze.jsx)(ct,{nodeId:e,nodeType:"END_EVENT"}),a==="edit"&&(0,ze.jsx)(Rt,{nodeId:e,isVisible:!n&&o,minWidth:ts.MIN_WIDTH,minHeight:ts.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Left,id:"left",className:G({"event-handle":p})}),(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Right,id:"right",className:G({"event-handle":p})}),(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Top,id:"top",className:G({"event-handle":p})}),(0,ze.jsx)(ne,{type:"target",position:Tt.Position.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&(0,ze.jsxs)(ze.Fragment,{children:[(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Left,id:"left"}),(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Right,id:"right"}),(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Top,id:"top"}),(0,ze.jsx)(ne,{type:"source",position:Tt.Position.Bottom,id:"bottom"})]})]})};var vt=require("@xyflow/react"),Kn=require("react");var Ye=require("react/jsx-runtime"),ma=(0,Kn.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let s=Ds[t.variant].icon,{updateNodeData:a}=(0,vt.useReactFlow)(),{inProgress:l,fromNode:c}=(0,vt.useConnection)(),{mode:d,isReadOnly:u,reconnectingEdgeId:p}=U(),[m,x]=(0,Kn.useState)(!1),E=l&&(c==null?void 0:c.id)!==e||!!p,g=(0,Kn.useCallback)(y=>{a(e,{label:y})},[e,a]),h=()=>{x(!0)},f=()=>{x(!1)};return(0,Ye.jsxs)("div",{className:"relative",style:{width:o!=null?o:Yn.MIN_WIDTH,height:n!=null?n:Yn.MIN_HEIGHT},onDoubleClick:h,children:[(0,Ye.jsx)(s,{className:G("w-full h-full min-w-14 min-h-14 stroke-1 stroke-grey-400 hover:stroke-grey-500 transition-colors duration-75",{"pointer-events-none":u,"stroke-blue-500 hover:stroke-blue-600":r&&!u,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)]":t.hasError})}),(0,Ye.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Ye.jsx)(st,{value:t.label,isEditing:m,onBlur:f,onChange:g})}),(0,Ye.jsx)(ct,{nodeId:e,nodeType:"GATEWAY",nodeVariant:t.variant}),d==="edit"&&(0,Ye.jsx)(Rt,{nodeId:e,isVisible:!i&&r,minWidth:Yn.MIN_WIDTH,minHeight:Yn.MIN_HEIGHT,offset:2,keepAspectRatio:!0}),(!l||E)&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Left,id:"left",className:G({"gateway-handle":E})}),(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Right,id:"right",className:G({"gateway-handle":E})}),(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Top,id:"top",className:G({"gateway-handle":E})}),(0,Ye.jsx)(ne,{type:"target",position:vt.Position.Bottom,id:"bottom",className:G({"gateway-handle":E})})]}),!l&&(0,Ye.jsxs)(Ye.Fragment,{children:[(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Left,id:"left",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Right,id:"right",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Top,id:"top",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant}),(0,Ye.jsx)(lt,{type:"source",position:vt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"GATEWAY",gatewayVariant:t.variant})]})]})});ma.displayName="Gateway";var Eu=require("@xyflow/react"),Yt=require("@produto-lecom/lecom-ui"),cy=require("lucide-react");var _u=require("react/jsx-runtime");var Nt=require("@xyflow/react"),bu=require("react");var Fe=require("react/jsx-runtime"),Tu=({id:e,data:t,selected:o,dragging:n})=>{let{updateNodeData:r}=(0,Nt.useReactFlow)(),{inProgress:i,fromNode:s}=(0,Nt.useConnection)(),{mode:a,isReadOnly:l,reconnectingEdgeId:c}=U(),[d,u]=(0,bu.useState)(!1),p=i&&(s==null?void 0:s.id)!==e||!!c,m=g=>{r(e,{label:g})},x=()=>{u(!0)},E=()=>{u(!1)};return(0,Fe.jsxs)("div",{className:"relative",onDoubleClick:x,children:[(0,Fe.jsx)(ti,{className:G("w-full h-full min-w-9 min-h-9 hover:stroke-[#54890b] transition-colors duration-75",{"pointer-events-none":l,"stroke-blue-500 hover:stroke-blue-600":o&&!l,"stroke-red-500 hover:stroke-red-600 drop-shadow-[0_0_3px_rgba(255,0,0,0.5)] fill-red-100":t.hasError})}),(0,Fe.jsx)("div",{className:"absolute mt-2 left-1/2 -translate-x-1/2 max-w-80 w-max",children:(0,Fe.jsx)(st,{value:t.label,isEditing:d,onBlur:E,onChange:m})}),(0,Fe.jsx)(ct,{nodeId:e,nodeType:"START_EVENT"}),a==="edit"&&(0,Fe.jsx)(Rt,{nodeId:e,isVisible:!n&&o,minWidth:es.MIN_WIDTH,minHeight:es.MIN_HEIGHT,offset:4,keepAspectRatio:!0}),(!i||p)&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Left,id:"left",className:G({"event-handle":p})}),(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Right,id:"right",className:G({"event-handle":p})}),(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Top,id:"top",className:G({"event-handle":p})}),(0,Fe.jsx)(ne,{type:"target",position:Nt.Position.Bottom,id:"bottom",className:G({"event-handle":p})})]}),!i&&(0,Fe.jsxs)(Fe.Fragment,{children:[(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Left,id:"left",nodeId:e,nodeType:"START_EVENT"}),(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Right,id:"right",nodeId:e,nodeType:"START_EVENT"}),(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Top,id:"top",nodeId:e,nodeType:"START_EVENT"}),(0,Fe.jsx)(lt,{type:"source",position:Nt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"START_EVENT"})]})]})};var Iu=require("@produto-lecom/lecom-ui"),wt=require("@xyflow/react"),an=require("react");var Sr=60,us=(e,t)=>{var s;let o=[],n=`${t} `;for(let a of e){if(!(a.type==="TASK"))continue;let c=(s=a.data)==null?void 0:s.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<=Sr?i:i.substring(0,Sr).trim()},qn=(e,t)=>{var a;let o=new Set;for(let l of t)l.type==="TASK"&&((a=l.data)!=null&&a.label)&&o.add(l.data.label);let n=e;if(n.length>Sr&&(n=n.substring(0,Sr).trim()),!o.has(n))return n;let r=n.replace(/\s+\(\d+\)$/,""),i=2,s=o.size+2;for(;i<=s;){let l=` (${i})`,c=Sr-l.length,u=`${r.substring(0,c).trim()}${l}`;if(!o.has(u))return u;i++}return n};var Mr=require("react/jsx-runtime"),vu=e=>(0,Mr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Mr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#10B981"}),(0,Mr.jsx)("path",{d:"M7 12L10 15L17 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var ga=require("react/jsx-runtime"),Nu=e=>(0,ga.jsx)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,ga.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 Pr=require("react/jsx-runtime"),wu=e=>(0,Pr.jsxs)("svg",w(_({width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),{children:[(0,Pr.jsx)("circle",{cx:"12",cy:"12",r:"10",fill:"#EF4444"}),(0,Pr.jsx)("path",{d:"M8 8L16 16M8 16L16 8",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}));var fe=require("react/jsx-runtime"),dy={APROVADO:vu,EM_ANDAMENTO:Nu,REJEITADO:wu},ha={APROVADO:"border-green-500 hover:border-green-500 border-[3px] border-solid",EM_ANDAMENTO:"border-turquoise-400 hover:border-turquoise-400 border-[3px] border-solid",REJEITADO:"border-red-500 hover: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)]"},uy={APROVADO:"bg-green-50",EM_ANDAMENTO:"bg-turquoise-50",REJEITADO:"bg-red-50"},ya=(0,an.memo)(({id:e,data:t,width:o,height:n,selected:r,dragging:i})=>{let{t:s}=(0,Iu.useTranslation)(),{toast:a}=et(),{updateNodeData:l,getNodes:c,setNodes:d}=(0,wt.useReactFlow)(),{inProgress:u,fromNode:p}=(0,wt.useConnection)(),{mode:m,isReadOnly:x,onSubprocessValidationClick:E,reconnectingEdgeId:g}=U(),{getTaskStatus:h}=Uo(),f=u&&(p==null?void 0:p.id)!==e||!!g,y=h(e),T=t.variant==="SUBPROCESS",b=t.variant==="SERVICE_TASK",I=!!t.variant&&!T&&!b||!!y,v=!!t.attribute||T||b,N=(0,an.useCallback)($=>{let S=I||v?80:40,B=$.split(`
41
+ `),F=B.reduce((K,Z)=>Math.max(K,Z.length),0),D=B.length,H=Math.max(Po.MIN_WIDTH,F*7+64),z=Math.max(Po.MIN_HEIGHT,D*24+S);d(K=>K.map(Z=>Z.id===e?w(_({},Z),{width:H,height:z,style:w(_({},Z.style),{width:H,height:z})}):Z))},[e,d,I,v]),C=(0,an.useCallback)($=>{let A=$.trim(),P=t.label||"";if(A===P)return;let k=A,S=c();if(!(A&&A!=="")){k=us(S,s("bpmn.task.label.prefix")),l(e,{label:k}),N(k),a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_empty.prefix")," ",(0,fe.jsx)("strong",{children:k})]})});return}let F=qn(k,S);F===P||(l(e,{label:F}),N(F),F!==k&&a({variant:"warning",content:(0,fe.jsxs)(fe.Fragment,{children:[s("bpmn.task.feedback.label_already_exists.prefix")," ",(0,fe.jsx)("strong",{children:A})," ",s("bpmn.task.feedback.label_already_exists.middle")," ",(0,fe.jsx)("strong",{children:F})]})}))},[t.label,c,e,s,l,N,a]),M=(0,an.useCallback)($=>{N($)},[N]),L=(0,an.useCallback)(()=>{a({variant:"error",content:s("bpmn.task.feedback.invalid_first_character")})},[s,a]),R=y?dy[y]:null,O=t.variant?oi[t.variant].icon:null,V=t.attribute?ni[t.attribute].icon:null,Y=()=>t.hasError?ha.error:y?ha[y]:x?ha.default:"",j=()=>{var $;return r&&($=uy[y])!=null?$:""},q=()=>{E==null||E({id:e,type:"sub_process",label:t.label})};return(0,fe.jsxs)("div",{className:G("relative w-full h-full min-w-44 min-h-24 flex flex-col items-stretch justify-stretch bg-white border-2 border-grey-400 hover:border-grey-500 rounded-md hover:shadow-md transition-colors duration-75",Y(),{"cursor-pointer":x,"border-blue-500 hover:border-blue-600 shadow-md":r&&!x&&!y,"border-red-500 hover:border-red-600 shadow-[0_0_5px_rgba(255,0,0,0.5)]":t.hasError}),style:{width:o!=null?o:Po.MIN_WIDTH,height:n!=null?n:Po.MIN_HEIGHT},children:[(0,fe.jsx)("div",{className:"flex-1 flex items-stretch justify-stretch overflow-hidden",children:(0,fe.jsx)(st,{value:t.label,maxLength:60,className:G(j(),{"py-10 px-8":I||v}),onChange:C,onInput:M,onInvalidFirstCharacter:L})}),O&&(0,fe.jsx)("div",{className:G("absolute flex items-center p-1",T||b?"bottom-0 left-1/2 -translate-x-1/2":"top-0 left-0"),children:(0,fe.jsx)(O,{size:b?20:16,className:G(t.hasError?"text-red-500":"text-grey-500",T&&"cursor-pointer"),onClick:T?q:void 0})}),V&&(0,fe.jsx)("div",{className:"absolute bottom-0 left-0 w-full flex items-center justify-center",children:(0,fe.jsx)("div",{className:G("flex items-center w-16 p-1",T||b?"justify-between":"justify-center"),children:(0,fe.jsx)(V,{size:16,className:G(t.hasError?"text-red-500":"text-grey-500")})})}),R&&(0,fe.jsx)("div",{className:"absolute top-0 right-0 flex items-center p-1",children:(0,fe.jsx)(R,{})}),(0,fe.jsx)(ct,{nodeId:e,nodeType:"TASK",nodeVariant:t.variant}),m==="edit"&&(0,fe.jsx)(Rt,{nodeId:e,isVisible:!i&&r,minWidth:Po.MIN_WIDTH,minHeight:Po.MIN_HEIGHT}),(!u||f)&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(ne,{type:"target",position:wt.Position.Left,id:"left",className:G({"task-handle":f})}),(0,fe.jsx)(ne,{type:"target",position:wt.Position.Right,id:"right",className:G({"task-handle":f})}),(0,fe.jsx)(ne,{type:"target",position:wt.Position.Top,id:"top",className:G({"task-handle":f})}),(0,fe.jsx)(ne,{type:"target",position:wt.Position.Bottom,id:"bottom",className:G({"task-handle":f})})]}),!u&&(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(lt,{type:"source",position:wt.Position.Left,id:"left",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(lt,{type:"source",position:wt.Position.Right,id:"right",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(lt,{type:"source",position:wt.Position.Top,id:"top",nodeId:e,nodeType:"TASK"}),(0,fe.jsx)(lt,{type:"source",position:wt.Position.Bottom,id:"bottom",nodeId:e,nodeType:"TASK"})]})]})});ya.displayName="Task";var xa=require("@xyflow/react");var xo=require("react/jsx-runtime"),Au=({id:e,data:t})=>(0,xo.jsxs)(xo.Fragment,{children:[(0,xo.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,xo.jsx)(ct,{nodeId:e,nodeType:"UNSUPPORTED"}),(0,xo.jsx)(ne,{type:"source",position:xa.Position.Right}),(0,xo.jsx)(ne,{type:"target",position:xa.Position.Left})]});var Oe=require("@xyflow/react"),ps=require("react");var Pe=require("react/jsx-runtime"),dA={type:"MESSAGE_EDGE",reconnectable:!0,markerEnd:{type:Oe.MarkerType.Arrow},data:{label:""}},Cu=({id:e,source:t,target:o,data:n,selected:r,sourcePosition:i,targetPosition:s,sourceHandleId:a,targetHandleId:l})=>{var B;let{zoom:c}=(0,Oe.useViewport)(),{updateEdgeData:d}=(0,Oe.useReactFlow)(),{mode:u,instanceId:p}=U(),m=qt(),x=u!=="edit",[E,g]=(0,ps.useState)(!1),{reconnectingHandle:h,cursorPosition:f,hoveredNodeId:y,reconnectingSide:T,isValidReconnection:b,handleReconnectStart:I}=Ji({edgeId:e,source:t,target:o,instanceId:p,isReadOnly:x}),v=(0,Oe.useInternalNode)(t),N=(0,Oe.useInternalNode)(o),{sx:C,sy:M,tx:L,ty:R,sourcePos:O,targetPos:V}=(0,ps.useMemo)(()=>{var te,xe;if(!v||!N)return{sx:0,sy:0,tx:0,ty:0,sourcePos:Oe.Position.Left,targetPos:Oe.Position.Right};let F=Cn(v,N),D=a?i:F.sourcePos,H=l?s:F.targetPos,z=(pe,le,Ae)=>{var oe,ae,Ce,$e,Ke,ut;let{x:Xe,y:rt}=pe.internals.positionAbsolute,J=(Ce=(ae=(oe=pe.measured)==null?void 0:oe.width)!=null?ae:pe.width)!=null?Ce:0,se=(ut=(Ke=($e=pe.measured)==null?void 0:$e.height)!=null?Ke:pe.height)!=null?ut:0;switch(le){case Oe.Position.Top:return{x:Xe+J*Ae,y:rt};case Oe.Position.Bottom:return{x:Xe+J*Ae,y:rt+se};case Oe.Position.Left:return{x:Xe,y:rt+se*Ae};case Oe.Position.Right:return{x:Xe+J,y:rt+se*Ae};default:return{x:Xe+J/2,y:rt+se/2}}},K=(te=n==null?void 0:n.sourceOffset)!=null?te:.5,Z=(xe=n==null?void 0:n.targetOffset)!=null?xe:.5,W=v?z(v,D,K).x:F.sx,X=v?z(v,D,K).y:F.sy,Q=N?z(N,H,Z).x:F.tx,ee=N?z(N,H,Z).y:F.ty;return h==="source"&&f?(W=f.x,X=f.y,T&&(D=T)):h==="target"&&f&&(Q=f.x,ee=f.y,T&&(H=T)),{sx:W,sy:X,tx:Q,ty:ee,sourcePos:D,targetPos:H}},[v,N,a,l,i,s,h,f,T,n==null?void 0:n.sourceOffset,n==null?void 0:n.targetOffset]);if(!v||!N)return null;let[Y,j,q]=(0,Oe.getSmoothStepPath)({sourceX:C,sourceY:M,targetX:L,targetY:R,sourcePosition:O,targetPosition:V}),$=r||(v==null?void 0:v.selected)||(N==null?void 0:N.selected),A=$?"sequence-edge-marker-highlighted":"sequence-edge-marker",P=E||(n==null?void 0:n.label.trim().length)>0,k=()=>{g(!1)},S=F=>{d(e,{label:F.trim()})};return(0,Pe.jsxs)("g",{className:G("group bpmn-arrow-edge",{"is-highlighted":$}),onDoubleClick:()=>!x&&g(!0),children:[(0,Pe.jsx)("path",{d:Y,fill:"none",stroke:"transparent",strokeWidth:Math.max(12,12/c),style:{pointerEvents:"stroke",cursor:"pointer"}}),(0,Pe.jsxs)("g",{className:G("text-grey-500 transition-colors duration-75 group-hover:text-grey-800",{"text-blue-500 group-hover:text-blue-600":$}),children:[(0,Pe.jsx)(Oe.BaseEdge,{id:e,path:Y,interactionWidth:0,markerEnd:`url(#${A})`,strokeDasharray:4,className:G("stroke-2 stroke-current transition-[stroke] duration-75 group-hover:stroke-[2.5px]",{"stroke-red-500 hover:stroke-red-600":(n==null?void 0:n.hasError)||h&&y&&!b,"stroke-green-500":h&&y&&b,"stroke-blue-500 hover:stroke-blue-600 stroke-[3px]":$&&!(n!=null&&n.hasError)&&!h})}),(0,Pe.jsxs)(Oe.EdgeLabelRenderer,{children:[(0,Pe.jsxs)("div",{className:"absolute z-[3000] pointer-events-auto flex flex-col items-center gap-1",style:{transform:`translate(-50%, -50%) translate(${j}px, ${q}px)`},children:[r&&!m&&(0,Pe.jsx)(Gn,{sx:C,sy:M,tx:L,ty:R,hasLabel:!!((B=n==null?void 0:n.label)!=null&&B.trim()),children:(0,Pe.jsx)(Hn,{edgeId:e,edgeType:"MESSAGE_EDGE"})}),P&&(0,Pe.jsx)(st,{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:E,onBlur:k,onChange:S})]}),r&&!m&&!x&&(0,Pe.jsxs)(Pe.Fragment,{children:[(0,Pe.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${C}px, ${M}px)`},children:(0,Pe.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="source"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="source"?.6:.3,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!h||h!=="source","cursor-not-allowed":h==="source"&&y&&!b,"cursor-grabbing":h==="source"&&(!y||b)}),onMouseDown:F=>I("source",F.nativeEvent)})]})}),(0,Pe.jsx)("div",{className:"absolute z-[1000] pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${L}px, ${R}px)`},children:(0,Pe.jsxs)("svg",{width:12/c,height:12/c,style:{overflow:"visible",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)"},children:[(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:4/c,fill:h==="target"?"#3b82f6":"#fff",stroke:"#3b82f6",strokeWidth:2/c,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:6/c,fill:"none",stroke:"#3b82f6",strokeWidth:1/c,opacity:h==="target"?.6:.3,className:"pointer-events-none"}),(0,Pe.jsx)("circle",{cx:6/c,cy:6/c,r:8/c,fill:"transparent",className:G("pointer-events-auto",{"cursor-move":!h||h!=="target","cursor-not-allowed":h==="target"&&y&&!b,"cursor-grabbing":h==="target"&&(!y||b)}),onMouseDown:F=>I("target",F.nativeEvent)})]})})]})]})]})]})};var ln=require("@xyflow/react"),Lr=require("react/jsx-runtime"),Su=({toX:e,toY:t,fromNode:o})=>{var u,p;if(!o)return null;let{internals:{positionAbsolute:{x:n,y:r}},measured:i}=o,s=(u=i.width)!=null?u:0,a=(p=i.height)!=null?p:0,c=[{x:n,y:r+a/2,pos:ln.Position.Left},{x:n+s,y:r+a/2,pos:ln.Position.Right},{x:n+s/2,y:r,pos:ln.Position.Top},{x:n+s/2,y:r+a,pos:ln.Position.Bottom}].reduce((m,x)=>{let E=Math.hypot(e-m.x,t-m.y);return Math.hypot(e-x.x,t-x.y)<E?x:m}),[d]=(0,ln.getStraightPath)({sourceX:c.x,sourceY:c.y,targetX:e,targetY:t});return(0,Lr.jsxs)("g",{className:"group",children:[(0,Lr.jsx)("path",{fill:"none",className:"stroke-2 stroke-grey-500 animated transition-[stroke,filter] duration-75",d}),(0,Lr.jsx)("circle",{cx:e,cy:t,fill:"none",r:4,className:"stroke-2 stroke-grey-600"})]})};var It=require("@xyflow/react"),Mu=require("lodash"),cn=require("react");var Le=require("react/jsx-runtime"),Ea=(0,cn.memo)(({id:e,data:t,selected:o,dragging:n,parentId:r})=>{var v;let{updateNodeData:i,getNodes:s}=(0,It.useReactFlow)(),{mode:a,isReadOnly:l}=U(),{inProgress:c,fromNode:d}=(0,It.useConnection)(),u=c&&(d==null?void 0:d.id)!==e,[p,m]=(0,cn.useState)(!1),x=s(),E=!r,g=!E&&((v=x.find(N=>N.id===r))==null?void 0:v.selected),h=(0,cn.useMemo)(()=>(0,Mu.orderBy)([...x.filter(N=>N.parentId===e&&N.type==="LANE")],"position.y","asc"),[x,e]),f=E?zd.MIN_WIDTH:ie.MIN_WIDTH,y=(0,cn.useMemo)(()=>{if(E&&h.length>1){let N=[...h];return N.pop(),N.reduce((M,L)=>{var R,O;return M+((O=(R=L.measured)==null?void 0:R.height)!=null?O:0)},0)+ie.MIN_HEIGHT}return ie.MIN_HEIGHT},[E,h]),T=N=>{i(e,{label:N})},b=()=>{m(!0)},I=()=>{m(!1)};return(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsxs)("div",{className:G("flex h-full min-h-64 w-full min-w-[50rem] hover:shadow-md bg-white outline outline-2 outline-grey-400",{"pointer-events-none":l,"outline-offset-0 outline-blue-500 shadow-sm":(o||g)&&!l}),children:[(0,Le.jsx)("div",{className:G("flex align-items justify-center w-10 border-r-2 border-grey-400",{"border-blue-500":(o||g)&&!l}),onDoubleClick:b,children:(0,Le.jsx)("div",{className:"relative flex-1 [writing-mode:vertical-rl] [text-orientation:sideways] transform rotate-180",children:(0,Le.jsx)(st,{value:t.label,className:"w-full h-full self-auto",contentClassName:G({"whitespace-nowrap":p}),isEditing:p,onBlur:I,onChange:T})})}),(0,Le.jsx)("div",{className:"flex-1"})]}),(0,Le.jsx)(ct,{nodeId:e,nodeType:"LANE",isChild:!E}),a==="edit"&&(0,Le.jsx)(Rt,{nodeId:e,isVisible:!n&&o,minWidth:f,minHeight:y,offset:10}),!c&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(ne,{type:"source",position:It.Position.Left,id:"left"}),(0,Le.jsx)(ne,{type:"source",position:It.Position.Right,id:"right"}),(0,Le.jsx)(ne,{type:"source",position:It.Position.Top,id:"top"}),(0,Le.jsx)(ne,{type:"source",position:It.Position.Bottom,id:"bottom"})]}),(!c||u)&&(0,Le.jsxs)(Le.Fragment,{children:[(0,Le.jsx)(ne,{type:"target",position:It.Position.Left,id:"left",className:G({"annotation-handle":u})}),(0,Le.jsx)(ne,{type:"target",position:It.Position.Right,id:"right",className:G({"annotation-handle":u})}),(0,Le.jsx)(ne,{type:"target",position:It.Position.Top,id:"top",className:G({"annotation-handle":u})}),(0,Le.jsx)(ne,{type:"target",position:It.Position.Bottom,id:"bottom",className:G({"annotation-handle":u})})]})]})});Ea.displayName="Lane";var Pu={START_EVENT:Tu,END_EVENT:xu,TASK:ya,GATEWAY:ma,ANNOTATION:hu,LANE:Ea,UNSUPPORTED:Au},Lu={SEQUENCE_EDGE:ra,MESSAGE_EDGE:Cu,ANNOTATION_EDGE:Pd},ku="#fafafa",Ru="#bebebe",Du=1,Ou=10,Vu="bottom-left",_a=.05,Hu=5,Gu=150,Bu=100,zu=_a,Yu=1,Fu={x:0,y:0,zoom:.75},Wu=1,Xu=2,py={[Wu]:4,[Xu]:2},kr=[Wu,Xu],Uu=[0,1,2],$u={hideAttribution:!0},ba=kr.reduce((e,t)=>e|py[t],0);var ko=()=>{let{setViewport:e}=(0,fs.useReactFlow)(),t=(0,fs.useStoreApi)();return{fitToNodes:(0,Ku.useCallback)(n=>{let{width:r,height:i}=t.getState();if(i<=0||r<=0)return;let s=dl(n);if(!s)return;let a=ul({bounds:s,canvasHeight:i,canvasWidth:r,minZoom:zu,maxZoom:Yu,offsetX:Gu,offsetY:Bu});e(a)},[t,e])}};var qu=require("@xyflow/react");var Dt=()=>{let{getEdges:e,getNodes:t}=(0,qu.useReactFlow)(),{lastElementId:o}=U(),n=()=>{let i=t(),s=e(),a=Kd(i,s);return Math.max(a,o)};return{getLastId:n,getNextId:()=>n()+1}};var Ro=()=>{let{getNodes:e,getEdges:t,setNodes:o,setEdges:n}=(0,Zu.useReactFlow)(),{getLastId:r}=Dt(),{fitToNodes:i}=ko(),{setLastElementId:s}=U(),a=(0,Ta.useCallback)(async(c="")=>{let{nodes:d,edges:u,lastElementId:p}=await lu(c);i(d),o(d),n(u),s(p)},[o,n,s,i]),l=(0,Ta.useCallback)(()=>{let c=e(),d=t(),u=r();return au(c,d,u)},[e,t,r]);return{importFromMxGraph:a,exportToMxGraph:l}};var fy=500,ms=()=>{let{isInitialized:e,onElementChanges:t}=U(),{exportToMxGraph:o}=Ro(),n=(0,Ju.useDebouncedCallback)(()=>{if(!e)return;let s=o();t==null||t(s)},fy);(0,Rr.useEffect)(()=>()=>{n.isPending()&&n.flush()},[n]);let r=(0,Rr.useCallback)(s=>{s.every(c=>c.type==="select")||s.some(c=>c.type==="position"&&c.dragging)||n()},[n]),i=(0,Rr.useCallback)(s=>{s.some(l=>l.type==="select")||n()},[n]);return{emitElementChanges:n,handleNodeChanges:r,handleEdgeChanges:i}};var Qu=({setEdges:e,saveHistory:t})=>{let{getNode:o,getEdges:n,getNodes:r,getInternalNode:i}=(0,gs.useReactFlow)(),{emitElementChanges:s}=ms(),a=(0,ro.useRef)(null),{getNextId:l}=Dt(),c=(0,ro.useCallback)(g=>{var b;let h=o(g.source),f=o(g.target);if(!h||!f)return!1;let y={sourceNodeId:h.id,targetNodeId:f.id,sourceNodeType:h.type,targetNodeType:f.type,nodes:r(),edges:n(),reconnectingEdgeId:(b=a.current)!=null?b:void 0};return ea(y).isValid},[o,n,r]),d=(0,ro.useCallback)(g=>{var y,T;let h=l(),f=i(g.source);if(f){let b=i(g.target),I=b?b.internals.positionAbsolute.x+((y=b.measured.width)!=null?y:0)/2:0,v=b?b.internals.positionAbsolute.y+((T=b.measured.height)!=null?T:0)/2:0,N=Bd(f,I,v),C=(b==null?void 0:b.type)==="ANNOTATION"||(f==null?void 0:f.type)==="ANNOTATION",M=C?Bn:kt,L;if(!C&&b&&g.targetHandle){let V=ji(N),Y=ji(g.targetHandle),{x:j,y:q}=ia(f,N),{x:$,y:A}=ia(b,g.targetHandle),k=qi(j,q,$,A,V,Y).slice(1,-1);k.length>0&&(L=k)}let R=w(_(_({},g),M),{id:String(h),sourceHandle:N,data:_(_({},C?{}:kt.data),L?{points:L}:{})}),O=n().concat(R);e(O),t("forceSave",{nodes:r(),edges:O}),s()}},[l,e,s,i,n,r,t]),u=(0,ro.useCallback)((g,h)=>{a.current=h.id},[]),p=(0,ro.useCallback)(()=>{a.current=null},[]),m=(0,ro.useCallback)((g,h)=>{let f=o(h.source),y=o(h.target);if(!f||!y){a.current=null;return}let T={sourceNodeId:f.id,targetNodeId:y.id,sourceNodeType:f.type,targetNodeType:y.type,nodes:r(),edges:n(),reconnectingEdgeId:g.id};if(!ea(T).isValid){a.current=null;return}let I=(0,gs.reconnectEdge)(g,h,n()).map(v=>v.id===g.id?w(_({},v),{data:w(_({},v.data),{points:void 0})}):v);e(I),t("forceSave",{nodes:r(),edges:I}),a.current=null,s()},[o,r,n,e,s,t]),x=(0,ro.useCallback)(g=>{a.current=g},[]),E=(0,ro.useCallback)(()=>{a.current=null},[]);return{isValidConnection:c,onConnect:d,onReconnect:m,onReconnectStart:u,onReconnectEnd:p,setReconnectingEdge:x,clearReconnectingEdge:E}};var Hr=require("@produto-lecom/lecom-ui"),ap=require("@xyflow/react"),Ct=require("react");var Dr=(e=[])=>e.filter(t=>t.type==="START_EVENT"),dn=(e=[])=>e.filter(t=>t.type==="END_EVENT"),Do=(e=[])=>e.filter(t=>t.type==="TASK")||[],ju=(e=[])=>e.filter(t=>{var o;return t.type==="TASK"&&((o=t.properties)==null?void 0:o.variant)==="SCRIPT"});var hs=(e=[])=>e.filter(t=>t.type==="GATEWAY"),ep=(e=[])=>e.filter(t=>{var o;return t.type==="GATEWAY"&&((o=t.properties)==null?void 0:o.variant)==="EXCLUSIVE"}),At=(e,t=[])=>t.filter(o=>o.source===e),Or=(e,t=[])=>t.filter(o=>o.target===e),tp=(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"},op=(e,t)=>{let o=At(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},np=e=>e?/[^\s]/.test(e.trim()):!1,Ee=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:[]}},Eo=(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)}},my=(e,t)=>{let o=new Set(e.filter(n=>n.type==="ANNOTATION").map(n=>n.id));return t.filter(n=>!o.has(n.source)&&!o.has(n.target))},rp=(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:my(e,t).map(o=>({id:o.id,source:o.source,target:o.target,type:o.type||"default"}))});var Vr=[{id:"start_event_not_found",validate:e=>{let t=Dr(e.nodes);return Ee({isValid:t.length>=1})}},{id:"end_event_not_found",validate:e=>{let t=dn(e.nodes);return Ee({isValid:t.length>=1})}},{id:"multiple_start_event_not_allowed",validate:e=>{let t=Dr(e.nodes),o=t.length===1;if(t.length===0)return Ee({isValid:!0});if(!o)return Ee({isValid:!1,nodeIds:t.map(i=>i.id)});let n=At(t[0].id,e.edges);if(!(n.length<=1)){let i=[...t.map(s=>s.id),...n.map(s=>s.target)];return Ee({isValid:!1,nodeIds:[...new Set(i)]})}return Ee({isValid:!0})}},{id:"task_flows_limit_exceeds",validate:e=>{let t=Do(e.nodes),o=Eo(t,n=>At(n.id,e.edges).length<=2);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_empty",highlightRelatedEdges:!1,validate:e=>{let t=Do(e.nodes),o=Eo(t,n=>!!n.label&&n.label.trim()!=="");return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"task_label_length",highlightRelatedEdges:!1,validate:e=>{let o=Do(e.nodes),n=Eo(o,r=>!r.label||r.label.length<=60);return Ee({isValid:n.isValid,nodeIds:n.invalidIds})}},{id:"duplicate_task_name",highlightRelatedEdges:!1,validate:e=>{let t=Do(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 Ee({isValid:n.length===0,nodeIds:n})}},{id:"nested_gateway",validate:e=>{var r,i,s,a;let t=hs(e.nodes),o=[],n=[];for(let l of t){let c=At(l.id,e.edges);for(let d of c){let u=e.nodes.find(x=>x.id===d.target);if((u==null?void 0:u.type)!=="GATEWAY")continue;let p=((r=l.properties)==null?void 0:r.variant)==="EXCLUSIVE"&&((i=u==null?void 0:u.properties)==null?void 0:i.variant)==="PARALLEL",m=((s=l.properties)==null?void 0:s.variant)==="COMPLEX"&&((a=u==null?void 0:u.properties)==null?void 0:a.variant)==="PARALLEL";!p&&!m&&(o.push(l.id,u.id),n.push(d.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"events_nested",validate:e=>{let t=[...Dr(e.nodes),...dn(e.nodes)],o=[],n=[];for(let r of t){let i=At(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&(a.type==="START_EVENT"||a.type==="END_EVENT")&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"flows_on_end_tasks_not_allowed",validate:e=>{let t=dn(e.nodes),o=[],n=[];for(let r of t){let i=Or(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.source);if(a&&a.type==="TASK"){let l=At(a.id,e.edges);l.length>1&&(o.push(a.id),l.forEach(c=>n.push(c.id)))}}}return Ee({isValid:o.length===0,nodeIds:o,edgeIds:n})}},{id:"conditions_flows_limit_exceeds",validate:e=>{let t=ep(e.nodes),o=Eo(t,r=>At(r.id,e.edges).length<=2),n=o.invalidIds.flatMap(r=>At(r,e.edges).map(i=>i.id));return Ee({isValid:o.isValid,nodeIds:o.invalidIds,edgeIds:n})}},{id:"activity_name_invalid",validate:e=>{let t=Do(e.nodes),o=Eo(t,n=>!n.label||np(n.label));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"final_activity_has_loop",validate:e=>{var s,a;if(!((s=e==null?void 0:e.nodes)!=null&&s.length)||!((a=e==null?void 0:e.edges)!=null&&a.length))return Ee({isValid:!0});let t=dn(e.nodes)[0];if(!t)return Ee({isValid:!0});let o=Or(t.id,e.edges);if(!o.length)return Ee({isValid:!0});let r=Do(e.nodes).filter(l=>o.some(c=>c.source===l.id)),i=Eo(r,l=>!tp(l.id,e));return Ee({isValid:i.isValid,nodeIds:i.isValid?[]:[t.id,...i.invalidIds]})}},{id:"concurrent_initial_and_final_event",validate:e=>{let t=Do(e.nodes),o=dn(e.nodes)[0];if(!o)return Ee({isValid:!0});let n=t.filter(l=>{let c=Or(l.id,e.edges),d=At(l.id,e.edges),u=c.some(m=>{var x;return((x=e.nodes.find(E=>E.id===m.source))==null?void 0:x.type)==="START_EVENT"}),p=d.some(m=>{var x;return((x=e.nodes.find(E=>E.id===m.target))==null?void 0:x.type)==="END_EVENT"});return u&&p}),r=Or(o.id,e.edges),i=r.length>1,s=r.map(l=>l.source),a={isValid:n.length===0&&!i,nodeIds:[...n.map(l=>l.id),...i?s:[]]};return Ee(a)}},{id:"gateway_flow_to_event",validate:e=>{let t=hs(e.nodes),o=[],n=[];for(let r of t){let i=At(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="END_EVENT"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"gateway_missing_output_streams",validate:e=>{let t=hs(e.nodes),o=Eo(t,n=>At(n.id,e.edges).length>=1);return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}},{id:"event_to_condition",validate:e=>{let t=[...Dr(e.nodes),...dn(e.nodes)],o=[],n=[];for(let r of t){let i=At(r.id,e.edges);for(let s of i){let a=e.nodes.find(l=>l.id===s.target);a&&a.type==="GATEWAY"&&(o.push(r.id,a.id),n.push(s.id))}}return Ee({isValid:o.length===0,nodeIds:o.length>0?[...new Set(o)]:[],edgeIds:n})}},{id:"script_in_final_activity",validate:e=>{let t=ju(e.nodes),o=Eo(t,n=>!op(n.id,e));return Ee({isValid:o.isValid,nodeIds:o.invalidIds})}}];var ip=e=>{e=e||{nodes:[],edges:[]},e.nodes=e.nodes||[],e.edges=e.edges||[];let t=[];for(let n of Vr){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}},sp=async(e,t)=>{var n;let o=[];try{let r=await e(),i=(n=r==null?void 0:r.filter(s=>s.area==="DIAGRAM"))!=null?n:[];return i.length===0?{isValid:!0,errors:[]}:(i.forEach(s=>{var l,c;let a=(c=(l=s==null?void 0:s.detail)==null?void 0:l.phases)==null?void 0:c.map(d=>d.diagramCellId);o.push({id:s.code,message:s.code,nodeIds:a,edgeIds:[]})}),{isValid:!1,errors:o})}catch(r){let i=[],s=(a,l)=>{let c=t.filter(d=>{var u;return((u=d.data)==null?void 0:u.variant)===a}).map(d=>d.id);c.length>0&&i.push({id:l,message:l,nodeIds:c,edgeIds:[]})};return s("SUBPROCESS","cannot_validate_subprocess_reference"),s("SERVICE_TASK","service_task_automation_status_unavailable"),{isValid:!1,errors:i}}};var un=require("react/jsx-runtime"),lp=()=>{let{t:e}=(0,Hr.useTranslation)(),{toast:t}=et(),{setNodes:o,setEdges:n,getNodes:r,getEdges:i}=(0,ap.useReactFlow)(),{validateCustomDiagram:s}=U(),[a,l]=(0,Ct.useState)(!1),c=(0,Ct.useRef)(!1),d=(0,Ct.useRef)(!1),u=(0,Ct.useRef)(!1),p=(0,Ct.useCallback)(async f=>{let y=rp(f.nodes,f.edges),T=ip(y),b=f.nodes.filter(({type:v,data:N})=>v==="TASK"&&((N==null?void 0:N.variant)==="SUBPROCESS"||(N==null?void 0:N.variant)==="SERVICE_TASK"));if(s&&b.length>0){let v=await sp(s,b);T={isValid:T.isValid&&v.isValid,errors:[...T.errors,...v.errors]}}let I=T.errors.map(v=>w(_({},v),{message:e(`validation.errors.${v.id}`)}));return a||l(!0),{isValid:T.isValid,errors:I}},[a,e,s]),m=(0,Ct.useCallback)((f,y=!0)=>{if(y&&f){let V=f.isValid?e("validation.success.title"):e("validation.errors.title"),Y=f.isValid?e("validation.success.message"):e("validation.errors.subtitle");t({variant:f.isValid?"success":"error",duration:5e3,title:V,content:(0,un.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,un.jsx)(Hr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:Y}),!f.isValid&&(0,un.jsx)("ul",{className:"list-disc list-inside max-h-[600px] overflow-y-auto",children:f.errors.map(j=>(0,un.jsx)("li",{children:(0,un.jsx)(Hr.Typography,{variant:"body-medium-400",textColor:"text-grey-950",children:j.message})},j.id))})]})})}if(!f)return;c.current=!0,d.current=!0,u.current=!0;let T=[],b=[];f.errors.forEach(V=>{V.nodeIds&&V.nodeIds.length>0&&V.nodeIds.forEach(Y=>T.push(Y)),V.edgeIds&&V.edgeIds.length>0&&V.edgeIds.forEach(Y=>b.push(Y))});let I=[...new Set(T)],v=r(),N=i(),C=new Set(I),M=new Set;f.errors.forEach(V=>{var q,$;let Y=Vr.find(A=>A.id===V.id);(Y==null?void 0:Y.highlightRelatedEdges)!==!1&&((q=V.edgeIds)==null||q.forEach(A=>M.add(A)),($=V.nodeIds)==null||$.forEach(A=>{N.forEach(P=>{(P.source===A||P.target===A)&&M.add(P.id)})}))});let L=new Set,R=new Set,O=new Set;v.forEach(V=>{V.type==="START_EVENT"?L.add(V.id):V.type==="END_EVENT"&&R.add(V.id)}),N.forEach(V=>{L.has(V.source)&&O.add(V.target),R.has(V.target)&&O.add(V.source)}),O.forEach(V=>{var Y,j;if(C.has(V)){let q=(Y=f.errors.find(A=>{var P;return(P=A.nodeIds)==null?void 0:P.includes(V)}))==null?void 0:Y.id;((j=Vr.find(A=>A.id===q))==null?void 0:j.highlightRelatedEdges)!==!1&&N.forEach(A=>{A.source===V&&R.has(A.target)&&(C.add(A.target),M.add(A.id)),A.target===V&&L.has(A.source)&&(C.add(A.source),M.add(A.id))})}}),o(V=>V.map(Y=>w(_({},Y),{data:w(_({},Y.data),{hasError:C.has(Y.id)})}))),n(V=>V.map(Y=>w(_({},Y),{data:w(_({},Y.data),{hasError:M.has(Y.id)})}))),setTimeout(()=>{d.current=!1,c.current=!1},0)},[e,i,r,n,o,t]),x=(0,Ct.useCallback)(()=>{l(!1),u.current=!1,o(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),n(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})})))},[n,o]),E=(0,Ct.useCallback)(()=>{u.current&&(d.current=!0,u.current=!1,o(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),n(f=>f.map(y=>w(_({},y),{data:w(_({},y.data),{hasError:!1})}))),setTimeout(()=>{d.current=!1},0))},[n,o]),g=(0,Ct.useCallback)(()=>d.current,[]),h=(0,Ct.useCallback)(()=>c.current,[]);return{validateDiagram:p,handleValidationComplete:m,clearValidation:x,dismissValidationPanel:E,isAutoValidationEnabled:a,getIsClearingValidation:g,getIsValidating:h}};var up=require("@xyflow/react"),pp=require("@produto-lecom/lecom-ui"),fp=require("react");var gy=15,cp="bpmn:selection",hy=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},dp=e=>{if(!hy(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},mp=({offset:e=gy,saveHistory:t})=>{let{t:o}=(0,pp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,up.useReactFlow)(),{getNextId:a}=Dt(),{mode:l,containerRef:c}=U();(0,fp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=m=>{var b,I;if(!dp(m)||!d.contains(document.activeElement))return;let E=n(),g=i(),h=E.filter(v=>v.selected);if(!h.length)return;m.preventDefault(),m.stopPropagation();let f=g.filter(v=>h.some(N=>N.id===v.source)&&h.some(N=>N.id===v.target)),T=JSON.stringify({nodes:h,edges:f});(b=m.clipboardData)==null||b.setData(cp,T),(I=m.clipboardData)==null||I.setData("text/plain",`BPMN Selection: ${h.length} nodes`)},p=m=>{var L,R;if(!dp(m)||!d.contains(document.activeElement))return;let E=(L=m.clipboardData)==null?void 0:L.getData(cp);if(!E)return;m.preventDefault(),m.stopPropagation();let g;try{g=JSON.parse(E)}catch(O){return}if(!((R=g.nodes)!=null&&R.length))return;let h=new Map,f=n(),y=[],T=g.nodes.filter(O=>Rn(O.type,f));if(T.length===0)return;let b=a(),I=T.map(O=>{var j;let V=String(b++);h.set(O.id,V);let Y=w(_({},O),{id:V,selected:!0,position:{x:O.position.x+e,y:O.position.y+e}});if(O.type==="TASK"){let q=(j=O.data)==null?void 0:j.label,$=qn(q||o("bpmn.task.label.prefix"),[...f,...y]);Y.data=w(_({},O.data),{label:$})}return y.push(Y),Y}),v=g.edges.map(O=>w(_({},O),{id:String(b++),selected:!0,source:h.get(O.source)||O.source,target:h.get(O.target)||O.target})),N=[...f.map(O=>w(_({},O),{selected:!1})),...I],M=[...i().map(O=>w(_({},O),{selected:!1})),...v];r(N),s(M),t("forceSave",{nodes:N,edges:M})};return d.addEventListener("copy",u,!0),d.addEventListener("paste",p,!0),()=>{d.removeEventListener("copy",u,!0),d.removeEventListener("paste",p,!0)}},[n,r,i,s,a,e,o,t,l,c])};var gp=require("@produto-lecom/lecom-ui"),hp=require("@xyflow/react"),pn=require("react");var yp=({nodes:e,setNodes:t})=>{let{t:o}=(0,gp.useTranslation)(),{toast:n}=et(),{getNodes:r}=(0,hp.useReactFlow)(),{setIsRemovingElements:i,validateDeleteElements:s}=U(),a=(0,pn.useRef)(!1),l=(0,pn.useCallback)(async p=>{try{let{activitiesWithInstances:m}=await s(p);if(m.length)return a.current=!1,i(!1),n({variant:"warning",content:o("editor.toolbar.delete_elements_blocked")}),!1}catch(m){return a.current=!1,i(!1),n({variant:"error",content:o("editor.toolbar.delete_elements_error")}),!1}return!0},[o,n,s,i]),c=(0,pn.useCallback)(async({nodes:p})=>{if(a.current)return!1;if(a.current=!0,i(!0),p.some(E=>E.type==="LANE"&&e.some(g=>g.parentId===E.id)))return a.current=!1,i(!1),n({variant:"error",title:o("validation.errors.title"),content:o("editor.toolbar.delete_pool_lane_error")}),!1;let x=p.filter(E=>E.type==="TASK");if(s&&x.length>0){let E=x.map(g=>g.id);return l(E)}return!0},[e,o,n,s,l,i]),d=(0,pn.useCallback)(p=>{a.current=!1,i(!1);let m=new Set(p.filter(x=>x.type==="LANE"&&!!x.parentId).map(x=>x.parentId));m.size!==0&&setTimeout(()=>{var g,h;let x=r(),E=new Map(x.map(f=>[f.id,f]));for(let f of m){let y=rn(x.filter(I=>I.type==="LANE"&&I.parentId===f));if(y.length===0)continue;let T=0;for(let I of y)E.set(I.id,w(_({},I),{position:{x:ie.HEADER_WIDTH,y:T}})),T+=(h=(g=I.measured)==null?void 0:g.height)!=null?h:0;let b=E.get(f);b&&E.set(f,w(_({},b),{height:T,measured:w(_({},b.measured),{height:T})}))}t(x.map(f=>{var y;return(y=E.get(f.id))!=null?y:f}))},0)},[r,t,i]),u=(0,pn.useCallback)(()=>{a.current=!1,i(!1)},[i]);return{onBeforeDelete:c,onNodesDelete:d,onEdgesDelete:u}};var xp=require("@produto-lecom/lecom-ui"),Ep=require("@xyflow/react");var ys=require("react");var yy=50,_p=({nodes:e,setNodes:t,setEdges:o,saveHistory:n})=>{let{draggableNode:r,setDraggableNode:i}=$n(),{t:s}=(0,xp.useTranslation)(),{getInternalNode:a,getNodes:l,getEdges:c,screenToFlowPosition:d}=(0,Ep.useReactFlow)(),{getNextId:u}=Dt(),{setIsDragging:p}=U(),{getInternalNodes:m}=ss(),{rebuildIndex:x,forceRebuildIndex:E}=Vi(),[g,h]=(0,ys.useState)(null),f=(0,ys.useRef)(""),y=(A,P,k)=>{var D;if(A.parentId!==P)return null;let S=k.filter(H=>H.id!==A.id&&H.parentId===P&&H.type==="LANE").sort((H,z)=>H.position.y-z.position.y);if(S.length===0)return null;let B=(D=k.find(H=>H.id===A.id))!=null?D:A,F=S.find(H=>B.position.y<H.position.y);return F?{draggedLaneId:A.id,beforeLaneId:F.id}:{draggedLaneId:A.id,afterLaneId:S[S.length-1].id}},T=(A,P=!1,k)=>{let S=P?"node-drop-target-error":"node-drop-target",B=P?"node-drop-target-lane-error":"node-drop-target-lane";t(F=>{var K,Z,W,X;let D=(K=k==null?void 0:k(F))!=null?K:null,H=[A!=null?A:"",P?"error":"valid",(Z=D==null?void 0:D.draggedLaneId)!=null?Z:"",(W=D==null?void 0:D.beforeLaneId)!=null?W:"",(X=D==null?void 0:D.afterLaneId)!=null?X:""].join(":"),z=Q=>{let ee=[];return Q.id===A&&ee.push(S),A!==void 0&&Q.parentId===A&&Q.type==="LANE"&&Q.id!==(D==null?void 0:D.draggedLaneId)&&ee.push(B),Q.id===(D==null?void 0:D.draggedLaneId)&&ee.push("lane-reorder-dragging"),Q.id===(D==null?void 0:D.beforeLaneId)&&ee.push("lane-reorder-before"),Q.id===(D==null?void 0:D.afterLaneId)&&ee.push("lane-reorder-after"),ee.join(" ")||void 0};return f.current===H?F:(f.current=H,F.map(Q=>{let ee=z(Q);return Q.className===ee?Q:w(_({},Q),{className:ee})}))})},b=(A,P)=>{let k=m();if(A.type==="LANE"){if(P){T();return}let H=k.filter(Z=>Z.id!==A.id&&Z.type==="LANE"&&!Z.parentId),z=ar(A,H);if(!z){T();return}if(Xo({parentId:z.id,nodes:e,excludeTypes:["LANE"]})){T(z.id,!0);return}T(z.id,!1,Z=>y(A,z.id,Z));return}let B=k.filter(H=>H.id!==A.id&&H.type==="LANE"),F=ar(A,B);if(!F){T();return}if(Xo({parentId:F.id,nodes:e,includeTypes:["LANE"]})){T();return}T(F.id)},I=A=>{let P=a(A.id),k=A.type==="LANE"&&Xo({parentId:A.id,nodes:e,includeTypes:["LANE"]});b(P,k)},v=A=>(f.current="",A.map(P=>w(_({},P),{className:void 0}))),N=A=>A.some(k=>k.dragging)?A.map(k=>k.dragging?w(_({},k),{dragging:!1}):k):A,C=(A,P)=>{let k=0;for(let S of P){if(S.id===A||S.parentId||S.type==="LANE")continue;let B=Mt(S),F=B.y+B.h;k=Math.max(k,F)}return k+yy},M=(A,P)=>{if(!Os(A,P))return P;let k=C(A,P);return P.map(S=>S.id===A?w(_({},S),{position:w(_({},S.position),{y:k})}):S)},L=A=>{if(A.preventDefault(),A.dataTransfer.dropEffect="move",!(r!=null&&r.type))return;let P=d({x:A.clientX,y:A.clientY}),k={id:"__sidebar_drag__",type:r.type,position:P,measured:{width:1,height:1},internals:{positionAbsolute:P}};b(k,!1)},R=A=>{let P=A.relatedTarget;(!P||!A.currentTarget.contains(P))&&T()},O=(A,P)=>{A.preventDefault(),I(P)},V=(A,P,k)=>{var K,Z;let S=[...k],B=P.parentId?P.parentId:P.id;if(A.parentId===P.id)return S=aa(A,P,S),S=go(S),S=nn(B,S),v(S);if(A.type==="LANE"){if(Xo({parentId:P.id,nodes:S,excludeTypes:["LANE"]})){let te=Ri(P),xe=50,pe=50;return S.map(le=>{var Ae,Xe;return le.id===A.id?w(_({},le),{position:{x:(Ae=g==null?void 0:g.x)!=null?Ae:te.x+xe,y:(Xe=g==null?void 0:g.y)!=null?Xe:te.y2+pe}}):le})}let Q=S.filter(te=>te.parentId===P.id).reduce((te,xe)=>{var pe,le;return te+((le=(pe=xe.measured)==null?void 0:pe.height)!=null?le:0)},0),ee={x:ie.HEADER_WIDTH,y:Q};return S=S.map(te=>te.id===A.id?w(_({},te),{parentId:P.id,position:ee,className:void 0}):w(_({},te),{className:void 0})),S=go(S),S=M(B,S),S}if(Xo({parentId:P.id,nodes:S,includeTypes:["LANE"]})){let W;if(A.parentId){let X=a(A.parentId),{x:Q,y:ee}=Mt(X);W={x:Q+((K=A.position.x)!=null?K:0),y:ee+((Z=A.position.y)!=null?Z:0)}}return S=S.map(X=>X.id===A.id?w(_({},X),{position:W!=null?W:X.position,parentId:void 0,className:void 0}):w(_({},X),{className:void 0})),S=nn(B,S),S}let H=ll(A,P);S=S.map(W=>W.id===A.id?w(_({},W),{parentId:P.id,position:H,className:void 0}):w(_({},W),{className:void 0}));let z=S.find(W=>W.id===A.id);return S=aa(z,P,S),S=go(S),S=nn(B,S),S},Y=A=>{if(A.preventDefault(),!(r!=null&&r.type))return;if(!Rn(r.type,l())){p(!1),i(null);return}let P=d({x:A.clientX,y:A.clientY}),k={width:de[r.type].MIN_WIDTH,height:de[r.type].MIN_HEIGHT},S=u(),B={id:String(S),type:r.type,position:P,measured:k,data:{label:r.type==="TASK"?us(e,s("bpmn.task.label.prefix")):"",variant:r.variant,attribute:r.attribute},selected:!0},F=w(_({},B),{internals:{positionAbsolute:P}}),D=w(_({},F),{measured:{width:1,height:1}}),H=m(),z=r.type==="LANE",K=H.filter(te=>z?te.type==="LANE"&&!te.parentId:te.type==="LANE"),Z=ar(D,K),W=[...H.map(te=>w(_({},te),{selected:!1})),F];Z&&(W=V(F,Z,W)),W=Wo(W),z&&!Z&&(W=M(F.id,W)),W=v(W),t(W),E();let X=A.dataTransfer.getData("sourceId"),Q=c(),ee=Q;if(X){let te={id:String(S+1),source:X,target:B.id},xe=r.type==="ANNOTATION"?_(_({},te),Bn):_(_({},te),kt);ee=Q.concat(xe),o(ee)}n("forceSave",{nodes:W,edges:ee}),p(!1),i(null)},j=async(A,P,k)=>{let S=[...m()],B=new Set;k.forEach(H=>{let z=a(H.id),K=H.type==="LANE",Z=S.filter(X=>X.id!==H.id&&(K?X.type==="LANE"&&!X.parentId:X.type==="LANE")),W=ar(z,Z);if(W){if(K&&Xo({parentId:H.id,nodes:S,includeTypes:["LANE"]})){H.parentId&&(S=$(H,S),B.add(H.id));return}S=V(z,W,S);return}H.parentId&&(S=$(H,S),H.type==="LANE"&&B.add(H.id))}),S=N(S);let F=k.filter(H=>H.type==="LANE"&&!H.parentId).map(H=>H.id);for(let H of F)Os(H,S)&&g&&(S=S.map(z=>z.id===H?w(_({},z),{position:_({},g)}):z));for(let H of B)S=M(H,S);if(k.some(H=>H.type!=="LANE"&&!H.parentId)){let H=S.filter(z=>z.type==="LANE"&&!z.parentId).map(z=>z.id);for(let z of H)S=nn(z,S)}S=Wo(S),S=v(S),t(S),x(S),h(null)},q=(A,P)=>{h({x:P.position.x,y:P.position.y})},$=(A,P)=>{var Z,W,X,Q,ee,te,xe,pe;let k=a(A.parentId);if(!k)return P;let S=A.type==="LANE",B=P.filter(le=>le.parentId===k.id&&le.id!==A.id),F=B.filter(le=>le.type==="LANE"),D;if(S&&F.length===0)D=ie.MIN_HEIGHT;else if(S){let le=(W=(Z=A.measured)==null?void 0:Z.height)!=null?W:ie.MIN_HEIGHT;D=((Q=(X=k.measured)==null?void 0:X.height)!=null?Q:ie.MIN_HEIGHT)-le,D=Math.max(ie.MIN_HEIGHT,D)}else D=B.length>0?B.reduce((le,Ae)=>{var Xe,rt;return le+((rt=(Xe=Ae.measured)==null?void 0:Xe.height)!=null?rt:0)},0)+De:Math.max(ie.MIN_HEIGHT,(te=(ee=k.measured)==null?void 0:ee.height)!=null?te:0);let{x:H,y:z}=Mt(k),K={x:H+((xe=A.position.x)!=null?xe:0),y:z+((pe=A.position.y)!=null?pe:0)};return P=P.map(le=>le.id===A.id?w(_({},le),{position:K,parentId:void 0}):le.id===k.id?w(_({},le),{height:D,measured:w(_({},le.measured),{height:D})}):le),P=go(P),P};return{onDragOver:L,onDragLeave:R,onDrop:Y,onNodeDrag:O,onNodeDragStart:q,onNodeDragStop:j}};var bp=require("@xyflow/react"),Tp=require("@produto-lecom/lecom-ui"),vp=require("react");var xy=30,Ey=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},_y=e=>!Ey(e.target),Np=({offset:e=xy,saveHistory:t})=>{let{t:o}=(0,Tp.useTranslation)(),{getNodes:n,setNodes:r,getEdges:i,setEdges:s}=(0,bp.useReactFlow)(),{getNextId:a}=Dt(),{mode:l,containerRef:c}=U();(0,vp.useEffect)(()=>{if(l!=="edit")return;let d=c.current;if(!d)return;let u=p=>{if(d.contains(document.activeElement)&&p.ctrlKey&&p.key.toLowerCase()==="d"&&_y(p)){p.preventDefault(),p.stopPropagation();let x=n(),E=i(),g=x.filter(M=>M.selected);if(!g.length)return;let h=new Map,f=[],y=g.filter(M=>Rn(M.type,x));if(y.length===0)return;let T=E.filter(M=>y.some(L=>L.id===M.source)&&y.some(L=>L.id===M.target)),b=a(),I=y.map(M=>{var O;let L=String(b++);h.set(M.id,L);let R=w(_({},M),{id:L,selected:!0,position:{x:M.position.x+e,y:M.position.y+e}});if(M.type==="TASK"){let V=(O=M.data)==null?void 0:O.label,Y=qn(V||o("bpmn.task.label.prefix"),[...x,...f]);R.data=w(_({},M.data),{label:Y})}return f.push(R),R}),v=T.map(M=>w(_({},M),{id:String(b++),selected:!0,source:h.get(M.source)||M.source,target:h.get(M.target)||M.target})),N=[...x.map(M=>w(_({},M),{selected:!1})),...I],C=[...E.map(M=>w(_({},M),{selected:!1})),...v];r(N),s(C),t("forceSave",{nodes:N,edges:C})}};return d.addEventListener("keydown",u,!0),()=>{d.removeEventListener("keydown",u,!0)}},[n,r,i,s,a,e,o,t,l,c])};var Br=require("react"),wp=require("@xyflow/react");var by=20,Ty=50,Gr={UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowRight"},vy=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},Ip=e=>{let{getNodes:t}=(0,wp.useReactFlow)(),{mode:o,isMoveTool:n}=U(),r=(0,Br.useRef)(0),i=(0,Br.useRef)(new Map);(0,Br.useEffect)(()=>{let s=a=>{if(o!=="edit"||!n||vy(a.target)||!Object.values(Gr).includes(a.key))return;let u=t().filter(f=>f.selected);if(u.length===0){i.current.clear();return}a.preventDefault();let p=Date.now(),m=p-r.current<500;r.current=p;let x=a.shiftKey?Ty:by,E=0,g=0;switch(a.key){case Gr.UP:g=-x;break;case Gr.DOWN:g=x;break;case Gr.LEFT:E=-x;break;case Gr.RIGHT:E=x;break}let h=u.map(f=>{let y=i.current.get(f.id);(!m||!y)&&(y={x:f.position.x,y:f.position.y});let T={x:y.x+E,y:y.y+g};return i.current.set(f.id,T),{id:f.id,dragging:!1,type:"position",position:T}});e&&e(h)};return window.addEventListener("keydown",s),()=>{window.removeEventListener("keydown",s)}},[t,e,o,n])};var Pp=require("@xyflow/react");var Cp={"start-event":"START_EVENT","end-event":"END_EVENT",task:"TASK","gateway-exclusive":"GATEWAY","gateway-parallel":"GATEWAY","gateway-complex":"GATEWAY"},Sp={"start-event":"","end-event":"",task:"","gateway-exclusive":"EXCLUSIVE","gateway-parallel":"PARALLEL","gateway-complex":"COMPLEX"},Ap=(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)||[],s="",a="",l="";if(o.length){switch(o[1]){case"<start>":s="start-event";break;case"<end>":s="end-event";break}e=e.replace(o[1],"")}return n.length&&(s="task",a=n[1].replace(/\[|\]/g,""),e=e.replace(n[1],"")),r.length&&(a=r[1].replace(/\{|\}/g,""),a.charAt(0)==="+"?(s="gateway-parallel",a=a.slice(1)):a.charAt(0)==="*"?(s="gateway-complex",a=a.slice(1)):s="gateway-exclusive",e=e.replace(r[1],"")),s||(s="task",a=e),i.length&&(l=i[1].replace(/(\||--)/g,""),e=e.replace(i[1],"")),e=e.trim(),t[e]||(t[e]={type:s,label:a}),{step:e,type:s,label:a,edgeLabel:l}},Ny=e=>{e=e||"";let t=e.trim().split(`
42
+ `),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 s=Ap(i[0],o),a=Ap(i[1],o);s&&a&&n.push({sourceId:s.step,targetId:a.step,label:s.edgeLabel||a.edgeLabel||""})}),{components:o,connections:n}},Mp=e=>{let{components:t,connections:o}=Ny(e);return{nodes:t,edges:o}};var wy=7,Iy=48,Ay=340,Cy=(e,t)=>{let o=Iy+e.length*wy;return Math.min(Ay,Math.max(t,o))},xs=()=>{let{setNodes:e,setEdges:t}=(0,Pp.useReactFlow)(),{fitToNodes:o}=ko(),{getNextId:n}=Dt();return{importFromLia:i=>{let s=typeof i=="string"?i:i.diagramXml||"",{nodes:a,edges:l}=Mp(s),c=[],d=new Map,u=!1,p=n();for(let[f,y]of Object.entries(a)){let T=String(p++),b=Cp[y.type],I=Sp[y.type];b==="START_EVENT"&&(u=!0),d.set(f,T);let v=de[b].MIN_WIDTH,N=de[b].MIN_HEIGHT;c.push({id:T,type:b,data:{label:y.label||"",variant:I,attribute:""},position:{x:0,y:0},width:v,height:N,measured:{width:v,height:N}})}let m=[];for(let f of l){let y=w(_({},kt),{id:String(p++),source:d.get(f.sourceId)||f.sourceId,target:d.get(f.targetId)||f.targetId});m.push(y)}if(!u&&c.length>0){let f=String(p++),y={id:f,type:"START_EVENT",data:{label:"",variant:"",attribute:""},position:{x:0,y:0},width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT,measured:{width:de.START_EVENT.MIN_WIDTH,height:de.START_EVENT.MIN_HEIGHT}};c.unshift(y);let T=c[1];if(T){let b=w(_({},kt),{id:String(p++),source:f,target:T.id});m.unshift(b)}}let x=c.map(f=>{var y,T;return f.type==="TASK"?w(_({},f),{width:Cy(String((T=(y=f.data)==null?void 0:y.label)!=null?T:""),de.TASK.MIN_WIDTH)}):f}),{nodes:E}=os(x,m),g=new Map(E.map(f=>[f.id,f.position])),h=c.map(f=>{var y;return w(_({},f),{position:(y=g.get(f.id))!=null?y:f.position})});e(h),t(m),o(h)}}};var Es=require("react"),Sy={origin:"*",debug:!1};function _s(e,t=Sy){let{origin:o,debug:n}=t,r=(0,Es.useCallback)((i,s)=>{let a={event:i,data:s};window.parent.postMessage(a,o||"*")},[o]);return(0,Es.useEffect)(()=>{if(!e)return;let i=s=>{let a=s.data;if(!(a!=null&&a.event)||(a==null?void 0:a.data)===void 0)return;let{event:l,data:c}=a,d;if(Array.isArray(c)){let[,u]=c;d=u.data}else d=c;n&&(console.debug("[postMessage] received:",a),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 Lp=require("@xyflow/react"),Zn=require("react");var kp=()=>{let e=(0,Lp.useNodesInitialized)(),{initialDiagram:t,isNewDiagram:o,isInitialized:n,setIsInitialized:r,onElementChanges:i}=U(),{importFromMxGraph:s,exportToMxGraph:a}=Ro(),{sendMessage:l}=_s(),c=(0,Zn.useRef)(!1);(0,Zn.useEffect)(()=>{t&&s(t)},[t,s]),(0,Zn.useEffect)(()=>{if(!n||!o||c.current)return;c.current=!0;let d=a();i==null||i(d)},[n,o,t,a,i]),(0,Zn.useEffect)(()=>{if(!e)return;(async()=>{await jr(),r(!0),l("INIT_MODELER",t)})()},[e,t,r,l])};var Rp=require("@xyflow/react"),va=require("react");function Dp(){let{setTaskStatuses:e,clearTaskStatuses:t,calculateFlowPath:o}=Uo(),{getEdges:n}=(0,Rp.useReactFlow)(),r=(0,va.useCallback)(s=>{if(!(s!=null&&s.activities))return;e(s.activities);let a=s.activities.map(c=>c.diagramId),l=n();o(l,a)},[e,o,n]),i=(0,va.useCallback)(()=>{t()},[t]);return{handleTasksStatus:r,handleClearTaskStatus:i}}var Vp=require("@xyflow/react"),dt=require("react"),Hp=require("use-debounce");var Py=500,Op=100,Gp=(e=!1)=>{let{getNodes:t,getEdges:o,setNodes:n,setEdges:r}=(0,Vp.useReactFlow)(),{mode:i,containerRef:s}=U(),[a,l]=(0,dt.useState)({history:[],currentStep:0}),{history:c,currentStep:d}=a,u=d>0,p=d<c.length-1,m=(0,dt.useCallback)((v,N)=>{n(v[N].nodes),r(v[N].edges)},[n,r]),x=(0,dt.useCallback)(()=>{if(d>0){let v=d-1;l(N=>w(_({},N),{currentStep:v})),m(c,v)}},[d,c,m]),E=(0,dt.useCallback)(()=>{if(d<c.length-1){let v=d+1;l(N=>w(_({},N),{currentStep:v})),m(c,v)}},[c,d,m]),g=(0,dt.useCallback)(v=>{l(N=>{let C=N.history[N.currentStep];if(C&&JSON.stringify(C)===JSON.stringify(v))return N;let R=[...N.history.slice(0,N.currentStep+1),v],O=R.length>Op?R.slice(R.length-Op):R;return{history:O,currentStep:O.length-1}})},[]),h=(0,dt.useCallback)((v,N)=>{let C=v.map(L=>w(_({},L),{selected:!1,className:"",data:w(_({},L.data),{hasError:!1})})),M=N.map(L=>w(_({},L),{data:w(_({},L.data),{hasError:!1})}));return{nodes:Wo(C),edges:M}},[]),f=(0,dt.useCallback)(()=>h(t(),o()),[t,o,h]),y=(0,Hp.useDebouncedCallback)(()=>{let v=f();g(v)},Py),T=(0,dt.useCallback)((v,N)=>{if(!e)return;if(c.length===0){let M=f();l({history:[M],currentStep:0})}if(v==="forceSave"){if(N){g(h(N.nodes,N.edges));return}y();return}v.some(M=>M.type==="select")||ii(v)||y()},[e,y,c.length,f,g,h]);(0,dt.useEffect)(()=>{if(e&&c.length===0){let v=f();l({history:[v],currentStep:0})}},[e,c.length,f]);let b=(0,dt.useCallback)(v=>{l({history:v||[],currentStep:0})},[]),I=(0,dt.useCallback)(()=>{l({history:[],currentStep:0})},[]);return(0,dt.useEffect)(()=>{if(i!=="edit")return;let v=s.current;if(!v)return;let N=C=>{if(!v.contains(document.activeElement)||!(C.ctrlKey||C.metaKey))return;let R=C.key.toLowerCase();if(C.shiftKey&&R==="z"){C.preventDefault(),E();return}R==="z"&&(C.preventDefault(),x())};return v.addEventListener("keydown",N),()=>{v.removeEventListener("keydown",N)}},[x,E,i,s]),{history:c,undo:x,redo:E,canUndo:u,canRedo:p,saveHistory:T,resetHistory:b,clearHistory:I}};var Bp=()=>{let[e,t,o]=(0,Oo.useNodesState)([]),[n,r,i]=(0,Oo.useEdgesState)([]),{getNode:s}=(0,Oo.useReactFlow)(),a=(0,Oo.useStoreApi)(),{instanceId:l,isInitialized:c,setIsConnecting:d,onElementClick:u}=U(),{updateHelperLines:p,HelperLines:m}=Vi(),{undo:x,redo:E,canUndo:g,canRedo:h,saveHistory:f}=Gp(c),{onNodeDrag:y,onDrop:T,onDragOver:b,onDragLeave:I,onNodeDragStop:v,onNodeDragStart:N}=_p({nodes:e,setNodes:t,setEdges:r,saveHistory:f}),{isValidConnection:C,onConnect:M,onReconnect:L,onReconnectStart:R,onReconnectEnd:O,setReconnectingEdge:V,clearReconnectingEdge:Y}=Qu({setEdges:r,saveHistory:f}),{handleValidationComplete:j,clearValidation:q,dismissValidationPanel:$,validateDiagram:A,getIsValidating:P,getIsClearingValidation:k}=lp(),{importFromLia:S}=xs(),{handleTasksStatus:B,handleClearTaskStatus:F}=Dp(),{clearPathEdges:D}=Uo(),{emitElementChanges:H,handleNodeChanges:z,handleEdgeChanges:K}=ms(),Z=gl();mp({saveHistory:f}),Np({saveHistory:f}),kp();let W=(0,io.useCallback)(()=>{t([]),r([]),D(),setTimeout(Z,0)},[t,r,D,Z]),{selectElements:X,clearSelection:Q}=$t(),{importFromMxGraph:ee,exportToMxGraph:te}=Ro(),{configureElement:xe,getConfigureElement:pe}=Fi(),le=(0,io.useCallback)(Se=>{Se!=null&&Se.id&&X([Se.id])},[X]),{sendMessage:Ae}=_s({LIA_CREATE_DIAGRAM:S,CLEAR_DIAGRAM:W,TASKS_STATUS:B,CLEAR_TASKS_STATUS:F,EXTERNAL_TASK_SELECT:le}),Xe=(0,io.useCallback)(()=>e.length+n.length,[e,n]);(0,io.useEffect)(()=>(to.set(l,{importFromMxGraph:ee,exportToMxGraph:te,selectElements:X,clearSelection:Q,configureElement:xe,getConfigureElement:pe,getElementsCount:Xe,setReconnectingEdge:V,clearReconnectingEdge:Y}),()=>{to.delete(l)}),[l,ee,te,X,Q,xe,pe,Xe,V,Y]);let rt=(0,io.useCallback)((Se,qe)=>{if(qe.type!=="TASK"&&qe.type!=="GATEWAY")return;let yt=pe(qe.id);yt&&(u==null||u(yt)),qe.type==="TASK"&&Ae("SELECT_TASK",{id:qe.id})},[pe,u,Ae]),J=(0,io.useCallback)((Se,qe)=>{if(qe.type!=="SEQUENCE_EDGE")return;let yt=s(qe.source),xt=s(qe.target),{isFromStartEvent:Vt,isGatewayToGateway:pt,isActiviyToAndGateway:Ue,isToEndEvent:it}=ri(yt,xt);if(!(!Vt&&!pt&&!Ue&&!it))return;let Xt=pe(qe.id);Xt&&(u==null||u(Xt))},[pe,s,u]),se=(0,io.useCallback)(Se=>{p(Se,e),o(Se),!ii(Se)&&(f(Se),k()||$(),P()||z(Se))},[e,f,k,$,p,z,P,o]),oe=(0,io.useCallback)(Se=>{i(Se),f(Se),k()||$(),P()||K(Se)},[i,f,k,$,K,P]);Ip(se);let{onBeforeDelete:ae,onNodesDelete:Ce,onEdgesDelete:$e}=yp({nodes:e,setNodes:t});return{nodes:e,setNodes:t,edges:n,setEdges:r,events:{isValidConnection:C,onConnect:M,onReconnect:L,onReconnectStart:R,onReconnectEnd:O,onDrop:T,onDragOver:b,onDragLeave:I,onNodeDrag:y,onNodeDragStop:v,onNodeDragStart:N,onNodeClick:rt,onEdgeClick:J,onDropCapture:()=>{f("forceSave"),H(),$()},onConnectStart:()=>{d(!0)},onConnectEnd:()=>{d(!1),$()},onSelectionEnd:()=>setTimeout(()=>a.setState({nodesSelectionActive:!1}),0),onNodesChange:se,onEdgesChange:oe,onBeforeDelete:ae,onNodesDelete:Ce,onEdgesDelete:$e},ui:{handleCloseValidationPanel:q},controls:{undo:x,redo:E,canUndo:g,canRedo:h},components:{HelperLines:m},actions:{saveHistory:f,selectElements:X,clearSelection:Q,exportToMxGraph:te,validateDiagram:A,handleValidationComplete:j,setReconnectingEdge:V,clearReconnectingEdge:Y}}};var zp=require("react"),Yp=require("@xyflow/react");function bs(){return(0,Yp.useStore)((0,zp.useCallback)(e=>e.nodes.length+e.edges.length>0,[]))}var Fp=require("@xyflow/react"),Vo=require("react");var Ly=".react-flow__node, .react-flow__edge, .react-flow__node-toolbar";function Wp(e,t,o){let[n,r]=(0,Vo.useState)(!1),i=(0,Vo.useRef)(null),{getViewport:s,setViewport:a}=(0,Fp.useReactFlow)(),l=(0,Vo.useCallback)(()=>{i.current=null,r(!1)},[]);return(0,Vo.useEffect)(()=>{let c=e.current;if(!c)return;let d=m=>{if(!kr.some(E=>E===m.button)||t.current||o.current||(r(!0),!(m.target instanceof Element))||!m.target.closest(Ly))return;m.preventDefault(),m.stopPropagation();let x=s();i.current={pointerX:m.clientX,pointerY:m.clientY,viewportX:x.x,viewportY:x.y,zoom:x.zoom}},u=m=>{let x=i.current;if(x){if((m.buttons&ba)===0){l();return}a({x:x.viewportX+(m.clientX-x.pointerX),y:x.viewportY+(m.clientY-x.pointerY),zoom:x.zoom})}},p=m=>{(m.buttons&ba)===0&&l()};return c.addEventListener("pointerdown",d,!0),window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),window.addEventListener("pointercancel",l),window.addEventListener("blur",l),()=>{c.removeEventListener("pointerdown",d,!0),window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),window.removeEventListener("pointercancel",l),window.removeEventListener("blur",l)}},[e,t,o,s,a,l]),n}var Na=require("react/jsx-runtime"),Ts=({id:e,className:t})=>(0,Na.jsx)("marker",{id:e,className:G("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,Na.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 Z"})});var fn=require("react/jsx-runtime"),Xp=()=>(0,fn.jsx)("svg",{style:{position:"absolute",top:0,left:0},children:(0,fn.jsxs)("defs",{children:[(0,fn.jsx)(Ts,{id:"sequence-edge-marker",className:"text-grey-500"}),(0,fn.jsx)(Ts,{id:"sequence-edge-marker-hovered",className:"text-grey-800"}),(0,fn.jsx)(Ts,{id:"sequence-edge-marker-highlighted",className:"text-blue-500"})]})});var Bo=require("@produto-lecom/lecom-ui");var Wr=require("@xyflow/react"),Ve=require("@produto-lecom/lecom-ui"),so=require("lucide-react"),Ft=or(require("react"),1);var Ho=require("@produto-lecom/lecom-ui");var zr=(y=>(y.START_EVENT="START_EVENT",y.END_EVENT="END_EVENT",y.TASK="TASK",y.SUBPROCESS="SUBPROCESS",y.GATEWAY="GATEWAY",y.LANE="LANE",y.ANNOTATION="ANNOTATION",y.CONNECTION="CONNECTION",y.INTERMEDIATE_EVENT="INTERMEDIATE_EVENT",y.ACTIVITY="ACTIVITY",y.PROCESS_INTERFACE="PROCESS_INTERFACE",y.WORKFLOW_INTERFACE="WORKFLOW_INTERFACE",y.VARIANT_ACTIVITY="VARIANT_ACTIVITY",y.AUTO_ACTIVITY="AUTO_ACTIVITY",y.DATA_STORE="DATA_STORE",y.DATA_OBJECT="DATA_OBJECT",y.DATA_OUTPUT="DATA_OUTPUT",y.DATA_INPUT="DATA_INPUT",y.MARKER="MARKER",y))(zr||{});var ws=require("@produto-lecom/lecom-ui"),tf=require("@xyflow/react");var vs=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 Up({columns:e=[],rows:t=[],fileName:o="report"}){if(!e.length||!t.length)return;let r="data:text/csv;charset=utf-8,"+[e,...t].map(s=>s.join(",")).join(`
43
+ `),i=encodeURI(r);Ns(i,`${o}.csv`)}var Ns=(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 $p(e){return e==null?void 0:e.replaceAll("&#xA;"," ")}var XM={START_EVENT:"START_EVENT",END_EVENT:"END_EVENT",TASK:"TASK",GATEWAY:"GATEWAY",ANNOTATION:"ANNOTATION"},Kp={script:"SCRIPT",subprocess:"SUBPROCESS"},qp={"marker-loop":"LOOP"},Zp={complex:"COMPLEX",none:"EXCLUSIVE",exclusive:"EXCLUSIVE",parallel:"PARALLEL",inclusive:"EXCLUSIVE"};var mn=({cell:e,type:t,variant:o="",attribute:n=""})=>{let{_attributes:r,mxGeometry:i}=e,{value:s,parent:a}=r,l=Number(i._attributes.width),c=Number(i._attributes.height),d=a==="1"?void 0:a;return{id:r.id,parentId:d,type:t,data:{label:s||"",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}}},Ry=e=>{let{subType:t,style:o}=e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=de.START_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=de.START_EVENT.MIN_HEIGHT,{node:mn({cell:e,type:"START_EVENT"}),status:n,originalType:o}},Dy=e=>{let{subType:t,style:o}=e==null?void 0:e._attributes,n="imported";return["none"].includes(t)||(n="adapted"),e.mxGeometry._attributes.width=de.END_EVENT.MIN_WIDTH,e.mxGeometry._attributes.height=de.END_EVENT.MIN_HEIGHT,{node:mn({cell:e,type:"END_EVENT"}),status:n,originalType:o}},Oy=(e,t)=>{let{id:o,subType:n,style:r}=e==null?void 0:e._attributes,i=Kp[n],s=t.get(o)||"",a=qp[s]||"",l=a==="LOOP",c="imported";return!["script","none"].includes(n)&&!l&&(c="adapted"),e.mxGeometry._attributes.width=To(e.mxGeometry._attributes.width||0,de.TASK.MIN_WIDTH),e.mxGeometry._attributes.height=To(e.mxGeometry._attributes.height||0,de.TASK.MIN_HEIGHT),{node:mn({cell:e,type:"TASK",variant:i,attribute:a}),status:c,originalType:r}},Vy=e=>{let{style:t,subType:o}=e==null?void 0:e._attributes,n=Zp[o],r=["none","inclusive","event-based"],i="imported";return r.includes(o)&&(i="adapted"),e.mxGeometry._attributes.width=de.GATEWAY.MIN_WIDTH,e.mxGeometry._attributes.height=de.GATEWAY.MIN_HEIGHT,{node:mn({cell:e,type:"GATEWAY",variant:n}),status:i,originalType:t}},Hy=e=>{let{style:t}=e==null?void 0:e._attributes;return{node:mn({cell:e,type:"LANE"}),status:"imported",originalType:t}},Gy=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=To(e.mxGeometry._attributes.width||0,de.ANNOTATION.MIN_WIDTH),e.mxGeometry._attributes.height=To(e.mxGeometry._attributes.height||0,de.ANNOTATION.MIN_HEIGHT),{node:mn({cell:e,type:"ANNOTATION"}),status:"imported",originalType:t}},Jp=e=>{let{style:t}=e==null?void 0:e._attributes;return e.mxGeometry._attributes.width=de.UNSUPPORTED.MIN_WIDTH,e.mxGeometry._attributes.height=de.UNSUPPORTED.MIN_HEIGHT,{node:mn({cell:e,type:"UNSUPPORTED"}),status:"unsupported",originalType:t}},Qp=(e,t)=>{let{id:o,source:n,target:r,value:i}=e._attributes;return w(_({},kt),{id:o,source:t.get(n)||n,target:t.get(r)||r,data:{label:i||""}})},jp={TASK:Oy,GATEWAY:Vy,START_EVENT:Ry,END_EVENT:Dy,LANE:Hy,ANNOTATION:Gy};var By=e=>{let t=new Map,o=Object.values(zr),n=[],r=new Map;e.forEach(a=>{var c;let l=(c=a._attributes)==null?void 0:c.type;if(l==="MARKER"){r.set(a._attributes.parent,a._attributes.style);return}if(o.includes(l)){n.push(a);return}});let i=[],s=[];for(let a of n){let{type:l}=a._attributes,c=jp[l]||Jp,{node:d,status:u,originalType:p}=c(a,r);s.push(d),i.push({originalType:p,type:d.type,variant:d.data.variant,value:$p(d.data.label),status:u})}return{nodes:s,governanceIdToNodeIdMap:t,summary:i}},zy=(e,t)=>e.filter(r=>{var i;return(i=r._attributes)==null?void 0:i.edge}).map(r=>Qp(r,t)),Yy=e=>{let{mxGraphModel:t}=e,{nodes:o,governanceIdToNodeIdMap:n,summary:r}=By(t.root.mxCell),i=zy(t.root.mxCell,n);return{nodes:o,edges:i,summary:r}},Fy=async e=>{let t=await vs(e),o=rs(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),s=r==null?void 0:r.root;if(!i||!s)throw new Error("INVALID_FILE");if(!Object.keys(r.root.mxCell||{}).length)throw new Error("CONTAIN_NO_CELLS");return{metadata:n,mxGraphModel:r}},ef=async e=>{try{let t=await Fy(e),{nodes:o,edges:n,summary:r}=Yy(t)||{};return{nodes:o,edges:n,summary:r}}catch(t){throw t}};var nf=require("react/jsx-runtime"),of=()=>{let{t:e}=(0,ws.useTranslation)(),{toast:t}=et(),{setNodes:o,setEdges:n}=(0,tf.useReactFlow)(),{fitToNodes:r}=ko(),i=a=>{let l=[e("adapter.governance.report.columns.type"),e("adapter.governance.report.columns.value"),e("adapter.governance.report.columns.status")],c=a.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,nf.jsx)(ws.Button,{size:"small",variant:"ghost",onClick:()=>Up({columns:l,rows:c,fileName:"governance-imported-cells"}),children:e("adapter.governance.action.download")})})};return{importFromGovernance:async a=>{try{let{nodes:l,edges:c,summary:d}=await ef(a);if(o(p=>p.concat(l)),n(p=>p.concat(c)),r(l),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 rf=require("@produto-lecom/lecom-ui"),sf=require("react");var gn=require("react/jsx-runtime"),af=a=>{var l=a,{children:e,accept:t="*",multiple:o=!1,disabled:n=!1,onClick:r,onFilesSelected:i}=l,s=Ut(l,["children","accept","multiple","disabled","onClick","onFilesSelected"]);let c=(0,sf.useRef)(null),d=p=>{let m=p.target.files;m!=null&&m.length&&i(m),c.current&&(c.current.value="")};return(0,gn.jsxs)(gn.Fragment,{children:[(0,gn.jsx)(rf.Button,w(_({disabled:n,onClick:p=>{var m;(m=c.current)==null||m.click(),r==null||r(p)}},s),{children:e})),(0,gn.jsx)("input",{type:"file",ref:c,className:"sr-only",accept:t,multiple:o,disabled:n,onChange:d})]})};var hn=require("react/jsx-runtime"),lf=({disabled:e=!1})=>{let{t}=(0,Ho.useTranslation)(),{toast:o}=et(),{importFromGovernance:n}=of(),r=()=>{if(e){o({variant:"error",content:t("adapter.governance.error.ALREADY_INITIALIZED")});return}},i=s=>{let a=s[0];if(!a){o({variant:"error",content:t("adapter.governance.error.NO_FILE")});return}n(a)};return(0,hn.jsxs)(Ho.Tooltip,{children:[(0,hn.jsx)(Ho.TooltipTrigger,{asChild:!0,children:(0,hn.jsx)(af,{className:"[&>svg]:size-7 p-0",variant:"ghost",size:"small",color:"grey",iconButton:!0,accept:".mdr",disabled:e,onClick:r,onFilesSelected:i,children:(0,hn.jsx)(Za,{})})}),(0,hn.jsx)(Ho.TooltipContent,{color:"black",children:t(e?"adapter.governance.error.ALREADY_INITIALIZED":"editor.controls.actions.import_governance")})]})};var cf=require("react/jsx-runtime"),wa=({shortcut:e})=>(0,cf.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 ye=require("@produto-lecom/lecom-ui"),Go=require("lucide-react"),yf=require("react");var ff=require("@produto-lecom/lecom-ui"),mf=require("@xyflow/react"),Yr=require("html-to-image"),gf=require("react");var df=require("@xyflow/react"),uf=(e,t=0)=>{let o=(0,df.getNodesBounds)(e),n=document.querySelectorAll(".react-flow__edge-path"),r=o.x,i=o.y,s=o.x+o.width,a=o.y+o.height;return n.forEach(l=>{let c=l.getBBox();r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x+c.width),a=Math.max(a,c.y+c.height)}),{x:r,y:i,width:s-r+t*2,height:a-i+t*2}};var Wy=3,Ia="diagram",Aa=50,Xy=e=>e instanceof Element&&e.closest("[data-export-hidden]")!==null,Ca=e=>!Xy(e),Uy=96,$y=25.4,Ky="sequence-edge-marker",pf=e=>e*$y/Uy,qy=e=>{let t=document.getElementById(Ky);if(!(t instanceof SVGElement)||!t.ownerSVGElement)return null;let n=t.ownerSVGElement.cloneNode(!0);return n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.setAttribute("aria-hidden","true"),n.setAttribute("data-export-marker-defs","true"),e.prepend(n),n},hf=()=>{let{t:e}=(0,ff.useTranslation)(),{toast:t}=et(),{getEdges:o,getNodes:n}=(0,mf.useReactFlow)(),{clearSelection:r}=$t(),{setIsExporting:i}=U(),[s,a]=(0,gf.useState)({png:!1,html:!1,print:!1}),l=()=>{let{x:m,y:x,width:E,height:g}=uf(n(),Aa),h=Aa-m,f=Aa-x;return{width:E,height:g,style:{width:`${E}px`,height:`${g}px`,transform:`translate(${h}px, ${f}px)`,transformOrigin:"top left"}}},c=async(m,x)=>{a(E=>w(_({},E),{[x]:!0})),i(!0),await r();try{let E=n(),g=o();if(E.length===0&&g.length===0){t({content:e("editor.controls.actions.export.feedback.empty"),variant:"warning"});return}let h=Ud();if(!h)throw new Error("Flow element not found");let f=l(),y=qy(h);try{return await m(h,f)}finally{y==null||y.remove()}}catch(E){console.error("Diagram export failed",E),t({content:e("editor.controls.actions.export.feedback.error"),variant:"error"})}finally{i(!1),a(E=>w(_({},E),{[x]:!1}))}};return{exportAsPng:async(m=Ia)=>{await c(async(x,E)=>{let g=await(0,Yr.toPng)(x,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Ca}));Ns(g,`${m}.png`)},"png")},exportAsHtml:async(m=Ia)=>{await c(async(x,E)=>{let g=await(0,Yr.toSvg)(x,w(_({},E),{backgroundColor:"#fcfcfc",skipFonts:!0,filter:Ca})),h=`
44
44
  <!DOCTYPE html>
45
45
  <html>
46
46
  <head>
47
47
  <meta charset="utf-8" />
48
- <title>${p}</title>
48
+ <title>${m}</title>
49
49
  <style>
50
50
  html, body {
51
51
  margin: 0;
@@ -65,11 +65,11 @@
65
65
  </style>
66
66
  </head>
67
67
  <body>
68
- <img src="${E}" alt="${p}" />
68
+ <img src="${g}" alt="${m}" />
69
69
  </body>
70
- </html>`,y=new Blob([g],{type:"text/html"}),m=URL.createObjectURL(y);Ns(m,`${p}.html`),window.setTimeout(()=>URL.revokeObjectURL(m),1e4)},"html")},printDiagram:async(p=Ia)=>{await l(async(f,h)=>{var N;let E=await(0,Yr.toPng)(f,w(_({},h),{backgroundColor:"#fcfcfc",pixelRatio:Fy,skipFonts:!0,filter:Ca})),g=document.createElement("iframe");g.style.position="fixed",g.style.right="0",g.style.bottom="0",g.style.width="0",g.style.height="0",g.style.border="0",document.body.appendChild(g);let y=(N=g.contentWindow)==null?void 0:N.document;if(!y)throw document.body.removeChild(g),new Error("Unable to access print iframe document");let m=uf(h.width).toFixed(2),x=uf(h.height).toFixed(2),T=y.createElement("style");T.textContent=`
70
+ </html>`,f=new Blob([h],{type:"text/html"}),y=URL.createObjectURL(f);Ns(y,`${m}.html`),window.setTimeout(()=>URL.revokeObjectURL(y),1e4)},"html")},printDiagram:async(m=Ia)=>{await c(async(x,E)=>{var C;let g=await(0,Yr.toPng)(x,w(_({},E),{backgroundColor:"#fcfcfc",pixelRatio:Wy,skipFonts:!0,filter:Ca})),h=document.createElement("iframe");h.style.position="fixed",h.style.right="0",h.style.bottom="0",h.style.width="0",h.style.height="0",h.style.border="0",document.body.appendChild(h);let f=(C=h.contentWindow)==null?void 0:C.document;if(!f)throw document.body.removeChild(h),new Error("Unable to access print iframe document");let y=pf(E.width).toFixed(2),T=pf(E.height).toFixed(2),b=f.createElement("style");b.textContent=`
71
71
  @page {
72
- size: ${m}mm ${x}mm;
72
+ size: ${y}mm ${T}mm;
73
73
  margin: 0;
74
74
  }
75
75
  html, body {
@@ -83,11 +83,11 @@
83
83
  height: 100%;
84
84
  object-fit: contain;
85
85
  }
86
- `,y.head.appendChild(T),y.title=p;let b=y.createElement("img");b.alt="Diagram",y.body.appendChild(b),await new Promise((S,M)=>{let L=!1,k=O=>{L||(L=!0,O?M(O):S())};b.onload=()=>k(),b.onerror=()=>k(new Error("Failed to load print image")),b.src=E,b.complete&&b.naturalWidth>0&&k()});let I=g.contentWindow;if(!I)throw document.body.removeChild(g),new Error("Unable to access print iframe window");let v=()=>{g.parentNode&&document.body.removeChild(g)};I.addEventListener("afterprint",v,{once:!0}),window.setTimeout(v,6e4),I.focus(),I.print()},"print")},isPrintingPng:i.png,isPrintingHtml:i.html,isPrinting:i.print}};var _e=require("react/jsx-runtime");function yf(){let{t:e}=(0,ye.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=gf(),[a,l]=(0,hf.useState)(!1);return(0,_e.jsxs)(ye.DropdownMenu,{modal:!1,open:a,onOpenChange:l,children:[(0,_e.jsx)(ye.DropdownMenuTrigger,{asChild:!0,children:(0,_e.jsx)("div",{children:(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,_e.jsx)(Go.FolderOutputIcon,{})})}),!a&&(0,_e.jsx)(ye.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,_e.jsxs)(ye.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,_e.jsx)(Go.FileImageIcon,{})})}),(0,_e.jsx)(ye.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.DropdownMenuItem,{className:"p-1.5",disabled:s,onClick:()=>o(),children:(0,_e.jsx)(Go.FileCodeIcon,{})})}),(0,_e.jsx)(ye.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,_e.jsx)(Go.PrinterIcon,{})})}),(0,_e.jsx)(ye.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var Ne=require("@produto-lecom/lecom-ui"),Zn=require("lucide-react"),Fr=require("react");var Sa=require("react"),je=require("@produto-lecom/lecom-ui");var xf=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};var Ot=require("react/jsx-runtime"),qy=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
86
+ `,f.head.appendChild(b),f.title=m;let I=f.createElement("img");I.alt="Diagram",f.body.appendChild(I),await new Promise((M,L)=>{let R=!1,O=V=>{R||(R=!0,V?L(V):M())};I.onload=()=>O(),I.onerror=()=>O(new Error("Failed to load print image")),I.src=g,I.complete&&I.naturalWidth>0&&O()});let v=h.contentWindow;if(!v)throw document.body.removeChild(h),new Error("Unable to access print iframe window");let N=()=>{h.parentNode&&document.body.removeChild(h)};v.addEventListener("afterprint",N,{once:!0}),window.setTimeout(N,6e4),v.focus(),v.print()},"print")},isPrintingPng:s.png,isPrintingHtml:s.html,isPrinting:s.print}};var _e=require("react/jsx-runtime");function xf(){let{t:e}=(0,ye.useTranslation)(),{exportAsPng:t,exportAsHtml:o,printDiagram:n,isPrinting:r,isPrintingPng:i,isPrintingHtml:s}=hf(),[a,l]=(0,yf.useState)(!1);return(0,_e.jsxs)(ye.DropdownMenu,{modal:!1,open:a,onOpenChange:l,children:[(0,_e.jsx)(ye.DropdownMenuTrigger,{asChild:!0,children:(0,_e.jsx)("div",{children:(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,_e.jsx)(Go.FolderOutputIcon,{})})}),!a&&(0,_e.jsx)(ye.TooltipContent,{color:"black",children:e("editor.controls.actions.export.title")})]})})}),(0,_e.jsxs)(ye.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.DropdownMenuItem,{className:"p-1.5",disabled:i,onClick:()=>t(),children:(0,_e.jsx)(Go.FileImageIcon,{})})}),(0,_e.jsx)(ye.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.png")})]}),(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.DropdownMenuItem,{className:"p-1.5",disabled:s,onClick:()=>o(),children:(0,_e.jsx)(Go.FileCodeIcon,{})})}),(0,_e.jsx)(ye.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.html")})]}),(0,_e.jsxs)(ye.Tooltip,{children:[(0,_e.jsx)(ye.TooltipTrigger,{asChild:!0,children:(0,_e.jsx)(ye.DropdownMenuItem,{className:"p-1.5",disabled:r,onClick:()=>n(),children:(0,_e.jsx)(Go.PrinterIcon,{})})}),(0,_e.jsx)(ye.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.export.print")})]})]})]})}var we=require("@produto-lecom/lecom-ui"),Jn=require("lucide-react"),Fr=require("react");var Sa=require("react"),je=require("@produto-lecom/lecom-ui");var Ef=e=>{if(!e)return"";let t=e.trim();return t=t.replace(/```[a-zA-Z]*\s*/g,"").replace(/```/g,""),t=t.replace(/^\s*(graph|flowchart)\s+[A-Za-z]{1,2}\s*\r?\n/i,""),t.trim()};var Ot=require("react/jsx-runtime"),Zy=`Um passo (A --> B) por linha, com um ID antes de cada n\xF3. Ex.:
87
87
 
88
88
  A<start> --> B[Analisar pedido]
89
89
  B --> C{Aprovado?}
90
90
  C -- Sim --> D[Liberar pedido]
91
91
  C -- N\xE3o --> E[Recusar pedido]
92
92
  D --> F<end>
93
- E --> F<end>`,Ef=({open:e,onOpenChange:t})=>{let{t:o}=(0,je.useTranslation)(),{importFromLia:n}=xs(),[r,i]=(0,Sa.useState)(""),[s,a]=(0,Sa.useState)(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=xf(r);if(!d){a(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(u){console.error("Falha ao gerar o diagrama a partir de Mermaid:",u),a(o("editor.modals.mermaid_import.error_parse"))}};return(0,Ot.jsx)(je.Dialog,{open:e,onOpenChange:l,children:(0,Ot.jsxs)(je.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,Ot.jsxs)(je.DialogHeader,{children:[(0,Ot.jsx)(je.DialogTitle,{children:o("editor.modals.mermaid_import.title")}),(0,Ot.jsx)(je.DialogDescription,{children:o("editor.modals.mermaid_import.description")})]}),(0,Ot.jsx)(je.Textarea,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:qy,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&(0,Ot.jsx)("p",{className:"text-sm text-red-500",children:s}),(0,Ot.jsxs)(je.DialogFooter,{children:[(0,Ot.jsx)(je.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),(0,Ot.jsx)(je.Button,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};var be=require("react/jsx-runtime"),Zy=".xml,text/xml,application/xml";function _f(){let{t:e}=(0,Ne.useTranslation)(),{importFromMxGraph:t}=Ro(),{toast:o}=et(),[n,r]=(0,Fr.useState)(!1),[i,s]=(0,Fr.useState)(!1),a=(0,Fr.useRef)(null),l=async c=>{var u;let d=(u=c.target.files)==null?void 0:u[0];if(c.target.value="",!!d)try{let p=await vs(d);await t(p)}catch(p){console.error("Falha ao importar o XML:",p),o({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}};return(0,be.jsxs)(be.Fragment,{children:[(0,be.jsxs)(Ne.DropdownMenu,{modal:!1,open:n,onOpenChange:r,children:[(0,be.jsx)(Ne.DropdownMenuTrigger,{asChild:!0,children:(0,be.jsx)("div",{children:(0,be.jsxs)(Ne.Tooltip,{children:[(0,be.jsx)(Ne.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ne.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,be.jsx)(Zn.ClipboardPasteIcon,{})})}),!n&&(0,be.jsx)(Ne.TooltipContent,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),(0,be.jsxs)(Ne.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,be.jsxs)(Ne.Tooltip,{children:[(0,be.jsx)(Ne.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ne.DropdownMenuItem,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:(0,be.jsx)(Zn.FileCodeIcon,{})})}),(0,be.jsx)(Ne.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),(0,be.jsxs)(Ne.Tooltip,{children:[(0,be.jsx)(Ne.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(Ne.DropdownMenuItem,{className:"p-1.5",onClick:()=>s(!0),children:(0,be.jsx)(Zn.CircleIcon,{})})}),(0,be.jsx)(Ne.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),(0,be.jsx)("input",{ref:a,type:"file",className:"sr-only",accept:Zy,onChange:l}),(0,be.jsx)(Ef,{open:i,onOpenChange:s})]})}var Is=require("react"),we=require("@produto-lecom/lecom-ui"),bf=require("@xyflow/react"),Jn=require("lucide-react");var We=require("react/jsx-runtime");function Tf(){let{t:e}=(0,we.useTranslation)(),{getNodes:t,getEdges:o,setNodes:n}=(0,bf.useReactFlow)(),{fitToNodes:r}=ko(),{toast:i}=et(),[s,a]=(0,Is.useState)(!1),l=(0,Is.useCallback)(c=>{let d=t();if(d.length===0)return;if(d.some(g=>g.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let p=d.map(g=>{var y,m,x,T;return w(_({},g),{width:(m=g.width)!=null?m:(y=g.measured)==null?void 0:y.width,height:(T=g.height)!=null?T:(x=g.measured)==null?void 0:x.height})}),{nodes:f}=ss(p,o(),c),h=new Map(f.map(g=>[g.id,g.position])),E=d.map(g=>{var y;return w(_({},g),{position:(y=h.get(g.id))!=null?y:g.position})});n(E),r(E)},[t,o,n,r,i,e]);return(0,We.jsxs)(we.DropdownMenu,{modal:!1,open:s,onOpenChange:a,children:[(0,We.jsx)(we.DropdownMenuTrigger,{asChild:!0,children:(0,We.jsx)("div",{children:(0,We.jsxs)(we.Tooltip,{children:[(0,We.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,We.jsx)(Jn.NetworkIcon,{})})}),!s&&(0,We.jsx)(we.TooltipContent,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),(0,We.jsxs)(we.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,We.jsxs)(we.Tooltip,{children:[(0,We.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(we.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("TB"),children:(0,We.jsx)(Jn.AlignVerticalJustifyStartIcon,{})})}),(0,We.jsx)(we.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),(0,We.jsxs)(we.Tooltip,{children:[(0,We.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(we.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("LR"),children:(0,We.jsx)(Jn.AlignHorizontalJustifyStartIcon,{})})}),(0,We.jsx)(we.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}var ue=require("react/jsx-runtime"),Ma=Ft.default.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=(0,Ve.useTranslation)(),{clearSelection:r}=$t(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:f}=K(),{getNodes:h,getEdges:E}=(0,Wr.useReactFlow)(),g=(0,Wr.useKeyPress)(["v","V"],{target:s==null?void 0:s.current}),y=(0,Wr.useKeyPress)(["h","H"],{target:s==null?void 0:s.current}),m=(0,Ft.useCallback)(()=>{r(),f(!0),p(!1)},[r,f,p]),x=(0,Ft.useCallback)(()=>{p(!0),f(!1)},[p,f]),[T,b]=(0,Ft.useState)(!1),I=(0,Ft.useCallback)(async()=>{b(!0);try{let v=h(),N=E(),S=await t({nodes:v,edges:N});o(S)}finally{b(!1)}},[h,E,t,o]);return(0,Ft.useEffect)(()=>{g&&!d&&i==="edit"&&x()},[g,x,d,i]),(0,Ft.useEffect)(()=>{y&&!u&&i==="edit"&&m()},[y,m,u,i]),(0,ue.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(d&&"bg-grey-400"),iconButton:!0,onClick:x,children:(0,ue.jsx)(so.MousePointerIcon,{})})}),(0,ue.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),(0,ue.jsx)(wa,{shortcut:"V"})]})]}),(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(u&&"bg-grey-400"),iconButton:!0,onClick:m,children:(0,ue.jsx)(so.HandIcon,{})})}),(0,ue.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",(0,ue.jsx)(wa,{shortcut:"H"})]})]})]}),(0,ue.jsx)(yf,{}),i==="edit"&&(0,ue.jsxs)(ue.Fragment,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)(_f,{}),(0,ue.jsx)(Tf,{})]}),(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:T,onClick:I,children:T?(0,ue.jsx)(so.Loader2Icon,{className:"animate-spin"}):(0,ue.jsx)(so.ListCheckIcon,{})})}),(0,ue.jsx)(Ve.TooltipContent,{color:"black",children:n(T?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,ue.jsx)(af,{disabled:e})]}),(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:H(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:(0,ue.jsx)(so.MapIcon,{})})}),(0,ue.jsx)(Ve.TooltipContent,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Ma.displayName="ActionsControl";var vf=tr(require("react"),1),ht=require("@produto-lecom/lecom-ui"),As=require("lucide-react"),St=require("react/jsx-runtime"),Pa=vf.default.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,ht.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)(ht.Tooltip,{children:[(0,St.jsx)(ht.TooltipTrigger,{asChild:!0,children:(0,St.jsx)(ht.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,St.jsx)(As.UndoIcon,{})})}),(0,St.jsx)(ht.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,St.jsxs)(ht.Tooltip,{children:[(0,St.jsx)(ht.TooltipTrigger,{asChild:!0,children:(0,St.jsx)(ht.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,St.jsx)(As.RedoIcon,{})})}),(0,St.jsx)(ht.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})});Pa.displayName="HistoryControl";var Nf=require("@xyflow/react"),He=require("@produto-lecom/lecom-ui"),Qn=require("lucide-react");var Re=require("react/jsx-runtime"),wf=()=>{let{t:e}=(0,He.useTranslation)(),t=!bs(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=(0,Nf.useReactFlow)();return(0,Re.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:(0,Re.jsx)(Qn.ScanIcon,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:(0,Re.jsx)(Qn.ZoomOut,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:(0,Re.jsx)(el,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:(0,Re.jsx)(Qn.ZoomIn,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var If=require("@xyflow/react"),hn=require("react/jsx-runtime"),Af=()=>(0,hn.jsxs)(If.ViewportPortal,{children:[(0,hn.jsxs)("svg",{"data-export-hidden":!0,width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,hn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,hn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,hn.jsx)("div",{"data-export-hidden":!0,className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var Cf=require("@xyflow/react"),ao=require("@produto-lecom/lecom-ui"),Cs=require("react");var Sf=require("lucide-react");var Wt=require("react/jsx-runtime"),Mf=()=>{let e=(0,Cs.useRef)(null),{t}=(0,ao.useTranslation)(),{setDraggableNode:o}=Un(),n=(0,Cf.useStore)(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=K(),[i,s]=(0,Cs.useState)(void 0),a=[{type:"START_EVENT",icon:ti,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:xn,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:rr,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:ir,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:Sf.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ol,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:tl,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:bn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:vn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:En,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ja,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Qr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s((0,Wt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Wt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Wt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((c,d)=>{let u=c.type==="START_EVENT"&&n,p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Wt.jsxs)(ao.Tooltip,{children:[(0,Wt.jsx)(ao.TooltipTrigger,{asChild:!0,children:(0,Wt.jsx)(ao.Button,{className:H("[&>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,Wt.jsx)(c.icon,{})},d)}),(0,Wt.jsx)(ao.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Wt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var tt=require("react/jsx-runtime"),La=e=>e.preventDefault(),ka=(0,yn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a}=K(),l=(0,lo.useKeyPress)("Space",{target:n==null?void 0:n.current}),c=(0,yn.useRef)(a),d=(0,yn.useRef)(l),{nodes:u,edges:p,actions:f,events:h,components:E,controls:g}=Gp(),{t:y}=(0,Bo.useTranslation)(),m=bs();c.current=a,d.current=l;let x=Fp(n,c,d);(0,yn.useImperativeHandle)(t,()=>({selectElements:f.selectElements,clearSelection:f.clearSelection}));let T=a||l||r!=="edit",b=T?Xu:kr,I=a||l||x,v=s&&!l&&!x,N=r==="edit"&&v,S=!T&&!x,M=r==="view"||v;return(0,tt.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,tt.jsx)(Mf,{}),(0,tt.jsx)(Wp,{}),(0,tt.jsxs)(lo.ReactFlow,w(_({},h),{id:`modeler-${o}`,className:H(r.toLowerCase(),{"is-hand-tool":I,"is-pan-tool-active":I}),edges:p,nodes:u,nodeTypes:Mu,edgeTypes:Pu,onlyRenderVisibleElements:!0,minZoom:_a,maxZoom:Vu,panOnDrag:b,panOnScroll:!0,selectionOnDrag:S,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:M,nodesConnectable:N,nodesDraggable:N,connectionLineComponent:Cu,selectionMode:lo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:N?"Delete":null,selectionKeyCode:null,defaultViewport:Yu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:La,onNodeContextMenu:La,onEdgeContextMenu:La,proOptions:Uu,children:[(0,tt.jsx)(lo.Background,{gap:Du,size:Ru,color:ku,bgColor:Lu}),(0,tt.jsx)(Af,{}),i&&(0,tt.jsxs)(Bo.Tooltip,{children:[(0,tt.jsx)(Bo.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,tt.jsx)(lo.MiniMap,{pannable:!0,zoomable:!0,position:Ou,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,tt.jsx)(Bo.TooltipContent,{color:"black",children:y("editor.controls.actions.minimap.label")})]}),(0,tt.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,tt.jsx)(Pa,_({},g)),r!=="readonly"&&(0,tt.jsx)(Ma,{hasContent:m,validateDiagram:f.validateDiagram,handleValidationComplete:f.handleValidationComplete}),(0,tt.jsx)(wf,{})]}),(0,tt.jsx)(E.HelperLines,{})]}))]})});ka.displayName="Editor";var Pf=require("@xyflow/react"),Xr=require("react"),Lf=require("react/jsx-runtime"),Jy=e=>({width:e.width,height:e.height,transform:e.transform}),Ra="rgba(51, 103, 217, 0.4)",pd=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Pf.useStore)(Jy),i=(0,Xr.useRef)(null),s=(0,Xr.useRef)(1);return(0,Xr.useEffect)(()=>{let a=i.current,l=a==null?void 0:a.getContext("2d");if(!l||!a)return;let c=Math.min(window.devicePixelRatio||1,2),d=Math.ceil(o*c),u=Math.ceil(n*c);(a.width!==d||a.height!==u)&&(a.width=d,a.height=u,s.current=c),l.setTransform(s.current,0,0,s.current,0,0),l.clearRect(0,0,o,n),l.strokeStyle=Ra,t&&(l.beginPath(),l.strokeStyle=t.color||Ra,l.moveTo(t.position*r[2]+r[0],0),l.lineTo(t.position*r[2]+r[0],n),l.stroke()),e&&(l.beginPath(),l.strokeStyle=e.color||Ra,l.moveTo(0,e.position*r[2]+r[1]),l.lineTo(o,e.position*r[2]+r[1]),l.stroke())},[o,n,r,e,t]),(0,Lf.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var jn=require("@produto-lecom/lecom-ui"),zo=require("react");var Ur=require("react/jsx-runtime"),to=new Map,kf=(0,zo.createContext)(null),Rn=()=>{let e=(0,zo.useContext)(kf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Rf=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=(0,zo.useState)(e||"pt_BR");(0,zo.useEffect)(()=>{e&&(s(e),jn.i18n.changeLanguage(e))},[e]);let a=E=>{let g=to.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!E){let[m]=to.values();return m}let y=to.get(E);if(!y)throw new Error(`Modeler instance with ID "${E}" not found`);return y},l=(E,g)=>{let y=a(g);return y==null?void 0:y.selectElements(E)},c=async E=>{let g=a(E);return g==null?void 0:g.clearSelection()},d=(E,g)=>{let y=a(g);return y==null?void 0:y.configureElement(E)},u=(E,g)=>{let y=a(g);return y==null?void 0:y.getConfigureElement(E)},p=async(E,g)=>{let y=a(g);await(y==null?void 0:y.importFromMxGraph(E))},f=E=>{let g=a(E);return g==null?void 0:g.exportToMxGraph()},h=E=>{let g=a(E);return(g==null?void 0:g.getElementsCount())||0};return(0,Ur.jsx)(kf.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:f,getElementsCount:h,toast:n},children:(0,Ur.jsxs)(jn.TooltipProvider,{children:[!n&&(0,Ur.jsx)(jn.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var Ss=require("react/jsx-runtime"),Vf=(0,Ie.createContext)(null),K=()=>{let e=(0,Ie.useContext)(Vf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Hf=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d})=>{let u=(0,Ie.useRef)(null),{t:p}=(0,Df.useTranslation)(),{defaultMode:f,featureFlags:h}=Rn(),E=(0,Ie.useId)(),[g]=(0,Ie.useState)(o||E),[y,m]=(0,Ie.useState)(n||f||"edit"),[x,T]=(0,Ie.useState)(Ar),[b,I]=(0,Ie.useState)(!1),[v,N]=(0,Ie.useState)(!0),[S,M]=(0,Ie.useState)(!1),[L,k]=(0,Ie.useState)(!1),[O,G]=(0,Ie.useState)(!1),[Y,j]=(0,Ie.useState)(!1),[q,U]=(0,Ie.useState)(!1),[A,P]=(0,Ie.useState)(null);(0,Ie.useEffect)(()=>{n&&m(n)},[n]);let R=!t,C=(0,Ie.useMemo)(()=>t||zd(p),[t,p]),B=(0,Ie.useMemo)(()=>({instanceId:g,containerRef:u,initialDiagram:C,mode:y,featureFlags:h,edgeHighlight:r,isEdit:y==="edit",isView:y==="view",isReadOnly:y==="readonly",isNewDiagram:R,lastElementId:x,isInitialized:b,isMinimapOpen:L,isMoveTool:v,isHandTool:S,isDragging:O,isConnecting:Y,isRemovingElements:q,setLastElementId:T,setIsInitialized:I,reconnectingEdgeId:A,setIsMinimapOpen:k,setIsMoveTool:N,setIsHandTool:M,setIsDragging:G,setIsConnecting:j,setIsRemovingElements:U,setReconnectingEdgeId:P,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d}),[g,u,C,y,h,r,R,x,b,L,v,S,O,Y,q,A,i,s,a,l,c,d]);return(0,Ss.jsx)(Of.ReactFlowProvider,{children:(0,Ss.jsx)(Vf.Provider,{value:B,children:(0,Ss.jsx)(ka,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});
93
+ E --> F<end>`,_f=({open:e,onOpenChange:t})=>{let{t:o}=(0,je.useTranslation)(),{importFromLia:n}=xs(),[r,i]=(0,Sa.useState)(""),[s,a]=(0,Sa.useState)(null),l=d=>{d||(i(""),a(null)),t(d)},c=()=>{let d=Ef(r);if(!d){a(o("editor.modals.mermaid_import.error_empty"));return}try{n(d),l(!1)}catch(u){console.error("Falha ao gerar o diagrama a partir de Mermaid:",u),a(o("editor.modals.mermaid_import.error_parse"))}};return(0,Ot.jsx)(je.Dialog,{open:e,onOpenChange:l,children:(0,Ot.jsxs)(je.DialogContent,{className:"w-[90vw] max-w-4xl",children:[(0,Ot.jsxs)(je.DialogHeader,{children:[(0,Ot.jsx)(je.DialogTitle,{children:o("editor.modals.mermaid_import.title")}),(0,Ot.jsx)(je.DialogDescription,{children:o("editor.modals.mermaid_import.description")})]}),(0,Ot.jsx)(je.Textarea,{value:r,onChange:d=>{i(d.target.value),s&&a(null)},placeholder:Zy,rows:16,className:"max-h-[60vh] min-h-[360px] resize-y font-mono"}),s&&(0,Ot.jsx)("p",{className:"text-sm text-red-500",children:s}),(0,Ot.jsxs)(je.DialogFooter,{children:[(0,Ot.jsx)(je.Button,{variant:"ghost",color:"grey",onClick:()=>l(!1),children:o("editor.modals.mermaid_import.cancel")}),(0,Ot.jsx)(je.Button,{variant:"filled",color:"blue",onClick:c,children:o("editor.modals.mermaid_import.generate")})]})]})})};var be=require("react/jsx-runtime"),Jy=".xml,text/xml,application/xml";function bf(){let{t:e}=(0,we.useTranslation)(),{importFromMxGraph:t}=Ro(),{toast:o}=et(),[n,r]=(0,Fr.useState)(!1),[i,s]=(0,Fr.useState)(!1),a=(0,Fr.useRef)(null),l=async c=>{var u;let d=(u=c.target.files)==null?void 0:u[0];if(c.target.value="",!!d)try{let p=await vs(d);await t(p)}catch(p){console.error("Falha ao importar o XML:",p),o({variant:"error",content:e("editor.controls.actions.import.feedback.error")})}};return(0,be.jsxs)(be.Fragment,{children:[(0,be.jsxs)(we.DropdownMenu,{modal:!1,open:n,onOpenChange:r,children:[(0,be.jsx)(we.DropdownMenuTrigger,{asChild:!0,children:(0,be.jsx)("div",{children:(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,be.jsx)(Jn.ClipboardPasteIcon,{})})}),!n&&(0,be.jsx)(we.TooltipContent,{color:"black",children:e("editor.controls.actions.import.title")})]})})}),(0,be.jsxs)(we.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.DropdownMenuItem,{className:"p-1.5",onClick:()=>{var c;return(c=a.current)==null?void 0:c.click()},children:(0,be.jsx)(Jn.FileCodeIcon,{})})}),(0,be.jsx)(we.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.xml")})]}),(0,be.jsxs)(we.Tooltip,{children:[(0,be.jsx)(we.TooltipTrigger,{asChild:!0,children:(0,be.jsx)(we.DropdownMenuItem,{className:"p-1.5",onClick:()=>s(!0),children:(0,be.jsx)(Jn.CircleIcon,{})})}),(0,be.jsx)(we.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.import.mermaid")})]})]})]}),(0,be.jsx)("input",{ref:a,type:"file",className:"sr-only",accept:Jy,onChange:l}),(0,be.jsx)(_f,{open:i,onOpenChange:s})]})}var Is=require("react"),Ie=require("@produto-lecom/lecom-ui"),Tf=require("@xyflow/react"),Qn=require("lucide-react");var We=require("react/jsx-runtime");function vf(){let{t:e}=(0,Ie.useTranslation)(),{getNodes:t,getEdges:o,setNodes:n}=(0,Tf.useReactFlow)(),{fitToNodes:r}=ko(),{toast:i}=et(),[s,a]=(0,Is.useState)(!1),l=(0,Is.useCallback)(c=>{let d=t();if(d.length===0)return;if(d.some(g=>g.parentId)){i({content:e("editor.controls.actions.organize.feedback.pool_lane"),variant:"warning"});return}let p=d.map(g=>{var h,f,y,T;return w(_({},g),{width:(f=g.width)!=null?f:(h=g.measured)==null?void 0:h.width,height:(T=g.height)!=null?T:(y=g.measured)==null?void 0:y.height})}),{nodes:m}=os(p,o(),c),x=new Map(m.map(g=>[g.id,g.position])),E=d.map(g=>{var h;return w(_({},g),{position:(h=x.get(g.id))!=null?h:g.position})});n(E),r(E)},[t,o,n,r,i,e]);return(0,We.jsxs)(Ie.DropdownMenu,{modal:!1,open:s,onOpenChange:a,children:[(0,We.jsx)(Ie.DropdownMenuTrigger,{asChild:!0,children:(0,We.jsx)("div",{children:(0,We.jsxs)(Ie.Tooltip,{children:[(0,We.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(Ie.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,children:(0,We.jsx)(Qn.NetworkIcon,{})})}),!s&&(0,We.jsx)(Ie.TooltipContent,{color:"black",children:e("editor.controls.actions.organize.title")})]})})}),(0,We.jsxs)(Ie.DropdownMenuContent,{align:"center",side:"top",sideOffset:16,className:"min-w-0 flex flex-col gap-2 p-2 shadow-sm",children:[(0,We.jsxs)(Ie.Tooltip,{children:[(0,We.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(Ie.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("TB"),children:(0,We.jsx)(Qn.AlignVerticalJustifyStartIcon,{})})}),(0,We.jsx)(Ie.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.vertical")})]}),(0,We.jsxs)(Ie.Tooltip,{children:[(0,We.jsx)(Ie.TooltipTrigger,{asChild:!0,children:(0,We.jsx)(Ie.DropdownMenuItem,{className:"p-1.5",onClick:()=>l("LR"),children:(0,We.jsx)(Qn.AlignHorizontalJustifyStartIcon,{})})}),(0,We.jsx)(Ie.TooltipContent,{side:"right",color:"black",children:e("editor.controls.actions.organize.horizontal")})]})]})]})}var ue=require("react/jsx-runtime"),Ma=Ft.default.memo(({hasContent:e,validateDiagram:t,handleValidationComplete:o})=>{let{t:n}=(0,Ve.useTranslation)(),{clearSelection:r}=$t(),{mode:i,containerRef:s,featureFlags:a,isMinimapOpen:l,setIsMinimapOpen:c,isMoveTool:d,isHandTool:u,setIsMoveTool:p,setIsHandTool:m}=U(),{getNodes:x,getEdges:E}=(0,Wr.useReactFlow)(),g=(0,Wr.useKeyPress)(["v","V"],{target:s==null?void 0:s.current}),h=(0,Wr.useKeyPress)(["h","H"],{target:s==null?void 0:s.current}),f=(0,Ft.useCallback)(()=>{r(),m(!0),p(!1)},[r,m,p]),y=(0,Ft.useCallback)(()=>{p(!0),m(!1)},[p,m]),[T,b]=(0,Ft.useState)(!1),I=(0,Ft.useCallback)(async()=>{b(!0);try{let v=x(),N=E(),C=await t({nodes:v,edges:N});o(C)}finally{b(!1)}},[x,E,t,o]);return(0,Ft.useEffect)(()=>{g&&!d&&i==="edit"&&y()},[g,y,d,i]),(0,Ft.useEffect)(()=>{h&&!u&&i==="edit"&&f()},[h,f,u,i]),(0,ue.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[i==="edit"&&(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:G(d&&"bg-grey-400"),iconButton:!0,onClick:y,children:(0,ue.jsx)(so.MousePointerIcon,{})})}),(0,ue.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.move_tool"),(0,ue.jsx)(wa,{shortcut:"V"})]})]}),(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:G(u&&"bg-grey-400"),iconButton:!0,onClick:f,children:(0,ue.jsx)(so.HandIcon,{})})}),(0,ue.jsxs)(Ve.TooltipContent,{color:"black",className:"flex items-center gap-2",children:[n("editor.controls.actions.hand_tool")," ",(0,ue.jsx)(wa,{shortcut:"H"})]})]})]}),(0,ue.jsx)(xf,{}),i==="edit"&&(0,ue.jsxs)(ue.Fragment,{children:[(a==null?void 0:a.importDiagramMermaidEnabled)&&(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)(bf,{}),(0,ue.jsx)(vf,{})]}),(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:T,onClick:I,children:T?(0,ue.jsx)(so.Loader2Icon,{className:"animate-spin"}):(0,ue.jsx)(so.ListCheckIcon,{})})}),(0,ue.jsx)(Ve.TooltipContent,{color:"black",children:n(T?"editor.controls.actions.check_loading":"editor.controls.actions.check")})]}),(0,ue.jsx)(lf,{disabled:e})]}),(0,ue.jsxs)(Ve.Tooltip,{children:[(0,ue.jsx)(Ve.TooltipTrigger,{asChild:!0,children:(0,ue.jsx)(Ve.Button,{size:"small",variant:"ghost",color:"grey",className:G(l&&"bg-grey-400"),iconButton:!0,onClick:()=>c(!l),children:(0,ue.jsx)(so.MapIcon,{})})}),(0,ue.jsx)(Ve.TooltipContent,{color:"black",children:n(l?"editor.controls.actions.minimap.close":"editor.controls.actions.minimap.open")})]})]})});Ma.displayName="ActionsControl";var Nf=or(require("react"),1),ht=require("@produto-lecom/lecom-ui"),As=require("lucide-react"),St=require("react/jsx-runtime"),Pa=Nf.default.memo(({undo:e,redo:t,canUndo:o,canRedo:n})=>{let{t:r}=(0,ht.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)(ht.Tooltip,{children:[(0,St.jsx)(ht.TooltipTrigger,{asChild:!0,children:(0,St.jsx)(ht.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!o,onClick:e,children:(0,St.jsx)(As.UndoIcon,{})})}),(0,St.jsx)(ht.TooltipContent,{color:"black",children:r("editor.controls.history.undo")})]}),(0,St.jsxs)(ht.Tooltip,{children:[(0,St.jsx)(ht.TooltipTrigger,{asChild:!0,children:(0,St.jsx)(ht.Button,{size:"small",variant:"ghost",color:"grey",iconButton:!0,disabled:!n,onClick:t,children:(0,St.jsx)(As.RedoIcon,{})})}),(0,St.jsx)(ht.TooltipContent,{color:"black",children:r("editor.controls.history.redo")})]})]})});Pa.displayName="HistoryControl";var wf=require("@xyflow/react"),He=require("@produto-lecom/lecom-ui"),jn=require("lucide-react");var Re=require("react/jsx-runtime"),If=()=>{let{t:e}=(0,He.useTranslation)(),t=!bs(),{zoomIn:o,zoomOut:n,zoomTo:r,fitView:i}=(0,wf.useReactFlow)();return(0,Re.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 bg-white rounded-sm shadow-md",children:[(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>i(),children:(0,Re.jsx)(jn.ScanIcon,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.fit")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>n(),children:(0,Re.jsx)(jn.ZoomOut,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.out")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>r(1),children:(0,Re.jsx)(el,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.reset")})]}),(0,Re.jsxs)(He.Tooltip,{children:[(0,Re.jsx)(He.TooltipTrigger,{asChild:!0,children:(0,Re.jsx)(He.Button,{iconButton:!0,size:"small",color:"grey",variant:"ghost",disabled:t,onClick:()=>o(),children:(0,Re.jsx)(jn.ZoomIn,{})})}),(0,Re.jsx)(He.TooltipContent,{color:"black",children:e("editor.controls.zoom.in")})]})]})};var Af=require("@xyflow/react"),yn=require("react/jsx-runtime"),Cf=()=>(0,yn.jsxs)(Af.ViewportPortal,{children:[(0,yn.jsxs)("svg",{"data-export-hidden":!0,width:"20",height:"20",viewBox:"0 0 20 20",className:"text-grey-400 -translate-x-1/2 -translate-y-1/2 pointer-events-none",children:[(0,yn.jsx)("line",{x1:"0",y1:"10",x2:"20",y2:"10",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"}),(0,yn.jsx)("line",{x1:"10",y1:"0",x2:"10",y2:"20",stroke:"currentcolor",strokeWidth:"1.5",strokeDasharray:"2 1"})]}),(0,yn.jsx)("div",{"data-export-hidden":!0,className:"absolute top-1 left-1 text-xs font-medium text-grey-400 bg-white/70 px-1 rounded-sm pointer-events-none",children:"0,0"})]});var Sf=require("@xyflow/react"),ao=require("@produto-lecom/lecom-ui"),Cs=require("react");var Mf=require("lucide-react");var Wt=require("react/jsx-runtime"),Pf=()=>{let e=(0,Cs.useRef)(null),{t}=(0,ao.useTranslation)(),{setDraggableNode:o}=$n(),n=(0,Sf.useStore)(c=>c.nodes.some(d=>d.type==="START_EVENT")),{setIsDragging:r}=U(),[i,s]=(0,Cs.useState)(void 0),a=[{type:"START_EVENT",icon:ti,label:t("bpmn.start_event.variant.default")},{type:"END_EVENT",icon:En,label:t("bpmn.end_event.variant.default")},{type:"TASK",icon:ir,label:t("bpmn.task.variant.default")},{type:"TASK",variant:"SUBPROCESS",icon:sr,label:t("bpmn.task.variant.subprocess")},{type:"TASK",variant:"SERVICE_TASK",icon:Mf.Bot,label:t("bpmn.task.variant.service_task")},{type:"TASK",variant:"SCRIPT",icon:ol,label:t("bpmn.task.variant.script")},{type:"TASK",attribute:"LOOP",icon:tl,label:t("bpmn.task.attribute.loop")},{type:"GATEWAY",variant:"EXCLUSIVE",icon:Tn,label:t("bpmn.gateway.variant.exclusive")},{type:"GATEWAY",variant:"PARALLEL",icon:Nn,label:t("bpmn.gateway.variant.parallel")},{type:"GATEWAY",variant:"COMPLEX",icon:_n,label:t("bpmn.gateway.variant.complex")},{type:"LANE",icon:ja,label:t("bpmn.lane.variant.default")},{type:"ANNOTATION",icon:Qr,label:t("bpmn.annotation.variant.default")}],l=(c,d)=>{o({type:d.type,variant:d.variant,attribute:d.attribute,icon:d.icon}),s((0,Wt.jsx)(d.icon,{})),c.dataTransfer.effectAllowed="move",e.current&&c.dataTransfer.setDragImage(e.current,10,10),setTimeout(()=>{r(!0)},100)};return(0,Wt.jsxs)("aside",{className:"sidebar absolute z-[1] top-4 left-4",children:[(0,Wt.jsx)("div",{className:"grid grid-cols-1 gap-2 p-2 bg-white rounded-md shadow-md",children:a.map((c,d)=>{let u=c.type==="START_EVENT"&&n,p=u?t("editor.toolbar.start_event_already_exists"):c.label;return(0,Wt.jsxs)(ao.Tooltip,{children:[(0,Wt.jsx)(ao.TooltipTrigger,{asChild:!0,children:(0,Wt.jsx)(ao.Button,{className:G("[&>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:m=>l(m,c),children:(0,Wt.jsx)(c.icon,{})},d)}),(0,Wt.jsx)(ao.TooltipContent,{color:"black",side:"right",children:p})]},d)})}),(0,Wt.jsx)("div",{ref:e,className:"absolute w-0 h-0 top-0 left-0 z-[-1] bg-transparent",children:i})]})};var tt=require("react/jsx-runtime"),La=e=>e.preventDefault(),ka=(0,xn.forwardRef)((e,t)=>{let{instanceId:o,containerRef:n,mode:r,isMinimapOpen:i,isMoveTool:s,isHandTool:a,isExporting:l}=U(),c=(0,lo.useKeyPress)("Space",{target:n==null?void 0:n.current}),d=(0,xn.useRef)(a),u=(0,xn.useRef)(c),{nodes:p,edges:m,actions:x,events:E,components:g,controls:h}=Bp(),{t:f}=(0,Bo.useTranslation)(),y=bs();d.current=a,u.current=c;let T=Wp(n,d,u);(0,xn.useImperativeHandle)(t,()=>({selectElements:x.selectElements,clearSelection:x.clearSelection}));let b=a||c||r!=="edit",I=b?Uu:kr,v=a||c||T,N=s&&!c&&!T,C=r==="edit"&&N,M=!b&&!T,L=r==="view"||N;return(0,tt.jsxs)("div",{ref:n,className:"w-full h-full outline-none",tabIndex:0,children:[r==="edit"&&(0,tt.jsx)(Pf,{}),(0,tt.jsx)(Xp,{}),(0,tt.jsxs)(lo.ReactFlow,w(_({},E),{id:`modeler-${o}`,className:G(r.toLowerCase(),{"is-hand-tool":v,"is-pan-tool-active":v}),edges:m,nodes:p,nodeTypes:Pu,edgeTypes:Lu,onlyRenderVisibleElements:!l,minZoom:_a,maxZoom:Hu,panOnDrag:I,panOnScroll:!0,selectionOnDrag:M,elevateEdgesOnSelect:!0,elevateNodesOnSelect:!0,elementsSelectable:L,nodesConnectable:C,nodesDraggable:C,connectionLineComponent:Su,selectionMode:lo.SelectionMode.Partial,multiSelectionKeyCode:["Control","Meta"],deleteKeyCode:C?"Delete":null,selectionKeyCode:null,defaultViewport:Fu,connectOnClick:!1,connectionRadius:50,onPaneContextMenu:La,onNodeContextMenu:La,onEdgeContextMenu:La,proOptions:$u,children:[(0,tt.jsx)(lo.Background,{gap:Ou,size:Du,color:Ru,bgColor:ku}),(0,tt.jsx)(Cf,{}),i&&(0,tt.jsxs)(Bo.Tooltip,{children:[(0,tt.jsx)(Bo.TooltipTrigger,{asChild:!0,children:(0,tt.jsx)("div",{className:"absolute bottom-[0px] left-[0px] z-[5]",children:(0,tt.jsx)(lo.MiniMap,{pannable:!0,zoomable:!0,position:Vu,className:"shadow-md rounded-md",ariaLabel:"",style:{pointerEvents:"all",position:"relative"}})})}),(0,tt.jsx)(Bo.TooltipContent,{color:"black",children:f("editor.controls.actions.minimap.label")})]}),(0,tt.jsxs)("div",{className:"absolute z-10 bottom-4 left-1/2 -translate-x-1/2 flex gap-4",children:[r==="edit"&&(0,tt.jsx)(Pa,_({},h)),r!=="readonly"&&(0,tt.jsx)(Ma,{hasContent:y,validateDiagram:x.validateDiagram,handleValidationComplete:x.handleValidationComplete}),(0,tt.jsx)(If,{})]}),(0,tt.jsx)(g.HelperLines,{})]}))]})});ka.displayName="Editor";var Lf=require("@xyflow/react"),Xr=require("react"),kf=require("react/jsx-runtime"),Qy=e=>({width:e.width,height:e.height,transform:e.transform}),Ra="rgba(51, 103, 217, 0.4)",pd=({horizontal:e,vertical:t})=>{let{width:o,height:n,transform:r}=(0,Lf.useStore)(Qy),i=(0,Xr.useRef)(null),s=(0,Xr.useRef)(1);return(0,Xr.useEffect)(()=>{let a=i.current,l=a==null?void 0:a.getContext("2d");if(!l||!a)return;let c=Math.min(window.devicePixelRatio||1,2),d=Math.ceil(o*c),u=Math.ceil(n*c);(a.width!==d||a.height!==u)&&(a.width=d,a.height=u,s.current=c),l.setTransform(s.current,0,0,s.current,0,0),l.clearRect(0,0,o,n),l.strokeStyle=Ra,t&&(l.beginPath(),l.strokeStyle=t.color||Ra,l.moveTo(t.position*r[2]+r[0],0),l.lineTo(t.position*r[2]+r[0],n),l.stroke()),e&&(l.beginPath(),l.strokeStyle=e.color||Ra,l.moveTo(0,e.position*r[2]+r[1]),l.lineTo(o,e.position*r[2]+r[1]),l.stroke())},[o,n,r,e,t]),(0,kf.jsx)("canvas",{ref:i,className:"w-full h-full absolute z-10 pointer-events-none"})};var er=require("@produto-lecom/lecom-ui"),zo=require("react");var Ur=require("react/jsx-runtime"),to=new Map,Rf=(0,zo.createContext)(null),Dn=()=>{let e=(0,zo.useContext)(Rf);if(!e)throw new Error("useModeler must be used within an <ModelerProvider />");return e},Df=({locale:e,defaultMode:t="view",featureFlags:o,toast:n,children:r})=>{let[i,s]=(0,zo.useState)(e||"pt_BR");(0,zo.useEffect)(()=>{e&&(s(e),er.i18n.changeLanguage(e))},[e]);let a=E=>{let g=to.size;if(g===0)throw new Error("No modeler instances found");if(g===1||!E){let[f]=to.values();return f}let h=to.get(E);if(!h)throw new Error(`Modeler instance with ID "${E}" not found`);return h},l=(E,g)=>{let h=a(g);return h==null?void 0:h.selectElements(E)},c=async E=>{let g=a(E);return g==null?void 0:g.clearSelection()},d=(E,g)=>{let h=a(g);return h==null?void 0:h.configureElement(E)},u=(E,g)=>{let h=a(g);return h==null?void 0:h.getConfigureElement(E)},p=async(E,g)=>{let h=a(g);await(h==null?void 0:h.importFromMxGraph(E))},m=E=>{let g=a(E);return g==null?void 0:g.exportToMxGraph()},x=E=>{let g=a(E);return(g==null?void 0:g.getElementsCount())||0};return(0,Ur.jsx)(Rf.Provider,{value:{defaultMode:t,locale:i,featureFlags:o,selectElements:l,clearSelection:c,configureElement:d,getConfigureElement:u,importDiagram:p,exportDiagram:m,getElementsCount:x,toast:n},children:(0,Ur.jsxs)(er.TooltipProvider,{children:[!n&&(0,Ur.jsx)(er.Notification,{type:"toast",placement:"topRight",enableClose:!0,showProgress:!0,pauseOnHover:!0}),r]})})};var Ss=require("react/jsx-runtime"),Hf=(0,Te.createContext)(null),U=()=>{let e=(0,Te.useContext)(Hf);if(!e)throw new Error("useModelerInstance must be used within an <Modeler />");return e},Gf=({selectorRef:e,initialDiagram:t,instanceId:o,mode:n,edgeHighlight:r=!0,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d})=>{let u=(0,Te.useRef)(null),{t:p}=(0,Of.useTranslation)(),{defaultMode:m,featureFlags:x}=Dn(),E=(0,Te.useId)(),[g]=(0,Te.useState)(o||E),[h,f]=(0,Te.useState)(n||m||"edit"),[y,T]=(0,Te.useState)(Ar),[b,I]=(0,Te.useState)(!1),[v,N]=(0,Te.useState)(!0),[C,M]=(0,Te.useState)(!1),[L,R]=(0,Te.useState)(!1),[O,V]=(0,Te.useState)(!1),[Y,j]=(0,Te.useState)(!1),[q,$]=(0,Te.useState)(!1),[A,P]=(0,Te.useState)(!1),[k,S]=(0,Te.useState)(null);(0,Te.useEffect)(()=>{n&&f(n)},[n]);let B=!t,F=(0,Te.useMemo)(()=>t||$d(p),[t,p]),D=(0,Te.useMemo)(()=>({instanceId:g,containerRef:u,initialDiagram:F,mode:h,featureFlags:x,edgeHighlight:r,isEdit:h==="edit",isView:h==="view",isReadOnly:h==="readonly",isNewDiagram:B,lastElementId:y,isInitialized:b,isMinimapOpen:L,isMoveTool:v,isHandTool:C,isDragging:O,isConnecting:Y,isRemovingElements:q,isExporting:A,setLastElementId:T,setIsInitialized:I,reconnectingEdgeId:k,setIsMinimapOpen:R,setIsMoveTool:N,setIsHandTool:M,setIsDragging:V,setIsConnecting:j,setIsRemovingElements:$,setIsExporting:P,setReconnectingEdgeId:S,validateCustomDiagram:i,validateDeleteElements:s,onElementChanges:a,onConfigureElement:l,onElementClick:c,onSubprocessValidationClick:d}),[g,u,F,h,x,r,B,y,b,L,v,C,O,Y,q,A,k,i,s,a,l,c,d]);return(0,Ss.jsx)(Vf.ReactFlowProvider,{children:(0,Ss.jsx)(Hf.Provider,{value:D,children:(0,Ss.jsx)(ka,{ref:e})})})};0&&(module.exports={EditorMode,ElementPosition,ElementType,GatewayElementVariant,GatewayVariant,Modeler,ModelerProvider,NodeAttribute,NodeType,NodeVariant,RoutingVariant,useModeler});